akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {

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

  cout << min(N * A, B) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys,random

input=sys.stdin.readline

N=int(input())
A=[-1]*N;B=[-1]*N
for i in range(N):
    A[i],B[i]=map(int,input().split())

ans=min(sum(A),sum(B))

temp=[(A[i],i) for i in range(N)]+[(B[i],i) for i in range(N)]
temp.sort()
#print(temp)
data=[0]*N
for i in range(N):
    val,id=temp[i]
    data[id]+=1
S=sum(temp[i][0] for i in range(N))

for i in range(N):
    if data[i]==2:
        test=S
        ans=min(ans,test)
    elif data[i]==1:
        if temp[N-1][1]!=i:
            test=S+max(A[i],B[i])-temp[N-1][0]
        else:
            test=S+max(A[i],B[i])-temp[N-2][0]
        ans=min(ans,test)

print(ans)


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


signed main() {
    int cnt = 0;
    int n;
    cin >> n;
    vi a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    rep(i, n){
        if(a[i] <= b[i]){
            cnt += a[i];
            /* cout << a[i] << " "; */
            b[i] -= a[i];
            if(a[i+1] >= b[i]){
                a[i+1] -= b[i];
                cnt += b[i];
            }else{
                cnt += a[i+1];
                a[i+1] = 0;
            }
        }else{
            cnt += b[i];
            /* cout << b[i] << " "; */
            b[i] = 0;
        }
    }
    /* cout << "\n"; */

    cout << cnt << endl;
}

Measured memory_bytes: 4844
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

type Weight = i32;
#[allow(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Edge {
    index: usize,
    src: usize,
    dest: usize,
    weight: Weight,
}
#[allow(dead_code)]
impl Edge {
    fn new(index: usize, src: usize, dest: usize, weight: Weight) -> Edge {
        Edge {
            index: index,
            src: src,
            dest: dest,
            weight: weight,
        }
    }
}
impl std::cmp::Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        (self.weight, self.src, self.dest).cmp(&(other.weight, other.src, other.dest))
    }
}
impl std::cmp::PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
type Edges = Vec<Edge>;
type Graph = Vec<Edges>;
#[allow(dead_code)]
fn graph_new(n: usize) -> Graph {
    vec![vec![]; n]
}
#[allow(dead_code)]
fn add_bi_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    graph[dest].push(Edge::new(*index, dest, src, weight));
    *index += 1;
}
#[allow(dead_code)]
fn add_uni_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    *index += 1;
}

fn dfs(g: &Graph, from: usize, parent: usize) -> (usize, usize) {
    let mut ret = (0, from);
    for e in g[from].iter() {
        if e.dest == parent {
            continue;
        }
        let mut nret = dfs(g, e.dest, from);
        ret = std::cmp::max(ret, nret);
    }
    ret.0 += 1;
    return ret;
}

fn main() {
    let n = read::<usize>();
    let mut g = graph_new(n);
    let mut index = 0;
    for _i in 0..(n - 1) {
        let f = read::<usize>() - 1;
        let t = read::<usize>() - 1;
        add_bi_edge(&mut g, &mut index, f, t, 1);
    }
    let (_, root) = dfs(&g, 0, 0);
    let (d, _) = dfs(&g, root, root);
    println!("{}", if d % 3 == 2 { "Second" } else { "First" });
}


Measured memory_bytes: 53756
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 16;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

//bitset使ったことほぼないなぁ
bitset<12811> dp1[90], dp2[90];

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


	fread(ci, 1, cm, stdin);
	int H, W;
	H = getint(), W = getint();
	char AB[80][80];
	rep(i, H) rep(j, W) {
		AB[i][j] = getint();
	}
	rep(i, H) rep(j, W) {
		AB[i][j] = abs(AB[i][j] - getint());
	}

	int m = min(H, W);
	dp1[0][6405] = true;
	for (int hw = 0; hw < m - 1; hw++) {
		for (int w = hw; w >= 0; w--) {
			int h = hw - w;
			dp1[w] = dp1[w] << AB[h][w] | dp1[w] >> AB[h][w];
			dp1[w + 1] |= dp1[w];
		}
	}
	if (H > W) {
		for (int hw = m - 1; hw < H - 1; hw++) {
			for (int w = W - 1; w >= 0; w--) {
				int h = hw - w;
				dp1[w] = dp1[w] << AB[h][w] | dp1[w] >> AB[h][w];
				dp1[w + 1] |= dp1[w];
			}
		}
	}
	else if (H < W) {
		for (int hw = m - 1; hw < W - 1; hw++) {

			int w = hw - H + 1;
			int h = H - 1;
			dp1[0] = dp1[0] << AB[h][w] | dp1[0] >> AB[h][w];

			for (int w = hw - H + 2;  w <= hw; w++) {
				int h = hw - w;
				dp1[H - h - 1] = dp1[H - h - 1] << AB[h][w] | dp1[H - h - 1] >> AB[h][w];
				dp1[H - h - 2] |= dp1[H - h - 1];
			}
		}
	}

	int M = max(H, W);
	dp2[0][6405] = true;
	for (int hw = H + W - 2; hw >= M; hw--) {
		for (int w = W - 1; w > hw - H; w--) {
			int h = hw - w;
			int tmp = H - 1 - h;
			dp2[tmp] = dp2[tmp] << AB[h][w] | dp2[tmp] >> AB[h][w];
			dp2[tmp + 1] |= dp2[tmp];
		}
	}
	for (int w = W - 1; w > M - 1 - H; w--) {
		int h = M - 1 - w;
		int tmp = H - 1 - h;
		dp2[tmp] = dp2[tmp] << AB[h][w] | dp2[tmp] >> AB[h][w];
	}

	rep(i, 81) {
		rep(j, m) if (int((dp1[j] >> i & dp2[j]).count())) {
			printf("%d", i);
			return 0;
		}
	}

	Would you please return 0;
}

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

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

void trace(vector<int>& A)
{
    for(int i = 0; i < A.size(); i++)
    {
        if(i < A.size() - 1)
        {
            cout << A[i] << " ";
        }
        else
        {
            cout << A[i];
        }
    }
    cout << endl;
}

void insertionSort(vector<int>& A, int N)
{
    trace(A);
    for (int i = 1; i < N; i++)
    {
        int v = A[i];
        int j = i - 1;
        while ((j >= 0) && (A[j] > v))
        {
            A[j + 1] = A[j];
            A[j] = v;
            j--;
        }
        trace(A);
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N)
        cin >> A[i];

    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 3088
fun main(arg: Array<String>) {
    val (a, b) = listOfInt()
    var ans: Int
    if (a == 0 || b == 0) {
        ans = 0
    } else if (a < 0 && 0 < b) {
        ans = 0
    } else if (a > 0) {
        ans = 1
    } else {
        ans = if ((b - a + 1) % 2 == 0) 1 else -1
    }
    print(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun print(ans: Int) = println(if (ans > 0) "Positive" else if (ans < 0) "Negative" else "Zero")

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

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


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

    vector<int> T(N+1);
    LL sum = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> T[i];
        sum += T[i];
    }

    int M, P, X;
    cin >> M;

    for (int i = 0; i < M; ++i) {
        cin >> P >> X;
        cout << (sum - T[P] + X) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{ 
  int n,m,a[100][100],b[100],c[100],add[100][100],sum[100]={0},i,j;
 
  scanf("%d %d",&n,&m);
 
  for(i = 0; i < n; i++)
  { 
    for(j = 0; j < m; j++)
    {
      scanf("%d",&a[i][j]);
    }
  }
 
  for(i = 0; i < m; i++)
  {
    scanf("%d",&b[i]);
  }
     
  for(i = 0; i < n; i++)
  {
    for(j = 0; j < m; j++)
    {
      add[i][j]=a[i][j]*b[j];   
    } 
  }
   
  for(i = 0; i < n; i++)
  { 
    for(j = 0; j < m; j++)
    {   
      sum[i]=sum[i]+add[i][j];  
    }
  }
 
  for(i = 0; i < n; i++)
  {     
    printf("%d\n",sum[i]);
  }
 
  return 0;
 
}


Measured memory_bytes: 2112
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    x,a,b = map(int,input().split())
    if a-b>=0:
        print('delicious')
    elif b-a<=x:
        print('safe')
    else:
        print('dangerous')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
using System;


class AOJ
{

    public static void Main()
    {
        int[] a = new int[4];
        int[] b = new int[4];

        while (true)
        {

            string ss = Console.ReadLine();
            if (ss == null) break;

            string[] s1 = ss.Split(' ');

            string[] s2 = Console.ReadLine().Split(' ');

            for (int i = 0; i < 4; i++)
            {
                a[i] = int.Parse(s1[i]);
                b[i] = int.Parse(s2[i]);
            }

            int hit = 0, blow = 0;

            for (int i = 0; i < 4; i++)
            {

                if (a[i] == b[i])
                    hit++;

                for (int j = 0; j < 4; j++)
                {
                    if (i != j && a[i] == b[j])
                        blow++;
                }
            }

            Console.WriteLine("{0} {1}", hit, blow);
        }
    }
}

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

using namespace std;

const int DIM = 2e5 + 7;

vector <int> v[DIM];
int father[DIM];
int nr[DIM];

queue <int> q;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	
	for(int i = 1; i <= n + m - 1; i++)
	{
		int x, y;
		cin >> x >> y;
		
		v[x].push_back(y);
		
		nr[y]++;
	}
	
	int root = 0;
	
	for(int i = 1; i <= n; i++)
		if(nr[i] == 0)
		{
			root = i;
			break;
		}
	
	q.push(root);
	
	while(!q.empty())
	{
		int nod = q.front();
		q.pop();
		
		for(auto i : v[nod])
		{
			nr[i]--;
			
			if(nr[i] == 0)
			{
				father[i] = nod;
				q.push(i);
			}
		}
	}
	
	for(int i = 1; i <= n; i++)
		cout << father[i] << '\n';
}

Measured memory_bytes: 9472
from sys import stdin
X, K, D = [int(i) for i in stdin.readline().split()]
pos = X
if abs(X) >= K * D:
    pos = abs(X) - (K * D)
else:
    res = abs(X) % D
    res_2 = abs(D) - res
    per = abs(X) // D
    if (K - per) % 2 == 0:
        pos = res
    else:
        pos = res_2
print(pos)

Measured memory_bytes: 9192
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9 + 7

N=ri()
S=input()

cnt = [1]*26
ord_a = ord('a')

for s in S:
    cnt[ord(s) - ord_a] += 1

ans = 1
for c in cnt:
    ans *= c
    ans %= MOD

ans -= 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define db double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a,b) for(it=a;it!=b;it++)
#define dzkt int T;cin>>T;while(T--)
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int pow2(int a,int b) {int s=1; while(b) {if(b&1) s*=a; a*=a; b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
const int N=2e5+10,inf=1e9+10;
char ch[N];
ll a,b;
int main()
{
    iosks;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int N=1e5+5,M=N<<2;
int ans,s,t,tot,now,n,m,head[N],nex[M],to[M];
int d[N];
bool vv[N];
void add(int u,int v)
{
    to[++tot]=v;nex[tot]=head[u];head[u]=tot;
}
struct node
{
    int u,x;
    node(int u,int x):u(u),x(x){}
    bool operator<(const node&o)const
    {
        return x>o.x;
    }
};
set<pair<int,int>,int>mp;
int vis[N][3];
priority_queue<node>q;
stack<pair<int,int> >st;
void dfs(int u,int p)
{
    if(p==0)
    {
        if(d[u]>d[now]+1)
        {
            d[u]=d[now]+1;
            vv[u]=false;
            q.push(node(u,d[u]));
        }
        return;
    }
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(vis[v][p-1]) continue;
        vis[v][p-1]=true;
        st.push(make_pair(v,p-1));
        dfs(v,p-1);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
    }
    memset(d,inf,sizeof(d));
    scanf("%d%d",&s,&t);
    d[s]=0;
    memset(vv,true,sizeof(vv));
    vv[s]=false;
    q.push(node(s,d[s]));
    while(!q.empty())
    {
        now=q.top().u;q.pop();
        if(vv[now]||d[now]>=d[t]) continue;
        while(!st.empty())
        {
            vis[st.top().first][st.top().second]=false;
            st.pop();
        }
        vv[now]=true;
        dfs(now,3);
        if(now==d[t]) break;
    }
    if(d[t]!=d[0]) printf("%d\n",d[t]);
    else printf("-1\n");
} 

Measured memory_bytes: 5112
n = int(input())
a = list(map(int, input().split()))
ans = 'APPROVED'


for i in a:
    if not i % 2 == 0:
        continue
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ans = 'DENIED'

print(ans)

Measured memory_bytes: 3060
hash = Hash.new 0
while x = gets
   hash[x.to_i] += 1
end
max = 0
xs = hash.sort_by{|k,v|v}.reverse
x = xs.first[1]
mode = xs.take_while{|y|x==y[1]}.map{|x|x[0]}.sort
mode.each do|x|
   puts x
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n, k;
  cin >> n >> k;
  int ans = 0;
  while (n) {
    n /= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>

int main(){
  
  char s[1000];
  scanf("%s",s);
  
  int w,i,j;
  scanf("%d",&w);
	
  for(i=0; s[i]!='\0'; ++i);
  
	for(j=0;j<i;j=j+w)
      printf ("%c",s[j]);

}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
int main()
{
float x,q;
while(1){
scanf("%f",&q);
if(q==-1){
break;
}
x=q/2;
while(fabs(x*x*x-q)>0.00001*q){
x=x-(x*x*x-q)/(3*x*x);
}
printf("%.6f\n",x);
}
return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ll x, k, d;
    scanf("%lld%lld%lld", &x, &k, &d);
    if (x < 0) x = -x;
    ll y = x / d;
    if (k <= y) printf("%lld\n", x - k * d);
    else {
        x -= y * d;
        k -= y;
        k %= 2;
        if (k) x = d - x;
        printf("%lld\n", x);
    }
    return 0;
}


Measured memory_bytes: 3792
n, m, l = map(int, input().split())
a = []
b = []
ans = [[0 for _ in range(l)] for _ in range(n)]
for _ in range(n):
    a.append(list(map(int, input().split())))
for _ in range(m):
    b.append(list(map(int, input().split())))
for i in range(n):
    for j in range(l):
        for k in range(m):
            ans[i][j] = ans[i][j] + a[i][k] * b[k][j]
for ans_row in ans:
    print(*ans_row)



Measured memory_bytes: 7064
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        var S = Chars ();

        for (int i = 0; i < S.Length; i++) {
            if (i % 2 == 0) {
                if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
                    continue;
                } else {
                    Console.WriteLine ("No");
                    return;
                }
            } else {
                if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
                    continue;
                } else {
                    Console.WriteLine ("No");
                    return;
                }
            }
        }
        Console.WriteLine ("Yes");
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main(){
    map<string,int> mp;
    int N;  cin >> N;
    ll tmp, ans;
    for(int i=0; i<N; i++){
        string s;   cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ans = 0;
    for(auto i=mp.begin(); i != mp.end(); i++){
        tmp = i->second;
        ans += tmp*(tmp-1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    bool any = false;
    
    int tab[n][n];
    FOR(i,0,n-1) {
        string s;
        cin >> s;
        
        FOR(j,0,n-1) {
            tab[i][j] = (s[j] == '#');
            if (tab[i][j]) any = true;
        }
    }
    
    if (!any) {
        cout << -1;
        return 0;
    }
    
    int columnsNotFull = 0;
    FOR(j,0,n-1) {
        bool full = true;
        FOR(i,0,n-1) if (!tab[i][j]) full = false;
        
        if (!full) columnsNotFull++;
    }
    
    if (!columnsNotFull) {
        cout << 0;
        return 0;
    }
    
    int col[n];
    FOR(i,0,n-1) col[i] = 0;
    
    FOR(i,0,n-1) FOR(j,0,n-1) if (tab[i][j]) {
        col[j] = 1;
    }
    
    int best = INF;
    FOR(i,0,n-1) {
        int here = 0;
        FOR(j,0,n-1) if (!tab[i][j]) {
            here++;
        }
        
        if (!col[i]) {
            here++;
        }
        
        best = min(best, here);
    }
    
    cout << best + columnsNotFull;

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll T;

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

int main()
{
  std::cin >> T;

  rep( t, T )
  {
    ll A, B, C, D;
    std::cin >> A >> B >> C >> D;

    if( D-B < 0 )
    {
      puts("No");

      continue;
    }

    ll G = gcd( B, D );
    ll x = A-B;

    if( x < 0 )
    {
      puts("No");

      continue;
    }
    
    ll L = C-B;

    if( L >= 0 )
    {
      puts("Yes");

      continue;
    }

    ll y = L+(x%G-L%G+G)%G;

    if( y == L )
      y += G;

    //printf( "y: %lld\n", y );

    if( std::min(x,y) >= 0 )
      puts("Yes");
    else
      puts("No");
  }

  return 0;
}

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

int H, A[MAX+1];

void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;
	
	if(l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	if(r <= H && A[r] > A[largest]) largest = r;
	
	if(largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}	
}

int main() {
	cin >> H;
    
    for(int i = 1; i <= H; i++) cin >> A[i];
    
    for(int i = H / 2; i >= 1; i--) maxHeapify(i);
    
    for(int i = 1; i <= H; i++) {
        cout << " " << A[i];
     }
    
	cout << endl;
}

Measured memory_bytes: 5004
#include<iostream>
#include<cstdio>
#define MN 12
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char s[MN+5][MN+5];
int n,m,match[MN+5],b[MN+5],B[MN+5],ans;
bool Match(int x,int y)
{
	for(int i=1;i<=n;++i) if(s[i][x]!=s[match[i]][y]) return false;
	return true;
}
void dfs(int x,int need)
{
	if(x>n)
	{
		int flag=1,can=m&1;
		for(int i=1;i<=m;++i) B[i]=0;
		for(int i=1;i<=m;++i) if(!B[i])
		{
			int found=0;
			for(int j=i+1;j<=m;++j)
				if(!B[j]&&Match(i,j)) {B[j]=1;found=1;break;}
			if(!found) if(can)can=0; else {flag=0;break;}
		}
		if(flag) ans=1;
		return;	
	}	
	if(b[x]) return dfs(x+1,need);
	if(need) match[x]=x,dfs(x+1,0);
	for(int j=x+1;j<=n;++j) if(!b[j]) b[j]=1,match[x]=j,match[j]=x,dfs(x+1,need),b[j]=0;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i) scanf("%s",s[i]+1);
	dfs(1,n&1);
	puts(ans?"YES":"NO");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


int main()
{

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

	int n, k; cin >> n >> k;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int h; cin >> h;
		res += (h >= k);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3564
package main

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

func main() {
	N := nextInt()
	As := nextInts(N)

	visited := make(map[int]bool)
	now := 1
	count := 0
	for {
		if now == 2 {
			fmt.Println(count)
			return
		}

		if visited[now] {
			fmt.Println(-1)
			return
		}
		visited[now] = true
		now = As[now]
		count++
	}
}

func nextInts(n int) []int {
	ret := make([]int, n+1)
	for i := 1; i <= n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> s(3);
  cin >> s[0]>> s[1] >> s[2];
  sort(s.begin(),s.end());
  int count_1=0,count_2=0;
  if(s[0]==5 && s[1]==5 && s[2]==7){
    cout <<"YES";
  }else{
    cout << "NO";
  }
}
 


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

using namespace std;

int main()
{   char c;
    cin>>c;
    if (c=='a'||c=='o'||c=='e'||c=='u'||c=='i'){
        cout<<"vowel";
    }
    else {
        cout<<"consonant";
    }

    return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

// 解説PDF

using mint = modint998244353;

vector<mint> ten, one;

struct S {
    mint val;
    int len;
    S(mint val=0, int len=0) : val(val), len(len) {}
};

S op(S a, S b) { return S(a.val*ten[b.len]+b.val, a.len+b.len); }

S e() { return S(0, 0); }

S mapping(int f, S s) {
    if (f == 0) return s;
    else return S(one[s.len]*f, s.len);
}

int composition(int g, int f) {
    if (g == 0) return f;
    else return g;
}

int id() { return 0; }

int main(){
    int n, q;
    cin >> n >> q;
    ten = vector<mint>(n);
    one = vector<mint>(n);
    ten[0] = 1; one[0] = 0;
    rep(i, n) ten[i+1] = ten[i] * 10;
    rep(i, n) one[i+1] = one[i]*10 + 1;
    vector<S> init(n, S(1, 1));
    lazy_segtree<S, op, e, int, mapping, composition, id> seg(init);
    rep(i, q) {
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        seg.apply(l, r, d);
        cout << seg.all_prod().val.val() << endl;
    }
    return 0;
}


Measured memory_bytes: 11568
//おいしさ127のクッキーを貪欲に作ってみる (未証明）
#include <iostream>
using namespace std;

int main() {
	int t;
	int n, d;
	
	cin >> t;
	while (t--) {
		cin >> n >> d;
		cout << 127 * (n - 1) + ((n % 2 == 0) ? 127 - d : d) << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    int n;
    int64_t a, b, c;
    cin >> n;
    a = 2;
    b = 1;
    for (int x = 0; x < n-1; x ++ ){
        c = b;
        b = b + a;
        a = c;
    }
    cout << b << endl;
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

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

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

int main() {
    string s;
    cin >>s;
    string ans = (s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[1] == s[3]) ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = 0;
  if (A + B < 2 * C) {
    if (X < Y) {
      ans += X * A + X * B;
    } else {
      ans += Y * A + Y * B;
    }
  } else {
    if (X < Y) {
      ans += X * 2 * C;
    } else {
      ans += Y * 2 * C;
    }
  }
  if (X < Y) {
    if (B < 2 * C) {
      ans += (Y - X) * B;
    } else {
      ans += (Y - X) * 2 * C;
    }
  } else {
    if (A < 2 * C) {
      ans += (X - Y) * A;
    } else {
      ans += (X - Y) * 2 * C;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a,b,c;
  cin>>a>>b;
  if(a=='H'){
    if(b=='H') c='H';
    else c='D';
  }else{
    if(b=='H') c='D';
    else c='H';
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 1000001
#define MAX_M 100000
#define MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define ent cout<<endl
using P = pair<int, int>;
#define YES "Yes"
#define NO "No"
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

// テレンス「もしかしてACですかーッ!?」　ジョセフ「Yse! Yse! Yse! Oh~MyGod」

int main() {
  string s;
  int n,ans=0;
  cin>>n>>s;
  for(int i=0;i<1000;i++) {
    int c[3]={i/100,(i/10)%10,i%10};
    int f=0;
    for (int j=0;j<n;j++) {
      if (s[j]==('0'+c[f]))f++;
      if(f==3)break;
    }
    if(f==3)ans++;
  }
  cout<<ans<< endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N, M;
    cin >> N >> M;
    vector<vi> pay(M);
    rep(i, N) {
        int day, money;
        cin >> day >> money;
        if (M - day >= 0)pay[M - day].push_back(money);
    }
    ll ans = 0;
    priority_queue<int> kouho;
    for (int i = M - 1; i >= 0; --i) {
        each(p, pay[i])kouho.push(p);
        if (!kouho.empty()) {
            ans += kouho.top();
            kouho.pop();
        }
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 5632
#include<stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);
    int ispoor= 0;
    if(a==b&&b!=c)
        ispoor= 1;
    if(b==c&&c!=a)
        ispoor= 1;
    if(c==a&&a!=b)
        ispoor= 1;
    if(ispoor)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    return 0;

}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))

dic = {}
sum = 0
for i in a:
	sum += i
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1

q = int(input())

ans = []
for i in range(q):
	b, c = map(int, input().split())
	if b in dic:
		if c in dic:
			sum += dic[b]*c - dic[b]*b
			dic[c] += dic[b]
			dic.pop(b)
			ans.append(sum)
		else:
			dic[c] = dic[b]
			sum += dic[c]*c - dic[b]*b
			dic.pop(b)
			ans.append(sum)

	else:
		ans.append(sum)

for i in ans:
	print(i)



Measured memory_bytes: 21356
#include<cstdio>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<list>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;
typedef pair<P,double> C;

const double PI = acos(-1);

//for vector
P unit(P p){return p / abs(p);}

pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}

double dot(P x,P y){return real(conj(x)*y);}

double cross(P x,P y){return imag(conj(x)*y);}

//rotate a point counter-clockwise on the origin
P rotate(P v,double s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}


//return seta A
double arg(double a,double b,double c){return acos( (b*b+c*c-a*a)/(2*b*c) );}


//for circle
double area_cir(C c){return PI * c.sc * c.sc;}

bool in_cir(C c,P x){return (abs(x-c.fs) +EPS < c.sc);}
bool on_cir(C c,P x){return EQ(abs(x-c.fs),c.sc);}

//circle position relation
int cpr(C a,C b){
  double d = abs(a.fs-b.fs);
  if(a.sc+b.sc + EPS < d)return -1;      //no cross point (outside)
  if(b.sc+d + EPS < a.sc)return 1;       //no cross point (inside,B in A)
  if(a.sc+d + EPS < b.sc)return 2;       //no cross point (inside,A in B)
  //------------above verified----------------// 
  if(abs(a.sc+b.sc - d) < EPS)return -3; //one cross point (outside)
  if(abs(b.sc+d - a.sc) < EPS)return 3;  //one cross point (inside,B in A)
  if(abs(a.sc+d - b.sc) < EPS)return 4;  //one cross point (inside,A in B)
  return 0;                              //two cross point
}
  
//not verified
vector<P> cp_cir_to_cir(C a, C b){
  vector<P> v;
  int pos = cpr(a,b);
  if(pos==0){
    double s = arg(b.sc,abs(b.fs-a.fs),a.sc);
    P x = a.sc * unit(b.fs - a.fs);
    v.pb(a.fs + rotate(x,s));
    v.pb(a.fs + rotate(x,-s));
  }else if(abs(pos) == 3){
    v.pb(a.fs + a.sc * unit(b.fs-a.fs));
  }else if(pos == 4){
    v.pb(a.fs + a.sc * unit(b.fs-a.fs));
  }
  return v;
}

int n;
C c[500];

int main(){
  while(scanf("%d",&n),n){
    for(int i=0;i<n;i++){
      scanf("%lf%lf",&c[i].fs.real(),&c[i].fs.imag());
      c[i].sc = 1.0;
    }

    int pos;
    vector<P> s,cp;

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	pos = cpr(c[i],c[j]);
	if(pos==1)s.pb(c[i].fs);
	else if(pos==2)s.pb(c[j].fs);
	else{
	  cp = cp_cir_to_cir(c[i],c[j]);
	  for(int x=0;x<cp.sz;x++)s.pb(cp[x]);
	}
      }
    }

    int ans = 1;
    for(int i=0;i<s.sz;i++){
      int num = 0;
      for(int j=0;j<n;j++){
	if(abs(s[i]-c[j].fs) < 1.0 + EPS)num++;
      }
      if(ans<num)ans = num;
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 1808
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		String[] a=br.readLine().split(" ");
		String[] b=br.readLine().split(" ");
		double l1=0,l2=0,l3=0,l4=0;
		for(int i=0;i<n;i++){
			double x=Double.parseDouble(a[i]);
			double y=Double.parseDouble(b[i]);
			double t=Math.abs(x-y);
	        l1+=t;
	        l2+=Math.pow(t,2);
	        l3+=Math.pow(t,3);
	        l4=Math.max(t,l4);
		}
        System.out.printf("%.6f%n", l1);
        System.out.printf("%.6f%n", Math.sqrt(l2));
        System.out.printf("%.6f%n", Math.cbrt(l3));
        System.out.printf("%.6f%n", l4);
	}
}

Measured memory_bytes: 17076
/*
~Like a small boat
~On the ocean
~Sending big waves
~Into motion
!Like how a single word
!Can make a heart open
!I might only have one match
!But I can make an explosion
#And all those things I didn't say
#Wrecking balls inside my brain
#I will scream them loud tonight
#Can you hear my voice this time?
@This is my fight song
@Take back my life song
@Prove I'm alright song
@My power's turned on
$Starting right now I'll be strong
$I'll play my fight song
$And I don't really care if nobody else believes
$'Cause I've still got a lot of fight left in me!!!
*/

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

#define  F  first
#define  S  second
#define  pb push_back
#define  mp make_pair
#define  sz(s) (int)s.size()
typedef long long int ll;
const int N = 3e3+5;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,m;cin>>n>>m;
    ll a = n%m;
    if(a)a=1;
    cout<<a<< "\n";



    return 0;
}


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

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

  for (int i = 0; i < 4 - 1; i++) {
    if ((int)(s[i] - '0') == (int)(s[i+1] - '0')) {
      cout << "Bad" << endl;
      return 0;
    }
  }

  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)

const int mod=1000000007;


int main(){
  int x;
  int a,b,c;
  cin>>x;
  a=x/500;
  c=x%500;
  b=c/5;
  cout<<1000*a+5*b<<endl;
  return 0;
}

Measured memory_bytes: 3160
#include <cstdio>
using namespace std;
int v[105];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&v[i]);
    int s=1,sum=0;
    for(int i=2;i<=n;i++)
        if(v[i]==v[i-1])
            s++;
        else{
            sum+=s/2;
            s=1;
        }
        sum+=s/2;
        printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long GCM(long x, long y)
        {
            var s = x;
            var t = y;
            if (x < y) GCM(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return s / x * t;
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Reads();
            var n = input[0];
            var k = input[1];
            var a = Reads();
            var data = new long[n][];
          
            
            long kind = 1;
            Array.Sort(a);
            data[0] = new long[2];
            data[0][0] = a[0];
            data[0][1]=1;
            var j = 0;
            for (int i = 1; i < n; i++)
            {
                data[i] = new long[2];
                if (a[i - 1] == a[i])
                {
                    data[j][1]++;
                }
                else
                {
                    kind++;
                    j++;
                    data[j][0] = a[i];
                    data[j][1] = 1;
                }
            }
            Array.Sort(data, (c, b) => (int)(c[1] - b[1]));
            //var data1 = data.OrderBy(e => e[1]);
            var count = 0;
            long ans = 0;
            for (int i = 0; count < kind - k && i < n; i++)
            {
                if (data[i][1] != 0)
                {
                    ans += data[i][1];
                    count++;
                }
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n, d, x,a,cnt=0,tmp=0;
    cin >> n >> d >> x;
    rep(i, n) {
        cin >> a;
        int index = 0;
        while (1) {
            tmp = index * a + 1;
            if (tmp > d)break;
            else index++;
        }
        cnt += index;
    }
    cout << cnt + x << endl;
    return 0;
}

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

#define scd second;
#define fst first;
#define mkp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef vector<bool> vbool;

int N=2e5+10, mod=2019;
vint rmod(N), rimod(N);

ll inv_mod(ll b, ll m){
	ll a=m, r, q, x=0, y=1;
	while(b){
		r=a%b;
		q=a/b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	return (x+m)%m;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	unordered_map<ll,pair<int,int>> cnt;
	for(ll a=1; a<=300; a++){
		for(ll b=-300; b<=a; b++){
			ll a5=a*a, b5=b*b;
			a5=a5*a5*a;
			b5=b5*b5*b;
			cnt[a5-b5]={a,b};
		}
	}

	int x;
	cin>>x;
	auto itr=cnt.find(x);
	if(itr!=cnt.end()) {
		cout<<itr->second.first<<" "<<itr->second.second<<endl;	
	} else {
		assert(false);
	}
}

Measured memory_bytes: 8584
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ds = list(mapint())

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += Ds[i]*Ds[j]

print(ans)

Measured memory_bytes: 63296
import java.util.Scanner;

public class Main {
    int n, q;
    int[] as, bs;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        q = sc.nextInt();
        as = new int[q];
        bs = new int[q];
        for (int i = 0; i < q; i++) {
            as[i] = sc.nextInt() - 1;
            bs[i] = sc.nextInt() - 1;
        }
    }

    private void solve() {
        int[] xs, pos;
        xs = new int[n];
        pos = new int[n];
        boolean[] memo = new boolean[n];
        memo[0] = memo[1] = true;
        for (int i = 0; i < n; i++) {
            xs[i] = i;
            pos[i] = i;
        }
        for (int i = 0; i < q; i++) {
            int posa = as[i], posb = bs[i];
            int cupa = pos[posa], cupb = pos[posb];
            xs[cupa] = posb;
            xs[cupb] = posa;
            pos[posa] = cupb;
            pos[posb] = cupa;
            int x = xs[0] - 1, y = xs[0] + 1;
            if (x >= 0 && x < n) memo[pos[x]] = true;
            if (y >= 0 && y < n) memo[pos[y]] = true;
        }
        int sum = 0;
        for (boolean b: memo)
            sum += b ? 1 : 0;
        System.out.println(sum);
    }
}


Measured memory_bytes: 86508
using System;
using System.Linq;
class P{
    static void Main(){
        var s=int.Parse(Console.ReadLine());
        long[] a=new long[s];
        for(int i=0;i<s;i++){
            a[i]=long.Parse(Console.ReadLine());
        }
        Console.WriteLine(a.OrderBy(x=>-x).First()/2 + a.OrderBy(x=>-x).Skip(1).Sum());
    }
}

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

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

  int n;
  pair<int, int> a[200000];
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i].first;
    a[i].second = i;
  }

  sort(a, a + n);
  for (int i = 0; i < n; i++)
    cout << (i == a[n - 1].second ? a[n - 2].first : a[n - 1].first) << '\n';
}


Measured memory_bytes: 3200