akhauriyash/Code-Regression huggingface dataset:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
tenka1-2018 E
"""

from itertools import product
from itertools import combinations

h, w = map(int, input().split())
slili = [list(input()) for i in range(h)]

coinsetli = [set() for i in range(h+w)]
for i, j in product(range(h), range(w)):
    if slili[i][j] == '#':
        coinsetli[i+j+1].add(j-i)

jmin = -304
jmin2 = jmin+2


coinacumdictli = [[] for i in range(h+w)]
for i in range(1, h+w):
    tmp = 0
    tt = (i % 2) - 1
    for j in range(jmin+tt, 303, 2):
        if j in coinsetli[i]:
            tmp += 1
        coinacumdictli[i].append(tmp)


coinacumdictli2 = [[] for i in range(h+w)]
for i in range(1, h+w):
    tt = (i % 2) - 1
    for j in range(len(coinacumdictli[i])-1):
        coinacumdictli2[i].append(coinacumdictli[i][j]+coinacumdictli[i][j+1])


coinlili = [[] for i in range(len(coinsetli))]
for i in range(len(coinsetli)):
    tt = (i % 2) - 1

    def rescale(x):
        return (x-jmin2-tt)//2
    coinlili[i] = sorted(list(map(rescale, coinsetli[i])))


ansdouble = 0
for i in range(1, h+w):
    tt = (i % 2) - 1
    for x, y in combinations(coinlili[i], 2):
        j = 2*(y-x)
        imj = i-j
        ipj = i+j
        if imj >= 1:
            ansdouble += coinacumdictli2[imj][y] - coinacumdictli2[imj][x]
        if ipj <= h+w-1:
            ansdouble += coinacumdictli2[ipj][y] - coinacumdictli2[ipj][x]

# repeat after reversing along the vertical axis
for i in range(h):
    slili[i].reverse()

coinsetli = [set() for i in range(h+w)]
for i, j in product(range(h), range(w)):
    if slili[i][j] == '#':
        coinsetli[i+j+1].add(j-i)

jmin = -304
jmin2 = jmin+2

coinacumdictli = [[] for i in range(h+w)]
for i in range(1, h+w):
    tmp = 0
    tt = (i % 2) - 1
    for j in range(jmin+tt, 303, 2):
        if j in coinsetli[i]:
            tmp += 1
        coinacumdictli[i].append(tmp)


coinacumdictli2 = [[] for i in range(h+w)]
for i in range(1, h+w):
    tt = (i % 2) - 1
    for j in range(len(coinacumdictli[i])-1):
        coinacumdictli2[i].append(coinacumdictli[i][j]+coinacumdictli[i][j+1])

coinlili = [[] for i in range(len(coinsetli))]
for i in range(len(coinsetli)):
    tt = (i % 2) - 1

    def rescale(x):
        return (x-jmin2-tt)//2
    coinlili[i] = sorted(list(map(rescale, coinsetli[i])))


for i in range(1, h+w):
    tt = (i % 2) - 1
    for x, y in combinations(coinlili[i], 2):
        j = 2*(y-x)
        imj = i-j
        ipj = i+j
        if imj >= 1:
            ansdouble += coinacumdictli2[imj][y] - coinacumdictli2[imj][x]
        if ipj <= h+w-1:
            ansdouble += coinacumdictli2[ipj][y] - coinacumdictli2[ipj][x]

print(ansdouble//2)


Measured memory_bytes: 68444
N = int(input())
dp = [0 for i in range(200)]
for i in range(26):
    dp[4 * i] = 1
for i in range(150):
    if(dp[i] == 1):
        dp[i + 7] = 1
if(dp[N]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
char inp[6][6];
int k;
int f(int x,int y,char inp[6][6])
{
  int ans1=0;
  char temp[6][6];
  for(int i=0;i<6;i++) for(int j=0;j<6;j++) temp[i][j]=inp[i][j];
  for(int i=0;i<6;i++)
  {
    if((1<<i)&x)
    {
      for(int j=0;j<6;j++) temp[i][j]='0';
    }
  }
  for(int i=0;i<6;i++)
  {
    if((1<<i)&y)
    {
      for(int j=0;j<6;j++) temp[j][i]='0';
    }
  }
  for(int i=0;i<6;i++) for(int j=0;j<6;j++)
  {
    if(temp[i][j]=='#') ans1++;
  }
  if(ans1==k) return 1;
  return 0;
}
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int h,w,ans=0;
  cin>>h>>w>>k;
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>inp[i][j];
  for(int i=0;i<(1<<h);i++)
  {
    for(int j=0;j<(1<<w);j++)
    {
      ans+=f(i,j,inp);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

int H, W;
int main(void){
	cin >> H >> W;
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			string s;
			cin >> s;
			//cout << "[" << s << "]" << endl;
			if (s=="snuke"){
				cout << (char('A'+j)) << i+1 << endl;
			}
		}
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

#define ARC(i,a,b) for(int i=(a);i<(b);++i)
#define RC(i,n) ARC(i,0,n)

int main(){
	static int n, t, x = 0, y = 0, px, py;
	scanf("%d", &n);
	RC(i, n){
		px = x;
		py = y;
		scanf("%d%d%d", &t, &x, &y);
		if(t < x - px + y - py || (t - x - py + y - py) % 2){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let x: i64 = read();
    let a: i64 = read();
    let b: i64 = read();
    if b <= a {
	println!("delicious");
    }else if b-a <= x {
	println!("safe");
    }else {
	println!("dangerous");
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2*i+1;}

int main() {
  int H,i,A[MAX+1];

  cin >> H;
  for(i=1;i<=H;i++) cin >> A[i];

  for(i=1;i<=H;i++){
    cout << "node " << i << ": key = " << A[i] << ", ";
    if(parent(i) >= 1 ) cout << "parent key = " << A[parent(i)] << ", ";
    if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
    if(right(i) <=H) cout << "right key = " << A[right(i)] << ", ";
                                                 cout << endl;
                                                 }
  return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
char s[110];
char t[110];
char ans[220];

int main()
{
	scanf("%d\n", &n);
	scanf("%s\n", s);
	scanf("%s", t);
	
	int szA = 0;
	for (int i = 0 ; i < n ; i++){
		ans[szA] = s[i];
		szA++;
		ans[szA] = t[i];
		szA++;
	}
	
	ans[szA] = '\0';
	
	printf("%s\n", ans);
	

	return 0;
}


Measured memory_bytes: 128
from collections import deque
N, X, Y = map(int, input().split())
INF = N+1
q = deque()

def node_search(i):
    nodes = []
    if i < N and check[i+1] == 0:
        nodes.append(i+1)
    if i > 1 and check[i-1] == 0:
        nodes.append(i-1)
    if i == X and check[Y] == 0:
        nodes.append(Y)
    return nodes


cnt = [0]*N
for i in range(1, N):
    check = [0]*(N+1)
    dist = [INF] * (N + 1)
    dist[i] = 0
    q.append(i)
    d = 1
    while q:
        now_node = q.pop()
        check[now_node] = 1
        for next_node in node_search(now_node):
            dist[next_node] = min(dist[now_node]+1, dist[next_node])
            q.appendleft(next_node)


    for j in range(i+1, N+1):
        cnt[dist[j]] += 1

for i in range(1, N):
    print(cnt[i])


a = 0

Measured memory_bytes: 86364
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

struct Input {
  vecint c;
  vector<vecint> s;
};

int score(const Input& input, const vecint& t) {
  vecint last(26);
  int ans = 0;
  int d = size(input.s);
  REP(i,d) {
    ans += input.s[i][t[i]];
    last[t[i]] = i+1;
    REP(j,26) {
      ans -= input.c[j] * (i+1 - last[j]);
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int d;
  cin>>d;
  vecint c(26);
  for(auto&&e:c)cin>>e;
  vector s(d, vecint(26));
  for(auto&&l:s)for(auto&&e:l)cin>>e;
  vecint t(d);
  for(auto&&e:t){
    cin>>e;
    --e;
  }
  Input input {c, s};
  int current = score(input, t);
  vector<set<int>> vs(26);
  REP(i,26) {
    vs[i].insert(0);
    vs[i].insert(d+1);
  }
  REP(i,d) {
    vs[t[i]].insert(i+1);
  }
  int m;
  cin>>m;
  REP(i,m) {
    int d,q;
    cin>>d>>q;
    --q;
    {
      int old = t[d-1];
      auto itr = vs[old].lower_bound(d);
      current -= c[old] * (*next(itr) - d) * (d - *prev(itr));
      vs[old].erase(d);
      current -= s[d-1][old];
    }
    vs[q].insert(d);
    auto itr = vs[q].lower_bound(d);
    current += c[q] * (*next(itr) - d) * (d - *prev(itr));
    current += s[d-1][q];
    t[d-1] = q;
    cout<<current<<"\n";
  }
  return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    vector<int> tower(b-a+1);
    tower[0] = 0;
    for(int i = 1;i <= b - a;i++) tower[i] = tower[i-1] + i;
    cout << tower[b-a] - b << endl;
    return 0;
}

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

int main()
{
  int max1 = 0, max2 = 0, index1 = 0;
  int A, N;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A;
    if(max1 <= A) {
      max2 = max1;
      max1 = A;
      index1 = i;
    } else if(max2 < A) {
      max2 = A;
    }
  }
  for(int i = 0; i < N; i++) {
    cout << ((i == index1)? max2 : max1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
import sys
S = input()
length = len(S)
while 1:
    if length == 0:
        print("YES")
        sys.exit()
    elif S[length-7 : length] == "dreamer":
        length = length - 7
    elif S[length-5 : length] == "dream":
        length = length - 5
    elif S[length-5 : length] == "erase":
        length = length - 5
    elif S[length-6 : length] == "eraser":
        length = length - 6
    else:
        print("NO")
        sys.exit()


Measured memory_bytes: 39920
#include <iostream>

using namespace std;

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

  int h[n];
  for (int i = 0; i < n; i++) {
  	cin >> h[i];
  }

  sort(h, h + n);

  long sum = 0;
  for (int i = n - k - 1; i >= 0; i--) {
  	sum += h[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
mat = []
i = 0
while True:
    tmp = list(map(int, input().split()))
    mat.append(tmp)
    i += 1
    if i == n:
        break

b = [int(input()) for i in range(m)]
ans = []

for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += mat[i][j] * b[j]
    
    ans.append(tmp)

for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 6020
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s;
    cin >> s;
    int a,b;
    a = s/100;
    b = s - a*100;
    bool ym,my;
    ym = true;
    my = true;
    if(0== a || a>= 13) my = false;
    if(0== b || b>= 13) ym = false;
    if(ym == true && my == true) cout << "AMBIGUOUS" << endl;
    if(ym == true && my == false) cout << "YYMM" << endl;
    if(ym == false && my == true) cout << "MMYY" << endl;
    if(ym == false && my == false) cout << "NA" << endl;
}


Measured memory_bytes: 3616
#include<bits/stdtr1c++.h>
#include<algorithm>
using namespace std;

int main(){
    int N,K,X,Y,ans;
    cin >> N;
    cin >> K;
    cin >> X;
    cin >> Y;
    if (K < N){
        ans = (N-K)*Y+K*X;
            }
    else{
        ans = N*X;
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=n; i++)
#define rep0(i,n) for (int i=0; i<n; i++)
#define chmin(a,b) if ((a)>(b)) { a=(b); }
#define chmax(a,b) if ((a)<(b)) { a=(b); }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%d "; return r + "\n"; }
#define debug(...) do{printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__);}while(0)
#else
#define debug(...) do{}while(0)
#endif

int main() {
    std::ios::sync_with_stdio(false); std::cin.tie(nullptr); // disable when using stdio
    int n;
    cin >> n;
    int s[n+1]; rep1(i,n) s[i] = 0;
    for(int i=2; i<=n; i++) {
        int a;
        cin >> a;
        s[a]++;
    }

    rep1(i,n) {
        cout << s[i] << endl;
    }
}


Measured memory_bytes: 4364
#include <bits/stdc++.h>
#define INF 1000000000000001
#define ll long long
using namespace std;

int main()
{
  ll N, M;
  cin >> N >> M;
  if (N == M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF=1000000007;
int f[1010101];
int ksm(int w,int x)
{
	int ans=1;
	while(x)
	{
		if(x&1)
			ans=(long long)ans*w%INF;
		x>>=1;
		w=(long long)w*w%INF;
	}
	return ans;
}
int main()
{
	int n,h,d,w,all=0,i,now;
	scanf("%d%d%d",&n,&h,&d);
	w=1;
	for(i=1;i<=n;i++)
	{
		w=(long long)w*i%INF;
		all=(all+w)%INF;
	}
	f[0]=1;
	now=1;
	for(i=1;i<=h;i++)
	{
		if(i-d-1>=0)
			now=(now-f[i-d-1]+INF)%INF;
		f[i]=(f[i]+(long long)all*now)%INF;
		now=(now+f[i])%INF;
	}
	printf("%d\n",(long long)f[h]*w%INF*ksm(all,INF-2)%INF);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	return 0;
}


Measured memory_bytes: 4096
def main():
    s = get_params()
    collatz_seq = collatz(s)
    am_index = first_duplicate_index(collatz_seq)
    print(am_index+1)


def get_params():
    return int(input())


def collatz(s):
    return iterate(f, s)


def iterate(f, init):
    while True:
        yield init
        init = f(init)


def f(n):
    return n//2 if n % 2 == 0 else 3*n+1


def first_duplicate_index(seq):
    s = set()
    for e in seq:
        if e in s:
            return len(s)
        s.add(e)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <utility>
using namespace std;
typedef pair<string, string> pss;

map<string, map<int, int> > arrays;
map<string, int> limit;
bool isdeclare(string &s){
	for(int i=0; i<(int)s.length(); i++){
		if(s[i]=='=') return false;
	}
	return true;
}
int tonum(string &s){
	for(int i=0; i<(int)s.length(); i++){
		if(s[i] < '0' || '9' < s[i]){
			return -1;
		}
	}
	return stoi(s);
}
pss parsebrac(string &s){
	int n = s.length();
	int i=0;
	while(s[i]!='[') i++;
	return make_pair(s.substr(0, i), s.substr(i+1, n-i-2));
}
pss parseeq(string &s){
	int n = s.length();
	int i=0;
	while(s[i]!='=') i++;
	return make_pair(s.substr(0, i), s.substr(i+1, n-i-1));
}
int getnum(string &s){
	if(tonum(s)!=-1) return tonum(s);
	pss pstr = parsebrac(s);
	int idx = getnum(pstr.second);
	string name = pstr.first;
	if(arrays[name].find(idx) != arrays[name].end()){
		return arrays[name][idx];
	}
	return -1;
}

int main(){
	while(1){
		bool end = false;
		int ans = 0;
		arrays = map<string, map<int, int> >();
		limit = map<string, int>();
		for(int line=1; ; line++){
			string str;
			cin >> str;
			if(str == "."){
				if(line == 1) end = true;
				break;
			}
			if(ans != 0) continue;
			
			if(isdeclare(str)){
				pss pstr = parsebrac(str);
				limit[pstr.first] = tonum(pstr.second);
				arrays[pstr.first] = map<int, int>();
			}else{
				pss pstr1 = parseeq(str);
				int val = getnum(pstr1.second);
				pss pstr2 = parsebrac(pstr1.first);
				int subsidx = getnum(pstr2.second);
				string subsname = pstr2.first;
				if(val!=-1 && subsidx!=-1 && limit[subsname]>subsidx){
					arrays[subsname][subsidx] = val;
				}else{
					ans = line;
				}
			}
		}
		if(end) break;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
program golf
 implicit none
 character s*3
 integer a,b,k,c,d
 read *, k
 read (*,*) a,b
 c = a/k
 d = b/k
 if ((c.NE.d) .or. ( k*c == a) ) then
 print *,'OK'
 else
 print *,'NG'
 end if
end program golf
 


Measured memory_bytes: 2860
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  int N = 3;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(all(A));
  int sum1 = 0;
  for (int i = 0; i < N - 1; i++) {
    sum1 += A[i + 1] - A[i];
  }
  int sum2 = 0;
  for (int i = N - 1; i >= 1; i--) {
    sum2 += A[i] - A[i - 1];
  }
  cout << min(sum1, sum2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;
#define mp make_pair

vector<int> median(vector<int> v) {
	sort(v.begin(), v.end());
	int n = v.size();
	vector<int> ret(1, v[n/2]);
	if (n % 2 == 0) {
		ret.push_back(v[n/2-1]);
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, N;
	cin >> W >> H >> N;
	vector<int> xs(N), ys(N);
	for (int i=0; i<N; ++i) {
		cin >> xs[i] >> ys[i];
	}
	vector<int> mx = median(xs);
	vector<int> my = median(ys);
	long long res = LLONG_MAX;
	int x, y;
	for (int i=0; i<(int)mx.size(); ++i) {
		for (int j=0; j<(int)my.size(); ++j) {
			long long time = 0, m = 0;
			for (int k=0; k<N; ++k) {
				long long t = abs(xs[k] - mx[i]) + abs(ys[k] - my[j]);
				time += t;
				m = max(m, t);
			}
			long long res2 = 2 * time - m;
			if (mp(res2, mp(mx[i], my[j])) < mp(res, mp(x, y))) {
				res = res2;
				x = mx[i];
				y = my[j];
			}
		}
	}
	cout << res << endl;
	cout << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 2328
#include<bits/stdc++.h>
using namespace std;
int main(){int n,k,i,cnt=0;
           cin>>n;
           for(i=0;i<n;i++){cin>>k;
                       if(k%2==0){if(k%3&&k%5){cnt++;}}    
                           }
           if(cnt){cout<<"DENIED";}
           else{cout<<"APPROVED";}
  return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
using namespace std;
typedef complex<double> P;

/* ?¨±?????????????????*/
#define EPS (1e-10)
/* 2?????????????????????????????????????????? */
#define EQ(a,b) (abs((a)-(b)) < EPS)

/* ?????? (cross product) : a??b = |a||b|sin */
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}


/* 2??´?????????????????? : a//b <=> cross(a, b) = 0 */
int isParallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

int main() {
  int n;
  double ax, ay, bx, by, cx, cy, dx, dy;
  cin >> n;

  while(n--) {
    cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;
    P a(ax, ay), b(bx, by), c(cx, cy), d(dx, dy);
    cout << (isParallel(a, b, c, d) ? "YES" : "NO") << endl;
  }

  return 0;
}

Measured memory_bytes: 3104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  string s;
  cin >> s;
  string one, zero;
  rep(i, s.size()){
    if (i%2){
      one += '1'; 
      zero += '0';
    }else {
      one += '0';
      zero += '1';
    }
  }
  int ans1 = 0, ans0 = 0;
  rep(i, s.size()){
    if (s[i] != one[i]) ans1++;
    if (s[i] != zero[i]) ans0++;
  }
  cout << min(ans0, ans1) << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  auto f=[&](ll x){
    ll xb=x/b;
    return a*x/b-a*xb;
  };
  cout << max(f(n),f(n-1-n%b));
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
//#include <ext/numeric>


using namespace std;
//using namespace __gnu_cxx;



int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("fence.out", "w", stdout);
#endif

    int n, a;
    cin >> n >> a;
    vector<int> arr(n);
    for (int &x : arr)
        cin >> x;
    int m = 2501;

    vector<vector<vector<long long>>> dp(n + 1, vector(n + 1, vector<long long>(m, -1)));
    function<long long(int, int, int)> solve = [&](int idx, int rem, int cnt) {
        if (idx == n)
            return (cnt == 0 && rem == 0 ? 1LL : 0LL);
        if (cnt < 0 || rem < 0)
            return 0LL;
        long long &ret = dp[idx][rem][cnt];
        if (~ret)
            return ret;
        ret = solve(idx + 1, rem - 1, cnt - arr[idx]) + solve(idx + 1, rem, cnt);
        return ret;
    };

    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += solve(0, i, a * i);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 55276
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll len = s.length();
    string ans = "Yes";
    rep(i, 0, (len - 1) / 2 / 2 + 1)
    {
        if (s[i] != s[(len - 1) / 2 - 1 - i])
            ans = "No";
    }
    rep(i, (len + 3) / 2 - 1, len)
    {
        if (s[i] != s[len - 1 - i])
            ans = "No";
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    int a[n],b[n];
    for(i=0;i<n;i++) cin>>a[i];
    b[n-1]=0; b[n-2]=abs(a[n-1]-a[n-2]);

    for(i=n-3;i>=0;i--)
    {
        b[i]=min(abs(a[i]-a[i+1])+b[i+1],abs(a[i]-a[i+2])+b[i+2]);
    }
cout<<b[0]<<endl;
    return 0;
}




Measured memory_bytes: 1024
N,A,B,C = map(int,input().split())
valid = True
array = []
for i in range(N):
    s = input()
    array.append(s)
array2 = []
for i in range(N):
    if array[i] == "AB":
        if A == B == 0:
            valid = False
            break
        elif i != N-1 and A == B and array[i+1] == "AC":
            A += 1
            B -= 1
            array2.append("A")
        elif i != N-1 and A == B and array[i+1] == "BC":
            A -= 1
            B += 1
            array2.append("B")
        elif A <= B:
            A += 1
            B -= 1
            array2.append("A")
        else:
            A -= 1
            B += 1
            array2.append("B")
    elif array[i] == "AC":
        if A == C == 0:
            valid = False
            break
        elif i != N-1 and A == C and array[i+1] == "BC":
            A -= 1
            C += 1
            array2.append("C")
        elif i != N-1 and A == C and array[i+1] == "AC":
            A += 1
            C -= 1
            array2.append("A")
        elif A <= C:
            A += 1
            C -= 1
            array2.append("A")
        else:
            A -= 1
            C += 1
            array2.append("C")
    else:
        if B == C == 0:
            valid = False
            break
        elif i != N-1 and B == C and array[i+1] == "AC":
            B -= 1
            C += 1
            array2.append("C")
        elif i != N-1 and B == C and array[i+1] == "AB":
            B += 1
            C -= 1
            array2.append("B")
        elif B <= C:
            B += 1
            C -= 1
            array2.append("B")
        else:
            B -= 1
            C += 1
            array2.append("C")
if valid:
    print("Yes")
    for i in range(len(array2)):
        print(array2[i])
else:
    print("No")


Measured memory_bytes: 89092
n, a, b, c, d = (int(e) - 1 for e in input().split())
s = input()

if c < d:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    print('Yes' if ok1 and ok2 else 'No')
else:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    ok3 = any(s[i - 1] == s[i] == s[i + 1] == '.' for i in range(b, d + 1) if 0 < i and i < n - 1)
    print('Yes' if ok1 and ok2 and ok3 else 'No')




Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> w;
	set<int> s;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		s.insert(tmp);
	}

	set<int>::iterator ite;
	int count = 0;
	for (ite = s.begin(); ite != s.end(); ++ite) {
		count++;
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    int n, k;
    std::cin >> n >> k;

    std::vector<bool> have(n, false);
    for (int i = 0; i < k; i++) {
        int d;
        std::cin >> d;

        for (int j = 0; j < d; j++) {
            int a;
            std::cin >> a;

            have[a - 1] = true;
        }
    }

    int num = 0;
    for (auto val : have) {
        if (!val) {
            num++;
        }
    }

    std::cout << num << std::endl;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);	
		int H = sc.nextInt();
		int W = sc.nextInt();
		int i , j , k;
		
		String[] weather = new String[H];
		for(i = 0 ; i < H ; i++){
			weather[i] = sc.next();
		}
		
		char[][] weatherArray = new char[H][W];
		for(i = 0 ; i < H ; i++){
			for(j = 0 ; j < weather[i].length() ; j++){
				weatherArray[i][j] = weather[i].charAt(j);
			}
		}
		
		int[][] count = new int[H][W];
		
		for(i = 0 ; i < H ; i++){
			if(weatherArray[i][0] == 'c'){
				count[i][0] = 0;
			}else if(weatherArray[i][0] == '.'){
				count[i][0] = -1;
			}
		}
		
		for(i = 0 ; i < H ; i++){
			for(j = W - 1 ; j > 0 ; j--){
out:			if(weatherArray[i][j] == 'c'){
					count[i][j] = 0;
				}else if(weatherArray[i][j] == '.'){
					for(k = 1 ; k < j + 1 ; k++){
						count[i][j]++;
						if(weatherArray[i][j - k] == 'c'){
							break out;
						}
						if(count[i][j] == j){
							count[i][j] = -1;
							break out;
						}
					}
				}
			}
		}		
		for(i = 0 ; i < H ; i++){
			for(j = 0 ; j < W ; j++){
				System.out.print(count[i][j]);
				if(j + 1 != W){
					System.out.print(" ");
				}
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 35844
s=sorted(input())
t=sorted(input())[::-1]
A=True
for i in range(min(len(s),len(t))):
    if s[i]<t[i]:
        A = True
        break
    elif s[i]>t[i]:
        A = False
        break
    else:
        if len(s)<len(t): A=True
        else:A= False
print('Yes' if A else 'No')

Measured memory_bytes: 9072
#include<iostream>
using namespace std;
int main(){
    int n;
    int a[200];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int r=0,flag=0;
    while(flag == 0){
        for(int i=0;i<n;i++){
            if(a[i] % 2 == 0){
                a[i] /= 2;
            }else{
                flag = 1;
            }
        }
        r++;
    }
    cout << r-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, x, c[15], a[15][15], tog[15];
int main() {
	cin>>n>>m>>x;
	for(int i = 0; i < n; i++) {
		cin>>c[i];
		for(int j = 0; j < m; j++) {
			cin>>a[i][j];
		}
	}
	int ans = 1e9;
	for(int i = 0; i < (1 << n); i++) {
		memset(tog, 0, sizeof tog);
		int sum = 0;
		for(int j = 0; j < n; j++) {
			if(i & (1 << j)) {
				sum += c[j];
				for(int k = 0; k < m; k++) {
					tog[k] += a[j][k];
				}
			}
		}
		for(int j = 0; j < m; j++) {
			if(tog[j] < x) {
				sum = 1e9;
				break;
			}
		}
		ans = min(ans, sum);
	}
	if(ans > 1e8) {
		cout<<-1<<endl;
	}else {
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++) {
        cin >> L[i];
    }


    sort(L.begin(), L.end());

    int ans = 0;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            int k = j+1;
            ans += distance(L.begin()+k, lower_bound(L.begin(), L.end(), L[i]+L[j]));
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
struct Vertex {
	// edge information
	vector<int> edges_to; //to vertex number
	int depth = -1;
};

Vertex V[100002];

int dep(int i){
	if (V[i].depth >= 0) return V[i].depth;
	int ret = 0;
	REP(k,V[i].edges_to.size()){
		ret = max(ret,1 + dep(V[i].edges_to[k]));
	}

	return V[i].depth = ret;
}

int main(){
	int N,M;
	SCD2(N,M);
	REP(i,M){
		int u,v;
		SCD2(u,v);
		u--; v--;
		V[u].edges_to.PB(v);
	}

	REP(i,N){
		dep(i);
	}

	int ret = 0;
	REP(i,N){
		ret = max(ret,V[i].depth);
	}

	PRINTD(ret);
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

int32_t main()
{
	fastIO
	inp_out();
	string s, t; 
	cin >> s >> t; 
	int n = s.size(), ans = 0; 
	for(int i = 0; i < n;  ++ i)
	{
		if(s[i] != t[i])
		 ++ ans; 

	}
	cout << ans; 
	return 0;
}

Measured memory_bytes: 3796
#include<cstdio>
#include<vector>
#include<set>
typedef std::pair<int,int> pii;
int main(){
    int n,m,a,b;
    std::set<pii> s;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        s.insert({a,b});
    }
    for(int i=2;i<n;i++){
        if(s.count({1,i})>0&&s.count({i,n})>0){
            printf("POSSIBLE");
            return 0;
        }
    }
    printf("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n)cin>>a[i];
  ll cu=0;
  rep(i,n){
    cu+=a[i];
    cu%=MOD;
  }
  ll ans=0;
  rep(i,n){
    cu-=a[i];
    if(cu<0) cu+=MOD;
    ans+=cu*a[i];
    ans%=MOD;
  }
  COUT(ans);
}

Measured memory_bytes: 4840
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007


void solve(){
	int k,x;
	cin>>k>>x;
	if((500*k)>=x) cout<<"Yes\n";
	else cout<<"No\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

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

using namespace std;

int main() {
  
  int N;
  cin >> N;
  
  int d[N];
  
  for (int i = 0; i < N; i++) cin >> d[i];
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      sum += d[i] * d[j];
    }
  }
  
  cout << sum << endl;
    
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	X, K, D := getInt(), getInt(), getInt()

	t := abs(X) / D
	if K <= t {
		if X > 0 {
			out(abs(X - K*D))
		} else {
			out(abs(X + K*D))
		}
		return
	}
	d := (K - t) % 2
	if d == 0 {
		if X > 0 {
			out(abs(X - t*D))
		} else {
			out(abs(X + t*D))
		}
		return
	} else {
		if X > 0 {
			out(abs(X - D*t - D))
		} else {
			out(abs(X + D*t + D))
		}
		return
	}

}


Measured memory_bytes: 1776
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b){
            for(int i = 0 ; i < b ; i++ ){
                System.out.print(a);
            }
        }else{
            for(int i = 0; i < a ; i++ ){
                System.out.print(b);
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 35796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    int N,K;cin>>N>>K;
    int info[N];
    rep(i,N)cin>>info[i];
    double ans=0,now=0;
    rep(i,K)now+=info[i]+1;
    ans=now;
    repl(i,K,N){
        now+=info[i]-info[i-K];
        ans=max(ans,now);
    }
    ans=ans/(double)2;
    CST(10)<<ans<<endl;
    return 0;
}

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

struct P {
	int x;
	int y;
	bool operator<(const P& p) const { 
		if (this->x < p.x) return true;
		else if (this->x > p.x) return false;
		else return this->y < p.y;
	}
};

int main()
{
	int n; std::cin >> n;
	P* A = new P[n];
	for (int i=0; i<n; i++) std::cin >> A[i].x >> A[i].y;

	std::sort(A, A+n);
	
	for (int i=0; i<n; i++) {
		std::cout << A[i].x << " " << A[i].y << std::endl;
	}
	
	delete[] A;
	
	return 0;
}



Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
const int N = 1e2 + 2;
const int Q = 1e4 + 4;
const int dx[4] = {0 , 1 , 0 , -1};
const int dy[4] = {1 , 0 , -1 , 0};
int n , m;
int ans[N][N];
int q;
int arr[Q];
bool done[N][N];
bool valid(int x , int y){
	return (x >= 1) && (y >= 1) && (x <= n) && (y <= m) && !done[x][y];
}
void go(int x , int y , int cur , int dir){
	ans[x][y] = cur;
	done[x][y] = 1;
	--arr[cur];
	if(!arr[cur]){
		++cur;
	}
	if(cur > q){
		return;
	}
	while(!valid(x + dx[dir] , y + dy[dir])){
		dir = (dir + 1) & 3;
	}
	go(x + dx[dir] , y + dy[dir] , cur , dir);
}
int main(){
	scanf("%d %d" , &n , &m);
	scanf("%d" , &q);
	for(int i = 1 ; i <= q ; ++i){
		scanf("%d" , &arr[i]);
	}
	go(1 , 1 , 1 , 0);
	for(int i = 1 ; i <= n ; ++i){
		for(int j = 1 ; j <= m ; ++j){
			printf("%d%c" , ans[i][j] , " \n"[j == m]);
		}
	}
}

Measured memory_bytes: 384
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

def gen_primes():
    D = {}
    q = 2
    while True:
        if q not in D:
            yield q
            D[q * q] = [q]
        else:
            for p in D[q]:
                D.setdefault(p + q, []).append(p)
            del D[q]

        q += 1
PRIMES=[]

for p in gen_primes():
    if p < 1000000:
        PRIMES.append(p)
    else:
        break

N=II()
cnt = 0
for PR in PRIMES:
    for i in range(1,64):
        v = PR**i
        if N % v == 0:
            # print("PR:{} i:{}".format(PR, i))
            cnt += 1
            N //= v
            # print(N)
        else:
            while N % PR == 0: N //= PR
            break

# print(N)
if N > 1: cnt += 1
print(cnt)


Measured memory_bytes: 100912
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
char w[2<<17];
string last,pas,cur;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>(w+1);
    int n=strlen(w+1);
    int ans=1;
    last+=w[1];
    for(int i=2;i<=n;++i)
    {
        cur=pas+w[i];
        if(cur!=last)
        {
            ++ans;
            last=cur;
            pas.clear();
        }
        else pas=cur;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    ll m = n/2;

    vl v(n+1);
    exrep(i, 1, n) {
        cin >> v[i];
    }

    vl cnt1(MAX_N);  // cnt1[i] : vの奇数番目に現れるiの個数
    vl cnt2(MAX_N);  // cnt2[i] : vの偶数番目に現れるiの個数
    exrep(i, 1, n) {
        if(i%2 == 1) {
            cnt1[v[i]]++;
        }
        else {
            cnt2[v[i]]++;
        }
    }
    
    vector<P> p1(MAX_N);
    vector<P> p2(MAX_N);
    exrep(i, 1, MAX_N-1) {
        p1[i] = make_pair(cnt1[i], i);    
        p2[i] = make_pair(cnt2[i], i);   
    }
    sort(rall(p1));
    sort(rall(p2));

    if(p1[0].second != p2[0].second) {
        out(n - (p1[0].first + p2[0].first));
    }
    else {
        ll A = p1[0].first + p2[1].first;
        ll B = p1[1].first + p2[0].first;
        out(n - max(A, B));
    }

    re0;
}

Measured memory_bytes: 5760