akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int n;
	cin >> n;

	string ans = "";

	if( n == 0 ) {
		cout << 0 << endl;
		return 0;
	}

	while( n ) {
		if( n % 2 == 0 ) {
			ans += '0';
		} else {
			ans += '1';
			n--;
		}

		n /= -2;
	}

	reverse(ans.begin(), ans.end());

	cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import collections

class WarshallFloyd():
    def __init__(self,N):  #Nは頂点の個数
        self.N = N
        self.d = [[float('inf')]*N for i in range(N)]  #d[i][j] = iからjへの最短距離,0-indexed
    def add(self,u,v,c,directed = False):
        if directed is False:  #無向グラフの場合
            self.d[u][v] = c
            self.d[v][u] = c
        else:  #有向グラフの場合
            self.d[u][v] = c
    def WarshallFloyd_search(self):
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(self.d[i][j],self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d

H,W = map(int,input().split())
A = [list(map(int,input().split())) for i in range(10)]
B = [list(map(int,input().split())) for i in range(H)]

G = WarshallFloyd(10)

for i in range(10):
    for j in range(10):
        G.add(i,j,A[i][j],directed=True)

d = G.WarshallFloyd_search()

C = []
for i in range(10):
    C.append(d[i][1])

D = [0]*11
for i in range(H):
    for j in range(W):
        if B[i][j] == -1:
            D[10] += 1
        else:
            D[B[i][j]] += 1

ans = 0
for i in range(10):
    ans += C[i]*D[i]

print(ans)

Measured memory_bytes: 40540
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
template<class T>
void input(vector<T>& vec,int n){
	vec.resize(n);
	for(int i=0;i<n;i++){
		cin >> vec[i];
	}
}
string s;
int f(char a){
	int ret = 0;
	int tmp = 0;
	for(int i=0;i<s.size();i++){
		if(s[i]==a)tmp = 0;
		else tmp++;
		chmax(ret,tmp);
	}
	return ret;
}
int main(){
	cin >> s;
	int ans = 10000;
	for(int i=0;i<26;i++){
		chmin(ans,f((char)('a'+i)));
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
//↓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 n, k[105], mon = 999, sum = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		mon = min(mon, k[i]);
		sum += k[i];
	}
	if (sum % 10 != 0) { cout << sum << endl; }
	else {
		sort(k, k + n);
		for (int i = 0; i < n; i++) {
			if (k[i] % 10 != 0) {
				sum -= k[i];
				if (k[i] % 10 != 0) {
					cout << sum << endl;
					return 0;
				}
			}
		}
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<unordered_map>

using namespace std;

typedef long long LL;

LL n;

unordered_map<LL, LL> mmp;

LL f(LL n)
{
    if(n == 1)  return 1;
    if(!mmp.count(n))  mmp[n] = f(n / 2) * 2 + 1;
    return mmp[n];
}

int main()
{
    LL n;
    cin >> n;
    cout << f(n);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
	int s;
	cin >> s;
	map<int,int> mp;
	int now = s;
	mp[s]++;
	int id = 1;
	while(1){
		if (now%2 == 0){
			if (mp.count(now/2)){
				cout << id+1 << endl;
				return 0;
			}
			else mp[now/2]++;
			now /=2;
			id++;
		}
		else {
			if (mp.count(now*3 + 1)){
				cout << id+1 << endl;
				return 0;
			}
			else mp[now*3+1]++;
			now = now*3 + 1;
			id++;
		}
	}
	
	
	return 0; 
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
ll ans=0,f[1000010];
int n,mod,c[1000010];
int main(){
	scanf("%d%d",&n,&mod);
	if(n&1){
		for(register int i=2,j=0;j<n/2;i++,j++)c[i]=j;
		for(register int i=n,j=1;j<=n/2;i--,j++)c[i]=j;
	}
	else{
		for(register int i=2,j=0;j<=(n-1)/2;i++,j++)c[i]=j;
		for(register int i=n,j=1;j<=(n-1)/2;i--,j++)c[i]=j;
	}
	f[0]=1;
	for(register int i=2;i<=n;i++){
		c[i]++;
		for(register int j=c[i];j<n;j++){
			f[j]=(f[j]+f[j-c[i]])%mod;
		}
	}
	//for(register int i=0;i<n;i++)cout<<"f["<<i<<"]="<<f[i]<<endl;
	for(register int i=0;i<n;i++)ans=(ans+f[i]*(n-i))%mod;
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


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

    int A, B;
    cin >> A >> B;

    cout << max(max(A+B, A-B), A * B) << endl;
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
m = 10000000
def judge_1(t):
  c = 0
  while t>0:
    c += t%6
    t = t//6  
  return c
def judge_2(t):
  c = 0
  while t>0:
    c += t%9
    t = t//9  
  return c
for i in range(N+1):
  m = min(m, judge_1(i)+judge_2(N-i))
print(m)

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

if(N == 2 and K != 0):
    print(-1)
    exit()
    
possible = (N-1)*(N-2)//2
if(possible < K):
    print(-1)
    exit()
    
over = possible - K

edge = []
for i in range(2, N+1):
    edge.append((1, i))

additional = []
for i in range(2, N+1):
    for j in range(i+1, N+1):
        if(len(additional) < over):
            additional.append((i, j))
        else:
            break

edge += additional
print(len(edge))
for i in range(len(edge)):
    print(str(edge[i][0]) + ' ' + str(edge[i][1]))
    


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
template <class T> void chmax(T &x, T y) { if (x < y) x = y; }
int main() {
    int N; cin >> N;
    vector<int> V(1 << 18), W(1 << 18);
    for (int i = 1; i <= N; i++) cin >> V[i] >> W[i];
    int Q; cin >> Q;
    vector<int> v(Q), L(Q);
    for (int i = 0; i < Q; i++) cin >> v[i] >> L[i];
    array<vector<int>, 512> A;
    array<int, 512> temp_weight = {}, temp_value = {};
    for (int i = 1; i < A.size(); i++) {
        auto &vec = A[i];
        vec.resize(1e5 + 1);
        int t = i;
        array<int, 9> items = {};
        int cnt = 0;
        while (t > 0) {
            items[cnt++] = t;
            t /= 2;
        }
        for (int j = 0; j < cnt; j++) {
            temp_weight[1 << j] = W[items[j]];
            temp_value[1 << j] = V[items[j]];
        }
        for (int bits = 0; bits < (1 << cnt); bits++) {
            int b = (bits - 1) & bits;
            temp_weight[bits] = temp_weight[b] + temp_weight[bits ^ b];
            temp_value[bits] = temp_value[b] + temp_value[bits ^ b];
            if (temp_weight[bits] < vec.size()) {
                chmax(vec[temp_weight[bits]], temp_value[bits]);
            }
        }
        for (int i = 1; i < vec.size(); i++) {
            chmax(vec[i], vec[i - 1]);
        }
    }
    for (int i = 0; i < Q; i++) {
        if (v[i] < (1 << 9)) {
            cout << A[v[i]][L[i]] << '\n';
        } else {
            array<int, 9> items = {};
            int t = v[i];
            int cnt = 0;
            while (t >= (1 << 9)) {
                items[cnt++] = t;
                t /= 2;
            }
            for (int j = 0; j < cnt; j++) {
                temp_weight[1 << j] = W[items[j]];
                temp_value[1 << j] = V[items[j]];
            }
            int ans = 0;
            for (int bits = 0; bits < (1 << cnt); bits++) {
                int b = (bits - 1) & bits;
                temp_weight[bits] = temp_weight[b] + temp_weight[bits ^ b];
                temp_value[bits] = temp_value[b] + temp_value[bits ^ b];
                if (temp_weight[bits] <= L[i]) {
                    chmax(ans, temp_value[bits] + A[t][L[i] - temp_weight[bits]]);
                }
            }
            cout << ans << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 206452
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] edges = new int[M];
    List<Integer>[] n2e = new List[N];
    for (int i = 0; i < N; i++) n2e[i] = new ArrayList<>();
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      n2e[a].add(i);
      n2e[b].add(i);
      edges[i] = a ^ b;
    }

    if (solve(N, M, n2e, edges)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean solve(int N, int M, List<Integer>[] n2e, int[] edges) {
    int numOver4 = 0;
    int numOver6 = 0;
    for (List<Integer> es : n2e) {
      if (es.size() % 2 == 1) return false;
      if (es.size() >= 4) numOver4++;
      if (es.size() >= 6) numOver6++;
    }

    if (numOver6 >= 1) return true;
    if (numOver4 >= 3) return true;
    if (numOver4 < 2) return false;

    int n = -1;
    for (int i = 0; i < N; i++) {
      if (n2e[i].size() >= 4) {
        n = i;
        break;
      }
    }

    int[] pred = new int[N];
    Arrays.fill(pred, -1);
    List<List<Integer>> loops = new ArrayList<>();
    dfs(0, n, n, N, M, n2e, edges, pred, loops);

    for (List<Integer> loop : loops) {
      boolean found = false;
      for (int i : loop) {
        if (n2e[i].size() >= 4) {
          found = true;
        }
      }
      if (!found) return true;
    }
    return false;
  }

  private static void dfs(int parent, int s, int i, int N, int M, List<Integer>[] n2e, int[] edges,
      int[] pred, List<List<Integer>> loops) {
    pred[i] = parent;
    for (int e : n2e[i]) {
      int to = edges[e] ^ i;
      if (to == parent) continue;
      if (to == s) {
        ArrayList<Integer> path = new ArrayList<>();
        int j = i;
        while (j != s) {
          path.add(j);
          j = pred[j];
        }
        loops.add(path);
        continue;
      }
      if (pred[to] < 0) dfs(i, s, to, N, M, n2e, edges, pred, loops);
    }
  }
}


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

void permute(string candidates, string &s, vector<string> &r) {
    if (candidates.empty()) {
        r.push_back(s);
    } else {
        for (int i = 0; i < candidates.size(); i++) {
            s.push_back(candidates[i]);
            permute(candidates.substr(0, i) + candidates.substr(i + 1), s, r);
            s.pop_back();
        }
    }
}

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    string p = "";
    string q = "";
    string candidates = "";
    for (int i = 1; i <= n; i++) {
        candidates += to_string(i);
    }
    string t = "";
    vector<string> perms;
    permute(candidates, t, perms);
    for (int i = 0; i < n; i++) {
        int pi;
        cin >> pi;
        p += to_string(pi);
    }
    for (int i = 0; i < n; i++) {
        int qi;
        cin >> qi;
        q += to_string(qi);
    }
    int ip = 0;
    int iq = 0;
    for (int i = 0; i < perms.size(); i++) {
        if (perms[i] == p) {
            ip = i;
        }
        if (perms[i] == q) {
            iq = i;
        }
    }
    cout << abs(ip - iq) << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
vector<ll>ad[200005];
ll vis[200005],ans[200005];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n >> m;
	for(i=1;i<=m;i++)
	{
		cin >> x >> y;
		ad[x].pb(y);
		ad[y].pb(x);
	}

	queue<ll>Q;
	Q.push(1);
	vis[1]=1;
	while(!Q.empty())
	{
		x=Q.front();
		Q.pop();

		for(auto it:ad[x])
		{
			if(!vis[it])
			{
				// cout<<it<<"ewg"<<x<<endl;
				Q.push(it),vis[it]=1,ans[it]=x;
			}
		}
	}
	x=0;
	for(i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			// cout<<i<<endl;
			x=1;
		}
	}

	if(!x)
	{
		cout<<"Yes"<<endl;
		for(i=2;i<=n;i++)
			cout<<ans[i]<<endl;

	}
	else
		cout<<"No"<<endl;
}

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

int main() {
  string S;
  cin >> S;
  int a = S.size();
  int h = a/2;
  int ans = 0;
  for (int i=0; i<h; i++) {
    if (S.at(i) != S.at(a-i-1)) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){
    // input
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    sort(A.begin(), A.end());
    
    ll i = 0;
    if(N%2 == 1){
        if(A[0] != 0){
            cout << 0 << endl;
            return 0;
        }else{
            i++;
        }
    }
    ll t;
    if(N%2 == 1) t = 2;
    else t = 1;

    while(i < N-1){
        if(A[i] == A[i+1] && A[i] == t){
            i += 2;
            t += 2;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;
    ll mod = 1e9+7;
    rep(i, 0, N/2){
        ans *= 2;
        ans %= mod;
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var s = consoleReader.String;
            return s.Distinct().Count() == s.Length ? "yes" : "no";
        }


        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}


Measured memory_bytes: 13268
#include<iostream>
#include<bits/stdc++.h>
#include<climits>

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
}

int main(){
    go();

    // code here
    int n,k;cin>>n>>k;
    int arr[n];
    forn(0,n,1) cin>>arr[i];
    sort(arr,arr+n);
    int sol = 0;
    forn(0,k,1) sol += arr[i];
    cout<<sol;
    
}






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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define MOD (int)10e9+7

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;


int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b;
    cin >> a >> b;
    
    int temp=-1;
    for(int i = 1; i <= 3; i++)
        temp = max(temp,i==a?0:i==b?0:i);

    cout << temp << endl;
    

    return 0;

}


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

int main(){
  string S;
  cin >> S;
  int count=0;
  count+=15-S.size();
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='o'){
      count++;
    }
  }
  if(count>=8){
    cout << "YES" << endl;
  }
  else{
    cout<< "NO" << endl;
  }
}

Measured memory_bytes: 3572
N,M=map(int,input().split())
A=[]
for i in range(M):
    a=int(input())
    if i!=0 and a==A[-1]:
        continue
    if i!=0 and a==A[-1]+1:
        print(0)
        quit()
    A.append(a)
INF=10**9+7
B=[]
tmp=0
A.append(N+1)
for i in A:
    B.append(i-tmp)
    tmp=i+1
dp=[0]*(N+3)
dp[0]=1
dp[1]=1
dp[2]=1
for i in range(2,N+2):
    dp[i+1]=dp[i]+dp[i-1]
    dp[i+1]%=INF
ans=1
for i in B:
    ans*=dp[i]
    ans%=INF
print(ans)


Measured memory_bytes: 49112
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b, c;

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

	if (a + b == c || a + c == b || b + c == a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
d = int(input())
c = list(map(int, input().split()))
s = []
r = []
prev = [0] * 26

for i in range(d):
  t = list(map(int, input().split()))
  s.append(t)
  rtmp = [0] * 26
  for j in range(26):
    rtmp[j] = t[j] - c[j]*(i+1)
  r.append(rtmp)

for i in range(d):
  if i == (d-1):
    stmp = s[i]
    happy = - (10 ** 10)
    ans = -1
    for j in range(26):
      tmp = stmp[j]
      cost = 0
      for k in range(26):
        if j == k:
          continue
        cost += c[k] * (i - prev[k])
      tmp -= cost
      if tmp > happy:
        happy = tmp
        ans = j
    prev[ans] = i
    print(ans+1)
  else:
    current = r[i]
    next = r[i+1]
    idx = -1
    val =  (10 ** 10)
    for j in range(26):
      tmp = current[j] - next[j]
      if val > tmp:
        val = tmp
        idx = j
    print(j+1)
    prev[j] = i

Measured memory_bytes: 75224
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n,m;
    cin >> n >> m;

    int a[n+1] = {};

    rep(i,m){
        int x,y;
        cin >> x >> y;
        a[x]++;a[y]++;
    }

    rep(i,n+1){
        if(a[i]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}
 
 


Measured memory_bytes: 640
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n, m;
  cin >> n >> m;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());

  float s = 0;
  rep(i, n) s += a[i];
  if (a[m-1] >= s/(4*m)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	lint n,x,y,z;
	cin>>n;
	REP(i,1,3510) REP(j,1,3510){
		x=i;y=j;
		lint c=x*y*n;
		lint d=4*x*y-n*x-n*y;
		if(d<=0) continue;
		if(c%d==0){
			cout<<x<<' '<<y<<' '<<c/d<<endl;return 0;
		}
	}
}


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    int even = 0;
    int odd = 0;
    auto ncr = [&] (int n, int k) {
		int res = 1;
		for (int i = 1; i <= k; ++i) {
			res *= (n - i + 1);
			res /= i;
		}
		return res;
	};
    if (n > 1) {
    	even = ncr(n, 2);
    } 
    if (m > 1) {
    	odd = ncr(m, 2);
    }
    cout << even + odd << '\n';
}

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

using namespace std;
const int maxn=2e5+111;
const double eps=1e-9;
int n, k, a[maxn];

bool cube(int x){
    int r=0;
    for (int i=0; i<n; i++){
        r+=(a[i]-1+x)/x-1;
    }
    return r<=k;
}

int main(){
    int l=0, r=0;
    scanf("%d %d", &n, &k);
    for (int i=0; i<n; i++){
        scanf("%d", &a[i]);
        r=max(r, (a[i]));
    }
    int ans=r;
    while (r-l>1){
        int mid=(r+l)/2;
//        printf("%.5lf %.9lf %.9lf\n", l, r, mid);
        if (cube(mid)){
            r=mid;
        }
        else l=mid;
    }
    printf("%d", r);
}


Measured memory_bytes: 4472
H, W = map(int, input().split())
l = [input() for i in range(H)]

from collections import deque
d = [(1, 0), (-1, 0), (0, 1), (0, -1)]

ans = 0
for i in range(H):
    for j in range(W):
        if l[i][j] == '#':
            continue
        ll = [[0] * W for _ in range(H)]
        q = deque([(i, j)])
        while q:
            y, x = q.popleft()
            for dy, dx in d:
                if 0 <= y+dy < H and 0 <= x+dx < W and l[y+dy][x+dx] == '.' and (y+dy, x+dx) != (i, j):
                    n = ll[y][x] + 1
                    if ll[y+dy][x+dx] == 0 or ll[y+dy][x+dx] > n:
                        ll[y+dy][x+dx] = n
                        q.append((y+dy, x+dx))
                        if ans < n:
                            ans = n

print(ans)

Measured memory_bytes: 47708
#include <iostream>

using namespace std;

int main() {
	double weight;
	while (cin >> weight) {
		if (weight <= 48.0) cout << "light fly" << endl;
		else if (weight <= 51.0) cout << "fly" << endl;
		else if (weight <= 54.0) cout << "bantam" << endl;
		else if (weight <= 57.0) cout << "feather" << endl;
		else if (weight <= 60.0) cout << "light" << endl;
		else if (weight <= 64.0) cout << "light welter" << endl;
		else if (weight <= 69.0) cout << "welter" << endl;
		else if (weight <= 75.0) cout << "light middle" << endl;
		else if (weight <= 81.0) cout << "middle" << endl;
		else if (weight <= 91.0) cout << "light heavy" << endl;
		else cout << "heavy" << endl;
	}
}

Measured memory_bytes: 0
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;

int dp[10005];

int main(){
    int h,n;
    cin >> h>>n;
    int a[n+1],b[n+1];
    int ans=INF;
    rep(i,n){
        cin >> a[i]>>b[i];
    }
    rep(i,h){
        
        dp[i]=INF;
        
    }

    Rreps(i,h+1,1){
        //cerr<<i<<' ';
        
        rep(j,n){
            int A=a[j];
            int B=b[j];
            if(i-A<=0){
                ans=min(ans,dp[i]+B);
                //cerr<<dp[i][j]+B<<';';
            }else{
                dp[i-A]=min(dp[i-A],dp[i]+B);
            }
        }
        //cerr<<endl;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

int main(void) {
    int N;cin>>N;
    ll A[N],B[N];
    for (int i = 0; i < N; i++) {
        cin>>A[i]>>B[i];
    }
    ll result = 0;
    ll sum = 0;
    for (int i = N-1; i>=0 ; i--) {
        ll tmp = A[i] + sum;
        if (tmp % B[i] > 0) {
            result += (tmp / B[i] + 1) * B[i] - tmp;
            sum += (tmp / B[i] + 1) * B[i] - tmp;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1792
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))
M = sum(A)


ans_candidates = []
for n in range(1, int(M ** 0.5) + 1):
    if M % n == 0:
        ans_candidates.append(n)
        ans_candidates.append(M // n)


ans = 0
for X in ans_candidates:
    need_plus = sorted([(X - a % X) % X for a in A])
    need_minus = [X - nm for nm in need_plus]

    need_plus = list(accumulate(need_plus))
    need_minus = list(accumulate(need_minus))

    for i in range(N):
        if need_plus[i] > K:
            break

        if need_plus[i] == (need_minus[-1] - need_minus[i]):
            ans = max(ans, X)
            break

print(ans)


Measured memory_bytes: 42972
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

x, y = na()
# a = (-1/3) * x + (2/3) * y
# b = (2/3) * x - (1/3) * y

if ((x+y) % 3) == 0:
    i = (x+y)//3
    print(cmb(i,x-i, mod))
else:
    print(0)

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

// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.

class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int K=sc.nextInt();
        long X=sc.nextLong();
        System.out.println((500*K>=X)?"Yes":"No");
    }
}

// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase


Measured memory_bytes: 20564
#include <iostream>
using namespace std;
int n, k;
int a[110];
bool vis[100100][2];
bool dp[100100][2];
bool check (int x, int p) {
	if (x < 0) return true;
	if (vis[x][p]) return dp[x][p];
	vis[x][p] = true;
	for (int i=0; i<n; i++) {
		if (!check(x-a[i], !p)) dp[x][p] = true;
	}
	return dp[x][p];
}
int main () {
	cin >> n >> k;
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	if (check(k, 0)) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
}

Measured memory_bytes: 11788
#include <iostream>
#include <vector>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for(auto &&c : v)
        std::cin >> c;
    
    int max = v[1] - v[0];
    int cur = v[0];
    for(int i=1; i<n; i+=1){
        if(v[i] - cur > max){
            max = v[i] - cur;
        }
        cur = (v[i] < cur) ? v[i] : cur;
    }  
    std::cout << max << std::endl;
}


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

long long fact(int x){
	if(x==0)return 1ll;
	return fact(x-1)*x;
}
long long comb(int x, int y){
	long long ret=1ll;
	for(int i = 1;i <= y;i ++){
		ret=ret*(x+1-i)/i;
	}
	return ret;
}
int main(){
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	vector <long long> v(n);
	for(auto&i:v)
		scanf("%lld", &i);
	sort(v.begin(), v.end());
	long double sum=0.0l;
	for(int i = n;i > n-a;i --){
		sum+=v[i-1];
	}
	printf("%.10Lf\n", sum/a);
	if(v[n-a]!=v[n-1]){//must pick a
		printf("%lld\n", comb(count(v.begin(), v.end(), v[n-a]),count(v.begin()+(n-a), v.end(), v[n-a])));
	}else{//can pick any number
		long long ans=0ll;
		for(int i = a;i <= b;i ++){
			if(v[n-i]!=v[n-1])
				break;
			ans+=comb(count(v.begin(), v.end(), v.back()), i);
		}
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n,d; cin>>n>>d;
  vector<vector<int>> v(n, vector<int>(d));
  rep(i,n){
    rep(j,d) {
      cin>>v[i][j];
    }
  }
  int ans = 0;
  for (int i=0; i<n-1; i++) {
    for (int j=i+1; j<n; j++) {
      int norm = 0;
      for (int k=0; k<d; k++){
        int diff = abs(v[i][k] - v[j][k]);
        norm += diff * diff;
      }

      bool flag = false;
      for (int k=0; k<=norm; ++k) {
        if (k*k == norm) flag = true;
      }
      if (flag) ++ans;
    }
  }
  cout << ans << endl;
}


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

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

typedef long long ll;
 
int N, M, Q;
vector<int> a,b,c,d;

long dfs(vector<int> A, int index, int num){
    if(N == index){
        long score = 0;
        for(int i=0; i<Q; i++){
            if(A[b[i]-1] - A[a[i]-1] == c[i]){
                score += d[i];
                //cout << d[i] << endl;
            }
        }
        return score;
    }

    long score = 0;
    for(int i=num; i<=M; i++){
        A[index] = i;
        score = max(dfs(A, index+1, i), score);
    }
    return score;
}

int main() {
    cin>>N>>M>>Q;
    rep(i, Q){
        int w,x,y,z;
        cin>>w>>x>>y>>z;
        a.push_back(w);
        b.push_back(x);
        c.push_back(y);
        d.push_back(z);
    }

    vector<int> A(N, 1);
    long ans = dfs(A, 0, 1);
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define T(x,y) (Num(x)-Num(x-(y))-Num(y))
using namespace std;
int n,a[1000010],tag=1,ans;
char c[1000010];
int Num(int x){
	int ret=0;
	for(int i=2;i<=x;i<<=1)ret+=x/i;
	return ret;
}
int main(){
	scanf("%d%s",&n,c+1);
	for(int i=1;i<n;++i)a[i]=abs(c[i]-c[i+1]),tag&=(a[i]!=1);
	--n;
	if(tag){
		for(int i=1;i<=n;++i)if(a[i])ans^=!T(n-1,n-i);
		return putchar(ans?'2':'0'),0;
	}
	for(int i=1;i<=n;++i)if(a[i]==1)ans^=!T(n-1,n-i);
	return putchar(ans?'1':'0'),0;
	return 0;
}

Measured memory_bytes: 5120
import math

N = int(input())
A = list(map(int, input().split()))

B = [{} for _ in range(N+1)]


for i in range(1,N+1):
  if i == 1:
    B[1][0] = 0
    B[1][1] = A[0]
  elif i == 2:
    B[2][1] = max(A[0],A[1])
    if N % 2 == 1:
      B[2][0] = 0
  else:
    if N % 2 == 0:
      for j in range(math.ceil((i-1)/2),(i+1)//2+1):
        m1 = B[i-2][j-1]+A[i-1] if j-1 in B[i-2] else -float('inf')
        m2 = B[i-1][j] if j in B[i-1] else -float('inf')
        B[i][j] = max(m1,m2)
    else:
      for j in range(math.ceil((i-2)/2),(i+1)//2+1):
        m1 = B[i-2][j-1]+A[i-1] if j-1 in B[i-2] else -float('inf')
        m2 = B[i-1][j] if j in B[i-1] else -float('inf')
        B[i][j] = max(m1,m2)
      

print(B[N][N//2])


Measured memory_bytes: 140756
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
double dist(int x1, int y1, int x2, int y2) {
    return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }
    double ans = 0.0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            ans += dist(x[i], y[i], x[j], y[j]);
        }
    }
    printf("%.9f\n", (ans * 2) / N);
    
    return 0;
}


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

int const mod = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);

	int x = 0;
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ans += (long long)x * A[i] % mod;
		x = (x + A[i]) % mod;
	}

	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3972
//#include "bits\stdc++.h"
#include <iostream>

using namespace std;
typedef long long LL;

int main()
{
    int a, b;

    cin >> a >> b;

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

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <string,string> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

int tx[] = {0,1,1,1,0,-1,-1,-1};
int ty[] = {-1,-1,0,1,1,1,0,-1};

bool isMatch(const P& p1,const P& p2){
	//p1:deny or permit
	for(int i=0;i<8;i++){
		
		if(p1.first[i] != '?' && p2.first[i] != '?'){
			if(p1.first[i] != p2.first[i]) return false;
		}

		if(p1.second[i] != '?' && p2.second[i] != '?'){
			if(p1.second[i] != p2.second[i]) return false;
		}
	}

	return true;
}

class Output{
public:
	string from;
	string to;
	string msg;
	Output(string _from, string _to , string _msg){
		from = _from;
		to = _to;
		msg = _msg;
	}
};

class Rule{
public:
	string from;
	string to;
	int filter;
	int priority;
	Rule(string _from, string _to ,int _f, int _p){
		from = _from;
		to = _to;
		filter = _f;
		priority = _p;
	}
};

int main(){
	int n,m;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && m==0) break;
		vector<Rule> r;
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			if(str == "permit"){
				string from,to;
				cin >> from >> to;
				r.push_back(Rule(from,to,1,i));
			}
			else{
				string from,to;
				cin >> from >> to;
				r.push_back(Rule(from,to,0,i));
			}
		}

		vector<Output> out;
		for(int i=0;i<m;i++){
			string from,to,msg;
			cin >> from >> to >> msg;

			for(int j=r.size()-1;j>=0;j--){
				if(isMatch(P(r[j].from,r[j].to),P(from,to))){
					if(r[j].filter == 1){
						out.push_back(Output(from,to,msg));
						break;
					}
					else{
						break;
					}
				}
			}
		}

		printf("%d\n",out.size());
		for(int i=0;i<out.size();i++){
			printf("%s %s %s\n",out[i].from.c_str(),out[i].to.c_str(),out[i].msg.c_str());
		}
	}
}

Measured memory_bytes: 1092
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &a[i]);
  }
  vector<bool> dp(2 * K + 1);
  dp[0] = false;
  for (int i = 0; i <= K; ++i)
  {
    for (int j = 0; j < N; ++j)
    {
      if (!dp[i + a[j]])
        dp[i + a[j]] = !dp[i];
    }
  }
  if (dp[K])
    cout << "First" << endl;
  else
    cout << "Second" << endl;

  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    getLine
    ts <- fmap read . words <$> getLine
    let sumts = sum ts
    m <- readLn
    ps <- replicateM m $ do
        [p, x] <- fmap read . words <$> getLine
        return (p, x)

    forM_ ps $ \(p, x) -> do
        let d = x - (ts !! (p - 1))
        print $ sumts + d

Measured memory_bytes: 1020
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int l[11];
    for (i = 0; i < n; i++)
        scanf("%d", &l[i]);
    int sum = 0;
    for (i = 0; i < n; i++)
        sum += l[i];
    for (i = 0; i < n; i++)
        if (sum <= 2 * l[i])
        {
            printf("No\n");
            return 0;
        }
    printf("Yes\n");
    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  for(int i=0;i<s.size();i++){
    s[i] += n;
    if(s[i] > 'Z'){
      s[i] -= 26;
    }
  }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    long long int k, n = 50;
    cin >> k;
    if (k == 0) {
        cout << "4" << endl;
        cout << "3 3 3 3" << endl;
        return 0;
    }
    vector<long long int> v(n, 0);
    for (int i = 0; i < n; i++) {
        v[i] = n - 1 + (k) / n;
    }
    k = (k) % n;
    for (int i = 0; i < k; i++) {
        int index = min_element(v.begin(), v.end()) - v.begin();
        v[index] += n;
        for (int j = 0; j < n; j++) {
            if (j != index) {
                v[j]--;
            }
        }
    }
    cout << n << endl;
    for (int i = 0; i < n; i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3520