akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>		//atoi(char *)

int top, S[1000];
void push(int x);

void push(int x)
{
	S[++top] = x;
}

int pop()
{
	top--;
	return S[top + 1];
}

int main()
{
	using namespace std;
	int a, b;
	top = 0;
	char calc[100];
	while (cin >> calc)
	{
		if (calc[0] == '+')
		{
			b = pop();
			a = pop();
			push(a + b);
		}
		else if (calc[0] == '-')
		{
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (calc[0] == '*')
		{
			b = pop();
			a = pop();
			push(a * b);
		}
		else if (calc[0] == '/')
		{
			b = pop();
			a = pop();
			push(a / b);
		}
		else
			push(atoi(calc));
	}
	cout << pop() << endl;
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(all(a));

    map<int, int> mp;
    REP(i, 2)
    {
        REP(j, sqrt(a[i]))
        {
            if(a[i] % (j+1) == 0)
            {
                mp[j+1]++;
                mp[a[i]/(j+1)]++;
            }
        }
    }

    for(auto &x : mp)
    {
        FOR(i, 2, n)
        {
            if(a[i] % x.first == 0) x.second++;
        }
    }
    int ans = 1;
    for(auto x : mp)
    {
        if(n-1 <= x.second) ans = max(ans, x.first);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string n; cin >> n;
    (n[0] == n[2]) ? Yes() : No();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<assert.h>

#define MAX 1000003
#define len 12

char T[MAX][len];

int getChar(char c){
  if (c == 'A') return 1;
  else if (c == 'C') return 2;
  else if (c == 'G') return 3;
  else if (c == 'T') return 4;
}

int getKey(char str[]){
  int sum = 0, p = 1, i;
  for (i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
int hash1(int key){
  return key%MAX;
}
int hash2(int key){
  return 1+key%(MAX-1);
}
int search(char str[]){
  int key = getKey(str);
  int i, j;

  for(i=0;i<MAX;i++){
    //    j=(hash1(key)+i*hash2(key))%MAX;
    j=((hash1(key)+i*hash2(key))&0x7fffffff)%MAX;
    if(strcmp(str, T[j])==0)return 1;
    if(T[j][0]=='\0') break;

  }
  return 0;
}

int insert(char str[]){
  int key = getKey(str);
  int i, j;
  for(i=0;T[j]=='\0'||i<MAX;i++){
    j=((hash1(key)+i*hash2(key))&0x7fffffff)%MAX;
    //   j=(hash1(key)+i*hash2(key))%MAX;
    if(T[j][0]=='\0'){
      strcpy(T[j], str);
      return 1;
    }
  }
  return 0;
}

int main(){
  int i,n;
  char com[8],str[len];
  for (i=0;i<MAX;i++) T[i][0] = '\0';
  scanf("%d",&n);

  for (i=0;i<n;i++){
    scanf("%s %s",com,str);
    if (com[0]=='i'){
      insert(str);
    } else {
      if (search(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 12324
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

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

  if (N<=999) {
    cout << "ABC" << endl;
  } else {
    cout << "ABD" << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	long long q,h,s,d,n;
	long long cost,min2,min1,min05,min025;
	cin>>q>>h>>s>>d>>n;
	min025=q;
	min05=min(h,2*min025);
	min1=min(s,min05*2);
	min2=min(d,min1*2);

	cost=0;
	while(n>0)
	{
	    if(n>=2)
	    {
	       cost+=(n/2*min2);
	       n=n%2;
	    }
	    else if (n==1)
	    {
	        cost+=min1;
	        n--;
	    }
	}
	cout<<cost<<"\n";
	    
	return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, k = i_map()
    num_list = i_list()

    num_list.sort(reverse=True)

    ans = 0
    
    for i in range(k):
        ans += num_list[i]

    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 77004
#include <bits/stdc++.h>
#define INF 1e18
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    ll N;
    cin >> N;
    string S[N];
    map<string, ll> memory;
    REP(i, N) {
        string x;
        cin >> x;
        sort(all(x));
        if (!memory.count(x)) memory[x] = 0;
        else memory[x] += 1;
    }
    
    ll ans = 0;
    for (auto item : memory) {
        //print(key << " : " << value);
        ans += (item.second + 1) * item.second / 2;
    }
    print(ans);
    
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 11904
#include<cstdio>

using namespace std;

int main(){
    int n, m, X, Y;
    scanf("%d %d %d %d", &n, &m, &X, &Y);
    int x[n];
    int y[m];
    int maxx, miny;
    maxx = -101;
    miny = 101;
    for(int i = 0; i < n; i++){
        scanf("%d", &x[i]);
        if (x[i] > maxx) {
            maxx = x[i];
        }
        
    }
    for(int i = 0; i < m; i++){
        scanf("%d", &y[i]);
        if (miny > y[i]) {
            miny = y[i];
        }
        
    }
    if (maxx < miny && X < miny && Y > maxx) {
        puts("No War");
    }else{
        puts("War");
    }
    
}

Measured memory_bytes: 128
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const S = input.shift().split('')
  const K = Number(input[0])
  let ans = ''
  for (let i = 0; i < S.length && i < K; i++) {
    ans = S[i]
    if (Number(ans) > 1) break
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main(){
    int N,now,past;
    cin >> N;
    int A[100000];

    rep(i,N) cin >> A[i];

    now = A[0] - 1;

    for (int i = 0;i<N;i++){
        if (now == 1){
            cout << i + 1 << endl;
            return 0;
        }
        past = now;
        now = A[now] - 1;
      }cout << -1 << endl;
       return 0;
}


Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int mae = 0;
	int maek = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '(') {
			maek++;
		}
		if (s[i]==')') {
			if (maek > 0) {
				maek--;
			}
			else {
				mae++;
			}
		}
	}
	for (int i = 0; i < mae; i++) {
		cout << "(";
	}
	cout << s;
	for (int i = 0; i < maek; i++) {
		cout << ")";
	}
	cout << endl;
}

Measured memory_bytes: 256
// Problem : D - Leaping Tak
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
    T f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1, mod = 998244353;

int n, k;
int l[N], r[N];
int tr[N << 2];
int dp[N];

inline int ls(int p) {return p << 1;}
inline int rs(int p) {return p << 1 | 1;}

inline void pushup(int p) {tr[p] = (tr[ls(p)] + tr[rs(p)]) % mod;}

void modify(int x, int val, int l, int r, int p)
{
	if (l == r) {tr[p] += val; return;}
	int mid = (l + r) >> 1;
	if (x <= mid) modify(x, val, l, mid, ls(p));
	else modify(x, val, mid + 1, r, rs(p));
	pushup(p);
}

int getans(int ql, int qr, int l, int r, int p)
{
	if (ql <= l && r <= qr) return tr[p];
	int mid = (l + r) >> 1, ans = 0;
	if (ql <= mid) ans = getans(ql, qr, l, mid, ls(p));
	if (qr > mid) ans = (ans + getans(ql, qr, mid + 1, r, rs(p))) % mod;
	return ans;
}

signed main()
{
    //File("");
    n = gi <int> (), k = gi <int> ();
    for (int i = 1; i <= k; i+=1) l[i] = gi <int> (), r[i] = gi <int> ();
    dp[1] = 1;
    modify(1, 1, 1, n, 1);
    for (int i = 2; i <= n; i+=1)
    {
    	for (int j = 1; j <= k; j+=1)
    	{
    		if (i > l[j])
    		{
    			//cout << i << ' ' << max(1ll, i - r[j]) << ' ' << max(1ll, i - l[j]) << endl;
    			dp[i] = (dp[i] + getans(max(1ll, i - r[j]), max(1ll, i - l[j]), 1, n, 1)) % mod;
    		}
    	}
    	//cout << i << ' ' << dp[i] << endl;
    	modify(i, dp[i], 1, n, 1);
    }
    printf("%lld\n", dp[n]);
    return 0;
}

Measured memory_bytes: 9412
import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		
		String s = sc.next();
		
		if(s.length() <= k) {
			System.out.println(s);
		} else {
			System.out.print(s.substring(0, k));
			System.out.println("...");
		}
        return;
	}
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;
int main(){
  int64_t n;
  cin >> n;
  vector<vector<pair<string,char>>> mtx(10);
  mtx[0].push_back(make_pair("a",'a'));
  rep(i,9){
    rep(j,mtx[i].size()){
      auto hoge = mtx[i][j];
      for(char k = 'a';k <= hoge.second+1;k++){
        string sp = hoge.first + k;
        mtx[i+1].push_back(make_pair(sp,max(hoge.second,k)));
      }
    }
  }
  rep(i,mtx[n-1].size()){
    cout << mtx[n-1][i].first << endl;
  }
    
  
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n+10];
	int b[n+10];
	int c[n+10];int ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i],ans+=b[i];
	for(int i=1;i<n;i++)
		cin>>c[i];
	
	for(int i=2;i<=n;i++){
		if(a[i]-a[i-1]==1){
			ans+=c[a[i-1]];
		}
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// atcoder/abc063/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b;
  while (cin >> a >> b) {
    if (10 <= a + b)cout << "error" << endl;
    else cout << a+b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class AOJ
{
    public static void Main()
    {
        while (true)
        {
            string s = Console.ReadLine();
            if (s == null) break;

            int d = int.Parse(s);
            int sum = 0;

            for (int i = 1; i < (600 / d); i++)
            {
                sum += d * (int)Math.Pow(d * i, 2);
            }

            Console.WriteLine(sum);
        }        
    }
}

Measured memory_bytes: 5628
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  A--;
  B--;
  C--;
  D--;
  string S;
  cin>>S;
  bool f=true;
  FOR(i,A,C)if(S[i]=='#' and S[i+1]=='#')f=false;
  FOR(i,B,D)if(S[i]=='#' and S[i+1]=='#')f=false;
  if(D>C){
    cout<<(f?"Yes":"No")<<endl;
    return 0;
  }
  f=false;
  FOR(i,B,D+1){
    if(S[i-1]=='.' and S[i]=='.' and S[i+1]=='.')f=true;
  }
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  long long a[n],sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }

  long long m=abs(sum-2*a[0]);
  long long x=0,y=sum;
  for(int i=0;i<n-1;i++){
    x+=a[i];
    y-=a[i];
    m=min(m,abs(x-y));
  }
  cout<<m<<endl;
  return 0;
}


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

using namespace std;
#define INFS (1LL<<28)
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define all(n) n.begin(),n.end()

signed main(){
	int n;
	cin>>n;
	int a[100010],b[100010];
	lp(i,n+1)cin>>a[i];
	lp(i,n)cin>>b[i];
	int ans=0,befs=0;
	for(int i=n-1;i>=0;i--){
		int y=b[i];
		if(a[i+1]>0){
			if(y>=a[i+1]){
				y-=a[i+1];
				ans+=a[i+1];
				a[i+1]=0;
			}
			else{
				ans+=y;
				a[i+1]-=y;
				y=0;
			}
		}
		if(a[i]>0){
			if(y>=a[i]){
				y-=a[i];
				ans+=a[i];
				a[i]=0;
			}
			else{
				ans+=y;
				a[i]-=y;
				y=0;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
function Main(s){
  s = s.split("\n");
  var k = s[1];
  s = s[0];
  var ans = 1;
  k = Math.min(s.length, +k)
  for(var i = 0; i < k; i++){
    if(s[i] !== "1"){ans = s[i]; break;}
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21064
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    
    string str;
    
    cin>>str;
    
    int cnt=0;
    
    for(int i=0;i<=n-3;i++)
    {
        int flag=0;
        
        if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')
        {
            flag=1;
            cnt++;
            
            i=i+2;
        }
    }
    
    
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
r, g, b = map(int, input().split())

# rgbを、100の位・10の位、1の位の順に表示
# 4の倍数の場合は「YES」、そうじゃない時は「NO」
if (100 * r + 10 * g + b) % 4 == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9160
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>

int table[10][10] = {0};

int e(const std::string& s) {
	int a = s[0] - '0',
		b = s[1] - '0',
		c = s[2] - '0',
		d = s[3] - '0';
	return table[table[table[table[0][a]][b]][c]][d];
}

bool check(const std::string& s) {
	int ee = s[4] - '0';
	return table[e(s)][ee] == 0;
}

int main() {
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			std::cin >> table[i][j];
		}
	}

	int num = 0;
	for (int i = 0; i < 10000; i++) {
		char* cp = new char[5];
		std::sprintf(cp, "%04d", i);
		std::string s = cp;
		s += std::to_string(e(s));
		int zeroCount = 1;
		// 1桁打ち間違い
		for (int j = 0; j < 5; j++) {
			for (int k = 0; k < 10; k++) {
				if (s[j] == '0' + k) continue;

				char c = s[j];
				s[j] = '0' + k;
				if (check(s)) zeroCount++;
				s[j] = c;
			}
		}
		// 入れ替え
		for (int j = 0; j < 4; j++) {
			if (s[j] == s[j + 1]) continue;

			std::string s2 = s;
			std::swap(s2[j], s2[j + 1]);
			if (check(s2)) zeroCount++;
		}
		if (zeroCount != 1) {
			num++;
		}
	}
	std::cout << num << std::endl;
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int search(int A[], int n, int key){
	int i = 0;
	A[n] = key;
	while(A[i] != key) i++;
	return i != n;
}

int main(void){
	int i,n,A[10000+1],q,key,sum = 0;
	
	scanf("%d",&n);
	for(i = 0; i < n; i++) scanf("%d",&A[i]);
	
	scanf("%d",&q);
	for(i = 0; i < q; i++) {
		scanf("%d",&key);
		if(search(A,n,key)) sum++;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 636
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> as(n);
    map<int, int> mp;
    i64 ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
        ans += mp[as[i]]++;
    }
    for (int i = 0; i < n; i++)
    {
        cout << ans - mp[as[i]] + 1 << endl;
    }
}

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


Measured memory_bytes: 8320
import sys
input = sys.stdin.readline


def main():
    n, m = input_list()
    heights = input_list()

    paths = {}
    pp = set()
    for _ in range(m):
        a, b = input_list()
        pp.add(a)
        pp.add(b)
        if a in paths:
            paths[a].add(b)
        else:
            paths[a] = {b}
        if b in paths:
            paths[b].add(a)
        else:
            paths[b] = {a}
    ans = 0
    for i, other in paths.items():
        x = heights[i-1]
        is_good = True
        for o in other:
            if x <= heights[o-1]:
                is_good = False
                break
        if is_good:
            ans += 1

    only_ones = n - len(pp)
    print(ans + only_ones)

def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 118264
#include <bits/stdc++.h>
#define REP(i, a) for(int i=0; i<int(a); i++)
#define ALL(x) begin(x), end(x)
#define VI vector<int>
using namespace std;
typedef long long LL;

const int MAX_N=100005;
VI A;

int main() {
    LL n, m;
    cin >> n >> m;
    LL x = min(n, m/2);
    m -= x*2;
    cout << (x + m/4) << endl;
    return 0; 
}

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

using namespace std;
typedef long long ll;
const int N = 1e5 +7;
map<pair<int,int> , int>ans;
bool vis[N];
vector<int>adj[N];
int out=0;
void dfs( int node , int prvcol)
{
    vis[node]=1;
    int child;
    int cnt=1;
    cnt=adj[node].size();
    out=max(out,cnt);
    cnt=1;
    for(int i = 0 ; i <adj[node].size() ;i++)
    {
        child=adj[node][i];
        if(!vis[child])
        {
            if(cnt==prvcol)cnt++;
            ans[{min(child,node),max(child,node)}]=cnt;
            dfs(child,cnt);
            cnt++;

        }
        //cout << node << " " << child << " " << cnt << "\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n  , m , x,y ;
    cin >> n;
    vector<pair<int,int> >v;
    for(int i = 0 ; i < n-1 ;i++)
    {
        cin >> x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
        v.push_back({x,y});
    }
    dfs(1 , 0);
    cout << out << "\n";
    for(int i = 0 ; i < n-1 ; i++)
    {
        x=min(v[i].first , v[i].second);
        y=max(v[i].first , v[i].second);
        cout << ans[{x,y}] << "\n";
    }
    return 0;
}


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


int main()
{

   ll t=1;
   //cin>>t;


   while(t--)
   {
   	   ll N;
   	   cin>>N;
   	   ll A[N+1]={0};

   	   for(ll i=1; i<=N; i++)
   	   {
   	   	    cin>>A[i];
   	   }

   	   ll ans=0;

   	   map<ll,ll> ca;

   	   for(ll i=N; i>=1; i--)
   	   {
   	   	    ll d=(A[i]+i);

   	   	    ll e=(i-A[i]);

   	   	    ans+=ca[d];

   	   	    ca[e]++;
   	   }

   	   cout<<ans<<endl;

   }


	return 0;
}

Measured memory_bytes: 27916
#include <stdio.h>

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a < b && b < c && a < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
		
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
11 4
)");
#define cin input
#endif

int main()
{
	int a, b;
	cin >> a >> b;

	if (a>8 || b>8)
		cout << ":(" << endl;
	
	else
	{
		cout << "Yay!" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mod 1000000007
#define mk make_pair
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,wt;
    cin>>n>>wt;
    ll w[n+1]={0};
    ll v[n+1]={0};
    for(int i=1;i<=n;i++)
    cin>>w[i]>>v[i];
    ll dp[n+1][wt+1];
    for(int i=0;i<=n;i++)
    dp[i][0]=0;
    for(int i=0;i<=wt;i++)
    dp[0][i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=wt;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(w[i]<=j)
            dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
        }
    }
   /* for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=wt;j++)
        {cout<<dp[i][j]<<" ";}
        cout<<endl;}*/
    cout<<dp[n][wt];
    
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;

    int ara[n + 1];
    map<int, int> mp;
    for (int i = 0; i < 4; i++)
    {
        mp[i] = -1;
    }
    if (n == 1)
    {
        bool ans = true;

        for (int i = 0; i < m; i++)
        {
            int index, value;
            cin >> index >> value;
            if (mp[index] == -1)
            {
                mp[index] = value;
            }
            else if (mp[index] != value)
            {
                ans = false;
            }
        }
        if (!ans)
            cout << -1 << endl;
        else
        {
            if (mp[1] == -1)
            {
                mp[1] = 0;
            }
            cout << mp[1] << endl;
        }
    }
    else
    {
        bool ans = true;

        for (int i = 0; i < m; i++)
        {
            int index, value;
            cin >> index >> value;
            if (index == 1 && value == 0)
            {
                ans = false;
                mp[index] = 0;
            }
            else if (mp[index] == -1)
            {
                mp[index] = value;
            }
            else if (mp[index] != value)
            {
                ans = false;
            }
        }
        if (!ans)
            cout << -1 << endl;
        else
        {
            for (int i = 1; i <= n; i++)
            {
                if (mp[i] == -1)
                {
                    if (i == 1)
                        cout << 1;
                    else
                        cout << 0;
                }
                else
                {
                    cout << mp[i];
                }
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 256
/*#include<iostream>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int s=0;
	for(int a=1;a<n;a++)
		for(int b=a+1;b<=n;b++)
			if(a%b>=k)
				s++;
	cout<<s;
	return 0;
}*/
#include<iostream>
using namespace std;
int main(){
	long long aa,bb,a,b;
	cin>>a>>b;
	if(a==1)
		aa=1;
	else
		aa=a-2;
	if(b==1)
		bb=1;
	else
		bb=b-2;
	cout<<aa*bb;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

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


    ll ans = 0;
    rep1(i, k){
        rep1(j, k){
            int tmp = __gcd(i, j);
            rep1(kk, k){
                ans += __gcd(tmp, kk);
            }
        }
    }    

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
template<typename T>
class BIT
{
//bit[x]
//manage range of bit[x] is (x & -x)
//
public:
	static const int n = 10000;
	T bit[n] = {};
	void add(int a, T w)
	{
		for (int x = a; x <= n; x += x & -x)
		{
			bit[x] += w;
		}
	}
	T sum(int a)
	{
		T ret = 0;
		for (int x = a; x > 0; x -= x & -x)
		{
			ret += bit[x];
		}
		return ret;
	}
};
 
long long int wa(long long int a)
{
	return (a*(a+1))/2;
}
 
int main()
{
	long long int n, k;
	cin >> n >> k;
	int A[2001], B[2001];
	for (int i = 0; i < n; ++i)
	{
		cin >> B[i];
		A[i] = 2000 - B[i] + 1;
	}
	long long int tentou[2001];
	long long int migi[2001];
	long long int ti = wa(k) % 1000000007;
	long long int to = wa(k - 1) % 1000000007;
	BIT<long long int> BT;
	BIT<long long int> saisho;
	for (int i = 0; i < n; ++i)
	{
		tentou[i] = BT.sum(A[i] - 1);
		BT.add(A[i], 1);
	}
	for (int i = n - 1; i >= 0; --i)
	{
		migi[i] = saisho.sum(A[i] - 1);
		saisho.add(A[i], 1);
	}
	long long int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += ((ti * tentou[i])%1000000007 + (to * migi[i])% 1000000007)% 1000000007 ;
	}
	cout << ans % 1000000007 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>

using namespace std;

int main(void){
  vector<long long> A(3);
  long long K;
  for(int i = 0; i < 3; i++) cin >> A[i];
  cin >> K;
  cout << (*max_element(A.begin(), A.end()) << K) + accumulate(A.begin(), A.end(), 0LL) - *max_element(A.begin(), A.end()) << endl;
  return 0;
}


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

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim = 1>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}

int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


///////////////////////////////////////////////////

int main()
{
    int H1, H2, M1, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int MM1 = H1 * 60 + M1;
    int MM2 = H2 * 60 + M2;

    int ans = MM2 - MM1 - K;
    cout << ans << endl;
}

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

int main() {
    string s;
    while(cin >> s, s != "#") {
        vector<string> v(1);
        for(int i=0; i<s.size(); ++i) {
            if(s[i] == '/') {
                v.push_back("");
            } else if('1' <= s[i] && s[i] <= '9') {
                for(int j=0; j<(s[i] - '0'); ++j) {
                    v[v.size()-1] += '.';
                }
            } else {
                v[v.size()-1] += 'b';
            }
        }
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        v[a-1][b-1] = '.';
        v[c-1][d-1] = 'b';

        string res;
        for(int i=0; i<v.size(); ++i) {
            int cnt = 0;
            for(int j=0; j<v[i].size(); ++j) {
                if(v[i][j] == 'b') {
                    if(cnt > 0) {
                        res += '0' + cnt;
                    }
                    res += 'b';
                    cnt = 0;
                } else {
                    cnt++;
                }
            }
            if(cnt > 0) {
                res += '0' + cnt;
            }
            if(i != v.size()-1) {
                res += '/';
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3144
A,B,C,X,Y = map(int,input().split())
mon = 0
if A + B > C*2:
    mon += C*2*min(X,Y)
else:
    mon += (A+B)*min(X,Y)
if X >= Y:
    Z = X - Y
    if A > C*2:
        mon += C*2*Z
    else:
        mon += A*Z
else:
    Z = Y - X
    if B > C*2:
        mon += C*2*Z
    else:
        mon += B*Z
print(mon)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define print(n) cout<<n<<endl
int main(){
	int n,f[100][100],p[100][11];
	cin>>n;
	rep(i,0,n)rep(j,0,10)cin>>f[i][j];
	rep(i,0,n)rep(j,0,11)cin>>p[i][j];
	int ans=-1<<30;
	rep(i,1,1<<10){
		int tmp=0;
		rep(j,0,n){
			int cnt=0;
			rep(k,0,10){
				if(i>>k&1&&f[j][k])cnt++;
			}
			tmp+=p[j][cnt];
		}
		ans=max(ans,tmp);
	}
	print(ans);
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	long long x,y;
	scanf("%lld%lld",&x,&y);
	if(abs(x-y)<=1) puts("Brown");
	else puts("Alice");
}


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

using namespace std;

int ans[26];

int main(){
    string s; cin >> s;
    sort(s.begin(), s.end());

    string a = "abcdefghijklmnopqrstuvwxyz";

    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < 26; j++){
            if(s[i] == a[j]){
                ans[j] = 1;    
            }
        }
    }

    for(int i = 0; i < 26; i++){
        if(ans[i] == 0){
            cout << a[i] << endl;
            return 0;
        }
    }

    cout << "None" << endl;
}

Measured memory_bytes: 512
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int64 w[102], v[102], n;
int64 dp[102][100002];
int64 solve(int i, int va){
    if(va == 0)    return 0;
    if(i < 1)   return inf;
    if(dp[i][va] != -1) return dp[i][va];
    int64 ans = inf;
    if(va >= v[i]){
        ans = w[i] + solve(i - 1, va - v[i]);
    }
    ans = min(ans, solve(i - 1, va));
    dp[i][va] = ans;
    return ans;
}
int main(){
    FAST
    //Do awesome things here
    int64 wt, sum = 0, ans = 0;
    cin >> n >> wt;
    memst(dp, -1);
    fre(i, 1, n){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    fre(i, 0, sum){
        int64 awt = solve(n, i);
        if(awt <= wt)   ans = i;
    }
    cout << ans << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 80000
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
int main() {
	string c1, c2;
	bool ans = false;
	cin >> c1 >> c2;
	for (int i = 0; i < 3; i++) {
		if (c1[i] != c2[2 - i])break;
		if (i == 2)ans = true;
	}
	cout << (ans ? "YES" : "NO") << endl;

	return 0;
}

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

using namespace std;

vector< string > split(string s, string cc)
{
  s += cc;
  int tail = 0;
  string buff;
  vector< string > ret;
  while(tail < s.size()) {
    if(cc.find(s[tail]) != string::npos) {
      if(buff.size()) ret.push_back(buff);
      buff.clear();
    } else {
      buff += s[tail];
    }
    ++tail;
  }
  return (ret);
}

int main()
{
  string K, S;
  vector< string > data;
  cin >> K;
  cin.ignore();
  while(getline(cin, S)) data.push_back(S);

  auto latte = split(K, ".");

  bool flag = false;
  vector< pair< string, int > > vs;

  auto ismatch = [&]
  {
    if(vs.size() != latte.size()) return (false);
    for(int i = 0; i < vs.size(); i++) if(vs[i].first != latte[i]) return (false);
    return (true);
  };

  for(auto &s : data) {
    auto malta = split(s, " :");
    int indent = 0;
    while(s[indent] == ' ') ++indent;
    while(vs.size() && indent <= vs.back().second) vs.pop_back();
    vs.emplace_back(malta[0], indent);
    if(ismatch()) {
      auto p = s.substr(s.find(':') + 1);
      if(p.empty()) cout << "object" << endl;
      else cout << "string \"" << p.substr(1) << "\"" << endl;
      flag = true;
      break;
    }
  }

  if(!flag) cout << "no such property" << endl;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str a; cin >> a;
  ll ans = 0;
  rep(i, a.size())
  {
    if(a[i] =='1') ans++;
  }
  fin(ans)
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

vector<vector<ll>> graph(MAXSIZE);
vector<bool> visited(MAXSIZE, false);
ll ans = 1;

void dfs(ll now, ll k, ll depth){
    visited[now] = true;
    ll cnt = 0;
    for(int i = 0; i < graph[now].size(); i++){
        if(visited[graph[now][i]] == false){
            cnt++;
            dfs(graph[now][i], k, depth+1);
        }
    }

    ll init = k - 2;
    if(depth == 0){init++;}
    for(int i = 0; i < cnt; i++){
        ans *= init - i;
        ans %= MOD;
    }
    return;
}

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

    for(int i = 0; i < n-1; i++){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    dfs(0, k, 0);
    ans *= k;
    ans %= MOD;
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int K = 1000;
int v[2*K][2*K];
int s[2*K+1][2*K+1];
const int dx[] = {0,1,2,1,0,-1,-2,-1};
const int dy[] = {2,1,0,-1,-2,-1,0,1};
int main() {
  int n,k;
  cin >> n >> k;
  rep(i,n){
    int x,y; char c;
    cin >> x >> y >> c;
    if(c=='B') x+=k;
    x %= 2*k; y %= 2*k;
    v[x][y]++;
  }
  rep(i,2*k)rep(j,2*k) s[i+1][j+1] = s[i][j+1]+s[i+1][j]-s[i][j]+v[i][j];
  auto f = [&](int x1,int y1,int x2,int y2){
    if(x1>=2*k||y1>=2*k||x2<0||y2<0) return 0;
    x1=max(x1,0); y1=max(y1,0); x2=min(x2,2*k); y2=min(y2,2*k);
    return s[x2][y2] - s[x2][y1] - s[x1][y2] + s[x1][y1];
  };
  int ans = 0;
  rep(i,2*k)rep(j,k){
    int temp = f(i,j,i+k,j+k);
    rep(d,8) {
      int x = i+k*dx[d], y = j+k*dy[d];
      temp += f(x,y,x+k,y+k);
    }
    ans = max(ans,temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 31488
import sys
import socket
import math
math.pi


hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    R = read_int()
    res = 2 * math.pi * R
    print(res)


main()


Measured memory_bytes: 9864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  ll N;
  cin >> N;
  ll ans = 0;
  for (ll i = 1; i * i < N; i ++) {
    if (N % i == 0) {
      ll kj = N / i;
      kj --;
      if (N / kj == N % kj) ans += kj;
      kj = i - 1;
      if (kj != 0 && N / kj == N % kj) ans += kj;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    vector <lli> arr;
    lli x;
    rep(i,n-1){
    	cin>>x;
    	arr.pb(x);
	}
	lli count[n+1];
	rep(i,n+1)
	count[i]=0;
	rep(i,arr.size())
	count[arr[i]]++;
	for(lli i=1;i<=n;i++)
	cout<<count[i]<<"\n";
    return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    int N;
    cin >> N;

    unordered_map<int, int> counter;

    int a;
    rep(i, N) {
        cin >> a;
        counter[a]++;
    }
    
    int ans = 0;

    auto it = counter.begin();
    while (it != counter.end()) {
        if (it->first < it->second) ans += it->second - it->first;
        else if (it->first > it->second) ans += it->second;
        it++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4260
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}
macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}

fn main() {
    let S = get!(String).chars().collect::<Vec<_>>();
    let T = get!(String).chars().collect::<Vec<_>>();
    let mut cnt = 0;
    for i in 0..3 {
        if S[i] == T[i] {
            cnt += 1;
        }
    }
    println!("{}", cnt);

}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	double v, y;
	int i;
	
	
	while (scanf("%lf", &v) != EOF){
		i = 1;
		v /= 9.8;
		y = v * v * 4.9;
		
		while (1){
			if (y <= 5 * i - 5){
				printf("%d\n", i);
				break;
			}
			i++;
		}
	}
	
	return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	
	map<pair<int,int>,int> mp;
	vector<pair<int,int>> edge(n-1);
	vector<vector<int>> ad(n);
	for(int i=1;i<n;i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		ad[a].push_back(b);
		ad[b].push_back(a);
		edge[i-1]=make_pair(a,b);
	}
	int mx=0;
	function<void(int,int,int)> dfs=[&](int cur,int par,int col){
		int noc=1;
		for(int ch:ad[cur]){
			if(ch==par) continue;
			if(col==noc) noc++;
			dfs(ch,cur,noc);
			mp[make_pair(ch,cur)]=noc;
			mp[make_pair(cur,ch)]=noc;
			noc++;
		}
		noc--;
		mx=max(mx,noc);
	};
	dfs(0,-1,0);
	cout << mx << "\n";
	
	for(int i=0;i<n-1;i++){
		cout << mp[make_pair(edge[i].first,edge[i].second)] << "\n";
	}
	return 0;
}

Measured memory_bytes: 20480
n = int(input())
a = list(map(int,input().split()))
am = [a[i]*(-2) for i in range(0,n,2)]

sa = sum(a)
sam = sum(am)

ans = [0 for i in range(n)]
ans[n-1] = sum(a) + sum(am) - am[(n-1)//2]

for i in range(n-2,-1,-1) :
  ans[i] = (a[i]-ans[i+1]//2)*2
  
print(*ans)

Measured memory_bytes: 16020