akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
if(s.at(0)=='9'||s.at(1)=='9'){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}

}









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

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

	int ans = 0;
	rep(i,S.size()) ans += int(S[i]-'0');
	rep(i,S.size()) {
		int tmp = int(S[i]-'0') - 1 + 9*(S.size()-i-1);
		rep(j,i) tmp += int(S[j]-'0');
		ans = max(ans,tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define endl ("\n")
using namespace std;

#define deb(x) cout << (#x) << " -> " << (x) << endl;
#define mod (1000000007)

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    long long sol = 2019;
    long long l, r;
    cin >> l >> r;
    if(r - l < 2024)
    {
        for(long long i = l;i <= r;i++)
        {
            for(long long j = i + 1;j <= r;j++)
            {
                sol = min(sol, (i*j)%2019);
            }
        }
        cout << sol;
    }
    else
    {
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;

#define i64 long long int
// #define i128 __int128_t

int L, n;
int nans, ans[111][3];

void pb(int a, int b, int c) {
	ans[nans][0] = a;
	ans[nans][1] = b;
	ans[nans][2] = c;
	nans++;
}

int main() {
	scanf("%d", &L);
	
	n=1;
	int cap = 2;
	while(cap<=L) {
		n++;
		cap*=2;
	}
	
	nans=0;
	int dig=1;
	for(int i=n;i>1;i--) {
		pb(i-1, i, 0);
		pb(i-1, i, dig);
		dig*=2;
	}
	
	cap/=2;
	L-=cap;
	
	int v = cap;
	for(int i=2;i<=n;i++) {
		cap /= 2;
		if (L>=cap) {
			pb(1, i, v);
			L-=cap;
			v+=cap;
		}
	}
	
	printf("%d %d\n", n, nans);
	for(int i=0;i<nans;i++)
		printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2]);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int a,b; cin >> a >> b;
    rep(i,10000) {
        if (i==0) continue;
        if (floor(i*0.08)==a && floor(i*0.1)==b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class Program {
    static void Main(string[] args) {
        BigInteger H = BigInteger.Parse(Console.ReadLine());
        if(H == 1) {
            Console.WriteLine(1);
        } else {
            int n = (int)BigInteger.Log(H, 2) + 1;
            Console.WriteLine(BigInteger.Pow(new BigInteger(2), n) - 1);
        }
    }
}

Measured memory_bytes: 13780
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    ll x;
    cin >> x;
    ll ret=(x/11LL)*2;
    ll res=x%11LL;
    if(res == 10) ret+=2;
    else if(res == 9) ret+=2;
    else if(res == 8) ret+=2;
    else if(res == 7) ret+=2;
    else if(res == 6) ret+=1;
    else if(res == 5) ret+=1;
    else if(res == 4) ret+=1;
    else if(res == 3) ret+=1;
    else if(res == 2) ret+=1;
    else if(res == 1) ret+=1;
    else if(res == 0) ret+=0;

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int W = sc.nextInt();
    int H = sc.nextInt();
    int N = sc.nextInt();
    
    int x = 0, y = 0, a = 0;
    int x1 = 0, y1 = 0;
    int x2 = W, y2 = H;
    
    for(int i = 0; i < N ; i++){
      x = sc.nextInt();
      y = sc.nextInt();
      a = sc.nextInt();
      
      if(a==1){
        x1 = Math.max(x1,x);
      }else if(a==2){
        x2 =Math.min(x2,x);
      }else if(a==3){
        y1 = Math.max(y1,y);
      }else if(a==4){
        y2 = Math.min(y2,y);
      }
    }
    System.out.println(Math.max((x2-x1),0)*Math.max((y2-y1),0));
  }
}

Measured memory_bytes: 21972
#include<iostream>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
 
using namespace std;
 
int main(){
    ll n,a,sum=0,mini=99999;
    cin>>n;
    lol(i,n){
    cin>>a;
    sum+=a;
    mini=min(mini,sum/(i+1));
    }
    cout<<mini<<endl;
    return 0;
}


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

int main() {
	double n,n1;
	cin>>n;
	n1=n+0.5;
	n+=0.45;
	int x=(int)((n*100/108)+0.5);
	int y=(int)((n1*100/108)+0.5);
	// cout<<x<<y<<endl;
	// cout<<(int)(x*1.08);
	// if((int)(x*1.08)!=n)a
	// 	cout<<":("<<endl;
	// else
	if(x==y)
		cout<<x<<endl;
	else
		cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline=sys.stdin.readline

A,B,C,K=map(int,readline().split())

# B+x,B,C
# B+C,B+C+x,2B+x
# 3B+C+2x,3B+c+x,2B+2C+x

# 奇数回実行すると答えは-x、偶数回だとx

print((A-B)*(-1)**(K&1))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,i,j,k,n,m,t;
string s[1005];
string s1,s2;
ll gcd(ll a,ll b){
	ll x=a>b?a:b;
	b=a<b?a:b;
	a=x;
	x=0;
	while(c=a%b){
		a=b;
		b=c;
	}
	return b;
}
int main(){
	scanf("%lld%lld",&n,&m);
	printf("%lld",n*m/gcd(n,m));
	return 0;
}


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

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

        string t[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
        string ans = "";

        int cnt = 0;
        int now = 0;
        rep(i, s.size()) {
            if (s[i] == '0') {
                if (cnt != 0) {
                    cout << t[now][(cnt - 1) % t[now].size()];
                    cnt = 0;
                }
            } else {
                cnt++;
                now = s[i] - '0';
            }
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <numeric>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N; 
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++) cin >> W[i];

    vector<int> c_sum(N, 0); c_sum[0] = W[0];
    for(int i = 1; i < N; i++) c_sum[i] = c_sum[i - 1] + W[i];

    int ans = inf;
    for(int i = 0; i < N - 1; i++) ans = min(ans, abs(c_sum[i] - (c_sum.back() - c_sum[i])));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s1,s2,s3,a,b,c;
    cin>>s1>>s2>>s3;
     a=s1[0]-32;
     b=s2[0]-32;
     c=s3[0]-32;
     cout<<a<<b<<c<<endl;
    return 0;
}


Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define MOD 1000000007
#define fi first
#define se second
#define ld double

using namespace std;

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

string s;
int rs;

int main(){
    // ifstream cin("date.in");
    // ofstream cout("date.out");

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> s;

    int n = s.size();
    rs = n;
    s = '+' + s;
    for (int i = 2; i <= n; i++) {
        if (s[i] == s[i - 1]) continue;
        rs = min(rs, max(i - 1, n - i + 1));
    }

    cout << rs;
	return 0;
} 

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
int main(){
  int n,a,b;cin>>n>>a>>b;
  int p[n];
  int m[3];
  fill(m,m+3,0);
  for(int i=0;i<n;i++){
    cin>>p[i];
    if(p[i]<=a)m[0]++;
    else if(p[i]<=b)m[1]++;
    else m[2]++;
  }
  sort(m,m+3);
  cout<<m[0]<<endl;
}
  

Measured memory_bytes: 256
#!/usr/bin/env python3


def solv(n, d):
    d = sorted(d)
    min_ = d[n // 2 - 1] + 1
    max_ = d[n // 2]
    if min_ > max_:
        return 0
    else:
        return max_ - min_ + 1



if __name__ == '__main__':

    n = int(input())
    d = [int(x) for x in input().split()]

    ans = solv(n, d)

    print(ans)


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

using namespace std;

void A_AC_or_WA(void) {

	int N, M;
	cin >> N >> M;
	cout << ((N == M) ? "Yes" : "No") << flush;
}

int main(void) {

	A_AC_or_WA();
	return 0;
}


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

using namespace std;

int main(){
  int n, q, x;
  vector<int> v;
  cin >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> x;
    v.push_back(x);
  }
  int sum = 0;
  cin >> q;
  for ( int i = 0; i < q; i++ ){
    cin >> x;
    if ( find(v.begin(), v.end(), x) != v.end() ) sum++;
  }

  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3272
N = int(input())
A = list(map(int, input().split()))

# ずらす
for i in range(N):
    A[i] = A[i] - (i+1)

A = sorted(A)
m = float('inf')
bs = []

# 探索対象
if N//2-1<N:
    bs.append(A[N//2-1])
if N//2<N:
    bs.append(A[N//2])
if N//2+1<N:
    bs.append(A[N//2+1])

for b in bs:
    diff = sum(list(map(lambda x: abs(x-b),A)))
    m = min(m,diff)

print(m)

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

using namespace std;
const int N = 1e6+100;
const long long INF = 999999999999;
long long dis[N][3];
vector<int> G[N];
bool vis[N][3];
struct node{
    int id;
    int  dis;
};
int n,m,S,T;
queue<node> q;
void dijkstra(int S){
    for(int i=1;i<=n+100;i++){
        for(int j=0;j<3;j++) dis[i][j]=INF,vis[i][j]=0;
    }
    dis[S][0]=0;
    q.push({S,0});
    while(!q.empty()){
        node rt=q.front();q.pop();
        int u=rt.id;
        int L=rt.dis;
        if(vis[u][L%3]) continue;
        vis[u][L%3]=1;
        for(auto v:G[u]){
            int nowL=(L+1)%3;
            if(dis[v][nowL]>dis[u][L]+1){
                dis[v][nowL]=dis[u][L]+1;
                q.push({v,nowL});
            }
        }
    }
}
int main(){
    cin>>n>>m;
    int u,v;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        G[u].push_back(v);
    }
    cin>>S>>T;
    dijkstra(S);
    //cout<<dis[T][0]<<endl;
    if(dis[T][0]==INF) puts("-1");
    else cout<<dis[T][0]/3<<endl;
    return 0;
}

Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 0.00001

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,l;cin>>n>>l;
    vector<string> v;
    rep(i,0,n-1)
    {
        string s;cin>>s;
        v.pb(s);
    }
    sort(all(v));
    for(auto i:v)
    {
        cout<<i;
    }
    return 0;
    //check for long long or int
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const ll mod=1e9+7;
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    int n,x;
    cin>>n>>x;
    int l[n];
    ll cnt=1,s=0;
    for(int i=0;i<n;i++)
    {
        cin>>l[i];
        s+=l[i];
        if(s<=x)
            cnt++;

    }
    cout<<cnt<<endl;






}
















































Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(auto i=0; i<(n); i++)

const int mod = 1000000007;

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if((x -= mod-a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
      mint a(*this);
      mint res = 1;
      while (n > 0) {
          if (n & 1) res *= a;
          a *= a;
          n >>= 1;
      }
      return res;
    }

    mint inv() const {
      return pow(mod - 2);
    }
};

const int MAX_V = 2005;

mint fac[MAX_V];
mint inv[MAX_V]; 

void initFact() {
  fac[0] = 1;
  inv[0] = 1;
	for (int i = 1; i < MAX_V; i++) {
		fac[i] = (fac[i - 1] * i);
		inv[i] = fac[i].inv();
	}
}

mint combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
	return fac[n] * inv[k] * inv[n - k];
}

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

  int n, k;
  cin >> n >> k;

  int red = n-k;
  initFact();

  for(int i = 1; i < k+1; i++) {
    cout << (combi(red+1, i) * combi(k-1, i-1)).x << endl;
  }
}


Measured memory_bytes: 256
//Xcode main は一つまで
//競プロのデバッグにでも使おう
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
long long N,X;
long long a[51];

long long L(long long n,long long x){
    if(n==0) return 1;
    if(x==0) return 0;
    if(x>1 && x<(a[n]+1)/2) return L(n-1,x-1);
    if(x==(a[n]+1)/2) return L(n-1,a[n-1])+1;
    if(x>(a[n]+1)/2 &&  x<a[n])return 1+L(n-1,a[n-1])+L(n-1,x-(a[n]+1)/2);
    if(x==a[n]) return 2*L(n-1,a[n-1])+1;
    else return 0;
}


int main() {
    cin>>N>>X;
    a[0]=1;
    for(int yy=1;yy<=50;yy++){
        a[yy]=2*a[yy-1]+3;
    }
    
    cout<<L(N,X)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;

int dual(int x)
{
    return x*x;
}

int main()
{
    int n;
    float x[8];
    float y[8];
    float sum = 0;
    
    cin >> n;
    
    for (int i = 0;i < n;i++){
        cin >> x[i] >> y[i];
    }
    for (int i = 0;i < n-1;i++){
        for (int j = i+1;j <= n-1;j++){
        sum += (float)sqrt(dual(x[j]-x[i])+dual(y[j]-y[i]));
        }
    }
    
    printf("%0.8lf\n",(float)(2*sum)/n);
}


Measured memory_bytes: 256
x,n=map(int,input().split())
p=list(map(int,input().split()))

a=[0]*102
for i in range(n):
    a[p[i]]+=1
l=x
s=x
while True:
    if a[s]==0:
        ans=s
        break
    s-=1
    if a[l]==0:
        ans=l
        break
    l+=1
    
print(ans)

Measured memory_bytes: 9188
n =int(input())
h =list(map(int ,input().split()))

if n ==1:
    print("Yes")
else:
    for i in range(n-1):
        if h[i] > h[i+1]:
            print("No")
            exit()
        elif h[i] ==h[i+1]:
            pass
        else:
            h[i+1] -=1
    print("Yes")

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

using i32 = int32_t;
using i64 = int64_t;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    i32 x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

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


#----------
N,C,K = list(map(int, input().rstrip().split()))

T_list = [int(input().strip()) for _ in range(N)]
T_list.sort()

#----------
num_bus=0
i=0
while i < len(T_list):

    # Busに何人乗せられるか時刻を比較
    member_bus=0
    break_flg=False
    for j in range(C):
        if (i+j) < len(T_list):
            if T_list[i+j] <= (T_list[i] + K):
                member_bus += 1
            else:
                break_flg=True
        else:
            break_flg=True
        
        if break_flg:
            break

    num_bus += 1
    i = i + member_bus
            

print(num_bus)


Measured memory_bytes: 7384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <numeric>

using namespace std;
typedef long long ll;

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

int abs(int x){ return x < 0 ? -x : x; }
bool between(int a, int b, int c){ return (a <= b) && (b < c); }

struct Matrix {
	int a[91][91];
	Matrix(){ memset(a, 0, sizeof(a)); }
};

Matrix multiply(const Matrix &a, const Matrix &b, int M){
	Matrix c;
	for(int i = 0; i < 91; ++i){
		for(int j = 0; j < 91; ++j){
			int sum = 0;
			for(int k = 0; k < 91; ++k){
				sum = (sum + (ll)a.a[i][k] * b.a[k][j]) % M;
			}
			c.a[i][j] = sum;
		}
	}
	return c;
}

Matrix modpow(const Matrix &m, int e, int M){
	if(e == 1){ return m; }
	Matrix a = modpow(m, e / 2, M);
	a = multiply(a, a, M);
	if(e % 2 == 1){ a = multiply(a, m, M); }
	return a;
}

int main(){
	int caseNum = 1;
	while(true){
		int N, M, L;
		cin >> N >> M >> L;
		if(N == 0 && M == 0 && L == 0){ break; }
		int indices[11][11];
		memset(indices, -1, sizeof(indices));
		vector<int> input(91);
		for(int i = 0, k = 0; i < 2 * N - 1; ++i){
			int offset = max(i - N + 1, 0); 
			int len = (i < N) ? (i + N) : (2 * N - 2 - (i - N));
			for(int j = 0; j < len; ++j){
				cin >> input[k];
				indices[i][j + offset] = k++;
			}
		}
		Matrix neighbor;
		for(int i = 0; i < 11; ++i){
			for(int j = 0; j < 11; ++j){
				if(indices[i][j] < 0){ continue; }
				for(int k = 0; k < 7; ++k){
					int y = i + dy[k], x = j + dx[k];
					if(!between(0, y, 11) || !between(0, x, 11)){ continue; }
					if(indices[y][x] < 0){ continue; }
					neighbor.a[indices[i][j]][indices[y][x]]++;
				}
			}
		}
		neighbor = modpow(neighbor, L, M);
		vector<ll> part(91);
		for(int i = 0; i < 91; ++i){
			for(int j = 0; j < 91; ++j){
				part[j] = (part[j] + (ll)input[i] * neighbor.a[i][j]) % M;
			}
		}
		ll answer = accumulate(part.begin(), part.end(), 0ll);
		cout << "Case " << caseNum++ << ": " << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 2864
n = gets.to_i

f = 1
i = 10
sum = 0

if n < 10 then
  sum = n
else
  while f == 1 do
    if n >= i then
      sum += i - i/10
      i *= 100
    else
      if n.to_s.length.odd? then
        tmp = n.to_s
        x = tmp.slice!(0)
        if x != 1 then
          sum += i/10*(x.to_i-1)
        end
        sum += tmp.to_i+1
      end
      f = 0
    end
  end
end

print sum

Measured memory_bytes: 3836
#include <stdio.h>

int main() {
	
	int x,a,b;
	int adiff = 0,bdiff = 0;
	scanf("%d %d %d", &x,&a,&b);
	if( x <= a && x <= b){
		adiff = a-x;
		bdiff = b-x;
	}else if (x >= a && x <= b){
		adiff = x-a;
		bdiff = b-x;
	}else if(x>=a && x>=b){
		adiff = x-a;
		bdiff = x-b;
	}else if(x <=a && x >= b){
		adiff= a-x;
		bdiff = x-b;
	}
	if(adiff > bdiff){
		printf("B");
	}else{printf("A");
	}
	return 0;
	}


Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,vector<ll>>P;

bool have_been[1005][1005][1005] = {};

int main(void){
    int x,y,z,cnt; cin >> x >> y >> z >> cnt;
    vector<ll>a(x),b(y),c(z);
    for(int i=0;i<x;i++) cin >> a[i];
    for(int i=0;i<y;i++) cin >> b[i];
    for(int i=0;i<z;i++) cin >> c[i];
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());
  
    priority_queue<P>q;
    
    // for(int i=0;i<x;i++)for(int j=0;j<y;j++)for(int k=0;k<z;k++)have_been[i][j][k]=false;
    q.push(P{a[0]+b[0]+c[0],{0,0,0}});
    for(int _=0;_<cnt;_++){
        P tmp = q.top();q.pop();
        ll ans = tmp.first;
        cout << ans << endl;
        ll i=tmp.second[0],j=tmp.second[1],k = tmp.second[2];
        if(i+1<x && have_been[i+1][j][k]==false) q.push(P{a[i+1]+b[j]+c[k],{i+1,j,k}}), have_been[i+1][j][k]=true;
        if(j+1<y && have_been[i][j+1][k]==false) q.push(P{a[i]+b[j+1]+c[k],{i,j+1,k}}),have_been[i][j+1][k]=true;
        if(k+1<z && have_been[i][j][k+1]==false) q.push(P{a[i]+b[j]+c[k+1],{i,j,k+1}}), have_been[i][j][k+1]=true;
    }
    return 0;
}

Measured memory_bytes: 985600
import Glibc
extension String: CollectionType {}

//var abc = readLine()!.split(" ").map { Int($0)! }
var xy = readLine()!.split(" ")
if xy[0] > xy[1] {
  print(">")
} else if xy[0] < xy[1] {
  print("<")
} else {
  print("=")
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  map<string, int> amap;
  string tmp;
  vector<string> arr;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(amap[tmp]==0) arr.push_back(tmp);
    amap[tmp]++;
  }
  int num = 0;
  for(int i=0;i<arr.size();++i) {
    num = max(num, amap[arr[i]]);
  }
  vector<string> ans;
  for(int i=0;i<arr.size();++i) {
    if(amap[arr[i]]==num) ans.push_back(arr[i]);
  }
  sort(ans.begin(), ans.end());
  for(int i=0;i<ans.size();++i) cout<<ans[i]<<endl;
}



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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

const ll INF = 1ll<<60;

int n;
int a[5252];
vi g[5252];
ll dp[5252][5252], dp2[5252][5252];
ll tmp[2][5252];
ll sz[5252];

void dfs(int p, int bef){
  sz[p] = 1;
  dp[p][0] = a[p]<0 ? INF : a[p];
  dp2[p][0]= a[p]<0 ? a[p] : INF;
  for(int to : g[p])if(to != bef){
    dfs(to,p);
    fill(tmp[0], tmp[0]+sz[p]+sz[to], INF);
    fill(tmp[1], tmp[1]+sz[p]+sz[to], INF);
    REP(i,sz[p])REP(j,sz[to]){
      if(dp[to][j]<INF/2){
        CHMIN(tmp[0][i+j], dp[p][i]+dp[to][j]);
        CHMIN(tmp[0][i+j+1], dp[p][i]);

        CHMIN(tmp[1][i+j], dp2[p][i]+dp[to][j]);
        CHMIN(tmp[1][i+j+1], dp2[p][i]);
      }

      CHMIN(tmp[1][i+j], dp[p][i]+dp2[to][j]);
      if(dp2[to][j]<0)CHMIN(tmp[0][i+j+1], dp[p][i]);

      CHMIN(tmp[1][i+j], dp2[p][i]+dp2[to][j]);
      if(dp2[to][j]<0)CHMIN(tmp[1][i+j+1], dp2[p][i]);
    }
    sz[p] = sz[p]+sz[to];
    REP(i,sz[p])dp[p][i] = tmp[0][i];
    REP(i,sz[p])dp2[p][i] = tmp[1][i];
  }
  // DEBUG(p);
  // REP(i,sz[p])printf("%lld ",dp[p][i]==INF ? 252521ll : dp[p][i]);puts("");
  // REP(i,sz[p])printf("%lld ",dp2[p][i]==INF ? 252521ll : dp2[p][i]);puts("");
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n-1){
    int u,v;
    scanf("%d%d",&u,&v);
    --u;--v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0,-1);
  int ans = n;
  REP(i,n)if(dp[0][i]<INF/2)CHMIN(ans,i);
  REP(i,n)if(dp2[0][i]<0)CHMIN(ans,i);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 413952
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}
int main() {
  string N;
  int k;
  cin >> N >> k;
  int l=N.size();
  vector<int> v(l);
  rep(i,l)
    v[i]=(N[i]-'0');
  int dp[101][2][5]={};
  // Fill(dp,0);
  dp[0][0][0]=1;
  rep(i,l)
    rep(s,2){
      int y=(s?9:v[i])+1;
      rep(j,k+1)
        rep(x,y){
          dp[i+1][s||x<v[i]][j+(x>0)]+=dp[i][s][j]; 
        }
    }
  cout<<dp[l][0][k]+dp[l][1][k];
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int l1, l2, l3;

    cin >> l1 >> l2 >> l3;

    if(l1>l2){
        if(l1>l3){
            l1=1;
        } else{
            l3=1;
        }
    } else{
        if(l2>l3){
            l2=1;
        } else{
            l3=1;
        }
    }

    cout << (l1*l2*l3)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
mod=10**9+7
if (x+y)%3:
    print(0)
    exit()
x,y=min(x,y),max(x,y)
sa=y-x
if sa>x:
    print(0)
    exit()
p=(x+y)//3

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

print(cmb(p,(p-sa)//2)%mod)


Measured memory_bytes: 102028
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n-1) cin >> a[i];
    int res = a[1] + a[n-1];
    FOR(i,1,n-2) res += min(a[i], a[i+1]);
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    vector<int>b(n);
    b = a;
    int cnt = 0;
    for(int i=1;i<n;i++){
        if(i%2==1){
            if(b[i-1]<b[i]){
                continue;
            }else{
                cnt++;
                if(i!=n-1){
                   if(b[i-1]<b[i+1]&&b[i+1]>b[i]){
                       swap(b[i],b[i+1]);
                   }else{
                       swap(b[i],b[i-1]);
                   }
                }else{
                    swap(b[i],b[i-1]);
                }
            }
        }else{
            if(b[i-1]<b[i]){
                cnt++;
                if(i!=n-1){
                   if(b[i-1]>b[i+1]&&b[i+1]<b[i]){
                       swap(b[i],b[i+1]);
                   }else{
                       swap(b[i],b[i-1]);
                   }
                }else{
                    swap(b[i],b[i-1]);
                }
            }else{
                continue;
            }
        }
    }
    // for(auto x:b){
    //     cout << x << " ";
    // }
    // cout << endl;
    b = a;
    int cnt2 =  0;
    for(int i=1;i<n;i++){
        if(i%2==0){
            if(b[i-1]<b[i]){
                continue;
            }else{
                cnt2++;
                if(i!=n-1){
                   if(b[i-1]<b[i+1]&&b[i+1]>b[i]){
                       swap(b[i],b[i+1]);
                   }else{
                       swap(b[i],b[i-1]);
                   }
                }else{
                    swap(b[i],b[i-1]);
                }
            }
        }else{
            if(b[i-1]<b[i]){
                cnt2++;
                if(i!=n-1){
                   if(b[i-1]>b[i+1]&&b[i+1]<b[i]){
                       swap(b[i],b[i+1]);
                   }else{
                       swap(b[i],b[i-1]);
                   }
                }else{
                    swap(b[i],b[i-1]);
                }
            }else{
                continue;
            }
        }
    }
    // for(auto x:b){
    //     cout << x << " ";
    // }
    // cout << endl;
    cout << min(cnt,cnt2) << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int n,x,i,a[100],sum=0;
    scanf("%d%d",&n,&x);
    int cnt=n;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    qsort(a,n,sizeof(int),asc);
    printf("%d",cnt+(x-sum)/a[0]);
}


Measured memory_bytes: 128
#include<cstdio>
#include<vector>
using namespace std;
const int maxn = 2e5+5;
typedef long long ll;
#define sz(x) (int)(x).size()

vector<int> v[maxn];
vector<int> g, sciez;
bool odw[maxn];
int n;
int zacz, ostc, ostb;
int ilec, ileb;
int sz[maxn];

void dfs(int x) {
	odw[x] = true;
	g.push_back(x);
	if(x == n)
		sciez = g;
	
	for(int i = 0; i < sz(v[x]); ++i)
	{
		if(!odw[v[x][i]]) {
			dfs(v[x][i]);
		}
	}
	g.pop_back();
}

void dfs_sz(int x) 
{
	odw[x] = true;
	sz[x] = 1;
	
	for(int i = 0; i < sz(v[x]); ++i)
	{
		if(!odw[v[x][i]]) {
			dfs_sz(v[x][i]);
			sz[x] += sz[v[x][i]];
		}
	}
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i < n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(1);
	for(int i = 1; i <= n; ++i) odw[i] = false;
	/*puts("");
	for(int i = 0; i < sz(sciez); ++i)
		printf("%d ", sciez[i]);*/
	int pol = sz(sciez) / 2 - 1;
	if(sz(sciez) % 2) {
		ostc = sciez[pol+1];
		ilec = pol+2;
		ostb = sciez[pol+2];
		zacz = 'b';
	}
	else {
		ostc = sciez[pol];
		ilec = pol+1;
		ostb = sciez[pol+1];
		zacz = 'c';
	}
	ileb = sz(sciez) - ilec;
	
	//printf("ostc: %d\nostb: %d\nzacz: %c\n", ostc, ostb, (char)zacz);
	//printf("ilec: %d\nileb: %d\n", ilec, ileb);
	dfs_sz(ostc);
	int pozb = sz[ostb] - ileb;
	int pozc = sz[ostc] - ilec - sz[ostb];
	//printf("%d %d\n", pozc, pozb);
	int ktowygr = 0;
	while(!ktowygr) {
		if(zacz == 'c') {
			if(pozc)
				pozc--;
			else {
				ktowygr = 2;
				break;
			}
			zacz = 'b';	
		}
		else {
			if(pozb)
				pozb--;
			else {
				ktowygr = 1;
				break;
			}
			zacz = 'c';	
		}
	}
	if(ktowygr == 1)
		puts("Fennec");
	else
		puts("Snuke");
	
}


Measured memory_bytes: 15736
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}
ll f(double n) {

	n *= n;
	n += 4.0;
	return n / 8.0;
}
ll calc(ll a, ll b, ll c) {
	int half = a / 2;
	if (a % 2 == 0) {
		return 0;
	}
	else {
		return b * c;
	}

}
void Solve() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << min(calc(a, b, c), min(calc(b, a, c), calc(c, a, b))) << endl;

}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
# abc156_c.py
# https://atcoder.jp/contests/abc156/tasks/abc156_c

# C - Rally /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# 数直線上に N人の人が住んでいます。
# i番目の人が住んでいるのは座標 Xiです。
# あなたは N人全員が参加する集会を開くことを考えています。
# 集会は数直線上の任意の 整数値の座標 で開くことができ、座標 Pで集会を開くとき、
# i 番目の人は集会に参加するために (Xi−P)2の体力を消費します。
# N人が消費する体力の総和としてありえる値の最小値を求めてください。

# 制約
#     入力は全て整数である。
#     1≤N≤100
#     1≤Xi≤100

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# X1 X2 ... XN

# 出力
# N人が消費する体力の総和としてありえる値の最小値を出力せよ。

# 入力例 1
# 2
# 1 4

# 出力例 1
# 5

# 座標 2で集会を開くとき、1 番目の人が消費する体力は (1−2)2=1、 2 番目の人が消費する体力は (4−2)2=4、よってその総和は 5 です。 
# これが 2人が消費する体力の総和としてありえる値の最小値です。
# 集会を開くことができるのは整数値の座標だけであることに注意してください。

# 入力例 2
# 7
# 14 14 2 13 56 2 37

# 出力例 2
# 2354


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = None
    for p in range(101):
        su = 0
        for n in range(N):
            su += (values[n] - p)**2
        if result is None:
            result = su
        elif result > su:
            result = su

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', '1 4']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['7', '14 14 2 13 56 2 37']
        lines_export = [2354]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int main() {
    int num;
    int cnt = 0;

    cin >> num;

    vector<int> vec(num);
    for (int i = 0; i < num; i++) cin >> vec.at(i);

    sort(vec.begin(), vec.end(), greater<int>());

    for (int i = 0; i < num; i++){
        if(i == 0){
            cnt++;
            continue;
        }

        if(vec.at(i) != vec.at(i-1)) cnt++;
    }

    cout << cnt;
}

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

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;

#define INF 1000000000
#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define foreach(v,c) for(typeof((c).begin()) v=(c).begin();v!=(c).end();++v)
#define all(a) a.begin(),a.end()
#define in(a,b) ((b).find(a)!=(b).end())
#define fill(a,v) memset(a,v,sizeof a)
#define sz(a) ((int)(a.size()))
#define mp make_pair
#define pb push_back

int a[110000], b[110000], c[110000];
int n;
int dp[3][110000];
int main(){
  fastIO
  cin>>n;
  for(int i = 0; i < n; i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  dp[0][0] = a[0];
  dp[1][0] = b[0];
  dp[2][0] = c[0];
  for(int i = 1; i < n; i++){
    dp[0][i] = max(dp[1][i - 1] + a[i], dp[2][i - 1] + a[i]);
    dp[1][i] = max(dp[0][i - 1] + b[i], dp[2][i - 1] + b[i]);
    dp[2][i] = max(dp[0][i - 1] + c[i], dp[1][i - 1] + c[i]);
  }
  cout<<max(dp[0][n - 1], max(dp[1][n - 1], dp[2][n - 1]))<<endl;
}

Measured memory_bytes: 2688
# stack
exp = input().split()
s = []

for lt in exp:
    if lt == '+' or lt == '-' or lt == '*':
        rhs = s.pop()
        lhs = s.pop()
        if lt == '+':
            s.append(lhs + rhs)
        if lt == '*':
            s.append(lhs * rhs)
        if lt == '-':
            s.append(lhs - rhs)
    else:
        s.append(int(lt))
        
print(str(s[0]))

Measured memory_bytes: 7668
#include <algorithm>
#include <iostream>

using namespace std;

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

  if (a > b) {
    swap(a, b);
  }
  if (b > c) {
    swap(b, c);
  }
  if (a > b) {
    swap(a, b);
  }
  cout << a << " " << b << " " << c << endl;;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,i,sum=0,sum1=0,x;
    cin>>n>>k;
    string s;
    cin>>s;
    if(n==1){
        cout<<0;
    }
    else{
        for(i=0;i<n-1;i++){
            if(s[i]==s[i+1]){
                sum++;
            }
            else{
                sum1++;
            }
        }
        k=k*2;
        x=min(sum1,k);
        sum=sum+x;
        cout<<sum;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

int X, Y, c[16][16], mem[20][20];

// tate 1, migi 2, hidari 3
int solve(int x, int y, int tate) {
  if(x < 0 || x >= X) return 0;
  if(y >= Y) {
    if(tate == 1)
      return 1;
    else
      return 0;
  }
  if(c[y][x] == 1) return 0;
  if(tate == 1 && c[y][x] == 2) {
    return solve(x, y+2, 1);
  }
  if(c[y][x] == 2) return 0;
  if(mem[y][x] != -1) return mem[y][x];
  int tmp = solve(x-1, y+1, 2) + solve(x+1, y+1, 3) + solve(x, y+1, 1);
  mem[y][x] = tmp;
  return tmp;
}
  

int main() {
  while(cin >> X >> Y, X) {
    int res = 0;
    
    rep(i, Y) {
      rep(j, X) {
        cin >> c[i][j];
        mem[i][j] = -1;
      }
    }
    
    rep(i, X) {
      res += solve(i, 0, 1);
    }
    
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3076
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort()
    print(sum(p[:k]))
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 21728
//abc149C
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {

  int x, i, c=0;
  scanf("%d", &x);

  while(1){
    c=0;
    for(i=2; i < sqrt(x); i++){
      if(x % i == 0) break;
      c++;
    }
    if(c >= sqrt(x) - 2){
      printf("%d", x);
      break;
    }
    x++;
  }
  return 0;
}


Measured memory_bytes: 128