akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int K,S; cin>>K>>S;

    int ans = 0;
    REP(x, K+1) {
        REP(y, K+1) {
            int z = S - x - y;
            if (0<= z and z <= K)
                ans += 1;
        }
    }

    cout << ans << endl;


    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	ll N;
	cin >> N;
	reps(i, 1, 3501) {
		reps(j, 1, 3501) {
			ll x = i*j;
			ll y = i + j;
			if (4 * x - N*y <= 0)continue;
			if (N*x%(4*x-N*y) == 0) {
				cout << N*x / (4 * x - N*y) << " " << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	
	/*
	int A,B,C,D,seconds,minutes;
	cin >> A >> B >> C >> D;
	seconds=A+B+C+D;
	minutes = seconds / 60;
	cout << minutes << seconds << endl;*/
	 
	/*int Q,P,R;
	cin >> Q >> P >>R;
	int answer;
	answer=Q*P/2;
	cout << answer << endl;*/

	/*int A,B;
	cin >> A >> B;
	int answer;
	answer=(A-1)*(B-1);
	cout << answer << endl;*/

	/*int A,A2,A3,Asecond,Aminutes,Ahour,Asecond2,Aminutes2,Ahour2;

    cin >>Ahour >> Aminutes>>Asecond>>Ahour2 >>Aminutes2>>Asecond2;
	A=Ahour2-Ahour;
	A2=Aminutes2-Aminutes;
	A3=Asecond2-Asecond;
	if(A3<0){
		A2=A2-1;
		A3=60+A3;

	}
	if(A2<0){
		A=A-1;
		A2=60+A2;

	}

	cout << A << " " << A2 << " " << A3 << endl;

	
	cin >>Ahour >> Aminutes>>Asecond>>Ahour2 >>Aminutes2>>Asecond2;
	A=Ahour2-Ahour;
	A2=Aminutes2-Aminutes;
	A3=Asecond2-Asecond;
	if(A3<0){
		A2=A2-1;
		A3=60+A3;

	}
	if(A2<0){
		A=A-1;
		A2=60+A2;

	}

	cout << A << " " << A2 << " " << A3 << endl;

	cin >>Ahour >> Aminutes>>Asecond>>Ahour2 >>Aminutes2>>Asecond2;
	A=Ahour2-Ahour;
	A2=Aminutes2-Aminutes;
	A3=Asecond2-Asecond;
	if(A3<0){
		A2=A2-1;
		A3=60+A3;

	}
	if(A2<0){
		A=A-1;
		A2=60+A2;

	}

	cout << A << " " << A2 << " " << A3 << endl;*/
	/*
	int A,B,C,D,E,F,G,answer;

	cin >>A;
	A=1000-A;
	B=A/500;
	A=A-500*B;
	C=A/100;
	A=A-100*C;
	D=A/50;
	A=A-50*D;
	E=A/10;
	A=A-10*E;
	F=A/5;
	A=A-5*F;
	G=A/1;

	answer=B+C+D+E+F+G;

	cout <<answer <<endl;
	*/

	/*int S,A1,A2,A3,A4,T,B1,B2,B3,B4,answer;

	cin >>A1 >> A2 >> A3 >>A4 >>B1 >>B2 >> B3 >> B4;
	S=A1+A2+A3+A4;
	T=B1+B2+B3+B4;
	if (S<T){
		answer=T;
	}
	else if(S>T){
		answer=S;
	}
	else if(S==T){
		answer=S;
	}
	cout <<answer <<endl;*/

	/*int A,B,C,D,E,P,J;
	cin >> A >> B >> C >> D >> E;
	P=min(A,B);
	P=min(P,C);
	J=min(D,E);
	
	int answer;
	answer=P+J-50;
	cout << answer << endl;*/

    /*int A,B,C,i,coin;
    cin >> A >> B >> C;
	i=0;
	coin=0;
	while(coin<C){
		i=i+1;
		coin=coin+A;
	    if(i%7==0){
			coin=coin+B;
		}
	}
	cout<< i << endl;*/

	int A,B,K;
	cin >> A >> B >> K;
	int j=A+B;
	int i=0;

    while(i < K){
		j--;
		if(A%j==0 && B%j==0){
			i++;
		}
	}
	cout<< j << endl;
	


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF (1e9)
#define N 16
#define M 4
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;


int n, h[N], w[N];

string s[M];

int d[(1<<N)];

queue<P> q;

set<P1> Range;

void init(){

  for(int idx=0;idx<N;idx++){
    int y=idx/M, x=idx%M;
    
    for(int stamp=0;stamp<n;stamp++){
      
      for(int i=0;i<h[stamp];i++){
    
	for(int j=0;j<w[stamp];j++){

	  int miny=M,maxy=0,minx=M,maxx=0;
	  
	  for(int k=0;k<h[stamp];k++){
	
	    for(int l=0;l<w[stamp];l++){
	      
	      int ny=y-i+k, nx=x-j+l;
	      
	      if(ny<0||nx<0||M<=ny||M<=nx) continue;
	      
	      miny=min(miny,ny);

	      maxy=max(maxy,ny);
	      
	      minx=min(minx,nx);

	      maxx=max(maxx,nx);
	      
	    }
	    
	  }

	  Range.insert(P1(P(miny,maxy),P(minx,maxx)));
	  
	}

      }

    }
    
  }

  
}

char c[3]={'R','G','B'};

void mark(int cost,int S){
  
  auto ite=Range.begin();
  
  while(ite!=Range.end()){

    P1 t=(*ite);
    
    for(int k=0;k<3;k++){
      
      int nS=S;
    
      for(int i=t.first.first;i<=t.first.second;i++){
	for(int j=t.second.first;j<=t.second.second;j++){
	  
	  int p=i*M+j;
	
	  if(s[i][j]==c[k]) nS|=(1<<p);
	  else nS=nS&~(1<<p);
	  
	}
      }
      
      if(d[nS]>cost+1){
	
	d[nS]=cost+1;

	q.push(P(cost+1,nS));
	
      }
      
    }

    ite++;
  }
  
}

int bfs(){
  
  for(int i=0;i<(1<<N);i++) d[i]=INF;
  
  d[0]=0;
  
  q.push(P(0,0));
  
  while(!q.empty()){
    
    P t=q.front(); q.pop();
    
    int cost=t.first, S=t.second;
    
    if(S==(1<<N)-1) return cost;
    
    mark(cost,S);
    
  }

  return 0;
}


int main(){
  
  cin>>n;
  
  for(int i=0;i<n;i++) cin>>h[i]>>w[i];
  
  for(int i=0;i<M;i++) cin>>s[i];

  init();
  
  cout<<bfs()<<endl;
  
  return 0;
}

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

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

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string n;
    cin >> n;
    iter(c, n) {
        if(c == '1') cout << '9';
        else if(c == '9') cout << '1';
        else cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main () {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = min(a, b); i >= 1; i--) {
		if (a % i == 0 && b % i == 0) {
			k--;
			if (k == 0) {
				cout << i;
				return 0;
			}
		}	
	}
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ans(m, 0);
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int a;
            cin >> a;
            ans[a - 1]++;
        }
    }

    int cnt = 0;
    rep(i, m)
    {
        if (ans[i] == n)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,q;
ll s[200100],t[200100],x[200100];
ll d[200100];
struct road{
	ll sx;
	ll a_d;
	ll dis;
	road(ll _sx,ll _a_d,ll _dis){
		sx=_sx;
		a_d=_a_d;
		dis=_dis;
	}
	bool operator<(road &r2){
		if(sx!=r2.sx){
			return sx<r2.sx;
		}else if(a_d!=r2.a_d){
			return a_d<r2.a_d;
		}else{
			return dis>r2.dis;
		}
	}
};
vector<road> rr;
ll ans[200100];
int main(){
	cin>>n>>q;
	for(ll i=0;i<n;i++)cin>>s[i]>>t[i]>>x[i];
	for(ll i=0;i<q;i++)cin>>d[i];
	for(ll i=0;i<n;i++){
		rr.push_back(road(s[i]-x[i],1,x[i]));
		rr.push_back(road(t[i]-x[i],-1,x[i]));
	}
	sort(rr.begin(),rr.end());
	//REP(i,rr.size())cout<<rr[i].sx<<" "<<rr[i].a_d<<" "<<rr[i].dis<<endl;
	set<ll> t1;
	ll t=0;
	for(ll i=0;i<q;i++){
		
		while(t<rr.size()&&rr[t].sx<=d[i]){
			//cout<<i<<" "<<t<<endl;
			if(rr[t].a_d==1){
				t1.insert(rr[t].dis);
			}else{
				t1.erase(rr[t].dis);
			}
			t++;
			//cout<<t1.size()<<endl;
			//cout<<i<<" "<<t<<endl;
		}
		if(t1.empty())cout<<-1<<endl;
		else cout<<*t1.begin()<<endl;
	}
	//REP(i,q)cout<<ans[i]<<endl;
	return 0;
}
			
			

Measured memory_bytes: 27624
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long n=gl();
	    //long t=gl();
	    //int b=gi();


       // System.out.println(Math.max(x-t,0));
        if (n%10==9 || n>=90 ) {
        	System.out.print("Yes");
        }else {
            System.out.print("No");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int tmp = p[0];
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(p[i] <= tmp){
            ans++;
            tmp = p[i];
        }
    }
    cout << ans;


}


Measured memory_bytes: 1024
inf = float('inf')

N,K = map(int,input().split())
ans = inf
X = []
Y = []
XY = []
for _ in range(N):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
    XY.append((x,y))

X = sorted(X)
Y = sorted(Y)

for i, left in enumerate(X):
    for right in X[i+1:]:
        for j, bottom in enumerate(Y):
            for top in Y[j+1:]:
                cnt = 0
                for x, y in XY:
                    if left <= x <= right and bottom <= y <= top:
                        cnt += 1
                if cnt < K: continue
                S = (right-left)*(top-bottom)
                if S < ans:
                    ans = S

print(ans)

Measured memory_bytes: 48604
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n)cin >> a[i];
  rep(i, n)cin >> b[i];
  ll asum = 0, bsum = 0;
  rep(i, n){
    asum += a[i];
    bsum += b[i];
  }
  if(bsum > asum){
    cout << -1 << endl;
    return 0;
  }
  int res = 0;
  ll rem = 0;
  vector<int> vec;
  rep(i, n){
    if(a[i] < b[i]){
      res++;
      rem += b[i] - a[i];
    }else{
      vec.pb(a[i] - b[i]);
    }
  }
  sort(all(vec));
  for(int i = sz(vec) - 1; i >= 0; i--){
    if(rem <= 0)break;
    res++;
    rem -= vec[i];
  }

  cout << res << endl;
	return 0;
}


Measured memory_bytes: 2428
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int kkkt(int a){
    int sum=0;
    while(a>0){
        sum += a%10;
        a/=10;
    }
    return sum;
}
int main(){
    //Seiranchan!
    
    int N;
    cin >>N;

    int K =kkkt(N);

    if(N%K==0) cout << "Yes" <<endl;
    else cout << "No" <<endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < v.length; ++i) {
            v[i] = sc.nextInt();
        }

        System.out.println(solve(v));

        sc.close();
    }

    static int solve(int[] v) {
        List<Candidate> candidates1 = buildCandidates(
                IntStream.range(0, v.length).filter(i -> i % 2 == 0).map(i -> v[i]).toArray());
        List<Candidate> candidates2 = buildCandidates(
                IntStream.range(0, v.length).filter(i -> i % 2 != 0).map(i -> v[i]).toArray());

        int result = v.length;
        for (Candidate candidate1 : candidates1) {
            for (Candidate candidate2 : candidates2) {
                if (candidate1.value != candidate2.value) {
                    result = Math.min(result, v.length - candidate1.count - candidate2.count);
                }
            }
        }

        return result;
    }

    static List<Candidate> buildCandidates(int[] values) {
        Map<Integer, Integer> valueToCount = new HashMap<>();
        for (int value : values) {
            valueToCount.put(value, valueToCount.getOrDefault(value, 0) + 1);
        }
        valueToCount.put(-1, 0);

        return valueToCount.keySet().stream()
                .sorted((value1, value2) -> -Integer.compare(valueToCount.get(value1), valueToCount.get(value2)))
                .limit(2).map(value -> new Candidate(value, valueToCount.get(value))).collect(Collectors.toList());
    }
}

class Candidate {
    int value;
    int count;

    Candidate(int value, int count) {
        this.value = value;
        this.count = count;
    }
}


Measured memory_bytes: 60624
#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
const ll mod = 1000000007;


int main() {
int n;
cin>>n;
vector<int> l(n);
r(i,n)cin>>l.at(i);

sort(l.begin(),l.end());
//r(i,n)cout<<l.at(i)<<' ';
//cout<<endl;
ll sum=0;
r(i,n-2){
  for(int j=i+2;j<n;j++){
    for(int k=i+1;k<j;k++){
      if(l.at(j)<l.at(i)+l.at(k))sum++;
    }
    //cout<<i<<" "<<j<<" "<<sum<<endl;
  }

}

cout<<sum<<endl;


  return 0;
}


Measured memory_bytes: 256
/*
 * hujx.cpp
 *
 *  Created on: 2015年5月21日
 *      Author: dell
 */
#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
#include<set>
#include<bitset>
//#define ONLINE_JUDGE
#define eps 1e-5
#define INF 0x7fffffff
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,num) scanf("%d%d%d",&a,&b,&num)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll long long
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
//#pragma comment(linker,"/STACK:1024000000,1024000000")
int n,m,c;
#define N 210
#define M 1000100
#define Mod 1000000000
#define p(x,y) make_pair(x,y)
const int MAX_len=550;
int f[M],prime[M];
int vis[M];
int tot;
void get_Prime(){
	memset(f,0,sizeof f);
	tot=0;
	int p = (int)sqrt(M)+1;
	for(int i=2;i<p;i++){
		if(f[i]) continue;
		for(int j=i;i*j<M;j++)
			f[i*j] = 1;
	}
	for(int i=2;i<M;i++){
		f[i] ^= 1;
		f[i] += f[i-1];
	}
}
int main(){
    get_Prime();
    while(sf(n)!=EOF){
    	pf(f[n]);
    }
    return 0;
}

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

long long A, B, P, sum[100002];

void add(int k, int x)
{
  for(++k; k < 100002; k += k & -k) (sum[k] += x) %= P;
}
int query(int k)
{
  int ret = 0;
  for(++k; k > 0; k -= k & -k) (ret += sum[k]) %= P;
  return(ret);
}

int main()
{
  while(cin >> A >> B >> P, A) {
    memset(sum, 0, sizeof(sum));
    vector< string > d;
    for(int i = A; i <= B; i++) {
      stringstream sss; sss << i;
      d.push_back(sss.str());
    }
    sort(d.begin(), d.end());
    for(int i = 0; i < d.size(); i++) {
      int val = stoi(d[i]);
      add(val - A, (query(val - A) + 1) % P);
    }
    cout << query(B - A) << endl;
  }
}

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

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

const long long MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  set<string> s;
  rep(i,n){
    string a;
    cin >> a;
    s.insert(a);
  }
  cout<<s.size()<<endl;
}


Measured memory_bytes: 19252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		long D = sc.nextInt();
		
		int count = 0;
		for (int i = 0; i < N; i++) {
			long X = sc.nextInt();
			long Y = sc.nextInt();
			if ((D * D) >= ((X * X) + (Y * Y))) {
				count++;
			}
		}
		
		// 結果の出力
		System.out.println(count);
		
		sc.close();
	}
}


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

using namespace std;
long long int sum, mnsum=INT_MAX;
int main()
{
    int j, n, q[109], mn=109, i,mx=-109, m, tmp;
    cin >> n;
    for(i=0;i<n;i++)
    {
        scanf("%d",&q[i]);
        mn = min(mn, q[i]);
        mx = max(mx, q[i]);
    }
    for(i=mn;i<=mx;i++)
    {
        for(j=0,sum=0;j<n;j++) sum += (i-q[j])*(i-q[j]);
        mnsum = min(sum, mnsum);
    }
    cout<<mnsum<<endl;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin >> N;
    vector<vector<int>> E(N);
    REP(i,N-1) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        E[a].pb(b);
        E[b].pb(a);
    }
    vector<int> c(N);
    REP(i,N) cin >> c[i];
    sort(ALL(c));
    ll sum = 0;
    REP(i,N-1) sum += c[i];
    reverse(ALL(c));
    vector<pair<int,int>> H(N); 
    REP(i,N) {
        H[i] = make_pair(E[i].size(), i);
    }
    sort(ALL(H), greater<pair<int,int>>());
    int max_h(H[0].se);
    vector<bool> visited(N, false);
    queue<int> que;
    vector<int> ans(N);
    que.push(max_h);
    int t = 0;
    ans[max_h] = c[t];
    t++;
    while (que.size()) {
        int n = que.front();
        que.pop();
        visited[n] = true;
        REP(i,E[n].size()) {
            if (!visited[E[n][i]]) {
                que.push(E[n][i]);
                ans[E[n][i]] = c[t];
                t++;
            }
        }
    }
    cout << sum << endl;
    REP(i,N) cout << ans[i] << " \n"[i == N-1];
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define in(N) cin >> N
#define in2(N,M) in(N) >> M
#define in3(N,M,K) in2(N,M) >> K
#define out(ans) cout << ans << endl
#define outf(ans) cout << fixed << setprecision(6) << ans << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define inv(A,N) rep(i,N) in(A[i])
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int S,W;
	in2(S,W);

	if(W>=S){
		out("unsafe");
	}else{
		out("safe");
	}
	return 0;
}

Measured memory_bytes: 3624
fun main(args: Array<String>)
{
    val (a, b, c, d) = readLine()!!.split(" ").map(String::toLong)
    val cdlcm = lcm(c, d)
    
    val cNearestA = a + step(a % c) * c - (a % c)
    val cNearestB = b - (b % c)
    val dNearestA = a + step(a % d) * d - (a % d)
    val dNearestB = b - (b % d)
    val cdNearestA = a + step(a % cdlcm) * cdlcm - (a % cdlcm)    
    val cdNearestB = b - (b % cdlcm)

    val cDiv = if (cNearestB >= cNearestA) cNearestB / c - cNearestA / c + 1L else 0L
    val dDiv = if (dNearestB >= dNearestA) dNearestB / d - dNearestA / d + 1L else 0L
    val cdDiv = if (cdNearestB >= cdNearestA) cNearestB / cdlcm - cdNearestA / cdlcm + 1L else 0L
    
    println(b - a + 1 - cDiv - dDiv + cdDiv)
}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!

fun step(x: Long) = if (x > 0L) 1L else 0L

// ユークリッドの互除法
// O(log(n))
fun gcd(a: Long, b: Long):Long {
    var tmp: Long
    var m = a
    var n = b
    while (m % n != 0L) {
        tmp = n
        n = m % n 
        m = tmp
   }
   return n
}

// 
fun lcm(m: Long, n: Long):Long = m * n / gcd(m, n)



Measured memory_bytes: 37912
/* ex 7_3
   Stuartyg */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int height,width,i,j;
    char **array;
    int *col;
    int *row;

    scanf("%d %d",&height,&width);

    //メモリ確保
    //各行の配列へのポインタ分のメモリ領域を確保
    array = (char**)calloc(height,sizeof(char*));

    if (array == NULL){ //確保失敗
        exit(1);
    }

    for (i= 0;i<height;i++ ){
        //各行の要素分のメモリ領域を確保
        array[i] = (char*)calloc(width,sizeof(char));
        if (array[i] == NULL){ //確保失敗
            exit(1);
        }
    }
    //配列col,rowの分のメモリ領域を確保
    row = (int*)calloc(height,sizeof(int));
    if (row == NULL){ //確保失敗
        exit(1);
    }
    col = (int*)calloc(width, sizeof(int));
    if (col == NULL){ //確保失敗
        exit(1);
    }
    for (i=0;i<height;i++){
        for(j=0;j<width;j++){
            scanf(" %c",&array[i][j]); //array[i][j]の値の受取り

            //白しかない行、列があるかのチェック       
            if (array[i][j] == '#'){ //黒を含む
                row[i] = 1;
                col[j] = 1;
            }
        }
    }

    //出力
    for (i=0;i<height;i++){
        if(row[i] == 1){ //行には黒を含む
            for (j=0;j<width;j++){
                    if (col[j] == 1){ //列にも黒を含む
                        printf("%c", array[i][j]);
                    }
            }
            printf("\n"); //1行出力するごとに改行
        }
    }

    //メモリ領域の開放
    for (i= 0;i<height;i++ ){
        //各行の要素分のメモリ領域を開放
        free(array[i]);
    }

    //各行の配列へのポインタ分のメモリ領域を開放
    free(array);

    free(col);
    free(row);

    return 0;
}



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

using namespace std;

const long long mod = 1000ll * 1000 * 1000 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

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

    long long sum_x = 0;
    sort(x.begin(), x.end());
    long long prev_sum = 0;
    long long prev_k = 0;
    for (int i = 0; i < x.size(); i++) {
        long long add = ((x[i] * prev_k % mod - prev_sum) % mod + mod) % mod;
        sum_x = (sum_x + add) % mod;
        prev_k++;
        prev_sum = (prev_sum + x[i]) % mod;
    }

    long long sum_y = 0;
    sort(y.begin(), y.end());
    prev_sum = 0;
    prev_k = 0;
    for (int i = 0; i < y.size(); i++) {
        long long add = ((y[i] * prev_k % mod - prev_sum) % mod + mod) % mod;        sum_y = (sum_y + add) % mod;
        prev_k++;
        prev_sum = (prev_sum + y[i]) % mod;
    }

    cout << (sum_x * sum_y) % mod << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int x;

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

	cin >> x;
	if ((x / 100) * 5 >= x % 100)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}



Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
ans=0
mod=10**9+7
for k in range(60):
    X=0
    Y=0
    for i in range(N):
        if A[i]^(2**k)>A[i]:
            X+=1
        else:
            Y+=1
    #print(X,Y)
    ans+=(pow(2,k,mod)*((X*Y)%mod))%mod
    ans%=mod
print(ans)


Measured memory_bytes: 122808
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, s, c = nas()

print(''.join(["A", s[0], "C"]))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; 
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
 
template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;
 
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 
 
const int MXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
 
int N;
ll DP[(1<<21) + 5];
bool adj[25][25], vis[(1<<21)+5];

ll dp(int women){
    if (women + 1 == (1<<N)) return 1;
    if (vis[women]) return DP[women];
    vis[women] = 1;
    FOR(j,1,N+1){
        if (adj[__builtin_popcount(women)+1][j] && !(women & (1<<(j-1)))){
            DP[women] = (DP[women] + dp(women | (1<<(j-1)))) % INF;
        }
    }
    return DP[women];
}

int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

    cin >> N;
    FOR(i,1,N+1){
        FOR(j,1,N+1){
            cin >> adj[i][j];
        }
    }
    finish(dp(0))


 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  rep(i, H) {
    cin >> vec.at(i);
  }
  vector<vector<int>> vec2(H + 2, vector<int>(W + 2));
  rep(i, H + 2) {
    rep(j, W + 2) {
      vec2.at(i).at(j) = 0;
    }
  }
  rep(i, H) {
    rep(j, W) {
      if(vec.at(i).at(j) == '#') {
        vec2.at(i).at(j) += 1;
        vec2.at(i).at(j+1) += 1;
        vec2.at(i).at(j+2) += 1;
        vec2.at(i+1).at(j) += 1;
        vec2.at(i+1).at(j+2) += 1;
        vec2.at(i+2).at(j) += 1;
        vec2.at(i+2).at(j+1) += 1;
        vec2.at(i+2).at(j+2) += 1;
      }
    }
  }
  char CH;
  rep(i, H) {
    rep(j, W) {
      if(vec.at(i).at(j) == '#') {
        cout << "#";
      }
      if(vec.at(i).at(j) == '.') {
        cout << vec2.at(i+1).at(j+1);
      }
    }
    cout << " " << endl;
  }
}

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

int main() {
	int n;
	cin >> n;
	int t, a;
	cin >> t >> a;
	int ans = 0;
	double diff = 1000.0;
	for(int i = 0; i < n; ++i) {
		int h;
		cin >> h;
		double td = abs(t - a - 0.006 * h);
		if (diff > td) {
			diff = td;
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[1010];
int n,v1,v2,v3,v4;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++)
	{
		if(s[i]=='N')v1=1;
		if(s[i]=='W')v2=1;
		if(s[i]=='S')v3=1;
		if(s[i]=='E')v4=1;
	}
	if((v1^v3)||(v2^v4))
		printf("No");
	else printf("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXHW = 800 + 50;
char a[MAXHW][MAXHW];
int d[MAXHW][MAXHW];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main() {
	int H, W, K;
	scanf("%d%d%d", &H, &W, &K);
	for(int i = 0; i < H; i++)
		scanf("%s", a[i]);
	queue<PII> q1;
	queue<PII> q2;
	for(int i = 0; i < H; i++)
		for(int j = 0; j < W; j++)
			d[i][j] = -1;
	for(int i = 0; i < H; i++)
		for(int j = 0; j < W; j++)
			if(a[i][j] == 'S') {
				d[i][j] = 0;
				q1.push(MP(i, j));
			}
	int ans = -1;
	while(!q1.empty()) {
		PII u = q1.front(); 
		int dis = d[u.F][u.S];
		if(dis == K) break;
		q1.pop();
		q2.push(u);
		for(int k = 0; k < 4; k++) {
			int nx = u.F + dx[k];
			int ny = u.S + dy[k];
			if(a[nx][ny] == '.' && (nx == 0 || nx == H - 1 || ny == 0 || ny == W - 1)) {
				ans = 1;
			}
			if(d[nx][ny] == -1 && a[nx][ny] == '.') {
				d[nx][ny] = dis + 1;
				q1.push(MP(nx, ny));
			}
		}
		if(ans == 1) break;
	}
	while(!q1.empty()) {
		q2.push(q1.front());
		q1.pop();
	}
	debug("ans = %d\n", ans);
	for(int i = 0; i < SZ(q2); i++) {
		PII u = q2.front(); q2.pop();
		d[u.F][u.S] = K;
		q2.push(u);
	}
	while(ans == -1) {
		PII u = q2.front(); 
		int dis = d[u.F][u.S];
		q2.pop();
		for(int k = 0; k < 4; k++) {
			int nx = u.F + dx[k];
			int ny = u.S + dy[k];
			if(nx == 0 || nx == H - 1 || ny == 0 || ny == W - 1) {
				ans = dis / K + 1;
			}
			if(d[nx][ny] == -1) {
				d[nx][ny] = dis + 1;
				q2.push(MP(nx, ny));
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3968
# coding: utf-8
"""this is python work script"""

def solver(word):
    """solve this problem"""
    check_result = word.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')

    answer = 'YES'
    if check_result:
        answer = 'NO'

    return answer

def main():
    """main function"""
    input_word = input().rstrip()
    answer = solver(input_word)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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



int main(){
    int a,b;
    cin>>a>>b;
    if(a<b)out(0);
    else out(10);
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		int four = 0, two = 0,x=0;
		int a;
		while (n--)
		{
			scanf("%d", &a);
			if (a % 4==0)
			{
				four++;
				continue;
			}
			if (a % 2 == 0)
			{
				two++;
				continue;
			}
			x++;
		}
		if (two)
			x++;
		if (four + 1 < x)
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
// ITP1_6_C OfficialHouse
import java.io.*;

public class Main {
   static int[][][] count = new int[4][3][10];
   static int b,f,r,v;

   public static void main(String[] args) {
      try  {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         int n = Integer.parseInt(br.readLine());
         for (int i = 0; i < n; i++) {
            String[] array = (br.readLine()).split(" ");
            b = Integer.parseInt(array[0]) - 1;
            f = Integer.parseInt(array[1]) - 1;
            r = Integer.parseInt(array[2]) - 1;
            v = Integer.parseInt(array[3]);

            count[b][f][r] += v;
         }

         for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
               for (int k = 0; k < 10; k++) {
                  System.out.printf(" %d", count[i][j][k]);
               }
               System.out.println();
            }
            if (i < 3)
               System.out.printf("####################\n");
         }
      }

      catch (Exception e) {
         System.out.println(e);
      }
   }
}

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

int main() {
  string S;
  cin>>S;
  bool ans=true;
  int n= S.size();
  for(int i=0; i<n; i++){
    if(i%2==0){
      if(S.at(i)=='L'){
        ans=false;
        break;
      }
    }
    else {
      if(S.at(i)=='R'){
        ans=false;
        break;
      }
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=8&&b<=8)
    {
        cout<<"Yay!"<<endl;
    }
    else
    {
        cout<<":("<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
  
N, M = MAP()

print( int((N+M)*(N+M-1)/2 - N*M )) 

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int N, M;
    cin >> N >> M;
    VI s(M), c(M);

    REP(i, M) cin >> s[i] >> c[i];

    if(N == 1) {
        REP(i, 10) {
            bool flag = true;
            REP(j, M) flag &= c[j] == i;
            if(flag) {
                cout << i << endl;
                return 0;
            }
        }
    } else if (N == 2 ){
        REP2(i, 10, 100) {
            bool flag = true;
            REP(j, M) {
                if(s[j] == 1) flag &= c[j] == i/10;
                else flag &= c[j] == i%10;
            }
            if(flag) {
                cout << i << endl;
                return 0;
            }
        }
    } else {
        REP2(i, 100, 1000) {
            bool flag = true;
            REP(j, M) {
                if(s[j] == 1) flag &= c[j] == i/100;
                else if(s[j] == 2) flag &= c[j] == (i/10)%10;
                else flag &= c[j] == i%10;
            }
            if(flag) {
                cout << i << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=[-1]*(n+1)
for i in range(m):
    idx=int(input())
    l[idx]=0
mod=10**9+7
if n!=1:
    if l[1]==-1:
        if l[2]==-1:
            l[1]=1;l[2]=2
        else:
            l[1]==1
    else:
        if l[2]==-1:
            l[2]=1
    if n>2:
        for i in range(3,n+1):
            if l[i]==-1:
                l[i]=(l[i-1]+l[i-2])%mod
            else:
                continue
    print(l[-1])
else:
    if l[1]==-1:
        print(1)
    else:
        print(0)

Measured memory_bytes: 6900
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<cmath>
#include<tuple>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define MMAX 7368795

int main()
{
	int m,n;
	while(cin >> m >> n,m|n)
	{
		vector<int> v;
		int memo[MMAX] = {};
		bool flag = false;
		int i,Mcount = 0;
		for(i = m;i < MMAX;i++)
		{
			if(memo[i] == 0)
			{
				if(Mcount == n)flag = true;

				for(int j = i;j < MMAX;j += i)
				{
					memo[j] = 1;
				}
				Mcount++;
				
			}
			if(flag)break;
		}
		
		cout << i << endl;
		
		
	}
	return 0;
}

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

int n, t1, mx, last, cnt;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t1;
		if (t1 > last) {
			mx = max(mx, cnt);
			cnt = 1;
		}
		else cnt++;
		last = t1;
//		cout << cnt << ' ';
	}
	mx = max(mx, cnt);
	cout << mx - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using ll = long long;
const int inf = 1e8;

int dp[105][105];

int main() {
    int n;
    cin >> n;
    vector<int> p(n+1);
    cin >> p[0] >> p[1];
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        p[i+2] = b;
    }
    rep(i,105)rep(j,105) dp[i][j] = inf;
    rep(i,n+1) dp[i][i] = 0;
    for (int i = n-1; i >= 1; i--) {
        for (int j = i+1; j <= n; j++) {
            if (j == i+1) dp[i][j] = p[i-1]*p[i]*p[i+1];
            else {
                for (int k = i; k <= j-1; k++) {
                    dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j]);
                }
            }
        }
    }
    cout << dp[1][n] << endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int n, i;
	char c[9], mx[9] = "", mn[9] = "";
	while (cin >> n)
	{
		if (cin.eof()) return 0;
		for (i = 0; i < n; i++)
		{
			scanf("%s", &c);
			strcpy(mx, c);
			sort(mx, mx+8, greater<int>());
			strcpy(mn, c);
			sort(mn, mn+8);
			printf("%d\n", atoi(mx) - atoi(mn));
		}
	}
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 3);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    //a[n + 1] = 0;
    int mx = 0, mn = 222;
    long long have = 1000;
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n + 1; ++j) {
            if (a[j] <= a[j - 1]) {
                long long cnt = have / a[i];
                have -= cnt * a[i];
                have += cnt * a[j - 1];
                i = j - 1;
                break;
            }
        }
    }
    cout << have;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> z(n), w(n);
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        z[i] = x + y;
        w[i] = x - y;
    }
    int ans = max(*max_element(z.begin(), z.end()) - *min_element(z.begin(), z.end()), *max_element(w.begin(), w.end()) - *min_element(w.begin(), w.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    char c;
    cin >> c;
    if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o')
        cout<<"vowel";
    else cout<<"consonant";

    return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
set<ll> s[51][51];
vii v;
void solve(){
    rep(i,0,51){
        s[i][i].insert(0);
    }
    rep(i,1,51){
        rep(j,0,i){
            rep(k,1,i+1){
                int cur=i%k;
                for(auto y:s[cur][j]){
                    y|=(1LL<<k);
                    s[i][j].insert(y);
                }
            }
        }
    }
    int n;
    cin>>n;
    v.resize(n);
    rep(i,0,n){
        cin>>v[i].x;
    }
    rep(i,0,n){
        cin>>v[i].y;
        if(v[i].y>v[i].x) {cout<<-1;return;}
    }
    ll ans=0;
    rep(i,0,n){
        if(!sz(s[v[i].x][v[i].y])){
            cout<<-1<<endl;
            return;
        }
    }
    for(int i=50;i>=0;i--){
        int f=0;
        rep(j,0,n){
            ll h=*s[v[j].x][v[j].y].begin();
            if((h>>i)&1){f=1;break;}
        }
        if(f){
            ans|=(1LL<<i);
            rep(j,0,n){
                set<ll> temp;
                for(auto k:s[v[j].x][v[j].y]){
                    if((k>>i)&1) k^=1LL<<i;
                    temp.insert(k);
                }
                s[v[j].x][v[j].y]=temp;
            }
        } 
    }
    cout<<ans;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1664
// http://algorithms.blog55.fc2.com/blog-entry-66.html

#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>

#define M 100

int N,R[M+1],C[M][M],B[M][M];

void compute(){
	int i=0,j,k,cost;
	memset(C,99,sizeof(C));
	for(;i<N;i++)C[i][i]=0;
	for(j=1;j<N;j++)
		for(i=0;i<N - j; i++ )
			for (k = i; k < i + j; k++ ){
				cost = C[i][k] + C[k+1][i+j] + R[i]*R[k+1]*R[i+j+1];
				if(cost<C[i][i+j])C[i][i+j]=cost,B[i][i+j]=k; 
			}
}

void order( int i, int j ){
	if ( i == j ) cout << "M" << i;
	else{
		cout << "(";
		order( i, B[i][j]-1 ); order(B[i][j], j);
		cout << ")";
	}
}

void input(){
	cin >> N;
	int z,i=0;
	for (; i < N; i++ ) cin >> R[i]>>z;
	R[i]=z;
	//SIZE++;
}

void output(){
	cout <<  C[0][N-1] << endl;
	//order(0, N);
	//cout << endl;
}

main(){
	input();
	compute();
	output();
}

Measured memory_bytes: 1244