akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	char a[1000];
	gets(a);
	for(int i=0;i<995;i++){
		if((a[i]=='a')&&(a[i+1]=='p')&&(a[i+2]=='p')&&(a[i+3]=='l')&&(a[i+4]=='e')){
			a[i]='p';
			a[i+1]='e';
			a[i+2]='a';
			a[i+3]='c';
			a[i+4]='h';
		}
		else if((a[i]=='p')&&(a[i+1]=='e')&&(a[i+2]=='a')&&(a[i+3]=='c')&&(a[i+4]=='h')){
			a[i]='a';
			a[i+1]='p';
			a[i+2]='p';
			a[i+3]='l';
			a[i+4]='e';
		}
	}
	cout << a <<"\n";
return 0;
}

Measured memory_bytes: 1092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.regex.Pattern;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        Pattern space = Pattern.compile(" ");

        int m = Integer.parseInt(stdin.readLine());
        long[] d = new long[m];
        long[] c = new long[m];
        for (int i = 0; i < m; i++) {
            long[] line = space.splitAsStream(stdin.readLine()).mapToLong(Long::parseLong).toArray();
            d[i] = line[0];
            c[i] = line[1];
        }

        long a = 0;
        long b = 0;
        for (int i = 0; i < m; i++) {
            a += c[i];
            b += d[i] * c[i];
        }

        stdout.println(a - 1 + (b - 1) / 9);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}

Measured memory_bytes: 93452
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int[] a = new int[w + 1];
    for (int i = 1; i <= w; i++)
      a[i] = i;
    int m = sc.nextInt();
    while (m-- != 0) {
      String[] s = sc.next().split(",");
      int l = Integer.parseInt(s[0]);
      int r = Integer.parseInt(s[1]);
      int t = a[l];
      a[l] = a[r];
      a[r] = t;
    }
    for (int i = 1; i <= w; i++)
      System.out.println(a[i]);
  }
}



Measured memory_bytes: 26252
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n;
    cin>>n;
    map<string,int> a;
    rep(i,n)
    {
        string s;
        cin>>s;
        a[s]++;
    }
    int ans=0;
    for(auto v:a)
    {
        ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 19204
import { readFileSync } from 'fs'
function main() {
  const input = readFileSync('/dev/stdin', 'utf8')
  const [stringN, s] = input.trim().split('\n')
  const n = Number(stringN)
  const slimes = s.trim().split('')
  let color = ''
  let count = 0
  slimes.forEach(slime => {
    if (color !== slime) {
      count++
    }
    color = slime
  });
  console.log(count)
}
main()


Measured memory_bytes: 8396
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
edges=[[] for _ in range(n)]
S=[]
T=[0]*n
for _ in range(m):
    x,y=map(int,input().split())
    edges[x-1].append(y-1)
    T[y-1]+=1
for i in range(n):
    if T[i]==0:
        S.append(i)
DP=[0]*n
while S:
    fr=S.pop()
    for to in edges[fr]:
        T[to]-=1
        if T[to]==0:
            S.append(to)
        DP[to]=max(DP[to],DP[fr]+1)
print(max(DP))

Measured memory_bytes: 56880
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
Alist = np.array(inpl())
print(1.0/((1.0/Alist).sum()))

Measured memory_bytes: 12428
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            
            if(op.equals("?")){
                break;
            }
            
            if(op.equals("+")){
                System.out.println(a+b);
            }else if(op.equals("-")){
                System.out.println(a-b);
            }else if(op.equals("/")){
                System.out.println(a/b);
            }else if(op.equals("*")){
                System.out.println(a*b);
            }
        }
    }
}


Measured memory_bytes: 26264
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
using namespace std;
#define int long long
typedef pair<int,int> P;
string s[3];
int c;
P ch(int p,int x){
  P a;a=P(0,0);
  r(i,10)if(c+i)if(s[0][p]=='?'||s[0][p]==i+'0')
    r(j,10)if(c+j)if(s[1][p]=='?'||s[1][p]==j+'0'){
      int t=i+j+x;
      if(s[2][p]!='?'&&t%10!=s[2][p]-'0')continue;
      if(t>9)a.fi++;
      else a.se++;
    }
  return a;
}
main(){
  while(cin>>s[0],s[0]!="0"){
    cin>>s[1]>>s[2];c=1;
    r(i,3)reverse(s[i].begin(),s[i].end());
    int sum1=1,sum2=0,t;
    r(i,s[0].size()){
      if(i==s[0].size()-1)c--;
      P a1=ch(i,0),a2=ch(i,1);
      t=sum1*a1.se+sum2*a2.se;
      sum2=(sum1*a1.fi+sum2*a2.fi)%1000000007;
      sum1=t%1000000007;
    }
    cout<<sum1<<endl;
  }
}

Measured memory_bytes: 3156
//AtCoder ABC095 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    ll ans=A*X+B*Y;
    ll cnum=2;
    while(true){
        ll tmp=A*max(X-cnum/2,(ll)0)+B*max(Y-cnum/2,(ll)0)+cnum*C;
        if(ans > tmp){
            ans=tmp;
            cnum+=2;
        } else {
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll cntr = 0, cntg = 0, cntb = 0;
    rep(i, n){
        if(s.at(i) == 'R') cntr++;
        if(s.at(i) == 'G') cntg++;
        if(s.at(i) == 'B') cntb++;
    }
    ll sum = cntr * cntg * cntb;
    cntr = 0;
    cntg = 0;
    cntb = 0;
    REP(i, n){
        rep(k, i){
            cntr = 0;
            cntg = 0;
            cntb = 0;
            for(int j = 0; j+k < n; j += i){
                if(s.at(k+j) == 'R') cntr = 3;
                if(s.at(k+j) == 'G') cntg = 3;
                if(s.at(k+j) == 'B') cntb = 3;
                
                if(cntr > 0 && cntb > 0 && cntg > 0) sum--;
                //cout << cntr << cntg << cntb << endl;
                if(cntr != 0) cntr--;
                if(cntg != 0) cntg--;
                if(cntb != 0) cntb--;
            }
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll N, K;
    cin >> N >> K;
    map<int, ll> mp;
    rep(i, N){
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    ll sum = 0;
    int ans;
    for(auto p : mp){
        sum += p.second;
        if(sum >= K){
            ans = p.first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

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

    // vector<int> diff(n);
    map<int, int> diffCnt;
    rep(i, 0, n) {
        int idx;
        cin >> idx;
        diffCnt[idx]++;
    }

    int m;
    cin >> m;

    rep(i, 0, m) {
        int idx;
        cin >> idx;
        diffCnt[idx]--;
        if (diffCnt[idx] < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 9600
from collections import deque

N, M=map(int,input().split())
a=[]
b=[]
for i in range(M):
  A,B=map(int,input().split())
  a.append(A)
  b.append(B)

graph = [[] for _ in range(N + 1)]
for i in range(M):
  graph[a[i]].append(b[i])
  graph[b[i]].append(a[i])

    # bfs
queue = deque([1])
signposts = [0] * (N + 1)
signposts[1] = 1
while queue:#キューが空になるまで
  u = queue.popleft()
  for v in graph[u]:
    if not signposts[v]:
      signposts[v] = u
      queue.append(v)
 
if all(signposts[2:]):
  print("Yes")
  print("\n".join(map(str, signposts[2:])))
else:
  print("No")

Measured memory_bytes: 45564
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int c[maxn][2], tot = 1, rt = 1;
char s[maxn];
inline void ins(const char * s) {
	int x = rt, last;
	for(;*s;++s) {
		int & p = c[x][*s & 1];
		last = 1;
		if(!p) p = ++tot, last = 0;
		x = p;
	}
	if(last) {
		cout << "Bob" << '\n';
		exit(0);
	}
}
ll ans;
inline void dfs0(int x, ll dep) {
	if(!x) {
		ans ^= dep & -dep;
		return ;
	}
	dfs0(c[x][0], dep - 1);
	dfs0(c[x][1], dep - 1);
}
int n; ll L;
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> L;
	for(int i = 0;i < n;++i) {
		cin >> s, ins(s);
	}
	dfs0(1, L + 1);
	cout << (ans ? "Alice" : "Bob") << '\n';
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
int main() {
    // input
    int n; cin >> n;
    vector<int> x(n); repeat (i,n) { cin >> x[i]; -- x[i]; }
    // solve
    vector<int> a(n*n, -1);
    repeat (i,n) a[x[i]] = i;
    vector<int> ix(n);
    whole (iota, ix, 0);
    whole (sort, ix, [&](int i, int j) { return x[i] < x[j]; });
    int j = 0;
    for (int i : ix) {
        for (int k = 0; k < i; ) {
            assert (j < n*n);
            if (a[j] == -1) {
                a[j] = i;
                ++ k;
            } else if (a[j] == i) {
                a.clear();
                goto done;
            }
            ++ j;
        }
    }
    whole(reverse, ix);
    j = n*n-1;
    for (int i : ix) {
        for (int k = 0; k < n-i-1; ) {
            assert (j >= 0);
            if (a[j] == -1) {
                a[j] = i;
                ++ k;
            } else if (a[j] == i) {
                a.clear();
                goto done;
            }
            -- j;
        }
    }
done: ;
    // output
    if (a.empty()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        repeat (i,n*n) {
            if (i) cout << ' ';
            cout << a[i] + 1;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
import scala.annotation.tailrec
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
//  val a, b, k = sc.nextInt
  val h, w = sc.nextInt
//  val d = List.fill(7)(sc.nextInt)
//  val j = List.fill(7)(sc.nextInt)
  val list = List.fill(h)(sc.next)


  list.foreach(l => {
      l.foreach(print(_))
      println("")
      l.foreach(print(_))
      println("")
    }
  )

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }

  // https://stackoverflow.com/questions/10199171/matcherror-when-match-receives-an-indexedseq-but-not-a-linearseq/10199441#10199441
  object +: {
    def unapply[T](s: Seq[T]) =
      s.headOption.map(head => (head, s.tail))
  }

  @tailrec
  def foldLeftWithNext[A, B](seq: Seq[A])(z: B)(op: (B, A, A) => B)(tailOp: (B, A) => B): B = {
    seq match {
      case Nil => z
      case a +: Nil => tailOp(z, a)
      case a +: next +: tail => foldLeftWithNext(next +: tail)(op(z, a, next))(op)(tailOp)
    }
  }
}

Measured memory_bytes: 175668
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I a,b;
  cin >> a >> b;
  I t= lcm(a,b);
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
I = input()
S = list(I)
temp = []
for i in range(8):
    for j in range(3):
        if i & 2**j > 0:
            temp.append(S[j] + "+")
        else:
            temp.append(S[j] + "-")
    temp.append(S[len(S)-1])
    temp = "".join(temp)
    if eval(temp) == 7:
        temp = temp + "=7"
        break
    temp = []

print(temp)    

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef long long ll;

const int MAX_SIZE = 10000;

struct edge{
	int to;
	int cost;
};

typedef pair<int,int> P;
int V;

const int MAX_V = 5000;

vector<edge> G[MAX_V];
int d[MAX_V];
const int INF = 100000000;

int prevv[MAX_V];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d,d+MAX_V,INF);
  fill(prevv,prevv+MAX_V,-1);
  d[s] = 0;
  que.push(P(0,s));
  while(!que.empty()){
	  P p = que.top();
	  que.pop();
	  int v = p.second;
	  if(d[v] < p.first)
		  continue;
	  for(int i = 0; i < G[v].size(); i++){
		  edge e = G[v][i];
		  if(d[e.to] > d[v] + e.cost){
			  d[e.to] = d[v] + e.cost;
			  que.push(P(d[e.to],e.to));
			  // ツつサツづ個ノツーツドツづ鳴づ個催短ツ仰猟猟」ツ経ツ路ツづーツ記ツ録ツつオツづつィツつュ
			  prevv[e.to] = v;
		  }
	  }
  }
}


int main(){

	int n,m;
	cin>>n;
	cin>>m;
	char cm;
	for(int i = 0; i < m; i++){
		int from,to,c1,c2;
		cin>>from>>cm>>to>>cm>>c1>>cm>>c2;
		edge e;
		e.to = to;
		e.cost = c1;
		G[from].push_back(e);
		e.cost=c2;
		e.to=from;
		G[to].push_back(e);
	}

	int s,g;
	int money;
	int val;
	cin>>s>>cm>>g>>cm>>money>>cm>>val;

	int sumCost=0;
	dijkstra(s);
	sumCost+=d[g];
	dijkstra(g);
	sumCost+=d[s];

	int t=money-val-sumCost;
	cout<<t<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <stack>
#include <list>
using namespace std;

int main(int argc, char *argv[])
{
  int commandNum = 0;
  list<int> li;

  string sCommand;
  int iSubCommand;
  cin >> commandNum;

  for (int i = 0; i  < commandNum; i++) {
    cin >> sCommand;
    if (sCommand == "insert") {
      cin >> iSubCommand;
      li.push_front(iSubCommand);
    }else if(sCommand == "delete"){
      cin >> iSubCommand;
      for (list<int>::iterator itr = li.begin(); itr != li.end(); itr++) {
	if (*itr == iSubCommand) {
	  li.erase(itr);
	  break;
	}
      }
    }else if(sCommand == "deleteFirst"){
      li.pop_front();
    }else if(sCommand == "deleteLast"){
      li.pop_back();
    }else{
      
    }
  }

  auto it = li.begin();
  for (; it != --li.end(); it++) {
    cout << *it << " ";
  }
  cout <<  *it << "\n";
  return 0;
}



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

int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  if (a[0] == a[1]) {
    cout << a[2] << endl;
  } else {
    cout << a[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int p[210000];
int q[210000];
int s[210000];
int t[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++)scanf("%d",q+i);
	int ret=0;
	for(int i=0;i<29;i++){
		for(int j=0;j<a;j++){
			s[j]=p[j]%(1<<(i+1));
			t[j]=q[j]%(1<<(i+1));
		}
		std::sort(s,s+a);
		std::sort(t,t+a);
		long long tmp=0;
		for(int j=0;j<a;j++){
			tmp+=lower_bound(t,t+a,(1<<i)*4-s[j])-lower_bound(t,t+a,(1<<i)*3-s[j]);
			tmp-=lower_bound(t,t+a,(1<<(i+1))-s[j])-lower_bound(t,t+a,(1<<i)-s[j]);
		}
		//printf("%lld\n",tmp);
		if(tmp%2)ret+=(1<<i);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int h[100000];

int main() {
    cin >> n;
    rep(i,n) cin >> h[i];
    int ans = 0;
    int now = 0;
    for (int i = 1; i < n; i++) {
        if (h[i-1] >= h[i]) {
            now++;
        } else {
            now = 0;
        }
        ans = max(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<int,int>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll n;

ll dfs(ll dig, string tmp, bool b) {
	if(dig == 9) {
		if(stol(tmp) > n) return 0;
		vector<bool> ok(3,false);
		REP(i,9) {
			if(tmp[i] == '3') ok[0] = true;
			if(tmp[i] == '5') ok[1] = true;
			if(tmp[i] == '7') ok[2] = true;
		}
		if(ok[0] && ok[1] && ok[2]) return 1;
		else return 0;
	}
	ll ret = 0;
	if(!b) {
		ret += dfs(dig + 1, tmp + "0", false);
		ret += dfs(dig + 1, tmp + "3", true);
		ret += dfs(dig + 1, tmp + "5", true);
		ret += dfs(dig + 1, tmp + "7", true);
	} else {
		ret += dfs(dig + 1, tmp + "3", true);
		ret += dfs(dig + 1, tmp + "5", true);
		ret += dfs(dig + 1, tmp + "7", true);
	}
	return ret;
}

/* --------------------------------------- */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	cout << dfs(0, "", false) << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
map<ll,ll> ma;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int n;  cin >> n;
  vector<vector<int> > v(n);
  rep(i,0,n){
    v[i].resize(10);
    rep(j,0,10){
      cin >> v[i][j];
    }
  }
  vector<vector<ll> > p(n);
  rep(i,0,n){
    p[i].resize(11);
    rep(j,0,11){
      cin >> p[i][j];
    }
  }
  ll ma = -1e18;
  for(int bit=1 ; bit<(1<<10) ; bit++){
    int d[n];
    rep(i,0,n){
      d[i] = 0;
    }
    for(int i=0 ; i<10 ; i++){
      if(bit & (1<<i)){
        for(int j=0 ; j<n ; j++){
          if(v[j][i]){
            d[j]++;
          }
        }
      }
    }
    ll k=0;
    rep(i,0,n){
      k += p[i][d[i]];
    }
    chmax(ma, k);
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/*---------------------------------------------------------------------------------------------------------------------*/

const int M = 2e5 + 5;

int main(){


	int n, k;
	si(n);  si(k);

	int ans = 0;
	for(int i = 1 ; i <= n ; i += 2){
        ans++;
	}

	if(ans >= k){
        cout<<"YES";
	}
	else{
        cout<<"NO";
	}



}






































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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;

vector<int> v[100005];
int d[100005];
ll cnt[2]={};
bool All = false;
void dfs(int n, int b=-1, int color=0){
	if( d[n] >= 0 && d[n] != color ){
		All = true;
		return;
	}
	if( d[n] == color ) return;
	d[n] = color;
	cnt[color]++;
	for(auto t: v[n]) if(t != b){
		dfs(t, n, (color+1)%2);
	}
}

int main(){
	//ios_base::sync_with_stdio(0);
	ll N, M, ans=0;

	cin >> N >> M;
	rep(i,M){
		int A, B;
		cin >> A >> B;
		A--; B--;
		v[A].push_back(B);
		v[B].push_back(A);
	}

	Fill(d, -1);
	dfs(0);

	if( All ){
		ans = N * (N-1) / 2ll;
	}else{
		//cout << cnt[0] << " " << cnt[1] << endl;
		ans = cnt[0] * cnt[1];
	}
	ans -= M;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6912
s = input()
forward = int(s[:2])
backward = int(s[2:])

fb = [forward, backward]

flag12 = [False, False]
flag0 = [False, False]

for i in range(2):
    if fb[i] > 12:
        flag12[i] = True
    if fb[i] == 0:
        flag0[i] = True

# 前半部分は何が来ても良い。後半にくるものが面倒
if backward > 12 or backward == 0:
    if forward > 12 or forward == 0:
        print("NA")
    else:
        print("MMYY")
elif forward > 12 or forward == 0:
    if backward > 12 or backward == 0:
        print("NA")
    else:
        print("YYMM")
else:
    print("AMBIGUOUS")


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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(a+b+c+d==21 && a*b*c*d==252) puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
//Dinic O(EV^2)
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<limits>
template<typename T>
struct MF{
	struct edge{
		int to,rev;
		T cap;
	};
	vector<vector<edge> >G;
	vector<int>level,iter;
	MF(int n_=0):G(n_),level(n_),iter(n_){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back({to,(int)G[to].size(),cap});
		G[to].push_back({from,(int)G[from].size()-1,0});
	}
	T dfs(int u,int t,T f)
	{
		if(u==t)return f;
		for(;iter[u]<G[u].size();iter[u]++)
		{
			edge&e=G[u][iter[u]];
			if(e.cap>0&&level[u]<level[e.to])
			{
				T d=dfs(e.to,t,min(f,e.cap));
				if(d>0)
				{
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(;;)
		{
			fill(level.begin(),level.end(),-1);
			queue<int>P;
			level[s]=0;
			P.push(s);
			while(!P.empty())
			{
				int u=P.front();P.pop();
				for(edge&e:G[u])
				{
					if(e.cap>0&&level[e.to]<0)
					{
						level[e.to]=level[u]+1;
						P.push(e.to);
					}
				}
			}
			if(level[t]<0)return ret;
			fill(iter.begin(),iter.end(),0);
			for(T f;(f=dfs(s,t,numeric_limits<T>::max()))>0;)ret+=f;
		}
	}
};
int H,W;
main()
{
	cin>>H>>W;
	MF<int>mf(H*W*2+H+W);
	int S,T;
	for(int i=0;i<H;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<W;j++)if(s[j]!='.')
		{
			int id=i*W+j;
			if(s[j]=='S')S=id*2+1;
			if(s[j]=='T')T=id*2;
			mf.add_edge(id*2,id*2+1,1);
			mf.add_edge(2*H*W+i,id*2,1e9);
			mf.add_edge(2*H*W+H+j,id*2,1e9);
			mf.add_edge(id*2+1,2*H*W+i,1e9);
			mf.add_edge(id*2+1,2*H*W+H+j,1e9);
		}
	}
	int ans=mf.max_flow(S,T);
	cout<<(ans<1e9?ans:-1)<<endl;
}

Measured memory_bytes: 2816
s = input()
if len(s)%2 == 0:
    for i in range(len(s)):
        if i%2==0 and s[i] != 'h':
            print("No")
            break
        if i%2==1 and s[i] != 'i':
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")
    


Measured memory_bytes: 2940
N = int(input())
D = {}
for _ in range(N):
    S = "".join(sorted(input()))
    if S in D:
        D[S] += 1
    else:
        D[S] = 1

ans = 0
for v in D.values():
    ans += v * (v - 1) // 2

print(ans)


Measured memory_bytes: 17852
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 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;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
signed main() {
    int h,r;cin>>h>>r;
    if(h+r<0)cout<<-1<<endl;
    if(h+r==0)cout<<0<<endl;
    if(h+r>0)cout<<1<<endl;
}



Measured memory_bytes: 3088
x, y = map(int,input().split())

A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]
ans = "No"
if((x in A and y in A) or (x in B and y in B) or (x in C and y in C)):
  ans = "Yes"
print(ans)

Measured memory_bytes: 3064
long a[400],p[1<<16],s[1<<16];i,I;main(n){for(scanf("%d",&n);I<1<<n;I++){for(i=0;i<n*n;i++)I||scanf("%ld",a+i),s[I]+=I&1<<i/n&&I&1<<i%n?a[i]:0;for(i=I;i;i&=I)p[I]=fmax(p[I],p[I^i]+s[i--]/2);}printf("%ld",p[I-1]);}

Measured memory_bytes: 1280
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N;
    cin >> N;
    vector<llong> A(N, 0);
    llong ans=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<A.size()-1; i++){
        for(int j=i+1; j<A.size(); j++){
            ans = max(ans, (llong)abs(A[i]-A[j]));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3192
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: Vec<char> = sc.chars();
    let n = s.len();
    let mut odds: Vec<usize> = vec![0; n];
    let mut evns: Vec<usize> = vec![0; n];

    for i in 0..n {
        if s[i] == 'L' {
            odds[i] = evns[i-1];
            evns[i] = odds[i-1];
        } else {
            if s[i + 1] == 'L' {
                odds[i] = i + 1;
                evns[i] = i;
            } else {
            }
        }
    }
    for i in (0..n-1).rev() {
        if s[i] == 'R' && s[i+1] == 'R' {
            odds[i] = evns[i+1];
            evns[i] = odds[i+1];
        }
    }
    // trace!(&odds);
    // trace!(&evns);

    let mut ans = vec![0; n];
    for i in 0..n { ans[evns[i]] += 1; }
    put!(..ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

const ll INF = 1e10;

int main() {
  int n, m; cin >> n >> m;
  vector<vector<ll>> dist(n, vector<ll>(n, INF));
  for (int i = 0; i < n; ++i) dist[i][i] = 0;
  for (int i = 0; i < m; ++i) {
    int s, t, d; cin >> s >> t >> d;
    dist[s][t] = d;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (dist[i][k] == INF || dist[k][j] == INF) continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (dist[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (j) cout << ' ';
      cout << ( (dist[i][j] == INF) ? "INF" : to_string(dist[i][j]) );
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  V<i64> A(N), B(N);
  i64 asum = 0, bsum = 0;
  REP(i, N) {
    cin >> A[i];
    asum += A[i];
  }
  REP(i, N) {
    cin >> B[i];
    bsum += B[i];
  }
  if (bsum > asum) {
    cout << -1 << endl;
    return 0;
  }
  V<tuple<i64, int>> dif(N);
  REP(i, N) { dif[i] = {A[i] - B[i], i}; }
  sort(dif.begin(), dif.end());
  int ans = 0;
  int hd = 0, tl = N - 1;
  for (; hd < N;) {
    DEBUG(hd, tl);
    // REP(j, N) {
    //   auto [s, _] = dif[j];
    //   cerr << '(' << s << ')';
    // }
    // cerr << endl;
    auto& [dh, ih] = dif[hd];
    if (dh >= 0) break;
    if (tl < 0) {
      cout << -1 << endl;
      return 0;
    }
    auto& [dt, it] = dif[tl];
    i64 x = min(-dh, dt);
    dh += x;
    dt -= x;
    if (dh == 0) ++hd;
    if (dt == 0) {
      --tl;
    }
  }
  REP(i, N) {
    auto [x, y] = dif[i];
    if (x != A[y] - B[y]) {
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6336
#include<stdio.h>
#include<math.h>
int main(){
	int a;
	double PI = acos(-1);
	while(scanf("%d",&a),~a){
		double x=1.0, y=0.0,r=PI/2;
		for(int i=0;i<a-1;i++){
			y+=sin(r);x+=cos(r);
			r=atan(y/x);
			if(x<0)r=r+PI;
			r+=PI/2;
		}
		printf("%.2lf\n%.2lf\n",x,y);
	}
}


Measured memory_bytes: 3060
h,w=map(int,input().split())
A=[[0]*w for i in range(h+1)]
for i in range(h):
  A[i]=list(map(int,input().split()))
a=0
b=0
for i in range(h):
  if i%2==0:
    for j in range(w):
      if i==h-1 and j==w-1:
        continue
      b=b+A[i][j]
      if b%2==1:
        a=a+1
  else:
    for j in range(w-1,-1,-1):
      if i==h-1 and j==0:
        continue
      b=b+A[i][j]
      if b%2==1:
        a=a+1
print(a)
for i in range(h):
  if i%2==0:
    for j in range(w):
      if i+j==h+w-2:
        continue
      elif A[i][j]%2==0:
        continue
      else:
        if j!=w-1:
          I=i
          J=j+1
          A[i][j+1]+=1
          print(i+1,j+1,I+1,J+1)
        else:
          I=i+1
          J=w-1
          A[i+1][w-1]+=1
          print(i+1,j+1,I+1,J+1)
  else:
    for j in range(w-1,-1,-1):
      if i==h-1 and j==0:
        continue
      elif A[i][j]%2==0:
        continue
      else:
        if j!=0:
          I=i
          J=j-1
          A[i][j-1]+=1
          print(i+1,j+1,I+1,J+1)
        else:
          I=i+1
          J=0
          A[i+1][0]+=1
          print(i+1,j+1,I+1,J+1)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;
const int INFLL=1001001001001001001ll;
const int mod=1000000007;
inline void am(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

set<pint>xs,ys;
bool used[111111];
signed main(){
    int N;
    cin>>N;
    vint X(N),Y(N);
    rep(i,N){
        cin>>X[i]>>Y[i];
        xs.insert({X[i],i});
        ys.insert({Y[i],i});
    }

    int sum=0;
    priority_queue<pint,vector<pint>,greater<pint>>que;
    que.push({0,0});
    while(que.size()){
        int d,v;
        tie(d,v)=que.top();
        que.pop();
        if(used[v])continue;
        sum+=d;
        used[v]=true;
        xs.erase({X[v],v});
        ys.erase({Y[v],v});

        auto it=xs.lower_bound({X[v],-1});
        if(it!=xs.end()){
            que.push({it->fi-X[v],it->se});
        }
        if(it!=xs.begin()){
            it--;
            que.push({X[v]-it->fi,it->se});
        }

        it=ys.lower_bound({Y[v],-1});
        if(it!=ys.end()){
            que.push({it->fi-Y[v],it->se});
        }
        if(it!=ys.begin()){
            it--;
            que.push({Y[v]-it->fi,it->se});
        }
    }

    cout<<sum<<endl;
    return 0;
}


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

int main(){
    int a, b, c;
     
    cin >> a >> b >> c;

    if (a + b == c){
        cout << "Yes" << endl;
        return 0;
    }else if(a + c == b){
        cout << "Yes" << endl;
        return 0;
    }else if(b + c == a){
        cout << "Yes" << endl;
        return 0;
    }
cout << "No" << endl;
return 0;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

alice = 0
bob = 0
turn = "alice"

a.sort()
a.reverse()

for i in range(n):
    if turn == "alice":
        alice += a[i]
        turn = "bob"
    else:
        bob += a[i]
        turn = "alice"

print(alice-bob)


Measured memory_bytes: 3060
X = int(input())

if 1800 <= X <=1999:
    print(1)
elif 1600 <= X <=1799:
    print(2)
elif 1400 <= X <=1599:
    print(3)
elif 1200 <= X <=1399:
    print(4)
elif 1000 <= X <=1199:
    print(5)
elif 800 <= X <=999:
    print(6)
elif 600 <= X <=799:
    print(7)
else:
    print(8)

Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int main(){
  int n,w,weight,value;
  cin>>n>>w;
  long dp[w+1]={0};
  for(int i=0;i<n;i++){
    cin>>weight>>value;
    for(int j=w;j>=weight;j--)dp[j]=max(dp[j],dp[j-weight]+value); 
  }
  cout<<dp[w]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int N,M;
string S;

signed main(){
  cin>>N>>M;
  vector<int>  H(N);
  REP(i,0,N)cin>>H[i];
  vector<vector<int>> road(N);
  int a,b;
  REP(i,0,M){
    cin>>a>>b;
    a--;b--;
    road[a].push_back(b);
    road[b].push_back(a);
  }
  int ans=0;
  vector<bool> used(N);
  REP(i,0,N){
    if(used[i]){
      continue;
    }
    bool flg=true;
    each(r,road[i]){
      if(H[i]>H[r]){
        used[r]=true;
      }
      else{
        flg=false;
        break;
      }
    }
    if(flg){
      ans++;
    }
  }
  print(ans);

}


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

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

    for (int i = 1; i <= N; i++) {
        int dt = t[i] - t[i - 1];
        int dx = abs(x[i] - x[i - 1]);
        int dy = abs(y[i] - y[i - 1]);

        if (dx + dy > dt || (dx + dy) % 2 != dt % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}

void solve()
{
map<int,int>m;
for(int i=1;i<=100;i++)
{
    for(int j=1;j<=100;j++)
    {
        for(int k=1;k<=100;k++)
        {
            int x=i*i+i*j+i*k+j*j+j*k+k*k;
            m[x]++;
        }
    }
}
int n;
cin>>n;
for(int i=1;i<=n;i++)
    cout<<m[i]<<"\n";
}

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



Measured memory_bytes: 5976
#include <iostream>
#include <cmath>

using namespace std;

int main() 
{
	int N;
	int H[1000];
	double T, A;
	double min = 1e9;
	int ans;

	cin >> N >> T >> A;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	for (int i = 0; i < N; i++) {
		if (abs(A - (T - H[i] * 0.006)) < min) {
			min = abs(A - (T - H[i] * 0.006));
			ans = i + 1;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def fn(x)
  if x >= 1 && x <= 12
    return true
  else
    return false
  end
end

s0 = gets.chars.map(&:to_i)
s1 = s0[0] * 10 + s0[1]
s2 = s0[2] * 10 + s0[3]

if fn(s1) && fn(s2)
  puts :AMBIGUOUS

elsif fn(s1)
  puts :MMYY

elsif fn(s2)
  puts :YYMM

else
  puts :NA

end


Measured memory_bytes: 3836
#include <iostream>
using namespace std;
int main(){
    int x,h1=0,h2=0,h3=0;
    for(int i=0;i<10;i++){
        cin >> x;
        if(h1<=x){
            h3 = h2;
            h2 = h1;
            h1 = x;
        }else if(h1>=x && x>=h2){
            h3 = h2;
            h2 = x;
        }else if(h2>=x && x>=h3){
            h3 = x;
        }
    }
    cout << h1 << endl << h2 << endl << h3 << endl;
    return 0;
}


Measured memory_bytes: 3112