akhauriyash/Code-Regression huggingface dataset:
SENTINEL = 2000000000
L = R = [0]
cnt = 0
def merge(A, n, left, mid, right):
    L = A[left:mid] + [SENTINEL]
    R = A[mid:right] + [SENTINEL]
    i = j = 0
    global cnt
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
def mergeSort(A, n, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, n, left, mid)
        mergeSort(A, n, mid, right)
        merge(A, n, left, mid, right)
n = int(input())
A = [int(i) for i in input().split()]
mergeSort(A, n, 0, n)
print(*A)
print(cnt)

Measured memory_bytes: 63760
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos;
	ld cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll i, ll z) {
	ll sum = 1;
	for (ll j = max(z, 2LL); j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%Mod;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
//#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b, c, x, sum = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int y = 0; y <= c; y++) {
				if (i * 500 + j * 100 + y * 50 == x) {
					sum++;
				}
			}
		}
	}
	cout << sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
n=int(input())
for i in range(n) :
    if (i+1)%3==0 :
        print(" {}".format(i+1),end="")
    else :
        x=i+1
        while(x!=0) :
            if x%10 == 3 :
                print(" {}".format(i+1),end="")
                break
            x=int(x/10)
print("")


Measured memory_bytes: 5872
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long a,b,ans=1;
	cin>>a>>b;
	if(a>0)
	std::cout<<"Positive\n";
	else
	if(b>=0)
	cout<<"Zero\n";
    else if((a&1)^(b&1)) 
	cout<<"Positive\n"; 
	else cout<<"Negative\n";
	return 0; 
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      double ans = 0;
      int count = 0;
      for(int i = 1;i<=n;i++){
        int m = i;
        while(m<k){
          m *=2;
          count++;
        }
        ans+=1/Math.pow(2,count)/n;

        count = 0;
      }
      // 出力
      System.out.println(ans);
	}
}

Measured memory_bytes: 22736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>

int main(){
  int a,b;
  cin >> a >> b;
  int ansmin = 0,ansmax = 1000000;
  rep(i,b){
    int c,d;
    cin >> c >> d;
    ansmin = max(ansmin,c);
    ansmax = min(ansmax,d);
  }
  if(ansmax >= ansmin) cout << ansmax - ansmin +1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int a;
    cin >> a;

    int b = a + (a * a) + (a * a * a);

    cout << b;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3632
N,M = list(map(int,input().split()))

A = list(map(int,input().split()))

BC = []
for i in range(M):
    b,c = list(map(int,input().split()))
    BC.append([b,c])
    
BC=sorted(BC,key = lambda x:x[1],reverse=True)

A.sort()
bc_index=0
for i in range(N):
    if A[i]<BC[bc_index][1]:
        BC[bc_index][0]-=1
        A[i]=BC[bc_index][1]
    else:
        break
    if BC[bc_index][0]==0:
        bc_index+=1
        if bc_index==M:
            break

print(sum(A))

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++)ans+=(s[i]=='2');
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using ll = long long;
using namespace std;

vector<int> G[100000];
int N;
bool visited[100000] = {};
int prenum[100000], parent[100000], lowest[100000], timer;
void dfs ( int now, int prev){
    prenum[now] = lowest[now] = timer;
    timer++;
    visited[now] = true;

    for (int &next : G[now]){
        if (!visited[next]){
            parent[next] = now;
            dfs(next, now);
            lowest[now] = min(lowest[now], lowest[next]);
        } else if (next != prev){
            lowest[now] = min(lowest[now], prenum[next]);
        }
    }
}

void artpoints(){
    for (int j = 0; j < N; ++j) {
        visited[j] = false;
    }
    timer = 1;
    dfs(0, -1);

    set<int> ap;
    int np = 0;
    for (int i = 0; i < N; ++i) {
        int p = parent[i];
        if (p == 0) np++;
        else if (prenum[p] <= lowest[i]) ap.insert(p);
    }
    if (np > 2) ap.insert(0);
    for (auto &a: ap){
        cout << a << "\n";
    }
}

int main() {
    int m;
    cin >> N >> m;
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    artpoints();
    return 0;
}



Measured memory_bytes: 6688
#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 n, k;
    cin >> n >> k;

    vector<ll> v(n);
    rep (i, n)
        cin >> v[i];

    ll ans = 0;
    for (int l = 0; l <= min(n, k); l++)
        for (int r = 0; l + r <= min(n, k); r++)
        {
            if (l + r > n)
                continue;
            vector<ll> sum;
            ll ret = 0;
            rep (i, l)
            {
                sum.push_back(v[i]);
                ret += v[i];
            }
            rep (i, r)
            {
                sum.push_back(v[n - 1 - i]);
                ret += v[n - 1 - i];
            }
            sort(sum.begin(), sum.end());

            int size = sum.size();
            rep (i, size)
            {
                if (i >= k - l - r || sum[i] >= 0)
                    break;
                ret -= sum[i];
            }
            ans = max(ans, ret);
        }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  cout << A.at(N-1)-A.at(0) << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n,m;
int dp[330][330][330];
inline void add(int &a,int b)
{
	a+=b;
	if(a>=MOD)a-=MOD;
}
int main()
{
	scanf("%d%d",&n,&m);
	dp[0][1][n-1]=1;
	for(int i=0;i<m;i++)
	{
		for(int fst=1;fst<=n;fst++)
		{
			for(int lft=0;lft+fst<=n;lft++)
			{
				if(!dp[i][fst][lft])continue;
				//keep
				add(dp[i+1][fst][lft],dp[i][fst][lft]*1ll*(n-lft-fst)%MOD);
				
				//extend
				if(lft)add(dp[i+1][fst][lft-1],dp[i][fst][lft]*1ll*lft%MOD);
				
				//back
				add(dp[i+1][n-lft][lft],dp[i][fst][lft]*1ll*fst%MOD);
			}
		}
	}
	printf("%d\n",dp[m][n][0]);
	return 0;
}

Measured memory_bytes: 127232
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int H, W;
int a[500][500];
int main()
{
    cin >> H >> W;
    REP(i, H) REP(j, W) cin >> a[i][j];

    int add = 0;
    using pint = pair<int, int>;
    vector<pint> ans;
    REP(i, H)
    {
        if (i & 1)
        {
            REP(j, W) if ((add + a[i][j]) & 1)
            {
                add = 1;
                if (i < H - 1 || j < W - 1) ans.push_back(pint(i + 1, j + 1));
            }
            else add = 0;
        }
        else
        {
            IREP(j, W) if ((add + a[i][j]) & 1)
            {
                add = 1;
                if (i < H - 1 || j > 0) ans.push_back(pint(i + 1, -j - 1));
            }
            else add = 0;
        }
    }
    cout << ans.size() << endl;
    for (auto v : ans)
    {
        int out = abs(v.second + 1);
        if (out >= 1 && out <= W )
        {
            cout << v.first << " " << abs(v.second) << " " << v.first << " " << out << endl;
        }
        else cout << v.first << " " << abs(v.second) << " " << v.first + 1 << " " << abs(v.second) << endl;
    }
}


Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=1e5+10;
int n,m,p;
int head[N],vis[N],In[N];
bool Flag;
struct Edge {
  int to,last;
  Edge () {}
  Edge (int a,int b) :to(a),last(b) {}
}edge[N<<2];
void ADD(int a,int b) {
  edge[++p]=Edge(b,head[a]); head[a]=p;
  edge[++p]=Edge(a,head[b]); head[b]=p;
}
void DFS(int u,int c) {
  if(vis[u]) {
    if(vis[u]!=c) Flag=true;
    return;
  }
  vis[u]=c;
  for(int i=head[u];i;i=edge[i].last) {
    int v=edge[i].to;
    DFS(v,c^1);
  }
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,m);
  for(int i=1;i<=m;++i) {
    int u,v; read(u,v);
    ADD(u,v);
    ++In[u]; ++In[v];
  }
  LL A=0,B=0,C=0;
  for(int i=1;i<=n;++i) if(!vis[i]) {
    if(!In[i]) ++A;
    else {
      Flag=false;
      DFS(i,2);
      if(Flag) ++C;
      else ++B;
    }
  }
  printf("%lld\n",A*n+A*(n-A)+B*B*2+C*C+C*B*2);
  return 0;
}


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

const int MOD = 1000003;

int mod_pow(int x, int n, int MOD = MOD) {
  if (n == 0)
    return 1;
  int res = mod_pow(x * x % MOD, n / 2, MOD);
  if (n % 2 == 1)
    res = res * x % MOD;
  return res;
}

const int MAX = MOD;
int fac[MAX], finv[MAX], inv[MAX];
void fact_Init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

signed main() {
  int Q;
  cin >> Q;

  fact_Init();

  while (Q--) {
    int x, d, n;
    cin >> x >> d >> n;

    if (d == 0) {
      cout << mod_pow(x, n) << endl;

    } else if (n >= MOD || x == 0) {
      cout << 0 << endl;

    } else {
      x = x * inv[d] % MOD;

      if (x + n - 1 >= MOD) {
        cout << 0 << endl;

      } else {
        int tmp = fac[x + n - 1] * finv[x - 1] % MOD;
        tmp *= mod_pow(d, n);
        cout << tmp % MOD << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 24320
#include<stdio.h>
int main(void){
    int m, f, r, sum;
    while(1){
        scanf("%d %d %d", &m, &f, &r);
        sum = m + f;
        if(m == -1 && f == -1 && r == -1) break;
        else if(m == -1 || f == -1) printf("F\n");
        else if(sum >= 80) printf("A\n");
        else if(sum >= 65) printf("B\n");
        else if(sum >= 50) printf("C\n");
        else if(sum >= 30){
            if(r >= 50) printf("C\n");
            else printf("D\n");
        }
        else  printf("F\n");
    }

    return 0;
}


Measured memory_bytes: 2036
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

type Town struct {
	x, y int
}

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	a := make([]Town, N)
	n, m, l := 0.0, 1.0, 1.0
	for i := 0; i < N; i++ {
		a[i].x, a[i].y = nextInt(), nextInt()
		m *= (float64(i) + 1)
	}
	for i := 0; i < N-2; i++ {
		l *= (float64(i) + 1)
	}

	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			n += 2 * l * float64(N-1) * math.Sqrt(float64((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)))
		}
	}

	fmt.Println(n / m)
}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n, m;
	cin >> n >> m;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	rep(i, m + 1) { // 何回操作する？
		rep(j, min(i, n) + 1) { // 左からどれだけ取り出す？
			rep(k, min(i - j, n) + 1) { // 右からどれだけ取り出す？
				priority_queue<int, V, greater<int>> pq;
				vector<bool> find(n, false);
				ll tmp = 0;
				int out = i - (k + j);
				rep(R, j) {
					tmp += a[R];
					pq.push(a[R]);
					find[R] = true;
				}
				rep(L, k) {
					if (find[n - 1 - L]) {
						out += k - L - 1;
						break;
					}
					tmp += a[n - 1 - L];
					pq.push(a[n - 1 - L]);
					find[n - 1 - L] = true;
				}
				while (out && !pq.empty() && pq.top() < 0) {
					out--;
					tmp += abs(pq.top());
					pq.pop();
				}
				chmax(ans, tmp);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::cmp;
use std::process;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_line(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // 入力を受け取る
    let a: usize = iter.next().unwrap().parse().unwrap();
    let mut b: usize = iter.next().unwrap().parse().unwrap();
    let c: usize = iter.next().unwrap().parse().unwrap();

    // 答え
    let mut cnt_sound: usize = 0;

    // 最大イテレーション数
    let n: usize = b / a;
    if n == 0 {
        println!("{}", cnt_sound);
        process::exit(0);
    }

    for i in 0..n {
        b -= a;
        cnt_sound += 1;
        if cnt_sound == c {
            println!("{}", cnt_sound);
            process::exit(0);
        }
    }
    println!("{}", cnt_sound);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
    int l,n;
	cin>>n>>l;
	string s;
    vector<string> v;
	for(int i=0;i<n;i++){
    	cin>>s;
		v.push_back(s);
    }
	sort(v.begin(),v.end());
	for(int j=0;j<n;j++){
    	cout<<v[j];
    }
    return 0;
}


Measured memory_bytes: 256
N, M, C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

count = 0
N.times do
  A = gets.split.map(&:to_i)
  sum = 0
  M.times do |m|
    sum += A[m] * B[m]
  end
  count += 1 if sum + C > 0
end

puts count

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

int main()
{
    LL n;
    LL c[100005];
    while(scanf("%lld",&n)!=EOF)
    {
        memset(c,0,sizeof c);
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&c[i]);
        }
        sort(c,c+n);
        LL a=c[0];
        LL sum=0,ans=0;
        for(LL i=0;i<n;i++)
        {
            if(a==c[i])
            {
                sum++;
            }
            else
            {
                if(sum%2==1)
                {
                    ans++;
                }
                sum=1;
                a=c[i];
            }
        }
        if(sum%2==1)ans++;
        printf("%lld\n",ans);
    }
    return 0;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
const int mod = 1e9+7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i=0;i<H;i++) cin >> s[i];
    vector<vector<int>> dp(H+1,vector<int>(W+1));
    dp[0][0] = 1;
    for (int h=0;h<H;h++){
        for (int w=0;w<W;w++){
            if (s[h][w] == '#') continue;
            if (w+1 < W){
                if (s[h][w+1] != '#') dp[h][w+1] = (dp[h][w+1] + dp[h][w]) % mod;
            }
            if (h+1 < H){
                if (s[h+1][w] != '#') dp[h+1][w] = (dp[h+1][w] + dp[h][w]) % mod;
            }
        }
    }
    cout << dp[H-1][W-1] << "\n";
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
long long dp[25][(1<<21)+10];
vector<int> sum[25];
int n,a[25][25];

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		for(int j=0;j<n;++j) cin>>a[i][j];
	for(int i=0;i<(1<<n)-1;++i) sum[__builtin_popcount(i)].push_back(i);
	dp[0][0]=1;
	for(int i=1;i<=n;++i){
		for(vector<int>::iterator it=sum[i-1].begin();it!=sum[i-1].end();++it){
			int x=*it;
			for(int j=0;j<n;++j){
				if(!a[i][j]||x&(1<<j)) continue;
				(dp[i][x|(1<<j)]+=dp[i-1][x])%=MOD;
			}
		}
	}
	cout<<dp[n][(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 320956
#include <bits/stdc++.h>
#define my_max(a, b) ((a) > (b) ? (a) : (b))
#define my_min(a, b) ((a) < (b) ? (a) : (b))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i, s, t) for(int i = (int)(s); i <= (int)(t); i++)
#define rev(i, t, s) for(int i = (int)(t); i >= (int)(s); i--)
#define lson rt << 1
#define rson rt << 1 | 1
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double lb;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<int> VI;
typedef std::vector<ll> VL;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> rbtree;
ll gcd(ll x, ll y){ return y % x == 0 ? x : gcd(y % x, x); }
template<class T>T my_abs(T a){ if(a < 0) a = -a; return a; }
inline ll read(){
    ll ret = 0, sign = 1;
    char c = getchar();
    while(c < '0' || c > '9'){ if(c == '-') sign = -1; c = getchar();}
    while(c >= '0' && c <= '9'){ ret = ret * 10 + c - '0'; c = getchar(); }
    return ret * sign;
}
inline void write(ll x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

//void expand_stack_space(){
//    int size = 256 << 20; // 256MB
//    char *p = (char*)malloc(size) + size;
//    __asm__("movl %0, %%esp\n" :: "r"(p));
//}

int main(){
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
    int a, b, c, k;
    scanf("%d%d%d%d", &a, &b, &c, &k);
    int ans = 0;
    if(k <= a) ans += k, k = 0;
    else ans += a, k -= a;
    if(k <= b) k = 0;
    else k -= b;
    if(k <= c) ans -= k, k = 0;
    else ans -= c, k -= c;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3828
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <unordered_set>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  string S; cin >> S;
  int N = S.size();
  int cnt1 = 0, cnt2 = 0;
  string prev;
  for (int i = 0; i < N;) {
    string str; str = S[i]; ++i;
    while (str == prev && i < N) {
      str += S[i];
      ++i;
    }
    if (str != prev) {
      ++cnt1;
    }
    prev = str;
  }

  prev = "";
  for (int i = N-1; i >= 0;) {
    string str; str = S[i]; --i;
    while (str == prev && i >= 0) {
      str += S[i];
      --i;
    }
    if (str != prev) {
      ++cnt2;
    }
    prev = str;
  }
  cout << max(cnt1, cnt2) << endl;
}


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

int main()
{
    int H, W;

    while (true) {
        cin >> H >> W;
        if( H==0 and W==0){
            break;
        }
        for(int i=0; i<H; ++i){
            for(int j=0; j<W; ++j){
                if( i==0 or i==H-1 or j==0 or j==W-1){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



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

const int add[13] = {1,1,2,1,2,2,1,1,1,2,3,2,3};
const int sub[13] = {1,1,2,2,1,1,2,2,3,1,1,3,2};
const int mul[13] = {1,2,1,1,2,1,2,3,2,3,2,1,1};

string s;

ll parse(int l, int r, int order){
  vector<ll> v;
  vector<char> op;
  for(int i=l;i<r;i++){
    if(s[i]=='('){
      int k = 1, start = i+1;
      while(k){
	i++;
	if(s[i]=='(')k++;
	else if(s[i]==')')k--;
      }
      v.push_back(parse(start,i,order));
    }else if(isdigit(s[i])){
      ll tmp = 0;
      while(isdigit(s[i])){
	tmp = tmp*10 + s[i]-'0';
	i++;
      }
      v.push_back(tmp);
      i--;
    }else{
      op.push_back(s[i]);
    }
  }
  /*
  for(int i=0;i<v.size();i++)cout << v[i] << " "; cout << endl;
  for(int j=0;j<op.size();j++)cout << op[j] << " "; cout << endl;
  */
  if(v.size()==0)return 0;

  for(int k=1;k<=3;k++){
    for(int i=0;i<op.size();i++){
      if(op[i] == '+' && add[order] == k){
	v[i] += v[i+1];
	v.erase(v.begin()+i+1);
	op.erase(op.begin()+i);
	i--;
      }
      if(op[i] == '-' && sub[order] == k){
	v[i] -= v[i+1];
	v.erase(v.begin()+i+1);
	op.erase(op.begin()+i);
	i--;
      }
      if(op[i] == '*' && mul[order] == k){
	v[i] *= v[i+1];
	v.erase(v.begin()+i+1);
	op.erase(op.begin()+i);
	i--;
      }
    }
  }
  return v[0];
}
     
int main(){
  cin >> s;
  
  ll res = parse(0,s.size(),0);
  for(int i=1;i<=12;i++)res = max(res,parse(0,s.size(),i));
  cout << res << endl;
}

Measured memory_bytes: 1212
#include<iostream>

using namespace std;

int main(){

    while(1){
        int x, y, s;
        cin>> x>> y>> s;
        if(!(x||y||s)) break;
        int ma=0;
        for(int i=1; i<s; i++){
            for(int j=1; j<s; j++){
                int mae1=i*(100+x)/100;
                int mae2=j*(100+x)/100;
                if(mae1+mae2==s){
                    ma=max(ma, i*(100+y)/100+j*(100+y)/100);
                }
            }
        }

        cout<< ma<< endl;
    }

    return 0;
}

Measured memory_bytes: 3072
import std.stdio, std.string, std.algorithm, std.conv, std.array;

void main(){
  auto nx=readln.split.map!(to!long).array;
  auto n=nx[0], x=nx[1];
  auto as=readln.split.map!(to!long).array;
  auto c=0L;
  long result=0;
  foreach(a; as){
    if(a+c>x){
      result+=a+c-x;
      c=-c+x;
    }else{
      c=a;
    }
  }
  writeln(result);
}


Measured memory_bytes: 4348
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=5000;
const int MOD=1000000007;

int n;
vector<int> adj[MAXN];

int sz[MAXN];

int dfscentroid(int at,int par) {
	sz[at]=1;
	int cmx=0;
	REPSZ(i,adj[at]) {
		int to=adj[at][i]; if(to==par) continue;
		int ret=dfscentroid(to,at); if(ret!=-1) return ret;
		sz[at]+=sz[to]; cmx=max(cmx,sz[to]);
	}
	cmx=max(cmx,n-sz[at]);
	return 2*cmx<=n?at:-1;
}

int centroid(int at) {
	return dfscentroid(at,-1);
}

int dfssz(int at,int par) {
	int ret=1;
	REPSZ(i,adj[at]) { int to=adj[at][i]; if(to==par) continue; ret+=dfssz(to,at); }
	return ret;
}

int a[MAXN],na;

int fac[MAXN+1];
int C[MAXN+1][MAXN+1];
int dp[MAXN+1][MAXN+1]; // dp[i][j] = # ways to fix j items out of the first i groups within its own group

int calc(int na) {
	//printf("a:"); REP(i,na) printf(" %d",a[i]); puts("");
	int cnt=0; REP(i,na) cnt+=a[i];
	memset(dp,0,sizeof(dp)); dp[0][0]=1; int sofar=0;
	REP(i,na) {
		REPE(j,sofar) REPE(k,a[i]) {
			dp[i+1][j+k]=(dp[i+1][j+k]+(ll)dp[i][j]*C[a[i]][k]%MOD*C[a[i]][k]%MOD*fac[k])%MOD;
		}
		sofar+=a[i];
	}
	//REPE(j,sofar) printf("%d: %d\n",j,dp[na][j]);

	int ret=0;
	REPE(j,sofar) {
		int cur=(ll)dp[na][j]*fac[cnt-j]%MOD;
		if(j%2==0) ret=(ret+cur)%MOD; else ret=(ret+MOD-cur)%MOD;
	}
	return ret;
}

void run() {
	fac[0]=1; FORE(i,1,MAXN) fac[i]=(ll)fac[i-1]*i%MOD;
	REPE(i,MAXN) { C[i][0]=C[i][i]=1; FOR(j,1,i) C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD; }

	scanf("%d",&n); REP(i,n-1) { int a,b; scanf("%d%d",&a,&b); --a,--b; adj[a].PB(b); adj[b].PB(a); }
	
	int c=centroid(0);
	na=0; REPSZ(i,adj[c]) a[na++]=dfssz(adj[c][i],c); a[na++]=1;
	

	int ret=(calc(na)+calc(na-1))%MOD;
	printf("%d\n",ret);
}

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


Measured memory_bytes: 196224
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        n: usize
    }
    let k = (n as f64).sqrt() as usize;

    // let mut i = n -1;
    // let mut sum = 0;
    // while k < i {
    //     let sh = n / i;
    //     let mo = n % i;
    //     if sh == mo {
    //         // println!("  {}", i);
    //         sum += i;
    //         i = n / (sh + 1);
    //         // i -= sh + 1;
    //     } else {
    //         i -= 1;
    //     }
    // }
    // println!("{}", sum);

    let mut m = mods(&n);
    m.sort();
    println!("{}", m.into_iter().rev().take_while(|v| v > &k).filter_map(|v| {
        let nv = v - 1;
        if n / nv == n % nv {
            Some(nv)
        } else {
            None
        }
    }).fold(0, |sum, a| sum + a));
}

fn mods(n: &usize) -> Vec<usize> {
    match n {
        &0 => vec![],
        &1 => vec![1],
        _ => {
            let mut v = vec![];
            let mut i = 1;
            while i * i <= *n {
                if n % i == 0 {
                    v.push(i);
                    v.push(n / i);
                }
                i += 1;
            }
            v
        }
    }
}



Measured memory_bytes: 4352
# coding: utf-8
# Your code here!

N = int(input())
a = list(map(int, input().split()))
a.sort()
Alice = 0
Bob = 0

for i in range(N):
    if i % 2 == 0:
        Alice += a[-1]
    else:
        Bob += a[-1]
    a.pop()
print(Alice - Bob)

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";


#define mod 1000000007
#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{IOS
ll  n,i,j,k,sum=0,f=0,count=0;

cin>>n;
ll a[n]={0};
for(i=0;i<n;i++)
{
    cin>>a[i];
}

for(i=0;i<n;i++)

{
    sum=(sum+a[i]);

}

for(i=0;i+1<n;i++)
{
    sum=sum-a[i];
    k=sum%mod;

    count=(count+(a[i]*k)%mod);

}
cout<<count%mod;




return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
using namespace std;
vector<ll> arr[200005];
ll vis[200005],dep[200005],ans[200005];
void bfs(ll src)
{
    queue<ll> q;
    q.push(src);
    dep[src]=0;
    vis[src]=1;
    while(!q.empty())
    {
        ll node=q.front();
        q.pop();
        for(ll child : arr[node])
        {
            if(vis[child]==0)
            {
                ans[child]=node;
                vis[child]=1;
                dep[child]=dep[node]=1;
                q.push(child);
            }
        }
    }
}
void dfs(ll node)
{
    vis[node]=1;
    for(ll child: arr[node])
    {
        if(vis[child]==0)
        dfs(child);
    }
}
int main()
{
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<n;i++)
    {
        ans[i]=INT_MAX;
    }
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        x--,y--;
        arr[x].pb(y);
        arr[y].pb(x);
    }
    ll c=0;
    for(ll i=0;i<n;i++)
    {
        if(vis[i]==0)
        {
            dfs(i);
            c++;
        }
    }
    if(c>1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    for(ll i=0;i<n;i++)
    {
        vis[i]=0;
    }
    bfs(0);
    for(ll i=1;i<n;i++)
    {
        cout<<ans[i]+1<<" "; 
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

const int N = 80+3;
const int M = 6500;

int n, m;
int a[N][N], b[N][N];
int mem[N][N][M<<1], *dp[N][N];

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
            dp[i][j] = mem[i][j]+M;

    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> a[i][j];
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> b[i][j];
    dp[0][1][0] = dp[1][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            for (int k = -6400; k <= 6400; ++k) {
                dp[i][j][k+a[i][j]-b[i][j]] |= dp[i-1][j][k];
                dp[i][j][k-a[i][j]+b[i][j]] |= dp[i-1][j][k];
                dp[i][j][k+a[i][j]-b[i][j]] |= dp[i][j-1][k];
                dp[i][j][k-a[i][j]+b[i][j]] |= dp[i][j-1][k];
            }
        }
    }
    int res;
    for (int i = 0; ; ++i) {
        if (!dp[n][m][i] && !dp[n][m][-i]) continue;
        res = i;
        break;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 338304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const ull MOD = 16769023;
const ull MOD1 = 1125899839733759;
int n,k;


ll a[maxN];
ll b[maxN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	int cnt = 0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]<0)
			cnt++;
	}
	vector<pll> p;
	ll ans = 0;
	if(cnt == 0)
	{
		ll last = a[1];
		for(int i=2;i<=n;i++)
		{
			if(i<n)
			{
				p.push_back(pll(last,a[i]));
				last = last - a[i];				
			}
			else
			{
				p.push_back(pll(a[i],last));
				last = a[n] - last;
			}
		}
		ans = last;
	}
	else if(cnt == n)
	{
		ll last = a[n];
		for(int i=n-1;i>=1;i--)
		{
			p.push_back(pll(last,a[i]));
			last = last - a[i];	
		}
		ans = last;
	}
	else
	{
		ll last = a[1];
		for(int i=cnt+1;i<n;i++)
		{
			p.push_back(pll(last,a[i]));
			last = last - a[i];	
		}
		p.push_back(pll(a[n],last));
		last = a[n] - last;
		for(int i=2;i<=cnt;i++)
		{
			p.push_back(pll(last,a[i]));
			last = last - a[i];
		}
		ans = last;
	}
	printf("%lld\n",ans);
	for(int i=0;i<p.size();i++)
	{
		printf("%lld %lld\n",p[i].first,p[i].second);
	}
	return 0;
}


Measured memory_bytes: 4336
#include<stdio.h>
int main()
{
    int N,K,r;
    scanf("%d %d",&N,&K);
    r=0;
    for(int i=1;N>0;i++)
    {
        N=N/K;
        r+=1;
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N; scanf("%d", &N);
	string s[100001];
	for (int i = 0; i < N; i++){
		char str[20];  scanf("%s", str);
		sort(str, str + 10);
		s[i] = string(str);
	}

	sort(s, s + N);
	long long int ret=0,cnt=0; string cmp = s[0];
	for (int i = 1; i < N; i++){
		if (cmp == s[i]){
			cnt++;
		}
		else{

			if (cnt >= 1){
				ret += (cnt+1)*(cnt)/2;
			}

			cmp = s[i];
			cnt = 0;
		}
	}

	if (cnt >= 1){
		ret += (cnt + 1)*(cnt) / 2;
	}

	printf("%lld", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 5760
n = int(input())
li = [int(input()) for _ in range(n)]
maximam = 0
second_maximam = 0

for i in li:
    if i >= maximam:
        second_maximam = maximam
        maximam = i
    elif i >= second_maximam:
        second_maximam = i

for i in li:
    if i == maximam:
        print(second_maximam)
    else:
        print(maximam)

Measured memory_bytes: 12624
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 2e9;
const int MOD = 1e9 + 7;

ll dp[100005];
int main() {
   int n, m;
   cin >> n >> m;
   vector<int> broken(n + 1);
   rep(i, 0, m) {
      int a;
      cin >> a;
      broken[a] = 1;
   }
   dp[0] = 1;
   rep(i, 0, n) {
      rep(j, i + 1, min(i + 3, n + 1)) {
         if (broken[j]) continue;
         (dp[j] += dp[i]) %= MOD;
      }
   }
   cout << dp[n] << endl;
   return 0;
}

Measured memory_bytes: 1408
import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Set<Integer> newset = new HashSet<>();
			for (int i=0;i<N;i++) {
				newset.add(sc.nextInt());
			}
			System.out.println(newset.size());
			
			sc.close();
		}
		
		
	}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
#define sz(x) (int)(x).size()
template <typename T> bool cmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
template <typename T> bool cmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }

int main() {
	
	string s;
	cin >> s;
	bool p = (s.size() & 1) == 0;
	bool q = s.front() == s.back();
	if (p ^ q) cout << "Second" << '\n';
	else cout << "First" << '\n';
}



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

int main() {
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  double a,b,c,d;
  int hun=H*60+M;
  double tyou,tan;
  tyou=M*M_PI/30;
  tan=hun*M_PI/360;
  
  //a=B*sin(tyou);
  //b=B*cos(tyou);
  //c=A*sin(tan);
  //d=A*cos(tan);

  //double e,f;
  //e=pow(a-c,2);
  //f=pow(b-d,2);
  //double ansa=sqrt(e+f);
  //cout<< setprecision(25) <<ansa<<endl;
  
  double ans;
  int E=pow(A,2);
  int F=pow(B,2);
  ans=sqrt(E+F-2*A*B*cos(tan-tyou));
  
  cout<< setprecision(25) <<ans<<endl;
}

Measured memory_bytes: 4256
#エラトステネスの篩
m=int(input())
n = 55555
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                #エラトステネスの篩
prime.remove(2)
lists=[]
for j in prime:
    if j%15==1:
        lists.append(j)
A=lists[:m]
print(*A)


Measured memory_bytes: 6764
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

void solve(){
    string s;
    cin >> s;
    int ans = 0;
    FOR(i,0,sz(s)){
        if(s[i] == 'S')continue;
        int len = 1;
        while(i+1 < sz(s) && s[i+1] == 'R')++len,++i;
        ans = max(ans,len);
    }
    cout << ans << "\n";
}
 
signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int d;
    cin >> d;
    cout << "Christmas";
    rep(i, 25 - d){
        cout << " Eve";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
typedef long long int ll;
const ll mod=1e9+7;
int main()
{
    fastio;
    int n;
    cin>>n;
    double p[n];
    fore(i,0,n)
    cin>>p[i];
    double d[n+1][n+1];
    double sum=0.0;
    memset(d,0,sizeof(d));
    d[0][0]=1;
    fore(i,1,n+1)
    {
        fore(j,0,i+1)
        {
            if(j==0)
            d[i][0]=d[i-1][j]*(1-p[i-1]);
            else if(i==j)
            d[i][j]=d[i-1][j-1]*p[i-1];
            else 
            d[i][j]=d[i-1][j]*(1-p[i-1])+d[i-1][j-1]*p[i-1];
        }
    }
    fore(i,n/2 +1,n+1)
    sum+=d[n][i];
    cout << fixed << setprecision(10) << sum;
    return 0;
}

Measured memory_bytes: 70656
import java.util.Scanner;

public class Main {
	 
    static int X,Y,ans;
    static int[][] field;
    static int[][] count;
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        while(true){
            X=cin.nextInt();
            Y=cin.nextInt();
            ans=0;
            if(X+Y==0){
                break;
            }
            field = new int[Y+2][X+2];
            count = new int[Y+2][X+2];
            for(int i = 0;i<Y+2;i++){
                for(int j = 0;j<X+2;j++){
                    field[i][j]=-1;
                }
            }
            for(int i = 0;i<Y;i++){
                for(int j = 1;j<X+1;j++){
                    field[i][j]=cin.nextInt();
                }
            }
            for(int i = 1;i<X+1;i++){
            	count[0][i]=1;
            }
            for(int i = 0;i<Y-1;i++){
            	for(int j = 1;j<=X;j++){
            		if(field[i][j]==0){
            			if(field[i+1][j-1]!=2)
            				count[i+1][j-1]+=count[i][j];
            			count[i+1][j]+=count[i][j];
            			if(field[i+1][j+1]!=2)
            				count[i+1][j+1]+=count[i][j];
            		}
            		else if(field[i][j]==1){
            			count[i][j]=0;
            		}
            		else if(field[i][j]==2){
            			
            			count[i+2][j]+=count[i][j];
            		}
            	}
            }
            for(int i = 1;i<=X;i++){
            	if(field[Y-1][i]!=1)
            		count[Y][i]+=count[Y-1][i];
            }
            for(int i = 0;i<Y+2;i++){
            	for(int j = 0;j<X+2;j++){
            		//System.out.print(count[i][j]+" " );
            	}
            	//System.out.println();
            }
            for(int i = 0;i<X;i++){
            	//System.out.println(count[Y][i+1]);
            	ans+=count[Y][i+1];
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 12000
#include <stdio.h>
int main(void){
    int x[9<<14];
    int i=0;
    int j=0;
    int min=9<<25;
    
    for(;~scanf("%d",x+i);i++);
    for(;j<x[0]-x[1]+1;j++)min=fmin(x[j+x[1]+1]-x[j+2]+fmin(abs(x[j+2]),abs(x[j+x[1]+1])),min);
    printf("%d",min);
}

Measured memory_bytes: 2516