akhauriyash/Code-Regression huggingface dataset:
import math
N,D=map(int,input().split())
X=[list(map(int,input().split())) for _ in range(N)]
count=0
ans=0
for k in range(N):
    for l in range(k+1,N):
        for m in range(D):
            ans=ans+(X[k][m]-X[l][m])**2
        ans=math.sqrt(ans)
        if ans.is_integer():
            count=count+1
        ans=0
print(count)

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

int main(){
	string c; cin >> c;
	if(c == "a" || c == "i" || c == "u" || c == "e" || c == "o"){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    ll s,w; cin >> s >> w;
    if(s<=w){
        cout << "unsafe" <<endl;
    }else{
        cout << "safe" << endl;
    }
}

void b(){
   
}

void c(){
    
}

void d(){
    
}

void e(){

}

int main(){
    a();
    return 0;
}





Measured memory_bytes: 3636
n=int(input())
a=list(map(int,input().split()))
s=[]
i=0
cnt=0
for i in range(n):
    while a[i]%2==0:
        cnt+=1
        a[i]=a[i]//2
    else:
        s.append(cnt)
        i+=1
        cnt=0
print(min(s))

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

typedef struct {
	double x;
	double y;
} Point;

double dist(Point p1, Point p2){
	return sqrt( pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2) );
}

int main(void){
	Point p1, p2;
	scanf("%lf%lf%lf%lf", &p1.x, &p1.y, &p2.x, &p2.y);
	double res = dist(p1, p2);
	printf("%.8lf\n", res);
	return 0;
}


Measured memory_bytes: 2728
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {

	int h, w, n;
	cin >> h >> w >> n;

	vector<int> a(n), b(n);
	set<P> s;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		s.insert(P(b[i], a[i]));
	}

	set<P> p;
	rep(i, n) {
		for (int x = b[i] - 2; x <= b[i]; x++) {
			for (int y = a[i] - 2; y <= a[i]; y++) {
				if (x >= 1 && y >= 1 && x <= w - 2 && y <= h - 2) {
					p.insert(P(x, y));
				}
			}
		}
	}
	map<int,int> ans;
	ans[0] = (w - 2) * (h - 2);
	each(i, p) {
		int x = i.first, y = i.second;
		int cnt = 0;
		for (int tx = x; tx <= x + 2; tx++) {
			for (int ty = y; ty <= y + 2; ty++) {
				cnt += s.count(P(tx, ty));
			}
		}
		ans[cnt]++;
		ans[0]--;
	}



	rep(i, 10) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 64256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  b-=a;
  int u=0;
  rep(i,n){
    ll ma=d*i-c*(n-i-1);
    ll mi=c*i-d*(n-i-1);
    if(ma>=b&&mi<=b)u++;
  }
  if(u==0)cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

int main() {
    //input
    int n;
    cin >> n;
    if(n < 1200){
        cout << "ABC";
    }else if(n < 2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }
    return 0;
}


Measured memory_bytes: 256
h, w = map(int,input().split())
grid = [list(input()) for _ in range(h)]

for i in range(h-1):
    for j in range(1, w):
        if grid[i][j] == "#":
            if grid[i+1][j-1] == "#":
                print("Impossible")
                exit()

print("Possible")

Measured memory_bytes: 3060
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,s):
        t += MAP[i*j-1]
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))


Measured memory_bytes: 17204
from itertools import permutations

def main():
    N: int
    M: int
    R: int
    A: int
    B: int
    C: int
    ans: int    
    INF: int
    INF = 10 ** 10
    N, M, R = map(int, input().split())
    r: list = list(map(lambda x: x - 1, map(int, input().split())))
    dist :list = [[float('inf')] * N for _ in range(N)]
    for _ in range(M):
        A, B, C = map(int, input().split())
        A -= 1
        B -= 1
        dist[A][B] = C
        dist[B][A] = C
    for i in range(N):
        dist[i][i] = 0
    
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    ans = INF
    for item in permutations(r):
        L: int = len(item)
        d: int = 0
        for i in range(1,L):
            pre: int = item[i-1]
            now: int = item[i]
            d += dist[pre][now]
        ans = min(ans, d)
    print(ans)  

if __name__ == "__main__":
    main()

Measured memory_bytes: 70828
import fractions as frac
a,b,c,d=map(int,input().split())
e=frac.gcd(c,d)
f=(c*d)//e
x=b//c
y=b//d
z=b//f
u=(a-1)//c
v=(a-1)//d
s=(a-1)//f
num1=(b-(x+y-z))
num2=((a-1)-(u+v-s))
print(num1-num2)


Measured memory_bytes: 5688
# -*- coding: utf-8 -*-
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

if k > q:
    for i in range(n):
        print('Yes')
else:
    ans = [k-q] * n
    for j in a:
        ans[j-1] += 1
    for h in range(n):
        if ans[h] <= 0:
            print('No')
        else:
            print('Yes')


Measured memory_bytes: 9984
def simulation(x, N, S, incantations):
    for t, d in incantations:
        if x < 0 or x >= N:
            return x
        if S[x] == t:
            if d == 'R':
                x += 1
            else:
                x -= 1
    return x


def solve(N, S, incantations):
    # 左側に落ちるロボットの範囲: (-inf, ok_left]
    ok_left, ng_left = -1, N
    while ng_left - ok_left > 1:
        mid = (ok_left + ng_left) // 2
        if simulation(mid, N, S, incantations) < 0:
            ok_left = mid
        else:
            ng_left = mid
    # 右側に落ちるロボットの範囲: [ok_right, inf)
    ok_right, ng_right = N, -1
    while ok_right - ng_right > 1:
        mid = (ok_right + ng_right) // 2
        if simulation(mid, N, S, incantations) >= N:
            ok_right = mid
        else:
            ng_right = mid
    print(ok_right - ok_left - 1)


def main():
    N, Q = list(map(int, input().split()))
    S = input()
    incantations = [input().split() for _ in range(Q)]
    solve(N, S, incantations)


if __name__ == '__main__':
    main()

Measured memory_bytes: 42648
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

bool check(const vector<pair<int, int>>& dists,
           const vector<vector<int>>& graph) {
    int n = SZ(graph);
    for (int i = 0; i < n; ++i) {
        int adist = -1;
        for (const auto& p: dists) {
            if (p.second == i) {
                adist = p.first;
            }
        }
        if (adist == -1) {
            throw;
        }
        vector<int> dist(n, n);
        dist[i] = 0;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int node = q.front();
            q.pop();

            for (int to: graph[node]) {
                if (dist[to] > dist[node] + 1) {
                    dist[to] = dist[node] + 1;
                    q.push(to);
                }
            }
        }
        if (adist != *max_element(dist.begin(), dist.end())) {
            return false;
        }
    }
    return true;
}

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<pair<int, int>> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.begin(), A.end());
    if (n >= 3 && A[2].first == A[1].first && A[1].first == A[0].first) {
        cout << "Impossible\n";
        return 0;
    }
    vector<vector<int>> graph(n);
    int lastDist = A[0].first;
    int ind = 1;
    vector<int> lastNodes;
    vector<int> cNodes = {A[0].second};
    if (A[0].first == A[1].first) {
        graph[A[0].second].push_back(A[1].second);
        graph[A[1].second].push_back(A[0].second);
        ind++;
        cNodes.push_back(A[1].second);
    }
    int nind = 0;
    while (ind < SZ(A)) {
        int node = A[ind].second;
        int dist = A[ind++].first;

        if (dist != lastDist) {
            lastNodes = cNodes;
            cNodes.clear();
            nind = 0;
            lastDist = dist;
        }
        cNodes.push_back(node);
        graph[lastNodes[nind]].push_back(node);
        graph[node].push_back(lastNodes[nind]);
        nind = (nind + 1) % SZ(lastNodes);
    }

    if (check(A, graph)) {
        cout << "Possible\n";
    } else {
        cout << "Impossible\n";
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,s=0 ; cin>>n;
    int arr[n] ;
    for (int i=0 ; i<n ;i++) {
        cin>>arr[i] ;
    }
    for (int j=0 ; j<n ;j=j+2) {
        if (arr[j]%2!=0) s =s +1 ;
    }
    cout<<s ;
    return 0;
}


Measured memory_bytes: 3636
class E169
  def call(n, x_s)
    a_s = x_s.map {|x| x[0]}.sort
    b_s = x_s.map {|x| x[1]}.sort
    a_center = center(n, a_s)
    b_center = center(n, b_s)
    b_center - a_center + 1
  end

  def center(n, nums)
    if n.even?
      (nums[(n / 2 - 1)] + nums[(n / 2)])
    else
      nums[(n / 2)]
    end
  end

  def main
    n = gets.to_i
    ab_s = readlines.map { |x| x.split(' ').map { |y| y.to_i } }
    puts call(n, ab_s)
  end
end

E169.new.main

Measured memory_bytes: 48272
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, m; cin >> n >> m;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    vector<bool> ok(n, true);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (h[a] <= h[b]) ok[a] = false;
        if (h[b] <= h[a]) ok[b] = false;
    }

    int ans = 0;
    rep(i, n) if (ok[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 4048
#include <cstdio>
#include <algorithm>

using namespace std;

int n, a[110];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	printf("%d\n", a[n] - a[1]);
	return 0;
}

Measured memory_bytes: 128
import sys
# gcd
# from bisect import bisect_left,bisect_right
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_1.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"

    # write code
    anslist = []
    MAX_A = max(a)
    MIN_A = min(a)
    if MIN_A >= 0:
        for i in range(1, N):
            anslist.append((i,i+1))
    elif MAX_A < 0:
        for i in range(N, 1, -1):
            anslist.append((i, i - 1))
    else:
        if abs(MAX_A) >= abs(MIN_A):
            MAX_INDEX = a.index(MAX_A)
            for i in range(1,N+1):
                anslist.append((MAX_INDEX+1, i))
            for i in range(1, N):
                anslist.append((i, i + 1))
        else:
            MIN_INDEX = a.index(MIN_A)
            for i in range(1, N + 1):
                anslist.append((MIN_INDEX+1, i))
            for i in range(N, 1, -1):
                anslist.append((i, i - 1))

            
    print(len(anslist))
    for tup in anslist:
        print(tup[0],tup[1])


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

#define rep(i, k) for (ll i = 0; i < k; i++)
#define pair(x, y) make_pair((x), (y))

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int h, a;
    cin >> h >> a;
    int i = 0;
    while (0 < h) {
        h -= a;
        i++;
    }
    cout << i;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<utility>
#include<cmath>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+eps)

double W, H;
double w,h;

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

  scan(W>>H>>w>>h);
  if( abs(w-W/2)<EPS && abs(h-H/2)<EPS) cout << setprecision(9) << W*H/2 << " " << 1;
  else  cout << setprecision(9) << W*H/2 << " " << 0;

//  cout <<  << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split(' '))
ans = {}

p = {} 
p_ = 0
for i in range(m):
  arr = list( input().split(' '))
  if not arr[0] in ans :
    if not arr[0] in p:
      p[arr[0]] = 0
    if arr[1] == 'WA':
      p[arr[0]] += 1
    if arr[1] == 'AC':
      ans[arr[0]] = 0
      p_ += p[arr[0]]
      p.pop(arr[0])
      
      
print(len(ans),p_)



Measured memory_bytes: 17124
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n){
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;
}


Measured memory_bytes: 19196
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<numeric>

using namespace std;

int main() {
    int N;
    cin>>N;
    cout<<800*N-200*(N/15)<<endl;
    return 0;
}

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

static const int N = 1000;

int lcs(string X,string Y){
    int C[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 1; i <= m ; ++i) {
        C[i][0] = 0;
    }
    for (int j = 1; j <= n ; ++j) {
        C[0][j] = 0;
    }

    for (int i = 1; i <= m ; ++i) {
        for (int j = 1; j <= n ; ++j) {
         if (X[i] == Y[j]){
             C[i][j] = C[i-1][j-1] + 1;
         }else{
             C[i][j] = max(C[i-1][j],C[i][j-1]);
         }
            maxl = C[i][j];
        }
    }
    return maxl;
}


int main(){
    string s1,s2;
    int n;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> s1 >> s2;
        cout << lcs(s1,s2) << endl;
    }
    return 0;
}

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

int main() {
  int s;
  cin >> s;
  cout << (s % 10) + (s / 10 % 10) + (s / 100) << endl;
}


Measured memory_bytes: 3584
N,M = map(int,input().split())
k = [list(map(int,input().split()))[1:] for _ in range(M)]
p = list(map(int,input().split()))
cnt = 0
for i in range(2**N):
    switch = bin(i)[2:].zfill(N)
    flag = True
    for j in range(M):
        on = 0
        for index in k[j]:
            if switch[index-1] == '1':
                on += 1
        if on % 2 != p[j]:
            flag = False
            break
    if flag:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	N := getStdinInt()

	switch {
	case (N%10 == 2) ||
		(N%10 == 4) ||
		(N%10 == 5) ||
		(N%10 == 7) ||
		(N%10 == 9):
		fmt.Print("hon")
	case (N%10 == 0) ||
		(N%10 == 1) ||
		(N%10 == 6) ||
		(N%10 == 8):
		fmt.Print("pon")
	case (N%10 == 3):
		fmt.Print("bon")
	}

	fmt.Printf("\n")
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	int D[15] = {}; 
	D[0] = 1; 
	cin >> N; 
	for(int i = 0; i < N; i++){
		int a; cin >> a; D[a] ++; 
	}
	int ans = 12; 
	for(int i = 1; i < 12; i++){
		if(D[i] >= 3) ans = 0; 
	}
	if(D[0] >= 2) ans = 0; 
	if(D[12] >= 2) ans = 0; 
	if(ans > 0){
		vector<int> exist = {0, 24};  
		for(int i = 1; i < 12; i++){
			if(D[i] == 2){
				exist.push_back(i); 
				exist.push_back(24 - i); 
			}
			else if(D[i] == 1){
				if(exist.at(exist.size()-1) < 12){
					exist.push_back(24 - i); 
				}
				else{
					exist.push_back(i); 
				}
			}
		}
		if(D[12] == 1) exist.push_back(12); 
		sort(exist.begin(), exist.end()); 
		for(int j = 0; j < exist.size() - 1; j++){
			ans = min(ans, exist[j+1] - exist[j]); 
		}
 	}
	cout << ans << endl; 
}

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


void solve(){

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

    int x;
    cin >> x;

    // int a=0,b=0,c=0,d=0;
    int a,b,c,d;
    d = x/1000;
    c = (x-1000*d)/100;
    b = (x-1000*d-100*c)/10;
    a = (x-1000*d-100*c-10*b);

    // cout <<a <<endl <<b <<endl <<c <<endl <<d <<endl;


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

    }

//     string x = to_string(x);
//     string a=x[0];
//     string b=x[1];
//     string c=x[2];
//     string d=x[3];
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

const int MaxN = 300 + 5;

int N;
int A[MaxN], Cnt[4];
double f[MaxN][MaxN], g[MaxN][MaxN];
bool vis[MaxN][MaxN];

void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  for (int i = 1; i <= N; ++i) Cnt[A[i]]++;
}

double dfs(int k, int i, int j) {
  if (vis[i][j] == true) return f[i][j];
  vis[i][j] = true;
  if (i == 0 && j == 0 && k == 0) return f[i][j] = 0;

  if (k != 0) f[i][j] += g[i][j + 1] * k;
  if (i != 0) f[i][j] += dfs(k, i - 1, j) * i;
  if (j != 0) f[i][j] += dfs(k, i + 1, j - 1) * j;
  f[i][j] += N;
  f[i][j] /= 1.0 * (i + j + k);
  return f[i][j];
}

void solve() {
  for (int k = 0; k <= Cnt[3]; ++k) {
    memset(vis, false, sizeof vis);
    memcpy(g, f, sizeof f);
    memset(f, 0, sizeof f);

    for (int i = 0; i <= N; ++i)
      for (int j = 0; j <= N; ++j)
        if (i + j + k <= N) dfs(k, i, j);
  }
  printf("%.10lf\n", f[Cnt[1]][Cnt[2]]);
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> vector<T> makev(T* b, T* e) {
    vector<T> vec;
    for (auto i = b; i != e; ++i) vec.push_back(*i);
    return vec;
}
struct err {
    err& operator <<(string s) { cerr << s; return *this; }
    template<class T1, class T2> err& operator <<(pair<T1, T2> x) { return *this << "(" << x.first << ", " << x.second << ")"; }
    template<class T> typename enable_if<is_scalar<T>::value == 1, err&>::type operator <<(T a) { cerr << boolalpha << a; return *this; }
    template<class T> typename enable_if<is_scalar<T>::value == 0, err&>::type operator <<(T a) {
        *this << "{";
        for (auto i = begin(a); i != end(a); ++i)
            *this << ", " + 2 * (i == begin(a)) << *i;
        return *this << "}";
    }
};
#define aty(...) "[ " << #__VA_ARGS__ << " : " << __VA_ARGS__ << " ]\n"


const ll INF = 1e18;

int32_t main() {
    ll n;
    scanf("%lld", &n);
    ll ans = INF;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            if (i * i != n) {
                ans = min(ans, i + n / i);
            }
            else {
                ans = min(ans, i + i);
            }
        }
    }
    printf("%lld\n", ans - 2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int k;
	string s;
	cin >> k >> s;
	if(s.size() <= k) cout << s << endl;
	else {
		cout << s.substr(0, k) << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    int N,S = 0;
   while(1)
   {
       cin >> N;
       int big[4] = {0},small[4],ans = 0;
       if(N == 0000)break;
       if(N % 1111 == 0)
       {
           puts("NA");
       }
       else
       {
           while(N != 6174)
           {


               big[0] = small[0] = N / 1000;
               big[1] = small[1] = (N - (big[0]*1000)) / 100;
               big[2] = small[2] = (N - (big[0]*1000 + big[1]*100)) / 10;
               big[3] = small[3] = N % 10;
               /*for(int i = 0; i < 4; i++)
               {
                   cout << big[i] << "??¨" << small[i] << endl;
               }*/
               for(int i = 0; i < 4; i++)
               {
                   for(int j = i+1; j < 4; j++)
                   {
                       if(big[i] > big[j])swap(big[i],big[j]);
                       if(small[i] < small[j])swap(small[i],small[j]);
                   }
               }
               N = 0; S = 0;
               int aaa = 1;
               for(int i = 0; i < 4; i++)
               {

                   S += small[i]*aaa;
                   N += big[i]*aaa;
                   aaa = aaa*10;
               }
               N -= S;
               ans++;
           }
           cout << ans << endl;
       }

   }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define endl "\n"


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
vll seen;
vvll graph;
vll indeg;
vll ret;


void init(ll n){
  graph.resize(n);
  indeg.resize(n,0);
  seen.resize(n,0);
  ret.resize(0);
}

void bfs(ll s){
  queue<ll> que;
  que.push(s);
  seen[s] = 1;

  while(!que.empty()){
    ll u = que.front(); que.pop();
    ret.push_back(u);
    for(ll i=0;i<graph[u].size();i++){
      ll v = graph[u][i];
      indeg[v]--;
      if(indeg[v] == 0 && seen[v] == 0){
        seen[v] = 1;
        que.push(v);
      }
    }
  }
}

void T_sort(ll n){
  for(ll i=0;i<n;i++){
    for(ll j=0;j<graph[i].size();j++){
      ll v = graph[i][j];
      indeg[v]++;
    }
  }
  for(ll i=0;i<n;i++){
    if(indeg[i] == 0 && seen[i] == 0){
      bfs(i);
    }
  }
}
//-----------------------------------------

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

  ll n;
  cin >> n;
  init(n);
  ll m;
  cin >> m;
  REP(i,m){
    ll s, t;
    cin >> s >> t;
    graph[s].push_back(t);
  }

  T_sort(n);

  REP(i,SZ(ret)) cout << ret[i] <<endl;

  return 0;
}




Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> ans(n,0);
    for(int i=0; i<n; i++){
        ans[a[i]-1] = i+1;
    }
    rep(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4008
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    int N;
    int A,B;
    cin >> N >> A >> B;

    if(N==2){
        cout << "Borys" << endl;
        return 0;
    }
    else{
        if((A+B)%2==0){
            cout << "Alice" << endl;
        }
        else{
            cout << "Borys" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N,i;cin>>N>>i;
    cout<<(N-1)*(i-1)<<endl;
}

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

using LL = long long;

int main() {
  int N;
  cin >> N;

  map<LL, int> cnt;
  vector<LL> v = {0, 0};
  for(auto i=0; i<N; ++i) {
    LL A;
    cin >> A;
    ++cnt[A];
    if(cnt[A]==2||cnt[A]==4) v.emplace_back(A);
  }
  sort(begin(v), end(v), greater<LL>());

  cout << v[0]*v[1] << endl;
}


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

int main(void){
    long long int n, i, j, ans=0, min=1000000001, nega=0, zero=0;
    scanf("%lld", &n);
    long long int a[n];
    for(i=0; i<n; i++) scanf("%lld", &a[i]);
    
    for(i=0; i<n; i++){
        if(abs(a[i])<min) min = abs(a[i]);
        ans += abs(a[i]);
        if(a[i] == 0) zero++;
        if(a[i]<0) nega++;
        nega = nega%2;
    }
    if(!zero && nega) ans = ans - min*2;
    printf("%lld", ans);
}

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

int main(void){
    string s;
    cin >> s;
    int sum = 0, mins = 1000;
    for (int i = 0; i < s.length() - 2; i++){
        sum = (s.at(i)-'0') * 100 + (s.at(i + 1)-'0') * 10 + (s.at(i + 2)-'0');
        mins = min(mins, abs(sum - 753));
    }
    cout << mins << endl;
    return 0;
    }

Measured memory_bytes: 256
import java.io.*;
  
class Main{
	public static void main(String[] args) throws IOException{

		int x,y,i,j;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i%2 == 0){
						if(j%2 == 0){
							System.out.printf("#");
						}else {
							System.out.printf(".");
						}
					}else {
						if(j%2 == 1){
							System.out.printf("#");
						}else {
							System.out.printf(".");
						}
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
  	}
}

Measured memory_bytes: 47884
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        R: f64,
    }

    println!("{}", 2. * R * PI);
}


Measured memory_bytes: 2204
def solve():
    l, r = map(int, input().split())
    ans = 2018
    for i in range(l, min(l + 2019, r + 1)):
        for j in range(i + 1, min(l + 2019, r + 1)):
            ans = min(ans, i * j % 2019)
    print(ans)
solve()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>

constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;

using namespace std;
vector<int> a;
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	vector<ll> arr(n, 0);
	vector<ll> count(200001, 0);
	for (ll i = 0; i < n; i += 1)
	{
		cin >> arr[i];
		count[arr[i]] += 1;
	}
	ll ans = 0;
	for (ll i = 0; i < 200001; i += 1)
	{
		if(count[i]>0)
		ans += (count[i] * (count[i] - 1) / 2);
	}
	for (ll i = 0; i < n; i += 1)
	{
		ll temp = arr[i];
		//ans -= count[temp] + 1;
		ans -= (count[temp] * (count[temp] - 1) / 2);
		ans += ((count[temp]-1) * (count[temp] - 2) / 2);
		cout << ans << "\n";
		ans += (count[temp] * (count[temp] - 1) / 2);
		ans -= ((count[temp] - 1) * (count[temp] - 2) / 2);
	}
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

signed main(){
	ll n; cin>>n;
	ll ans=0;
	if(n%2==1){
		cout<<0<<endl;
		return 0;
	}
	while(n>0){
		n/=5;
		ans+=n-(n%2);
	}
	cout<<ans/2<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;
struct point {int x, y;};
int main() {
  point a, b, c, d;
  cin >> a.x >> a.y >> b.x >> b.y;
  c.x = b.x-b.y+a.y;
  c.y = b.x+b.y-a.x;
  d.x = c.x-c.y+b.y;
  d.y = c.x+c.y-b.x;
  cout << c.x << " " << c.y << " " << d.x << " " << d.y << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int n, x, l, cnt = 1, d = 0;
    cin >> n >> x;

    for (int i = 0; i < n; i++)
    {
        cin >> l;
        d += l;
        if (d <= x)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000003

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int maxn = 100001;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
long long  gcd(long long  a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

bool check1(string s,int p)
{
    p = p-1;
    int j=p;
    for(int i=0;i<=j;i++,j--)
    {
        if(s[i] != s[j])
            return false;
    }
    return true;
}

bool check2(string s,int p,int n)
{

    int j=n-1;
    for(int i=p-1;i<=j;i++,j--)
    {
        if(s[i] != s[j])
            return false;
    }
    return true;
}

int main()
{
    fast;
    int n;
    cin>>n;
    map<ll, ll> mp;
    map<ll,ll> :: iterator it;
    ll x[n+1];
    for(int i=0;i<n;i++)
    {
        
        cin>>x[i];
        mp[x[i]]++;
    }
    
    ll sum = 0;
    for(it = mp.begin() ; it !=  mp.end() ; it++)
    {
        ll xx = it->second;
        xx = (xx*(xx-1))/2;
        sum+= xx;
        //cout<<sum<<endl;
    }
    
    for(int i = 0;i<n;i++)
    {
        ll m = mp[x[i]];
        ll p = (m*(m-1))/2;
        ll ans = sum-p;
        m = m-1;
        p = (m*(m-1))/2;
        ans += p;
        cout<<ans<<endl;
    }
    
   
    
}


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

int main(){
  int r,c,k;
  cin>>r>>c>>k;
  map<int,ll> item;
  rep(i,k){
    int l,m,v;
    cin>>l>>m>>v;
    l--; m--;
    item[c*l+m]=v;
  }

  vector<vector<ll>> dp1(3005,vector<ll>(4,-1));
  vector<vector<ll>> dp2(3005,vector<ll>(4,-1));
  dp2[0][0]=0;
  if(item.count(0)) dp2[0][1]=item[0];
  rep(i,r){
    rep(j,c){
      if(i>0){
	rep(k,4){
	  if(dp1[j][k]!=-1){
	    dp2[j][0]=max(dp2[j][0],dp1[j][k]);
	    if(item.count(i*c+j)) dp2[j][1]=max(dp2[j][1],dp1[j][k]+item[i*c+j]);
	  }
	}
      }
      if(j>0){
	rep(k,4){
	  if(dp2[j-1][k]!=-1){
	    dp2[j][k]=max(dp2[j][k],dp2[j-1][k]);
	  }
	}
	rep(k,3){
	  if(dp2[j-1][k]!=-1){
	    if(item.count(i*c+j)) dp2[j][k+1]=max(dp2[j][k+1],dp2[j-1][k]+item[i*c+j]);
	  }
	}
      }
    }
    dp1=dp2;
  }
  
  ll ans=0;
  rep(i,4) ans=max(dp1[c-1][i],ans);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 16472
def main():
    a, b, c, x, y = map(int, input().split())
    res = a * x + b * y
    for n_c in range(2, 2 * max(x, y) + 1, 2):
        xx = x - n_c // 2
        yy = y - n_c // 2
        p = a * max(xx, 0) + b * max(yy, 0) + c * n_c
        res = min(res, p)
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# input here
_INPUT = """\
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
2 AC
"""

def main():
    n, m = map(int, input().split())

    seikai = [False] * n
    matigai = [0] * n

    for i in range(m):
        p,q = map(str, input().split())
        p = int(p)-1

        if q == "AC":
            seikai[p] = True
        else:
            if seikai[p] != True:
                matigai[p] += 1

    num = 0
    ac = 0
    for i in range(n):
        if seikai[i] == True:
            num += matigai[i]
            ac += 1
    print(ac,num)
            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 76256
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int win = 0;
    int loss = 0;
    for (int i = 0; i < n; ++i) {
        bool my_paper = i & 1;
        if (!my_paper && s[i] == 'p') {
            ++loss;
        } else if (my_paper && s[i] == 'g') {
            ++win;
        }
    }

    cout << (win - loss) << '\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if(500*i + 100*j + 50*k == x)count++;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int k;
  cin >> k;
  queue<ll> q;
  rep(i, 9) q.push(i + 1);

  ll ans;
  rep(i, k) {
    ans = q.front();
    q.pop();
    if(ans % 10 != 0)
      q.push(10 * ans + ans % 10 - 1);
    q.push(10 * ans + ans % 10);
    if(ans % 10 != 9)
      q.push(10 * ans + ans % 10 + 1);
  }
  cout << ans;
}


Measured memory_bytes: 5072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];
		for ( int i = 0 ; i < N ; i++ ) {
			A[i] = sc.nextInt();
		}
		for ( int i = 0 ; i < N ; i++ ) {
			B[i] = sc.nextInt();
		}
		for ( int i = 0 ; i < N - 1 ; i++ ) {
			C[i] = sc.nextInt();
		}
		sc.close();

		int s = 0;
		for ( int i = 0 ; i < N ; i++ ) {
			s += B[A[i] - 1];
			if ( i >= 1 && A[i] == A[i - 1] + 1 ) {
				s += C[A[i - 1] - 1];
			}
		}
		System.out.println(s);
	}
}


Measured memory_bytes: 21844
N = int(input())
a = []
for i in range(N):
    b = int(input())
    a.append(b)
ans = 0
tmp = 1
flag = False
while(1):
    tmp = a[tmp-1]
    ans += 1
    if tmp==2:
        flag = True
        break
    if ans > N:
        break
if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 7084
import sys
from pprint import pprint

def solve(n, k, p):
    acum_E = [0]
    sum_E = 0
    for i, p_i in enumerate(p):
        sum_E += (1.0 + p_i)/2 
        acum_E.append(sum_E)
    # pprint(acum_E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+k, i)
        ans = max(ans, acum_E[i + k] - acum_E[i])
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Measured memory_bytes: 77364
def insertion_sort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j = j-1
        A[j+1] = v

        print(*A)

if __name__ == '__main__':
    N = int(input())
    A = [int(_) for _ in input().split()]

    print(*A)

    insertion_sort(A, N)

Measured memory_bytes: 6756