akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_ll.hpp>
// using namespace boost::multiprecision; // cpp_ll

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair

signed main(){
    M s;
    FOR(i,1,2000){
        if((i * (i - 1)) % 2 == 0)
            s[(i * (i - 1)) / 2] = i;
    }
    CIN(n);
    Yes(s.count(n));
    if(!s.count(n))return 0;

    int k = s[n];
    COUT(k);

    vector<S> v(k);
    int cou = 0;
    REP(i,k){
        int c = 0;
        FOR(j, i + 1, k){
            ++c;
            ++cou;
            v[i].insert(cou);
            v[i + c].insert(cou);
        }
    }

    FOREACH(xx,v){
        SCOUT(k - 1);
        VECCOUT(xx);
    }

}


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

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

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

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

    return gcd(b, a % b);
}

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

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

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

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

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

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

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

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

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

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

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

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

int main()
{
    int n;
    std::cin >> n;
    std::string s;
    std::cin >> s;

    long long count = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                auto ptr = std::find(s.begin(), s.end(), i + '0');
                if (ptr == s.end()) {
                    continue;
                }
                ptr = std::find(ptr + 1, s.end(), j + '0');
                if (ptr == s.end()) {
                    continue;
                }
                ptr = std::find(ptr + 1, s.end(), k + '0');
                if (ptr == s.end()) {
                    continue;
                }
                count++;
            }
        }
    }

    std::cout << count << std::endl;
}


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

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

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とる。(負の剰余を正にするため)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

ll sum(ll a){
    if(a == 0) return 0;
    if((a-1) % 2 == 1){
        ll num = (a-1) / 2;
        if(num % 2 == 0){
            return 1^a;
        }else{
            return a;
        }
    }else{
        ll num = (a-1) / 2;
        if(num % 2 == 0){
            return 1;
        }else{
            return 0;
        }
    }
}

int main()
{
    ll a,b;  cin >> a >> b;
    if(a == 0 ){
        cout << sum(b);
    }else{
        a--;
        ll x = sum(a),y = sum(b);
        ll ans = x^y;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1140
#include<stdio.h>

int main(void)
{
  char S[6];
  scanf("%s",&S);
  if(S[0]=='S'){
    printf("Cloudy");
  }else if(S[0]=='C'){
    printf("Rainy");
  }else{
    printf("Sunny");
  }
  return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7

n=I()
for i in range(10**5):
    if i*i<=n:
        ans=i*i
print(ans)

Measured memory_bytes: 38768
N=int(input())
dic={}
for i in range(N):
 a=input()
 if a in dic:
  dic[a]+=1
 else:
  dic[a]=1
c=max(dic.values())
keys = [k for k, v in dic.items() if v == c]
keys.sort()
for j in range(len(keys)):
 print(keys[j])

Measured memory_bytes: 94424
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    int D; cin >> D;
    vector<vector<int>> X(N,vector<int>(D));
    for (int i=0;i<N;i++){
        for (int j=0;j<D;j++){
            cin >> X[i][j];
        }
    }
    int cnt=0;
    for(int i=0;i<N-1;i++){
        for (int j=i+1;j<N;j++){
            int DIST=0;
            for (int k=0;k<D;k++){
                DIST += pow((X[i][k]-X[j][k]),2);
            }
            int dist = (int)sqrt(DIST);
            if (DIST==dist*dist) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int N, sum = 0;
    cin >> N;
    int A[N + 2];
    A[0] = 0, A[N + 1] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        sum += abs(A[i] - A[i - 1]);
    }
    sum += abs(A[N + 1] - A[N]);

    for (int i = 1; i <= N; i++) {
        if (A[i - 1] <= A[i] && A[i] <= A[i + 1] ||
            A[i - 1] >= A[i] && A[i] >= A[i + 1])
            cout << sum << endl;
        else {
            cout << sum - min(abs(A[i - 1] - A[i]), abs(A[i] - A[i + 1])) * 2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  if(s[0]!='1'||s[n-1]!='0') {
    cout << -1 << "\n";
    return 0;
  }
  for(ll i=0;i<n&&n-2-i>=0;i++) {
    if(s[i]!=s[n-2-i]) {
      cout << -1 << "\n";
      return 0;
    }
  }
  queue<ll> q;
  for(ll i=0;i<n;i++) {
    if(s[i]=='1'||i==n-1) {
      while(q.size()) {
        cout << q.front()+1 << " " << i+1 << "\n";
        q.pop();
      }
    }
    q.push(i);
  }
}

Measured memory_bytes: 4368
import scala.io.StdIn

object Main extends App {
  
  val n = StdIn.readLine().trim.toInt
  val ar = StdIn.readLine().trim.split(' ').map(_.toInt)
  val result = new Array[Int](n)
  var max = ar.max
  
  def countingSort(): Unit = {
    val count = Array.fill(max + 1)(0)

    ar.foreach{ e =>
      count(e) += 1
    }

    def loop(current: Int): Unit = {
      if(current <= max){
        count(current) = count(current) + count(current - 1)
        loop(current + 1)
      } 
    }

    loop(1)

    //println(count.mkString(" "))
    
    (n-1 to 0 by -1).foreach{ i =>
      //print(s"ar($i) : ${ar(i)} ")
      //println(s"count(ar(i)) : ${count(ar(i))} ")
      result(count(ar(i)) - 1) = ar(i)
      count(ar(i)) -= 1
    }
  }
  
  countingSort()
  
  println(result.mkString(" "))

}


Measured memory_bytes: 471168
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set>
using namespace std;
 int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int tmp, ans = 1000000000;
  for(int i = 0; i <= 200000; i++){
    tmp = c*2*i + a*max(0, x-i) + b*max(0, y-i);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string S; cin >> S;
    rep(i,26) {
        rep(j, S.size()) {
            if (S.at(j) - 97 == i)break;
            if (j == S.size() - 1) {
                cout << char(i + 97) << endl;
                return 0;
            }
        }
    }
    cout << "None" << endl;
}

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

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N;
    cin >> N;
    
    map<int, int> X, Y;
    
    for(int i=0; i<N; i++)
    {
        int x;
        cin >> x;
        
        if(i % 2)
            X[x]++;
        else
            Y[x]++;
    }
    
    vector< pair<int, int> > A, B;
    
    for(auto &it : X)
        A.push_back({it.second, it.first});
    for(auto &it : Y)
        B.push_back({it.second, it.first});
    
    int ans = 0;
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    
    if(A.size() == 1 && B.size() == 1)
    {
        if(A[0].second == B[0].second)
            ans = N/2;
        else
            ans = 0;
    }
    else if(A.size() == 1)
    {
        if(B[0].second == A[0].second)
            ans = N - A[0].first - B[1].first;
        else
            ans = N - A[0].first - B[0].first;
    }
    else if(B.size() == 1)
    {
        if(B[0].second == A[0].second)
            ans = N - A[1].first - B[0].first;
        else
            ans = N - A[0].first - B[0].first;
    }
    else
    {
        if(B[0].second == A[0].second)
            ans = min(N - A[1].first - B[0].first, N - A[0].first - B[1].first);
        else
            ans = N - A[0].first - B[0].first;
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#pragma GCC optimize("O3")
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;

ll a,b,c,k;
int main(){
    cin >> a >> b >> c >> k;
    if(abs(b-a)>1e18)rc("Unfair");
    if(k%2==1){
        rc(b-a);
    }
    else rc(a-b);


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	deque<int> b;
	for(int i=0;i<n;i++){
		if(i%2==0) b.push_back(a[i]);
		else b.push_front(a[i]);
	}
	vector<int> c(b.begin(),b.end());
	if(n%2==1) reverse(c.begin(),c.end());
	for(int i=0;i<n;i++){
		cout << c[i] << " " ;
	}
	cout << endl;
}

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

int64_t a[100010];
int64_t b[100010];

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

    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < N; ++i){
        cin >> b[i];
    }
    int64_t sum = 0;
    for(int i = 0; i < N; ++i){
        if(a[i] < b[i]){
            sum += int((b[i] - a[i]) / 2);
        }
        else if(a[i] > b[i]){
            sum -= a[i] - b[i];
        }
    }
    cout << (sum >= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
def digit_sum(x):
  if x < 10:
    return x
  return x % 10 + digit_sum(int(x / 10))
N = int(input())
ans = N
for i in range(1, int(N / 2) + 1):
  d = digit_sum(i) + digit_sum(N - i)
  if d < ans:
    ans = d
print(ans)

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

const ll MOD = 1000000007;
const ll MAX = 100100;
const double PI = 3.1415926;

#define vll vector<ll>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
// #define traverse( container, it) for( typeof(container.begin()) it = container.begin(); it!=container.end(); it++)

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int h,w;cin>>h>>w;
	char arr[h+1][w+1];
	ll dp[h+1][w+1];
	memset(dp,0,sizeof(dp));
	for (int i = 0; i < h; i++)
	{
		string s;
		cin >> s;
		for(int j = 0; j < w; j++)
			arr[i][j] = s[j];
	}
	dp[0][0] = 1;
	for (int i = 1; i < w; i++)
	{
		if (arr[0][i] == '#')
			dp[0][i] = 0;
		else
			dp[0][i] = dp[0][i - 1];
	}

	for (int i = 1; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (arr[i][j] == '#')
			{
				dp[i][j] = 0;
				continue;
			}
			if (j == 0)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= MOD;
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

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

int main() {
    ll n;
    cin>>n;
    ll count1=0,count2=0,count3=0,count4=0;
    while(n--)
    {
        
        string s;
        cin>>s;
        if(s=="AC") count1++;
        else if(s=="WA") count2++;
        else if(s=="TLE") count3++;
        else count4++;
        
    }
    cout<<"AC x "<<count1<<"\n";
    cout<<"WA x "<<count2<<"\n";
    cout<<"TLE x "<<count3<<"\n";
    cout<<"RE x "<<count4<<"\n";
    return 0;
}

Measured memory_bytes: 3608
s = input()
s = list("".join(s))
ans = 0
for i in range(1,len(s)):
    if int(s[i-1]) == int(s[i]) == 0:
        s[i] = 1
        ans += 1
    elif int(s[i-1]) == int(s[i]) == 1:
        s[i] = 0
        ans += 1
print(ans)


Measured memory_bytes: 3956
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
xy = []
for _ in range(n):
    m = int(readline())
    tmp = [list(map(int, readline().split())) for _ in range(m)]
    xy.append(tmp)
    
# 逆から
for l in sorted(itertools.product([0, 1], repeat=n),reverse=True):
    bl = True
    for i, a in enumerate(l):
        if a == 1:
            for b in xy[i]:
                if l[b[0] - 1] != b[1]:
                    bl = False
                    break
    if bl:
        print(sum(l))
        exit()
print('0')

Measured memory_bytes: 8948
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;


signed main() {
	string s;
	cin >> s;
	if(s=="Sunny"){
		cout << "Cloudy" << endl;
	}
	else if(s=="Cloudy"){
		cout << "Rainy" << endl;
	}
	else if(s=="Rainy"){
		cout << "Sunny" << endl;
	}
}

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

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long maxv =  a * c;
    maxv = max(maxv, a *d);
    maxv = max(maxv, b * c);
    maxv = max(maxv, b * d);

    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 3568
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int W,A,B;
	cin >> W>>A>>B;
	int ans = 0;
	if( A+W < B ){
		ans = B-(A+W);
	}else if( B+W < A ){
		ans = A-(B+W);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*b - *a);
}

int main(int argc, char const *argv[]){
	int n,k,*l;
	int ans = 0;
	scanf("%d%d",&n,&k);
	l = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; ++i)	scanf(" %d",&l[i]);
	qsort(l,n,sizeof(int),comp);
	for (int i = 0; i < k; ++i)	ans += l[i];
	printf("%d\n",ans);	
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K,X;
  cin >> K >> X;
  if(500*K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  string s;
  cin >> s;
  if (s.size() < 8) {
    cout << s << endl;
    return 0;
  }
  rep(i, s.size() - 7) {
    string t = s.substr(i, 8);
    sort(all(t));
    if (t == "AADINNUY") {
      s.replace(i, 8, "AIZUNYAN");
      i += 7;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 3224
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

ls = [-1] * n
now = 0
cnt = 0
path = []
while 1:
    if ls[now] != -1:
        b = ls[now]
        break
    ls[now] = cnt
    path.append(now)
    now = a[now]
    cnt += 1
loop = path[b:]
if k <= b:
    print(path[k] + 1)
else:
    print(loop[(k - b) % len(loop)] + 1)


Measured memory_bytes: 103320
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  string w[40];
  int lengths[] = {5, 7, 5, 7, 7};
 
  while(cin >> n, n) {
    for(int i = 0; i < n; i++) {
      cin >> w[i];
    }
    for(int i = 4; i < n; i++) {
      int beforreadidx = 4, len = 0;
      for(int j = i; j >= 0; j--) {
        len += w[j].length();
        if(lengths[beforreadidx] == len) {
          len = 0;
          beforreadidx--;
          if(beforreadidx == -1) {
            cout << j + 1 << endl;
            break;
          }
        }
      }
      if(beforreadidx == -1) break;
    }
  }
  return(0);
 
}

Measured memory_bytes: 1208
// 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    
    for (int i = 0; i < N; ++i)
    {
        cin >> a[i];
    }
    int num4 = 0, num2 = 0, numother = 0;
    for (int i = 0; i < N; ++i)
    {
        if (a[i] % 4 == 0)
        {
            ++num4;
        }
        else if (a[i] % 2 == 0)
        {
            ++num2;
        }
        else
        {
            ++numother;
        }
    }

    if (num4 > 0 && num4 + 1 - (num2 % 2) - numother >= 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (num4 == 0 && num2 > 0 && numother == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>

using namespace std;

int main(void){
    string str;
    cin >> str;
    if((str.at(0) == str.at(1) && str.at(1) == str.at(2))){
        cout << "Yes" << endl;
    }else if((str.at(1) == str.at(2)&& str.at(2) == str.at(3))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
H=list(map(int, input().split()))
MAXV=10**9
dp=[MAXV for _ in range(N)]
dp[0]=0
dp[1]=abs(H[1]-H[0])
for i in range(2, N):
  dp[i]=min(dp[i-2]+abs(H[i]-H[i-2]), dp[i-1]+abs(H[i]-H[i-1]))
print(dp[-1])

Measured memory_bytes: 13924
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

class UF(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

N,M = II()
A,B = Line(M)

uf = UF(N)

temp = N*(N-1)//2
ans = []
ans.append(temp)
for i in range(M)[::-1]:
    if uf.is_same(A[i]-1,B[i]-1):
        ans.append(temp)
    else:
        a,b = uf.get_size(A[i]-1), uf.get_size(B[i]-1)
        temp -= a*b
        ans.append(temp)
        uf.union(A[i]-1,B[i]-1)

for i in range(M)[::-1]:
    print(ans[i])

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

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
// constexpr ll mod = 1e9 + 7;

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

    ll ans = 0;
    ans += X/500*1000;
    X = X%500;
    ans += X/5*5;


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


Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        tmp = 0
        for di in range(max(i-1, 0), min(i+2, H)):
            for dj in range(max(j-1, 0), min(j+2, W)):
                tmp += int(S[di][dj] == '#')
        S[i][j] = str(tmp)

for si in S:
    print(''.join(si))
    

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

int N,M,H[100000],res;
vector<int>v[100000];

int main(){
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>H[i];
	for(int i=0;i<M;i++){
		int A,B;
		cin>>A>>B;
		A--;
		B--;
		v[A].push_back(B);
		v[B].push_back(A);
	}
	for(int i=0;i<N;i++){
		bool f=true;
		for(int j:v[i]){
			if(H[j]>=H[i])f=false;
		}
		res+=f;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    int num;

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
        num=n;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        --num;
        return true;
    }
};

int main(){
    int n,k;
    cin>>n>>k;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    UnionFind uf(n-k+2);
    int inc=1;
    bool flag=false;
    for(int i=0;i<n-1;i++){
        if(p[i]<p[i+1])inc++;
        else inc=1;
        if(inc>=k){
            uf.merge(i-k+2,n-k+1);
            flag=true;
        }
    }
    set<int> st;
    for(int i=0;i<k;i++){
        st.insert(p[i]);
    }
    for(int i=1;i<n-k+1;i++){
        auto it=st.lower_bound(p[i+k-1]);
        if(p[i-1]==*st.begin()&&it==st.end()){
            uf.merge(i-1,i);
        }
        st.erase(p[i-1]);
        st.insert(p[i+k-1]);
    }
    int ans=uf.num;
    if(!flag)--ans;
    cout<<ans<<endl;
}


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

int main() {
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    int sum = 0;
    rep(i,3) sum += a[i];

    if (sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3+7;
const int maxm = 2e6+7;
const ll mod = 1e9+7;
int n,m,ar[maxn];

char ch[maxn][maxn];
int a[2][maxn][maxn];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%s", ch[i]+1);
    for(int i=1;i<=n;i++){
        int j=1;
        while(j<=m){
            while(j<=m && ch[i][j]=='#')j++;
            int pre = j;
            while(j<=m && ch[i][j]=='.'){
                j++;
            }
            for(int k=pre;k<j;k++)a[0][i][k] = j-pre;
        }
    }
    for(int i=1;i<=m;i++){
        int j=1;
        while(j<=n){
            while(j<=n && ch[j][i]=='#')j++;
            int pre = j;
            while(j<=n && ch[j][i]=='.'){
                j++;
            }
            for(int k=pre;k<j;k++)a[1][k][i] = j-pre;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(ch[i][j]=='.'){
                int pre = ans;
                ans = max(ans, a[0][i][j]+a[1][i][j]-1);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {
	string s; cin >> s;
	vector<string> a(s.size()), b;
	for (int i = 0; i < s.size(); i++) {
		a[i] = s[i];
	}
	b = a;

	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());

	int cnt = 0;
	for (int i = 0; i < a.size(); i++) {
		size_t n_count = count(b.begin(), b.end(), a[i]);
		cnt += n_count % 2;
	}

	if (cnt == 0) cout << "Yes";
	else cout << "No";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
def sign(n):
    if 0 <= n:
        return 0
    return -1

sx, sy, tx, ty = map(int, input().split(" "))

w, h = tx-sx, ty-sy

text = ""
text += "UD"[sign(h)] * abs(h)
text += "RL"[sign(w)] * abs(w)
text += "DU"[sign(h)] * abs(h)
text += "LR"[sign(w)] * (abs(w)+1)
text += "UD"[sign(h)] * (abs(h)+1)
text += "RL"[sign(w)] * (abs(w)+1)
text += "DU"[sign(h)]
text += "RL"[sign(w)]
text += "DU"[sign(h)] * (abs(h)+1)
text += "LR"[sign(w)] * (abs(w)+1)
text += "UD"[sign(h)]
print(text)

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> board(h);
    vector<bool> good_x(w, false);
    vector<bool> good_y(h, false);
    for (int i = 0; i < h; i++) {
        cin >> board[i];
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (board[i][j] == '#') {
                good_y[i] = true;
                good_x[j] = true;
            }
        }
    }
    for (int i = 0; i < h; i++) {
        if (good_y[i] == false) {
            continue;
        }
        for (int j = 0; j < w; j++) {
            if (good_x[j] == false) {
                continue;
            }
            cout << board[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) { a = 14; }
	if (b == 1) { b = 14; }
	if (a==b){print("Draw")}
	else if (a > b) {print("Alice");}
	else if (b > a) { print("Bob"); }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 ll dp[2000][2000];



int main(){
   string s,s2;
   cin>>s>>s2;
   bool f=1;
   rep(i,s.size()){
       if(s[i]!=s2[i])f=0;
   }
   if(f)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}


Measured memory_bytes: 3576
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <list>          // list
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int n;
    scanf("%d", &n);
    list<int> lst;

    rep(i, n)
    {
        char cmd[12];
        scanf("%s", cmd);
        if (cmd[0] == 'i')
        {
            int key;
            scanf("%d", &key);
            lst.push_front(key);
        }
        else if (cmd[6] == 'F')
        {
            lst.pop_front();
        }
        else if (cmd[6] == 'L')
        {
            lst.pop_back();
        }
        else if (cmd[0] == 'd')
        {
            int key;
            scanf("%d", &key);
            for (list<int>::iterator it = lst.begin(); it != lst.end(); it++)
            {
                if (*it == key)
                {
                    lst.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = lst.begin(); it != lst.end(); it++)
    {
        if (i++)
            printf(" ");
        printf("%d", *it);
    }
    printf("\n");
}



Measured memory_bytes: 34440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans;
		ans = A+B;
		if(ans<A-B) {
			ans = A-B;
		}
		if(ans<A*B) {
			ans = A*B;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21716
#include<stdio.h>
int main(){
	int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a==b&&b==c){
    	printf("1");
    	}
    if (a==b&&b!=c){
    	printf("2");
    	}
    if (a==c&&a!=b){
    	printf("2");
    	}
    if (b==c&&b!=a){
    	printf("2");
    	}
    if (a!=b&&a!=c&&b!=c){
    	printf("3");
    	}
	return 0;
	}

Measured memory_bytes: 128
from itertools import permutations

N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

ed = list(range(1, N+1))
temp = permutations(ed)

ans = 0

for i in temp:
    flg = True
    if i[0] != 1:
        continue
    else:
        for j in range(1, N):
            a, b = i[j-1], i[j]
            if a > b:
                ab = a
                a = b
                b = ab
            if [a, b] in edge:
                continue
            else:
                flg = False
                break
    if flg:
        ans += 1

print(ans)

Measured memory_bytes: 3188
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=(input.trim()).split("\n");
var cnt=1;
while(true){
   var n=arr.shift()-0;
   if(n==0)break;
   var xy=[];
   while(n--)xy.push(arr.shift().split(" ").map(Number));
   var S=0;
   for(var i=0;i<xy.length-1;i++){
      S+=(xy[i][0]-xy[i+1][0])*(xy[i][1]+xy[i+1][1]);
   }
   S+=(xy[xy.length-1][0]-xy[0][0])*(xy[xy.length-1][1]+xy[0][1]);
   console.log(cnt+" "+Math.abs(S/2).toFixed(1));
   arr.shift();
   cnt++;
}

Measured memory_bytes: 15892
#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>;

ll choose(ll n) {
  return n*(n-1)/2;
}

int main() {
  int n; 
  cin >> n;
  map<int,int> mp;
  vector<int>a(n);
  rep(i,n) {
    cin >> a[i];
    a[i]--;
  }
  rep(i,n) mp[a[i]]++;
  ll total = 0;
  rep(i,n) {
    total += choose(mp[i]);
  }
  rep(i,n) {
    ll ans = total;
    ans -= choose(mp[a[i]]);
    ans += choose(mp[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 13440
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    digit = N%10
    if digit in [2,4,5,7,9]:
        return 'hon'
    if digit in [0,1,6,8]:
        return 'pon'
    return 'bon'


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 9176
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l = sc.nextInt();
    sc.nextLine();
    String[] s = new String[n];
    for(int i = 0; i <n;i++){
      s[i] = sc.nextLine();
    }
    Arrays.sort(s);
    String strs = String.join("", s);
    System.out.println(strs);
  }
}

Measured memory_bytes: 23252
//#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> ps(n), qs(n), rs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ps[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> qs[i];
        rs[i] = i + 1;
    }
    int p, q, cnt = 0;
    do
    {
        if (ps == rs)
        {
            p = cnt;
        }
        if (qs == rs)
        {
            q = cnt;
        }
        cnt++;
    } while (next_permutation(rs.begin(), rs.end()));
    cout << abs(p - q) << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int x;
    cin >> x;

    cout << (x / 500) * 1000 + (x % 500) / 5 * 5 << "\n";

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  ll a[n];rep(i,0,n)cin>>a[i];

  ll count=0;
  map<ll,ll>mp;
  rep(i,0,n){
    mp[a[i]]++;
    mp[a[i]];
    if(a[i]!=0)count++;
  }

  bool e=true;
  rep(i,0,n){
    if(a[i]!=0&&mp[a[i]]!=2)e=false;
    else if(a[i]==0){
      if(n%2==0&&mp[a[i]]!=0)e=false;
      else if(n%2==1&&mp[a[i]]!=1)e=false;
    }
  }
  ll ans=1;
  rep(i,0,count/2){
    ans*=2;
    ans%=mod;
  }
  if(e)out(ans);
  else out(0);

  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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;
}
using namespace std;

void solve(){
  string s;
  cin>>s;
  int cnt=0;
  if(s.front()==s.back())cnt=s.size()-2-1;
  else cnt=s.size()-2;
  if(cnt%2==0)cout<<"Second\n";
  else cout<<"First\n";
  return;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AABC
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            bool b = false;

            for(int i = 0; i < s.Length; i++)
            {
                s = s.Substring(s.Length-1, 1) + s.Substring(0, s.Length-1);
                if(s.Equals(t))
                {
                    b = true;
                    break;
                }
            }
            if(b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092