akhauriyash/Code-Regression huggingface dataset:
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n, m, x, y, mn=inf, mx=0, ans;
vpi v;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n >> m;

rep(i, 1, m)
{
    cin >> x >> y;
    v.pb({x,y});
}

sort(all(v));

rep(i, 0, m-1){

x = v[i].f;y=v[i].ss;

if(x>=mx && x<mn){
    mn = min(mn, y);
    mx = max(mx, x);
}

else {
    ans++;
    mx = x;
    mn = y;
}

}
ans++;

cout << ans << endl;




return 0;}
///.... Maria Otonashi


Measured memory_bytes: 1400
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> numList = new ArrayList<Integer>();
        while(sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == 0 && b == 0){
                break;
            }
            numList.add(a);
            numList.add(b);
        }
        for(int i = 0; i < numList.size() / 2; i++){
            for(int j = 0; j < numList.get(i * 2); j++){
                for(int k = 0; k < numList.get(i * 2 + 1); k++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34808
# coding: utf-8
# Your code here!

h,w= list(map(int,input().split()))	
B = []
for _ in range(h):
    B.append([int(i) for i in input().split()])

def hh(j):
    return j//w

def ww(j):
    if j//w%2==0:
        return j%w
    else:
        return w-1-j%w

ans = []
for i in range(h*w-1):
#    print(hh(i),ww(i))
    if B[hh(i)][ww(i)]%2 ==1:
        B[hh(i)][ww(i)]-=1
        B[hh(i+1)][ww(i+1)]+=1
        ans.append([hh(i)+1,ww(i)+1,hh(i+1)+1,ww(i+1)+1])

print(len(ans))
for a in ans:
#    for i in a:
#        print(i,end=" ")
#    print()
    print(*a)

#print(B)






Measured memory_bytes: 31636
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int i,n,ptr,currcount,lastnum,res=0;
	int *a;
	scanf("%d",&n);
	a=new int [n];
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	ptr=0;
	while(ptr<n)
	{
		lastnum=a[ptr];
		currcount=0;
		while(ptr<n&&a[ptr]==lastnum)
		{
			currcount++;
			ptr++;
		}
		res+=currcount%2;
	}
	printf("%d\n",res);
	delete [] a;
	return 0;
}


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

int main() {
	int a[3], ans = 1;;
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 0; i < 3; i++) {
		if (!((a[i] >= a[0]) && (a[i] >= a[1]) && (a[i] >= a[2]))) {
			ans *= a[i];
		}
	}
	cout << ans / 2 << endl;
	return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<double,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

struct state{
	ll x,y,r;
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	vector<state> g;
	g.push_back({a,b,0});
	g.push_back({c,d,0});
	int n;
	cin>>n;
	rep(i,n){
		ll x,y,r;
		cin>>x>>y>>r;
		g.push_back({x,y,r});
	}
	n+=2;
	auto calc=[&](double x1,double x2,double y1,double y2){
		return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	};
	vector<vector<double>> dist(n,vector<double>(n,inf));
	rep(i,n){
		dist[i][i]=0;
		rep(j,n){
			dist[i][j]=calc(g[i].x,g[j].x,g[i].y,g[j].y)-(g[i].r+g[j].r);
			chmax(dist[i][j],double(0));
		}
	}
	vector<double> dp(n,inf);
	priority_queue<P,vector<P>,greater<P>> que;
	que.push(P(0,0));
	dp[0]=0;
	while(!que.empty()){
		auto hoge=que.top();
		que.pop();
		int v=hoge.se;
		double d=hoge.fi;
		if(d<dp[v]) continue;
		rep(to,n){
			if(chmin(dp[to],dp[v]+dist[v][to])){
				que.push(P(dp[to],to));
			}
		}
	}
	cout<<setprecision(15)<<dp[1]<<endl;
}

Measured memory_bytes: 13680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
    
    ll N;cin >> N;
    cout << N*(N-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <string.h>
#include <math.h>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef long double ld;
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define pb push_back
#define _1 first
#define _2 second

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1000000007;
const int alphabet = 26;
const int MAXINT = 2e5+1;

int child[MAXINT], op[MAXINT], ciclo, prefx, z;
ll k, n;

void dfs(int v){
    //cout << "* "<< v << endl;
    if( v!=0 && op[ child[v] ] ){
        //cout << "=> "<< v << " " << child[v] << " | "<< op[v] << " " << op[child[v]] << endl;
        z = child[v];
        ciclo = op[v] - op[child[v]];
        prefx = op[child[v]];
    }else{
        op[ child[v] ] = op[v]+1;
        //FOR(i,1,n+1) cout << op[i] << " ";
        //cout << endl;
        dfs(child[v]);
    }
}

int main(){
    lrii(n,k);
    FOR(i,1,n+1) ri(child[i]);
    op[1]=1, dfs(1);
    prefx--, ciclo++;

    int v = 1;
    if( k>prefx ) k -= prefx, k%=ciclo, v = z;//, cout << "=> "<< k << " desde " << v << endl; ;

    FOR(i,0,k) v = child[v];
    printf("%d\n", v);

    //cout << "Tamaño del ciclo = "<< ciclo << endl;
    //cout << "Previos al ciclo = "<< prefx << endl;

}

/*
6 11
2 3 4 5 6 2


*/  

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


int main() {
    int N,K;
    int ans = 1;
    cin >> N >> K;
    for(int i = 0;i < N; i++){
        if(ans * 2 >= ans + K){
            ans = ans + K;
        }else{
            ans = ans * 2;
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<string> S(n);
    for(ll i=0;i<n;++i)cin>>S[i];
    vector<vector<ll>> count(n, vector<ll>(26, 0));
    for(ll i=0;i<n;++i){
        for(auto c: S[i]){
            count[i][c-'a']++;
        }
    }
    for(ll i=1;i<n;++i){
        for(ll j=0;j<26;++j)chmin(count[0][j],count[i][j]);
    }
    string ans="";
    for(ll i=0;i<26;++i){
        for(ll j=0;j<count[0][i];++j){
            ans+='a'+i;
        }
    }
    prt(ans)

    return 0;
}


Measured memory_bytes: 380
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
using namespace std;
string s;
signed main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    if(s.back()=='s')
    {
        cout<<s+"es"<<endl;
    }
    else
    {
        cout<<s+'s'<<endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N;
  rep(i, 1, N) {
    int k;
    cin >> k;
    va.push_back(k);
  }
}
void solve() {
  vb.resize(N);
  vb[0] = va[0];
  rep(i, 1, N - 1) { vb[i] = vb[i - 1] + va[i]; }
  debugv(va);
  debugv(vb);
  ;
  map<int, int> mp;
  for (auto x : vb) {
    mp[x]++;
  }
  int ans = 0;
  for (auto x : mp) {
    if (x.first == 0) {
      ans += (x.second + 1) * x.second / 2;
    } else
      ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 15856
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, A);
  invar(int, B);
  
  int sc = 1;
  int nu = 0;
  while(sc < B) {
    sc += A - 1;
    nu ++;
  }
  
  fin(nu);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll res = 0;
    cout << min(C, A + B + 1) + B << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
b=sorted(list(map(int,input().split())))
ma=a[0]*b[-1]
mi=0
if sum(a)<k+1:
  ma=0
for i in range(n):
  a[i]=a[i]*b[i]
while abs(ma-mi)>1:
  now=0
  for i in range(n):
    now+=max(0,(a[i]-(mi+ma)//2+b[i]-1)//b[i])
  if now>k:
    mi=(ma+mi)//2
  else:
    ma=(ma+mi)//2
print(ma)

Measured memory_bytes: 121008
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define N_MAX 44

int A[N_MAX];

int fibonacci(int n) 
{
    if (n == 0 || n == 1) return A[n];
    else {
        A[n-1] = fibonacci(n-1);
        return A[n-1] + A[n-2];
    }
}

int main() {
    int n;

    A[0] = 1;
    A[1] = 1;
    cin >> n;

    int fb = fibonacci(n);

    cout << fb << endl;

    return 0;
}



Measured memory_bytes: 3104
#include <iostream>

using namespace std;
int main() {
	int n;
	cin >> n;
	int list[200000];
	for(int i=0; i<n; i++){
		cin >> list[i];
	}
	int min = list[0];
	int ans = list[1] - list[0];
	for(int i = 1; i<n; i++){
		if(min > list[i]){
			min = list[i];
		}else if(list[i] - min > ans){
			ans = list[i] - min;
		}
	}
	cout << ans << endl;
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
vector<int> dag1(vector<vector<int>> e)
{
  int n=e.size();
  vector<int> ans(0);
  vector<int> ins(n,0);
  int i,j;
  rep(i,n)
  {
    rep(j,e[i].size())
    {
      ins[e[i][j]]++;
    }
  }
  queue<int> s;
  rep(i,n) if(ins[i]==0)s.push(i);
  while(!s.empty())
  {
    int now=s.front();
    s.pop();
    ans.emplace_back(now);
    rep(i,e[now].size())
    {
      ins[e[now][i]]--;
      if(ins[e[now][i]]==0)
      {
        s.push(e[now][i]);
      }
    }
  }
  return ans;
}

int main()
{
  int n,m;cin>>n>>m;
  vector<int> x(m);
  vector<int> y(m);
  int i,j;
  rep(i,m)cin>>x[i]>>y[i];
  rep(i,m){
    x[i]--;
    y[i]--;
  }
  vector<vector<int>> e(n);
  rep(i,m)
  {
    e[x[i]].emplace_back(y[i]);
  } 
  vector<int> row=dag1(e);
  vector<int> len(n,0);
  rep(i,n)
  {
    rep(j,e[row[i]].size())
    {
      len[e[row[i]][j]]=max(len[e[row[i]][j]],len[row[i]]+1);
    }
  }
  int ans=0;
  rep(i,n)ans=max(ans,len[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 13056
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );
	final Stack<Integer> stack = new Stack<Integer>();
	
	while ( stdin.hasNextLine() ) {
	    final String input = stdin.nextLine().trim();
	    if ( new Scanner( input ).hasNextInt() ) {
		stack.push( Integer.parseInt( input ) );
	    } else {
		if ( "+".equals( input ) ) {
		    final int before = stack.pop();
		    final int next = Integer.parseInt( stdin.nextLine().trim() );
		    stack.push( before + next );
		} else if( "-".equals( input ) ) {
		    final int before = stack.pop();
		    final int next = Integer.parseInt( stdin.nextLine().trim() );
		    stack.push( before - next );
		} else if( "*".equals( input ) ) {
		    final int before = stack.pop();
		    final int next = Integer.parseInt( stdin.nextLine().trim() );
		    stack.push( before * next );
		} else if( "/".equals( input ) ) {
		    final int before = stack.pop();
		    final int next = Integer.parseInt( stdin.nextLine().trim() );
		    stack.push( before / next );
		}
	    }
	}
	System.out.println( stack.pop() );
    }    
}

Measured memory_bytes: 31372
MARK = 0
NUMBER = 1


def bubble_sort(A):
    for i in range(len(A)-1):
        for j in reversed(range(i+1, len(A))):
            if A[j][NUMBER] < A[j - 1][NUMBER]:
                swap(A, j-1, j)


def selection_sort(A):
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j][NUMBER] < A[mini][NUMBER]:
                mini = j
        if mini != i:
            swap(A, mini, i)


def swap(A, i, j):
    tmp = A[j]
    A[j] = A[i]
    A[i] = tmp


amount = int(input())
cards = input().split()  # list of cards (ex:[H2 S8])
isStable_selection = True

# make tuple of mark and number
for i in range(amount):
    cards[i] = tuple([cards[i][MARK], int(cards[i][NUMBER])])

cards_bubble = list(cards)
cards_selection = list(cards)

bubble_sort(cards_bubble)
selection_sort(cards_selection)

# judge stable or not (bubble sort is stable)
if cards_bubble == cards_selection:
    isStable_selection = True
else:
    isStable_selection = False

print(*[cards_bubble[i][MARK] + str(cards_bubble[i][NUMBER])
        for i in range(amount)])
print("Stable")

print(*[cards_selection[i][MARK] + str(cards_selection[i][NUMBER])
        for i in range(amount)])
if isStable_selection:
    print("Stable")
else:
    print("Not stable")

Measured memory_bytes: 6780
from collections import Counter
from operator import itemgetter
import numpy as np

N, K = map(int, input().split())
A = list(map(int, input().split()))
c = np.array(sorted(Counter(A).items(), key=itemgetter(1), reverse=True))
a_to_replace = c[K:]
print(sum(a_to_replace[:,1]))

Measured memory_bytes: 48052
#include "bits/stdc++.h"
using namespace std;
const int mod = 1000000000 + 7;
long long dp[1000010];

int main(int argc, char const *argv[])
{
	int N, H, D;
	cin >> N >> H >> D;

	long long sum = 0;
	long long fac = 1;
	for(int i = 1; i <= N; i++) {
		fac = (fac * i) % mod;
		sum = (sum + fac) % mod;
	}
	dp[0] = 1;
	long long last = dp[0];
	
	for(int i = 1; i <= H; i++) {
		if(i < H) {
			dp[i] += sum * last;
		} else {
			dp[i] += fac * last;
		}
		dp[i] %= mod;
		last += dp[i];
		if(i - D >= 0) {
			last -= dp[i - D];
		}
		last %= mod;
	}
	if(dp[H] < 0) dp[H] += mod;
	cout << dp[H] << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans = 0;
  int minimum = N;
  for(int i = 0; i < N; i++) {
    int P;
    cin >> P;
    if(P <= minimum) {
      minimum = P;
      ans++;
    }
    //高速化，なくてもよい
    if(P == 1) {
      break;
    }
    //ここまで
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
dist = []
for a in A:
    if dist and dist[-1] == a:
        continue
    dist.append(a)
ans = 1
i = 2
while i < len(dist):
    if (dist[i-2] < dist[i-1]) != (dist[i-1] < dist[i]):
        ans += 1
        i += 1
    i += 1
print(ans)

Measured memory_bytes: 14252
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

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

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	printf("%d\n", not n);

	Please AC;
}

Measured memory_bytes: 3828
#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(){
  int N,M;
  cin >> N >> M;
  
  int a, b;
  int left=0;
  int right= 1000000;
  rep(i,N){
    cin >> a >> b;
    if( left <=  a)left = a;
    if( right >= b)right = b;
  }
  
  if(right < left)cout << 0 << endl;
  
  else cout << right - left +1 << endl;
  
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

ll		factorial(ll nb)
{
	ll ans = 1;

	while (nb > 0)
	{
		ans *= nb;
		nb--;
		ans %= 1000000007;
	}
	return (ans);
}

int		main(void)
{
	ll N, M;

	cin >> N >> M;
	ll nf = factorial(N);
	ll mf = factorial(M);

	if (N == M)
	{
		cout << nf * mf * 2 % 1000000007 << endl; 
	}
	else if (abs(N - M) <= 1)
	{
		cout << nf * mf % 1000000007 << endl; 
	}
	else
		cout << 0 << endl;
}



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

signed main() {
	int a,b,c;
	cin >> a >> b >> c;
	int s = 0;
	for (; a < b + 1; a++) {
		if (c%a == 0)s++;
	}
	cout << s << endl;
}

Measured memory_bytes: 3072
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

struct query {
  int a, b, c, d;
};


int main() {
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int Q;
  cin >> Q;
  vector<query> qs(Q);
  FOR(q,qs) {
    cin >> q.a >> q.b >> q.c >> q.d;
  }
  VI a_in_S(S.size()+1, 0);
  VI a_in_T(T.size()+1, 0);
  REP(i,0,S.size()) {
    a_in_S[i+1] = a_in_S[i] + (S[i] == 'A' ? 1 : 2);
  }
  REP(i,0,T.size()) {
    a_in_T[i+1] = a_in_T[i] + (T[i] == 'A' ? 1 : 2);
  }
  FOR(q,qs) {
    int s = a_in_S[q.b] - a_in_S[q.a-1];
    int t = a_in_T[q.d] - a_in_T[q.c-1];
    bool ans = s % 3 == t % 3;
    if(s == 0 && t != 0) ans = false;
    cout << (ans ? "YES" : "NO") << endl;
  }
  return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

ll gcd(ll a, ll b) {
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X;
    cin >> N >> X;
    REP(i, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    ll g = abs(X - A[0]);
    REP(i, N - 1) {
        g = gcd(g, abs(A[i + 1] - A[i]));
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main { 
 boolean[] p;
 int MAX = 1<<16;
 void run() {
  Scanner sc = new Scanner(System.in);
  p = new boolean[MAX+1];
  p[0] = p[1] = true;
  for(int i=2;i<=MAX;i++) if(!p[i]) {
   for(int j=2*i;j<=MAX;j+=i) p[j] = true;
  }
  for(;;) {
   int n = sc.nextInt();
   if( n == 0 ) break;
   int cnt = 0;
   for(int i=2;2*i<=n;i++) if(!p[i] && !p[n-i])
    cnt++;
   System.out.println(cnt);
  }
 }
 public static void main(String[] args) {
  new Main().run();
 }
}

Measured memory_bytes: 12000
package main
 
import (
	"fmt"
)
 
func main() {
	var yen500Coin, total int
    var yen500 int = 500
	fmt.Scanf("%d %d", &yen500Coin, &total)

	if(yen500Coin < 1 || 100 < yen500Coin) {
		panic("allow length 1 to 100")
	}
	if(total < 1 || 100000 < total) {
		panic("allow total 1 to 100000")
	}

    if((yen500Coin * yen500) < total) {
		fmt.Printf("No")
    } else {
		fmt.Printf("Yes")
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;

struct Edge {
    long long from;
    long long to;
    long long cost;
};
using Edges = vector<Edge>;
using Graph = vector<vector<int>>;
vector<int> seen;
vector<int> path;
vector<ll> disb;
vector<int> negative;
const long long INF = 1LL << 60;

/* bellman_ford(Es,s,t,dis)
    入力: 全ての辺Es, 頂点数V, 開始点 s, 最短経路を記録するdis
    出力: 負の閉路が存在するなら ture
    計算量：O(|E||V|)
    副作用：dis が書き換えられる
*/
bool bellman_ford(const Edges &Es, int V, int s, vector<long long> &dis) {
    dis.resize(V, INF);
    for(int i=0;i<V;i++){
        dis[i]=INF;
    }
    dis[s] = 0;
    int cnt = 0;
    while (cnt < V-1) {
        for (auto e : Es) {
            if (dis[e.from] != INF && dis[e.from] + e.cost < dis[e.to]) {
                dis[e.to] = dis[e.from] + e.cost;
            }
        }
        cnt++;
    }
    cnt = 0;
    while (cnt < V) {
        for (auto e : Es) {
            if (dis[e.from] != INF && dis[e.from] + e.cost < dis[e.to]) {
                dis[e.to] = dis[e.from] + e.cost;
                negative[e.to]=1;
            }
            if(negative[e.from]==1){
                negative[e.to]=1;
            }
        }
        cnt++;
    }
    return (cnt == V);
}

void dfs(const Graph &G, int s){
    seen[s]=1;
    for(int v:G[s]){
        if(seen[v]==0){
            dfs(G,v);
        }
    }
}

int main(){
    int n,m;
    ll p;
    cin>>n>>m>>p;
    Edges Es(m);
    Graph G1(n);
    Graph G2(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        c-=p;
        c*=-1;
        Es.push_back({a,b,c});
        G1[a].push_back(b);
        G2[b].push_back(a);
    }
    disb.resize(n,0);
    negative.resize(n,0);
    path.resize(n,0);
    seen.resize(n,0);
    dfs(G1,0);
    for(int i=0;i<n;i++){
        path[i]+=seen[i];
    }
    fill(seen.begin(),seen.end(),0);
    dfs(G2,n-1);
    for(int i=0;i<n;i++){
        path[i]+=seen[i];
    }
    vector<ll> dis(n);
    bellman_ford(Es,n,0,dis);
    ll zero=0;
    if(negative[n-1]!=0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<min(zero,dis[n-1])*-1<<endl;
}

Measured memory_bytes: 4132
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

void max_heapify(vector<ll> &A, ll i) {
	ll H = A.size() - 1; // size of 1-origin array A
	ll lc, rc;
	lc = 2*i;
	rc = 2*i + 1;
	ll largest = i;
	if (lc <= H && A[lc] > A[i]) {
		largest = lc;
	}
	if (rc <= H && A[rc] > A[largest]) {
		largest = rc;
	}

	if (largest != i) {
		ll temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		max_heapify(A, largest); 
	}
}

void build_max_heap(vector<ll> &A) {
	ll H = A.size() - 1;
	for (ll i=H/2; i>0; --i) {
		max_heapify(A, i);
	}
}

int main() {
	ll H;
	cin >> H;
	vector<ll> A(H+1);
	for (ll i=1; i<A.size(); ++i) cin >> A[i];
	build_max_heap(A);
	for (ll i=1; i<A.size(); ++i) cout << " " << A[i];
	cout << endl;
	return 0;
}




Measured memory_bytes: 6656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int binary_search(int* p, int n, int key,int num)
{
    int low, high, middle;

    low = 0;
    high = n - 1;

    while (low <= high)
    {
        middle = (low + high) / 2;
        if (gcd(num,p[middle])==1)
            return middle;
        else 
            high = middle - 1;
    }
}

int main()
{
    int N;
    char S[5000];
    lli ans = 0;

    lli num[3] = { 0 };

    scanf("%d%s", &N, S);

    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'R')
            num[0]++;
        else if (S[i] == 'G')
            num[1]++;
        else if (S[i] == 'B')
            num[2]++;
    }


    for (int i = 0; i < N-1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            if (2 * j - i >= N)
                continue;
            if ( S[i] != S[j] && S[i] != S[2*j-i] && S[j] != S[2*j-i])
                    ans++;
        }
    }
    printf("%lld", num[0]*num[1]*num[2]-ans);
}



Measured memory_bytes: 3836
#include <stdio.h>
int main(void){
    int X, A, B,C;
    scanf("%d" ,&A);
    scanf("%d" ,&B);
    scanf("%d" ,&C);
    scanf("%d" ,&X);
    
    int total_count = 0;
    
    for(int i = 0; i <= A && i <= X/500; i++){
        int sum_A = X-500*i;    
        for(int j = 0; j <= B && j <= sum_A/100; j++){
            int sum_B = sum_A - 100*j;
            if(sum_B%50 == 0 && sum_B/50 <= C) ++total_count; 
        }
    }
    printf("%d\n", total_count);
    
}

Measured memory_bytes: 128
n,m=map(int, input().split())
an=[int(i) for i in input().split()]
import fractions
ans=an[0]
for i in range(1, n):
    ans = ans * an[i] // fractions.gcd(ans, an[i])

def count2(i):
    if i%2==0:
        c=0
        while i%2==0:
            i//=2
            c+=1
        return c
    else:
        return 0
    
c2=count2(ans)

for ak in an:
    if ak%(2**c2)==0:
        d=1
        pass
    else:
        d=0
        break

if d==0:
    print(0)
else:
    lca=ans//2
    if (m//lca)%2==0:
        print((m//lca)//2)
    else:
        print(((m//lca)+1)//2)

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, m, R;
    cin >> n >> m >> R;
    ll r[R];
    rep(i, R) { cin >> r[i]; }
    ll d[n][n];
    rep(i, n) {
        rep(j, n) { d[i][j] = mod; }
    }

    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    sort(r, r + R);

    ll ans = mod;
    do {
        ll temp = 0;
        rep(i, R - 1) { temp += d[r[i] - 1][r[i + 1] - 1]; }
        ans = min(ans, temp);
    } while (next_permutation(r, r + R));

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



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

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

int main() {
	int n;
	cin >> n;
	VI a(n);
	rep(i, n)cin >> a[i];
	REVE(a);
	rep(i, n) {
		cout << a[i];
		if (i != n - 1)cout << " ";
	}
	puts("");
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, K, R, S, P; string T; cin >> N >> K >> R >> S >> P >> T;
    char H[T.size()];

    ll ans = 0;
    for (int i = 0; i < T.size(); i++) {
        if (i - K < 0) {
            if (T[i] == 'r') {
                H[i] = 'p';
                ans += P;
            }
            if (T[i] == 'p') {
                H[i] = 's';
                ans += S;
            }
            if (T[i] == 's') {
                H[i] = 'r';
                ans += R;
            }
            continue;
        }
        if (T[i] == 'r') {
            if (H[i - K] == 'p') {
                if (i + K < T.size()) {
                    if (T[i + K] == 'r') H[i] = 's';
                    if (T[i + K] == 'p') H[i] = 'r'; 
                    if (T[i + K] == 's') H[i] = 'p';
                }
            } else {
                H[i] = 'p';
                ans += P;
            }
        }
        if (T[i] == 'p') {
            if (H[i - K] == 's') {
                if (i + K < T.size()) {
                    if (T[i + K] == 'r') H[i] = 's';
                    if (T[i + K] == 'p') H[i] = 'r'; 
                    if (T[i + K] == 's') H[i] = 'p';
                }
            } else {
                H[i] = 's';
                ans += S;
            }
        }
        if (T[i] == 's') {
            if (H[i - K] == 'r') {
                if (i + K < T.size()) {
                    if (T[i + K] == 'r') H[i] = 's';
                    if (T[i + K] == 'p') H[i] = 'r'; 
                    if (T[i + K] == 's') H[i] = 'p';
                }
            } else {
                H[i] = 'r';
                ans += R;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a;
  bool flag = true;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a%2 == 0) {
      if (a%3 != 0 && a%5 != 0) {
        flag = false;
        break;
      }
    }
  }
  
  if (flag)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;
ll n,m,sum=0;
ll a[110000];
pair<ll,ll>x[110000];
int main(){
    cin>>n>>m;
    ll ps1=0,ps2=0;
    rep(i,0,n){cin>>a[i];sum+=a[i];}
    rep(i,0,m)cin>>x[i].second>>x[i].first;
    sort(x,x+m,greater<pair<ll,ll>>());
    sort(a,a+n);
    bool p=true;
    while(p&&ps2<m&&ps1<n){
        if(x[ps2].first>a[ps1] && x[ps2].second>0){sum+=x[ps2].first-a[ps1];ps1++;x[ps2].second--;}
        else if(x[ps2].first<=a[ps1])p=false;
        else if(x[ps2].second==0)ps2++;
    }
    cout<<sum;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int a, b, c;
    int color = 0;
    cin >> a >> b >> c;
    
    if (a == b)
    {
        if (a != c)
        {
            color = 2;
        }
        else
        {
            color = 1;
        }
    }
    else if (a == c || b == c)
    {
        color = 2;
    }
    else
    {
        color = 3;
    }
    
    cout << color << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
 

signed main(){
   
   int n,c,k,a[111111];
   cin>>n>>c>>k;
   int limit=0,co=0,ans=0;
   rep(i,n){
       cin>>a[i];
   }
   sort(a,a+n);
   rep(i,n){
       co++;
       if(i+1==n){
           ans++;
           continue;
       }
       if(a[i+1]-limit>k || co+1>c){
           limit=a[i+1];
           co=0;
           ans++;
       }
   }
   cout<<ans<<endl;
       
}


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

list<int>E[5000], out;
bool V[5000], flag;
int indeg[5000];

void tsort(int s) {
	queue<int>que;
	que.push(s);
	V[s] = true;
	while (!que.empty()) {
		if (que.size() >= 2)flag = true;
		int u = que.front(); que.pop();
		out.push_back(u);
		for (int v : E[u]) {
			indeg[v]--;
			if (!indeg[v] && !V[v]) {
				V[v] = true;
				que.push(v);
			}
		}
	}
}
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(t, m) {
		int i, j; scanf("%d%d", &i, &j);
		i--; j--;
		E[i].push_back(j);
		indeg[j]++;
	}
	rep(i, n) {
		if (!indeg[i] && !V[i])tsort(i);
	}
	for (int i : out)printf("%d\n", i + 1);
	printf("%d\n", flag);
}

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

int main(){
    int A,B;
    cin >> A >> B;
    if((A%3 == 0)||(B%3 == 0)||((A+B)%3 == 0)){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
    return 0;
}

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

using namespace std;

class Bipartite{
public:
    vector< vector<int> > graph;
    vector< int > match, used;
    int time_stamp;

    Bipartite(int n) : graph(n), match(n, -1), used(n, 0), time_stamp(0) {}

    void add_edge(int u, int v){
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    bool dfs(int node){
        used[node] = time_stamp;
        for(auto &to : graph[node]){
            int to_match = match[to];
            if( to_match == -1 || (used[to_match] != time_stamp && dfs(to_match)) ){
                match[node] = to;
                match[to] = node;
                return true;
            }
        }
        return false;
    }

    int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(match[i] == -1) {
        ++time_stamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};

int main() {
  int X, Y, E;
  scanf("%d %d %d", &X, &Y, &E);
  Bipartite bm(X + Y);
  for(int i = 0; i < E; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    bm.add_edge(a, X + b);
  }
  printf("%d\n", bm.bipartite_matching());
}



Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
int main () {
 char a, b;
 cin >> a >> b ;
  
 bool A = (a == 'H');
 bool B = b == 'H';
  
  if ((A&&B) || (!A&&!B) ){
    cout << 'H' << endl;
  }
  else{
    cout << 'D' << endl;
  }
}

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

using namespace std;

int main() {
    int n, num, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> num;
        if((i&1) && (num&1)) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3532
#include <stdio.h>


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

int main(){
  int i,j;
  int v[110],w[110],dp[110][10010];
  int N,W;
  scanf("%d %d",&N,&W);

  for(i = 1; i <= N ; i++){
    scanf("%d %d",&v[i],&w[i]);
  }
  for(i = 0; i <= W ; i++){
    dp[0][i] = 0;
  }

  for(i = 1; i <= N; i++){
    for(j = 0; j <= W ; j++){
      if(j >= w[i]){
	dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
      }else{
	dp[i][j] = dp[i-1][j];
      }
    }
   
  }
  printf("%d\n",dp[N][W]);


  return 0;
}



Measured memory_bytes: 5812
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define qwq (cerr<<"qwq"<<endl)
#define orz(x) (cerr<<#x": "<<x<<endl)
#define orzarr(a,n) {cerr<<#a": "; repeat(__,0,n)cerr<<(a)[__]<<" "; cerr<<endl;}
#define orzeach(a) {cerr<<#a": "; for(auto __:a)cerr<<__<<" "; cerr<<endl;}
#define fi first
#define se second
typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;}
typedef double lf; typedef long double llf; const lf err=1e-11; const lf pi=acos(-1); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;}
typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010;
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
int n,m;
bool pal(string s){
	string t(s);
	reverse(t.begin(),t.end());
	return t==s;
}
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s; int len=s.length();
	cout<<(
	pal(s) && pal(s.substr(0,len/2)) && pal(s.substr(len/2+1,-1))
	?
	"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

N1 = int(S[0:2])
N2 = int(S[2:4])

judge = (N1 < 1 or N1 > 12) * 1 + (N2 < 1 or N2 > 12) * 2 

if judge == 0:
    print("AMBIGUOUS")
elif judge == 1:
    print("YYMM")
elif judge == 2:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3060