akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Int int64_t
#define ll long long
#define pb push_back
using namespace std;
const int MAXN=500005;
Int N,M,K;

int main()
{
    Int N,M;
    cin>>N>>M>>K;
    set<pair<int,int>> both;
    for(int i=0;i<K;++i){
        int u,v;
        cin>>u>>v;
        both.insert({u,v});
    }
    map<int,int> rows;
    map<int,int> cols;
    map<pair<int,int>,int> common;
    priority_queue<pair<int,int>> pq;
    for(auto &itr:both){
        rows[itr.first]++;
        cols[itr.second]++;
        common[{itr.first,itr.second}]++;
    }
    Int a=0,b=0;Int fromRows,fromCols;
    for(auto &itr:rows){
        if(itr.second>a){
            a=itr.second;
            fromRows=itr.first;
        }
    }
    for(auto &itr:cols){
        if(itr.second>b){
            b=itr.second;
            fromCols=itr.first;
        }
    }
    vector<int> poss_rows,poss_cols;
    for(auto itr:rows){
        if(itr.second==a){
            poss_rows.pb(itr.first);
        }
    }
    for(auto itr:cols){
        if(itr.second==b){
            poss_cols.pb(itr.first);
        }
    }
    int ans=rows[fromRows]+cols[fromCols]-1;
    bool commonFind=false;
    for(auto x:poss_rows){
        for(auto y:poss_cols){
            if(!common[{x,y}]) {
                ++ans;
                commonFind=true;
                break;
            }
        }
        if(commonFind) break;
    }
    cout<<ans<<"\n";
    
}


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

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

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

    int flag = 0;
    //cout << h[n - 1] << endl;

    for(long long i = n - 2; i >= 0; i--){
        if(h[i] > h[i + 1]){
            h[i] -= 1;
            if(h[i] > h[i + 1]){
                flag = 1;
                break;
            }
        }
    }

    if(flag == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1024
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
    `(let ((it ,expr))
       ,then
       ,else))

(defun read2 ()
  (cons (read) (read)))

(defun add (a b)
  (cons (+ (car a) (car b)) (+ (cdr a) (cdr b))))

(defun sub (a b)
  (cons (- (car a) (car b)) (- (cdr a) (cdr b))))

(defun rot (x)
  (cons (- 0 (cdr x)) (car x)))

(defun tolist (x)
  (list (car x) (cdr x)))

(defun main (v1 v2)
  (let ((adder (rot (sub v2 v1))))
    (append (tolist (add v2 adder)) (tolist (add v1 adder)))))

(format t "~{~a~^ ~}" (main (read2) (read2)))

(main (read2) (read2))


Measured memory_bytes: 18744
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long ll;
int main()
{
    char s[10];
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes\n";

    }
    else
    {
        cout<<"No\n";
    }
    return 0;
    
}


Measured memory_bytes: 3652
//                        Bismillahir Rahmanir Rahim
//ALGO:
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=0;
int main() {
    char a;
    cin>>a;
    if(a>='a'&&a<='z') cout<<'a';
    else cout<<'A';
}



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

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
 
 
void solve(){
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;
}
 
signed main(){
    //while(1)
    solve();
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        boolean[] isCorrect = new boolean[N];
        int correct = 0;
        int wa = 0;
        int wrong[] = new int[N];
        for(int i = 0; i < M; i++){
            int p = scan.nextInt()-1;
            String str = scan.next();
            if(isCorrect[p]) continue;
            if(str.equals("AC")){
                isCorrect[p] = true;
                correct++;
                wa += wrong[p];
            } else {
                wrong[p]++;
            }
        }
        os.println(correct + " " + wa);
    }
}

Measured memory_bytes: 63432
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t N, H[(int)1e5];
    intmax_t tmp = 0, ans = 0;

    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%jd", &H[i]);
    }

    for (size_t i = 1; i < N; i++) {
        if (H[i - 1] >= H[i]){
            tmp++;
        } else {
            if (tmp > ans) ans = tmp;
            tmp = 0;
        }
    }
    if (tmp > ans) ans = tmp;

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

    return 0;
}


Measured memory_bytes: 896
<?php
$s=trim(fgets(STDIN));
$n=strlen($s);
$ans=0;
$i=0;
while($i<$n){
  if($i%2==0){
    if($s[$i]==0){
      ++$ans;
    }
  }else{
    if($s[$i]==1){
      ++$ans;
    }
  }
  ++$i;
}
echo min($ans,$n-$ans);

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int k, s; cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (0 <= z && z <= k) {
                ans = ans + 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int x = 0;
	if (n % 2 == 0)
	{
		x = (n / 2) * (n / 2);
	}
	else if(n%2==1)
	{
		x = (n / 2) * ((n / 2) + 1);
	}
	cout << x << endl;
	return 0;
}
/*
死のマウス
.　　あり許せん！
　　　∧＿＿∧
　|| （＃｀Д´ ） ||
　|| ( |　 　| | |||
　从| |　 　| |从从
￣) ⊂ノ￣￣!_つ￣て
　フヘ(　　　　ヽヘ(＼

*/

Measured memory_bytes: 256
n=int(input())
a=0
w=0
t=0
r=0
for _ in range(n):
  b=input()
  if b=="AC":
    a+=1
  elif b=="WA":
    w+=1
  elif b=="TLE":
    t+=1
  else:
    r+=1
print("AC x %d"%a)
print("WA x %d"%w)
print("TLE x %d"%t)
print("RE x %d"%r)

Measured memory_bytes: 69804
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(ALL(a));
  int cnt = 0;
  if((a[1]-a[0])%2==1){
    ++cnt;
    ++a[1];
    ++a[2];
  }
  cnt+=(a[1]-a[0])/2;
  cnt+=a[2]-a[1];
  cout<<cnt<<endl;


  return 0;
}


Measured memory_bytes: 256
from fractions import gcd 

A, B, C, D = map(int, input().split())
GCD = gcd(C,D)
LCM = (C * D) // GCD

def countnumber(x):
    number = B // x
    number -= A // x
    if A % x == 0:
        number += 1
    return number 

number = countnumber(C) + countnumber(D) - countnumber(LCM)
answer = B - A - number + 1
print(answer)

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

ll gcd(ll n, ll m) {  // 最大公約数を求めるプログラム
    // nとmの最大公約数を返す関数
    if(m > n) {
        ll c = n;
        n = m; 
        m = c;
    }
    if(n%m == 0) return m;
    else return gcd(m, n%m);
}

ll lcm(ll n, ll m) {  // 最小公倍数を求めるプログラム
    // 依存:gcd
    return n * m / gcd(n, m);
}


int main(){
    int N, M;
    cin >> N >> M;
    int l;
    cin >> l;
    int X = l/2;
    rp(i, 1, N) {
        int a; cin >> a;
        int b = a/2;
        while(X < b) X += l;
        int flag = 1;
        while(flag) {
            if((X-b) % a == 0) {
                flag = 0; continue;
            }
            if(X > M) {
                printf("0\n");
                return 0;
            }
            X += l;
        }
        l = lcm(l, a);
    }
    if(X > M) {
        printf("0\n");
        return 0;
    }
    cout << int((M-X) / l) + 1 << endl;
    return 0;
}

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

using namespace std;

#define MAX 1010
#define INF 1e9

struct Intersection{
  int x,y;
};

struct State{
  int dist,v,dir,c;
  State(int dist,int v,int dir,int c) :
    dist(dist),v(v),dir(dir),c(c) {}
  bool operator < (const State &s)const{
    if(dist != s.dist){
      return dist > s.dist;
    }else{
      return c > s.c;
    }
  }
};

int M,N;
string src,dst;
vector<int> G[MAX];
Intersection n[MAX];
map<string,int> num;

int nextdir(int xs,int ys,int xt,int yt,int dir){
  if(dir == 0){
    if(xs < xt) return -1;
    if(ys > yt) return -1;
    if(xs > xt) return 3;
    return 0;
  }else if(dir == 1){
    if(ys > yt) return -1;
    if(xs > xt) return -1;
    if(ys < yt) return 0;
    return 1;
  }else if(dir == 2){
    if(xs > xt) return -1;
    if(ys < yt) return -1;
    if(xs < xt) return 1;
    return 2;
  }else{
    if(ys < yt) return -1;
    if(xs < xt) return -1;
    if(ys > yt) return 2;
    return 3;
  }
}

int getDist(int x1,int y1,int x2,int y2){
  return max(abs(x2-x1),abs(y2-y1));
}

void solve(){
  priority_queue<State> Q;
  int dist[MAX][4];
  fill(dist[0],dist[0]+MAX*4,INF);
  for(int i = 0 ; i < 4 ; i++){
    Q.push(State(0,num[src],i,1));
    dist[num[src]][i] = 0;
  }
  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int v = s.v,dir = s.dir;
    if(dist[v][dir] < s.dist) continue;
    if(v == num[dst]){
      cout << s.c << endl;
      return;
    } 
    Intersection ni = n[v];
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      Intersection u = n[G[v][i]];
      int ndir = nextdir(ni.x,ni.y,u.x,u.y,dir);
      if(ndir == -1) continue;
      int ndist = s.dist + getDist(ni.x,ni.y,u.x,u.y);
      if(ndist < dist[G[v][i]][ndir]){
        dist[G[v][i]][ndir] = ndist;
        Q.push(State(ndist,G[v][i],ndir,s.c+1));
      }
    }
  }
  cout << "impossible" << endl;
}

int main(){
  string name,a,b;
  int x,y;
  while(cin >> M >> N, M){
    num.clear();
    for(int i = 0 ; i < MAX ; i++){
      G[i].clear();
    }
    for(int i = 0 ; i < M ; i++){
      cin >> name >> x >> y;
      n[i+1] = (Intersection){x,y};
      num[name] = i+1;
    }
    for(int i = 0 ; i < N ; i++){
      cin >> a >> b;
      G[num[a]].push_back(num[b]);
      G[num[b]].push_back(num[a]);
    }
    cin >> src >> dst;
    solve();
  }
  return 0;
}

Measured memory_bytes: 1512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	ll n,m;
	cin>>n>>m;
	vp in(n+m);
	rep(i,n){
		ll a;cin>>a;
		in[i]=pii(a,0);
	}
	rep(i,m){
		ll a;cin>>a;
		in[n+i]=pii(a,1);
	}
	ll out=0;
	sort(all(in));
	ll coa=0,cob=0;
	rep(i,n+m){
		if(in[i].second==0){
			out+=(m+1-cob)*in[i].first;
			coa++;
		}else{
			out+=(n+1-coa)*in[i].first;
			cob++;
		}
//		cout<<out<<endl;
	}
	cout<<out<<endl;
}








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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct UnionFind {
    vector<int> par, s;
    UnionFind(int n=2e5) { init(n); }
    void init(int n) {
        s.assign(n, 1); par.resize(n);
        iota(par.begin(), par.end(), 0);
    }
    int find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
        else par[y] = x, s[x] = s[x] + s[y];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return s[find(x)]; }
};

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

    ll n, m, q;
    cin >> n >> m >> q;
    vector<ll> a(q), b(q), c(q);
    REP(i, q) cin >> a[i] >> b[i] >> c[i];

    if(m == n-1) {
        bool flag = true;
        REP(i, q) if(c[i] == 1) flag = false;
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }

    UnionFind uf(n);
    REP(i, q) if(c[i] == 0) uf.unite(a[i], b[i]);
    REP(i, q) if(c[i] == 1 && uf.same(a[i], b[i])) {
        cout << "No" << endl;
        return 0;
    }
    ll num = 0;
    REP(i, n) if(uf.find(i) == i) num++;

    if(m <= n-num + num*(num-1)/2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

vi decode(int code, int n) {
    vi people(n, 0);
    rep(i, 0, n) {
        if (code % 2 == 1) {
            people[i] = 1;
        } else {
            people[i] = -1;
        }
        code /= 2;
    }
    return people;
}

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

    int n;
    cin >> n;

    vector<map<int, int>> testimonies(n);

    rep(i, 0, n) {
        int a;
        cin >> a;
        rep(j, 0, a) {
            int x, y;
            cin >> x >> y;
            if (y == 1) {
                testimonies[i][x - 1] = 1;
            } else {
                testimonies[i][x - 1] = -1;
            }
        }
    }

    int ans = 0;

    // O(2^n * n^2)
    rep(code, 0, (int)pow(2, n)) {
        vi people = decode(code, n);
        bool valid = true;

        // O(n^2)
        rep(i, 0, n) {
            // Skip unkind.
            if (people[i] == -1) { continue; }

            for (auto t : testimonies[i]) {
                if (people[t.first] != t.second) {
                    valid = false;
                    break;
                }
            }
            if (!valid) { break; }
        }
        if (valid) {
            int cnt = 0;
            rep(i, 0, n) {
                if (people[i] == 1) { ++cnt; }
            }
            ans = max(ans, cnt);
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1000000007LL;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
//from http://noshi91.hatenablog.com/entry/2019/03/31/174006
template <std::uint_fast64_t Modulus>
class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint operator^(const u64 rhs) const noexcept {
        return modint(*this) ^= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr modint &operator^=(u64 exp) {
        modint rhs = modint(*this);
        a = 1;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    friend ostream &operator<<(ostream &os, const modint &x) {
        os << x.a;
        return os;
    }
    friend istream &operator>>(istream &is, modint &x) {
        is >> x.a;
        return is;
    }
};
using mint = modint<MOD>;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    mint res = 0;
    for (ll i = k; i <= n + 1; i++) {
        res += (mint(n + n - i + 1) * i / 2LL) - (mint(i - 1) * i / 2LL) + 1LL;
    }
    cout << res << '\n';
}

Measured memory_bytes: 3648
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 998244353
using namespace std;

ll power(ll a, ll b){
  if(b == 0 || a == 1)
    return 1;
  ll so = power(a, b /2);
  so =(so * so) % mod;
  if(b % 2 == 1)
    so = (so * a) % mod;
  return so;
}
ll fact[200001];
ll ncr(ll n, ll r){
  if(r > n)
    return 0;
  ll ans = fact[n];
  ans = (ans * power(fact[r], mod - 2)) % mod;
  ans = (ans * power(fact[n-r], mod - 2)) % mod;
  return ans;
}
int main() {
	FASTIO
	ll n, m, k;
	cin >> n >> m >> k;
  	fact[0] = 1;
  	rep(i, 1, 200001){
      fact[i] = (i * fact[i-1]) % mod;
    }
	ll ans = 0;
  	rep(i, 0, k + 1){
     ans = (ans + (((ncr(n - 1, i) * m) % mod) * power(m - 1, n - 1 - i)) % mod) % mod;
    }
  	cout << ans;
	return 0;
}




Measured memory_bytes: 5216
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
using namespace std;


int main() {
    string s;
    cin >> s;
    for(int i = 0; i < 19; i++){
        if(s[i] == ','){
            cout << " ";
        }
        else{
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = []
    for _ in range(N):
        ans.append(0)
    for i in A:
        ans[i-1]+=1
    for j in ans:
        print(j)
if __name__ == '__main__':
    main()

Measured memory_bytes: 32184
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>
#include <deque>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

int main() {
	string s;
	cin >> s;
	if (s.size() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	REP(i, s.size() - 1) {
		if (s[i] == 'h' and s[i + 1] == 'i')i++;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin >> str;
    int l = str.length(), r;
    if(l & 1)
    {
        //cout << "odd" << endl;

        r = (l / 2) + 1;
        l = (l / 2) - 1;
    }
    else
    {
        //cout << "even " << endl;
        r = (l / 2);
        l = r - 1;
    }
    //cout << l  << ' ' << r << endl;
    int i = l  , j = r, c = 0;
    while(i >= 0)
        if(str[i--] != str[j++]) c++;
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n;
    vector <ll> a(n+1);
    rep(i,1,n+1) {
        cin >> a[i];
    }
    int count =0;
    for(int i =0;i <a.size();i++) {
        for(int j = i+1; j< a.size();j++) {
            for(int k =j +1; k < a.size() ;k++) {
                if (a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[i] + a[k] > a[j]) {
                    if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;
                    count++;
                }
            }
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define mp make_pair
#define x first
#define y second
#define pll pair<LL,LL>
#define pii pair<int,int>
#define LL long long
#define pb push_back
#define pi acos(-1)
#define pdd pair<double,double>
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-7
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int d[100005];
    LL tot=0;
    for(int i = 0;i<=n;i++){
        scanf("%d",&d[i]);
        tot+=d[i];
    }
    LL now=1;
    LL ans=0;
    for(int i = 0;i<=n;i++){
        if(now<d[i]){
            printf("-1\n");
            return 0;
        }
        ans+=now;
        now-=d[i];
        tot-=d[i];
        now=min(now*2,tot);
    }
    printf("%lld\n",ans);
}
/*
2 11 14
9 3


000111222
001112220
*/

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c;
  cin >> a >> b >> c ;
 if ((c-a-b)*(c-a-b)>4*a*b && c-a-b>0) {cout  << "Yes" << endl;}
  else {cout <<"No" << endl;}
 
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <map>

using namespace std;

double volume(int len){
    double t = len / 3.0;
    return t * t * t;
}


int main(int argc, char* argv[]){
    int L;
    cin >> L;
    cout << std::fixed;
    cout << volume(L) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

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

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

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

bool over(ll a,ll b){
	ll p=a*b;
	if(p/a==b){
		return false;
	}
	else{
		return true;
	}
}

void solve(){

	ll ans=0;
	vector<ll> n(5,0);
	for(ll i=0;i<5;i++){
		cin>>n[i];
		if(n[i]==0){
			cout<<i+1<<endl;
			break;
		}

	}

}


int main(){
	
	solve();
	
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;

// Problem Specific Parameter:

int n,d[2];

using pii = pair<int,int>;
vector<pii> adj[2];
vector<pii> graph[2][610][610];

int color[610][610];
bool visited[610][610];

void dfs(int k,int i,int j,int c){
	visited[i][j] = true;
	color[i][j] |= (c << k);
	for(auto &elem:graph[k][i][j]){
		const int ni = elem.first;
		const int nj = elem.second;
		if(visited[ni][nj]) continue;
		dfs(k,ni,nj,c^1);
	}
}

vector<pii> ans[4];

int main(void){
	cin >> n >> d[0] >> d[1];
	const int limit = 2 * n;

	rep(i,-limit,limit+1){
		rep(j,-limit,limit+1){
			const int cur = i * i + j * j;
			rep(k,2){
				if(d[k] != cur) continue;
				adj[k].push_back(pii(i,j));
			}
		}
	}

	rep(k,2){
		rep(i,limit)rep(j,limit){
			visited[i][j] = false;
			for(auto &elem:adj[k]){
				pii tmp = pii(i + elem.first, j + elem.second);
				if(tmp.first < 0 or limit <= tmp.first) continue;
				if(tmp.second < 0 or limit <= tmp.second) continue;
				graph[k][i][j].push_back(tmp);
			}
		}
		rep(i,limit)rep(j,limit) if(visited[i][j] == false) dfs(k,i,j,0);
	}

	rep(i,limit)rep(j,limit) ans[color[i][j]].push_back(pii(i,j));

	rep(k,4){
		if(ans[k].size() < n * n) continue;
		rep(i,n * n) cout << ans[k][i].first << " " << ans[k][i].second << endl;
		k = 4;
	}


	return 0;
}

Measured memory_bytes: 179452
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int N,M;
  cin>>N>>M;
  int n=N;
  vector<vector<char>> d(N, vector<char>(M));
  while(n--){
    string S;
    cin>>S;  
    for(int j=0; j<M;j++){
      d[N-n-1][j]=S.at(j);
    }
  }
  vector<vector<char>> ans(N, vector<char>(M));
  for(int i=0; i<N;i++){
    for(int j=0; j<M;j++){
      int an=0;
      if(d[i][j]=='#'){
        ans[i][j]='#';
      }
      
      else{
        for(int dx=-1; dx<=1;dx++){
          for(int dy=-1; dy<=1;dy++){
            int nx=i+dx,ny=j+dy;
            if (0<=nx&&nx<N&&0<=ny&&ny<M&&d[nx][ny]=='#'){
              an++;
            }
          }
        }
        
        ans[i][j]=char(an+'0');
      }
    }
  }
        
 
  for(int i=0; i<N;i++){
    for(int j=0; j<M;j++){
      cout<<ans[i][j];
    }
    cout<<endl;
  }

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M;
  cin>>N>>M;
  VI S(M),C(M);
  rep(i,M) cin>>S[i]>>C[i];
  int Q=1;
  if(N==1){
    rep(i,10){
      VI X(1);
      X[0]=i;
      int ans=1;
      rep(j,M){
        if(X[S[j]-1]!=C[j]) ans=0;
      }
      if(ans){
        cout<<i<<endl;
        Q=0;
        break;
      }
    }
  }else if(N==2){
    rep(i,90){
      VI X(2);
      X[0]=(i+10)/10;
      X[1]=(i+10)%10;
      int ans=1;
      rep(j,M){
        if(X[S[j]-1]!=C[j]) ans=0;
      }
      if(ans){
        cout<<i+10<<endl;
        Q=0;
        break;
      }
    }
  }else{
    rep(i,900){
      VI X(3);
      X[0]=(i+100)/100;
      X[1]=(i+100)%100/10;
      X[2]=(i+100)%10;
      int ans=1;
      rep(j,M){
        if(X[S[j]-1]!=C[j]) ans=0;
      }
      if(ans){
        cout<<i+100<<endl;
        Q=0;
        break;
      }
    }
  }
  if(Q) cout<<-1<<endl;
}
  




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

using namespace std;

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

const ll INF=1e9+7;
int n,m,ans;
bool f[9][9],visited[9];
void dfs(int p,int num){
	if(num==n){
		ans++;
		return;
	}
	visited[p]=1; 
	rep(i,n){
		if(!visited[i]&&f[p][i]){
			dfs(i,num+1);
		}
	}
	visited[p]=0;
	return;
}
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>m;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		f[x][y]=f[y][x]=1;
	}
	dfs(1,1);
	cout<<ans;
	return 0;
}

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

int AN, BN, R, XA, YA, XB, YB;

inline long long makeKey(int x, int y) {
    return x * 10000 + y;
}

inline int getX(long long key) {
    return key / 10000;
}

inline int getY(long long key) {
    return key % 10000;
}

int main() {
    ios::sync_with_stdio(false);
    while (1) {
        cin >> AN >> BN >> R;
        if ( ! AN && ! BN && ! R) break;

        vector<long long> xy;
        for (int i=0; i<AN; ++i) {
            cin >> XA >> YA;
            xy.push_back(makeKey(XA, YA));
        }
        sort(begin(xy), end(xy));

        int ans = 0;
        for (int i=0; i<BN; ++i) {
            cin >> XB >> YB;
            auto begin_it = lower_bound(begin(xy), end(xy), makeKey(XB - 4 * R, 0));
            auto end_it = lower_bound(begin(xy), end(xy), makeKey(XB + 4 * R + 1, 0));
            for (auto it=begin_it; it!=end_it; ++it) {
                int dx = getX(*it) - XB;
                int dy = getY(*it) - YB;
                ans += (dx * dx + dy * dy <= 16 * R * R);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2664
import java.util.Scanner;

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

        int x[];
        x = new int[n];

        for (int i = 0; i < n; i++) {
            x[i] = num.nextInt();
        }
        int count = 0;


        int flag = 1;
        while (flag == 1) {
            flag = 0;
            for (int j = n - 1; j >= 1; j--) {
                if (x[j] < x[j - 1]) {
                    int tmp = x[j];
                    x[j] = x[j - 1];
                    x[j - 1] = tmp;
                    flag = 1;
                    count++;
                }
            }
        }

        for (int i = 0; i < n; i++) {
            System.out.printf("%d", x[i]);
            if (i != n - 1) System.out.printf(" ");
            else System.out.printf("\n");
        }

        System.out.println(count);
    }
}


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

int main() {
  int k, s;
  cin >> k >> s;
  
  int ans = 0;
  rep(l,k) {
    rep(m,k) {
      int n = s - l - m;
      if (0 <= n && n <= k) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        static void Solve()
        {
            int n = ReadAndParseInt();
            int ans = 0;
            for(int i = 1; i <= n; ++i)
            {
                ans += i;
            }
            Console.WriteLine(ans);
        }
        
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <list>
#include <climits>
#include <bitset>
#include <fstream>
#include <algorithm>
#include <functional>
#include <stack>
#include <string>
#include <cmath>
#define fi first
#define se second
#define re register
#define ls i << 1
#define rs i << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

//#define endl puts("")
//#define int long long

using namespace std;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);

inline int rd(){
    re int res = 0,flag = 0;char ch;
    if ((ch = getchar()) == '-')flag = 1;
 	else if(ch >= '0' && ch <= '9')res = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')res = (res<<1) + (res<<3) + (ch - '0');
    return flag ? -res : res;
}

void out(int a) {
    if (a < 0) {
        putchar('-');a = -a;
    }
    if (a >= 10) out(a / 10);
    putchar(a % 10 + '0');
}

int t, n, k;

//signed main(){
int main() {
	long long a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    V<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];

    const int start = n * m, end = n * m + 1;
    atcoder::mf_graph<int> graph(n * m + 2);
    
    auto check = [&](int i, int j) -> bool {
        return 0 <= i && i < n && 0 <= j && j < m;
    };

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '#') continue;
            if ((i & 1) ^ (j & 1)) {
                graph.add_edge(start, i * m + j, 1);
                if (check(i + 1, j) && s[i + 1][j] == '.') graph.add_edge(i * m + j, (i + 1) * m + j, 1);
                if (check(i - 1, j) && s[i - 1][j] == '.') graph.add_edge(i * m + j, (i - 1) * m + j, 1);
                if (check(i, j + 1) && s[i][j + 1] == '.') graph.add_edge(i * m + j, i * m + j + 1, 1);
                if (check(i, j - 1) && s[i][j - 1] == '.') graph.add_edge(i * m + j, i * m + j - 1, 1);
            } else graph.add_edge(i * m + j, end, 1);
        }
    }

    cout << graph.flow(start, end) << '\n';

    V<string> ans = s;
    for (auto e: graph.edges()) {
        if (e.from == start || e.to == end || e.flow == 0) continue;
        int x1 = e.from / m, y1 = e.from % m, x2 = e.to / m, y2 = e.to % m;
        if (x1 > x2 || y1 > y2) swap(x1, x2), swap(y1, y2);
        if (x1 + 1 == x2) ans[x1][y1] = 'v', ans[x2][y2] = '^';
        if (y1 + 1 == y2) ans[x1][y1] = '>', ans[x2][y2] = '<';
    }
    
    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


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

int str_to_min(string s){
	int num=0;
	num+=(s[0]-'0')*600;
	num+=(s[1]-'0')*60;
	num+=(s[3]-'0')*10;
	num+=(s[4]-'0');
	return num;
}

int main(){
	int N,T;
	cin>>N>>T;
	
	int cnt=0;
	
	string s1,s2,s3,s4;
	cin>>s1>>s2;
	vector<string>name;
	vector<int>tim;
	for(int i=1;i<N;i++){
		cin>>s1>>s2>>s3>>s4;
		name.push_back(s2);
		int tmp=str_to_min(s3)-str_to_min(s1);
		tim.push_back(tmp);
		if(tmp>=T)cnt++;
	}
	cin>>s1>>s2;
	
	cout<<cnt<<endl;
	for(int i=0;i<name.size();i++){
		if(tim[i]>=T){
			cout<<name[i]<<" "<<tim[i]<<endl;
		}
	}
	
	
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int n;
    while(cin >> n,n){
        int k;
        int res=0;
        bool flg=false;
        REP(i,n){
            cin >> k;
            if(k>0)res++;
            if(k>1)flg=true;
        }
        if(flg)cout << res+1 << endl;
        else cout << "NA" << endl;
    }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int D;
const int T = 26;      // type no kazu
vector<ll> c(T + 1);   // penalty 1-indexed
vector<vector<ll>> s;  // 1-indexed
vector<set<ll>> days(T + 1);
vector<ll> ans;
ll maxScore = 0;

void readInput() {
  cin >> D;
  REP(i, T) { cin >> c[i + 1]; }
  s = vector<vector<ll>>(D + 1, vector<ll>(T + 1));
  REP(i, D) REP(j, T) { cin >> s[i + 1][j + 1]; }
}

ll calcInitScore(const vector<ll>& t) {
  FOR(i, 1, T + 1) {
    days[i].insert(D + 1);
    days[i].insert(0);
  }

  ll beforeScore = 0;
  FOR(i, 1, D + 1) {
    days[t[i]].insert(i);
    // score gain
    ll afterScore = beforeScore + s[i][t[i]];
    // penalty
    FOR(j, 1, T + 1) { afterScore -= c[j] * (i - *(++days[j].rbegin())); }
    beforeScore = afterScore;
  }
  return beforeScore;
}

int main() {
  readInput();

  ans = vector<ll>(D + 1);

  ll minc = 101, mincIdx = 0;
  FOR(i, 1, T + 1) {
    if (minc > c[i]) {
      minc = c[i];
      mincIdx = i;
    }
  }

  FOR(i, 1, D + 1) {
    ll maxs = -1, idx = 0;
    FOR(j, 1, T + 1) {
      if (maxs < s[i][j]) {
        maxs = s[i][j];
        idx = j;
      }
    }
    ans[i] = idx;
    if (maxs > 100) {
      continue;
    }
    ans[i] = mincIdx;
  }

  REP(i, D) { cout << ans[i + 1] << endl; }
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define rep(i,n) for(ll i=0;i<(n);i++)
using namespace std;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll p[n];
    rep(i,n) cin>>p[i];
    ll x=0,y=0,z=0;
    rep(i,n){
        if(p[i]<=a) x++;
        else if (p[i]<=b) y++;
        else z++;
    }
    cout<<min({x,y,z})<<endl;
    return 0;
}

Measured memory_bytes: 256