akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x, y, z;
        int xx, yy, zz, xy;
        int count = 0;
        int mid = sqrt(n) + 1;
        for (x = 1; x < mid; x++) {
            xx = x * x;
            for (y = 1; y <= x; y++) {
                yy = y * y;
                xy = x * y;
                if (xx + yy >= n) {
                    break;
                }
                for (z = 1; z <= y; z++) {
                    zz = z * z;
                    if (yy + zz >= n) {
                        break;
                    }
                    if (xx + yy + zz + xy + x * z + y * z == i) {
                        if (x == y && x == z && y == z) {
                            count++;
                        } else if (x != y && x != z && y != z) {
                            count += 6;
                        } else {
                            count += 3;
                        }
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 2124
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  n = InputLine.to_i
  x = InputLine.to_ia

  m = 1e+12
  (1..100).each do |p|
    s = 0
    n.times{|i| s += (x[i] - p) ** 2}
    m = [m, s].min
  end
  puts m.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

int main() {
    int x, n; cin >> x >> n;
    int p[n];
    rep(i, n) cin >> p[i];
    int left = x, right = x;
    if(n == 0){
        cout << x << endl;
        return 0;
    }
    bool frag1 = true;
    rep(i, n){
        if(p[i] == x) frag1 = false;
    }
    if(frag1){
        cout << x << endl;
        return 0;
    }
    while(1){
        left--;
        bool frag = true;
        rep(i,n){
            if(left == p[i]) frag = false;
        }
        if(frag){
            // cout << "now" <<endl;
            cout << left << endl;
            return 0;
        }
        right++;
        frag = true;
        rep(i,n){
            if(right == p[i]) frag = false;
        }
        if(frag){
            cout << right << endl;
            return 0;
        }

    }

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  ll N;
  std::cin >> N;

  std::map< std::string, ll > mc;
  for (ll i = 0; i < N; i++) {
    std::string s;
    std::cin >> s;
    std::sort(s.begin(), s.end());
    mc[s]++;
  }

  ll cnt = 0LL;
  for (auto& x : mc) {
    if (x.second > 1) cnt += x.second * (x.second - 1) / 2;
  }

  print(cnt);
  return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>  
#define lli long long 
using namespace std; 
long long mod=1e9+7;
// lli power(lli x, lli y,lli m=mod) 
// {
//     lli res = 1;  
   
//     while (y > 0) 
//     { 
//         if (y & 1) 
//             res = (res*x)%m; 
//         y = y>>1; 
//         x = (x*x)%m;  
//     }
//     if(res<0)
//        res+=m; 
//     return res; 
// }
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
int main() 
{ 
    // fact[0]=1;
    // for(int i=1;i<=2000005;i++)fact[i]=(i*fact[i-1])%mod;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        int x;cin>>x;x=1-x;
        cout<<x<<"\n";
    }
    return 0; 
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define maxx 100010
using namespace std;
long long n,w,peso[200],valor[200],dp[200][maxx];

int main() {
	cin >> n >> w;
	for(int i = 1; i <= n; i++){
		cin >> peso[i] >> valor[i];
	}

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= w; j++){
			if(peso[i] <= j){
				dp[i][j] = max(valor[i] + dp[i-1][j - peso[i]],dp[i-1][j]);
			}
			else dp[i][j] = dp[i-1][j];
		}
	}

	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 81716
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL  INF=1<<31;



int main(){
     LL n,x;
     cin>>n>>x;
     LL a[100005];
     for(int i=0;i<n;++i){
          cin>>a[i];
     }
          LL ans=0;
          if(a[0]>x){
               ans+=a[0]-x;
               a[0]=x;
          }

     for(int i=0;i<n-1;++i){
          if(a[i]+a[i+1]>x){
               ans+=(a[i]+a[i+1])-x;
               a[i+1]=x-a[i];
          }
     }
     cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

vector<ll> barlen(55), pnum(55);

ll dfs(int hier, ll layer){
    if (hier == 0){
        return 1;
    }
    if (layer == 1){
        return 0;
    }else if (layer > 1 && layer <= 1 + barlen[hier-1]){
        return dfs(hier - 1, layer - 1);
    }else if (layer == 2 +barlen[hier-1]){
        return 1 + pnum[hier - 1];
    }
    else if (layer > 2 + barlen[hier - 1] && layer <= 2 + 2*barlen[hier - 1])
    {
        return 1 + pnum[hier - 1] + dfs(hier - 1, layer - 2 - barlen[hier - 1]);
    }else{
        return 1 + 2 * pnum[hier - 1];
    }
}

int main()
{
    ciosup;
    int n;
    ll x;
    cin >> n >> x;
    barlen[0] = 1;
    pnum[0] = 1;
    FOR(i, 1, n+1)
    {
        barlen[i] = barlen[i - 1] * 2 + 3;
        pnum[i] = pnum[i - 1] * 2 + 1;
    }
    cout << dfs(n, x) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
           int n = sc.nextInt();
           int arr[] = new int[n];
           for(int i=0; i<n; i++) arr[i] =sc.nextInt();
           int prev=0,count=0;
           int max=0;
           for(int i=0; i+1<n; i++){
             //  out.println(arr[i]+ " "+arr[i+1]);
              if(arr[i] >= arr[i+1])
                  count++;
              else{
                  if(count > max)
                      max=count;
                  count=0;
              }
           }
           if(count > max)
               max = count;
           out.println(max);

    }
    private static boolean helper(long x){
        double ans = Math.sqrt(x);
        return ans%1!=0;
    }

    private static int gcd(int a, int b){
        if(b==0)
            return a;
        return gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair  {
    int x;
    int y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

Measured memory_bytes: 42052
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl
 
#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define mod 1000000007

#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	ios_base::sync_with_stdio(false);
     	cin.tie(NULL);
    	cout.tie(NULL);    
    ll n;
    cin>>n;
    ll ans=0;
    ll p = n/500;
    ans+= p*1000;
    
    n-= p*500;
    
    ans+= (n/5)*5;
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
using namespace std;
main(){
  int m,n;
  while(cin>>m>>n,n){
    int a1[n][n],a2[n][n],q,w,e,r;
    r(i,n)r(j,n){
      if(i==j)a2[i][j]=a1[i][j]=0;
      else a2[i][j]=a1[i][j]=INF;
    }
    while(m--){
      scanf("%d%d%d%d",&q,&w,&e,&r);q--;w--;
      a1[q][w]=a1[w][q]=e;
      a2[q][w]=a2[w][q]=r;
    }
    r(k,n)r(i,n)if(a1[i][k]!=INF||a2[i][k]!=INF)r(j,n)
    if(a1[j][k]!=INF&&a1[i][k]!=INF||a2[j][k]!=INF&&a2[i][k]!=INF){
      a1[i][j]=min(a1[i][j],a1[i][k]+a1[k][j]);
      a2[i][j]=min(a2[i][j],a2[i][k]+a2[k][j]);
    }
    cin>>e;
    while(e--){
      scanf("%d%d%d",&q,&w,&r);q--;w--;
      if(r)cout<<a2[q][w]<<endl;
      else cout<<a1[q][w]<<endl;
    }
  }
}

Measured memory_bytes: 3320
local S, T = io.read("*l", "*l")

local count = 0
--[[ パターン1
for i = 1, S:len() do
	if S:sub(i, i) ~= T:sub(i, i) then
		count = count + 1
	end
end
--]]
--[[ パターン2
local S_byte_s, T_byte_s = {}, {}
for i = 1, S:len() do
	S_byte_s[i] = S:byte(i)
	T_byte_s[i] = T:byte(i)
end

for i = 1, S:len() do
	if S_byte_s[i] ~= T_byte_s[i] then
		count = count + 1
	end
end
--]]
---[[ パターン3

for i = 1, S:len() do
	if S:byte(i) ~= T:byte(i) then
		count = count + 1
	end
end
--]]

print(count)


Measured memory_bytes: 3020
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    double R;
    cin >> R;
    double ans=2*R*M_PI;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var ABCD = ReadSplitInt();
            var a = new int[101];
            var b = new int[101];

            for (int i = ABCD[0]; i <= ABCD[1]; i++)
                a[i] = 1;

            for (int i = ABCD[2]; i <= ABCD[3]; i++)
                b[i] = 1;

            var ans = 0;
            for (int i = 0; i <= 100; i++)
            {
                if (a[i] == 1 && b[i] == 1)
                    ans++;
            }
            Console.WriteLine(ans > 0 ? ans -1: ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 11348
import java.util.*;

public class Main {

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

        for(int i=0; i<N; i++){
            d[i] = scanner.nextInt();
        }

        long ans = 0;
        for(int i=0; i<N-1; i++){
            for(int j=i+1; j<N; j++){
                ans += d[i] * d[j];
            }
        }

        System.out.println(ans);

    }

}

Measured memory_bytes: 23636
from collections import Counter
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
C = Counter(A).most_common()
Ans = 0
for i in range(len(C)):
    x,y = C[i]
    if y%2 == 1:
        Ans += 1
print(Ans)

Measured memory_bytes: 21372
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br   = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int		nNum  = parseNum();
		long	nFact = 1;
		for (int n = 2; n <= nNum; n++ ) {
			nFact *= (long)n;
		}
		System.out.println(nFact);
	}

	private static int parseNum() {
		int	nNum = -1;
		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					nNum = Integer.parseInt(line);
				}
			}
		}
		catch (IOException e) {}

		return nNum;
	}
}

Measured memory_bytes: 16860
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int Q;
string S;
struct edge{bool hanten, f; char c;};

void calc(bool hanten, bool mae, char c) {
  // 反転がない場合、mae?前:後ろ
  // 反転がある場合、mae?後ろ:前
  if ((hanten && mae) || (!hanten && !mae)) S.insert(S.end(), c);
  else S.insert(S.begin(), c);
}

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

  cin >> S >> Q;
  int a,f;
  int cnt = 0;
  char c;
  vector<edge> V;
  rep(i, Q) {
    cin >> a;
    if (a==1) {
      cnt++;
    }
    else {
      cin >> f >> c;
      if (cnt%2>0) {
        V.push_back({true, f==1, c});
      } else {
        V.push_back({false, f==1, c});
      }
    }
  }
  rep(i, Q-cnt) {
    edge e = V[i];
    calc(e.hanten, e.f, e.c);
  }
  cnt%=2;
  if (cnt>0) reverse(ALL(S));
  cout << S << "\n";
  return 0;
}


Measured memory_bytes: 1416
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n,T;
  int t[SIZE];
  int ans = 0;
  
  scanf("%d%d",&n,&T);

  int p = 0;
  
  for(int i=0;i<n;i++){
    scanf("%d",t+i);

    ans += min(T,t[i]+T - p);
    p = t[i]+T;
  }

  printf("%d\n",ans);
  
  return 0;
}


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

bool hantei( vector<int>& x, vector<int>& y ) {
  rep( Z, -100, 100+1 ) {
    bool flag = true;
    rep( i, 0, x.size() ) {
      if ( x.at(i) >= Z ) flag = false;
    }

    rep( i, 0, y.size() ) {
      if ( y.at(i) < Z ) flag = false;
    }
    if (flag) return false;
  }

  return true;
}

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

  vector<int> x(N+1), y(M+1);
  cin >> x.at(0) >> y.at(0);
  rep(i, 1, N+1) cin >> x.at(i);
  rep(i, 1, M+1) cin >> y.at(i);

  cout << ( hantei(x, y) ? "War" : "No War" ) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, a, n) for(int i = a; i <= n; i++)
#define SIZE 100001
#define INF 100000000
using namespace std;
 
 
int N, A[SIZE];
vector<int> vec[SIZE];
 
int rec(int i) {
  int l = vec[i].size();
  vector<int> st;
 
  for(int j = 0; j < l; j++)
    st.push_back(rec(vec[i][j]));
 
  sort(st.begin(), st.end());
  reverse(st.begin(), st.end());
 
  for(int j = 0; j < l; j++) st[j] += j + 1;
 
  int m = 0;
  for(int j = 0; j < l; j++) m = max(m, st[j]);
 
  return m;
}
 
int main(void) {
  cin >> N;
  REP(i, 2, N) cin >> A[i];
 
  REP(i, 2, N) vec[A[i]].push_back(i);
 
  cout << rec(1) << endl;
 
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, x[100000], y[100000], ans;
pair<LL, LL> ppx[100000], ppy[100000];
array<LL, 3>  px[100000],  py[100000];

const int N = 100001;
vector<int> v[N];
int id[N];
int unit, cn;
void init() {
	inc(i, n) { v[i].PB(i); id[i] = i; }
	unit = n;
	cn = n;
}
void unite(int xx, int yy) {
	int x = id[xx], y = id[yy];
	if(x == y) { return; }
	cn--;
	if(v[x].size() > v[y].size()) { swap(x, y); }
	if(v[x].size() == 1) { unit--; }
	if(v[y].size() == 1) { unit--; }
	
	dec(i, v[x].size()) {
		id[ v[x][i] ] = y;
		v[y].PB(v[x][i]);
		v[x].pop_back();
	}
}

int main() {
	cin >> n;
	inc(i, n) { cin >> x[i] >> y[i]; }
	
	inc(i, n) {
		ppx[i] = MP(x[i], i);
		ppy[i] = MP(y[i], i);
	}
	sort(ppx, ppx + n);
	sort(ppy, ppy + n);
	
	inc(i, n - 1) {
		px[i] = { ppx[i + 1].FI - ppx[i].FI, ppx[i].SE, ppx[i + 1].SE };
		py[i] = { ppy[i + 1].FI - ppy[i].FI, ppy[i].SE, ppy[i + 1].SE };
	}
	sort(px, px + n - 1);
	sort(py, py + n - 1);
	
	init();
	int ix = 0, iy = 0;
	while(true) {
		if(ix == n - 1 && iy == n - 1) { break; }
		
		bool flag;
		     if(iy == n - 1) { flag = true; }
		else if(ix == n - 1) { flag = false; }
		else { flag = (px[ix][0] <= py[iy][0]); }
		if(flag) {
			if(id[ px[ix][1] ] != id[ px[ix][2] ]) {
				unite(px[ix][1], px[ix][2]);
				ans += px[ix][0];
			}
			ix++;
		} else {
			if(id[ py[iy][1] ] != id[ py[iy][2] ]) {
				unite(py[iy][1], py[iy][2]);
				ans += py[iy][0];
			}
			iy++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 19580
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll dp[114514];
ll h[114514];
int main(){
	cin>>N;
	int K;
	cin>>K;
	rep(i,N)cin>>h[i];
	dp[0]=0;
	for(int i=1;i<=N;i++){
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		for(int j=1;j<=min(K,i);j++){
			dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
		}
	}
	cout<<dp[N-1]<<endl;


}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[][] m = new int[N][N];
		for(int i=0; i<N; i++) {
			Arrays.fill(m[i], -1);
			int A = sc.nextInt();
			for(int j=0; j<A; j++) {
				int x = sc.nextInt()-1;
				int y = sc.nextInt();
				m[i][x] = y;
			}
		}
		
		for(int i=N; i>0; i--) {
			int comb = (1<<i)-1;
			while(comb<(1<<N)) {
				boolean ok = true;
				for(int j=0; j<N; j++) {
					if((comb&(1<<j))!=0) {
						for(int k=0; k<N; k++) {
							if(m[j][k]==0 && (comb&(1<<k))!=0) {
								ok = false;
								break;
							}
							if(m[j][k]==1 && (comb&(1<<k))==0) {
								ok = false;
								break;
							}
						}
					}
					if(!ok)
						break;
 				}
				
				if(ok) {
					System.out.println(i);
					sc.close();
					return;
				}
			
				int x = comb & -comb;
				int y = comb+x;
				comb = ((comb & ~y)/ x>>1) | y;
			}
		}

		System.out.println(0);
		sc.close();
	}
}


Measured memory_bytes: 22228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

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

using ll = long long;

int main()
{
	int K, A, B;
	cin >> K >> A >> B;

	bool ans = false;
	rep(i, 1001)
	{
		if (i % K == 0 && A <= i && i <= B)
		{
			ans = true;
			break;
		}
	}

	if (ans)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int((x).size()))
#define fi first
#define se second
#define pb push_back
#define VI vector<int>
typedef long long ll;
typedef pair<int,int> pii;
const int maxN=250005;
const int mod=1000*1000*1000+7;
int n,root[5][2],f[5][maxN],g[5][maxN];
pii cof[5][maxN];
char str[maxN];
map<tuple<int,int,int,int,int>,int>map_cnt;
int pw(int x,int y){
  int t=1;
  for(;y;y>>=1){
    if(y&1)t=(ll)t*x%mod;
    x=(ll)x*x%mod;
  }
  return t;
}
void trans(pii&x,pii y,char c,int sed[2]){
  if(c=='+')x=pii(y.fi,(mod-y.fi+y.se)%mod);
  if(c=='-')x=pii(y.fi,(y.fi+y.se)%mod);
  if(c=='>')x=pii((ll)y.fi*sed[0]%mod,y.se);
  if(c=='<')x=pii((ll)y.fi*sed[1]%mod,y.se);
}
int main(){
  srand(time(0));
  //freopen("aa.in","r",stdin);
  int i,j;
  scanf("%d%s",&n,str+1);
  for(i=0;i<5;++i){
    root[i][0]=rand()%(1000*1000*1000);
    root[i][1]=pw(root[i][0],mod-2);
    //printf("root val %d %d\n",root[i][0],root[i][1]);
    int bas=0;
    for(j=n;j;--j){
      if(str[j]=='+')bas=(bas+1)%mod;
      if(str[j]=='-')bas=(bas+mod-1)%mod;
      if(str[j]=='>')bas=(ll)bas*root[i][1]%mod;
      if(str[j]=='<')bas=(ll)bas*root[i][0]%mod;
    }
    cof[i][n+1]=pii(1,0);
    //printf("root %d\n",i);
    for(j=n;j;--j){
      trans(cof[i][j],cof[i][j+1],str[j],root[i]); 
      f[i][j]=cof[i][j].se;
      g[i][j]=((ll)cof[i][j].fi*bas+cof[i][j].se)%mod;
      //printf("f[%d] g[%d]\n",f[i][j],g[i][j]);
    }
    //printf("g %d %d\n",i,g[i][1]);
  }
  
  ll ans=0;
  map_cnt[make_tuple(0,0,0,0,0)]++;
  for(i=n;i;--i){
    //int pre=ans;
    auto nowg=make_tuple(g[0][i],g[1][i],g[2][i],g[3][i],g[4][i]);
    ans+=map_cnt[nowg];
    //if(ans-pre)printf("ans %d %d\n",i,ans-pre);
    auto nowf=make_tuple(f[0][i],f[1][i],f[2][i],f[3][i],f[4][i]);
    map_cnt[nowf]++;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 51200
n = int(input())
S = input()
def rot_encode(n):
    from string import ascii_lowercase as lc, ascii_uppercase as uc
    lookup = str.maketrans(lc + uc, lc[n:] + lc[:n] + uc[n:] + uc[:n])
    return lambda s: s.translate(lookup)
print(rot_encode(n)(S))

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

const int MAX_N = 100001;
int N;
std::vector<std::pair<int,int> > ds[MAX_N];
int ans[MAX_N];

void dfs(int x, int y){
   
   for(int i=0; i<ds[x].size(); ++i){
      int n = ds[x][i].first;
      if(n==y) continue;
      if(ds[x][i].second%2) ans[n] = ans[x] ? 0 : 1;
      else ans[n] = ans[x];
      dfs(n,x);
   }
   return;
}

int main(){
   std::cin >> N;
   int u, v, w;
   for(int i=0; i<N-1; ++i){
      std::cin >> u >> v >> w;
      ds[u].push_back(std::make_pair(v,w));
      ds[v].push_back(std::make_pair(u,w));
   }

   dfs(1,1);
   for(int i=1; i<=N; ++i){
      std::cout << ans[i] << std::endl;
   }

   return 0;

}


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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e9
#define ll long long
#define int long long

const int N = 1e5 + 5;
int n , mod = 1e9 + 7;
int black[N] , white[N];
vector < int > g[N];

void DFS(int i , int j)
{
    black[i] = white[i] = 1;
    REP(s , g[i].size())
    {
        int u = g[i][s];
        if(u != j)
        {
            DFS(u , i);
            black[i] = (black[i] * white[u]) % mod;
            white[i] = (white[i] * (white[u] + black[u])) % mod;
        }
    }
}

main()
{
    //freopen("P.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n - 1)
    {
        int x , y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    DFS(1 , -1);
    cout << (black[1] + white[1]) % mod;
}


Measured memory_bytes: 12800
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, a[MAXN], b[3];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,0,2) b[i] = 0;
    ll res = 1;
    FOR(i,1,n) {
        int cnt = 0;
        FOR(j,0,2)
            if (a[i] == b[j]) cnt++;
        res = res * cnt % MODBASE;
        FOR(j,0,2)
            if (a[i] == b[j]) {
                b[j]++;
                break;
            }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
static const int MAX=100;
static const int INFTY=1000000000;
static const int WHITE=-1;
static const int BLACK=1;

int A[MAX][MAX],dk[MAX],p[MAX];

void SSSP(int n){
    int C[n];
    for(int i=0;i<n;i++){
        C[i]=WHITE;
        dk[i]=INFTY;
    }
    dk[0]=0;
    while(true){
        int u=-1;int minv=INFTY;
        for(int i=0;i<n;i++){
            if(C[i]==WHITE&&minv>dk[i]){
                minv=dk[i];
                u=i;
            }
        }
        if(u==-1)break;
        C[u]=BLACK;
        for(int i=0;i<n;i++){
            if(C[i]==WHITE&&A[u][i]!=INFTY){
                if(dk[i]>dk[u]+A[u][i]){
                    dk[i]=dk[u]+A[u][i];
                }
            }
        }
    }
}

int main(){
    int n,v,k,u,d;
    cin>>n;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)A[i][j]=INFTY;

    for(int i=0;i<n;i++){
        scanf("%d %d",&v,&k);
        for(int j=0;j<k;j++){
            scanf("%d %d",&u,&d);
            A[v][u]=d;
        }
    }
    SSSP(n);
    for(int i=0;i<n;i++){
        printf("%d %d\n",i,dk[i]);
    }

}


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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    ll b;
    for (ll i = 0; i < n - 1; i++)
    {
        cin >> b;
        a[b - 1]++;
    }
    for (ll i = 0; i < n; i++)
    {
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4844
import java.util.*;
 
class Main {	
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
        	v[i] = sc.nextInt();
        }
        Arrays.sort(v);
        double x = (v[0] + v[1]) / 2.0;
        for (int i = 2; i < N; i++) {
        		x = (v[i] + x) / 2;
        	}
        System.out.println(x);
    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
	 
	static String str;
	
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		double x1=cin.nextDouble(),y1=cin.nextDouble(),x2=cin.nextDouble(),y2=cin.nextDouble();
		System.out.println(Math.sqrt(Math.pow((x2-x1), 2.0)+Math.pow((y2-y1), 2.0)));
	}
	
	
	
}


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

using namespace std;

const int  Nmax = 1e5 + 5;
int n, a[Nmax], i;

bool solve()
{
    int i, cnt = 0;
    for(i=1; i<=n; ++i)
        if(a[i] & 1) ++cnt;

    if(n % 2 == 0) return (cnt&1);
    if(cnt % 2 == 0) return 1;
    if(cnt > 2) return 0;

    for(i=1; i<=n; ++i)
        if(a[i] == 1) return 0;
            else if(a[i] & 1) --a[i];

    int g = a[1];
    for(i=2; i<=n; ++i)
        g = __gcd(g, a[i]);

    for(i=1; i<=n; ++i)
        a[i] /= g;

    return solve() ^ 1;
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=n; ++i)
        cin >> a[i];

    //if(n == 1) cout << (a[i]&1 ? "Second" : "First") << '\n';
    cout << (solve() ? "First" : "Second") << '\n';

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

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

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int k = 2;
            int count = 1;
            while (i % k == j % k) {
                k *= 2;
                count++;
            }
            cout << count;
            if (j == N - 1) cout << endl;
            else cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N,C=map(int,input().split())
lena=10**5+1
a=[[0]*lena for _ in range(C+1)]
for i in range(N):
    s,t,c=map(int,input().split())
    a[c][s]+=1
    a[c][t]+=-1
#print(a)
for i in range(C+1):
    for j in range(1,lena):
        a[i][j]+=a[i][j-1]
#print(a)
for i in range(C+1):
    for j in range(1,lena):
        if a[i][j]==1:
            a[i][j-1]=1
#print(a)

for i in range(lena):
    for j in range(1,C+1):
        a[j][i]+=a[j-1][i]

ans=0
#print(a)
for i in range(lena):
    ans=max(ans,a[C][i])
print(ans)


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

int main() {
    string s;
    cin >> s;
    int count[26];
    fill(count, count + 26, 0);
    for (int i = 0; i < s.size(); i++) {
        if ('A' <= s[i] && s[i] <= 'Z') {
            count[s[i] - 'A']++;
        }
    }
    cout << min(min(count['K' - 'A'], count['U' - 'A']), min(count['P' - 'A'], count['C' - 'A'])) << endl;
    return 0;
}

Measured memory_bytes: 3196
s=input()
l=[]
for i in range(97,123):
    c=chr(i)
    ind=0
    while s.find(c,ind)!=-1:
        ind=s.find(c,ind)
        for j in range(1,6):
            if s[ind:ind+j] not in l:
                l.append(s[ind:ind+j])
        ind+=1
    if len(l)>=5:
        break
l.sort()
print(l[int(input())-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


int main(){
    string S;
    cin >> S;

    string p = "01";

    int a = 0;
    int b = 0;
    rep(i,S.length()){
        if(S[i] != p[i%2])a+=1;   
        if(S[i] != p[(i+1)%2])b+=1;
    }
    cout << min(a,b) << endl;
}



Measured memory_bytes: 3720
n = int(input())
for i in range(n):
    a = list(map(int, input().split()))
    b = 0
    c = 0
    for j in range(10):
        if a[j] > b:
            if a[j] > c:
                if a[j] - b < a[j] - c:
                    b = a[j]
                else:
                    c = a[j]
            else:
                b = a[j]
        elif a[j] > c:
            c = a[j]
        else:
            print("NO")
            break

        if j == 9:
            print("YES")



Measured memory_bytes: 5588
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define in insert
#define er erase
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
 
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}


//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int32_t main(){
    init;
    ll n,m,i,j,k,l,p;
    cin >> n >> m >> k;

    ll fac[n + 1];
    fac[0] = 1LL;
    for(i = 1; i <= n; i++){
        mod( fac[i] = fac[i - 1] * i );
    }

    ll ans = 0;
    for(i = 0; i <= k; i++){
        ll c = fac[n - 1LL] * powerMod(fac[i] , MOD - 2);
        mod( c );
        mod ( c *= powerMod(fac[n - i - 1] , MOD - 2) );
        mod(c *= powerMod(m - 1 , n - 1 - i));

        mod( ans += c);
    }

    mod ( ans *= m);
    cout << ans << endc;
    return 0;
}

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

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

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

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

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    REP1(i, 10) REP1(j, 10) {
        if (i * j == N) {
            cout << YES << endl;
            return;
        }
    }

    cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main(){
	int N,M,ans=0;
	cin >> N >> M;
	vector<pair<int,int>> AB;
	for(int i=0;i<N;i++){
		int A,B;
		cin >> A >> B;
		AB.push_back(make_pair(A,B));
	}
	sort(AB.begin(),AB.end());
	reverse(AB.begin(),AB.end());
	
	priority_queue<int,vector<int>,greater<int>> que;
	for(int i=0;i<N;i++){
		int A=AB[i].first,B=AB[i].second;
		if(M-A+1>((int)que.size())){
			ans+=B;
			que.push(B);
		}
		else{
			if(M-A+1<0 || que.empty())continue;
			if(B>que.top()){
				ans-=que.top();
				que.pop();
				ans+=B;
				que.push(B);
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1908
#include <cstdio>

const int MAXN = 105;

int n;
double arr[MAXN], sum;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%lf", &arr[i]);
        arr[i] = 1 / arr[i];
        sum += arr[i];
    }
    printf("%.10lf", 1 / sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
using Graph = vector<vector<int>>;
void recur(const Graph &G, vector<int> &A, vector<int> &B, int node, int prv) {
    for (auto nxt : G[node]) if (nxt != prv) {
        A[nxt] = max(A[nxt], A[node] - 1);
        B[nxt] = min(B[nxt], B[node] + 1);
    }
    for (auto nxt : G[node]) if (nxt != prv) {
        recur(G, A, B, nxt, node);
    }
    for (auto nxt : G[node]) if (nxt != prv) {
        A[node] = max(A[node], A[nxt] - 1);
        B[node] = min(B[node], B[nxt] + 1);
    }
}
bool answer(const Graph &G, const vector<int> &A, const vector<int> &B,
            int node, int prv, int odd, vector<int> &ans) {
    int t = A[node];
    if (t % 2 != odd) t++;
    if (t > B[node]) return false;
    ans[node] = t;
    for (auto nxt : G[node]) if (nxt != prv) {
        if (!answer(G, A, B, nxt, node, !odd, ans)) {
            return false;
        }
    }
    return true;
}
int main() {
    int N; cin >> N;
    Graph G(N);
    vector<int> A(N, -INF), B(N, INF);
    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int K; cin >> K;
    for (int i = 0; i < K; i++) {
        int v, p; cin >> v >> p; v--;
        A[v] = B[v] = p;
    }
    recur(G, A, B, 0, -1);
    recur(G, A, B, 0, -1);
    vector<int> ans(N);
    if (answer(G, A, B, 0, -1, 0, ans) || answer(G, A, B, 0, -1, 1, ans)) {
        cout << "Yes\n";
        for (int i = 0; i < N; i++) {
            cout << A[i] << '\n';
        }
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 18560
// #pragma GCC optimize("Ofast")

// #pragma GCC optimize("no-stack-protector")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>

using namespace std;

template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}

template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define left left228
#define right right228
#define ld long double
#define list list228
// #define prev prev228
#define mp make_pair
#define list list228
#define all(v) v.begin(), v.end()

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << (h * w + 1) / 2 << endl;
    return 0;
}

/*
3
1 1 2
2 2 2
3 3 2
2 1 1
3 2 1


2 2
1 1 2
2 2 2
1 2 3
2 1 1

2
2 1 2 2 3
2 2 2 1 1

5
1 2
2 3
3 4
3 5
1
2 3
1 2
4 3
2 3 5

*/



Measured memory_bytes: 256