akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
using namespace std;
bool isPrime[2000002];
set<int> tPrimes;
//klk joa
void Sieve() {
	for(int i = 2; i <= 1000000; i++) {
		if(!isPrime[i]) {
			if (i % 5 == 1)
				tPrimes.insert(i);
			for(int j = i + i; j <= 1000000; j += i) {
				isPrime[j] = true;
			}
		}
	}
}
int main() {
	Sieve();
    int n;
    cin >> n;
    int k = 0;
    for(auto x : tPrimes) {
		k++;
		cout << x << ' ';
		if (k == n)
			break;
	}
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) {return log(b) / log(a);}

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n), aa(n), bb(n), cc(n);
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	aa[0] = a[0];
	bb[0] = b[0];
	cc[0] = c[0];

	FOR(i, 1, n) {
		aa[i] = max(bb[i-1], cc[i - 1]) + a[i];
		bb[i] = max(cc[i - 1], aa[i - 1]) + b[i];
		cc[i] = max(aa[i - 1], bb[i - 1]) + c[i];
	}
	cout << max(aa[n - 1], max(bb[n - 1], cc[n - 1])) << endl;
}


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

#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define snd sd.ft
#define td sd.sd
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()

#define ninf -1000000000
#define pinf 1000000000

typedef long long int ll;
const ll MOD= 1e9+7;
typedef vector<pair<ll,ll> > vecpair;
typedef vector<pair<ll, pair<ll,ll> > > vecpair3;
typedef pair<ll, ll> pi;

//double mei ye line cout << fixed << setprecision(10); kam mei le

ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}

struct subset // disjoint set use subsets.claer and subsets.resize............
{
	int parent,sz;
};
vector< subset> subsets;
int find( int i)
{
    if (subsets[i].parent != i)
        subsets[i].parent = find(subsets[i].parent);

    return subsets[i].parent;
}
void uniona(int x, int y){
	if( x == y)
	return ;
    int xroot = find( x);
    int yroot = find( y);
    if (subsets[xroot].sz < subsets[yroot].sz){
        subsets[xroot].parent = yroot;
        subsets[yroot].sz += subsets[xroot].sz;
    }
    else{
        subsets[yroot].parent = xroot;
        subsets[xroot].sz += subsets[yroot].sz;
    }
}
//..............................

ll n;
ll A[100005],B[100005],C[100005],dp[100005][4];
ll solve(ll i,ll k)
{
	if(i>n)
	return 0;
	if(dp[i][k]!=-1)
	return dp[i][k];
	if(k!=1)
	{
		dp[i][k]=max(dp[i][k],A[i]+solve(i+1,1));
	}
	if(k!=2)
	{
		dp[i][k]=max(dp[i][k],B[i]+solve(i+1,2));
	}
	if(k!=3)
	{
		dp[i][k]=max(dp[i][k],C[i]+solve(i+1,3));
	}
	return dp[i][k];
}
int main()
{
	std:ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  cin >> n;
	for(int i=0;i<100005;i++)
		for(int j=0;j<4;j++)
			dp[i][j]=-1;
	for(int i=1;i<=n;i++)
	{
		cin >> A[i] >> B[i] >> C[i];
	}
	cout << solve(0,0);

	return 0;
}


Measured memory_bytes: 10368
#include<iostream>
using namespace std;
int main(void){
  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;
  if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}



Measured memory_bytes: 3096
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

  private static Map<String, Long> map = new HashMap<>();

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    scan.nextLine();

    for (int i = 0; i < N; i++) {
      String s = sortStr(scan.nextLine());
      counter(s);
    }
    long count = 0;
    for (Map.Entry<String, Long> entry : map.entrySet()) {
      long i = entry.getValue();
      count += i * (i + 1) / 2;
    }
    System.out.println(count);
  }

  private static String sortStr(String str) {
    byte[] b = str.getBytes();
    Arrays.sort(b);
    return new String(b, StandardCharsets.UTF_8);
  }

  private static void counter(String key) {
    if (map.computeIfPresent(key, (k, s) -> s + 1) == null) {
      map.put(key, 0L);
    }
  }

}


Measured memory_bytes: 112368
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
const ll MOD = 1000000007;
#define P pair<int, int>
using namespace std;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    vector<vector<int>> s(N + 1, vector<int>(0));
    UnionFind uf(N + 1);
    
    rep(i, 0, M){
        cin >> A.at(i) >> B.at(i);
        uf.unite(A.at(i), B.at(i));
        s.at(A.at(i)).push_back(B.at(i));
        s.at(B.at(i)).push_back(A.at(i));
    }
    
    int ans = 0;
    rep(i, 1, N + 1){
        int x = uf.size(i);
        ans = max(x, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 16820
#include<bits/stdc++.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==b+1||a==b*2||b==a+1||b==a-1||a==b)
    {
        printf("Yay!");
    }
    else
    {
        printf(":(");
    }
    return 0;   
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
  /**
   * main method.
   */
  public static void main(String[] args) throws IOException {
    InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
    BufferedReader in = new BufferedReader(reader);
    
    //支払うN円
    String line = in.readLine();
    int N = Integer.parseInt(line);	
    
    //１円硬貨の枚数
    line = in.readLine();
    int A = Integer.parseInt(line);	
    
    if ((N % 500) <= A) {
    	System.out.println("Yes");
    } else {
    	System.out.println("No");
    }
    
  }
}

Measured memory_bytes: 22996
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
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);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
using namespace std;
set<int> g;
void prime(int n)  
{
    while (n % 2 == 0)  
    {  
        g.insert(2);
        n = n/2;  
    } 
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
            g.insert(i);  
            n = n/i;  
        }  
    }  
 	  if (n > 2)  
    	g.insert(n);
}  
int solve()
{
	int n;	
	cin>>n;
	int cnt=0;
	prime(n);
	for(auto it=g.begin();it!=g.end();it++){
		int x=*it;
		int temp=*it;
		int raise=1;
		while(n%x==0){
			n/=x;
			++cnt;
			++raise;
			x=pow(temp,raise);
		}
	}
	cout<<cnt<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}

Measured memory_bytes: 4060
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int n, h, w, a, b, ans;

int main() {
    cin >> n >> h >> w;
    rep(i, n) {
        cin >> a >> b;
        if (a >= h && b >= w) ans++;
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(c)     for(bool p=1;p;p=next_permutation(ALL(c)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

ll dp[104][104][104];

int main() {
    ll A, B, C; cin >> A >> B >> C;
    fill((ll *)dp, (ll *)dp + 104 * 104 * 104, INF);
    dp[A][B][C] = 0;
    
    FOR(i, A, 100) FOR(j, B, 100) FOR(k, C, 100) {
        dp[i+2][j][k] = min(dp[i+2][j][k], dp[i][j][k] + 1);
        dp[i][j+2][k] = min(dp[i][j+2][k], dp[i][j][k] + 1);
        dp[i][j][k+2] = min(dp[i][j][k+2], dp[i][j][k] + 1);
        dp[i+1][j+1][k] = min(dp[i+1][j+1][k], dp[i][j][k] + 1);
        dp[i+1][j][k+1] = min(dp[i+1][j][k+1], dp[i][j][k] + 1);
        dp[i][j+1][k+1] = min(dp[i][j+1][k+1], dp[i][j][k] + 1);
    }
    
    ll ans = INF;
    FOR(i, max({A, B, C}), 100) ans = min(ans, dp[i][i][i]);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 9088
n,l = map(int, input().split())
a = list(map(int, input().split()))
MAX = 0
MAX_i = 0
for i in range(n-1):
  now = a[i] + a[i+1]
  if now > MAX:
    MAX = now
    MAX_i = i
if MAX >= l:
  print("Possible")
  for i in range(MAX_i):
    print(i+1)
  for i in range(n-MAX_i-1):
    print(n-i-1)
else:
  print("Impossible")

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
class rangefenwick{
	private:
		int n;
		vector<T>f1,f2;
		void add1(int p,T x){
			while(p<=n){
				f1[p]+=x;
				p+=(p&-p);
			}
		}
		void add2(int p,T x){
			while(p<=n){
				f2[p]+=x;
				p+=(p&-p);
			}
		}
		T sum1(int p){
			T x=T();
			while(p>0){
				x+=f1[p];
				p-=(p&-p);
			}
			return x;
		}
		T sum2(int p){
			T x=T();
			while(p>0){
				x+=f2[p];
				p-=(p&-p);
			}
			return x;
		}
	public:
		rangefenwick(int n):n(n),f1(n+1),f2(n+1){}
		void update(int l,int r,T x){
			add1(l,x);
			add1(r+1,-x);
			add2(l,x*(l-1));
			add2(r+1,-x*r);
		}
		void update(int p,T x){
			update(p,p,x);
		}
		T query(int p){
			return sum1(p)*p-sum2(p);
		}
		T query(int l,int r){
			return query(r)-query(l-1);
		}
};
int main(){
	int n,q;
	cin>>n>>q;
	rangefenwick<ll>f(n);
	while(q--){
		int o,s,t;
		cin>>o>>s>>t;
		if(o){
			cout<<f.query(s,t)<<"\n";
		}
		else{
			ll x;
			cin>>x;
			f.update(s,t,x);
		}
	}
}


Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
int main(){
    long h,w,n;
    cin >> h >> w >> n;
    long a[n];
    long b[n];
    for(int i=0;i<n;i++)cin >> a[i] >> b[i];
    map<pair<long,long>,bool>m;
    for(int i=0;i<n;i++){
        m[make_pair(a[i],b[i])] = true;
    }
    vector<long>ans(10,0);
    
    for(int i=0;i<n;i++){
        long y = a[i];
        long x = b[i];
        for(int j = 0;j<9;j++){
            int cnt = 0;
            int xx = j%3;
            int yy = j/3;
            bool chk = true;
            for(long xxx = 0;xxx<3;xxx++){
                if(x-xx+xxx <= 0)chk = false;
                if(x-xx+xxx >w)chk=false;
                for(long yyy=0;yyy<3;yyy++){
                    if(y-yy+yyy <= 0)chk = false;
                    if(y-yy+yyy > h)chk=false;

                    // cout << x-xx+xxx<<" "<<y-yy+yyy << "  ";

                    if(m[make_pair(y-yy+yyy,x-xx+xxx)])cnt++;
                    
                }
                // cout<<endl;
            }
            // cout<<chk<<cnt<<endl;
            if(chk)ans[cnt]++;
        }
        // cout << endl;
    }
    long zero = (h-2)*(w-2);
    for(int i=1;i<=9;i++){
        ans[i]/=i;
        zero -= ans[i];
    }
    ans[0] = zero;
    for(int i=0;i<=9;i++)cout<<ans[i]<<endl;
    
}

Measured memory_bytes: 158080
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] H = new int[N];
        int Max = 0;
        int count = 0;

        for(int i =0; i<N; i++){
            if(i==0){
                H[i] = sc.nextInt();
                Max = H[i];
                count ++;
            }else{
                H[i] = sc.nextInt();
                Max = Math.max(Max, H[i]);
                if(H[i]>=Max){
                    count++;
                }
            }
        }
        System.out.println(count);


    }
}

Measured memory_bytes: 26800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

#define MAX_DIST 1LL<<50
#define NMAX 3000
#define MMAX 5200

vector<ll> dist(NMAX,0);
bool negative[NMAX] = {false,};
vector<ll> a(MMAX);
vector<ll> b(MMAX);
vector<ll> c(MMAX);

void bellmanford(ll start, ll v, ll e, ll p){
    for(int i = 0; i < NMAX; i++){
        dist[i] = MAX_DIST;
    }
    dist[start] = 0;

    for(int i = 0; i < v-1; i++){
        for(int j = 0; j < e; j++){
            if(dist[a[j]] == MAX_DIST){continue;}
            if(dist[b[j]] > dist[a[j]] + c[j] + p){
                dist[b[j]] = dist[a[j]] + c[j] + p;
            }
        }
    }
    for(int i = 0; i < v; i++){
        for(int j = 0; j < e; j++){
            if(dist[a[j]] == MAX_DIST){continue;}
            if(dist[b[j]] > dist[a[j]] + c[j] + p){
                dist[b[j]] = dist[a[j]] + c[j] + p;
                negative[b[j]] = true;
            }
            if(negative[a[j]]){
                negative[b[j]] = true;
            }
        }
    }
}


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


    for(int i = 0; i < m; i++){
        ll ta, tb, tc;
        cin >> ta >> tb >> tc;
        ta--; tb--;
        a[i] = ta;
        b[i] = tb;
        c[i] = -tc;
    }

    bellmanford(0, n, m, p);
    ll ans = -dist[n-1];
    if(negative[n-1]){cout << -1 << endl;}
    else{cout << max(ans, 0LL) << endl;}

    return 0;

}


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

using namespace std;

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

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,d;
int x[12][12];

int main(){
    cin>>n>>d;
    REP(i,n)REP(j,d)cin>>x[i][j];
    int ans = 0;
    REP(i,n)REP(j,i){
        int d2 = 0;
        REP(k,d){
            int dd = x[i][k]-x[j][k];
            d2 += dd*dd;
        }
        REP(i,400)if(i*i==d2){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
require 'set'
include Math

loop do
	n = gets.to_i
	break if n == 0

	events = []
	stars = (0..n-1).map do |i|
		s = gets.split.map(&:to_f)
		events << [s[-2] / s[-1], i]
		s
	end
	
	(0..n-1).to_a.combination(2) do |s1, s2|
		px1, py1, pz1, vx1, vy1, vz1, r1, vr1 = stars[s1]
		px2, py2, pz2, vx2, vy2, vz2, r2, vr2 = stars[s2]
		dvx = vx1 - vx2
		dvy = vy1 - vy2
		dvz = vz1 - vz2
		dpx = px1 - px2
		dpy = py1 - py2
		dpz = pz1 - pz2
		sr = r1 + r2
		svr = vr1 + vr2
		a = dvx ** 2 + dvy ** 2 + dvz ** 2 - svr ** 2
		b = 2 * (dvx * dpx + dvy * dpy + dvz * dpz + sr * svr)
		c = dpx ** 2 + dpy ** 2 + dpz ** 2 - sr ** 2
		d = b ** 2 - 4 * a * c
		next if d <= 0

		t = (-b - sqrt(d)) / (2 * a)
		events << [t, s1, s2] if t > 0
		t = (-b + sqrt(d)) / (2 * a)
		events << [t, s1, s2] if t > 0
	end
	
	events.sort_by!(&:first)

	vanished = Set.new	
	vanish_time = []
	events.each do |t, s1, s2|
		if !s2
			next if vanished.include?(s1)
			vanished << s1
			vanish_time[s1] = t
		else
			next if vanished.include?(s1)
			next if vanished.include?(s2)
			vanished << s1
			vanished << s2
			vanish_time[s1] = t
			vanish_time[s2] = t
		end
	end	
	puts vanish_time.map {|f| sprintf("%.9f", f)}
end

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

int main() {
  int64_t H;
  cin >> H;

  int64_t t = 0; // Hを割れる回数

  while(H>1){
    H = H/2;
    t++;
  }

  int64_t result = 1;
  int64_t tmp;

  for(int i = 0; i < t; i++){
    if(i == 0){
      tmp = 2;
    } else {
     tmp *= 2;
    }
    result += tmp;
  }
  
  
  cout << result << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
char s[500005];
vector <P> table[20];

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

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> q;
        for(int j=0;j<q;j++){
            cin >> a >> b;
            a--;
            table[i].pb(P(a, b));
        }
    }
    ans = 0;
    for(ll bit = 0;bit < (1ll << n);bit ++){
        bool dame = false;
        ll true_count = 0;
        for(int i=0;i<n;i++){
            if(!((bit >> i) & 1))continue;
            true_count ++;
            for(int j=0;j<table[i].size();j++){
                ll person = table[i][j].first;

                ll content = table[i][j].second;
                if(content != ((bit >> person) & 1)){
                    dame = true;
                }
            }
        }

        if(!dame){
            ans = max(true_count , ans);
        }
    }
    p(ans);

    return 0;
}
 

Measured memory_bytes: 26880
#include<stdio.h>
#include <math.h>
void main(void)
{
  double a,b,h,m;
  long double rad;
  long double ressult;
  scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
  rad=(h*30.0+(m/2)-m*6.0);
  rad*=(M_PI/180.0);
  ressult=a*a+b*b-2.0*a*b*cos(rad);
  printf("%.20lf\n",sqrt(ressult));
}


Measured memory_bytes: 2600
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;

    int count = 0;

    int n = N;

    while(n > 0) {
        count += n % 10;
        n /= 10;
    }

    cerr << count << endl;

    if(N % count) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();
        int N, T;
        {int[] a = r.ii(); N = a[0]; T = a[1];}
        int[] t = r.ii();
        long sum = T;
        for(int i = 0; i < N-1; i++){
            int interval = t[i+1]-t[i];
            sum += T < interval ? T : interval;     
        }
        println(sum);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 44500
n, K = map(int, input().split())

p = 1/n

ans = 0
for result in range(1, n+1):
    # result = 1,2,3
    k = K
    k /= result
    cnt = 0
    while k > 1:
        k /= 2
        cnt += 1
    ans += p * (0.5)**cnt
print(ans)

Measured memory_bytes: 9312
N = int(input())
A = [[] for _ in range(N)]
for i in range(N):
  m = int(input())
  for _ in range(m):
    x,y = map(int,input().split())
    x -= 1
    A[i].append((x,y))
ans = 0

for i in range(1<<N):
  d = [0]*N
  for j in range(N):
    if (i>>j&1):
      d[j] = 1
  flag = True
  for j in range(N):
    if d[j]:
      for k,l in A[j]:
        if d[k] == l:
          continue
        if d[k] != l:
          flag = False
      if not flag:
        break
  if flag:
    ans = max(ans,sum(d))
print(ans)

Measured memory_bytes: 3064
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, X, *L = map(int, read().split())
    
    ans = 1
    d = 0
    for l in L:
        d += l
        if d <= X:
            ans += 1
        else:
            break
    
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
def extgcd(a,b):
    a0,b0=a,b
    x0,y0=1,0
    x1,y1=0,1

    while b0!=0:
        q = a0 // b0
        r = a0 % b0

        a0,b0=b0,r
        x0,x1=x1,x0-q*x1
        y0,y1=y1,y0-q*y1

    return a0,x0,y0

def mo(x,m):
    return (m+x%m)%m

def inv(a,m):
    g,x,y=extgcd(a,m)
    ans=mo(x,m)
    return ans

def combi_mod(n,k,m):
    mi=min(k,n-k)
    invlist = [1]
    for i in range(1, mi + 1):
        temp = inv(i, m)
        invlist.append(temp)
    ans=1

    for i in range(1,mi+1):
        ans=(ans*(n+1-i)*invlist[i])%m
    ans = ans % m
    return ans

X,Y=map(int,input().split())
mod=1000000007

if (2*Y-X)%3!=0 or (2*X-Y)%3!=0:
    print(0)
    exit()

a=(2*X-Y)//3
b=(2*Y-X)//3

if a<0 or b<0:
    print(0)
    exit()

ans=combi_mod(a+b,a,mod)
print(ans)



Measured memory_bytes: 16292
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+10, mod= 998244353;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,m,a,b;
	cin>>n>>m>>a>>b;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if( ( i<n-b&&j<a ) || ( i>=n-b&&j>=a ) ) cout<<"1";
			else cout<<"0";
		}cout<<"\n";
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
}
const int INF = 1e9; 
const int MAX_N = 105;
int N; 
struct Graph { 
	vector<int> E[MAX_N]; 
	int fa[MAX_N], deg[MAX_N]; 
	void init() { for (int i = 1; i <= N; i++) fa[i] = deg[i] = 0, E[i].clear(); } 
	void Add_Edge(int u, int v) { E[u].push_back(v), ++deg[v]; } 
	void dfs(int x) { 
		for (int v : E[x]) 
			if (v != fa[x]) fa[v] = x, dfs(v); 
	} 
} A, B, C; 
bool check(int x) { return A.fa[x] == B.fa[x]; } 
int solve() { 
	int res = 0; 
	for (int i = 1; i <= N; i++) res += !check(i); 
	C.init(); 
	for (int i = 1; i <= N; i++) { 
		if (check(i)) {
			if (!check(A.fa[i])) return INF; 
			else continue; 
		} 
		if (!check(A.fa[i])) C.Add_Edge(i, A.fa[i]); 
		if (!check(B.fa[i])) C.Add_Edge(B.fa[i], i); 
	} 
	queue<int> que; int siz = 0;
	for (int i = 1; i <= N; i++) if (!C.deg[i]) que.push(i); 
	while (!que.empty()) {
		int x = que.front(); que.pop(), ++siz; 
		for (int v : C.E[x]) 
			if (!--C.deg[v]) que.push(v); 
	} 
	return siz == N ? res : INF; 
} 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif 
	int T = gi(); 
	while (T--) { 
		N = gi(); 
		for (int i = 1; i < N; i++) { 
			int u = gi(), v = gi(); 
			A.Add_Edge(u, v), A.Add_Edge(v, u); 
		} 
		for (int i = 1; i < N; i++) { 
			int u = gi(), v = gi(); 
			B.Add_Edge(u, v), B.Add_Edge(v, u); 
		} 
		int ans = INF; 
		for (int i = 1; i <= N; i++) { 
			A.fa[i] = B.fa[i] = 0; 
			A.dfs(i), B.dfs(i), ans = min(ans, solve()); 
			if (A.deg[i] != 1) continue; 
			for (int j = 1; j <= N; j++) {
				if (i == j) continue; 
				A.fa[j] = i, A.dfs(j), A.fa[i] = 0, ans = min(ans, solve() + 1); 
			} 
		} 
		printf("%d\n", ans == INF ? -1 : ans); 
		A.init(), B.init(), C.init(); 
	} 
    return 0; 
} 

Measured memory_bytes: 3732
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int[] x = ReadIntArray();
	Array.Sort(x);
	WriteLine(Solve(x));
    }

    static bool isEven(int x)
    {
	return ((x&1) == 0);
    }
    
    static int Solve(int[] x)
    {
	int d0 = x[2]-x[0];
	int d1 = x[2]-x[1];

	if (isEven(d0) && isEven(d1)) // even, even
	{
	    return d0/2 + d1/2;
	}
	else if (isEven(d0)) // even, odd
	{
	    x[0] += 1;
	    x[2] += 1;
	}
	else if (isEven(d1)) // odd, even
	{
	    x[1] += 1;
	    x[2] += 1;
	}
	else // odd, odd
	{
	    x[0] += 1;
	    x[1] += 1;
	}
	return 1 + Solve(x);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
void print (int n , char ch){
	
	for(int i= 0 ; i < n ; ++i)putchar(ch);
}
int main() {
	int x1 , y1 , x2 , y2;
	cin>>x1>>y1>>x2>>y2;
	int dx = x2 - x1 , dy = y2 - y1;
	print(dy,'U');
	print(dx,'R');
	print(dy,'D');
	print(dx,'L');
	cout<<'L';
	print(dy+1,'U');
	print(dx+1,'R');
	cout<<'D'<<'R';
	print(dy+1,'D');
	print(dx+1,'L');
	cout<<'U';
	return 0;
}

Measured memory_bytes: 256
f = True
while True:
    n = int(input())
    if n == 0:
        break
    T = []
    for i in range(n):
        name,w,l,d = list(input().split())
        T.append((name,i,int(w)*3+int(d)))
    if f: f = False
    else: print()
    for i in sorted(T, key = lambda x:(-x[2],x[1])):
        print(i[0],",",i[2],sep="")


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  vector<int> S(N+1, 0);
  for(int i = 0; i < N; i++) {
    S[i+1] = (S[i] + A[i])%K;
  }
  map<int, int> mp;
  queue<int> q;
  long long ans = 0;
  for(int i = 0; i < N+1; i++) {
    ans += mp[S[i]];
    mp[S[i]]++;
    q.push(S[i]);
    if(q.size() == K) {
      mp[q.front()]--;
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    char c;
    cin >> c;
    char ans = c + 1;
    co(ans);
    return 0;
}

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

int main(){
	
	ios::sync_with_stdio(false);
	
	int k, v[3];
	cin >> v[0] >> v[1] >> v[2];
	cin >> k;
	
	sort(begin(v), end(v)); 	
	
	while (k--) v[2] = v[2]*2;

	cout << v[0] + v[1] + v[2] <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string s;
    cin >> s;

    int num = 0;
    rep (i, s.size())
    {
        num = num * 10 + (s[i] - '0');
        num %= 9;
    }

    cout << (num == 0 ? "Yes\n" : "No\n");
    return 0;
}



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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   100007
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/





ll a[N];


int main()
{
    ll a[N],n,c,x=0,y,i,j;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {

            x+=(a[i]*a[j]);

        }
    }
    cout<<x<<endl;
    return 0;

}
































Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long int64;
const int MOD = 1e9 + 7;
class EFlatten {
 public:
  vector<pair<int, int> > factors(int n) {
    vector<pair<int, int> > ans;
    for (int i = 2; i * i <= n; ++i) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      if (cnt)ans.push_back({i, cnt});
    }
    if (n > 1)ans.push_back({n, 1});
    return ans;
  }
  int64 fastPow(int64 e, int x) {
    if (x == 0)return 1;
    int64 ans = fastPow(e, x >> 1);
    ans = (ans * ans) % MOD;
    if (x & 1)ans = (ans * e) % MOD;
    return ans;
  }
  void solveOne(std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    vector<int> v(n);

    for (int &e : v) in >> e;

    map<int, int> fs;

    for (int e : v) {
      auto fss = factors(e);
      for (auto p : fss)fs[p.first] = max(fs[p.first], p.second);
    }
    int64 lcm = 1;
    for (auto p : fs) {
      lcm = lcm * fastPow(p.first, p.second);
      lcm %= MOD;
    }
    int64 ans = 0;
    for (int e : v) {
      ans += (fastPow(e, MOD - 2) * lcm);
      ans %= MOD;
    }
    out << ans << endl;
  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  EFlatten solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 768
N , K = map(int,input().split())
d_list = []
A_list = []
for k1 in range(K):
    d_list+=[int(input())]
    A_list+=[[a_i for a_i in map(int,input().split())]]

S=[0 for i in range(N)]
for k2 in range(K):
    for i in A_list[k2]:
        S[i-1]+=1

counter = 0
for i in range(N):
    if S[i]==0:
        counter+=1
print(counter)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7,N=2e5+5;
char s[N];int n,a[N];
signed main(){
	cin>>n>>(s+1);
	n<<=1;
	int res=0;
	for(int i=1;i<=n;++i){
		a[i]=(res&1)^(s[i]=='W');
		res+=(a[i]==1?-1:1);
		if(res<0) return puts("0"),0;
	}
	if(res) return puts("0"),0;
	int ans=1;
	for(int i=1;i<=n;++i){
		if(a[i]==1) ans=ans*res%mod,res--;
		else ++res;
	}
	for(int i=1;i<=n/2;++i)
		ans=ans*i%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5368
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int y = n % 10;
	if (y == 2 || y == 4 || y == 5 || y == 7 || y == 9)
	{
		cout << "hon" << endl;
	}
	else if (y == 0 || y == 1 || y == 6 || y == 8)
	{
		cout << "pon" << endl;
	}
	else if (y == 3)
	{
		cout << "bon" << endl;
	}
	return 0;
}

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

int main() {
  string A;
  cin >> A;
  if ((A.at(2) == A.at(3)) && (A.at(4) == A.at(5))) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
int N;
ll X,Y;
ll p[100010] = {0},r[100010] = {0};

void init(ll N){
	for(int i=1;i<=N;++i) p[i] = i;
}

int root(ll a){
	if(p[a] == a) return a;
	return (p[a] = root(p[a]));
}

bool is_same_set(ll a,ll b){
	return root(a) == root(b);
}

void unite(ll a, ll b){
	a = root(a);
	b = root(b);
	if(a==b) return;
	if(r[a]<r[b]){
		p[a] = b;
	}else{
		p[b] = a;
		if(r[a] == r[b]) r[a]++;
	}
}

struct edge{ll u,v,cost;};

bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}

edge es[400010];

int main(){
	cin >> N;
	vector<PP> v(N+1),u(N+1);
	for(int i=1;i<=N;i++){
		cin >> X >> Y;
		v[i] = PP(X,P(Y,i));
		u[i] = PP(Y,P(X,i));
	}
	ll ans = 0;
	sort(v.begin()+1,v.end());
	sort(u.begin()+1,u.end());
	int j = 0;
	for(int i=1;i<N;i++){
		es[j].u = v[i].second.second; es[j].v = v[i+1].second.second; es[j].cost = min(abs(v[i].first-v[i+1].first),abs(v[i].second.first-v[i+1].second.first)); j++;
		es[j].u = v[i+1].second.second; es[j].v = v[i].second.second; es[j].cost = min(abs(v[i].first-v[i+1].first),abs(v[i].second.first-v[i+1].second.first)); j++;
		es[j].u = u[i].second.second; es[j].v = u[i+1].second.second; es[j].cost = min(abs(u[i].first-u[i+1].first),abs(u[i].second.first-u[i+1].second.first)); j++;
		es[j].u = u[i+1].second.second; es[j].v = u[i].second.second; es[j].cost = min(abs(u[i].first-u[i+1].first),abs(u[i].second.first-u[i+1].second.first)); j++;
	}
	sort(es,es+j-1,comp);
	init(N);
	for(int i=0;i<j;i++){
		edge e = es[i];
		if(!is_same_set(e.u,e.v)){
			unite(e.u,e.v);
			ans += e.cost;
//			cout << e.u << " " << e.v << " " << e.cost << endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 15872
import heapq
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
q = []
s = set()
heapq.heappush(q,(-a[0]-b[0]-c[0],0,0,0))

for i in range(k):
    ans,ai,bi,ci = heapq.heappop(q)
    print(-ans)
    if ai < x-1 and ((ai+1, bi, ci) not in s):
        heapq.heappush(q, (-a[ai+1]-b[bi]-c[ci],ai+1,bi,ci))
        s.add((ai+1, bi, ci))
    if bi < y-1 and ((ai, bi+1, ci) not in s):
        heapq.heappush(q, (-a[ai]-b[bi+1]-c[ci],ai,bi+1,ci))
        s.add((ai, bi+1, ci))
    if ci < z-1 and ((ai, bi, ci+1) not in s):
        heapq.heappush(q, (-a[ai]-b[bi]-c[ci+1],ai,bi,ci+1))
        s.add((ai, bi, ci+1))

Measured memory_bytes: 4976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

const ll MAX = 1000000000000001;
ll N;

void solve()
{
	string ans;
	while(N){
		N--;
		ans += char('a'+(N%26));
		N /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	solve();
	return 0;
}

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

const int MAX_WEIGHT = 10000;
const int MAX_NUM_PACKAGES = 100000;
int w[MAX_NUM_PACKAGES], n, k;

int check(long long p) {
  long long s {0}, i {0};
  for (int j = 0; j < k; j++) {
    s = 0;
    while (s + w[i] <= p && i < n) {
      s += w[i];
      i++;
    }
  }
  return i;
}

long long solve() {
  long long left {0};
  long long right {MAX_WEIGHT * MAX_NUM_PACKAGES};
  long long mid {0};
  while (right - left > 1) {
    mid = (left + right) / 2;
    int v = check(mid);
    if (v >= n) {
      right = mid;
    } else {
      left = mid;
    }
  }
  return right;
}


int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> w[i];
  cout << solve() << endl;
}



Measured memory_bytes: 3520
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;
  
public class Main {  
	static Map<List<Integer>, Integer> dp;
	static int n;
	static int min = Integer.MAX_VALUE;
    public static void main(String[] args) throws IOException { 
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
		StringTokenizer st = new StringTokenizer(br.readLine()); 
		int k = Integer.parseInt(st.nextToken());
		int n = Integer.parseInt(st.nextToken());
		if (500 * k >= n) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21204
import numpy as np
import sys
input = sys.stdin.readline

N, W = map(int, input().split())

dp = np.zeros((N+1,W+1), int)
r = W+1
for i in range(1,N+1):
    w, v = map(int, input().split())
    dp[i,:w] = dp[i-1,:w]
    dp[i,w:r] = np.maximum(dp[i-1,w:r], dp[i-1,:r-w]+v)
    
print(dp[N,W])

Measured memory_bytes: 92244
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  ll x, ans = 0;
  cin >> x;
  ll n = 100;
  while (n < x) {
    n = n * 1.01;
    ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
	double x, max = 0.0, min;
	scanf("%lf",&x);
	max = x ;
	min = x ;
	while(scanf("%lf", &x) != EOF){
		if(max<x) max = x;
		if(min>x) min = x;
	}
	
	printf("%f\n", max-min);
	
	return 0;
}

Measured memory_bytes: 648