akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

vll graph[200000] = {};
lli score[200000] = {};
lli answer[200000] = {};

void dfs(int i, int s) {

	s += score[i];
	answer[i] = s;

	for (int j = 0; j < graph[i].size(); j++)
		if (answer[graph[i][j]] == -1)
			dfs(graph[i][j], s);

	return;
}


int main(void) {

	lli n, k, ans = 1;
	cin >> n >> k;

	for (lli i = k; i <= n; i++) {

		//0 kara N

		lli t = (i * n) - (i * (i - 1)) + 1;
		t %= mod197;

		//cout << t << endl;

		ans += t;
		ans %= mod197;

	}

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

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

int main() {
	long long N; std::cin >> N;
	std::vector<char> C(N);
	for (auto& r : C)
		std::cin >> r;
	long long count_r{ 0 };
	for (auto i{ 0 }; i < N; ++i) {
		if (C.at(i) == 'R')
			++count_r;
	}
	long long count_right_r{ 0 };
	for (auto i{ 0 }; i < count_r; ++i) {
		if (C.at(i) == 'R')
			++count_right_r;
	}
	std::cout << count_r - count_right_r << std::endl;

	return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<tuple<ll, ll, char>> v(n);
  for (int i = 0; i < n; i++) {
    ll x, y;
    char u;
    cin >> x >> y >> u;
    v.at(i) = make_tuple(x, y, u);
  }
  
  sort(v.begin(), v.end());
  
  ll ans = 1e18;
  
  { // R and L
    vector<vector<ll>> stock(200001);
    for (int i = 0; i < n; i++) {
      auto [nowx, nowy, way] = v.at(i);
      if (way == 'R') {
        stock.at(nowy).emplace_back(nowx);
      }
      else if (way == 'L') {
        if (stock.at(nowy).size() > 0) {
          ans = min(ans, (nowx - stock.at(nowy).back()) * 5);
        }
      }
    }
  }
  
  { // U and D
    vector<vector<ll>> stock(200001);
    for (int i = 0; i < n; i++) {
      auto [nowx, nowy, way] = v.at(i);
      if (way == 'U') {
        stock.at(nowx).emplace_back(nowy);
      }
      else if (way == 'D') {
        if (stock.at(nowx).size() > 0) {
          ans = min(ans, (nowy - stock.at(nowx).back()) * 5);
        }
      }
    }
  }
  
  { // (U and L) or (R and D)
    map<ll, ll> ul, rd;
    for (int i = 0; i < n; i++) {
      auto [nowx, nowy, way] = v.at(i);
      if (way == 'U') {
        ul[nowy - nowx] = nowx;
      }
      else if (way == 'L') {
        if (ul.find(nowy - nowx) != ul.end()) ans = min(ans, (nowx - ul[nowy - nowx]) * 10);
      }
      else if (way == 'R') {
        rd[nowy - nowx] = nowx;
      }
      else {
        if (rd.find(nowy - nowx) != rd.end()) ans = min(ans, (nowx - rd[nowy - nowx]) * 10);
      }
    }
  }
  
  { // (R and U) or (D and L)
    map<ll, ll> ru, dl;
    for (int i = 0; i < n; i++) {
      auto [nowx, nowy, way] = v.at(i);
      if (way == 'R') {
        ru[nowy + nowx] = nowx;
      }
      else if (way == 'U') {
        if (ru.find(nowy + nowx) != ru.end()) ans = min(ans, (nowx - ru[nowy + nowx]) * 10);
      }
      else if (way == 'D') {
        dl[nowy + nowx] = nowx;
      }
      else {
        if (dl.find(nowy + nowx) != dl.end()) ans = min(ans, (nowx - dl[nowy + nowx]) * 10);
      }
    }
  }
  
  if (ans == 1e18) cout << "SAFE\n";
  else cout << ans << '\n';
}

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

int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int sum=0;
  
  if(a>=k)
  {
    sum+=k;
  }
  else
  {
    sum+=a;
    k-=a;
    if(b>=k)
    {
      sum+=0;
    }
    else
    {
      sum+=0;
      k-=b;
      sum=sum+(-1)*k;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3596
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]

import math

dist = 0
for i in range(N-1):
  for j in range(i+1, N):
    dist = dist + math.sqrt((x[i][0]-x[j][0])**2 + (x[i][1]-x[j][1])**2)

ans = dist * 2 / N
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define ll long long
int  main(){
    ll n;
    scanf("%lld",&n);
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0)
            ans += i;
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
  int a, b;
  string op;
  cin >> a >> op >> b;
  int ans = 0;
  // ここにプログラムを追記
  if(op == "+") {
    ans = a + b;
  } else {
    ans = a - b;
  }
  cout << ans << endl;
  return 0;
}


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

while N[0]>=0:
    N[2]= N[2] - N[1]
    if N[2]<=0:
        print("Yes")
        break
    N[0] = N[0]-N[3]
    if N[0] <=0:
        print("No")
        break

Measured memory_bytes: 9184
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int x,n;
  cin>>x>>n;
  map<int,int> mp;
  int p;
  rep(i,n){
    cin>>p;
    mp[p]=1;
  }

  int dist=1e9,ans=x;
  for(int i=110;i>=-100;i--){
    if(mp[i]!=1 && abs(x-i)<=dist){
      dist=abs(x-i);
      ans=i;
    }
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    string input;
    cin >> n;
    cin >> input;

    long r_count = count(input.cbegin(), input.cend(), 'R');
    long b_count = count(input.cbegin(), input.cend(), 'B');

    if (r_count > b_count) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
from math import floor,ceil,sqrt,factorial,log
from heapq import heapify, heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from decimal import Decimal
inf = float('inf')
mod = 1000000007

h1, m1, h2, m2, k = map(int, input().split())

t1 = h1 * 60 + m1
t2 = h2 * 60 + m2

if t2 > t1:
    ans = t2 - t1 - k
    if ans < 0:
        ans = 0
    print(ans)
else:
    ans = 24 - t1 + t1
    if ans < 0:
        ans = 0
    print(ans)

Measured memory_bytes: 71008
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
L=[A,B]

S=0
for i in range(N):
    K=sum(L[0][0:i+1])+sum(L[1][i:N])
    S=max(S,K)
print(S)

Measured memory_bytes: 8940
#include<bits/stdc++.h>
#define line cout<<endl;
#define space cout<<" ";
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI 3.141592653589793238
typedef long long int ll;

using namespace std;

const int N = 1e9+7;

vector<ll> a(100005);
vector<ll> b(100005);
vector<ll> c(100005);

ll dp[100005][4];


ll findans(ll n,ll k)
{
    if(n==0)
        return 0;

    if(dp[n][k]!=-1)
    {
        return dp[n][k];
    }

    if(k==0)
    {
        return dp[n][k] =  max(a[n]+findans(n-1,1),max(b[n]+findans(n-1,2),c[n]+findans(n-1,3)));
    }
    else if(k==1)
    {
        return dp[n][k] = max(b[n]+findans(n-1,2),c[n]+findans(n-1,3));
    }
    else if(k==2)
    {
        return dp[n][k] = max(a[n]+findans(n-1,1),c[n]+findans(n-1,3));
    }
    else if(k==3)
    {
        return dp[n][k] = max(a[n]+findans(n-1,1),b[n]+findans(n-1,2));
    }

}

void solve()
{
    memset(dp,-1,sizeof(dp));
    ll n;
    cin>>n;

    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }

    ll ans = findans(n,ll(0));
    cout<<ans;
}


int main()
{
   ll t;
   t = 1;
  // cin>>t;

   while(t--)
   {
       solve();
       cout<<endl;
   }




}















Measured memory_bytes: 16380
#include<stdio.h>
  
typedef struct{
  char m[2];
  int n;
  int o;
} Card;
  
int partition(Card *A, int p, int r){
  int i, j, a;
  Card tmp;
  a = A[r].n;
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].n<=a){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}
 
void quickSort(Card *A, int p, int r){
  int q; 
  if(p<r){
    q=partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

int main(){
  Card A[100000];
  int i,j,nn,v=0;
  
  scanf("%d",&nn);
  for(i=0;i<nn;i++){
    scanf("%s %d",A[i].m, &A[i].n);
    A[i].o = i + 1;
  }
  quickSort(A, 0, nn-1);
  for(i=0;i<nn;i++){
    if(A[i].o>A[i+1].o&&A[i].n==A[i+1].n){
      v++;
      break;
    }
  }
  
  if(v==0) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<nn;i++) printf("%s %d\n",A[i].m, A[i].n);
  return 0;
  
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

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

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

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

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

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int n; cin>>n;
	int a[n]; for(int &i:a) cin>>i;
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
#define dbg(x) cout << #x << " = " << (x) << endl;
const ll MOD = 1000000007;
const ll INF = 0x7fffffffffffffff;

template <typename T>
void print(T v, int l = 0, int r = 5){
    for(int i = l;i < r;i++) cout << v[i] << " ";
    cout << endl;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    
    ll a, b;
    cin >> a >> b;
    ll gcd = __gcd(a, b);
    cout << a * b/gcd << endl;
}

Measured memory_bytes: 256
N,C=map(int,input().split())
STC=[list(map(int,input().split())) for _ in range(N)]

S=[[] for _ in range(10**5+1)]
T=[[] for _ in range(10**5+1)]

for s,t,c in STC:
    S[s].append(c)
    T[t].append(c)

used=set()
ans=0
for i in range(10**5+1):
    start=set()
    finish=set()
    for s in S[i]:
        start.add(s)
    for t in T[i]:
        finish.add(t)
    ans=max(ans,len(used)+len(start-finish))
    used=used-finish|start
print(ans)

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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    int cnt0 = 0;
    int cnt1 = 0;

    for(int i = 0; i < N; i++) {
        if(i % 2 == 0) {
            if(S[i] != '0') {
                cnt0++;
            }
        }
        else {
            if(S[i] != '1') {
                cnt0++;
            }
        }
    }

    for(int i = 0; i < N; i++) {
        if(i % 2 == 0) {
            if(S[i] != '1') {
                cnt1++;
            }
        }
        else {
            if(S[i] != '0') {
                cnt1++;
            }
        }
    }

    if(cnt0 < cnt1) {
        cout << cnt0;
    }
    else {
        cout << cnt1;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 512
N,K=map(int,input().split())
if K==0: print(N**2);exit(0)
ans=(N-K)*(N-K+1)//2
for b in range(K+1, N):
  n=(N-b+1)//b
  ans+=(n)*(b-K)
  if n*b+b-1!=N:
    if N%b>=K:
      ans+=N%b-K+1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n, m; cin >> n >> m;
    string ans(n, '-');

    if(n == 1) {
        rep(i, m) {
            int j, c; cin >> j >> c;
            j--;
            if(ans[j] != '-' && ans[j] != c+'0') { cout << -1 << endl; return 0; }
            ans[j] = c+'0';
        }
        if(ans[0] == '-') cout << 0 << endl;
        else cout << ans << endl;
        return 0;
    } 

    rep(i, m) {
        int j, c; cin >> j >> c;
        j--;
        if(j==0 && c==0) { cout << -1 << endl; return 0; }
        if(ans[j] != '-' && ans[j] != c+'0') { cout << -1 << endl; return 0; }
        ans[j] = c+'0';
    }

    rep(i, n) if(ans[i]=='-') {
        if(i==0) ans[i] = '1';
        else ans[i] = '0';
    }

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

Measured memory_bytes: 256
// http://arc076.contest.atcoder.jp/submissions/1375863 の改造
// クラスカル法からプリム法に変更

#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<ll, int> pii; // (cost, to)

const int MAX_N = 100000;
int n;
vector<pii> G[MAX_N];

// http://algoogle.hadrori.jp/algorithm/prim.html
ll prim() {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    vector<bool> used(n, false);
    que.push(pii(0,0));
    ll ret = 0;
    while(!que.empty()) {
        ll cost = que.top().first;
        int v = que.top().second;
        que.pop();
        if(used[v]) {
            continue;
        }
        used[v] = true;
        ret += cost;
        for (auto& e : G[v]) {
            que.push(pii(e.first, e.second));
        }
    }
    return ret;
}

void add_edge(int i, int j, int cost) {
    G[i].push_back(pii(cost, j));
    G[j].push_back(pii(cost, i));
}

int main() {
    cin >> n;
    vector<pair<ll, ll>> ps(n);
    for (auto& p : ps)
        cin >> p.first >> p.second;
 
    // xord[i] x座標がi番目に小さいpointのid
    // yord[i] y座標がi番目に小さいpointのid
    vector<int> xord(n), yord(n);
    for (int i = 0; i < n; i++) {
        xord[i] = i;
        yord[i] = i;
    }
    sort(xord.begin(), xord.end(), [&](int a, int b) { return ps[a].first < ps[b].first; });
    sort(yord.begin(), yord.end(), [&](int a, int b) { return ps[a].second < ps[b].second; });
 
    for (int i = 1; i < n; i++) {
        add_edge(xord[i], xord[i - 1], ps[xord[i]].first  - ps[xord[i - 1]].first);
        add_edge(yord[i], yord[i - 1], ps[yord[i]].second - ps[yord[i - 1]].second);
    }
    cout << prim() << endl;
    return 0;
}

Measured memory_bytes: 19824
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC156B - Digitsx

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        int cnt = 0;
        while(true) {
            n = n / k;
            ++cnt;
            if (n == 0) break;
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; cin>>n>>k;
	vector<int> h(n);
	for (int i=0; i<n; i++)
		cin>>h[i];
	sort(h.rbegin(), h.rend());
	ll ret=0;
	for (int i=k; i<n; i++)
		ret+=h[i];
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;cin>>n;
    cout<<n/3<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>N;
    vec d(N, 0);
    rep(i,N){
        cin>>A>>B;
        d[i] = (A == B);
    }
    bool flag = false;
    rep(i, N - 2){
        if(d[i] && d[i + 1] && d[i + 2]) flag = true;
    }
    cout<<(flag ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3628
#include <iostream>

static const int g_sec_in_hour = 3600;
static const int g_sec_in_min = 60;

int main()
{
	int in_seconds;
	std::cin >> in_seconds;
	int hours = in_seconds / g_sec_in_hour;
	int remain_min = in_seconds % g_sec_in_hour;
	int min = remain_min / g_sec_in_min;
	int sec = remain_min % g_sec_in_min;

	std::cout << hours << ":" << min << ":" << sec << "\n";
    return 0;
}




Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    sort(a, a+n);
    rep(i, q){
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", upper_bound(a, a+n, r)-lower_bound(a, a+n, l));
    }
}


Measured memory_bytes: 3620
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val graph = Graph(n)

    repeat(n - 1) {
        val (u, v, w) = readLine()!!.split(' ').map { it.toInt() }
        graph.add(u, v, w)
    }

    graph.solve().forEach {
        println(it)
    }
}

private class Graph(val n: Int) {

    private val adjacencyMap = mutableMapOf<Int, MutableMap<Int, Int>>()

    fun add(u: Int, v: Int, w: Int) {
        if (!adjacencyMap.containsKey(u)) {
            adjacencyMap[u] = mutableMapOf()
        }
        adjacencyMap[u]!![v] = w

        if (!adjacencyMap.containsKey(v)) {
            adjacencyMap[v] = mutableMapOf()
        }
        adjacencyMap[v]!![u] = w
    }

    fun solve(): List<Int> {

        val visited = mutableMapOf<Int, Int>()
        val queue: Deque<Int> = ArrayDeque<Int>()

        queue.push(1)
        visited[1] = 0

        while (queue.isNotEmpty()) {
            val e = queue.pop()

            adjacencyMap[e]!!.forEach {
                if (visited.containsKey(it.key)) {
                    return@forEach
                }

                queue.add(it.key)
                visited[it.key] = visited[e]!! + it.value
            }
        }

        return (1..n).map {
            if (visited[it]!! % 2 == 0) 0 else 1
        }
    }

}

Measured memory_bytes: 128776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> ii;


int main(){
  int N;cin>>N;
  vll A;
  for (int i=0;i<N;++i){
    ll a;cin>>a;A.push_back(a);
  }

  vll LG(N), RG(N);
  LG[0]=A[0];
  RG[N-1]=A[N-1];
  for (int i=0;i<N-1;++i){
    LG[i+1]=__gcd(LG[i], A[i+1]);
  }
  for (int i=N-1;i>=1;--i){
    RG[i-1]=__gcd(RG[i],A[i-1]);
  }

  ll ans=RG[1];
  if (N==2){
    ans=max(A[0], A[1]);
    cout << ans << endl;
    return 0;
  }
  
  for (int i=1;i<N-1;++i){
    ll tmp=__gcd(LG[i-1], RG[i+1]);
    ans=max(ans, tmp);
  }
  ans=max(ans, LG[N-2]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2804
// D - String Formation
#include <bits/stdc++.h>
using namespace std;

int main(){
	string F,B; int Q; cin>>B>>Q;
	while(Q--){
		int t; cin>>t;
		if(t==1) swap(F,B);
		else{
			int f; string c; cin>>f>>c;
			if(f==1) F += c;
			else B += c;
		}
	}
	reverse(F.begin(), F.end());
	cout<< F+B <<endl;
}

Measured memory_bytes: 1312
def f(words):
	seen = set([words[0]])
	p = words[0]
	for w in words[1:]:
		if w in seen or p[-1] != w[0]: return False
		p = w
		seen.add(w)
	return True

print 'Yes' if f([raw_input() for _ in range(int(raw_input()))]) else 'No'


Measured memory_bytes: 85168
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int x,y;
	cin >> x >> y;
	int a,b;
	if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
		a = 1;
	}
	else if(x == 2){
		a = 2;
	}
	else{
		a = 3;
	}

	if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
		b = 1;
	}
	else if(y == 2){
		b = 2;
	}
	else{
		b = 3;
	}

	if (a == b){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

ll dp[N][N][2] ;
int a[N] ;

ll calc(int l , int r , bool c){

		
	if (l == r){
		if (c)
			return -a[l];
		else 
			return a[l] ; 
	}
	
	ll &ret = dp[l][r][c] ; 
	if (ret != -1)
		return ret ; 
	
	if (!c)
		ret = max(1ll * calc(l+1 , r , !c)+a[l] , 1ll * calc(l , r-1 , !c)+a[r]) ; 
	else 
		ret = min(1ll * calc(l+1 , r , !c)-a[l] , 1ll * calc(l , r-1 , !c)-a[r]) ; 
	
	return ret ; 
}
int main() {
	int n ; 
	scanf("%d" , &n) ; 
	
	memset(dp , -1 , sizeof dp) ; 
	
	for (int i = 0 ; i<n ; ++i) {
		scanf("%d" , &a[i]) ; 
	}
	ll ans = calc(0 , n-1 , 0) ; 
	printf("%lld" , ans) ; 
	return 0;
}

Measured memory_bytes: 141056
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
struct SegmentTree
{
  int sz;
  vector< tree< pair< int, int >, null_type, less< pair< int, int > >, rb_tree_tag, tree_order_statistics_node_update > > seg;
 
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.resize(2 * sz - 1);
  }
 
  int query(int a, int b, int lower, int upper, int k, int l, int r)
  {
    if(a >= r || b <= l) {
      return (0);
    } else if(a <= l && r <= b) {
      return (seg[k].order_of_key(make_pair(upper, -1)) - seg[k].order_of_key(make_pair(lower, -1)));
    } else {
      return (query(a, b, lower, upper, 2 * k + 1, l, (l + r) >> 1) + query(a, b, lower, upper, 2 * k + 2, (l + r) >> 1, r));
    }
  }
 
  int query(int a, int b, int l, int r)
  {
    return (query(a, b, l, r, 0, 0, sz));
  }
 
  void set(int k, int x, bool type)
  {
    int pv = k;
    k += sz - 1;
    if(type) seg[k].insert({x, pv});
    else seg[k].erase({x, pv});
    while(k > 0) {
      k = (k - 1) >> 1;
      if(type) seg[k].insert({x, pv});
      else seg[k].erase({x, pv});
    }
  }
};
 
int main()
{
  int H, W, T, Q;
  scanf("%d %d %d %d", &H, &W, &T, &Q);
 
  SegmentTree tree1(H), tree2(H);
  queue< tuple< int, int, int > > addev;
  int add = 0;
 
  for(int i = 0; i < Q; i++) {
    int t, c, h, w;
    scanf("%d %d %d %d", &t, &c, &h, &w);
 
    while(!addev.empty() && get< 0 >(addev.front()) <= t) {
      int x, y, z;
      tie(x, y, z) = addev.front();
      addev.pop();
      tree1.set(y, z, false);
      tree2.set(y, z, true);
      --add;
    }
 
    if(c == 0) {
      addev.emplace(t + T, --h, --w);
      tree1.set(h, w, true);
      ++add;
    } else if(c == 1) {
      tree2.set(--h, --w, false);
    } else {
      int h2, w2;
      scanf("%d %d", &h2, &w2);
      --h, --w;
      printf("%d %d\n", tree2.query(h, h2, w, w2), tree1.query(h, h2, w, w2));
    }
  }
}

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

int main() {
  int N; //個数
  int D; //距離
  int k = 0;//個数
  
  cin >> N >> D;//個数と距離の入力
  
  for (int i = 0; i < N; i ++){
  	int x;//x座標
    int y;//y座標
    cin >> x >> y;//ｘとyの座標の入力
    if(sqrt(pow(x,2) + pow(y,2)) <= D){
    	k = k + 1;
    }
  }
  cout << k;
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>

using namespace std;

int main() {
    long long int N, A, B, ans;
    cin >> N >> A >> B;
    if (A > B || (N == 1 && A != B)) {
        ans = 0;
    }
    else if (A == B) {
        ans = 1;
    }
    else {
        if (N == 2) {
            ans = B - A + 1;
        }
        else {
            ans = B * (N - 1) + A - A * (N - 1) - B + 1;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] l = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int H = l[0];
        int W = l[1];
        int A = l[2];
        int B = l[3];


        for (int i = 0; i < B; i++)
        {
            Console.Write(new string('0', A));
            Console.WriteLine(new string('1', W - A));
        }

        for (int i = 0; i < H - B; i++)
        {
            Console.Write(new string('1', A));
            Console.WriteLine(new string('0', W - A));
        }

    }
}


Measured memory_bytes: 16340
import java.util.*;
import java.lang.*;
import java.io.*;
 
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	     Scanner SC=new Scanner(System.in);
	     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	     PrintWriter pw=new PrintWriter(System.out);
	     int t=0;
	     
	     /*if(SC.hasNext())
	     t=SC.nextInt();
	     
	     for(int i=0;i<t;i++)
	     {
	          
	     }*/
	     
	     int a,b,c,d;
	     a=SC.nextInt();
	     b=SC.nextInt();
	     c=SC.nextInt();
	     d=SC.nextInt();
	     
	     
	     int f=(a*b);
	     int g=(c*d);
	     
	     int ans=(int)(Math.max(f,g));
	     pw.println(ans);
	     
	     //code for reading n long from bfreader in one line
	    /* String inp2=br.readLine();
	         for(int j=0;j<n-1;j++)
     	    {
     	         arr[j]=Long.parseLong(inp2.substring(0,inp2.indexOf(" ")));
     	         inp2=inp2.substring(inp2.indexOf(" ")+1);
     	    }
     	    arr[(int)n-1]=Long.parseLong(inp2);*/
	     
	     pw.close();     
		
}
}

Measured memory_bytes: 35636
from functools import reduce

n,a,b = map(lambda x:int(x),input().split(" "))

ans = 0
for ni in range(a,n+1):
    if ni <= 9 :
        if a <= ni and ni <= b:
            ans += ni
    else:
        add_each_dig = reduce(lambda x, y: int(x) + int(y), str(ni) )
        if a <= add_each_dig and add_each_dig <= b:
            ans += ni

print(ans)

Measured memory_bytes: 9420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int a;
	cin >>a;
	cout << a * (a + 1) / 2 << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,j,n,m,cn;
  char c,s[5]={'S','H','C','D','\0'};
  static int card[4][13];
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    scanf("%c %d\n",&c,&m);
    for(j=0;j<4;j++)
      if(s[j]==c)
        card[j][m-1]=1;
  }
  for(i=0;i<4;i++)
    for(j=0;j<13;j++)
      if(card[i][j]==0)
        printf("%c %d\n",s[i],j+1);
  return 0;
}


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

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

vector<edge> edges;

int uf_par[10000];
int uf_rank[10000];

void uf_init(int uf_n){
	for(int i = 0;i < uf_n;i++){
		uf_par[i] = i;
		uf_rank[i] = 0;
	}
}

int uf_find(int uf_x){
	if(uf_par[uf_x] == uf_x) return uf_x;
	else return uf_par[uf_x] = uf_find(uf_par[uf_x]);
}

void uf_unite(int uf_x,int uf_y){
	uf_x = uf_find(uf_x);
	uf_y = uf_find(uf_y);
	if(uf_x == uf_y) return;
	if(uf_rank[uf_x] < uf_rank[uf_y]){
		uf_par[uf_x] = uf_y;
	}else{
		uf_par[uf_y] = uf_x;
		if(uf_rank[uf_x] == uf_rank[uf_y]) uf_rank[uf_x]++;
	}
}

bool uf_same(int uf_x,int uf_y){
	return uf_find(uf_x) == uf_find(uf_y);
}

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

int kruskal(int V){
	sort(edges.begin(),edges.end(),krus_comp);
	uf_init(V);
	int krus_res = 0;
	for(int i = 0;i < edges.size();i++){
		edge krus_e = edges[i];
		if(!uf_same(krus_e.u,krus_e.v)){
			uf_unite(krus_e.u,krus_e.v);
			krus_res += krus_e.cost;
		}
	}
	return krus_res;
}

int main(){
	int V,E;
	cin >> V >> E;
	for(int i = 0;i < E;i++){
		int a,b,c;
		cin >> a >> b >> c;
		edges.push_back({a,b,c});
	}
	cout << kruskal(V) << endl;
	return 0;
}

Measured memory_bytes: 4484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010],b[100010],c[100010];
priority_queue<ll,vector<ll>,greater<ll> > q;
int main()
{
    ios::sync_with_stdio(false);
    ll x,y,A,B,C;cin>>x>>y>>A>>B>>C;
    for(ll i=0;i<A;i++) cin>>a[i];
    for(ll i=0;i<B;i++) cin>>b[i];
    for(ll i=0;i<C;i++) cin>>c[i];
    sort(a,a+A);
    sort(b,b+B);
    sort(c,c+C);
    reverse(a,a+A);
    reverse(b,b+B);
    reverse(c,c+C);
    for(ll i=0;i<x;i++) q.push(a[i]);
    for(ll i=0;i<y;i++) q.push(b[i]);
    for(ll i=0;i<C;i++)
    {
        if(q.top()<c[i])
        {
            q.pop();
            q.push(c[i]);
        }
    }
    ll ans=0;
    while(q.size())
    {
        ans+=q.top();
        q.pop();
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 4852
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N=scan.nextLine();
        if(N.charAt(0)=='7'||N.charAt(1)=='7'||N.charAt(2)=='7'){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define int long long
bool sE(const pair<int,int> &a,const pair<int,int> &b)
{
    return(a.second>b.second);
}
int32_t main()
{
    int n,m; cin>>n>>m;
    map<int,int>a;
    for(int i=0;i<n;i++)
    {
        int temp; cin>>temp; temp*=-1;
        a[temp]++;
    }
    for(int i=0;i<m;i++)
    {
        int b,c; cin>>b>>c;
        c*=-1;
        a[c]+=b;
    }
    int ans=0,pos=0;
    for(auto i=a.begin();i!=a.end();i++)
    {
        int mul=i->second;
        int num=i->first;
        pos+=mul;
        //cout<<mul<<endl;
        ans+=mul*num;
        if(pos>=n)
        {
            ans-=num*(pos-n);
            break;
        }
    }
    cout<<ans*-1;
    return 0;
}


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

using namespace std;
using ll=long long int;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll T1,T2,A1,A2,B1,B2;
  cin>>T1>>T2>>A1>>A2>>B1>>B2;
  B1-=A1;
  B2-=A2;
  if((B1>0&&B2>0)||(B1<0&&B2<0))cout<<0<<endl;
  else if(abs(B1*T1)>abs(B2*T2))cout<<0<<endl;
  else if(abs(B1*T1)==abs(B2*T2))cout<<"infinity"<<endl;
  else{
    ll D=abs(B2*T2)-abs(B1*T1);
    ll ans=2*((abs(B1*T1))/D)+1;
    if(abs(B1*T1)%D==0)ans--;
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

#define ROUND		4			/* 小数点以下第ROUND位を四捨五入 */

/*--- 四捨五入 ---*/
double round(double num)
{
	int i, cmp;
	for (i = 0; i < ROUND; i++)		/* 四捨五入する値を１の位にもってくる */
		num *= 10;
	
	cmp = (int)num;					/* int型にキャストしたものをcmpに代入 */
	while (cmp > 10)				/* 一桁の数にして */
		cmp %= 10;
	
	if (cmp >= 5)					/* その値が5より大きければ*/
		num += 1;					/* numに１を加えて */
	
	for(i = 0; i < ROUND; i++)		/* 元の数に戻す */
		num /= 10;
	
	return num;
}


int main(void)
{
	double a, b, c, d, e, f;			/* ax + by = c, dx + ey = fの連立方程式 */
	double ans_x, ans_y;				/* xとyの答え */
	
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
	
		ans_y = (d*c - a*f) / (d*b - a*e);
		ans_x = (c - b*ans_y) / a;
	
		ans_y = round(ans_y);
		ans_x = round(ans_x);
	
		printf("%.3f %.3f\n", ans_x, ans_y);
	}
	
	return 0;
}

Measured memory_bytes: 652
a=(0 1 9 30 76 141 267 400 624 885 1249 1590 2208 2689 3411 4248 5248 6081 7485 8530 10248 11889 13687 15228 17988 20053 22569 25242 28588 31053 35463 38284 42540 46581 50893 55362 61824 65857 71247 76884 84388 89349 97881 103342 111528 120141 128047 134580 146316 154177 164817 174438 185836 194157 207927 218812 233268 245277 257857 268182 288216 299257 313635 330204 347836 362973 383709 397042 416448 434025 456967 471948 499740 515581 536073 559758 583960 604833 633651 652216 683712 709065 734233 754734 793188 818917 846603 874512 909496 933081 977145 1006126 1041504 1073385 1106467 1138536 1187112 1215145 1255101 1295142 1342852 1373253 1422195 1453816 1502376 1553361 1595437 1629570 1691292 1726717 1782111 1827492 1887772 1925853 1986837 2033674 2089776 2145333 2197483 2246640 2332104 2379085 2434833 2490534 2554600 2609625 2693919 2742052 2813988 2875245 2952085 3003306 3096024 3157249 3224511 3306240 3388576 3444609 3533637 3591322 3693924 3767085 3842623 3912324 4027884 4102093 4181949 4270422 4361548 4427853 4548003 4616104 4718640 4812789 4918561 5003286 5131848 5205481 5299011 5392008 5521384 5610705 5739009 5818390 5930196 6052893 6156139 6239472 6402720 6493681 6623853 6741078 6864016 6953457 7094451 7215016 7359936 7475145 7593865 7689630 7886244 7984165 8130747 8253888 8403448 8523897 8684853 8802826 8949612 9105537 9267595 9376656 9574704 9686065 9827097 9997134 10174780 10290813 10493367 10611772 10813692)
read k
echo ${a[k]}

Measured memory_bytes: 3864
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 5e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, d; cin >> n >> d;
	vector<vector<ll>>x(n, vector<ll>(d, 0));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = i + 1; j < n; j++) {
			ll kek = 0;
			for (ll k = 0; k < d; k++) {
				kek += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			if (sqrtl(kek) == roundl(sqrtl(kek))) {
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
}
/*

*/

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
import heapq

n = int(input())
A = list(map(int, input().split()))
L = []
R = []
C = [0]*(n+1)
D = [0]*(n+1)
s = 0
t = 0
for i in range(n):
  a, b = A[i], -A[3*n-1-i]
  s += a
  t += b
  heapq.heappush(L, a)
  heapq.heappush(R, b)
C[0] = s
D[-1] = t
for i in range(n):
  a, b = A[n+i], -A[2*n-1-i]
  h = heapq.heappop(L)
  s -= h
  h = max(h, a)
  s += h
  heapq.heappush(L, h)
  C[i+1] = s
  g = heapq.heappop(R)
  t -= g
  g = max(g, b)
  t += g
  heapq.heappush(R, g)
  D[n-1-i] = t
ans = -float("inf")
for c, d in zip(C, D):
  ans = max(ans, c+d)
print(ans)

Measured memory_bytes: 43020
#include <bits/stdc++.h>
using namespace std;
#define _                             \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define deb(x) cerr << "\n" \
					<< #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
						<< #x << "=" << x << "\n" \
						<< #y << "=" << y << "\n";
typedef long long int ll;

class segment_tree
{

public:
	vector<ll> tree;
	segment_tree(ll n)
	{
		tree.resize(3 * n + 1);
	}

	// void build(ll a[],int n)
	// {

	// }

	void update(ll node, ll start, ll end, ll ind, ll val)
	{
		if (start == end)
		{
			tree[node] = max(tree[node], val);
		}
		else
		{
			int mid = (start + end) / 2;

			if (ind >= start && ind <= mid)
				update(2 * node + 1, start, mid, ind, val);

			if (ind >= mid + 1 && ind <= end)
				update(2 * node + 2, mid + 1, end, ind, val);

			tree[node] = max(tree[2 * node + 1], tree[2 * node + 2]);
		}
	}

	ll query(ll node, ll start, ll end, ll l, ll r)
	{

		//completely inside

		if (start >= l && end <= r)
			return tree[node];

		ll mid = (start + end) / 2;

		if (r < start || end < l)
		{
			return -1;
		}

		return max(query(2 * node + 1, start, mid, l, r), query(2 * node + 2, mid + 1, end, l, r));
	}
};

int main()
{
	_
		ll n;
	cin >> n;

	ll h[n + 1], a[n + 1];

	segment_tree s(n);

	for (ll i = 0; i < n; i++)
		cin >> h[i];
	//		h[i] = 1 + i;
	for (ll i = 0; i < n; i++)
		cin >> a[i];
	//	a[i] = 1;

	for (ll i = 0; i < n; i++)
	{

		ll maxm = s.query(0, 0, n, 0, h[i] - 1);

		s.update(0, 0, n, h[i], a[i] + maxm);
	}
	// for (ll i : s.tree)
	// 	cout << i << " ";
	cout << s.query(0, 0, n, 0, n);
}


Measured memory_bytes: 8064
S = str(input())

if S == "SUN":
    cmd = 0
elif S == "MON":
    cmd = 1
elif S == "TUE":
    cmd = 2
elif S == "WED":
    cmd = 3
elif S == "THU":
    cmd = 4
elif S == "FRI":
    cmd = 5
elif S == "SAT":
    cmd = 6

print(7-cmd)

Measured memory_bytes: 3060
from collections import deque

def check(st,en,ed):
    ed[st-1][en-1] -= 1
    ed[en-1][st-1] -= 1
    cnt = [0] * n
    q = deque()
    q.append(st)
    cnt[st-1] += 1
    while q:
        now = q.popleft()
        if ed[now-1][en-1] == 1:
            ed[st-1][en-1] += 1
            ed[en-1][st-1] += 1
            return False
        for r in range(n):
            if ed[now-1][r] == 1 and cnt[r] == 0:
                q.append(r+1)
                cnt[r] += 1
    ed[st-1][en-1] += 1
    ed[en-1][st-1] += 1
    return True

n, m = map(int, input().split())

edge = [[0] * n for _ in range(n)] 

nodes = []

for i in range(m):
    a, b = map(int, input().split())
    nodes.append((a,b))
    edge[a-1][b-1] += 1
    edge[b-1][a-1] += 1

ans = 0 
for node in nodes:
    a,b = node[0], node[1]
    if check(a,b,edge):
        ans += 1

print(ans)

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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    ll r, d, x;
    scanf("%lld %lld %lld", &r, &d, &x);
    for(int i = 0; i < 10; i++){
        x = r*x-d;
        printf("%lld\n", x);
    }
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
N,_=gets.chomp.split(" ").map{|n| n.to_i}
S=gets.chomp.split("")
T=gets.chomp.split("")
size = S.size
for i in 0..(size-1)
	if(S[i..(size-1)] == T[0..(size-1-i)])
		puts size-1-i+1 + 2*(i)
		exit(0)
	end
end
puts 2*size


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n;
    string s;
    cin >> n >> s;
    int x = 0;
    int max = 0;
    rep(i, n){
        if(s.at(i) == 'I'){
            x++;
        }else{
            x--;
        }
        if(x > max) max = x;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int main(){
	cin>>n;
	n%=10;
	if(n==3)  printf("bon\n");
	else if(n==0 || n==1 || n==6 || n==8)
		printf("pon\n");
	else  printf("hon\n");
	return 0;
}




Measured memory_bytes: 3556
trait Monoid {
    type T: Clone;
    fn id() -> Self::T;
    fn op(a: &Self::T, b: &Self::T) -> Self::T;
}

#[derive(Debug)]
struct SegmentTree<M: Monoid> {
    n: usize,
    vec: Vec<M::T>,
}

impl<M: Monoid> SegmentTree<M> {
    fn new(n: usize) -> Self {
        let n = n.next_power_of_two();
        SegmentTree {
            n: n,
            vec: vec![M::id().clone(); 2 * n - 1],
        }
    }

    // vec[k] = a
    fn update(&mut self, k: usize, a: M::T) {
        let mut k = k + self.n - 1;
        self.vec[k] = a;
        self.up(k);
    }

    // vec[k] = op(vec[k], a)
    fn add(&mut self, k: usize, a: M::T) {
        let mut k = k + self.n - 1;
        self.vec[k] = M::op(&self.vec[k], &a);
        self.up(k);
    }

    fn up(&mut self, mut k: usize) {
        while k > 0 {
            k = (k - 1) / 2;
            self.vec[k] = M::op(&self.vec[2 * k + 1], &self.vec[2 * k + 2]);
        }
    }

    fn query_sub(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> M::T {
        if r <= a || b <= l {
            M::id()
        } else if a <= l && r <= b {
            self.vec[k].clone()
        } else {
            M::op(
                &self.query_sub(a, b, k * 2 + 1, l, (l + r) / 2),
                &self.query_sub(a, b, k * 2 + 2, (l + r) / 2, r),
            )
        }
    }

    // op [a, b)
    fn query(&self, a: usize, b: usize) -> M::T {
        self.query_sub(a, b, 0, 0, self.n)
    }

    // vec[k]
    fn get(&self, k: usize) -> M::T {
        self.vec[k + self.n - 1].clone()
    }
}

struct SUM;
impl Monoid for SUM {
    type T = i64;
    fn id() -> Self::T {
        0_i64
    }
    fn op(a: &Self::T, b: &Self::T) -> Self::T {
        *a + *b
    }
}

use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let q: usize = read();
    let mut seg: SegmentTree<SUM> = SegmentTree::new(n);
    for _ in 0..q {
        let com: usize = read();
        let x: usize = read();
        let y: usize = read();
        if com == 0 {
            seg.add(x - 1, y as i64);
        } else {
            println!("{}", seg.query(x - 1, y));
        }
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}



Measured memory_bytes: 7072
#include<iostream>
#include<map>

using namespace std;

const int MAX_N = 100000;
const int MAX_V = 100000;
int N;
map<int, int> mp0, mp1;

int main(){
	for(int i = 1; i <= MAX_V; i++){
		mp0[i] = 0;
		mp1[i] = 0;
	}


	cin >> N;

	int m0, m1;
	for(int i = 0; i < N / 2; i++){
		cin >> m0 >> m1;
		mp0[m0]++;
		mp1[m1]++;
	}

	int max0 = 1;  //mp0で1番多いindex
	int maxx0 = 2;  //mp0で2番目に多いindex
	int max1 = 1;
	int maxx1 = 2;
	if(mp0[max0] < mp0[maxx0]) swap(max0, maxx0);
	if(mp1[max1] < mp1[maxx1]) swap(max1, maxx1);

	for(int i = 2; i <= MAX_V; i++){
		if(mp0[i] > mp0[max0]){
			maxx0 = max0;
			max0 = i;
		}else if(mp0[i] > mp0[maxx0]){
			maxx0 = i;
		}
	}
	for(int i = 2; i <= MAX_V; i++){
		if(mp1[i] > mp1[max1]){
			maxx1 = max1;
			max1 = i;
		}else if(mp1[i] > mp1[maxx1]){
			maxx1 = i;
		}
	}

	int ans;
	if(max0 == max1){
		//cout << "a" << endl;
		if(mp0[maxx0] > mp1[maxx1]){
			//cout << "b" << endl;
			ans = N - mp0[maxx0] - mp1[max1];
			cout << ans << endl;
		}else{
		/*	
			cout << "c" << endl;
			cout << "mp0[max0]" << mp0[max0] <<endl;
			cout << "mp1[maxx1]" << mp1[maxx1] <<endl;
			cout << "mp0[maxx0]" << mp0[maxx0] <<endl;
			cout << "mp1[max1]" << mp1[max1] <<endl;
			cout << "max0" << max0;
			cout << "maxx0" << maxx0;
		*/
			ans = N - mp0[max0] - mp1[maxx1];
			cout << ans << endl;
		}	
	}else{
		ans = N - mp0[max0] - mp1[max1];
		cout << ans << endl;
	}


	return 0;
}



Measured memory_bytes: 9600