akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        int N = NextInt();
        for (int i = 1; i <= 9; i++) { if (N % i == 0 && N / i < 10) { Console.WriteLine("Yes"); return; } }
        Console.WriteLine("No");
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }

}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
    static int MAX = 10010017;  // (1 ≦ k ≦ n ≦ 10^7 程度)
    static int MOD = 1000000007;
    static long[] fac;  // 階乗
    static long[] finv;
    static long[] inv;  // 逆元
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        COMinit();
        
        int n = sc.nextInt();
        
        if (n < 3) {
            System.out.println(0);
            return;
        }
        
        int possible = n / 3;
        
        long ans = 0;
        for (int i = 1; i <= possible; i++) {
            int m = n - 3 * i;
        //     k+n-1Ck
        //  - = k個のボールとn-1個の仕切り
        //  m個のボールとi-1この仕切
            long tmp = nCkMOD(m+(i)-1, m);
            // System.out.println(i + " " + tmp + " " + (m+i-1) + " " + m);
            ans += tmp;
            ans %= MOD;
        }
        System.out.println(ans);
    }
    
    // テーブルを作る前処理
    public static void COMinit() {        
        fac = new long[MAX];
        finv = new long[MAX];
        inv = new long[MAX];
        
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    // 二項係数計算(1 ≦ k ≦ n ≦ 10^7 程度)
    // nCk = n! / (k! * (n-k)!)
    public static long nCkMOD(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
    // 順列計算
    // nPk = n! / (n-k)!
    public static long nPkMOD(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return (fac[n] * finv[n - k]) % MOD;
    }
    
    public static long modpow(long a, long n) {
        long res = 1;
        while (n > 0) {
            long tmp = n & 1;
            if (tmp > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}

Measured memory_bytes: 271160
s=input()
t=input()
length=len(s)
flag=0

for i in range(length):
    j=i
    for k in range(length):
        if s[j%length]!=t[k]:
            break
        if k==length-1:
            flag=1
        j+=1
            
if flag==1:
    print("Yes")
elif flag==0:
    print("No")

Measured memory_bytes: 3060
n,m,k=map(int,input().split())
from itertools import accumulate
from bisect import bisect_right
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ac=[0]+list(accumulate(a))
bc=[0]+list(accumulate(b))
temp=0

for i in range(n+1):
    if ac[i]<=k:
        count=i
        count+=bisect_right(bc,k-ac[i])-1
        temp=max(temp,count)
print(temp)

Measured memory_bytes: 50704
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll A,B;
    cin >> A >> B;
    int ANS = -1;
    REP(i,1001){
        int a = i*0.08;
        int b = i*0.1;
        if(a == A && b == B){
            ANS = i;
            break;
        }
    }
    cout <<ANS<<endl;

    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  string s;
  cin >> s;
  int n = s.size();
  string t = s;
  rep(i,n){
    if(s.at(i) == '?') t.at(i) = 'D';
  }
  cout << t << endl;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb(x) push_back((ll)(x))
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
//void ini(){
//	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
//		freopen("output.txt","w",stdout);
//	#endif
//}
 
ll h[100001],dp[100001];

int memo(ll n){
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	f(i,3,n+1){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}

	return dp[n];
}

int main(){
	//ini();
	
	ll n;
	cin >> n;
	f(i,1,n+1){
		cin >> h[i];
	}

	cout <<memo(n);

}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAirplane solver = new AAirplane();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAirplane {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int p = in.nextInt();
            int q = in.nextInt();
            int r = in.nextInt();
            out.println(Math.min(Math.min(p + q, p + r), q + r));
        }

    }
}



Measured memory_bytes: 21716
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N,K;
  cin >> N >> K;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  vector<ll> s(N+1);
  s[0]=0;
  rep(i,N) s[i+1]=s[i]+a[i];
  vector<ll> t(N+1);
  rep(i,N+1) t[i]=(s[i]-i)%K;
  map<ll,ll> mp;
  ll ans=0;
  rep(i,N+1){
    if(i>=K) mp[t[i-K]]--;
    ans+=mp[t[i]];
    mp[t[i]]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1LL<<60;
const int MOD = 1e9+7;

signed main()
{
   string s; cin >> s;

   if (
       s == "KIHBR" ||
       s == "KIHBRA" ||
       s == "KIHBAR" ||
       s == "KIHBARA" ||
       s == "KIHABR" ||
       s == "KIHABRA" ||
       s == "KIHABAR" ||
       s == "KIHABARA" ||
       s == "AKIHBR" ||
       s == "AKIHBRA" ||
       s == "AKIHBAR" ||
       s == "AKIHBARA" ||
       s == "AKIHABR" ||
       s == "AKIHABRA" ||
       s == "AKIHABAR" ||
       s == "AKIHABARA"
         ) {
      cout << "YES" << endl;
   } else {
      cout << "NO" << endl;
   }


   return 0;
}


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

namespace A {
	class main {
		public main() { }
		public static int Main() {
			new main().run();
            return 0;
        }
		void run() {
			Scanner cin = new Scanner();
			int n = cin.nextInt();
			while(n-->0) {
				String t=cin.next();
				String s=cin.next();
				for(int i=t.Length-1; i>=0; i--) {
					if(t[i]=='A') {
						char[] a = s.ToCharArray();
						Array.Reverse(a);
						s= new string(a);
					}
					if(t[i]=='C') {
						s=s.Substring(1)+s[0];
					}
					if(t[i]=='J') {
						s=s[s.Length-1]+s.Substring(0,s.Length-1);
					}
					if(t[i]=='E') {
						if(s.Length%2==1) {
							s=s.Substring(s.Length/2+1)+s[s.Length/2]+s.Substring(0,s.Length/2);
						} else {
							s=s.Substring(s.Length/2)+s.Substring(0,s.Length/2);
						}
					}
					if(t[i]=='M') {
						for(int j=0; j<s.Length; j++) {
							if(s[j]>='0' && s[j]<'9') s=s.Substring(0,j)+(char)(s[j]+1)+s.Substring(j+1);
							else if(s[j]=='9') s=s.Substring(0,j)+'0'+s.Substring(j+1);
						}
					}
					if(t[i]=='P') {
						for(int j=0; j<s.Length; j++) {
							if(s[j]>'0' && s[j]<='9') s=s.Substring(0,j)+(char)(s[j]-1)+s.Substring(j+1);
							else if(s[j]=='0') s=s.Substring(0,j)+'9'+s.Substring(j+1);
						}
						
					}
				}
				Console.WriteLine(s);
			}
		}
	}

	class Scanner {
		string[] s;
		int i;
		
		char[] cs = new char[] { ' ' };
		
		public Scanner() {
			s = new string[0];
			i = 0;
		}
		public string next() {
			if (i < s.Length) return s[i++];
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 0;
			return s[i++];
		}
		public int nextInt() {
			return int.Parse(next());
		}
		public long nextLong() {
			return long.Parse(next());
		}
		public double nextDouble() {
			return double.Parse(next());
		}
	}
}


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

 
int main() {
	ll A,B,C;
  	cin >> A >> B >> C;
  	if(A==B && B==C){
      cout << "Yes" << endl;
    }
	else if(C>A && C<B){
      cout << "Yes" << endl;
    }
  	else{
      cout << "No" <<  endl;
    }
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


s = int(input())
num = []
num.append(s)
for i in range(1000000):
    if num[i] % 2 == 0:
        num.append(int(num[i]/2))
    else:
        num.append(int(3*num[i]+1))
    if len(set(num)) == i+1:
        print(len(num))
        break


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/04  Problem: ABC 045 A / Link: http://abc045.contest.atcoder.jp/tasks/abc045_a  ----- */


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

	LL a, b, c; cin >> a >> b >> c;
	LL ans = (a + b)*c / 2;


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    ss=[SI() for _ in range(n)]
    ms1=[]
    ms2=[]
    for s in ss:
        mn=0
        now=0
        for c in s:
            if c=="(":now+=1
            else:now-=1
            if now<mn:mn=now
        if now>0:ms1.append((mn,now))
        else:ms2.append((mn-now,-now))
    #print(ms1)
    #print(ms2)

    cnt=0
    for mn,s in sorted(ms1,reverse=True):
        if cnt+mn<0:
            print("No")
            exit()
        cnt+=s

    cnt2=0
    for mn,s in sorted(ms2,reverse=True):
        if cnt2+mn<0:
            print("No")
            exit()
        cnt2+=s

    if cnt==cnt2:print("Yes")
    else:print("No")

main()

Measured memory_bytes: 92032
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    X = SS()

    # 一回の操作でnはN以下になる
    # 2回目以降の操作はメモ化再帰
    # 初回popcountは2種類しかない Xのpopcountから足し引きすればよい

    pc_X = X.count('1')

    if pc_X == 0:
        for i in range(N):
            print(1)
    elif pc_X == 1:
        for i in range(N):
            if i == X.index('1'):
                print(0)
            else:
                # 1が2つある場合、最後の位が1の場合、奇数
                if i == N - 1 or X.index('1') == N - 1:
                    print(2)
                else:
                    print(1)
    else:
        next_X_m1 = 0
        next_X_p1 = 0
        pc_m1 = pc_X - 1
        pc_p1 = pc_X + 1
        for i in range(N):
            if X[i] == '1':
                next_X_m1 += pow(2, N - 1 - i, pc_m1)
                next_X_p1 += pow(2, N - 1 - i, pc_p1)

        dp = [-1] * N
        dp[0] = 0

        def dfs(n):
            if dp[n] == -1:
                dp[n] = 1 + dfs(n % bin(n).count('1'))
            return dp[n]

        for i in range(N):
            next = 0
            if X[i] == '0':
                next = (next_X_p1 + pow(2, N - 1 - i, pc_p1)) % pc_p1
            else:
                next = (next_X_m1 - pow(2, N - 1 - i, pc_m1)) % pc_m1
            ans = dfs(next) + 1
            print(ans)
    # print(dp)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 12100
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

ll n;
vector<ll>adj[100001];
ll dp[100001][2];

// 0 -> black_color
// 1 -> white_color

ll totalWays(ll node,ll parent,ll color)
{
	if(dp[node][color]!=-1) return dp[node][color];
	ll total=1;
	for(auto child : adj[node])
	{
		ll count=0;
		if(child!=parent)
		{
			if(color==0)
				count+=totalWays(child,node,1)%MOD;
			else
				count+=totalWays(child,node,0)+totalWays(child,node,1)%MOD;

			total*=count;
			total%=MOD;
		}
	}
	dp[node][color]=total%MOD;
	return total%MOD;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    ll i,u,v;
    for(i=0;i<n-1;i++)
    {
    	cin>>u>>v;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }
    mem(dp,-1);
    cout<<(totalWays(1,-1,0)%MOD+totalWays(1,-1,1)%MOD)%MOD;
    return 0;
}

Measured memory_bytes: 18836
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#define LL long long

struct NumContainer{
	LL num, pos;
};

bool compareFunc(NumContainer a, NumContainer b){
	return (a.num < b.num);
}

int main(){
	LL n,i;
	std::cin >> n;
	LL x1[n], result[n];
	std::vector<NumContainer> x2(n);
	for(i=0;i<n;i++){
		std::cin>>x1[i];
		x2[i].num = x1[i];
		x2[i].pos = i;
	}

	std::sort(x2.begin(), x2.end(), &compareFunc);


	for(i=0;i<n;i++){

		if(i==n/2-1){

			result[x2[i].pos] = x2[n/2].num;

		} else if(x2[i].num>x2[n/2-1].num){

			result[x2[i].pos] = x2[n/2-1].num;

		} else {

			result[x2[i].pos] = x2[n/2].num;

		}
	}

	for(i=0;i<n;i++){
		std::cout << result[i] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


const int Max=10000000;
bool prime[Max];
int main()
{
    for(int i = 1 ; i <= 9 ; i++){
        for(int j = 1 ; j <= 9 ; j++){
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
const double eps = 1e-9;

struct Point{
	double x,y,z;
	Point(double x, double y, double z):
		x(x), y(y), z(z){}
	Point(){}
};
struct Obj{
	Point p;
	double r;
	long long int l;
};
double Length(Point a){
	return sqrt(a.x*a.x +a.y*a.y +a.z*a.z);
}

//distance between p+t*vec(line) and q(point)
double distLP3(Point p, Point q, Point c){
	p.x-=c.x; p.y-=c.y; p.z-=c.z;
	q.x-=c.x; q.y-=c.y; q.z-=c.z;
	double vx = q.x-p.x, vy=q.y-p.y, vz=q.z-p.z;
	double t = -(vx*p.x +vy*p.y +vz*p.z) /(vx*vx +vy*vy +vz*vz);
	if(t<0) return Length(p);
	if(t>1) return Length(q);
	return Length(Point(p.x+t*vx, p.y+t*vy, p.z+t*vz));
}

int main(){
	int n,q;
	cin >> n >> q;
	vector<Obj> ob(n);
	for(int i=0; i<n; i++){
		cin >> ob[i].p.x >> ob[i].p.y >> ob[i].p.z >> ob[i].r >> ob[i].l;
	}
	
	for(int i=0; i<q; i++){
		Point s,d;
		cin >> s.x >> s.y >> s.z;
		cin >> d.x >> d.y >> d.z;
		long long int ans=0;
		for(int j=0; j<n; j++){
			if(distLP3(s, d, ob[j].p) < ob[j].r + eps){
				ans+=ob[j].l;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++){
        cin >> d.at(i);
    }
    
    sort(d.begin(),d.end());
    
    cout << d.at(N/2)-d.at(N/2-1) << endl;
}

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

const int N = 105;

int n;
int a[N];

int main() {
  scanf("%d", &n);
  for (int i=0; i<n; i++) scanf("%d", a + i);
  
  int sum = 0;
  for (int i=0; i<n; i++) sum += a[i];
  
  int idx = 0;
  for (int i=1; i<n; i++) {
    if (abs(sum - a[i]*n) < abs(sum - a[idx]*n)) idx = i;
  }
  
  printf("%d\n", idx);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const ll MOD = 1000000000+7;
    int N, K;
    cin >> N >> K;

    ll ans = 0;
    ll mn = 0,mx = 0;
    FOR(i,1,N+2) {
        mn += i-1;
        mx += N-i+1;
        if (i >= K) ans += mx - mn + 1;
        ans %= MOD;
        //cerr << mn << " " << mx << endl;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    X=[0]*N
    Y=[0]*N
    d=[[0]*N for _ in range(N)]
    for i in range(N):
        X[i],Y[i]=MI()
        
    for i in range(N):
        for j in range(N):
            dx=X[i]-X[j]
            dy=Y[i]-Y[j]
            d[i][j]=(dx**2 + dy**2)**0.5
            
    import itertools
    
    ans=0
    for ite in itertools.permutations(range(N), N):
        now=ite[0]
        for i in range(1,N):
            nxt=ite[i]
            ans+=d[nxt][now]
            now=nxt
    M=1
    for i in range(1,N+1):
        M*=i
    ans=ans/M
    print(ans)
            

main()


Measured memory_bytes: 73656
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n;cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<ll>());
  queue<ll> q;
  q.push(a[0]);
  ll ans = 0;
  for(int i = 1; i < n; i++){
    q.push(a[i]); q.push(a[i]);
    ans += q.front(); q.pop();
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 6420
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
class uf:
    def __init__(self,n):
        self.n=n
        self.l=[-1]*n
    def ro(self,n):         #root
        if self.l[n]<0:
            return n
        r=self.ro(self.l[n])
        self.l[n]=r
        return r
    def me(self,a,b):       #merge
        ra=self.ro(a)
        rb=self.ro(b)
        if self.l[ra]>self.l[rb]:
            ra,rb=rb,ra
        if ra!=rb:
            self.l[ra]+=self.l[rb]
            self.l[rb]=ra
    def size(self,n):
        return -self.l[self.ro(n)]
    def sa(self,a,b):       #same
        return self.ro(a)==self.ro(b)
    def rl(self):           #roots list
        return [i for i,v in enumerate(self.l) if v<0]
    
    def len(self):          #len(roots)
        return len(self.rl())
    def ul(self):
        d={n:i for i,n in enumerate(self.rl())}
        m=[[]for i in range(self.len())]
        for i in range(self.n):
            m[d[self.ro(i)]].append(i)
        return m
    def __str__(self):
        return f"{self.ul()}"
    def __setitem__(self,i,v):
        self.l[i]=v
N,M=map(int,input().split())
u=uf(N)
for i in range(M):
    A,B=map(lambda x: int(x)-1,input().split())
    u.me(A,B)
a=0
for i in u.ul():
    t=len(i)
    if t>a:
        a=t
print(a)

Measured memory_bytes: 139476
import sys
from collections import deque
import itertools


def input():
    return sys.stdin.readline().rstrip()


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    l = [0] * 62
    n = [0] * 62
    for i in A:
        di = 0
        while i:
            if i % 2 == 1:
                l[di] += 1
            else:
                n[di] += 1
            i = i // 2
            di += 1
    di = 1
    ans = 0
    for j in range(61):
        ans += l[j] * (N - l[j]) * di

        di *= 2
        ans %= mod
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 124624
#include<iostream>
#include<cstdio>
#include<algorithm>
int main(void)
{
	int	N=0;
	int out1[101]={0};int out2[101]={0};int out3[101]={0};
	int a[660]={0};int a1[660]={0};int a2[660]={0};
	int all[220]={0};
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d %d %d",&a[i],&a1[i],&a2[i]);
		if(out1[a[i]]<0){out1[a[i]]=-2;}
		else{out1[a[i]]=-1;}
		if(out2[a1[i]]<0){out2[a1[i]]=-2;}
		else{out2[a1[i]]=-1;}
		if(out3[a2[i]]<0){out3[a2[i]]=-2;}
		else{out3[a2[i]]=-1;}
	}
	for(int i=1;i<=N;i++)
	{
		if(out1[a[i]]!=-2)
		{
			all[i]+=a[i];
		}
		if(out2[a1[i]]!=-2)
		{
			all[i]+=a1[i];
		}
		if(out3[a2[i]]!=-2)
		{
			all[i]+=a2[i];
		}
		printf("%d\n",all[i]);
	}
	return 0;
}


Measured memory_bytes: 3244
from collections import defaultdict
def getDic(L,n):
    d=defaultdict(int)
    for i in range(n):
        s=L[i]
        d[s]+=1
        for j in range(i+1,n):
            s+=L[j]
            d[s]+=1
    return d

while True:
    N,M=map(int,raw_input().split())
    if N==M==0:break
    H=[input() for i in range(N)]
    W=[input() for i in range(M)]
    dh=getDic(H,N)
    dw=getDic(W,M)
    print sum(dh[h]*dw[h] for h in dh if h in dw)

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

const int maxn = 1000006;
int a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        a[i+1] = s[i]-'0';
    }
    int ans = 0;
    for (int i = s.size(); i >= 1; i--) {
        if (a[i] == 10) {
            a[i] = 0;
            a[i-1]++;
        }
        else if (a[i] == 5) {
            if (a[i-1] >= 5) {
                a[i-1]++;
                ans += 5;
            }
            else {
                ans += 5;
            }
        }
        else if (a[i] < 5) {
            ans += a[i];
        }
        else if (a[i] > 5) {
            ans += 10-a[i];
            a[i-1]++;
        }
    }
    ans += a[0];
    cout << ans << endl;
}



Measured memory_bytes: 5276
#include <iostream>
#include<set>

using namespace std;

int main() {
    string s;
    cin >> s;
    
    set<char> a;
    a.insert(s[0]);
    
    int c1 = 1;
    for(int i=1; i<4; i++){
        a.insert(s[i]);
        
        if(s[0] == s[i]) c1++;
    }
    
    if(a.size() == 2 && c1 == 2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

int main()
{
	ll N,A,B;
	cin >> N >> A >> B;
	
	ll ans = N / (A + B) * A;
	
	if ( N % (A + B) < A )
	{
		ans += N % (A + B);
	}
	else
		ans += A;
	
	cout << ans;
}

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

bool solve(int i, int m, int N, int S[]) {
  if (m == 0) {
    return true;
  }
  if (i >= N) {
    return false;
  }
  bool res = solve(i + 1, m, N, S) || solve(i + 1, m - S[i], N, S);
  return res;
}

int main() {
  int N, Q, A[20], m;

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> m;
    if (solve(0, m, N, A)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  
  return 0;
}


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

int main() {
  int n, k;
  int r, s, p;
  string t;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;

  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( i >= k && t[i] == t[i-k] ) { t[i] = '.'; }
    if ( t[i] == 'r' ) { ans += p; }
    if ( t[i] == 's' ) { ans += r; }
    if ( t[i] == 'p' ) { ans += s; }
  }

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


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

P f(int x1, int y1, int x2, int y2){
    int dx = x2 - x1, dy = y2 - y1;
    return std::make_tuple(x2 - dy, y2 + dx);
}

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

    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    std::tie(x3, y3) = f(x1, y1, x2, y2);
    std::tie(x4, y4) = f(x2, y2, x3, y3);

    printf("%d %d %d %d\n", x3, y3, x4, y4);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
    int n, ret;
	int i;
	int p[1000];
	double m = 0.0;
	double a2 = 0.0;
	do {
		ret = scanf("%d", &n);
		if (n == 0)
			break;
		for (i = 0; i < n; i++)
		{
			scanf("%d", &p[i]);
		}
		m = 0.0;
		for (i = 0; i < n; i++)
		{
			m += p[i];
		}
		m /= n;
		a2 = 0.0;
		for (i = 0; i < n; i++)
		{
			a2 += (p[i] - m) * (p[i] - m) / n;
		}
		printf("%lf\n", sqrt(a2));
	} while (ret != EOF);
	return 0;
}


Measured memory_bytes: 2028
#include <iostream>

using namespace std;

int main() {
  int N, K, R, S, P, ans{};
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  for (int i = 0; i != N; ++i) {
    if (i >= K && T[i] == T[i-K]) {
      T[i] = 'n';
      continue;
    }
    ans += T[i] == 'r' ? P : T[i] == 's' ? R : S;
  }
  cout << ans << endl;
}


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

#define N 1000000

int arr[N];
map<ll, ll> sosuu;
//エラトステネスの篩
void Eratosthenes()
{
    for (int i = 0; i < N; i++)
    {
        arr[i] = 1;
    }
    for (int i = 2; i < sqrt(N); i++)
    {
        if (arr[i])
        {
            for (int j = 0; i * (j + 2) < N; j++)
            {
                arr[i * (j + 2)] = 0;
            }
        }
    }

    for (int i = 2; i < N; i++)
    {
        if (arr[i])
        {
            sosuu[i] = 1;
            //cout << i << endl;
        }
    }
}

int main()
{
    //前処理として、素数を書き出すことができれば早そう！！(1~10**5までの素数)
    ll q;
    cin >> q;
    Eratosthenes();
    vector<ll> L(q);
    vector<ll> R(q);
    vector<int> sosuu2(100000);
    //累積和のように考えて、前処理する。具体的には、rep(i,10**5)で回して、満たしたら1を入れるみたいな感じで
    for (int i = 2; i <= 99999; i++)
    {
        if (sosuu[i] == 1 && sosuu[(ll)((i + 1) / 2)] == 1)
        {
            sosuu2[i] = 1 + sosuu2[i - 1];
        }
        else
        {
            sosuu2[i] = sosuu2[i - 1];
        }
    }

    rep(i, q) //
    {
        cin >> L[i] >> R[i];

        cout << sosuu2[R[i]] - sosuu2[L[i] - 1] << endl;

        //vector<ll> sosuu;のなかでoL[i]以上のindexとR[i]以下のindex
        //lower_bound:探したい値以上が現れる最小のindexをイテレータで返す
    }
}


Measured memory_bytes: 17024
N = int(input())
S = input()

R = S.count('R')
G = S.count('G')
B = S.count('B')
tmp = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + (j - i)
        if k >= N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            tmp-=1
print(tmp + R*G*B)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
int n, ans = 1e9, sum;
int main() {
	scanf("%d", &n);
	for(int i = 1; i < n; ++i) {
		int a = i, b = n - i;
		sum = 0;
		while(a) {
			sum += a % 10;
			a /= 10;
		}
		while(b) {
			sum += b % 10;
			b /= 10;
		}
		ans = min(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
ll gcd(ll a,ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll e=(a+c-1)/c;ll f=b/c;
    ll g=(a+d-1)/d;ll h=b/d;
    ll x=f-e+1;
    ll y=h-g+1;
    //cout<<x<<" "<<y<<"\n";
    ll lcm=(c*d)/gcd(c,d);
    ll i=(a+lcm-1)/lcm;ll j=b/lcm;
    ll z=j-i+1;
    ll gap=b-a+1;
    ll ans1=x+y-z;
    ll ans=gap-ans1;
    cout<<ans<<"\n";
    return 0;

    //check for long long or int
}


Measured memory_bytes: 256
while 1:
    n,x=map(int,input().split())
    if n+x == 0:break
    data = list(range(1,n+1))
    count = 0
    for i in data:
        for j in data[i:]:
            if x-i-j in data[j:]:
                count += 1
    print(count)


Measured memory_bytes: 5596
#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 P pair<int, int>
#define F first
#define S second
#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};
int H, W, K;
bool judge(vector<int> Count) {
    bool res = true;
    for(auto x : Count) res &= (x <= K);
    return res;
}
signed main(void) {
    cin >> H >> W >> K;
    bool G[H][W];
    rep(i, H) {
        string s;
        cin >> s;
        rep(j, W) {
            if(s[j] == '1')
                G[i][j] = true;
            else
                G[i][j] = false;
        }
    }
    int ans = INF;
    rep(i, 1 << (H - 1)) {
        vector<int> Cut;
        int sum = 0;
        Cut.push_back(0);
        rep(j, H - 1) {
            if((i >> j) & 1) {
                sum++;
                Cut.push_back(j + 1);
            }
        }
        Cut.push_back(H);
        int c = Cut.size();
        vector<int> Count(c - 1, 0);
        int j = 0;
        while(j < W) {  //貪欲にとる
            int now = j;
            while(judge(Count) && j < W) {
                rep(k, c - 1) {
                    for(int l = Cut[k]; l < Cut[k + 1]; l++) {
                        if(G[l][j]) Count[k]++;
                    }
                }
                j++;
            }
            if(now + 1 == j && !judge(Count)) {
                sum = INF;
                break;
            }
            if(judge(Count) && j == W) {
                break;
            }
            //if(i == 0) cout << sum << endl;
            rep(k, c - 1) Count[k] = 0;
            sum++;
            j--;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


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

int main() {
  ll n;   
  cin >> n;
  ll ans = 1001001001001001;
  for(ll i = 1; i * i <= n; ++i) {
    if(n%i == 0) {
      ll a = i + n/i - 2;
      ans = min(ans, a);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	cin.tie();
	ios::sync_with_stdio(false);
	int n,m,*t,sum=0,p,x;
	cin>>n;
	t=new int[n];
	for(int i=0;i<n;++i){
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;++i){
		cin>>p>>x;
		cout<<sum-t[p-1]+x<<'\n';
	}
	delete[] t;
	return 0;
}

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

using namespace std;

int get_index(int i, int j, int n)
{
    return (i + j) % n;
}

int main()
{

    string s, t;
    cin >> s >> t;

    int n = s.size();
    int i, j = 0;

    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            if (s[j] != t[get_index(i, j, n)])
                break;
        }

        if (j == n)
        {
            cout << "Yes" << endl;

            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

using namespace std;

const int N(1e5 + 9);

int n, m, ans;
int f[N], d[N];
vector<int>a[N];
stack<int>s;

void topo_sort()
{
	for (int i=1;i<=n;i++)
	{
		if (d[i] == 0)
		{
			s.push(i);
		}
	}
	while (!s.empty())
	{
		int u = s.top();
		s.pop();
		for (int i=0;i<a[u].size();i++)
		{
			int v = a[u][i];
			d[v]--;
			f[v] = max(f[v], f[u] + 1);
			if (d[v] == 0)
			{
				s.push(v);
			}
		}
	}
}

int main()
{
	cin>>n>>m;
	for (int i=1;i<=m;i++)
	{
		int u, v;
		cin>>u>>v;
		a[u].push_back(v);
		d[v]++;
	}
	topo_sort();
	for (int i=1;i<=n;i++)
	{
		ans = max(ans, f[i]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 6528
#include<iostream>

using namespace std;

int main(void){

    int X;
    cin >> X;
    int p1=0;
    int p2=0;

    if(int(X/500)>0){
        p1 = int(X/500);
        X = X - (p1 * 500);
    }
    if(int(X/5)>0){
        p2 = int(X/5);
        X = X - (p2 *5);

    }

    cout << p1*1000 + p2 * 5 << endl;

    return 0;
}


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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;
       
int a[Sz * 10], b[Sz * 10];
                   
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;      
  for (int i = 1; i <= n; i++) {
    int x; cin >> x;
    a[x] = b[x] = i;
  }
  int ptr = 1;                     
  for (int i = 1; i <= n*n; i++) {
    if (b[i]) {  
      for (int j = 1; j < b[i]; j++) {
        while (a[ptr] && ptr < i)
          ptr++;
        if (ptr >= i) {
          cout << "No"; return 0;
        }    
        assert (a[ptr] == 0);
        a[ptr] = b[i];
      }
    }
  }   
  ptr = n * n;
  for (int i = n*n; i >= 1; i--) {
    if (b[i]) {
      for (int j = 1; j <= n - b[i]; j++) {
        while (a[ptr] && ptr >= i)
          ptr--;
        if (ptr <= i) {
          cout << "No"; return 0;
        }
        assert (a[ptr] == 0);
        a[ptr] = b[i];
      }
    }
  }

  cout << "Yes" << endl;
  for (int i = 1; i <= n*n; i++)
    cout << a[i] << ' ';        


  return 0;
}






// Coded by Z..



Measured memory_bytes: 3968
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		
		ArrayList<Integer>v=new ArrayList<>();
		
		for(int i=0;i<n;i++) {
			v.add(sc.nextInt());
		}
		Collections.sort(v);
		double ans=v.get(0);
		
		for(int i=0;i<n;i++) {
			ans=(ans+v.get(i))/2;
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 21716
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <cctype>
using namespace std;

int main(){
  vector< queue<char> > que(3);
  string s_a,s_b,s_c;
  cin>>s_a>>s_b>>s_c;

  for(int i=0;i<s_a.size();i++) que[0].push(s_a[i]);
  for(int i=0;i<s_b.size();i++) que[1].push(s_b[i]);
  for(int i=0;i<s_c.size();i++) que[2].push(s_c[i]);

  char c=que[0].front();
  que[0].pop();
  
  int index=0;
  while(1){
    if(c=='a') index=0;
    else if(c=='b') index=1;
    else index=2;
    if(que[index].empty()) break;
    c=que[index].front();
    que[index].pop();
  }

  c=toupper(c);
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#define MAX 1000
using namespace std;

int main()
{
	int n,j=0;
	int S[MAX]={0};
	double a=0.0,m=0.0,temp=0.0;

	while(1)
	{
		a = 0.0;
		m = 0.0;
		temp = 0.0;
		
		cin >> n;
		
		if(n == 0 ) break;

		for(int i=0;i<n;i++)
		{
			cin >> S[i] ;
			m = m + S[i] ;
		}

		m = m / n ;

		for(int i=0;i<n;i++)
		{
			temp = temp + (S[i] - m) * (S[i] - m) ;
		}

		a = temp / n ;

		a = sqrt(a);

		cout << a << endl;

	}

	return 0;
}

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

int main()
{
    int h, a;
    cin >> h >> a;
    int ans = (h + (a - 1)) / a;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N,L[100],S=0,max=0;
  int i=0;
  scanf("%d",&N);
  while(i<N){
    scanf("%d",&L[i]);
    i++;
  }
  for(i=0;i<N;i++){
    S += L[i];
    if(L[i]>max){
      max=L[i];
    }
  }
  S = S-max;
  if(max<S){
   
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }  
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 500;

int N, M, Q;
int L, R;
int p, q;

int cnt[MAX_N][MAX_N];
int dp[MAX_N][MAX_N];

int main() {
    cin >> N >> M >> Q;
    REP(i, N) {
        REP(j, N) {
            cnt[i][j] = 0;
            dp[i][j] = 0;
        }
    }
    REP(i, M) {
        cin >> L >> R; L--; R--;
        cnt[L][R]++;
    }

    REP(i, N) dp[i][i] = cnt[i][i];

    REP2(k, 1, N) {
        REP(i, N-k) {
            int j = i + k;
            dp[i][j] = dp[i+1][j] + dp[i][j-1] - dp[i+1][j-1] + cnt[i][j];
        }
    }
    
    REP(i, Q) {
        cin >> p >> q; p--; q--;
        PRINT(dp[p][q]);
    }

    return 0;
}

Measured memory_bytes: 5472
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       D: usize,
       T:usize,
       S:usize,
    }

    let mut ans: usize = 0;
    echo!(if S * T >= D { "Yes" } else { "No" });
}


Measured memory_bytes: 2148
#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;
const int dx[] = {1, 1, -1, -1};
const int dy[] = {-1, 1, 1, -1};

bool check(vector<int> loc){
    rep(i, 8){
        int x = loc[i];
        int y = i;
        rep(dir, 4){
            int nx = x + dx[dir];
            int ny = y + dy[dir];
            while(0<=nx && nx<8 && 0<=ny && ny<8){
                
                if(loc[ny] == nx) return false;

                nx += dx[dir];
                ny += dy[dir];
            }
        }
    }

    return true;
}

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

    int k;
    cin >> k;

    vector<int> r(k), c(k);
    rep(i, k) cin >> r[i] >> c[i];

    vector<int> loc(8);
    rep(i, 8) loc[i] = i;

    do{
        bool verified = true;
        rep(i, k){
            if(loc[r[i]] != c[i]) verified = false;
        }
        if(!verified) continue;

        if(check(loc)) break;


    } while(next_permutation(loc.begin(), loc.end()));

    rep(i, 8){
        rep(j, 8){
            if(loc[i] == j) cout << 'Q';
            else cout << '.';
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3232
N,C=map(int,input().split())
ch=[[] for i in range(31)]
for i in range(N):
  s,t,c=map(int,input().split())
  ch[c].append([s,t])
arr=[[] for i in range(31)]
start=[]
end=[]
for i in range(31):
  score=[0]*(10**5+1)
  for j in range(len(ch[i])):
    score[ch[i][j][0]]+=1
    score[ch[i][j][1]]-=1
  for j in range(10**5+1):
    if score[j]==1:
      start.append(j)
    if score[j]==-1:
      end.append(j)
ans=[0]*(10**5+3)
for i in start:
  ans[i]+=1
for j in end:
  ans[j+1]-=1
for i in range(10**5):
  ans[i+1]+=ans[i]
print(max(ans))


Measured memory_bytes: 30548