akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define re register
using namespace std;
struct ios{
	template <typename ty> inline ios& operator >> (ty &x)
	{
		register int f=1;x=0;register char c=getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
		for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
		x*=f;return *this;
	}
	template <typename ty>  inline ios& operator << (ty x)
	{
		if(x<0) x=-x,putchar('-');
		if(x>9) *this << x/10;
		putchar(x%10+48);
		return *this;
	}
	inline ios& operator << (char c){putchar(c);return *this;}
}io;
ll n,a[1000],sum,k,fac[1000],tot,b[1000];
inline bool check(ll x)//ÒÔxÎª×î´ógcd 
{
	for(int i=1;i<=n;i++) b[i] = a[i]%x;//¶ÔÓÚÃ¿¸öa[i]ÕÒµ½ËûµÄ¶ÔÓÚxµÄÄ£Êý£¬
	sort(b+1,b+1+n);
	int cnt = 0;
	int l=1,r=n;
	while(l<r)
	{
		
		int dis = x-b[r];
		if(b[l] >= dis) cnt += dis,b[l] -= dis,b[r] += dis;
		else 
		{
			cnt += b[l],b[r] += b[l],b[l] -= b[l];
		}
		while(b[r]==x) r--;
		while(b[l]==0) l++;
	}
	for(int i=1;i<=n;i++) if(b[i]%x!=0) return false;
	return cnt <= k;
}

int main()
{
	io >> n >> k;
	for(int i=1;i<=n;i++) io >> a[i],sum += a[i];
	ll ans = 1;
	for(ll i=1;i*i<=sum;i++)
	{
		if(sum%i==0) 
		{
//			fac[++tot] = i;
//			fac[++tot] = sum/i;
			if(check(i)) ans = max(ans,i);
			if(check(sum/i)) ans = max(ans,sum/i);
//			if(check(sum/i))
//			{
//				io <<sum/i;
//				return 0;
//			}
		}
	}
//	sort(fac+1,fac+1+tot);
//	for(int i=tot;i>=1;i--)
//	{
//		if(check(fac[i]))
//		{
//			io << fac[i];
//			return 0;
//		}
//	}
	io << ans;
	return 0;
}

Measured memory_bytes: 256
fn main(){
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let c: i32 = vec[0].parse().unwrap();

    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let mut data: Vec<i32> = Vec::new();
    for x in 0..c{
        let n: i32 = vec[x as usize].parse().unwrap();
        data.push(n);
    }
    sort(& mut data);
}

pub fn sort(data:&mut Vec<i32>){
    let mut count = 0;

    for x in 0..data.len(){
        let mut min = x;
        for y in x..data.len(){
            if data[y] < data[min]{
                min = y;
            }
        }
        if data[x] != data[min] {count += 1;}
        data.swap(x, min);

    }

    for x in 0..data.len(){
        let n: i32 = data[x];
        print!("{}",n);
        if x != data.len()-1 {
            print!(" ");
        }
    }
    println!("");
    println!("{}",count);
}

Measured memory_bytes: 5052
from itertools import permutations
import math

n = int(input())
p = [tuple(map(int, input().split())) for _ in range(n)]

ans = cnt = 0
for perm in permutations(range(n)):
    dist = 0
    for i in range(1, n):
        dist += math.sqrt((p[perm[i]][0] - p[perm[i - 1]][0])**2 +
                          (p[perm[i]][1] - p[perm[i - 1]][1])**2)

    # print(perm, dist)
    ans += dist
    cnt += 1

ans /= cnt
print(ans)


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
ll x[100005], y[100005];
P px[100005],py[100005];
vector<P> G[100005]; // to,cost
ll ans;

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

    cin >> N;
    for (int i = 0;i < N;i++){
        cin >> x[i] >> y[i];
        px[i] = P(x[i],i);
        py[i] = P(y[i],i);
    }
    sort(px,px+N);
    sort(py,py+N);
    
    for (int i = 0; i < N-1;i++){
        int a = px[i].second, b = px[i+1].second;
        G[a].push_back(P(min(abs(x[a]-x[b]),abs(y[a]-y[b])),b));
        G[b].push_back(P(min(abs(x[a]-x[b]),abs(y[a]-y[b])),a));
        a = py[i].second; b= py[i+1].second;
        G[a].push_back(P(min(abs(x[a]-x[b]),abs(y[a]-y[b])),b));
        G[b].push_back(P(min(abs(x[a]-x[b]),abs(y[a]-y[b])),a));
    }

    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,0));
    bool used[100005]; memset(used,0,sizeof(used));

    while(que.size()){
        ll cost = que.top().first;
        ll node = que.top().second;
        que.pop();
        if(used[node]) continue;
        used[node] = true;
        ans += cost;
        for (int i = 0;i < G[node].size();i++){
            que.push(G[node][i]);
        }
    }

    cout << ans << endl;

    return 0;

}

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




signed main(){
    
    string s; cin >> s;
    if( 'A' <= s[0] and s[0] <= 'Z')
        cout << "A" << endl;
    else
    {
         cout << "a" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3636
n = int(input())
if n < 10:
    ans = n
elif n < 100:
    ans = 9
elif n < 1000:
    ans = 9 + n - 99
elif n < 10000:
    ans = 9 + 999 - 99
elif n < 100000:
    ans = 9 + 999 - 99 + n - 9999
else:
    ans = 9 + 999 - 99 + 99999 - 9999
print(ans)

Measured memory_bytes: 3060
n,a,b=map(int,input().split())
l=list(range(1,n+1))
SUM=0
for i in l:
  sum=0
  S=str(i)
  for j in range(len(S)):
    sum+=int(S[j])
  if a<=sum<=b:
    SUM+=i
print(SUM)   

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        string s;
        cin>>s;
        vi count(3000,0);
        n=s.size();
        ll ans=0;
        ll x=1;
        ll yy=0;
        count[0]++;
        for(i=0;i<n;i++)
        {
            yy=(yy*10+s[i]-'0')%2019;
            ll y=(yy*x)%2019;
            // cout<<y<<endl;
            ans+=count[y];
            count[y]++;
            x=(x*202)%2019;
        }
        cout<<ans;
    }
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()) {
        int ct = 0;
        for (int j = 0; i+j < s.size(); j++){
            if (s[i+j] == 'A' || s[i+j] == 'C' || s[i+j] == 'G' || s[i+j] == 'T') {
                ct++;
            }
            else break;
        }
        ans = max(ans,ct);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<cmath>

using namespace std;
/*
int main() {
	int A, N,answer;
	cout << "N,Aを入力。" << endl;
	cin >> N >> A;
	answer = N % 500;
	if (A>=1)
	{
		answer %= 1;
		if (answer==0)
		{
			cout << "Yes" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}
*/
int main() {
	int N ,n,m;
	
	cin >> N;
	if (N%2==0)
	{
		cout << N;
	}else{
		cout << 2 * N;
	}

	return 0;
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim s As String = NextString()
        Dim dic(s.Length - 1) As HashSet(Of Char)
        Dim flg As Boolean = False

        For i As Integer = 0 To s.Length - 1
            dic(i) = New HashSet(Of Char)
            dic(i).Add(s(i))
        Next

        Do
            For c As Byte = Asc("a"c) To Asc("z"c)
                For i As Integer = 0 To dic.Length - 1
                    If Not dic(i).Contains(Chr(c)) Then
                        GoTo exitLoop
                    End If
                Next
                flg = True
exitLoop:
            Next

            For i As Integer = 0 To dic.Length - 2
                For Each v As Char In dic(i + 1)
                    dic(i).Add(v)
                Next
            Next

            If flg Then Exit Do
            ReDim Preserve dic(dic.Length - 2)
        Loop

        WriteLine(s.Length - dic.Length)
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 20560
#include<bits/stdc++.h>
using namespace std;
//long long a[100005]={0};
vector<long long>a;
vector<long long>q1;
vector<long long>q2;
vector<long long>q3;
vector<long long>q4;
vector<long long>q5;
int main()
{
	long long n,m,c;
	cin>>n;
	for(int i=0;i<n;i++)
	{int t;
		cin>>t;
		a.push_back(t);
	}
	if(n==1)
	{
		printf("0\n");
		
	}
	
	sort(a.begin(),a.end());
	long long sum=0,mid=n/2;

       
       vector<long long>q;
    
       if(n%2==1)
       {    
	       q.push_back(a[mid]);
	       q2.push_back(a[mid]);
	      //long long dise=a[n-1]-a[mid],disb=a[mid]-a[0];
        	   for(long long i=0;i<n/2;i++)
                {
                	q.push_back(a[n-1-i]);
       	      	    q.push_back(a[i]);	
	            }
             
          
            for(long long i=0;i<n/2;i++)
           { q2.push_back(a[i]);
       	    q2.push_back(a[n-1-i]);
       	    		
	        }
	
	     	   
	   }
	   else
	   { mid--;
	   	   q4.push_back(a[mid]);
	     
        
	           for(long long i=0;i<n/2-1;i++)
                {
                	q4.push_back(a[n-1-i]);
       	      	    q4.push_back(a[i]);	
	            }
	            q4.push_back(a[mid+1]);
             
           q3.push_back(a[mid]);
            for(long long i=0;i<n/2-1;i++)
           { q3.push_back(a[i]);
       	    q3.push_back(a[n-1-i]);
       	    		
	        }
	q3.push_back(a[mid+1]);
	     	
		 mid++;
		    q1.push_back(a[mid]); 
		      q5.push_back(a[mid]);
		     //long long dise1=a[n-1]-a[mid],disb1=a[mid]-a[0];
		     	   for(long long i=0;i<n/2-1;i++)
                {
                	q1.push_back(a[n-1-i]);
       	      	    q1.push_back(a[i]);	
	            }
	            q1.push_back(a[mid-1]);
             
          
            for(long long i=0;i<n/2-1;i++)
           { q5.push_back(a[i]);
       	    q5.push_back(a[n-1-i]);
       	    		
	        }
	q5.push_back(a[mid-1]);
	     //printf(" 11");
	   }
	   
     long long ans[10]={0};
     long long sum1=0;
	   for(long long i=0;i<n-1;i++)
	   {
	   	if(n%2==1)
	   	{
	   		ans[0]+=abs(q[i]-q[i+1]); 
	   		ans[1]+=abs(q2[i]-q2[i+1]); 
		   }
	   	else
	   	{
	   	ans[2]+=abs(q1[i]-q1[i+1]); 
	   	ans[3]+=abs(q3[i]-q3[i+1]); 
	   		sum1+=abs(q4[i]-q4[i+1]); 
	   			ans[5]+=abs(q5[i]-q5[i+1]); 
		   }

		} 
		sort(ans,ans+6);
	//	
	
cout<<ans[5]<<endl;	
 } 

Measured memory_bytes: 4852
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <numeric>
#include <stack>
#include <sstream>
#include <set>
using namespace std;

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


int main(){
    int64_t n ;
    cin >> n ;
    vector<int> x(n) ;
    vector<int> y(n) ;
    vector<int> h(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> x.at(i) >> y.at(i) >> h.at(i) ;
    }
    int64_t cx,cy,th ;
    bool end = false ;
    for (size_t i = 0; i < 101; i++)
    {
        for (size_t j = 0; j < 101; j++)
        {
            cx = i ;
            cy = j ;
            int s ;
            for (size_t k = 0; k < n; k++)
            {
                if (h.at(k) > 0)
                {
                    s = k ;
                    break ;
                }
                
            }
            
            th = h.at(s) + abs(cx - x.at(s)) + abs(cy - y.at(s)) ;
            bool match = true ;
            for (size_t k = 0; k < n; k++)
            {
                int64_t judge = th - abs(cx - x.at(k)) - abs(cy - y.at(k)) ;
                if (judge < 0)
                {
                    judge = 0 ;
                }
                
                if (judge != h.at(k))
                {
                    match = false ;
                    break ;
                }
                
            }
            if (match == 1)
            {
                end = 1 ;
                break ;
            }
            
        }
        if (end == 1)
        {
            break ;
        }
        
    }
    cout << cx << " " << cy << " " << th << endl ;
}


Measured memory_bytes: 256
//
// Created by kashi on 27-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}
int lcm(int a, int b){
    return (a*b)/gcd(a, b);
}
int32_t main() {
    int h, n;
    cin >> h >> n;
    int a[n];
    int sum=0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if(sum>=h)
        cout<<"Yes"<<Endl;
    else cout<<"No"<<Endl;
    return 0;
}



Measured memory_bytes: 4276
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();
    
    string s;
    cin >> s;
    
    for (auto to : s) {
    	if (to == '9')
    		cout << 1;
    	else if (to == '1')
    		cout << 9;
    	else
    		cout << to;
    }
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int bsr(int x) { return 31 - __builtin_clz(x); }
using D = double;
const D pi = acos(-1);
using Pc = complex<D>;

void fft(bool type, vector<Pc> &c){	//multiply : false -> mult -> true
	static vector<Pc> buf[30];
	int N = c.size();
	int s = bsr(N);
	assert(1<<s == N);
	if(buf[s].empty()){
		buf[s]=vector<Pc>(N);
		rep(i,N) buf[s][i] = polar<D>(1,i*2*pi/N);
	}
	vector<Pc> a(N),b(N);
	copy(begin(c),end(c),begin(a));
	rep1(i,s){
		int W = 1<<(s-i);
		for(int y=0;y<N/2;y+=W){
			Pc now = buf[s][y];
			if(type) now = conj(now);
			rep(x,W){
				auto l =       a[y<<1 | x];
				auto r = now * a[y<<1 | x | W];
				b[y | x]        = l+r;
				b[y | x | N>>1] = l-r;
			}
		}
		swap(a,b);
	}
	copy(begin(a),end(a),begin(c));
}


/*
	long long/mint 用
	最後roundしてキャストする
*/

template<class Mint>
vector<Mint> multiply_fft(const vector<Mint>& x,const vector<Mint>& y){
	if(x.empty() || y.empty()) return {};
	const int B = 15;
	const int K = 2;
	int S = x.size()+y.size()-1;
	int N = 1; while(N<S) N*=2;
	vector<Pc> a[K],b[K];
	rep(t,K){
		a[t] = vector<Pc>(N);
		b[t] = vector<Pc>(N);
		rep(i,x.size()) a[t][i] = Pc( (x[i] >> (t*B)) & ((1<<B)-1) , 0 );
		rep(i,y.size()) b[t][i] = Pc( (y[i] >> (t*B)) & ((1<<B)-1) , 0 );
		fft(false,a[t]);
		fft(false,b[t]);
	}
	vector<Mint> z(S);
	vector<Pc> c(N);
	Mint base = 1;
	rep(t,K+K-1){
		fill_n(begin(c),N,Pc(0,0));
		rep(xt,K){
			int yt = t-xt;
			if(0<=yt && yt<K){
				rep(i,N) c[i] += a[xt][i] * b[yt][i];
			}
		}
		fft(true,c);
		rep(i,S){
			c[i] *= 1.0/N;
			z[i] += Mint(ll(round(c[i].real()))) * base;
		}
		base *= 1<<B;
	}
	return z;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	ll N,M; cin >> N >> M;
	V<ll> f(100001);
	rep(i,N){
		int a; cin >> a;
		f[a]++;
	}
	auto g = multiply_fft(f,f);
	ll ans = 0;
	for(int i=g.size()-1;i>=0;i--){
		if(M < g[i]){
			ans += M*i;
			M = 0;
		}else{
			ans += g[i]*i;
			M -= g[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 35960
#include <stdio.h>

int main(void){
	
	int a,b,c,m;
	scanf("%d %d %d",&a,&b,&c);
	if (a>b){
		m=a;
		a=b;
		b=m;
	}
	if (b>c){
		m=b;
		b=c;
		c=m;
	}
	if (a>b){
		m=a;
		a=b;
		b=m;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int min(int a, int b){
    if (a < b) return a;
    else return b;
}

int main(void){
    int n;
    scanf("%d", &n);
    int h[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++){
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    printf("%d\n", dp[n - 1]);

    return 0;
}


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

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

int main() {
    int n; cin >> n;
    vector<int> H(n);
    rep(i,n) cin >> H[i];
    bool ans = true;
    for(int i = n-1; i > 0; i--){
        if(H[i] >= H[i-1]) continue;
        if(H[i]+1 == H[i-1]) H[i-1]--;
        if(H[i]+1 < H[i-1]) ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    using namespace std;
    unsigned long X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<unsigned long> A(X), B(Y), C(Z);
    for(auto &i : A)cin >> i;
    for(auto &i : B)cin >> i;
    for(auto &i : C)cin >> i;

    unsigned long L = min(X * Y, K);
    auto comp = greater<>();

    vector<unsigned long> AB, ABC;

    for_each(A.cbegin(), A.cend(), [&B, &AB, &K, &comp](auto i){for(const auto j : B)AB.push_back(i + j);if(AB.size() > K){nth_element(AB.begin(), AB.begin() + K, AB.end(), comp);AB.resize(K);}});
    for_each(AB.cbegin(), AB.cbegin() + L, [&C, &ABC, &K, &comp](auto i) {for(const auto j : C)ABC.push_back(i + j);if(ABC.size() > K){nth_element(ABC.begin(), ABC.begin() + K, ABC.end(), comp);ABC.resize(K);}});

    sort(ABC.rbegin(), ABC.rend());
    for_each(ABC.cbegin(), ABC.cend(), [](auto i){cout << i << endl;});
    return 0;
}

Measured memory_bytes: 384
from copy import copy
n, m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    ai,bi = map(int,input().split())
    ab[ai-1][bi-1] = 1
    ab[bi-1][ai-1] = 1

count = 0

def dfs(x,v):
    l = copy(v)
    l.append(x)
    if len(l)==n:
        global count
        count += 1
    for i in range(n):
        if ab[x][i] == 1 and not i in l:
            dfs(i,l)
    
dfs(0,[])
print(count)

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


int main(){
	int x,y,i;
	int a[]={1,3,5,7,8,10,12},b[]={4,6,9,11};

	cin >> x >> y;

	for(i=0;i<7;i++){
		if (x==a[i])x=100;
	}
	if (x!=100 && x!=2) x=101;


	for(i=0;i<7;i++){
		if (y==a[i])y=100;
	}
	if (y!=100 && y!=2) y=101;


	if(x==y){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/**
 *    AUTHOR:    crypter472                  
 *   CREATED:   12.09.2020 01:58:19  
**/

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int d, t, s;
  cin >> d >> t >> s;
  cout << ((d + s - 1) / s <= t ? "Yes" : "No") << '\n';
  return 0;
}

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

int main(){
  int N,Z,W;
  cin>>N>>Z>>W;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  if(N>=2)cout<<max(abs(v[N-2]-v[N-1]),abs(v[N-1]-W))<<endl;
  else cout<<abs(v[0]-W)<<endl;
}


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

int main() {
  string S;
  cin >> S;
  int maxxxx=0, count = 0;
  for (int i = 0; i < S.size(); i++) {
    if ((S[i] == 'A') || (S[i] == 'C') || (S[i] == 'G') || (S[i] == 'T')) {
      count++;
    }
    else {
      count = 0;
    }
    maxxxx = max(maxxxx, count);
  }
  cout << maxxxx << endl;
}


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

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

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];

    int left = 0;
    int right = 0;
    ll ans = 0;
    while(true)
    {
        bool flag = true;
        rep(i,N)
        {
            if( h[right] != 0 )
            {
                flag = false;
                right++;
            }
            else
            {
                for( int j = left ; j < right ;j++) h[j]--;
                if( left != right ) ans++;
                left = right+1;
                right = left;
            }
            //cout << h[i] << " ";
        }
        //cout << endl;
        if(flag)
        {
            cout << ans << endl;
            return 0;
        }
        else
        {
            for( int j = left ; j < right ;j++) h[j]--;
            if( left != right ) ans++;
            left = 0;
            right = left;
        }
    }
}


Measured memory_bytes: 256
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a[]={10,1,2,1,0,1,0,1,1,0,1,0,1};
	int x,y;
	cin>>x>>y;
	if(a[x]==a[y]) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


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

long long f(long long a)
{
    if (a == 0)
    {
        return 0;
    }
    bitset<60> b(a);
    return 1 + f(a % b.count());
}

int main()
{
    size_t N;
    string X;
    cin >> N >> X;

    size_t count = 0;
    for (char x : X)
    {
        if (x == '1')
        {
            count++;
        }
    }

    reverse(X.begin(), X.end());
    long long digit_minus = 1;
    long long minus = 0;
    vector<long long> m;

    long long digit_plus = 1;
    long long plus = 0;
    vector<long long> p;

    for (char x : X)
    {
        if (x == '1')
        {
            minus += digit_minus;
            plus += digit_plus;
        }

        m.push_back(digit_minus);
        p.push_back(digit_plus);

        if (count > 1)
        {
            minus %= count - 1;
        }
        digit_minus *= 2;
        if (count > 1)
        {
            digit_minus %= count - 1;
        }

        plus %= count + 1;
        digit_plus *= 2;
        digit_plus %= count + 1;
    }

    vector<long long> ans(N, 0);
    for (size_t i = 0; i < N; i++)
    {
        long long a;
        if (X[i] == '1')
        {
            a = minus;
            a -= m[i];
            a += count - 1;
            if (count > 1)
            {
                a %= count - 1;
            }
        }
        else
        {
            a = plus;
            a += p[i];
            a %= count + 1;
        }
        if (count == 1 && X[i] == '1')
        {
            ans[i] = 0;
        }
        else
        {
            ans[i] = 1 + f(a);
        }
    }
    reverse(ans.begin(), ans.end());
    for (long long a : ans)
    {
        cout << a << endl;
    }
}


Measured memory_bytes: 8156
#include <iostream>
#include <cstdio>
using namespace std;
int main (){

  double r,s,l;
  
  cin >>r;

  s=r*r*3.141592653589;
  l=2*r*3.141592653589;

  printf("%.6lf %.6lf\n",s,l);


  return 0;
}

Measured memory_bytes: 1240
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
// using namespace atcoder;
using ll = long long;
const int mod = 1e9 + 7;

void solve()
{
    int x;
    cin >> x;
    int ans = 0;
    rep(i, 360)
    {
        int y = 360 * (i + 1);
        if (y % x == 0)
        {
            ans = y / x;
            break;
        }
    }
    cout << ans << endl;
}

int main()
{
    // srand((unsigned)time(NULL));
    // int t = clock();
    solve();
    // double et = 1.0 * (clock() - t) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3636
K,A,B = map(int,input().split())

if B<=A+2:
	print(1+K)
	exit()
if K <= A:
	print(1+K)
	exit()

ans = B
nokori = K-A-1
rieki = B-A
ans += (nokori//2)*rieki+(nokori%2)
print(ans)




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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int a, b, c;
	cin >> a >> b >> c;
	cout << (3 - min((a == b) + (a == c) + (b == c), 2)) << endl;
	return 0;
}


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

#define st first
#define nd second
typedef pair<int, int> pii;

const int INF = 1e9;
const int N = 1e5 + 7;
pii elems[N];

int main()
{
	int n;
	scanf("%d", &n);

	int x, l;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d%d", &x, &l);
		elems[i] = {x + l, x - l};
	}

	sort(elems, elems + n);

	int cur = -INF, res = 0;
	for (int i = 0; i < n; ++i)
		if (cur <= elems[i].nd)
		{
			++res;
			cur = elems[i].st;
		}

	printf("%d", res);

	return 0;
}

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

int64_t a,b,H,W;
int64_t cnt[10];
map<pair<int64_t, int64_t>, int64_t> mp;
int N,i,j,k;
int64_t sm;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>H>>W>>N;
  for(i=0;i<N;i++){
    cin>>a>>b;
    a--;b--;
    for(j=-2;j<=0;j++){
      for(k=-2;k<=0;k++){
        if(a+j<0 || a+j+2>H-1 || b+k<0 || b+k+2>W-1)continue;
        mp[make_pair(a+j, b+k)]++;
      }
    }
  }
  sm = (H - 2) * (W - 2);
  for(auto itr=mp.begin(); itr!=mp.end();++itr){
    for(i=1;i<=9;i++){
      if((itr->second)==i)cnt[i]++;
    }
  }
  for(i=1;i<=9;i++){
    sm-=cnt[i];
  }
  cnt[0]=sm;
  for(i=0;i<=9;i++)cout<<cnt[i]<<endl;
  return 0;
}

Measured memory_bytes: 56576
import itertools
from collections import Counter

N = int(input())
V = [int(x) for x in input().split()]
EV_cnt = Counter(V[::2])
OD_cnt = Counter(V[1::2])

EV_cnt[-1] = 0
OD_cnt[-2] = 0

EV = EV_cnt.most_common(2)
OD = OD_cnt.most_common(2)

ans = N
for (k1,v1), (k2,v2) in itertools.product(EV,OD):
    if k1 == k2:
        continue
    x = (N - v1 - v2)
    if ans > x:
        ans = x

print(ans)

Measured memory_bytes: 18592
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)

Measured memory_bytes: 95436
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    int x,y,s;
    while(cin>>x>>y>>s,x){
        vi bef(2000,0);
        rep(i,1000){
            bef[floor(i*(100+x)/100)]=i;
        }
        int m=-1;
        for(int i=1;i<=s/2;i++){
            double a=i,b=s-i;
            if(bef[a]!=0 &&bef[b]!=0){
                m=max(m,(int)(floor(bef[a]*(100+y)/100)+floor(bef[b]*(100+y)/100)));
            }
        }
        cout<<m<<endl;
    }
}

Measured memory_bytes: 3128
#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    dp = [0] * N
    dp[0], dp[1] = 0, abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min(
            dp[i-1] + abs(h[i] - h[i-1]),
            dp[i-2] + abs(h[i] - h[i-2])
        )
    print(dp[-1])


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, h)

if __name__ == '__main__':
    main()


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin >> n;
    vi v(n);
    for(int &x : v)cin >> x;
    sort(RALL(v));
    int take = n - 2;
    ll ans = v[0];
    range(i,1,n-1){
        int mn = min(take , 2);
        ans += v[i] * mn;
        //cout << v[i] << "*" << mn << endl;
        take -= mn;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3940
using System;
using System.Text;

class KiwiJuiceEasy
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        var resultCount = 0;
        for(var i = 0; i<N; i++)
        {
            if(int.Parse(s[i]) != i + 1)
            {
                resultCount++;
            }
        }

        if(resultCount == 2 || resultCount == 0)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }

}


Measured memory_bytes: 11092
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let n: usize = input.next();
    let l: usize = input.next();
    let a: Vec<usize> = (0..n).map(|_| input.next()).collect();
    let x: Option<usize> = (0..n - 1).filter(|i| a[i + 0] + a[i + 1] >= l).last();
    if x.is_some() {
        println!("Possible");
        let v = x.unwrap() + 1;
        let mut i = 1;
        while i < v {
            println!("{}", i);
            i += 1;
        }
        i = n - 1;
        while i > v {
            println!("{}", i);
            i -= 1;
        }
        println!("{}", v);
    } else {
        println!("Impossible");
    }
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 12324
def resolve():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    grid=[list(map(int,input().split())) for i in range(M)]

    res = min(a) + min(b)

    for x, y, c in grid:
        res = min(res, a[x-1]+b[y-1]-c)

    print(res)
    
resolve()

Measured memory_bytes: 38556
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef pair<int,int> pi;
pi u;
deque<pi>q;
int k;
bool vis[100002];
int main(){
	scanf("%d",&k);
	q.push_front({1,1});
	while (1){
		u=q.front(),q.pop_front();
		if (vis[u.fi]) continue;
		vis[u.fi]=1;
		if (!u.fi) return printf("%d",u.se),0;
		q.push_front({u.fi*10%k,u.se});
		q.push_back({(u.fi+1)%k,u.se+1});
	}
}

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

main(){
    int size;
    string str;
    int target;
    char chr;
    cin >> size >> target >> str;
    //strのtarget番目を大文字にする1つだけ
    chr = str[target-1];

    if(chr == 'A'){
        str[target-1]  = 'a';
    }else if(chr == 'B'){
        str[target-1]  = 'b';
    }else if(chr == 'C'){
        str[target-1]  = 'c';
    }

    cout << str << endl;
    return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
 
#define fi first
#define se second
 
typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;
 
const int kN = 2e5 + 5;
 
char s[kN]; int a[kN];
 
int main() {
	int n, k, km; rd(n, k); km = k; k = std::min(k, 2 * n);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; ++i) a[i] = s[i] - 'A';
	int inv = 0, st = 1;
	for(int i = 1; i <= k; ++i, --km) {
		if(a[st] == inv) a[st] ^= 1;
		else {
			inv ^= 1;
			st = st % n + 1;
		}
	}
	if(n % 2 == 0) {
		for(int i = 1; i <= n; ++i)
			printf("%c", (a[(st + i - 2) % n + 1] ^ inv) + 'A');
	} else {
		printf("%c", (a[st] ^ inv ^ (km & 1)) + 'A');
		for(int i = 2; i <= n; ++i)
			printf("%c", (a[(st + i - 2) % n + 1] ^ inv) + 'A');
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
//cout<<fixed;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main() {
// #ifdef _DEBUG
// 	fast;
// 	freopen("input.txt", "r", stdin);
//     // g++ tmp.c
//     // ./a.out < input.txt > out.txt
// #endif
	
	fast;
	int t;
	cin >> t;
    int i=0;
    vector<int> v(t); 
	while (i<t) {
		cin>>v[i];
        i++;		
	}
    vector<long long> ans(t,INT_MAX);
    ans[0]=0;
    ans[1]=abs(v[0]-v[1]);
    
    for(int i=2;i<t;i++){ 
        ans[i]=min(abs(v[i-1]-v[i])+ans[i-1],abs(v[i-2]-v[i])+ans[i-2]);
    }
    // for(int i=0;i<t;i++){ 
    //     cout<<ans[i]<<" ";
    // }
    cout<<endl<<ans[t-1]<<endl;	
	return 0;
}

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

int main(){
    ll n,ans=10000000,total;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n) cin >> vec[i];
    for(ll i=0;i<=100;i++){
        total=0;
        for(ll j=0;j<n;j++){
            total+=(vec[j]-i)*(vec[j]-i);
        }
        ans=min(ans,total);
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int N, M;
  cin >> N >> M;
  
  int A[N];
  int sum=0;
  int ans=0;
  rep(i, N){
  cin >> A[i];
      sum+=A[i];
      }
  rep(i, N){
    if(A[i]>=sum/(4*M)&&sum%(4*M)==0)
       ans++;
    if(A[i]>=1+sum/(4*M)&&sum%(4*M)!=0)
       ans++;
      }
  if(ans>=M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int[] cnt = new int[9];
            cnt[a - 1]++;
            cnt[b - 1]++;
            cnt[c - 1]++;
            boolean ok = false;
            for (int i = 0; i < 9; i++)
                if (cnt[i] == 2) {
                    ok = true;
                    break;
                }
            if (!ok)
                out.println("No");
            else {
                for (int i = 0; i < 9; i++)
                    if (cnt[i] == 1) {
                        out.println("Yes");
                        return;
                    }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21328
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
vector< ll > jb[114514];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		jb[x].pb(y);
	}
	priority_queue<ll> pue;
	ll ans = 0;
	for(int i=1;i<=m;i++){
		for(int j=0;j<jb[i].size();j++){
			pue.push(jb[i][j]);
		}
		if(!pue.empty()){
			ll t = pue.top(); pue.pop();
			ans += t;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m, k, val;
    cin >> n >> m;
    unordered_map<int, int> cnt;
    for(int i = 0; i < n; i++) {
        cin >> k;
        for(int j = 0; j < k; j++) {
            cin >> val;
            cnt[val] += 1;
        }
    }
    int ans = 0;
    for(auto& p: cnt)
        if (p.second == n)
            ans += 1;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#define INF -1
using namespace std;
typedef pair<int, int>P;

char joi[1000][1001];
int h, w;
int sy, sx, gy, gx;
int d[1000][1000];

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

int solve(){
	queue<P>que;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			d[i][j] = INF;
	que.push(P(sy, sx));
	d[sy][sx] = 0;

	while (!que.empty()){
		P p = que.front(); que.pop();
		if (p.first == gy&&p.second == gx)break;
		for (int i = 0; i < 4; i++){
			int ny = p.first + dy[i]; int nx = p.second + dx[i];
			if (0 <= ny&&ny < h && 0 <= nx&&nx < w&&d[ny][nx] == INF&&joi[ny][nx] != 'X'){
				d[ny][nx] = d[p.first][p.second] + 1;
				que.push(P(ny, nx));
			}
		}
	}
	return d[gy][gx];
}
int main(){
	int n, cnt = 0;
	P q[9];
	scanf("%d%d%d", &h, &w, &n);
	for (int i = 0; i < h; i++){
		scanf("%s", joi[i]);
		for (int j = 0; j < w; j++){
			if ('0' < joi[i][j] && joi[i][j] <= '9')q[joi[i][j] - '1'] = P(i, j);
			if (joi[i][j] == 'S'){ sy = i; sx = j;}
		}
	}
	for (int i = 0; i < n; i++){
		gy = q[i].first; gx = q[i].second;
		cnt += solve();
		sy = gy; sx = gx;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 7600
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken());
            String op=st.nextToken();
            int b = Integer.parseInt(st.nextToken());
            if(op.equals("+")){ System.out.println(a+b); }
            else if(op.equals("-")){ System.out.println(a-b); }
            else if(op.equals("*")){ System.out.println(a*b); }
            else if(op.equals("/")){ System.out.println(a/b); }
            else break;
        }
    }
}

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

int main() 
{
int n,x=0,flag=0;
cin>>n;
int a[n][2];
for(int i=0;i<n;i++)
{
    cin>>a[i][0]>>a[i][1];
}
for(int i=0;i<n;i++)
{
    if(a[i][0]==a[i][1])
    {
       x++;
       if(x==3)
       {
           flag=1;
           break;
       }
    }
    else
    x=0;
}
  
  if(flag)
  cout<<"Yes"<<"\n";
  else
  cout<<"No\n";
   
   
   return 0;
}

Measured memory_bytes: 3628
# include <stdio.h>

int max(int a,int b){
  int M = a*b;
  if(M<a+b) M=a+b;
  if(M<a-b) M=a-b;
  return M;
}

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",max(a,b));
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		if(a+b==c||a+c==b||b+c==a){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using int64 = long long;

int64 f(int64 n)
{
    if (n < 2)
        return 1LL;

    return n * f(n - 2);
}

void test()
{
    for (int64 i = 1LL; i <= 30LL; i++) {
        std::cout << i << " " << f(i) << std::endl;
    }
}

int digit(int64 n)
{
    int dig = 0;
    while (true) {
        if (n % 10 != 0) {
            break;
        }
        n /= 10;
        dig++;
    }
    return dig;
}

int main()
{
    // test();

    int64 N;
    std::cin >> N;

    if (N % 2 == 1) {
        std::cout << 0 << std::endl;
    }
    else {
        int64 res = 0, x = 5;
        while (N >= x) {
            res += N / x / 2;
            x *= 5;
        }
        std::cout << res << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{   
	int N,A;
	A=0;
	cin>>N;
	for(int t=1;t<=N;t++)
	{
		if(t<10)
		A++;
		else if(t>99 && t<1000)
		A++;
		else if(t>9999 && t<100000)
		A++;
		else
		A+=0;
	}
	cout<<A;
	return 0;  	
}	

Measured memory_bytes: 256