akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
class slove
{
private:
        int node[10];
        int route[205][205];
        int dp[1<<10][10];
        int n,m,k;
public:
    void in();
    void doing()
    {

        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                for(int s = 1; s <= n; s++)
                {
                    route[j][s] = min(route[j][s],route[j][i] + route[i][s]);
                }
            }
        }
        memset(dp,0x3f,sizeof(dp));
        int maxx = dp[0][0];
        for(int i = 0; i < k; i++)
        {
            dp[(1<<i)][i] = 0;
        }
        for(int i = 1; i < 1<<k; i++)
        {
            for(int j = 0; j < k; j++)
            {
                for(int s = 0; s < k; s++)
                {
                    if(j!=s&&!(i&(1<<s)))
                    {
                        dp[i|(1<<s)][s] = min(dp[i|(1<<s)][s],dp[i][j] + route[node[j]][node[s]]);
                    }
                }
            }
        }
        for(int i = 0; i < k; i++)
        {
            maxx = min(dp[(1<<k)-1][i],maxx);
        }
        printf("%d\n",maxx);
    }
};
void slove::in()
    {
        memset(route,0x3f,sizeof(route));
        scanf("%d %d %d",&n,&m,&k);
        for(int i = 0; i < k; i++)
            scanf("%d",&node[i]);
        while(m--)
        {
            int x,y,cost;
            scanf("%d %d %d",&x,&y,&cost);
            route[y][x] = route[x][y] = cost;
        }
    }
int main(void)
{
    slove M;
    M.in();
    M.doing();
    return 0;
}


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

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


Measured memory_bytes: 3560
N, L = map(int, input().split())
llist = []
p = 0
zeronear = {}
for i in range(N):
    llist.append(L+i)
for i in range(len(llist)):
    zeronear[i] = abs(llist[i]-0)
a = min(zeronear, key=zeronear.get)
del llist[a]
print(sum(llist))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long int ll;
#define MOD 1000000007
#define MAXN 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
using namespace std;

int main() {
    ll n,m;
    cin >> n >> m;
    ll a[m],sum=0;
    f(i,0,m){
        cin >> a[i];
        sum+=a[i];
    }
    if(n-sum>=0){
        cout <<n-sum;
    }else{
        cout <<-1;
    }
}

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

#define ll long long 

int n, x, y;
int cnt[(int) 3e3];

void bfs(int v, vector<vector<int>> adj) {
    queue<int> q;
    vector<int> dist(n, 1e9);
    vector<int> parent(n, -1);
    vector<bool> visited(n);
    dist[v] = 0;
    parent[v] = v;
    visited[v] = true;
    q.push(v);

    while (not q.empty()) {
        int x = q.front(); q.pop();
        for (auto y : adj[x]) {
            if (visited[y]) continue;
            //cout << "v: " << y << endl;
            visited[y] = true;
            parent[y] = x;
            dist[y] = dist[x] + 1;
            cnt[dist[x] + 1]++;
            q.push(y);
        }
    }

}

int main() {
    ios::sync_with_stdio(0); 

    cin >> n >> x >> y;
    memset(cnt, 0, sizeof(cnt));

    vector<vector<int>> adj(n);
    for (int i = 0; i < n-1; i++) {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }

    adj[x-1].push_back(y-1);
    adj[y-1].push_back(x-1);

    for (int v = 0; v < n; v++) 
        bfs(v, adj);


    for (int i = 1; i <= n-1; i++) 
        cout << cnt[i]/2 << endl;



    return 0; 
}



Measured memory_bytes: 3816
#include <bits/stdc++.h>
    #define pb push_back
    using namespace std;
    int n,q;
    vector<int>G[200010];
    int a[200010];
    int ans[200010];
    void dfs(int x,int pr=-1){
    	ans[x]=ans[pr]+a[x];
    	for(auto to:G[x])if(to!=pr){
    		dfs(to,x);
    	}
    }
    int main(){
    	cin>>n>>q;
    	for(int i=1;i<n;i++){
    		int x,y;
    		cin>>x>>y;
    		G[x].pb(y);
    		G[y].pb(x);
    	}
    	for(int i=1;i<=q;i++){
    		int x,y;
    		cin>>x>>y;
    		a[x]+=y;
    	}
    	dfs(1);
    	for(int i=1;i<=n;i++)cout<<ans[i]<<' ';
    	puts("");
    	return 0;
    }

Measured memory_bytes: 24064
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    const val = input.split(" ");
    console.log(val[0] * val[1] / 2)


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  int max=0;
  int maxindex=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(max < A[i]){
      max=A[i];
      maxindex=i;
    }
  }
  int semimax=0;
  int semimaxindex=0;
  for(int i=0;i<N;i++){
    if(semimax<A[i] && i!=maxindex){
      semimax=A[i];
      semimaxindex=i;
    }
  }
  for(int i=0;i<N;i++){
    if(i!=maxindex){
      cout << max << endl;
    }else{
      cout << semimax << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n),t(n);
	for(int i = 0; i < n; i++){
		cin >> t[i] >> a[i];
	}

	ll T = 1,A=1;
	for(int i = 0; i < n; i++){
		//ll co = max(ceil((double)T/t[i]),ceil((double)A/a[i]));　これでWAになる理由が分からない...
		ll x = T/t[i];
		ll y = A/a[i];
		if(T%t[i] != 0) x++;
		if(A%a[i] != 0) y++;
		ll co = max(x,y);
		T = co * t[i];
		A = co * a[i];
	}

	cout << T+A << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
  ll n,k; cin >> n >> k;
  ll ans=k;
  for(ll i=1; i<n; i++){
    ans *= k-1;
    //cout<< ans << endl;
  }
  cout << ans <<endl;
  return 0;
}




Measured memory_bytes: 256
// DP F

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n;
  cin >> n;
  vector<int> scores(n);
  int sum = 0;
  rep(i, n) {
    cin >> scores[i];
    sum += scores[i];
  }
  sort(scores.begin(), scores.end());

  if (sum % 10 == 0) {
    for (auto it = scores.begin(); it != scores.end(); it++) {
      if (*it % 10 != 0) {
        sum -= *it;
        break;
      }
    }
  }

  if (sum % 10 == 0) {
    cout << 0 << endl;
  } else {
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int,input().split())
P = sorted(list(map(int,input().split())), reverse=True)
Q = sorted(list(map(int,input().split())), reverse=True)
R = sorted(list(map(int,input().split())), reverse=True)
P = P[:X]
Q = Q[:Y]
A = P + Q + R
A.sort(reverse=True)
ans = sum(A[:X+Y])
print(ans)

Measured memory_bytes: 23200
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
template <typename T>
using Vec3 = vector<Vec2<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repe(i, n) REPN(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define reper(i, n) REPNR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec2<ll> memo(3001, Vec(3001, -LINF));
Vec a;

ll f(ll l, ll r){
	if(r-l == 0) return memo[l][r] = 0;
	if(r-l == 0) return memo[l][r] = a[l];
	if(memo[l][r] != -LINF) return memo[l][r];
	return memo[l][r] = max(a[l]-f(l+1, r), a[r-1]-f(l, r-1));
}

int main(void){
	sonic();
	ll n;
	cin >> n;
	a.resize(n);
	rep(i, n) cin >> a[i];
	co(f(0, n));

	return 0;
}


Measured memory_bytes: 72960
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  1000000007
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; 
    string s1,s2; 
    cin >> n >> s1 >> s2 ; 
    int ans = 3;
    for (int i=0;i<n;i++){
        if (s1[i] != s2[i]){
            if (i==0 or (s1[i-1] == s2[i-1])) ans = (ans*2LL)%mod;
            else ans = (ans*3LL)%mod;
            i++;
        }
        else {
            if (i>0 and (s1[i-1] == s2[i-1])) ans = (ans*2LL)%mod; 
        }
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
ll n;
DVector tree;
Vector snuke,fennec;

int main(){
  cin.sync_with_stdio(false);
  cin >> n;
  tree.resize(n);
  snuke.resize(n);
  fennec.resize(n);
  rep(i,n-1){
    ll a,b;
    cin >> a >> b;
    tree[a-1].pb(b-1);
    tree[b-1].pb(a-1);
  }
  queue<P> q1;
  q1.push(mkp(0,0));
  set<ll> st1;
  while(q1.size()){
    P state = q1.front();
    q1.pop();
    if(st1.count(state.fi))continue;
    st1.insert(state.fi);
    fennec[state.fi] = state.se;
    each(itr,tree[state.fi]){
      q1.push(mkp(itr,state.se+1));
    }
  }
  queue<P> q2;
  q2.push(mkp(n-1,0));
  set<ll> st2;
  while(q2.size()){
    P state = q2.front();
    q2.pop();
    if(st2.count(state.fi))continue;
    st2.insert(state.fi);
    snuke[state.fi] = state.se;
    each(itr,tree[state.fi]){
      q2.push(mkp(itr,state.se+1));
    }
  }
  ll cnt1 = 0,cnt2 = 0;
  rep(i,n)fennec[i] <= snuke[i] ? cnt1++ : cnt2++;
  cout << (cnt1 > cnt2 ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 16768
import sys
f=lambda:map(int,sys.stdin.readline().split())
n,d,a=f()
lt=sorted(tuple(f()) for _ in range(n))
from collections import *
q=deque()
c=s=0
for x,h in lt:
  while q and q[0][0]<x: s+=q.popleft()[1]
  h-=s
  if h<1: continue 
  t=-h//a; c-=t; s-=t*a; q.append((x+d*2,t*a))
print(c)

Measured memory_bytes: 76508
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <math.h>

using namespace std;



int main(){
	
	int A[200000], b[200000] = { 0 }, N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		b[A[i]-1] = b[A[i]-1] + 1;
	}
	for (int i = 0; i < N; i++) {
		cout << b[i] << endl;
	}

return 0;

}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 1e6;

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;
}


int main(){
  int n,H,W; cin >> n >> H >> W;
  int ans = 0;
  rep(i,n) {
    int a,b; cin >> a >> b;
    ans += min(a/H,b/W);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vll a(N);
    REP(i, N) cin >> a[i];
//
//    ll m = a[0];
//    REP(i, N) {
//        m = lcm(m, a[i]);
//    }

    ll ans = 0;
    REP(i, N) {
        ans += a[i] - 1;
    }

    print(ans);

}


Measured memory_bytes: 256
use petgraph::unionfind::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        k: isize,
        p: [Usize1; n],
        c: [isize; n],
    }
    let mut components = UnionFind::new(n);
    for i in 0..n {
        components.union(i, p[i]);
    }
    let mut cycles = vec![0; n];
    let mut cycle_cost = vec![0isize; n];
    for i in 0..n {
        cycles[components.find(i)] += 1;
        cycle_cost[components.find(i)] += c[p[i]];
    }
    let mut cost = vec![0isize; n];
    for i in 0..n {
        let cc = cycle_cost[components.find(i)];
        let ci = cycles[components.find(i)];

        let l = min(k, k % ci + ci);
        let k = k - l;

        let mut s = vec![c[p[i]]];
        let mut j = p[i];
        for _ in 1..l {
            s.push(s[s.len() - 1] + c[p[j]]);
            j = p[j];
        }
        let mut c = *s.iter().max().unwrap();
        if cc > 0 {
            c += cc * (k / ci);
        }
        // eprintln!("{} {} {} {:?}", i, cc, ci, s);
        cost[i] = c;
    }
    println!("{}", cost.iter().max().unwrap());
}


Measured memory_bytes: 2516
x,y=map(int,input().split())
 
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
 
if x==2 or y==2:
  print('No')
elif (x in A and y in A) or (x in B and y in B):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9080
import fractions
from functools import reduce

 
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // fractions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                if n[j] % t == 0 and (n[j] / t) % 2 == 1:
                        n[j] = int(n[j]/t)
                else: return 0
        return int(t//2)
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
n=sorted(set(n),reverse = True)

bs = n[0]

if len(n) > 1:
        
        c = chk(n[-1])
        
        if  c != 0:
                v = lcm_o()*c
                
                if v > M:
                        print(0) 
                else:
                        v = M//v
                        if v%2==1: v+=1
                        print(int(v//2))
        
        else: print(0)
elif len(n)==1:
        v = int(bs*0.5)
        v = M//v
        if v%2==1: v+=1
        print(int(v//2))

Measured memory_bytes: 16284
n = int(input())
A = list(map(int,input().split()))
one = A.count(1)
two = A.count(2)
three = A.count(3)

dp = [[[0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
for sushi in range(1,n+1):
    for k in range(sushi+1):
        for j in range(sushi-k+1):
            i = sushi-k-j
            if i != 0:
                dp[i][j][k] += dp[i - 1][j][k] * i / sushi
            if j != 0:
                dp[i][j][k] += dp[i + 1][j - 1][k] * j / sushi
            if k != 0:
                dp[i][j][k] += dp[i][j + 1][k - 1] * k / sushi
            dp[i][j][k] += n / sushi
print(dp[one][two][three])

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

int main(void) {
  long double num;
  long double v;
  cin >> num;
  for (int i = 0; i < num; i++) {
    v = sqrt(num - i);
    if (v == long(v)) {
      cout << long(num - i) << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include<iostream>

#define ll long long int
#define rep(i,n) for(int (i)=1;(i) <= (n);(i)++)
#define INF 1000000000000000000

using namespace std;

int abs(int x,int y){
    if(x < y){
        return y - x;
    }else{
        return x - y;
    }
}

int main(void){
    int X,N,min = 220;
    int ans;
    int p[101],q[101];
    q[0] = 1;
    rep(i,100){
        q[i] = 1;
    }
    cin >> X >> N;

    rep(i,N){
        cin >> p[i];
        q[p[i]] = 0;
    }

    if(N == 0){
        cout << X << endl;
        return 0;
    }
    
    for(int i = 0;i <= 101;i++){
        if(q[i] == 0){
            continue;
        } 
        if(abs(i,X) < min){
            min = abs(i,X);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

class union_find {
public:
    union_find(int n) : par(n, -1) {}

    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return;
        if(par[x] < par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

private:
    vector<int> par;
};

struct edge {
    int u, v, cost;
    edge(int a, int b, int c) : u(a), v(b), cost(c) {}
    bool operator<(edge const& e) const {
        return cost < e.cost;
    }
};

int main() {
    int n, t, k;
    int test = 1;
    while(cin >> n >> t >> k, n) {
        vector<edge> es;
        for(int i = 0; i < n - 1; ++i) {
            int a, b, c; cin >> a >> b >> c;
            es.emplace_back(a - 1, b - 1, c);
        }
        sort(rbegin(es), rend(es));

        vector<bool> base(n);
        for(int i = 0; i < t; ++i) {
            int x; cin >> x;
            base[x - 1] = true;
        }

        union_find uf(n);
        int region = t;
        int ans = 0;
        for(auto const& e : es) {
            const int u = uf.root(e.u), v = uf.root(e.v);
            if(base[u] && base[v] && region == k + 1) {
                ans += e.cost;
                continue;
            }
            uf.unite(u, v);
            region -= (base[u] && base[v]);
            base[u] = base[v] = (base[u] || base[v]);
        }

        cout << "Case " << (test++) << ": " << ans << endl;
    }
}



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

int dp[(int)1e5+1];

int solve(int *h, int n)
{
    if(n == 0)
        return 0;
    if(dp[n] != -1)
        return dp[n];
    int op1, op2;
    op1 = op2 = 1e9;
    if(n >= 2)
        op1 = solve(h, n-2) + abs(h[n]-h[n-2]);
    if(n >= 1)
        op2 = solve(h, n-1) + abs(h[n]-h[n-1]);
    return dp[n] = min(op1, op2);
}

int main() {
    int t = 1;
    while(t--)
    {
    	int n;
    	cin >> n;
    	int h[n];
    	for(int &val : h) 
    	    cin >> val;
    	memset(dp, -1, sizeof dp);
    	cout << solve(h, n-1);
    }
	return 0;
}

Measured memory_bytes: 7432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    UnionFind u(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        u.unite(a, b);
    }

    int ans = 0;
    rep(i, n) {
        chmax(ans, u.size(i));
    }
    
    pr(ans);
    return 0;
}


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

int main(){
    int n,l;
    cin>>n>>l;
    vector<pair<int,int>> v(n);
    int min = abs(l),nbapple = 1;
    for(int i = 2;i<=n;++i){
        if(min > abs(l+i-1)){
            min = abs(l+i-1);
            nbapple = i;
        }
    }
    int s = (n-1)*l-n+1;
    for(int i = 1;i<=n;++i){
        if(i == nbapple)
            continue;
        s += i;
    }
    cout<<s;

    return 0;
}

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

public class Main{
	public static void main(String[] args){
		Scanner stdIn = null;
		List<Double> point = new ArrayList<Double>();
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.next();
				String[] s = str.split(",");
				double x = Double.parseDouble(s[0]);
				double y = Double.parseDouble(s[1]);
				point.add(x);
				point.add(y);
			}
			double sum = 0;
			for(int i = 2; i < point.size()/2; i++){
				double x = point.get(2*i)-point.get(0);
				double y = point.get(2*i+1)-point.get(1);
				double a = Math.sqrt(x*x+y*y);
				x = point.get(2*i-2)-point.get(0);
				y = point.get(2*i-1)-point.get(1);
				double b = Math.sqrt(x*x+y*y);
				x = point.get(2*i-2)-point.get(2*i);
				y = point.get(2*i-1)-point.get(2*i+1);
				double c = Math.sqrt(x*x+y*y);
				double z = (a+b+c)/2;
				sum += Math.sqrt(z*(z-a)*(z-b)*(z-c));
			}
			System.out.printf("%.6f", sum);
		} finally {
			if( stdIn != null){
				stdIn.close();
			}
		}
	}
}

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

//const long long INF = 1000000001;
//const int INF = 2147483647;

const long long MOD = 1000000009;

typedef long long ll;

const int max = 100000; //配列の最大長

class Union_find{
public:
  int par[2*max];
  int rank[2*max];

  Union_find(int n){
    for(int i=0; i<n; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x){
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x,int y){
    return find(x) == find(y);
  }
};

int main(void){
  int N,K,L;
  std::cin >> N >> K >> L;

  Union_find uf1(N),uf2(N);

  for(int i=0; i<K; i++){
    int p,q;
    std::cin >> p >> q; p--; q--;
    uf1.unite(p,q);
  }
  for(int i=0; i<L; i++){
    int r,s;
    std::cin >> r >> s; r--; s--;
    uf2.unite(r,s);
  }

  std::map<std::pair<int,int>,int> mp;
  std::pair<int,int> pr;
  for(int i=0; i<N; i++){
    pr = std::make_pair(uf1.find(i),uf2.find(i));
    mp[pr]++;
  }

  for(int i=0; i<N; i++){
    pr = std::make_pair(uf1.find(i),uf2.find(i));
    std::cout << mp[pr] << " ";
  }
  return 0;
}


Measured memory_bytes: 15232
from collections import Counter
#K = int(input())
#N,K = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
c=0
l=[]
r=[]
for i in range(N):
    l.append(A[i]+i+1)
    r.append(i+1-A[i])

C=Counter(r)

for x in l:
    c+=C.get(x,0)
print(c)


Measured memory_bytes: 50608
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 0) { cout << "Even"; }
	else { cout << "Odd"; }
	cout << endl;
}

Measured memory_bytes: 256
import math

n = int(input())
x = []
y = []


arr = [i for i in range(1,n)]
for i in range(n):
  a,b = map(int,input().split())
  x.append(a)
  y.append(b)
  
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    count += math.sqrt(((x[i]-x[j])**2)+((y[i]-y[j])**2))

print(count / n * 2)

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


bool solve(int N, vector<string>& w) {
    set<string> deja;
    deja.insert(w[0]);

    for (int i=1; i<N; ++i) {
        if (found(deja, w[i])) return false;
        if (w[i-1].back() != w[i][0]) return false;
        deja.insert(w[i]);
    }
    return true;
}

int main() {
    int N; cin >> N;
    vector<string> w(N);
    rep(i,N) cin >> w[i];
    cout << (solve(N,w) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N,S=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353

dp=[0 for n in range(3001)]
c=0
for n in range(N):
    a=A[n]
    for s in range(0,S+1)[::-1]:
        if s+a<=S:
            dp[s+a]+=dp[s]
            dp[s+a]%=mod

    dp[a]+=n+1
    dp[a]%=mod
    c+=dp[S]
    c%=mod
#print(dp[S])
print(c)


Measured memory_bytes: 63976
#include"bits/stdc++.h"
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=1 ; i < N+1 ; i++){
    if(i<1){continue;}
   else if(i<10){ans++;}
   else if(i<100){continue;}
   else if(i<1000){ans++;}
   else if(i<10000){continue;}
   else if(i<100000){ans++;}
   else if(i<1000000){continue;}}
  cout << ans ;
}


Measured memory_bytes: 256
import collections
n = int(input())
v_array = list(map(int, input().split()))

c1 = collections.Counter(v_array[0::2])
c2 = collections.Counter(v_array[1::2])
c1_num, c1_count = c1.most_common()[0]
_, c1_second = c1.most_common()[1] if len(c1) > 1 else [0, 0]
c2_num, c2_count = c2.most_common()[0]
_, c2_second = c2.most_common()[1] if len(c2) > 1 else [0, 0]
if c1_num != c2_num:
    ans = n - (c1_count + c2_count)

else:
    ans = n - max(c1_count + c2_second, c1_second + c2_count)

print(ans)

Measured memory_bytes: 70124
package main

import (
	"fmt"
)

func main() {
	c_5_2()
}

func c_5_2() {
	var n int
	fmt.Scanf("%d", &n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &s[i])
	}
	fmt.Scanf("%d", &n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &t[i])
	}
	c := 0
	for _, ti := range t {
		for _, si := range s {
			if si == ti {
				c++
				break
			}
		}
	}
	fmt.Println(c)
}



Measured memory_bytes: 1732
package main

import "fmt"

func main() {
	card := make([][]int, 4)
	mark := []string{"S", "H", "C", "D"}

	for i := 0; i < 4; i++ {
		card[i] = make([]int, 13)
	}

	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var mk string
		var num int
		fmt.Scan(&mk, &num)
		for j := 0; j < 4; j++ {
			if mark[j] == mk {
				card[j][num-1] = 1
			}
		}
	}
	for j := 0; j < 4; j++ {
		for i := 0; i < 13; i++ {
			if card[j][i] == 0 {
				fmt.Printf("%s %d\n", mark[j], i+1)
			}
		}
	}
	return
}



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

int main() {
    int sum = 0;
    for (int i = 0; i < 3; i++) {
        char s;
        cin >> s;
        if (s == 'o') {
            sum++;
        }
    }
    cout << 700 + sum * 100 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <locale>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    string s;
    locale l = locale::classic();
    getline(cin, s);
    rep(i, s.length())
    {
        if (isupper(s[i]))
        {
            cout << tolower(s[i], l);
        }
        else
        {
            cout << toupper(s[i], l);
        }
    }
    cout << endl;
}


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



int lcs[1001][1001];

char X[1001];
char Y[1001];


void makeLCS(int len_i, int len_j){
    
    int i, j;
    for (i = 0; i <= len_i; i++ ) {
        lcs[i][0] = 0;
    }
    
    for (j = 0; j <= len_j; j++ ) {
        lcs[0][j] = 0;
    }
    
    for (i = 1; i <= len_i; i++) {
        for(j = 1; j <= len_j; j++){
            if (X[i-1] == Y[j-1]) {
                lcs[i][j] = lcs[i-1][j-1] + 1;
            }
            else{
                if (lcs[i][j-1] > lcs[i-1][j]) {
                    lcs[i][j] = lcs[i][j-1];
                }
                else{
                    lcs[i][j] = lcs[i-1][j];
                }
            }
        }
    }
}


int main( ){
    
    int i, n;
    
    
    scanf("%d", &n);
    
    for (i=0; i<n; i++) {
        scanf("%s", X);
        scanf("%s",Y);
        makeLCS(strlen(X), strlen(Y));
        printf( "%d\n", lcs[strlen(X)][strlen(Y)] );
    }
    
    return 0;
}

Measured memory_bytes: 4516
from itertools import product

n, m, l = map(int, input().split())
subjects = [[] for _ in range(5)]
for _ in range(m):
    d, a, k, t = map(int, input().split())
    subjects[d].append((a, a + k - 1, t))

for i in range(5):
    subjects[i].sort(key=lambda x:x[1])
 
#各曜日の科目数ごとの最大幸福
def calcDp(i):
    #dp[y][x] ... y科目xコマまでの最大幸福
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    sub = subjects[i]
    for init, end, value in sub:
        for y in range(n):
            new_score = dp[y][init - 1] + value
            for x in range(end, n + 1):
                dp[y + 1][x] = max(dp[y + 1][x], new_score)
    ret = []
    for i in range(n + 1):
        ret.append(max(dp[i]))
    return ret

lst = [calcDp(i) for i in range(5)]

ans = 0
for t in product(range(n + 1), repeat=5):
    if sum(t) > l:continue
    score = 0
    for i, v in enumerate(t):
        score += lst[i][v]
    ans = max(score, ans)
print(ans)


Measured memory_bytes: 5688
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;

int main(void) {


	//0011
	int Line[31], w=0, n=0, a, b, tmp;
	cin >> w;
	cin >> n;
	for (int i=0; i < 31; i++) {
		Line[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf("%d,%d", &a, &b);
		tmp = Line[a];
		Line[a] = Line[b];
		Line[b] = tmp;
	}
	for (int k = 1; k <= w; k++) {
		cout << Line[k] << endl;
	}


	return 0;
}

Measured memory_bytes: 1240
#include<cstdio>
#include<cstring>
typedef long long LL;
const int N=60;
int n,fa[N],fid[N],dep[N],m,head[N],cnt;
unsigned long long U[N],F[2][1<<20];
struct edge{
	int to,nxt,id;
}e[N<<1];
void dfs(int now){
	for(int i=head[now];i;i=e[i].nxt)
	if(!dep[e[i].to]){
		dep[e[i].to]=dep[now]+1;
		fa[e[i].to]=now,fid[e[i].to]=e[i].id;
		dfs(e[i].to);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		e[++cnt]=(edge){v,head[u],i},head[u]=cnt;
		e[++cnt]=(edge){u,head[v],i},head[v]=cnt;
	}
	dfs(dep[1]=1);
	scanf("%d",&m);
	for(int i=0;i<m;++i){
		int u,v;
		unsigned long long zt=0;
		scanf("%d%d",&u,&v);
		if(dep[u]<dep[v])u^=v^=u^=v;
		while(dep[u]!=dep[v])zt|=1uLL<<fid[u],u=fa[u];
		while(u!=v)zt|=(1uLL<<fid[u])|(1uLL<<fid[v]),u=fa[u],v=fa[v];
		U[i]=zt;
	}
	**F=1;
	for(int i=1;i<n;++i){
		memcpy(F[i&1],F[i&1^1],sizeof*F);
		for(int S=0;S<1<<m;++S){
			int zt=S;
			for(int j=0;j<m;++j)
			if(!(S>>j&1)&&(U[j]>>i&1))zt|=1<<j;
			F[i&1][zt]+=F[i&1^1][S];
		}
	}
	printf("%llu\n",F[n&1^1][(1<<m)-1]);
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int N; cin >> N;
    vector<pair<int64_t, int64_t>> points(N);
    REP(i, N) cin >> points[i].first >> points[i].second;

    vector<vector<int64_t>> f(N);
    REP(i, N) {
        auto [x, y] = points[i];
        f[i] = {x-y, x+y};
    }

    int64_t ans = numeric_limits<int64_t>::min();
    REP(d, 2) {
        auto m1 = numeric_limits<int64_t>::max();
        auto m2 = numeric_limits<int64_t>::min();
        REP(i, N) m1 = min(m1, f[i][d]);
        REP(i, N) m2 = max(m2, f[i][d]);
        ans = max(ans, m2 - m1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 17248
#include <stdio.h>
#include <stdlib.h>

int main(){
        int p;
        scanf("%d",&p);
        int f = 0;
        for(int i = 0;i <= 9;i++){
                for(int j = 0;j <= 9;j++){
                        if((i * j) == p){
                                f = 1;
                        }
                }
        }
        if(f){
                printf("Yes\n");
        }else{
                printf("No\n");
        }
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,w;
long long dp[100005],v[105];
int u[105];

int main(){
	scanf("%d %d",&n,&w);
	for(int i=1;i<=n;i++){
		scanf("%d %lld",&u[i],&v[i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=w;j>=u[i];j--){
			dp[j]=max(dp[j],dp[j-u[i]]+v[i]);
		}
	}
	printf("%lld\n",dp[w]);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
using ll = long long;

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

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

  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a = [a[i] - (i + 1) for i in range(N)]
a = sorted(a)

if N % 2 == 0:
    t = (a[N // 2 - 1] + a[N // 2]) // 2
else:
    t = a[N // 2]

ans = sum(abs(aa - t) for aa in a)
print(ans)


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

int main(){
    int n;

    cin >> n;

    switch (n % 10 )
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon\n";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon\n";
        break;
    case 3:
        cout << "bon\n";
        break;
    default:
        break;
    }


    return 0;
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int AandB = min(X, Y);
    int ans = 0;
    if (2*C < A + B) ans += 2 * C * AandB;
    else ans += (A + B) * AandB;
    if (2*C < A) ans += 2*C * (X - AandB);
    else ans += A * (X - AandB);
    if (2*C < B) ans += 2*C * (Y - AandB);
    else ans += B * (Y - AandB);

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

Measured memory_bytes: 632
n=int(input())
A=list(map(int,input().split()))

count=[0 for _ in range(max(A)+1)]
for i in range(n):
  count[A[i]]+=1
  
answer=0
if n>3:
  for i in range(0,n-2):
    tmp=sum(count[i:i+3])
    if tmp>answer:
      answer=tmp
elif n==2:
  if len(count)>3:
    answer=1
  else:
    answer=2
elif n==1:
  answer=1

print(answer)

Measured memory_bytes: 20756
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if(s == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

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

  if(S[0] == 'A') {
    int count = 0;
    for(int i = 1; i < S.length(); i++) {
      if(2 <= i && i <= S.length() - 2 && S[i] == 'C') {
	count++;
      }
      else if('A' <= S[i] && S[i] <= 'Z') {
	cout << "WA" << endl;
	return 0;
      }
    }
    if(count == 1) {
      cout << "AC" << endl;
      return 0;
    }
    else {
      cout << "WA" << endl;
      return 0;
    }
  }
  else {
    cout << "WA" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, c, d;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    while(1)
    {
        c = c - b;
        if(c <= 0)
        {
            printf("Yes");
            break;
        }
        a = a - d;
        if(a <= 0)
        {
            printf("No");
            break;
        }
    }

}

Measured memory_bytes: 1724
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
 
class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};
 
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; i++)
	{
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
 
	vector<long long> ans(M);
	ans[M - 1] = (long long)N * (N - 1) / 2;
 
	UnionFind Uni(N);
 
	for (int i = M - 1; i >= 1; i--)
	{
		ans[i - 1] = ans[i];
 
		//繋がってなかったのが繋がった時
		if (Uni.root(A[i]) != Uni.root(B[i])) {
			ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
			Uni.connect(A[i], B[i]);
		}
	}
 
	for (int i = 0; i < M; i++)
	{
		cout << ans[i] << endl;
	}
}
 

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


int main() {

    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     int x;
     cin>>x;
     if(x>=400&&x<=599)cout<<8;
     if(x>=600&&x<=799)cout<<7;
     if(x>=800&&x<1000)cout<<6;
     if(x>=1000&&x<1200)cout<<5;
     if(x>=1200&&x<1400)cout<<4;
     if(x>=1400&&x<1600)cout<<3;
     if(x>=1600&&x<1800)cout<<2;
     if(x>=1800&&x<2000)cout<<1;
}



Measured memory_bytes: 3632
program test
implicit none
integer(8) :: k,ans,i,j,list_number(10,0:100000)=0,count=0,count_digit=0,count_digit_before=0,digit=1,tmp=0

read(*,*) k

if(k <= 9) then
  ans = k
else
  
  do i=1,9
    count_digit = count_digit + 1
    count = count + 1
    list_number(digit,count_digit) = i
  enddo
  
  do
    if(list_number(digit,count_digit) == 10**digit - 1) then
      digit = digit + 1
      count_digit_before = count_digit
      count_digit = 0
    endif
    
    do j=1,count_digit_before
      
      tmp = mod(list_number(digit-1,j),10)
      
      if(tmp>=1)then
        count_digit = count_digit + 1
        count = count + 1
        list_number(digit,count_digit) = 10*list_number(digit-1,j) + tmp - 1
        ans = list_number(digit,count_digit)
        if(count == k) then
          goto 100
        endif
        
      endif
      
      count_digit = count_digit + 1
      count = count + 1
      list_number(digit,count_digit) = 10*list_number(digit-1,j) + tmp
      ans = list_number(digit,count_digit)
      if(count == k) then
        goto 100
      endif
      
      if(tmp<=8)then
        count_digit = count_digit + 1
        count = count + 1
        list_number(digit,count_digit) = 10*list_number(digit-1,j) + tmp + 1
        ans = list_number(digit,count_digit)
        if(count == k) then
          goto 100
        endif
        
      endif
      
    enddo
    
  enddo
  
endif

100 continue

write(*,*) ans


end

Measured memory_bytes: 4352
use std::collections::BTreeSet;

use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);

    let s: String = sc.next();
    let k: usize = sc.next();

    let mut ss = BTreeSet::new();

    for i in 0..s.len() {
        for j in 1..6 {
            if i + j <= s.len() {
                ss.insert(&s[i..i + j]);
            }
        }
    }

    let ans = ss.iter().nth(k - 1).unwrap();
    println!("{}", ans);
}

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

pub mod io {
    use std;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T>(&mut self) -> T
        where
            T: std::str::FromStr,
            <T as std::str::FromStr>::Err: std::fmt::Debug,
        {
            let s = self.iter.next().unwrap();
            s.parse::<T>().unwrap()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

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

  
  
int main() {
  intll n , d ;
  cin >> n >> d ;
  intll ans = 0 ; 
  vector<vector<intll>> data(n,vector<intll> (d));
  rep(i,n){
    rep(j,d){
      cin >> data.at(i).at(j);
    }
  }
  
  rep(i,n){
    for(int k=i+1;k<n;k++){
     intll now = 0;
     rep(j,d){
       intll x = data.at(i).at(j) - data.at(k).at(j);
       now += x*x; 
      }
   
   bool  flag = false ;
    rep(i,now+1){
     if(now == i*i) {
      flag = true;
    }
  }
    if(flag) ans ++ ;
   
    }
  }
    

  
  cout << ans ;
}


Measured memory_bytes: 256