akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

void solve() {
    ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z); if (x == 0 and y == 0 and z == 0) exit(0);
    ll a = INF, b = INF;
    for (ll i = 0; i <= 500000; i++) {
        {
            ll t = x * i;
            if (llabs(z - t) % y == 0) {
                ll j = llabs(z - t) / y;
                if (i + j < a + b or (i + j == a + b and i * x + j * y < a * x + b * y)) {
                    a = i, b = j;
                }
            }
        }
        {
            ll t = x * i;
            if (llabs(-z - t) % y != 0) continue;
            ll j = llabs(-z - t) / y;
            if (i + j < a + b or (i + j == a + b and i * x + j * y < a * x + b * y)) {
                a = i, b = j;
            }
        }
    }
    printf("%lld %lld\n", a, b);
}

int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */
    int kkt = 89;
    while (kkt) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3148
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b) = sc.nextLine.split(" ").map(_.toInt)
    if (a == b) println("Draw")
    else if (a == 1) println("Alice")
    else if (b == 1) println("Bob")
    else if (a > b) println("Alice")
    else println("Bob")
  }
}


Measured memory_bytes: 27476
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  REP(i,n) cin >> s[i];
  sort(ALL(s));
  REP(i,n) cout << s[i];
  cout << endl;

  return 0;
}


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

using namespace std;

int a[1003][1003];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int k=0;
	while(k*(k-1)<2*n) k++;
	if(k*(k-1)!=2*n){
		cout << "No";
		return 0;
	}else{
		cout << "Yes" << endl;
		cout << k << endl;
		int ind=1;
		for(int i=1;i<=k;i++){
			cout << k-1 << " ";
			int j;
			for(j=1;j<i;j++){
				a[i][j] = a[j][i];
				cout << a[j][i-1] << " ";
			}
			for(;j<=k-1;j++,ind++){
				a[i][j] = ind;
				cout << ind << " ";
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3200
from collections import deque

N = int(input())
vertex_neighbor_vertices = {}  # 各頂点と、その頂点に隣接する頂点リストのマップ
vertex_colors = {}  # 各頂点と、その頂点を端点に持つ辺に塗られた色セットのマップ
sides = []  # 辺情報（(a_i, b_i)のタプル形式で、順番を保持）
side_color = {}  # 辺とその辺に塗られた色のマップ


def add_neighbors(start, end):
    neighbors_of_s = set()
    if start in vertex_neighbor_vertices:
        neighbors_of_s = vertex_neighbor_vertices[start]
    else:
        vertex_neighbor_vertices[start] = neighbors_of_s
    neighbors_of_s.add(end)


def init_colors(vertex):
    colors = set()
    if vertex not in vertex_colors:
        vertex_colors[vertex] = colors


def get_unused_color(colors_of_sv, colors_of_ev, color_start):
    for i in range(color_start, N + 1):
        if (i not in colors_of_sv) and (i not in colors_of_ev):
            return i


for i in range(N - 1):
    s, e = map(int, input().split())
    sides.append((s, e))
    add_neighbors(s, e)
    add_neighbors(e, s)
    init_colors(s)
    init_colors(e)

max_color_num = 0
max_neighbor_vertex = 0
for k, v in vertex_neighbor_vertices.items():
    if len(v) > max_color_num:
        max_color_num = len(v)
        max_neighbor_vertex = k

print(max_color_num)

# 辺を最も多く持つ頂点を起点に、幅優先探索で辺を色付けしていく
visited = set()
q = deque([max_neighbor_vertex])

while q:
    vertex = q.popleft()
    visited.add(vertex)
    # 色付け
    color_start = 1
    for neighbor in vertex_neighbor_vertices[vertex]:
        if neighbor in visited:
            continue
        q.append(neighbor)
        color = get_unused_color(vertex_colors[vertex], vertex_colors[neighbor], color_start)
        color_start = color + 1
        vertex_colors[vertex].add(color)
        vertex_colors[neighbor].add(color)
        side_color[(vertex, neighbor)] = color

for s, e in sides:
    color = 0
    if (s, e) in side_color:
        color = side_color[(s, e)]
    else:
        color = side_color[(e, s)]
    print(color)


Measured memory_bytes: 100116
n,m=map(int,input().split())
ks=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  switch=[0]*n
  cnt_on=0
  for j in range(n):
    if (i>>j)&1:
      switch[j]+=1
  for j in range(m):
    cnt=0
    for k in range(ks[j][0]):
      if switch[ks[j][k+1]-1]==1:
        cnt+=1
    if cnt%2==p[j]:
      cnt_on+=1
  if cnt_on==m:
    ans+=1
print(ans)

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

int main(){
int n,l,ans;
cin >> n >> l;
for(int i=0; i<n; i++){
    if(l>=0){
        ans = (((l+1)+(l+n-1))*(n-1))/2;
    }else if((l+n)>=1){
        ans = ((l+(l+n-1))*n)/2;
    }else{
        ans = ((l+(l+n-2))*(n-1))/2;
    }
}
cout << ans << endl;
return 0;
}

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



int main (){
   
    
    char s[6];
    cin >> s;
    if(s[2] == s[3] && s[4]==s[5]){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
a, b, m = map(int, input().strip().split())
as_ = list(map(int, input().strip().split()))
bs = list(map(int, input().strip().split()))
xyc = [list(map(int, input().strip().split())) for _ in range(m)]

min_no_discount = min(as_) + min(bs)

min_discount = 1e20
for x, y, c in xyc:
    min_discount = min(min_discount, as_[x - 1] + bs[y - 1] - c)

print(min(min_discount, min_no_discount))


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

typedef long long ll;


int main() {
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        string s;
        int a=0,b=0,c=0,d=0;
        for(int i=0;i<n;i++){
            cin>>s;
            if(s=="AC")
                a++;
            else if(s=="TLE")
                b++;
            else if(s=="WA")
                c++;
            else
                d++;
        }
        cout << "AC x " << a << endl;
    	cout << "WA x " << c << endl;
    	cout << "TLE x " << b << endl;
    	cout << "RE x " << d << endl;
    }
	return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    string s; cin >> s;

    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    cout << mp[s] << endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
void inputoutput()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0); 
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
       
}

int n,m;
vector<int> adj[100500];
vector<bool> vis(100500);
vector<int> d(100500);
queue<int> q ;



void bfs(int v)
{
   q.push(v);
   vis[v]=true;
   while(!q.empty())
   {
      int x=q.front();
      q.pop();
      for(auto u : adj[x])
      {
         if(!vis[u])
         {
            vis[u]=true;
            q.push(u);
            d[u] = d[v] + 1;
         }
      }
   }
}
void dfs(int v)
{
   vis[v]=true;
   for(auto u : adj[v])
   {
      if(!vis[u])
         dfs(u);
   }
}

void solve()
{
	cin>>n>>m;
	for(long long int i=0 ; i<m ; ++i)
	{
		long long int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}	
	long long int roadreq=0;
 
 
	for(long long int i=1 ; i<=n ; ++i)
	{
		if(!vis[i])
		{
			dfs(i);
			roadreq++;
		}
	}
 
 
	cout<<roadreq-1<<"\n";

}

int main()
{ 
   inputoutput() ;

   solve();
   


   return 0;
}


Measured memory_bytes: 9528
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

vvi Graph(100010);
vi dp(100010, 0);
vb seen(100010, false);

int dfs(int v){
  if(seen[v]) return dp[v];
  seen[v] = true;
  int ret = 0;
  for(int nv : Graph[v]){
    ret = max(ret, dfs(nv)+1);
  }
  return dp[v] = ret;
}

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    Graph.at(x-1).push_back(y-1);
  }
  int ans = 0;
  rep(i,n) ans = max(ans, dfs(i));
  cout << ans << endl;
}


Measured memory_bytes: 11056
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

void Main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  auto getPositions = [&] {
    vector<int> res;
    for (int i = 0; i < n && res.size() < k;) {
      if (s[i] == 'o') {
        res.push_back(i);
        i += c+1;
      } else {
        ++i;
      }
    }
    return res;
  };
  vector<int> l, r;
  l = getPositions();
  reverse(s.begin(), s.end());
  r = getPositions();
  rep(i, r.size()) r[i] = n - r[i] - 1;
  reverse(r.begin(), r.end());
  rep(i, min(l.size(), r.size())) if (l[i] == r[i]) cout << l[i] + 1 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3468
#include "bits/stdc++.h"

using namespace std;

#define int long long // −9·10^18 to 9·10^18
#define lll __int128_t //−10^38 to 10^38
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<int, int> mi;

//const
#define EPS 1e-9
#define INF LLONG_MAX
const int mod = 1000 * 1000 * 1000 + 7; //1e9+7

// inputs & output & debug
#define w(t) int t; cin>> t; while(t--)

template<typename... T>
void read(T&... args) {
	((cin >> args), ...);
}

template<typename... T>
void write(T&&... args) {
	((cout << args << " "), ...);
}

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

//useful functions
//#define deb(x) cout<<#x<<": "<<x<<endl;
#define isPowOfTwo(x) return (x && (!(x&(x-1))));
#define gcd(x,y) return __gcd(x,y);

void fio()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("/Users/asuryana/Desktop/CP/input.txt", "r", stdin);
	freopen("/Users/asuryana/Desktop/CP/output.txt", "w", stdout);
#endif
}

void solve()
{
	int n; read(n);
	int s[125] = {0};
	for (int i = 1; i <= 120; i++) s[i] = pow(i, 5);
	for (int i = 0; i <= 120; i++)
		for (int j = 0; j <= 120; j++)
		{
			if ((s[i] - s[j]) == n)
			{
				write(i, j); return;
			}
			if ((s[j] + s[i]) == n)
			{
				write(j, -i); return;
			}
		}

}

int32_t main()
{
	fio();
	return solve(), 0;
}


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

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << endl;
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

vi cnt(1e5+1);

void solve(){
	int n;
	cin >> n;
	
	for(int i=1 ; ; ++i){
		if(i*i > n)break;
		for(int j=1 ; ; ++j){
			if(i*i + j*j + i*j > n)break;
			for(int k=1 ; ; ++k){
				int x = i*i + j*j + k*k + i*j + j*k + k*i;
				if(x > n)break;
				cnt[x]++;
			}
		}
	}
	
	for(int i=1 ; i<=n ; ++i)cout << cnt[i] << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3632
A, B = map(int,input().split())

#偶数×偶数＝偶数、偶数×奇数＝偶数、奇数×奇数＝奇数。
#A*Bが偶数なら、A*B*Cが奇数となるような整数Cは無い。A*Bが奇数なら、A*B*Cが奇数となるような整数Cは無い

if A*B %2 == 0:
    print("No")

if A*B %2 == 1:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int INF=1e9;
const ll mod = 1e9 + 7;

int main(){
	ll n,sum1=1,sum2=1,ans =1;
	cin >> n;
	rep(i,n){
		ans *= 10;
		sum1 *= 9;
		sum2 *= 8;
		ans%=mod;
		sum1%=mod;
		sum2%=mod;
	}
	ans -= (sum1 * 2);
	ans%=mod;
	ans += sum2;
	ans%=mod;
	ans=(ans+mod)%mod;
	cout << ans << endl;
}

Measured memory_bytes: 3596
import math
import itertools

x,y=map(int, input().split()) 
v=x+y
if v%3!=0:
    print(0)
    exit()

if (v//3-abs(x-y))%2!=0:
    print(0)
    exit()

v1=(v//3-abs(x-y))//2+abs(x-y)
v2=v//3-v1

if v2<0:
    print(0)
    exit()

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

a = cmb(v//3,v1)
a//(math.factorial(v2))

print(a%(10**9+7))






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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
n = int(input())
l = [int(i) for i in input().split()]

cnt = 0
for i in range(1,n-1):
    if (l[i+1] >= l[i] and l[i-1] <= l[i]) or (l[i+1] <= l[i] and l[i-1] >= l[i]):
        cnt += 1 
    
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int used[200010];
bool ok[200010];

void solve() {
    int n,k;
    cin >> n >> k;
    int a[k];
    REP(i,k) {
        cin >> a[i];
        a[i]--;
        used[a[i]]++;
        ok[a[i]] = 1;
    }
    reverse(a,a+k);
    REP(i,k) {
        if (used[a[i]] != 0) {
            cout << a[i] + 1 << endl;
            used[a[i]] = 0;
        }
    }
    REP(i,n) {
        if (!ok[i]) cout << i+1 << endl;
    }
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}


Measured memory_bytes: 4428
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

struct edge{ int from,to,cost; };

edge es[2010];    //辺
ll d[1010];   //最短距離
int n,m,sm;


bool BF(int s,int V,int E){ //vは頂点数eは辺の数
	REP(i,V)d[i] = -10000000000000;d[s] = 0;
	int cou = E;
	while(cou--){
		REP(i,E){
			edge e = es[i];
			if(d[e.from] != -10000000000000 && d[e.to] < d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
	ll tmp = d[n-1];
	cou = E;
	while(cou--){
		REP(i,E){
			edge e = es[i];
			if(d[e.from] != -10000000000000 && d[e.to] < d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
	if(tmp < d[n-1])return false;
	return true;
}


int main()
{
	cin >> n >> m;
	
	REP(i,m)
	{
		int a,b,c;
		cin >> a >> b >> c;
		es[i].from = a-1;es[i].to = b-1;es[i].cost = c;
		if(c > 0)sm+=c;
	}
	
	if(BF(0,n,m))
	{
		cout << d[n-1] << endl;
	}
	else
	{
		cout << "inf" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}
  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};
struct Circle{
  Point c;
  double r;
};
typedef Point vect;
struct seg{Point p1,p2;};
double norm(Point p){return p.x*p.x+p.y*p.y;}
//??¶???????????????absolute  ?????????????????¶?????????
double abs(Point p){return sqrt(norm(p));}
//?????????????????????????????????
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
//?????? ????????????????????????
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
//??´??????????????¢(????°?)???????????????
double getDistanceLP(seg l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}
//?????????????????¢??????????????????
double getDistanceSP(seg s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}
int main(){
  int n,m;
  double r;
  while(cin>>r>>n,n+r){
    int h[50]={};
    seg s[50];
    r(i,50)s[i].p1.x=i,s[i].p1.y=0,s[i].p2.y=0,s[i].p2.x=i+1;
    r(i,n){
      int a,b,c;
      cin>>a>>b>>c;
      for(int i=a+25;i<b+25;i++)
        s[i].p1.y=s[i].p2.y=max(s[i].p1.y,(double)c);
    }
  int p=0,t=0;
    Point time;
    time.x=25;
    time.y=-r;
    double d=0;
    while(1){
      r(i,50)if((getDistanceSP(s[i],time)<(double)r-EPS)){
        printf("%.4f\n",d-0.0001);
        goto L;
      }
      d+=0.0001;
      time.y+=0.0001;
    }
    L:;
  }
}

Measured memory_bytes: 3128
def d_card_eater(N, A):
    # 解説どおり
    kind = len(set(A))  # 数列に現れる値の種類の数
    ans = kind if kind % 2 == 1 else kind - 1
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(d_card_eater(N, A))

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "-1" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    ll ct=0;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    if(A[0]!=0) dame;
    rep(i,N-1){
        if(A[i+1]>A[i]+1) dame;
    }
    ll ima=A[N-1];
    ct+=A[N-1];
    repr(i,N-2,0){
        if(A[i]!=A[i+1]-1) ct+=A[i];
    }
    cout<< ct <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    X = X * 2;
    Y = Y * 2;
    ll value = numeric_limits<ll>::max();
    for (auto &&i: boost::irange(0LL, max(X, Y) + 1)){
        ll AB_pizza = i;
        ll A_pizza_from_AB = AB_pizza;
        ll B_pizza_from_AB = AB_pizza;
        ll A_pizza_remaining = X - A_pizza_from_AB;
        ll B_pizza_remaining = Y - B_pizza_from_AB;
        ll A_pizza_to_be_bought = max(0LL, (A_pizza_remaining+1) / 2);
        ll B_pizza_to_be_bought = max(0LL, (B_pizza_remaining+1) / 2);
        value = min(value, A * A_pizza_to_be_bought + B * B_pizza_to_be_bought + C * AB_pizza);
    }
    cout << value << endl;
    return 0;
}

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

int main(void) {
	
	bool isTrue = true;
	char S[3];
	cin >> S;
	for(int i=0; i<3; i++) {
		char t;
		switch(i) {
		case 0:
			t = 'a';
			break;
		case 1:
			t = 'b';
			break;
		case 2:
			t = 'c';
			break;
		}
		
		int count = 0;
		for(int j=0; j<3; j++) {
			if(S[j] == t) {
				count++;
			}
		}
		if(count!=1) {
			isTrue = false;
			break;
		}
	}

	if(isTrue) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int main(){
    int N; cin >> N;
    vector<int> t(N+1,0), x(N+1,0), y(N+1,0);

    for(int i=1; i<=N; i++) cin >> t[i] >> x[i] >> y[i];

    bool flg = true;
    for(int i=1; i<=N; i++){
        int mht = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        int time = t[i]-t[i-1];
        if(!(time >= mht && (time%2) == (mht%2))){
            flg = false;
            break;
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstring> 
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int par[maxn],num[maxn],u,v;
ll ans[maxn],tmp;
int n,m;
struct edge
{
	int u,v;
}e[maxn];
void init(int n)
{
	for(int i=0;i<n;++i)
	par[i]=i,num[i]=1;
}
int find(int x)
{
	return par[x]==x?x:par[x]=find(par[x]);
}
void unite(int x,int y)
{
	x=find(x),y=find(y);
	if(x==y)return;
	if(x<y)par[y]=x,num[x]+=num[y];
	else par[x]=y,num[y]+=num[x];
}
int main()
{
	scanf("%d%d",&n,&m);
	init(n);
	for(int i=0;i<m;++i)scanf("%d%d",&e[i].u,&e[i].v);
	for(int i=m-1;i>=0;--i)
	{
		if(i==m-1)ans[i]=1ll*n*(n-1)/2;
		else ans[i]=ans[i+1]-tmp;
		u=find(e[i].u),v=find(e[i].v);
		if(u==v)tmp=0;
		else
		{
		 tmp=num[u]*num[v];
		 unite(u,v);
	    }
	}
	for(int i=0;i<m;++i)
	printf("%lld\n",ans[i]);
	return 0;
} 

Measured memory_bytes: 3712
MOD = 10**9 + 7

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

def getComb(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

def getCombNs(n, invs, MOD):
    combNs = [1] * (n//2+1)
    for x in range(1, n//2+1):
        combNs[x] = (combNs[x-1] * (n-x+1) * invs[x]) % MOD
    return combNs + combNs[:(n+1)//2][::-1]

def getInvs(n, MOD):
    invs = [1] * (n+1)
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs


ans = getComb(2*n-1, n, MOD)

if k < n-1:
    m = n-1-k
    invs = getInvs(n+3, MOD)
    combNs = getCombNs(n, invs, MOD)
    combN1s = getCombNs(n-1, invs, MOD)

    for i in range(m):
        ans -= combN1s[i] * combNs[i+1] % MOD
        ans %= MOD

print(ans)


Measured memory_bytes: 22756
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n,m,d;
    cin>>n>>m>>d;
    doublecout(((d)?2:1)*(m-1)*(n-d)/(n*n));
    return 0;
}


Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,x(2000),b,c,d,s,t,k
    integer(8),allocatable :: a(:),y(:)
  
    read(*,*) n,k
    allocate(a(n))
    read(*,*)a
    s=0
    t=0
    x(:)=0
    do i=1,n
        b=a(i)
        c=0
        x(b)=x(b)+1
        if(b>=2)then
            do j=1,b-1
                c=c+x(j)
            end do
        end if
        s=s+c
        t=t+i-x(b)-c
    end do
    d=10**9+7
    m=mod(k*(k-1)/2,d)
    
    s=mod(s*m,d)
    t=mod(t*(m+k),d)
    m=mod(s+t,d)
   

    write(*,*) m
  
    stop
end program sample
  



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

int main(){
    
    int a;
    string s;
    cin >> a >> s;

    if(a>=3200)cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a1,a2,b1,b2,a,b;
    scanf("%d %d %d %d",&a1,&a2,&b1,&b2);
    a=a1*a2;b=b1*b2;
    if(a>=b) printf("%d",a);
    else if(a<b) printf("%d",b);
    return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
const ll MOD=1000000007LL;
int main(){
  ll N;
  cin>>N;
  for(ll h=1;h<=3500;h++){
    for(ll n=1;n<=3500;n++){
      if(4*h*n-N*(n+h)==0)continue;
      if((N*h*n)%(4*h*n-N*(n+h))==0){
        if(N*h*n/(4*h*n-N*(n+h))<=0)continue;
        cout<<h<<" "<<n<<" "<<N*h*n/(4*h*n-N*(n+h))<<endl;
        return 0;
      }
    }
  }
}
      

Measured memory_bytes: 384
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();
int area = a*b;
int length = 2*a+2*b;
System.out.println(area + " " + length);
}
}



Measured memory_bytes: 26032
#include<stdio.h>
#include<string.h>
int F(int c)
{
	if(c=='(')return')';
	if(c==')')return'(';
	return c;
}
int main()
{
	char s[16];
	scanf("%s",s);
	int i,l=strlen(s),r=0;
	if(l&1)r=(s[l/2]!=F(s[l/2]));
	for(i=0,--l;i<l;++i,--l)r+=(s[i]!=F(s[l]));
	printf("%d\n",r);
}

Measured memory_bytes: 0
N,M=map(int, input().split())
from collections import defaultdict
A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
D=defaultdict(int)
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    D[now]+=1
    twos=max(twos, now)
if len(set(D.values()))!=1:
    print(0)
    exit()
now=1
for i in range(N):
    now=lcm(now, B[i])

# 1.5 * 3 2*5
from math import ceil

ans=ceil(M//now/2)


print(ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 10000000000

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

int main(){
	int n,k;
	cin >> n >> k;
	ll a[n];
	FOR(i,n) cin >> a[i];
	ll sol[n];
	FOR(i,n) sol[i]=INF;
	sol[n-1]=0;
	for (int i = n-2; i >-1; --i)
	{
		for(int j=1 ; j <= min(n-1-i , k) ; j++){
			sol[i]=min(sol[i],abs(a[i+j]-a[i])+ sol[i+j]);
		}
	}
	cout << sol[0];

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


int main()
{
    int r;
    cin >> r;
    pr(2*r*3.1415926535);

    return 0;
}



Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(){
    string s; cin>>s;
    string t=s;
    reverse(all(t));
    cout<<(s==t?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#define maxn 100005
#define LL long long

using namespace std;

LL n,m,ans[maxn];
int ret=0;

void dfs(int len,int n,int k,LL now)
{
	if (n==len)
	{
		ans[ret++]=now;
		return;
	}
	for (int i=max(k-1,0);i<=min(k+1,9);i++)
	{
		dfs(len,n+1,i,now*10+i);
		if (ret==100000) return ;
	}
}

void solve()
{
	for (int i=1;i<=10;i++)
		for (int j=1;j<=9;j++)
		{
			if (ret==100000) return;
			dfs(i,1,j,j);
			if (ret==100000) return ;
		}
}

int main()
{
	solve();
	scanf("%lld",&n);
	cout <<ans[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#define N 500010
#define ll long long
#define squ(x) ((x)*(x))
using namespace std;

int n, l, r, q[N];
ll dp[N], s[N], M;

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

inline ll f(int k, int j) {return dp[j] + squ(s[j]) - (dp[k] + squ(s[k]));}
inline ll g(int k, int j) {return s[j] - s[k];}

void DP() {
	l = 1, r = 0; q[++r] = 1; dp[0] = 0;
	for (int i = 2; i <= n; ++i) {
		while (l < r && f(q[l], q[l + 1]) <= 2 * 1ll * s[i]*g(q[l], q[l + 1])) l++;
		int j = q[l];
		dp[i] = dp[j] + squ(s[i] - s[j]) + M;
		while (l < r && f(q[r], i) * 1ll * g(q[r - 1], q[r]) < f(q[r - 1], q[r]) * 1ll * g(q[r], i)) r--; //保证斜率单调
		q[++r] = i;
	}
}

int main() {
	n = read(); scanf("%lld", &M);
	{
		for (int i = 1; i <= n; ++i)scanf("%lld", &s[i]);
		DP();
		printf("%lld\n", dp[n]);
	}
	return 0;
}

Measured memory_bytes: 8320
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int N;
	string S, T;
	char ans[300] = {0};

	cin >> N >> S >> T;

	int j = 0;
	for (int i = 0; i < N; i++) {
		ans[j] = S[i];
		ans[j + 1] = T[i];
		j += 2;
	}
	ans[j] = '\0';

	puts(ans);

	return 0;
}

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

using namespace std;

int n;
vector<int> v[200005];
int cnt[200005];
int s[200005];
int f[200005];
int ans[200005];
const int MOD = 1000000007;

int pow(int x, int y) {
  if (y == 0) {
    return 1;
  }
  if (y % 2 == 0) {
    return pow(1ll * x * x % MOD, y / 2);
  } else {
    return 1ll * x * pow(x, y - 1) % MOD;
  }
}

int inv(int x) {
  return pow(x, MOD - 2);
}

int nCr(int n, int r) {
  return 1ll * f[n] * inv(f[r]) % MOD * inv(f[n - r]) % MOD;
}

void dfs(int x, int y) {
  for (auto u: v[x]) {
    if (u != y) {
      dfs(u, x);
    }
  }
  cnt[x] = 1;
  s[x] = 1;
  for (auto u: v[x]) {
    s[x] += s[u];
  }
  int z = s[x] - 1;
  for (auto u: v[x]) {
    if (u != y) {
      cnt[x] = 1ll * cnt[x] * nCr(z, s[u]) % MOD * cnt[u] % MOD;
      z -= s[u];
    }
  }
}

void dfs2(int x, int y) {
  int z = s[1] - 1;
  ans[x] = 1ll * nCr(z, s[1] - s[x]) * (1ll * ans[y] * inv(1ll * nCr(z, s[x]) * cnt[x] % MOD) % MOD) % MOD;
  z -= s[1] - s[x];
  for (auto u: v[x]) {
    if (u != y) {
      ans[x] = 1ll * ans[x] * nCr(z, s[u]) % MOD * cnt[u] % MOD;
      z -= s[u];
    }
  }
  for (auto u: v[x]) {
    if (u != y) {
      dfs2(u, x);
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = 1ll * i * f[i - 1] % MOD;
  }
  dfs(1, 0);
  ans[1] = cnt[1];
  for (auto u: v[1]) {
    dfs2(u, 1);
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", ans[i]);
  }
}


Measured memory_bytes: 17140
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math as mt

def main():
    A, B, H, M = map(int, input().split())

    theta1 = 30*H + M/2
    theta2 = 6*M

    xx = A**2 + B**2 - 2*A*B*mt.cos(mt.radians(theta2-theta1))
    print(mt.sqrt(xx))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9444
#include <iostream>
int main () {
      int a, b;
 
      std::cin >> a;
      std::cin >> b;
 
     if (a > b) {
         std::cout << "a > b\n";
     }
     else if (a < b) {
         std::cout << "a < b\n";
     }
     else {
         std::cout << "a == b\n";
     }

     return 0;
 }



Measured memory_bytes: 3084
/*
* @author:  codancer
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef pair<int,int> pii;
ll cnt[300000];
int main(){
	int n;
	cin>>n;
	vector<int> a(n+1);
	rep(i,1,n){
		 cin>>a[i];
		 ++cnt[a[i]];
	}
	long long ans=0;
	rep(i,1,200000){
		if(cnt[i]){
			ans+=cnt[i]*(cnt[i]-1)/2;
		}
	}
	rep(i,1,n){
		cout<<ans-(cnt[a[i]]-1)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3968
def lcm(a, b):
    from fractions import gcd

    return a // gcd(a, b) * b


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    x = 1

    for e in a:
        x = lcm(x, e)

    ans = 0
    for e in a:
        ans += x // e

    print(ans % int(1e9 + 7))


main()


Measured memory_bytes: 5612
using System;

class Program
{
	static void Main(string[] args)
	{
		//入力数を分解して配置
		string input = Console.ReadLine();
		int Count = 0;

		if (input[0] =='1')
			Count++;
		if (input[1] == '1')
			Count++;
		if (input[2] == '1')
			Count++;
		Console.WriteLine(Count);
	}
}

Measured memory_bytes: 25716
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length();
vector<int> v;
rep(i,0,n-1)
{
	if(s[i]=='S')
	v.pb(1);
	else
	{
		if(v.size()==0)
		v.pb(0);
		else
		{
			if(v.back()==1)
			{
				v.pop_back();
			}
			else
			v.push_back(0);
		}
	}
}
ol(v.size());
return 0;
}


Measured memory_bytes: 1552
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,c;
    cin>>n>>c;
    int d[c][c];
    for(int i=0;i<c;i++)for(int j=0;j<c;j++)cin>>d[i][j];
    int color[n][n];
    int x[3][c];
    for(int i=0;i<3;i++)for(int j=0;j<c;j++)x[i][j]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>color[i][j];
            x[(i+j)%3][color[i][j]-1]++;
        }
    }
    int m=1000000000;
    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            if(i==j)continue;
            for(int k=0;k<c;k++){
                if(i==k || j==k)continue;
                int iwakan=0;
                for(int l=0;l<c;l++){
                    iwakan+=x[0][l]*d[l][i];
                    iwakan+=x[1][l]*d[l][j];
                    iwakan+=x[2][l]*d[l][k];
                }
                m=min(m,iwakan);
            }
        }
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i, n) FOR(i, 0, (n)-1)
#define ROF(i, a, b) for(int (i)=(a); (i)>=(b); (i)--)
#define PER(i, n) ROF(i, (n)-1, 0)
int sod(int a){
	int ret=0;
	while(a){
		ret+=a%10;
		a/=10;
	}
	return ret;
}
int main(){
	int n;
	scanf("%d", &n);
	int ans=0x3f3f3f3f;
	FOR(a, 1, n-1){
		int b=n-a;
		ans=min(ans, sod(a)+sod(b));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j,v,N,n,z;
  int A[1000];

  scanf("%d",&N);
  if (N>=1 && N<=100){
    for (n=0; n<N; n++) scanf("%d",&A[n]);
  }

  for (z=0; z<N-1; z++) printf("%d ",A[z]);
  printf("%d", A[z]);
  printf("\n");

  for (i=1; i<N; i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for (z=0; z<N-1; z++) printf("%d ",A[z]);
    printf("%d", A[z]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2100
#include <cstdio>

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);
    int value;
    if(A <= 5)
        value = 0;
    else if(A <= 12)
        value = B / 2;
    else
        value = B;
    printf("%d\n", value);
    return 0;
}


Measured memory_bytes: 128
N = int(input())

D = []
for i in range(N):
    a, b = map(int, input().split())
    D.append((a, b))

cnt = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
    else:
        cnt = 0

print("No")


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int arr[4] = {};
    double max = -1;
    for (int i = 0; 100 * a * i <= f; i++)
    {
        for (int j = 0; 100 * b * j <= f; j++)
        {
            for (int m = 0; ((100 * a * i) + (100 * b * j)) / 100 * e >= m * c; m++)
            {
                for (int n = 0; ((100 * a * i) + (100 * b * j)) / 100 * e >= n * d; n++)
                {
                    if (((100 * a * i) + (100 * b * j)) / 100 * e < m * c + n * d)
                        continue;
                    int tmp = 100 * a * i + 100 * b * j + m * c + n * d;
                    if (tmp <= f && tmp != 0)
                    {
                        double r = (m * c + n * d) * 100.0 / (double)(tmp);
                        // cout << "+" << r << endl;
                        // cout << tmp << " " << c << " " << d << " " << r << " " << m << " " << n << " " << (m * c + n * d) << endl;
                        if (r > max && r <= 100)
                        {
                            // cout << r << "," << i << "," << j << "," << m << "," << n << endl;
                            arr[0] = i;
                            arr[1] = j;
                            arr[2] = m;
                            arr[3] = n;
                            max = r;
                        }
                    }
                }
            }
        }
    }
    cout << 100 * a * arr[0] + 100 * b * arr[1] + c * arr[2] + d * arr[3] << " " << c * arr[2] + d * arr[3] << endl;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

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

    int N, Y; cin >> N >> Y;

    int a = -1, b = -1, c = -1;
    bool found = false;
    FOR(i,0,N+1){
        FOR(j,0,N+1-i){
            int k = N - i - j;
            if (10000*i+5000*j+1000*k == Y) {
                a = i; b = j; c = k;
                found = true;
                break;
            }
        }
        if (found) break;
    }

    cout << a << " " << b << " " <<  c << endl;  

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2001;
int n,f[N][N],b[N],x,y,a[N];
int main()
{
	cin>>n>>x>>y;
	f[x][y]=1;
	for(int i=2;i<=n;i++)f[i-1][i]=1,b[i]=b[i-1]+1;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			a[min(b[j]-b[i],abs(x-i)+1+abs(y-j))]++;
	for(int i=1;i<=n-1;i++)cout<<a[i]<<endl;
}


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

int main(){
  string n, t;
  cin >> n >> t;
  rep(i,n.size()){
    if(n[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define DEBUG

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

const int oo = 1e9 + 7;
const ll mod = 998244353, maxn = 200200;
const double PI = acos(-1);


int main (){
    string a, b;
    cin >> a >> b;
    b.pop_back();

    cout << (a == b? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3600