akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

bool odd(string s){
    int n = s.size();
    if (n % 2 == 1) return false;
    n /= 2;
    REP(i, n){
        if (s[i] != s[n + i]) return false;
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string s1;
    REP(i, n) {
        s1 = s.substr(0, n - 1 - i);
        if (odd(s1)){
            cout << (n - i - 1) << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

const ll INF = 1e9;

int main() {
    int n, k;
    cin >> n >> k;
    ll h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    ll dp[n];
    for (int i = 0; i < n; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k && i + j < n; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    OUT(dp[n - 1]);
}


Measured memory_bytes: 1792
import java.util.*;

public class Main{
  
  static int price(int cost){
    	float a = cost/(float)1.08;
    	int b = (int) a;
    	if((b*1.08)==(float) cost){
          return b;
        }
    	else if((int)((b+1)*1.08) ==  cost){
          return b+1;
        }
    	else return -1;
  }
  public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n = scan.nextInt();
    	int a = price(n);	
    if(a!=-1){
          	System.out.println(a);
        }else System.out.println(":(");
  }
}

Measured memory_bytes: 21844
n,m,x = map(int, input().split())

book = []

for _ in range(n):
  book.append(list(map(int, input().split())))

min_cost = 9999999
  
for i in range(1,2**n):
  b = format(i, 'b')
  b = b.zfill(n)
  cost = 0
  us = [0 for _ in range(m)]
  for j in range(len(b)):
    if int(b[j]) == 1:
      cost += book[j][0]
      for k in range(m):
        us[k] += book[j][k+1]
  
  if sum(a>=x for a in us) == m:
    if cost < min_cost:
      min_cost = cost

if min_cost == 9999999:
  print(-1)
else:
  print(min_cost)

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

#define FOR(a, b, c) for (int a = (b), _for = (c); a < _for; ++a)
#define REP(a, n) FOR(a, 0, n)
#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define lf double

using namespace std;

const int MAX = (int)1e5+5;

int n;
int p[MAX];

void END(int out){
	if (out) puts ("Yes");
	else puts ("No");
	exit(0);
}

int main(){
	scanf ("%d",&n);
	REP(i,n) scanf ("%d",p+i);
	int c=0;
	REP(i,n) if (p[i]!=0) c=1;
	if (!c) END(1);
	
	if (n%3) END(0);
	
	map<int,int>m;
	REP(i,n) m[p[i]]++;
	
	if (m.size()>3) END(0);
	vector<int>v;
	for (auto x:m){
		REP(i,x.y*3/n) v.pb(x.x);
	}
	if (v.size()!=3) END(0);
	int a=v[0],b=v[1];
	c=v[2];
	if ((a^b)!=c) END(0);
	if ((c^b)!=a) END(0);
	if ((a^c)!=b) END(0);
	END(1);
	return 0;
}


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

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    ll res = 0;
    map<ll, ll> memo;
    for(ll i=0; i<n; ++i){
        cin >> a[i]; 
        memo[a[i]]++; res += a[i];
    }
    
    ll q; cin >> q;
    vector<ll> b(q), c(q);
    for(ll i=0; i<q; ++i){
        cin >> b[i] >> c[i];
        res -= b[i] * memo[b[i]];
        res -= c[i] * memo[c[i]];
        
        memo[c[i]] += memo[b[i]];
        memo[b[i]] = 0;
        res += c[i] * memo[c[i]];
        
        cout << res << endl;
    }
    return 0;
}

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

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if(x < a || (a + b) < x) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 256
let main = (standardInput) => {
    let lenghtList = standardInput.split(' ');
    let varticalLength = parseInt(lenghtList[0]);
    let horizonLength = parseInt(lenghtList[1]);

    console.log(varticalLength * horizonLength + ' ' + 2 * (varticalLength + horizonLength));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 17176
require 'prime'

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end

N,M=gets.chomp.split(" ").map(&:to_i)
divisors = divisors(M).reverse
puts divisors.bsearch {|x| x<=M/N }


Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int x,k;

int main()
{
	cin >> k >> x;
	if(500*k >= x) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
template <class _T> static _T tp_gcd(_T first, _T second)
{
	_T num1 = first, num2 = second;
	_T remainder = 0, common = 0;

	if (!num1) return num2;
	if (!num2) return num1;

	while (!common) {
		remainder = num1 % num2;

		if (remainder == 0) {
			common = num2;
		}
		else {
			num1 = num2;
			num2 = remainder;
		}
	}
	return(common);
}


static void ABC104C_AllGreen();

#if 1
int main()
{
	ABC104C_AllGreen();

	fflush(stdout);
	return 0;
}
#endif

class ProbInfo {
public:
	int point = 0;
	int count = 0;
	int bonus = 0;
	int getTotal() {
		return(point * count + bonus);
	}
	static const int INF = 100000000;
};

static int getLeastNum(ProbInfo* prob, bool* solved, int probSize, int nowProb, int nowPoint, int targPt)
{

	int solveCount = 0;
	int ptSum = nowPoint;
	for (int i = 0; i <= tp_min(nowProb, probSize-1); i++) {
		if (solved[i]) {
			solveCount += prob[i].count;
		}
	}
	if (ptSum < targPt) {
		for (int i = probSize - 1; i >= 0; i--) {
			if (!solved[i]) {
				int j = 0;
				for (; j < prob[i].count; j++) {
					ptSum += prob[i].point;
					if (ptSum >= targPt) {
						break;
					}
				}
				if ((ptSum >= targPt) && (j < prob[i].count - 1)) {
					solveCount += j + 1;
				}
				else {
					solveCount = ProbInfo::INF;
				}
				break;
			}
		}
	}
	if (nowProb >= probSize) {
		return solveCount;
	}
	solved[nowProb] = true;
	solveCount = tp_min(solveCount, getLeastNum(prob, solved, probSize, nowProb + 1, nowPoint + prob[nowProb].getTotal(), targPt));
	solved[nowProb] = false;
	solveCount = tp_min(solveCount, getLeastNum(prob, solved, probSize, nowProb + 1, nowPoint, targPt));

	return solveCount;
}

static void ABC104C_AllGreen()
{
	int D, G;
	get2int(D, G);

	auto prInfo = new ProbInfo[D];
	for (int i = 0; i < D; i++) {
		get2int(prInfo[i].count, prInfo[i].bonus);
		prInfo[i].point = (i + 1) * 100;
	}

	bool solved[10] = { 0 };
	printf("%d\n", getLeastNum(prInfo, solved, D, 0, 0, G));
	delete[] prInfo;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
V = [int(i) for i in input().split()]

ans = 0

for left in range(0, K + 1) :
    for right in range(0, K - left + 1) :
        if left + right > N :
            break

        cd = K - left - right

        res = 0
        minus = []

        for vi in V[:left] :
            if vi < 0 :
                minus.append(vi)
            res += vi

        for vi in V[-1:-1-right:-1] :
            if vi < 0 :
                minus.append(vi)
            res += vi

        if len(minus) > cd :
            minus.sort()
            res -= sum(minus[:cd])
        else :
            res -= sum(minus)

        ans = max(ans, res)

print(ans)
            

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

int main()
{
	int a;

	while ((cin >> a) &&  a != 0){
		map<char, char> tbl;
		for (int i = a; i > 0; i--){
			char b;
			cin >> b;
			cin >> tbl[b];
		}
		int d;
		cin >> d;
		for (int i = d; i > 0; i--){
			char tmp;
			cin >> tmp;

			map<char, char>::iterator itr = tbl.find(tmp);
			//?????????????????????????????????????????£?????´????????????
			if (itr != tbl.end()){
				cout << tbl[tmp];
			}
			else{
				cout << tmp;
			}
		}
		cout << endl;
	}
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  if (N % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  string T1 = S.substr(0, N / 2);
  string T2 = S.substr(N / 2, S.size());

  if (T1 == T2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
if a%2 == 0:
    if b%2 == 0:
        if ((b-a)//2) % 2 == 0:
            ans = list(map(int, list(format(b, "b"))))
        else:
            b_bin = list(format(b, "b"))
            l = len(b_bin)
            b_bin[l-1] = str((int(b_bin[l-1])+1)%2)
            ans = list(map(int, b_bin))
        answer = 0
        l_ans = len(ans)
        for i in range(l_ans):
            answer += (2**i)*ans[l_ans-i-1]
    else:
        b_len = len(list(format(b, "b")))
        if ((b+1-a)//2) % 2 == 0:
            answer = 0
        else:
            answer = 1
else:
    if b%2 == 1:
        if ((b-a)//2) % 2 == 0:
            ans = list(map(int, list(format(a, "b"))))
        else:
            a_bin = list(format(a, "b"))
            l = len(a_bin)
            a_bin[l-1] = str((int(a_bin[l-1])+1)%2)
            ans = list(map(int, a_bin))
        answer = 0
        l_ans = len(ans)
        for i in range(l_ans):
            answer += (2 ** i) * ans[l_ans - i - 1]
    else:
        if ((b-a-1)//2)%2 == 0:
            flag = 0
        else:
            flag = 1
        answer = b^a
        if flag:
            answer ^= 1

print(answer)

Measured memory_bytes: 38384
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include<iterator>
#include <map>
using namespace std;

int main() {
    long long ch, i = 1, n, q, k, l, r;
    long long j;
    cin >> n;
    ch = 7;
    if (n % 2 != 0) {
        while (ch % n != 0) {
            i++;
            ch = (ch * 10 + 7) % n;
            if (i > n){
                cout << -1;
                return 0;
            }

        }
        cout << i;
    }
    else
        cout << -1;

    return 0;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>


using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

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; }
const long long INF = 1LL<<60;


int main(void){

  int N, M;
  cin >> N >> M;

  int s[M][N];
  int k[M];

  for (int i = 0; i < M; ++i){
    cin >> k[i];

    for (int j = 0; j < k[i]; ++j){
      cin >> s[i][j];
      s[i][j]--;
    }
  }

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

  // all explore
  long long ans = 0;
  for (int bit = 0; bit < (1<<N); ++bit){
      bool light = true;
    for (int i = 0; i < M; ++i){
      int on_num = 0;
      for (int j = 0; j < k[i]; ++j){
        if (bit & (1<<s[i][j])){++on_num;}
      }
      if (on_num % 2 != p[i]){
        light = false;
        break;
      }
    }
    if (light){++ans;}
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$list = fscanf(STDIN, str_repeat("%d", $N));
sort($list);
$bai_list  = [];
$same_list = [];
$ans = 0;
foreach($list as $value){
    if(isset($same_list[$value])){
        if($same_list[$value] == 1){
            $ans--;
            $same_list[$value] = 2;
        }
    }elseif(!isset($bai_list[$value])){
        $no = $value;
        while($no < 1000000){
            $bai_list[$no] = 1;
            $no += $value;
        }
        $bai_list[$no] = 1;
        $same_list[$value] = 1;
        $ans++;
    }else{
        $same_list[$value] = 2;
    }
}

echo $ans;

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;

	vector<int> a(n+1);

	for (int i = 1; i < n; ++i)
		a[i+1] = s[i-1] == 'A' && s[i] == 'C';

	for (int i = 2; i <= n; ++i)
		a[i] += a[i-1];

	for (int l, r; q--; )
	{
		cin >> l >> r;
		cout << a[r] - a[l] << "\n";
	}

	return 0;
}


Measured memory_bytes: 1488
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a + b >= 10) {
            System.out.println("error");
        } else {
            System.out.println(a + b);
        }
    }

}


Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
//#include "MyLib.h"

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

vector<int> P;
bool isP[100005];

class comb
{
public:
	comb(long long int mod)
		:mod(mod)
	{}
	~comb()
	{}

	void init(int n)
	{
		fact.resize(n);
		fact[0] = 1;
		for (int i = 1; i < n; ++i)
		{
			//! 階乗
			fact[i] = fact[i - 1] * i;
			fact[i] %= mod;
		}

		//! 階乗の逆元
		revFact.resize(n);
		revFact[n - 1] = powmod(fact[n - 1], mod - 2);
		for (int i = n - 2; i >= 0; --i)
		{
			revFact[i] = revFact[i + 1] * (i + 1);
			revFact[i] %= mod;
		}
	}

	long long int get(int a, int b)
	{
		return (((fact[a] * revFact[b]) % mod)*revFact[a - b]) % mod;
	}

private:

	long long int powmod(long long int a, long long int p)
	{
		long long int ans = 1;
		long long int mul = a;
		for (; p > 0; p >>= 1, mul = (mul*mul) % mod)
		{
			if ((p & 1) == 1) ans = (ans*mul) % mod;
		}
		return ans;
	}
	long long int mod;
	std::vector<long long int> fact;
	std::vector<long long int> revFact;
};

struct PrimeList
{
	PrimeList()
	{
		prime.clear();
	};
	~PrimeList() {};

	void init(int n)
	{
		std::vector<bool> isComposite(n + 1);
		for (int i = 2; i <= n; ++i)
		{
			if (isComposite[i])continue;
			prime.push_back(i);
			for (int j = i; j <= n; j += i)
			{
				isComposite[j] = true;
			}
		}
	}

	std::vector<int> prime;
};
struct PrimeFactorization
{
	PrimeFactorization()
	{
		factor.clear();
	};
	~PrimeFactorization() {};

	void init(int N)
	{
		PrimeList primList;
		primList.init(100000);
		for (int i = 0; i < primList.prime.size() && N != 1; ++i)
		{
			int p = primList.prime[i];
			int n = 0;
			for (; N%p == 0; N /= p) { ++n; }
			if (n > 0) factor.push_back(std::pair<int, int>(p, n));
		}
		if (N != 1)factor.push_back(std::pair<int, int>(N, 1));
	}

	std::vector< std::pair<int, int> > factor;
};

int main()
{
	int N, M;
	cin >> N >> M;
	comb c(MOD);
	c.init(100 + N);

	PrimeFactorization p;
	p.init(M);

	ll ans = 1;
	REP(i, p.factor.size())
	{
		ans *= c.get(p.factor[i].second + N - 1, p.factor[i].second);
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
n = int(input())
A = list(map(int,input().split()))
halfA = sum(A)//2

rest = 0
for i in range(n//2):
  rest += A[i*2+1]
  

a = halfA-rest
ans = [a*2]
for i in range(n-1):
  a = A[i]-a
  ans.append(a*2)

print(*ans)

Measured memory_bytes: 14092
W, H, N = [int(i) for i in input().split()]
w, h = 0, 0
for i in range(N):
    x, y, a = [int(i) for i in input().split()]
    if a is 1:
        w = max(w, x)
    elif a is 2:
        W = min(W, x)
    elif a is 3:
        h = max(h, y)
    elif a is 4:
        H = min(H, y)

print(max(0, max(0, W - w) * max(0, H - h)))


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

class name
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        for (int i = 0; i < b.Length - 1; i++)
        {

            // 下から上に順番に比較します
            for (int j = b.Length - 1; j > i; j--)
            {

                // 上の方が大きいときは互いに入れ替えます
                if (b[j] < b[j - 1])
                {
                    int t = b[j];
                    b[j] = b[j - 1];
                    b[j - 1] = t;
                }
            }
        }
        int s = 0;
        for(int d = 0; d < a[1]; d++)
        {
             s += b[d]; 

        }
        Console.WriteLine(s);

    }


}

Measured memory_bytes: 28624
n,m,x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
num,num2 = 0,0
for i in range(x+1,n):
	if i in a: num+=1
for i in range(x-1,0,-1):
	if i in a: num2+=1
print(min(num,num2))

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int H = 0, W = 0, h = 0, w = 0;

    scanf("%d", &H);
    scanf("%d", &W);
    scanf("%d", &h);
    scanf("%d", &w);

    printf("%d", (H - h) * (W - w));

    return 0;
}

Measured memory_bytes: 128
def inpl(): return [int(i) for i in input().split()]
x, y = inpl()
if x < y:
    if y > 0:
        if 0 <= x :
            ans = y-x
        elif -y <= x < 0:
            ans = 1+x+y
        else:
            ans = 1-y-x
    else:
        ans = y-x
else:
    if x == 0:
        ans = 1-y
    elif x > 0:
        if y == 0:
            ans = x+1
        elif y > 0:
            ans = -y+x+2
        elif -x <= y:
            ans = 1+x+y
        else:
            ans = -y-x+1
    else:
        ans = x-y+2
print(ans)

Measured memory_bytes: 3064
#pragma region header
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
template <class T> ll size(const T& x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1 << 31);
const double pi = acos(-1);
const double EPS = 1e-9;

#pragma endregion

int main()
{
	ll n;
	cin >> n;
	vi cnt(200001, 0);
	vi A(n);
	rep(i, 0, n)
	{
		cin >> A[i];
		cnt[A[i]]++;
	}
	ll sm = 0;
	rep(i, 0, 200001)
	{
		sm += (cnt[i])*(cnt[i]-1)/2;
	}
	rep(i, 0, n)
	{
		ll diff = ((cnt[A[i]]) * (cnt[A[i]] - 1) / 2) - (cnt[A[i]]-1) * (cnt[A[i]] - 2) / 2;
		cout << sm - diff << endl;
	}
}

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

int main() {
  int length;
  cin >> length;
  map<int,int> mp;
  int ans = 0;
  for (int i = 0; i < length; i++){
    int num;
    cin >> num;
    ans++;
    if (mp.count(num) == 1){
      mp[num]++;
    } else {
      mp[num] = 1;
    }
    if (mp[num] == num){
      ans -= num;
    }
  }
  cout << ans;
}

Measured memory_bytes: 4736
using System;
using System.Linq;
using System.Collections;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            MyInputStream cin = new MyInputStream();

            var cards = new int[14] { 0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            var A = cin.ReadInt();
            var B = cin.ReadInt();
            if (cards[A] == cards[B])
                WriteLine("Draw");
            else if (cards[A] < cards[B])
                WriteLine("Bob");
            else
                WriteLine("Alice");
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }

    public class Pair<T1, T2>
    {
        public T1 First;
        public T2 Second;
        public Pair() { First = default(T1); Second = default(T2); }
        public Pair(T1 f, T2 s) { First = f; Second = s; }
        public override string ToString() { return "(" + First + ", " + Second + ")"; }
        public override int GetHashCode() { return First.GetHashCode() ^ Second.GetHashCode(); }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            else if (obj == null) return false;
            var tmp = obj as Pair<T1, T2>;
            return (object)tmp != null && First.Equals(tmp.First) && Second.Equals(tmp.Second);
        }
    }

    #region HashMap
    public class HashMap<K, V> : Dictionary<K, V>
    {
        public HashMap() : base() { }
        public HashMap(int cap) : base(cap) { }
        public HashMap(IDictionary<K, V> dictionary) : base(dictionary) { }
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }
    #endregion
}


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

string C(string str){
	string ret = "";
	int cnt = 0;
	for(size_t i = 0; i < str.size(); i++){
		if(str[i] == '+'){
			cnt++;
		}
		else if(str[i] == '-'){
			cnt--;
		}
		else if(str[i] == '['){
			int j = 0, d = 1;
			while(d > 0){
				if(str[i+j+1] == '[')d++;
				if(str[i+j+1] == ']')d--;
				j++;
			}
//			cerr << "rev:" << str.substr(i+1,j-1) << endl;;
			string tmp = C(str.substr(i+1,j-1));
//			cerr << "tmp:" << tmp << endl;
			reverse(ALL(tmp));
			ret += tmp;
			i+=j;
		}
		else if(str[i] == '?'){
			ret.push_back('A');
			cnt = 0;
		}
		else if(isalpha(str[i])){
			if(cnt > 0){
				ret.push_back((str[i]-'A'+cnt)%26 + 'A');
				cnt = 0;
			}
			else if(cnt < 0){
				ret.push_back((str[i]-'A'+cnt+26*4)%26 + 'A');
				cnt = 0;
			}
			else{
				ret.push_back(str[i]);
			}
		}
	}
	return ret;
}


signed main(){
	while(true){
		string str; cin >> str;
		if(str == ".")break;
		cout << C(str) << endl;
	}
	return 0;
}





Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)

int main(){
	io;
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
	return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
sgns = ('>', '==', '<')
d_sa = {
    sgn:ans
    for sgn, ans in
    zip(sgns, ('Left', 'Balanced', 'Right'))
    }
for sgn in sgns:
    f = str(a+b)+sgn+str(c+d)
    if eval(f):
        print(d_sa[sgn])
        exit()


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10 ** 6)

def vacation(n, cost):
    res = []
    for i in range(n):
        res.append([-1,-1,-1])

    for i in range(3):
        res[0][i] = cost[0][i]
        for day in range (1, n ):
            for action in range(3):
                res[day][action] = cost[day][action]
                for prev_action in range(3):
                    if prev_action == action:
                        continue
                    res[day][action] = max(res[day][action], res[day-1][prev_action] + cost[day][action])
    #print(res[0][i])
    #print(res[n-1][i])
    #print(res)
    print(max(res[n-1]))

def main():
    lines = []
    for line in sys.stdin:
        lines.append([int(i) for i in line.strip().split(' ')])
    n = lines[0][0]
    gains = lines[1:]
 
    #print(n)
    #print(gains)
    vacation(n, gains)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44876
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

struct Node{
    int x, y, r;
};

double getLen(Node n1, Node n2){
    return max(0.0, sqrt(pow(n1.x - n2.x, 2) + pow(n1.y - n2.y, 2)) - n1.r - n2.r);
}

int main(){
    int xs, ys, xt, yt, n;
    cin >> xs >> ys >> xt >> yt >> n;
    vector<Node> nodes(n);
    for(int i=0;i<n;i++){
        int x, y, r;
        cin >> x >> y >> r;
        nodes[i] = {x, y, r};
    }
    nodes.push_back({xt, yt, 0});
    Node s = {xs, ys, 0};
    //TODO
    priority_queue<pair<double, Node*>, vector<pair<double, Node*>>, greater<pair<double, Node*>>> pq;
    pq.push({0, &s});
    set<Node*> visited;
    while(!pq.empty()){
        auto p = pq.top(); pq.pop();
        double cost = p.first;
        Node* n = p.second;
        if(visited.count(n)){ continue; }
        visited.insert(n);
        if(n == &nodes.back()){
            cout << fixed << setprecision(10) << cost << endl;
            return 0;
        }
        for(uint i=0;i<nodes.size();i++){
            if(n == &nodes[i]){ continue; }
            pq.push({cost + getLen(*n, nodes[i]), &nodes[i]});
        }
    }
    return 0;
}


Measured memory_bytes: 16756
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
map<int,int>d;
int read() { 
	char ch=getchar();
	int x=0,q=1;
	while(ch>'9' || ch<'0')q=ch==45?-1:q,ch=getchar();
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
	return x*q;
}
int solve(int x) {
	if(d[x]!=0)
		return d[x];
	else
		return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main() {
	d[0]=1;
	d[1]=2;
	int n;
	n=read();
	int ans=solve(n);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int n, p[100001], q[100001], odd_val, even_val, odd_cnt, even_cnt;
int main()
{
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		if (i % 2) {
			p[a[i]]++;
			if (odd_cnt < p[a[i]]) {
				odd_cnt = p[a[i]];
				odd_val = a[i];
			}
		} else {
			q[a[i]]++;
			if (even_cnt < q[a[i]]) {
				even_cnt = q[a[i]];
				even_val = a[i];
			}
		}
	}
	sort(all(p), greater<int>());
	sort(all(q), greater<int>());
	if (odd_val == even_val) {
		cout << min(n - p[0] - q[1], n - p[1] - q[0]) << endl;
	} else {
		cout << n - p[0] - q[0] << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
def check(x, N, S):
    candidate = set()
    for i in range(N - 2*x + 1):
        candidate.add(S[i:i+x])
        if S[i+x:i+2*x] in candidate:
            return True
    return False

def main():
    n = int(input())
    s = input().rstrip()
    l = 0
    r = n
    while l < r:
        mid = (l+r+1) // 2
        if check(mid, n, s):
            l = mid
        else:
            r = mid-1
    print((l+r+1)//2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 6388
import bisect
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort()
C.sort()
count = 0
for Bi in B:
    a = bisect.bisect_left(A, Bi)
    c = bisect.bisect_right(C, Bi)
    count += a * (len(C) - c)
print(count)

Measured memory_bytes: 23232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ll;
typedef pair<ll, ll> P;

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


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
  print(-1)
  exit()
S = 0
cnt = 0
AB = []
for i in range(N):
  if A[i] >= B[i]:
    AB.append(A[i] - B[i])
  else:
    S += B[i] - A[i]
    cnt += 1
AB = sorted(AB)[::-1]
i = 0
while S > 0:
  S -= AB[i]
  cnt += 1
  i += 1
print(cnt)

Measured memory_bytes: 18356
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int L, R, d; cin >> L >> R >> d;
	cout << R / d - (L-1) / d  << endl;
}


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

int main(){
	string s0, s1;
	cin >> s0 >> s1;
	int f = 0;
	rep(i, s0.size()){
		int f0 = 0;
		rep(j, s0.size()){
//			cout << s0.at(i%s0.size()) << ' ' << s1.at(j) << endl;
			if(s0.at((j+i)%s0.size()) != s1.at(j)) f0 = 1;
		}
		if(f0 == 0) f = 1;
	}
	if(f == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int n;
lint a[200000];
lint b[200000];
lint c[200000];
lint a_bc[200000];
lint a_ab[200000];
lint ans;

int main(){
  cin >> n;
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> b[i];
  REP(i,n) cin >> c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  int l = 0;
  int r = 0;
  for(int i = 0;i<n;i++){
    if(a[0]>=b[i]||b[i]>=c[n-1]) continue;
    while(a[l+1]<b[i]&&l+1<n) l++;
    a_ab[i] = l+1;
    while(b[i]>=c[r]&&r<n-1) r++;
    a_bc[i] = n-r;
    ans += a_ab[i]*a_bc[i];
    //dump(a_ab[i]*a_bc[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6908
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let mut a=a.chars().collect_vec();
    let mut b=false;
    let mut c=false;
    let mut d=false;
    let mut e=false;
    for i in 0..a.len() {
        if a[i]=='N'{b=true}
        if a[i]=='W'{c=true}
        if a[i]=='S'{d=true}
        if a[i]=='E'{e=true}
    }
    if b==d&&c==e{println!("Yes")}
    else{println!("No")}
}

Measured memory_bytes: 2128
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: usize,
        y: usize,
        z: usize,
        k: usize,
        aaa: [i64; x],
        bbb: [i64; y],
        ccc: [i64; z],
    }
    let mut ab = Vec::<i64>::new();
    for a in &aaa {
        for b in &bbb {
            ab.push(a + b);
        }
    }
    ab.sort();
    ab.reverse();
    if ab.len() > k {
        ab = ab[..k].to_vec();
    }
    let mut abc = Vec::<i64>::new();
    for a in &ab {
        for c in &ccc {
            abc.push(a + c);
        }
    }
    abc.sort();
    abc.reverse();
    let ans: Vec<String> = abc[..k].iter().map(|a| a.to_string()).collect();
    let ans = ans.join("\n");
    println!("{}", ans);
}

Measured memory_bytes: 36084
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    cin>>s>>t;
    int n=s.length(),i,count=0;
    for(i=0;i<n;i++)
    {
        if(s[i]!=t[i])
            count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3920
import java.util.Scanner;




public class Main{

  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    String S = sc.next();

    String[] splitArray = S.split("");

    int flg = 0;



    for (int i = 0; i < splitArray.length - 1; i ++ ) {

      if (splitArray[i].equals(splitArray[i+1])) {

        System.out.println("Bad");

        System.exit(0);

      }

    }


    

    System.out.println("Good");



  }


}






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

using namespace std;
typedef long long ll;


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

	int n;
	cin >> n;
	vector<ll> a(n);
	for(ll &x: a) cin >> x;
	sort(a.begin(), a.end());



	{
		ll ans = -a[0] + a.back();
		for(int i = 1; i + 1 < n; ++i)
			ans += abs(a[i]);
		cout << ans << endl;
	}
/*

	int cntNeg = 1;
	for(int i = 1; i + 1 < n; ++i)
		cntNeg += a[i] < 0;*/

	ll s1 = a.back();
	for(int i = 1; i + 1 < n && a[i] < 0; ++i) {
		cout << s1 << ' ' <<a[i] << '\n';
	s1 -= a[i];
	}

	ll s2 = a[0];
	for(int i = n - 2; i > 0 && a[i] >= 0; --i) {
		cout << s2 << ' '<<a[i] << '\n';
		s2 -= a[i];
	}
	cout << s1 << ' ' << s2 << endl;
	return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
int main(void)
{
	int q;
	int c,a,n;
	int cnt,flg;
	int i;
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d %d %d",&c,&a,&n);
		cnt=0;
		while(c!=0){
			flg=0;
			if(c>=1 && a>=1 && n>=1){
				c--;
				a--;
				n--;
				cnt++;
				flg=1;
			}
			else if(c>=2 && a>=1){
				c=c-2;
				a--;
				cnt++;
				flg=1;
			}
			else if(c>=3){
				c=c-3;
				cnt++;
				flg=1;
			}
			if(flg==0){
				break;
			}
		}
	printf("%d\n",cnt);
	}
	return 0;
}

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

using namespace std ;

char s [123456] ;

int main ( )  {
	scanf ( "%s", s ) ;
	int len = strlen ( s ) ;
	int ans ( 0 ) ;
	int p1 = 0, p2 = len - 1 ;
	while ( p1 < p2 )  {
		int cnt1 ( 0 ), cnt2 ( 0 ) ;
		while ( s [p1] == 'x' )  ++ p1, ++ cnt1 ;
		while ( s [p2] == 'x' )  -- p2, ++ cnt2 ;
		if ( s [p1] == s [p2] )  ++ p1, -- p2 ;
		else return puts ( "-1" ), 0 ;
		ans += abs ( cnt1 - cnt2 ) ;
	}
	return cout << ans << endl, 0 ;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;
	string s;
	cin>>n>>s;
	for(int i=1;i<n;i++){
		int num1=0,num2=0;
		for(int j=0;j<i;j++)
			num1|=1<<s[j]-'a';
		for(int j=i;j<n;j++)
			num2|=1<<s[j]-'a';
		ans=max(__builtin_popcount(num1&num2),ans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
for i in range(20000):
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)
    else:
        break



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

int main() {
  int a_pos, z_pos;
  string s;
  cin >> s;

  a_pos = s.find_first_of("A");
  z_pos = s.find_last_of("Z");

  cout << z_pos - a_pos + 1 << endl;
}

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

using namespace std;
typedef long long ll;
int n;
int p[200005];
int f[200005];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &p[i]);
	}
	int ans = 0;
	for(int i = 1; i <= n; i ++){
		f[p[i]] = f[p[i] - 1] + 1;
		ans = max(ans, f[p[i]]);
	}
	printf("%d\n", n - ans);
	return 0;
}

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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define pu push
#define pb push_back
ll f_min(ll a,ll b){
    return (a>b)?b:a; 
}
ll f_max(ll a,ll b){
    return (a>b)?a:b;
}
ll f_abs(ll a){
    return abs(a);
}
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
const ll MOD = 1000000007;
const int inf = 1000000001;
const ll INF = 1e16;
ll i,j,k;

bool solve(string& str){
    for(i=0;i<str.size()/2;i++){
        if(str[i] != str[str.size()-i-1])
            return false;
    }
    string front = str.substr(0,(str.size()-1)/2);
    string back  = str.substr((str.size()+3)/2-1,(str.size()-1)/2);
    // cout<<front<<" "<<back<<endl;
    for(i=0;i<front.size()/2;i++){
        if(front[i] != front[front.size()-i-1])
            return false;
    }
    for(i=0;i<back.size()/2;i++){
        if(back[i] != back[back.size()-i-1])
            return false;
    }
    return true;

}
int main(){
    fio();
    string str;
    cin>>str;
    if ( solve(str) )
        cout<<"Yes";
    else 
        cout<<"No";
}

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

D,N=map(int,input().split())
if D == 0:
    if N < 100:
        ans = N
    else:
        ans = 101
elif D == 1:
    if N < 100:
        ans = N*100
    else:
        ans = 10100
else:
    if N < 100:
        ans = N * 10000
    else:
        ans = 1010000
print(ans)


Measured memory_bytes: 62008
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B;
	cin >> A >> B;

	if (0 <= A && A <= 9 && 0 <= B && B <= 9)cout << A * B << endl;
	else cout << "-1" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  vll W(N);
  rep(i, N) {
    cin >> W[i];
  }

  vll sums(N);
  rep(i, N) {
    if (i == 0) {
      sums[i] = W[i];
    } else {
      sums[i] = sums[i - 1] + W[i];
    }
  }

  ll sum = sums[N - 1];
  ll m = INF;
  rep(i, N) {
    if (i == 0) {
      continue;
    } else {
      ll a = sum - sums[i];
      if (m > abs(a - sums[i])) {
        m = abs(a - sums[i]);
      }
    }
  }
  COUT(m);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    long long a, b, c, d;
    long long multiac, multiad, multibc, multibd ;

    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    multiac = a * c;
    multiad = a * d;
    multibc = b * c;
    multibd = b * d;

    if(multiac > multiad && multiac > multibc && multiac > multibd)
        printf("%lld", multiac);
    else if(multiad > multiac && multiad > multibc && multiad > multibd)
        printf("%lld", multiad);
    else if(multibc > multiac && multibc > multiad && multibc > multibd)
        printf("%lld", multibc);
    else
        printf("%lld", multibd);

    return 0;
}


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

int main(void){
  long long int n, m;
  cin >> n >> m;
  if(m >= n*2){
    long long int ans = n;
    m -= n*2;
    ans += m/4;
    cout << ans << endl;
  }else{
    cout << m/2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline void rd(int &x) {
	char ch; for(;!isdigit(ch=getchar()););
	for(x=ch-'0';isdigit(ch=getchar());)x=x*10+ch-'0';
}
typedef long long LL;
const int MAXN = 305;
int n, m, L, q, dis[MAXN][MAXN], f[MAXN][MAXN];
int main() {
	memset(dis, 0x3f, sizeof dis);
	memset(f, 0x3f, sizeof f);
	rd(n), rd(m), rd(L);
	for(int i = 1, u, v; i <= m; ++i)
		rd(u), rd(v), rd(dis[u][v]), dis[v][u] = dis[u][v];
	for(int i = 1; i <= n; ++i) dis[i][i] = f[i][i] = 0;
	for(int k = 1; k <= n; ++k)
		for(int i = 1; i <= n; ++i)
			for(int j = 1; j <= n; ++j)
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			if(dis[i][j] <= L && i != j) f[i][j] = f[j][i] = 1;
	for(int k = 1; k <= n; ++k)
		for(int i = 1; i <= n; ++i)
			for(int j = 1; j <= n; ++j)
				f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
	rd(q); int x, y;
	while(q--)
		rd(x), rd(y), printf("%d\n", f[x][y] == 0x3f3f3f3f ? -1 : f[x][y]-1);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll k, n;
	cin >> k >> n;
	ll a[n];
	zep(i, 0, n){
		cin >> a[i];
	}
	ll ans = (a[0]+k)-a[n-1];
	
	zep(i, 1, n){
		ans = max(ans, a[i]-a[i-1]);
	}
	print(k-ans)
	return 0;
}

Measured memory_bytes: 1792