akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        if (a == 5 && b == 5) {
            String[] arr = getComb(4, 4);
            for (String s : arr) {
                sb.append(s).append("AB").append("\n");
                sb.append(s).append("BA").append("\n");
            }
        } else if (a == 6) {
            String[] arr = getComb(4, 4);
            for (String s : arr) {
                sb.append(s).append("AA").append("\n");
            }
        } else if (b == 6) {
            String[] arr = getComb(4, 4);
            for (String s : arr) {
                sb.append(s).append("BB").append("\n");
            }
        } else if (a == 5) {
            String[] arr = getComb(a - 1, b);
            for (String s : arr) {
                sb.append(s).append("A").append("\n");
            }
        } else if (b == 5) {
            String[] arr = getComb(a, b - 1);
            for (String s : arr) {
                sb.append(s).append("B").append("\n");
            }
        } else {
            String[] arr = getComb(a, b);
            for (String s : arr) {
                sb.append(s).append("\n");
            }
        }
        System.out.print(sb);
    }
    
    static String[] getComb(int a, int b) {
        if (a == 0 && b == 0) {
            return new String[]{""};
        }
        if (a == 0) {
            String[] arr = getComb(a, b - 1);
            for (int i = 0; i < arr.length; i++) {
                arr[i] = "B" + arr[i];
            }
            return arr;
        } else if (b == 0) {
            String[] arr = getComb(a - 1, b);
            for (int i = 0; i < arr.length; i++) {
                arr[i] = "A" + arr[i];
            }
            return arr;
        } else {
            String[] arr1 = getComb(a - 1, b);
            for (int i = 0; i < arr1.length; i++) {
                arr1[i] = "A" + arr1[i];
            }
            String[] arr2 = getComb(a, b - 1);
             for (int i = 0; i < arr2.length; i++) {
                arr2[i] = "B" + arr2[i];
            }
            int length = arr1.length + arr2.length;
            String[] arr = new String[length];
            for (int i = 0; i < length; i++) {
                if (i < arr1.length) {
                    arr[i] = arr1[i];
                } else {
                    arr[i] = arr2[i - arr1.length];
                }
            }
            return arr;
       }
    }
}


Measured memory_bytes: 26508
h, w, a, b = gets.split.map(&:to_i)
if a > w / 2 || b > h / 2
  puts "No"
  exit
end

ans = Array.new(h) { Array.new(w, 0) }
b.times do |i|
  a.times do |j|
    ans[i][j] = 1
  end
end
(b...h).each do |i|
  (a...w).each do |j|
    ans[i][j] = 1
  end
end

puts ans.map{|x| x * ""}

Measured memory_bytes: 15996
data = list(map(int, input().split()))

buy = []

for i in range(2):
    if data[0] % data[2*i+1] == 0:
        buy.append(data[0] / data[2*i+1])
    else:
        buy.append(data[0] / data[2*i+1] + 1)

dataA = int(buy[0])*data[2]
dataB = int(buy[1])*data[4]

if dataA <= dataB:
    print(dataA)
else:
    print(dataB)


Measured memory_bytes: 5604
using System;
using System.Linq;

namespace Testcode
{
    class Program
    {
        static void Main(string[] args)
        {
                int total = int.Parse(Console.ReadLine());
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Reverse(x);
            for (int i = 0; i < total; i++)
            {
                if (!(i == 0))
                {
                    Console.Write(" ");
                }
                Console.Write(x[i]);
                            }
            Console.WriteLine();
        }

    }
}


Measured memory_bytes: 8192
import math
A, B, H, M = map(int, input().split())
cosAB = abs((H * 30 + M * 0.5) - (M * 6))
C = math.sqrt(pow(A, 2) + pow(B, 2) - 2*A*B*math.cos(math.radians(cosAB)))
print (C)

Measured memory_bytes: 9448
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

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

char s[4]={'0'};
for(int i=0;i<4;i++){
    cin>>s[i];
}
//1=0  2=1  3=2  4=3//
if(s[0]==s[1]&&s[0]==s[2]&&s[0]==s[3]){
       cout<<"No";
}
else if((s[0]==s[3]&&s[1]==s[2])||(s[1]==s[3]&&s[0]==s[2])||(s[0]==s[1]&&s[2]==s[3])){
    cout<<"Yes";
}

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


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

int main(void)
{
	char s[100];
	char t[100];
	int a,b;
	char u[100];
	scanf("%s %s",s,t);
	scanf("%d %d",&a,&b);
	scanf("%s",u);

	if(strcmp(s,u)==0){
		a=a-1;
	}else{
		b=b-1;
	}
	printf("%d %d",a,b);
}

Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ans = 0;
	cin >> N;

	vector<SINT32> DATA(N);
	
	rep(i,0,N) {
		cin >> DATA[i];
	}

	SINT32 buf = 0;
	while (1) {
		rep(i,0,N) {
			if ((DATA[i] % 2) == 0) {
			DATA[i] /= 2;

			} else {
				buf = 1;
			}
		}
		if (buf == 1) {
			break;
		}
		ans++;
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll x, ll y) {
  if (x < y) swap(x, y);
  while (y) swap(x %= y, y);
  return x;
}
int main() {
  ll x, y; cin >> x >> y;
  ll g = gcd(x, y);
  ll ans = x / g * y - x;
  if (ans > 0) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
import numpy as np
n, m = map(int, input().split())
ans = np.zeros(m)
for _ in range(n):
    result = np.array(list(map(int, input().split())))
    k = result[0]
    foods = result[1:] - 1
    for i in range(k):
        index = foods[i]
        ans[index] += 1

ans -= n-1
ans = np.maximum(ans, 0)
print(int(np.sum(ans)))

Measured memory_bytes: 12488
use proconio::{input};
use std::cmp::{max};

fn optmax<T:Ord + Copy>(x: Option<T>, v: T) -> Option<T> {
    return Some(max(x.unwrap_or(v), v));
}

#[allow(non_snake_case)]
#[allow(unused)]
fn main() {
    input! {
        N: usize,
        K: usize,
        P: [usize; N],
        C: [i64; N],
    }

    let calc = |startIndex| {
        let mut res: Option<i64> = None;
        let mut nodes: Vec<Option<(usize, i64)>> = vec![None; N];

        let mut k: usize = 0;
        let mut index = startIndex;
        let mut score = 0;

        while (k < K && nodes[index] == None) {
            nodes[index] = Some((k, score));

            index = P[index] - 1;
            score += C[index];
            res = optmax(res, score);

            k += 1;
        }

        if let Some((kk, ss)) = nodes[index] {
            let dk = k - kk;
            let dn = max(0, ((K - k) / dk) as i64 - 1) as usize;
            let ds = score - ss;

            if ds > 0 { score += ds * (dn as i64); }
            res = optmax(res, score);

            k += dn * dk;
        }

        while (k < K) {
            index = P[index] - 1;
            score += C[index];
            res = optmax(res, score);

            k += 1;
        }

        return res.unwrap_or_default();
    };

    let ans = ((0..N).map(|i| calc(i))).max();
    println!("{:?}", ans.unwrap_or_default());
}

Measured memory_bytes: 2420
from collections import Counter

N, P = map(int, input().split())
S = [int(s) for s in input()]
S.reverse()

ans = 0

if P != 2 and P != 5:
    prime10 = [1] * N
    for n in range(1, N):
        prime10[n] = (prime10[n-1] * 10) % P
    S = [(s * prime10[n]) % P for n, s in enumerate(S)]
    for n in range(1, N):
        S[n] = (S[n-1] + S[n]) % P

    S = Counter(S)
    for p in range(P):
        if p == 0:
            ans += S[p]
        ans += (S[p] * (S[p]-1)) // 2

else:
    for n in range(N):
        if S[n] % P == 0:
            ans += N - n

print(ans)

Measured memory_bytes: 60364
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll for (int i =0 ;i<n ;i++)
#define ll2 for (int j =0 ;j<k ;j++)
#define wh while (k>0)
#define pb push_back
#define stack stack<int>
//#define vector vector<int>vec(n)
#define set set<int>
#define sort sort(vec.begin(),vec.end())
#define  popcount __builtin_popcount
#define beg begin()
#define endi end()
#define f first
#define sec second
#define iso ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main()
{
    int a ,b ;
    cin>> a>>b ;
    if(a+b>=24)
    {
        cout<< (a+b)%24<<endl  ;
    }
    else
    {
        cout<< a+b<<endl ;
    }
}


Measured memory_bytes: 3572
nm = STDIN.gets.chomp.split(" ")
m = nm[1].to_i
data = []
STDIN.each{|x| data.push(x.chomp.split(" ").map{|y| y.to_i})}
data.sort!{|a,b| a[0] <=> b[0]}

i = 0
cost = 0
while m > 0 do
  if data[i][1] < m
    m -= data[i][1]
    cost += data[i][0] * data[i][1]
  else
    cost += data[i][0] * m
    m = 0
  end
  i += 1
end

puts cost

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


const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007;
const int INF = 1000000000 + 1;

long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}

void dfs(int curcol, int v, vector<vector<int>>& gr, vector<int>& col) {
  col[v] = curcol;
  for (int next : gr[v]) {
    if (col[next] < 0) {
      dfs(curcol, next, gr, col);
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;

  while (q-- >0) {
    int n;
    cin >> n;
    ll a[n];
    ll res = 1ll;
    const ll bound = 1000000000000000000ll;
    for (int i = 0;i  <n; ++i) {
      cin >> a[i];
      if (a[i] == 0) res = 0ll;
      if (a[i] > 0 && res >  2 * bound / a[i]) {
        res = -1;
      }
      if (res > 0) res *= a[i];
      if (res > bound) res = -1;
    }
    cout << res << endl;

  }
  return 0;
}



Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
//char型から数値型に変換する関数（z.at(i)などに使用）
int ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
  int n;
  cin>>n;
  int z=n/111;
  if(n%111==0){
  cout<<n;
  }
  else{
    cout<<111*(z+1);
  }
}

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

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

  vector<string> day = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

  for (int i = 0; i < 7; i++) {
    if (day[i] == S) {
      cout << 7 - i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
n,k = map(int, input().split())
As = list(map(int, input().split()))

visited = [-1] * n
cnt = 0
n = 0
while True:
    visited[n] = cnt
    nx = As[n] - 1
    cnt += 1
    # ループ入った場合
    if visited[nx] != -1:
        first = visited[nx]
        if k <= first:
            for i,v in enumerate(visited):
                if v == k:
                    print(i+1)
                    exit()    
        a = (k-first)%(cnt-first)
        loop = [v-first for v in visited]
        for i,x in enumerate(loop): 
            if x == a:
                print(i+1)
                exit()
        break
    n = nx



Measured memory_bytes: 32380
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e9],A[m:r]+[1e9]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1;c+=j
  else:A[k]=R[j];j+=1
def s(A,l,r):
 if l+1<r:m=(l+r)//2;s(A,l,m);s(A,m,r);g(A,l,m,r)
if'__main__'==__name__:
 c=0
 n=int(input())
 A=list(map(int,input().split()))
 s(A,0,n)
 print(c)


Measured memory_bytes: 27480
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
using namespace std;
using ll =long long;
int main() {
	string N;

		cin >> N;


	
	if (N[3] == N[2] && N[4] == N[5]) {


		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

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

#define IS_DEBUG true

#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl

int main()
{
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    if (count(A.begin(), A.end(), a) == 0)
    	A.push_back(a);
  }
  
  RESULT_OUTPUT(A.size());
  
  
  if (IS_DEBUG)
  {
    int end;
    cin >> end;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int n = 2 * 1e5;
 int a[n];
int main(){
	string s;
	cin >> s;
	int e = 0;
	for(int i = 1; i < s.size(); i++)
	{
		if(s[i] != s[i - 1])
		{
			e++;
		}
		if(s[i] == s[i - 1])
		{
			if( i == s.size() - 1 - 2)
			{
				cout << e + 3;
				return 0;
			}
			if(i == s.size() - 1 - 1)
			{
				cout << e + 2;
				return 0;
			}
			if(i == s.size() - 1)
			{
				cout << e + 1;
				return 0;
			}
			e += 2;
			i += 2;
		}
	}
	cout << e + 1;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

int main(){
    int counter = 0;
    string W, T;
    cin >> W;
    for(int i = 0; i < W.size(); i++){
        W[i] = tolower(W[i]);
    }
    // cout << W << endl;
    while(cin >> T){
        if("END_OF_TEXT" == T){
            break;
        }
        // cout << T << endl;

        for(int i = 0; i < T.size(); i++){
            T[i] = tolower(T[i]);
        }

        // cout << W << T << endl;

        if(W == T){
            counter++;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    
    vector<int> Time = {a, b, c, d, e};
    vector<int> NextTime(5);
    for (int i = 0; i < 5; i++) {
        if (Time[i] % 10 == 0) {
            NextTime[i] = Time[i];
        }
        else {
            NextTime[i] = Time[i] - Time[i] % 10 + 10; 
        }
    }
    
    int BestTime = 99999;
    for (int i = 0; i < 5; i++) {
        int SumTime = 0;
        for (int j = 0; j < 5; j++){
            if (i == j) {
                SumTime += Time[j];    
            }
            else {
                SumTime += NextTime[j];
            }
        }
        BestTime = min(BestTime, SumTime);
    }
    
    cout << BestTime << endl;
    
    
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll NMAX = 1e6;
ll fac[NMAX + 1], inv[NMAX + 1], finv[NMAX + 1];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, NMAX + 1) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}

ll N;
VL A, invsum;

int main() {
    cin >> N;
    A.resize(N);
    invsum.resize(N + 1);
    VECCIN(A);
    cominit();
    invsum[0] = 0;
    REP(i, N) { invsum[i + 1] = (invsum[i] + modinv(i + 1, MOD)) % MOD; }
    ll ans = 0;
    REP(i, N) {
        ans += A[i] * (invsum[i + 1] + invsum[N - i] - 1) % MOD;
        ans %= MOD;
    }
    (ans *= fac[N]) %= MOD;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 25216
def bmi(w,h):
    return w / (h ** 2)

s,w,h = [],[],[]
while True:
    try:
        tmp = input().split(',')
        s.append(int(tmp[0]))
        w.append(float(tmp[1]))
        h.append(float(tmp[2]))
    except EOFError:
        break
f = []
for i in range(len(s)):
    if bmi(w[i],h[i]) >= 25:
      f.append(s[i])
if len(f) != 1 and len(f) != 0:
    for i in range(len(f)-1):
        print(f[i])
if len(f) != 1 and len(f) != 0:
    print(f[-1])
elif len(f) == 1:
    print(f[0])

Measured memory_bytes: 7640
import bisect

while True:
  max_S = 0
  p = [0]
  pp = []

  n, m = map(int, input().split())
  if n == 0 and m == 0:
    break

  for _ in range(n):
    p.append(int(input()))

  for c in range(n + 1):
    for d in range(c, n + 1):
      pp.append(p[c] + p[d])

  pp.sort()

  # ppの中でm以下の数字の位置
  t = bisect.bisect_left(pp, m)
  ## ppの中でm/2以下の数字の位置
  h = bisect.bisect_left(pp, m//2 , 0, t)

  if t < len(pp):
    if pp[t] == m:
      print(m)
      continue
    pp = pp[:t]
  max_S = 0

  for i in range(0, len(pp)):
    t = bisect.bisect_left(pp, m - pp[i])
    if pp[i] + pp[t - 1] > max_S:
      max_S = pp[i] + pp[t - 1]
  print(max_S)



Measured memory_bytes: 27840
#include <stdio.h>
#include <math.h>
#define N_MAX 110
#define INFINITE 2147000000

int main(){
    
    int n;
    int min = INFINITE;
    int x[N_MAX];
    
    scanf("%d",&n);
    for ( int i=0; i<n; i++ )  scanf("%d",&x[i]);
    
    int p;
    for ( p=1; p<=100; p++ ){
        
        int disp = 0;
        for ( int i=0; i<n; i++ )  disp += pow(p-x[i],2);
        if ( disp < min )          min = disp;
        
    }
    
    printf("%d\n",min);
    return 0;
    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	int ans=0;
	for(int i=1;i*i<=m;i++){
		if(m%i==0){
			int j=m/i;
			if(j>=n) chmax(ans,i);
			if(i>=n) chmax(ans,j);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;
  cin>>N>>M;
  vector<vector<ll>> A(N,vector<ll>(M));
  cin>>A;
  for(auto &I:A){for(auto &J:I){J--;}}
  auto judge=
    [&](int X){
      vector<bool> used(M,false);
      vector<int> idx(N,0);
      vector<stack<int>> people(M);
      queue<int> over;
      for(int i=0;i<N;i++){
        people[A[i][0]].push(i);
        if((int)people[A[i][0]].size()==X){over.push(A[i][0]);}
      }
      while(!over.empty()){
        int k=over.front(); over.pop();
        used[k]=true;
        while(!people[k].empty()){
          int a=people[k].top(); people[k].pop();
          while(idx[a]<M && used[A[a][idx[a]]]){idx[a]++;}
          if(idx[a]==M){return false;}
          people[A[a][idx[a]]].push(a);
          if((int)people[A[a][idx[a]]].size()==X){over.push(A[a][idx[a]]);}
        }
      }
      return true;
    };
  int l=1,r=N+1;
  while(r-l>1){
    int m=(l+r)>>1;
    if(judge(m)){r=m;}
    else{l=m;}
  }
  cout<<l<<endl;
  


  return 0;
}


Measured memory_bytes: 1240
N, K = map(int, input().split())

if K > (N - 1) * (N - 2) // 2:
    print(-1)
else:
    M = N * (N - 1) // 2 - K
    cnt = 0
    ans = []
    for i in range(N - 1):
        for j in range(i + 1, N):
            ans.append((i + 1, j + 1))
            cnt += 1
            if M == cnt:
                break
        else:
            continue
        break
    print(M)
    for edge in ans:
        print(*edge)


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

int main(){
  int k,a,b; cin>>k>>a>>b;
  int check=0;
  for (int i=a; i<b+1; i++){
    if (i%k==0)  check=1;
  }
  cout<<(check==1 ? "OK" : "NG")<<endl;
}

Measured memory_bytes: 3584
n = int(input())
if n <= 9:
  print(n)
elif n <= 99:
  print(9)
elif n <= 999:
  print(9 + (n-100+1))
elif n <= 9999:
  print(909)
elif n <= 99999:
  print(909 + (n-10000+1))
else:
  print(90909)

Measured memory_bytes: 2940
function Main(input) {
	var lines = input.split("\n");
	var n_num = Number(lines[0].split(' ')[0])
	var n_str = lines[0].split(' ')[0].split('')
	var d = lines[1].split(' ')
	while(1) {
		if(n_str.some(n => d.indexOf(n) > -1)) {
			n_num++
			n_str = (n_num + '').split('')
		} else {
			console.log(n_num)
			break
		}
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21688
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

using pii = pair<int64_t, int64_t>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;

constexpr int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    vector<intmax_t> a(N);
    for (auto &ai: a) cin >> ai;

    const int MOD = int(1e9) + 7;
    intmax_t sum = 0;
    for (intmax_t i = 0; i < 60; ++i) {
        intmax_t cnt = 0;
        for (size_t j = 0; j < N; ++j) {
            if ((a[j] >> i) & 1) {
                cnt++;
            }
        }
        sum += cnt * (N - cnt) % MOD * ((1LL << i) % MOD);
        sum %= MOD;
    }

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    long long int n, m, a[100100] = {0};
    long long int sa[100100] = {0};
    long long int ans = 0;

    cin >> n >> m;

    for (int i = 0; i < m; i++) cin >> a[i];

    sort(a, a+m);

    for (int i = 0; i < m-1; i++) {
        sa[i] = a[i+1]-a[i];
        ans += sa[i];
    }

    sort(sa, sa+(m-1));
    reverse(sa, sa+(m-1));

    for (int i = 0; i < n-1; i++) {
        ans -= sa[i];
    }

    cout << ans << endl;

}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	if (s == "ARC") cout << "ABC";
	else cout << "ARC";
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int x1, y1, x2, y2;
    int x3, y3, x4, y4;
    
    cin >> x1 >> y1 >> x2 >> y2;
    
    if(x1 > x2) {
        y3 = y2 - abs(x2 - x1);
        y4 = y1 - abs(x2 - x1);
    } else {
        y3 = y2 + abs(x2 - x1);
        y4 = y1 + abs(x2 - x1);
    }
    if(y1 > y2) {
        x3 = x2 + abs(y2 - y1);
        x4 = x1 + abs(y2 - y1);
    } else {
        x3 = x2 - abs(y2 - y1);
        x4 = x1 - abs(y2 - y1);
    }
    
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
    
    return 0;
}


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

int main(){
    long int a,b,c,tmp1,tmp2;
    
    scanf("%ld %ld %ld",&a,&b,&c);
    
    tmp1 = 4*a*b;
    c -= a+b;
    if(c < 0) c = 0;
    tmp2 = c*c;
    
    if(tmp1 < tmp2) printf("Yes\n");
    else printf("No\n");
    
//    printf("%Lf %Lf %Lf %Lf\n",ans_a,ans_b,ans_ab,ans_c);
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define  N 200000
int main()
{

    char s[N];
    int countD=0;
    int countPD = 0;
    int pre = 1;//1なら以前がP
    scanf("%s", s);

    for (int i = 0; s[i] != '\0'; i++){
        if (s[i]=='?'){
            s[i] = 'D';
            countD++;
            countPD += pre;
            pre = 0;
        }
        else if(s[i]=='D'){
            countD++;
            countPD += pre;
            pre = 0;
        }
        else {
            pre = 1;
        }
    }


          //  printf("%d\n",countD+countPD);
      
            printf("%s",s);
        


    printf("\n");
}

Measured memory_bytes: 2348
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a[0];
    int tmp;
    repext(i, 1, n) {
        cin >> tmp;
        a[i] += a[i - 1] + tmp;
    }

    vector<p_i> pos;
    rep(i, h) {
        if (i % 2 == 0) {
            rep(j, w) {
                pos.push_back(p_i(i, j));
            }
        } else {
            reprev(j, w) {
                pos.push_back(p_i(i, j));
            }
        }
    }

    vector<vector<int>> map(h, vector<int>(w, 0));

    int sum_index = 0;
    int current_sum = a[sum_index];
    rep(i, h * w) {
        if (i == current_sum) {
            sum_index++;
            current_sum = a[sum_index];
        }
        int y = pos[i].first;
        int x = pos[i].second;

        map[y][x] = sum_index + 1;
    }

    rep(i, h) {
        rep(j, w) {
            cout << map[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
n = int(input())

cards = [False] * 52

for i in range(0, n):
  l = input().split()
  mark, num = l[0], int(l[1])
  if mark == 'S':
    cards[num-1] = True
  elif mark == 'H':
    cards[num-1+13] = True
  elif mark == 'C':
    cards[num-1+26] = True
  elif mark == 'D':
    cards[num-1+39] = True

for i in range(52):
  if cards[i] == True:
    continue
  elif i < 13:
    print('S {}'.format(i+1))
  elif i < 26:
    print('H {}'.format(i+1-13))
  elif i < 39:
    print('C {}'.format(i+1-26))
  elif i < 52:
    print('D {}'.format(i+1-39))


Measured memory_bytes: 5596
from math import sqrt,floor
N=int(input())
L=[]
for i in range(2,55556):
    if i%10!=1:
        continue
    flag=True
    for j in range(2,int(sqrt(i))+4):
        if i%j==0:
            flag=False
    if flag:
        L.append(i)
print(' '.join(map(str,L[:N])))

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

int d[110];

int main(){
  int n; cin >> n;
  for(int i = 2; i <= n; i++){
    int tmp = i;
    for(int j = 2; j <= i; j++){
      while(tmp % j == 0){
        d[j]++;
        tmp /= j;
      }
    }
  }
  int ans = 0;
  vector<int> k(5); //2, 4, 14, 24, 74
  for(int i = 2; i <= n; i++){
    if(d[i] >= 2) k.at(0)++;
    if(d[i] >= 4) k.at(1)++;
    if(d[i] >= 14) k.at(2)++;
    if(d[i] >= 24) k.at(3)++;
    if(d[i] >= 74) k.at(4)++;
  }
  ans += k[4] + k[3]*(k[0]-1) + k[2]*(k[1]-1);
  ans += k[1]*(k[1]-1)*(k[0]-2)/2;
  cout << ans << endl;
}
                                     
    
        
        
      
        
        
      

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <map>
using namespace std;

int N, M;
map<string, int> C;

int main(void) {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		++C[s];
	}
	cin >> M;
	for (int i = 0; i < M; ++i) {
		string t;
		cin >> t;
		--C[t];
	}

	map<string, int>::iterator itr;
	int max_cnt = 0;
	for (itr = C.begin(); itr != C.end(); ++itr) {
		if (itr->second > max_cnt)
			max_cnt = itr->second;
	}
	if (max_cnt < 0)
		max_cnt = 0;

	cout << max_cnt << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return l>r;
  }
};
ll inf=1e18;
int dp[3005][3005];
string s,t;
int l1,l2;
int fun(int pos1,int pos2)
{
    if(pos1==l1 || pos2==l2)
        return 0;
    if(dp[pos1][pos2]!=-1)
    {
        return dp[pos1][pos2];
    }
    int ans=0;
    if(s[pos1]==t[pos2])
    {
        ans=1+fun(pos1+1,pos2+1);
    }
    else
    {
        ans=fun(pos1+1,pos2);
        ans=max(ans,fun(pos1,pos2+1));
    }
    return dp[pos1][pos2]=ans;
}
void print(int pos1,int pos2,int l)
{
    if(l==0)
        return;
    if(pos1==l1 || pos2==l2)
        return;
    if(s[pos1]==t[pos2])
    {
        cout<<s[pos1];
        print(pos1+1,pos2+1,l-1);
    }
    else
    {
        if(dp[pos1+1][pos2]==l)
        {
            print(pos1+1,pos2,l);
        }
        else
            print(pos1,pos2+1,l);
    }
}
int main()
{
//    READ;
    cin>>s>>t;
    l1=s.length();
    l2=t.length();
    mem(dp,-1);
    int x=fun(0,0);
//    cout<<x<<endl;
    print(0,0,x);
    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, K;
ll ans = 0;
VL sum, rsum, ju;
priority_queue<ll, vector<ll>, greater<ll>> pq;
int main() {
    cin >> N >> K;
    REP(i, N) ju.emplace_back(IN());
    // sum.resize(N+2);
    // rsum.resize(N+2);
    // REP(i,N){
    //     sum[i+1]=sum[i]+ju[i];
    //     rsum[N-i]=sum[N-i+1]+ju[N-i-1];
    // }
    ll ans = 0;
    REP(k, min(K + 1, N + 1)) {
        REP(j, k + 1) { // j;; left kosuu
            ll tmp = 0;
            REP(idx, j) { pq.emplace(ju[idx]); }
            FOR(idx, N - (k - j), N) { pq.emplace(ju[idx]); }
            ll cnt = 0;
            // cout << "\n" << j << "\n";
            // while(!pq.empty()) {
            //     cout << pq.top() << " ";
            //     pq.pop();
            // }
            while(!pq.empty() && cnt < K - k) {
                ll t = pq.top();
                if(t >= 0) break;
                pq.pop();
                cnt++;
            }
            while(!pq.empty()) {
                tmp += pq.top();
                pq.pop();
            }
            ans = max(tmp, ans);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "c.cpp"

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

  ll cnt = 0;
  ll sum = 0;
  ll x = 1;

  while (true) {
    cnt++;
    x *= 26;
    sum += x;
    if (n <= sum) {
      break;
    }
  }

  ll p = n-(sum-x)-1;

  vector<char> ans(cnt);
  rep(i, cnt) {
    ans[i] = 'a'+(p%26);
    p /= 26;
  }

  per(i, cnt) {
    cout << ans[i];
  }
  cout << el;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	int S=0;
	int V=N;
	while(V){
		S+=(V%10);
		V/=10;
	}

 	cout << (N%S ? "No" : "Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    for i in range(n):
        num3=list1[i][1]
        numa+=[num3]*(num3-1)
        numb+=[num3]*(n-num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def countnum(num):
        return ans.count(num)
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                if countnum(list1[count1][1])!=list1[count1][1]-1:
                    ansnum=1
                    break
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()


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

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

    int ans = 0;
    for (int i = 0; i < n; i++){
        if(s[i] == '.') ans++;
    }
    int m = ans;
    for (int i = 0; i < n; i++){
        if(s[i] == '.') ans--;
        if(s[i] == '#') ans++;
        m = min(ans, m);
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int min(int n,int m){
    if(n<m) return n;
    else return m;
}
int main(void){
    char s[100001];
    int a=0,b=0;
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='0') a++;
        else b++;
    }
    printf("%d",min(a,b)*2);
}

Measured memory_bytes: 256
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint num[252521];
vector<int> gr[252521];
lint ch[252521];
lint out[252521];
int c[252521];
lint dfs(int v,int u){
	ch[v]=1;
	lint def=num[c[v]];
	rep(i,gr[v].size()){
		int w=gr[v][i];
		if(w==u) continue;
		lint pre=num[c[v]];
		ch[v]+=dfs(w,v);
		lint now=num[c[v]];
		lint x=ch[w]-(now-pre);
		//cout<<c[v]<<' '<<w<<' '<<now<<' '<<pre<<' '<<ch[w]<<endl;
		out[c[v]]-=x*(x+1)/2;
	}
	num[c[v]]=def+ch[v];
	return ch[v];
}
int main()
{
	int n,a,b;cin>>n;
	rep(i,n){
		cin>>c[i];c[i]--;
	}
	rep(i,n-1){
		cin>>a>>b;a--;b--;
		gr[a].pb(b);gr[b].pb(a);
	}
	memset(num,0,sizeof(num));
	rep(i,n) out[i]=(lint)n*(n+1)/2;
	dfs(0,-1);
	rep(i,n) out[i]-=(n-num[i])*(n-num[i]+1)/2;
	rep(i,n) cout<<out[i]<<endl;
}


Measured memory_bytes: 40380
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in=new Scanner(System.in);
		int x=in.nextInt();
		int a=in.nextInt();
		int b=in.nextInt();
		int x1=Math.abs(a-x);
		int x2=Math.abs(b-x);
		if (x1<x2){
			System.out.println("A");
		}else{
			System.out.println("B");
		}
	}
}

Measured memory_bytes: 21972
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		
		int height = 0;
		int width = 0;
		
		Scanner sc = new Scanner(System.in);
		
		for(;;){
			
			String line = sc.nextLine();
			String[] array = line.split(" ");
			
			height = Integer.parseInt(array[0]);
			width = Integer.parseInt(array[1]);
			
			if(height == 0 && width == 0){
				sc.close();
				break;
			}
			else{
				for(int rowIndex = 0; rowIndex < height; rowIndex++ ){
					for(int columnIndex = 0; columnIndex < width; columnIndex++){
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
		}
		

	}

}

Measured memory_bytes: 35552
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors

n=int(input())

l=make_divisors(n)

print(n//l[-1]+l[-1]-2)

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
  cerr << ' ' << head;
  debug_cerr(tail...);
}
void chmax(lint &a, lint b) { if (a < b) a = b; }
void chmin(lint &a, lint b) { if (a > b) a = b; }
struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} iosetup;

int main() {
  vector<bool> vec(3, true);
  for (int i = 0; i < 2; ++i) {
    int a; cin >> a;
    vec[a-1] = false;
  }
  for (int i = 0; i < 3; ++i) {
    if (vec[i]) cout << i + 1 << '\n';
  }
}


Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<(n-2);i++)
	{
	    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
	        ans++;
	}
	cout<<ans;
    return 0;
}


//252908XL

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

int main(void){
    int n;
    scanf("%d",&n);
    while(1){
        if(n/100 == n%10 && n%10 == (n/10)%10){
            break;
        }
        n++;
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 128