akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, k = map(int, input().split())
    p = sorted([int(pi) for pi in input().split()])

    print(sum(p[:k]))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 65768
#include <cstdio>
#include <cstring>
#include <algorithm>

const int MAXN = 100 + 5;

const int MOD = (int)1e9 + 7;

int n, h[MAXN], sorted[MAXN];

int qpow(int a, int x) {
    int res = 1;
    for (; x > 0; x >>= 1) {
        if (x & 1)
            res = 1LL * res * a % MOD;
        a = 1LL * a * a % MOD;
    }
    return res;
}

bool added[MAXN];
int R_L[MAXN], L_R[MAXN];

int dp[MAXN][MAXN][2][2][2];
int last_h[MAXN][MAXN];

void merge(int dp_l[2][2][2], int dp_r[2][2][2], int res[2][2][2]) {
    int tmp[2][2][2];
    
    memset(tmp, 0, sizeof tmp);
    
    for (int l = 0; l < 2; ++l)
    for (int r = 0; r < 2; ++r) {
        for (int ll = 0; ll < 2; ++ll)
        for (int rr = 0; rr < 2; ++rr)
        for (int sl = 0; sl < 2; ++sl)
        for (int sr = 0; sr < 2; ++sr) {
            int t = sl | sr | (ll == rr);
            tmp[l][r][t] = (tmp[l][r][t] + 1LL * dp_l[l][ll][sl] * dp_r[rr][r][sr]) % MOD;
        }
    }
    
    memcpy(res, tmp, sizeof tmp);
}

void calc(int L, int R, int h_now) {
    if (last_h[L][R] == h_now) {
        return;
    }
    
    int tmp[2][2][2];
    int t = (last_h[L][R] - h_now) & 1;

    for (int l = 0; l < 2; ++l)
    for (int r = 0; r < 2; ++r) {
        tmp[l][r][1] = dp[L][R][l ^ t][r ^ t][1];
        tmp[l][r][0] = 1LL * (dp[L][R][l][r][0] + dp[L][R][l ^ 1][r ^ 1][0]) * qpow(2, last_h[L][R] - h_now - 1) % MOD;
    }

    memcpy(dp[L][R], tmp, sizeof tmp);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", h + i);
        sorted[i] = i;
    }
    
    std::sort(sorted + 1, sorted + n + 1, [&] (int a, int b) {
        return h[a] > h[b];
    });

    for (int i = 1; i <= n; ++i) {
        int j = sorted[i];

        int tmp[2][2][2];
        int L = j, R = j;

        memset(tmp, 0, sizeof tmp);
        tmp[0][0][0] = tmp[1][1][0] = 1;

        if (R_L[j - 1]) {
            int l = R_L[j - 1], r = j - 1;
            L_R[l] = R_L[r] = 0;
            calc(l, r, h[j]);
            merge(dp[l][r], tmp, tmp);
            L = l;
        }

        if (L_R[j + 1]) {
            int l = j + 1, r = L_R[j + 1];
            L_R[l] = R_L[r] = 0;
            calc(l, r, h[j]);
            merge(tmp, dp[l][r], tmp);
            R = r;
        }

        added[j] = true;
        memcpy(dp[L][R], tmp, sizeof tmp);
        L_R[L] = R;
        R_L[R] = L;
        last_h[L][R] = h[j];
    }

    if (h[sorted[n]] > 1) {
        int t = (h[sorted[n]] - 1) & 1;
        int tmp[2][2][2];

        for (int l = 0; l < 2; ++l)
        for (int r = 0; r < 2; ++r) {
            tmp[l][r][1] = dp[1][n][l ^ t][r ^ t][1];
            tmp[l][r][0] = 1LL * (dp[1][n][l][r][0] + dp[1][n][l ^ 1][r ^ 1][0]) * qpow(2, h[sorted[n]] - 1 - 1) % MOD;
        }
        
        memcpy(dp[1][n], tmp, sizeof tmp);
    }

    int ans = 0;
    for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
    for (int k = 0; k < 2; ++k) {
        ans = (ans + dp[1][n][i][j][k]) % MOD;
    }

    printf("%d\n", ans);

    return 0;
}

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

struct Data {int al, ah, bl, bh;};

int main() {
  int X, K;
  cin >> X >> K;
  vector<int> r(K);
  for(auto& i: r) cin >> i;

  auto fix = [X](auto& p) {
    for(auto* i: {&p.al, &p.ah, &p.bl, &p.bh}) {
      *i = max(0, *i);
      *i = min(*i, X);
    }
  };

  vector<Data> P(K);
  P[0] = {r[0], X, 0, X-r[0]};
  fix(P[0]);
  for(auto i=1; i<K; ++i) {
    P[i] = P[i-1];
    auto d = r[i] - r[i-1];
    if(i&1) {
      P[i].bl += d;
      P[i].bh += d;
      if(X < P[i].bl) P[i].al = X;
      if(X < P[i].bh) P[i].ah -= P[i].bh - X;
    } else {
      P[i].bl -= d;
      P[i].bh -= d;
      if(P[i].bl < 0) P[i].al += -P[i].bl;
      if(P[i].bh < 0) P[i].ah = 0;
    }
    fix(P[i]);
    if(P[i].al >= P[i].ah) P[i].al = X, P[i].ah = 0;
  }

  int Q;
  cin >> Q;
  for(auto q=0; q<Q; ++q) {
    int t, a;
    cin >> t >> a;
    auto i = upper_bound(begin(r), end(r), t) - begin(r);
    if(i == 0) {
      cout << max(0, a - t) << endl;
    } else {
      auto p = P[i-1];
      auto d = t - r[i-1];
      if(i&1) {
        if(a <= p.al)      a = p.bl;
        else if(p.ah <= a) a = p.bh;
        else               a = p.bl + a - p.al;
        cout << min(X, a + d) << endl;
      } else {
        if(a <= p.al)      a = p.bl;
        else if(p.ah <= a) a = p.bh;
        else               a = p.bh - (p.ah - a);
        cout << max(0, a - d) << endl;
      }
    }
  }
}


Measured memory_bytes: 3200
# coding: utf8
# 日本語を入力できるようにするために上記一文が必要


N = int(input())

num_list = []
ans = 0
count1,count2,count3 = 0,0,0
for i in range(N):
        D1,D2 = map(int, input().split())
        num_list.append([D1,D2])
        if D1 != D2:
                count1 = 0
                count2 = 0
                count3 = 0
        if D1 == D2 and  count1 == 1 and  count2 == 1:
                count3 = 1
                ans = 1
        if D1 == D2 and count1 == 1:
                count2 = 1
        if D1 == D2:
                count1 = 1
if ans == 1:
        print("Yes")
else:
        print("No")

Measured memory_bytes: 9208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            while (n-- > 0)
            {
                int[,] map = new int[9, 9];
                char[,] memo = new char[9, 9];

                for (int i = 0; i < 9; i++)
                {
                    string input = Console.ReadLine().Replace(" ", "");

                    int[] nums = new int[10];

                    for (int j = 0; j < 9; j++)
                    {
                        map[i, j] = int.Parse(input[j].ToString());
                        nums[map[i, j]]++;
                    }

                    for (int j = 0; j < 9; j++)
                    {
                        if (nums[map[i, j]] != 1)
                        {
                            memo[i, j] = '*';
                        }
                        else memo[i, j] = ' ';
                    }
                }

                for (int i = 0; i < 9; i++)
                {
                    int[] nums = new int[10];

                    for (int j = 0; j < 9; j++)
                    {
                        nums[map[j, i]]++;
                    }

                    for (int j = 0; j < 9; j++)
                    {
                        if (nums[map[j, i]] != 1)
                        {
                            memo[j, i] = '*';
                        }
                    }
                }

                int[] posX = new int[] { 0, 3, 6, 0, 3, 6, 0, 3, 6 };
                int[] posY = new int[] { 0, 0, 0, 3, 3, 3, 6, 6, 6 };

                for (int k = 0; k < 9; k++)
                {
                    int[] nums = new int[10];

                    for (int i = 0; i < 3; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            int x = j + posX[k];
                            int y = i + posY[k];

                            nums[map[y, x]]++;
                        }
                    }

                    for (int i = 0; i < 3; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            int x = j + posX[k];
                            int y = i + posY[k];

                            if (nums[map[y, x]] != 1)
                            {
                                memo[y, x] = '*';
                            }
                        }
                    }
                }

                for (int i = 0; i < 9; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        sb.Append(memo[i, j]);
                        sb.Append(map[i, j]);
                    }
                    sb.Append("\n");
                }

                if (n != 0) sb.Append("\n");
            }
            Console.Write(sb);
        }
    }
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int AB = b - a;
    int BC = c - b;

    if (AB == BC){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

// Double Landscape
const int64_t mod = 1e9 + 7;

int64_t factorial[1000001];
int64_t mod_pow(int64_t x, int64_t n) {
  if (n % 2 == 0) {
    if (n == 0) {
      return 1;
    } else {
      int64_t tmp = mod_pow(x, n / 2);
      return (tmp * tmp) % mod;
    }
  } else {
    return (x * mod_pow(x, n - 1)) % mod;
  }
}
int64_t solve(int64_t place, int64_t number) {  // number個をplaceに並べる並べ方
  return number >= place ? (factorial[number] * mod_pow(factorial[number - place], mod - 2)) % mod : 0;
}
int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> A(N), B(M);
  for (int64_t i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int64_t j = 0; j < M; j++) {
    cin >> B[j];
  }
  sort(A.begin(), A.end());
  A.push_back(0);
  A.push_back(0);
  A.erase(unique(A.begin(), A.end()));
  A.pop_back();
  sort(B.begin(), B.end());
  B.push_back(0);
  B.push_back(0);
  B.erase(unique(B.begin(), B.end()));
  B.pop_back();
  factorial[0] = 1;
  for (int i = 1; i <= 1000000; i++) {
    factorial[i] = (factorial[i - 1] * i) % mod;
  }
  int64_t ans = 1;
  if (A.size() != N || B.size() != M) {
    cout << 0 << endl;
    return 0;
  }
  int64_t x = 0;     // Aをどこまで片付けたか
  int64_t y = 0;     // Bをどこまで片付けたか
  int64_t used = 0;  // これまで埋めた数字の数
  while (x < N && y < M) {
    // cout << x << ' ' << y << endl;
    // cout << A[x] << ' ' << B[y] << endl;
    if (A[x] < B[y]) {
      ans = (ans * solve(M - y - 1, A[x] - used - 1) % mod * (M - y)) % mod;
      used += M - y;
      x++;
    } else if (A[x] > B[y]) {
      ans = (ans * solve(N - x - 1, B[y] - used - 1) % mod * (N - x)) % mod;
      used += N - x;
      y++;
    } else {  // A[x]==B[y]
      ans = (ans * solve(M + N - x - y - 2, A[x] - used - 1)) % mod;
      used += M + N - x - y - 1;
      x++;
      y++;
    }
    if (ans == 0) break;
  }
  cout << ans << endl;
  return 0;
}


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

a = []
for i in range(m):
  #[0] = 県
  #[1] = 誕生年
  #[2] = 市番号
  a.append(list(map(int, input().split())))
  a[i].append(i)

#県、誕生年ごとにソート
a.sort(key=lambda x:(x[0], x[1]))
p = 0
num = 1
for v in a:
  if not v[0] == p:
    p = v[0]
    num = 1
  _id = str(v[0]).zfill(6) + str(num).zfill(6)
  num += 1
  v.append(_id)

a.sort(key=lambda x:x[2])

for v in a:
  print(v[3])

Measured memory_bytes: 38580
# https://atcoder.jp/contests/abc061/tasks/abc061_c
# K番目に小さい数

N, K = map(int, input().split())
A = [0] * (100005)
for _ in range(N):
    ai, bi = map(int, input().split())
    A[ai] += bi

for index in range(100005):
    if K <= A[index]:
        print(index)
        exit()
    else:
        K -= A[index]
    

Measured memory_bytes: 76868
from bisect import bisect_left
from numpy import cumsum

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
B_ = [0]*N
ans = 0
start = 0
for i, b in enumerate(B):
    j = bisect_left(A, b, start)
    B_[i] = j
    start = j
B_ = cumsum(B_)
start = 0
for c in C:
    i = bisect_left(B, c, start)
    start = i
    if i != 0:
        ans += B_[i-1]
print(ans)


Measured memory_bytes: 47072
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll N,A,B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  rep(i,N) cin >> X[i]; 
  ll sum = 0;
  rep(i,N-1)
  {
    if((X[i+1]-X[i])*A<=B)
    {
      sum += (X[i+1]-X[i]) * A;
    }
    else
    {
      sum += B;
    }
    
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4040
#include <iostream>

using namespace std;

#define ull unsigned long long

int main()
{
    ull n;
    cin >> n;

    ull i;
    for (i = 1; i <= n; i++) {
        if (n == i * i) {
            cout << i * i << endl;
            break;
        } else if (n < i * i) {
            cout << (i - 1) * (i - 1) << endl;
            break;
        }
    }
    return 0;
}

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


int main(void){
    
    int M1,D1;
    int M2,D2;
    cin >> M1 >> D1;
    cin >> M2 >> D2;
    
    int ans = 0;
    if(M1 != M2)ans = 1;
    cout << ans <<endl;
    
}


Measured memory_bytes: 256
while True:
    N, M, P, A, B = map(int, input().split())
    if not (N | M | P | A | B):
        break
    A, B = A - 1, B - 1
    T = [int(x) for x in input().split()]
    dp = [[float("inf")] * M for _ in range(1 << N)]
    dp[0][A] = 0
    edges = []
    for _ in range(P):
        s, t, c = map(int, input().split())
        s, t = s - 1, t - 1
        edges.append((s, t, c))
        edges.append((t, s, c))
    ans = float('inf')
    for state in range(1 << N):
        for s, t, c in edges:
            for k in range(N):
                if not (state >> k & 1):
                    next_s = state | (1 << k)
                    dp[next_s][t] = min(dp[next_s][t], dp[state][s] + c / T[k])
            if t == B and dp[state][t] < ans:
                ans = dp[state][t]
    print("Impossible" if ans == float("inf") else "{:.020f}".format(ans))

Measured memory_bytes: 8044
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#include <functional>
#include<map>
#include<stack>
#define T long long
const double PI=3.14159265358979323846;
 
int main(){
	int n,m;
	std::cin >>n>>m;
	std::vector<int> mark(n+1);
	std::vector<std::vector<int>> G(n+1);
	for(int i=0;i<m;i++){
		int a,b;
		std::cin >> a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	std::queue<int> que;
	que.push(1);
	for(int i=0;i<=n;i++){
		mark[i]=0;
	}
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		
		for (int nv : G[v]) {
			if (mark[nv] != 0) continue;
			mark[nv] = v;
			que.push(nv);
		}
	}
	for(int i=2;i<=n;i++){
		if(mark[i]==0){
			std::cout << "No"<<std::endl;
			return 0;
		}
	}
	std::cout << "Yes"<<std::endl;
	for(int i=2;i<=n;i++){
		std::cout << mark[i]<<std::endl;
	}
}

Measured memory_bytes: 10172
#include <bits/stdc++.h>
using namespace std;
const int MN = 100012;
int n,k,a[MN],dp[MN];
int main (void) {
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if (i-a[j] < 0) continue;
            if (dp[i-a[j]] == 0) dp[i] = 1;
        }
    }
    if (dp[k]) cout << "First\n";
    else cout << "Second\n";
    return 0;
}



Measured memory_bytes: 640
import sys
s = list(input())
if s[0] == 'A':
  del s[0]
  if s[1:-1].count('C') == 1:
      s.remove('C')
      for i in range(len(s)):
          if s[i].isupper():
              print('WA')
              sys.exit()
      print('AC')
  else:
      print('WA')
else:
    print('WA')


Measured memory_bytes: 2940
l = []
while True:
  h,w = map(int,input().split())
  if (h,w) == (0,0):
    break
  else:
    l.append([h,w])
for i in l:
  print('#'*i[1])
  for j in range(i[0]-2):
    print('#'+'.'*(i[1]-2)+'#')
  print('#'*i[1])
  print()

Measured memory_bytes: 7612
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]-=i;
	}
	sort(a+1,a+n+1);
	int p=a[(n+1)/2];
	unsigned long long ans=0;
	for(int i=1;i<=n;i++)
		ans+=a[i]-p>0? a[i]-p:p-a[i];
	cout<<ans;
	return 0;
}

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

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  for(int i = a; i <= b; i++){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

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

void solve(){
    int n; string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++){
        cout << (char)((s[i] - 'A' + n)%26 + (int)('A'));
    }
    cout << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;


struct UnionFind{
private:
    vector<int> par;
    vector<int> rank;
    vector<int> sz;

public:
    //n要素で親を初期化、par[x]はxの親を表す
    UnionFind(int n){
        par.resize(n,0);
        rank.resize(n,0);
        sz.resize(n,1);
        rep(i,n){
            par[i] = i;
        }
    }

    //木の根を求める
    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //xとyの属する集合を併合
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        else{
            par[y] = x;
            sz[x] += sz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //xとyが同じ集合に属するか否か
    bool same(int x, int y){
        return root(x) == root(y);
    }

    //xが属する集合のサイズを返す
    int size(int x){
        return sz[root(x)];
    }

    // 集合の数を返す
    int num_of_s(){
        set<int> st;
        rep(i,par.size()) st.insert(root(i));
        return st.size();
    }
};

int main(){
    ll n,m,k; cin >> n >> m >> k;
    UnionFind uf(n);
    vl graph(n,0);
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--;b--;
        uf.unite(a, b);
        graph[a]++;
        graph[b]++;
    }
    vector<ll> block(n,0);
    rep(i,k){
        ll a,b; cin >> a >> b;
        a--;b--;
        if(uf.same(a,b)){
            block[a]++;
            block[b]++;
        }
    }

    rep(i,n){
        cout << uf.size(i) - block[i] - graph[i] - 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3968
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      
      var flag = true;
      var count = 0;
      while(flag){
        flag = false;
        for(int i = N-1; i > 0;i--){
          if(A[i] < A[i-1]){
            var tmp = A[i];
            A[i] = A[i-1];
            A[i-1] = tmp;
            flag = true;
            count++;
          }
        }
      }
      Console.WriteLine(String.Join(" ",A));
      Console.WriteLine(count);
    }
}


Measured memory_bytes: 20352
#include <stdio.h>
   
#define PutChar(c) ; *p = (char)(c); ++p;
   
#define MAX_N (2000001)
#define MAX_Ai (10001)
#define STR_SIZE (10000010)
   
int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int len);
   
int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;
   
int main(void) {
    register int i;
    int n;
   
    fread(str, 1, STR_SIZE, stdin);
       
    n = getNum();
    for (i = 1; i <= n; ++i) {
        A[i] = getNum();
    }
       
    CountingSort(A, B, MAX_Ai, n);
       
    p = str;
    --n;
    for (i = 1; i <= n; ++i) {
        putNum(B[i]);
        PutChar(' ');
    }
    putNum(B[i]);
    PutChar('\0');
       
    puts(str);
       
    return 0;
}
   
int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    }
    ++p;
    return n;
}
   
void putNum(int n) {
    int d;
    if (n < 10) {
        PutChar('0' + n);
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    PutChar('0' + (n - (d * 10)));
}
   
void CountingSort(int A[], int B[], int k, int len) {
    int C[MAX_Ai] = { 0 };
    int i, j;
    for (j = 1; j <= len; ++j) {
        ++C[A[j]];
    }
    for (i = 1; i <= k; ++i) {
        C[i] += C[i - 1];
    }
    for (j = len; j > 0; --j) {
        B[C[A[j]]] = A[j];
        --C[A[j]];
    }
}

Measured memory_bytes: 26700
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

s = list(input())
co = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
            co += 1
        else:
            print("No")
            exit()
    else:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
            co += 1
        else:
            print("No")
            exit()
print("Yes")


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

ll calc(ll x, vector<ll> v, ll l){
	int low=-1,high=v.size();
	while(low<high){
		int mid=(low+high)/2;
		if(x*mid<l)low=mid;
		else high=mid;
	}
	return low+1;
}

int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];

	sort(all(a));

	vector<ll> minus, zero, plus;
	rep(i,n){
		if(a[i]<0)minus.push_back(a[i]);
		else if(a[i]==0)zero.push_back(a[i]);
		else plus.push_back(a[i]);
	}

	ll ms=minus.size(), ps=plus.size(), zs=zero.size();

	ll total_minus = ms*ps;
	ll total_zero = (ms+ps)*zs + zs*(zs-1)/2;


	if(total_minus<k&&k<=total_minus+total_zero){
		cout<<0<<endl;
		return 0;
	}
	if(k<=total_minus){
		ll low=-1e18-1,high=-1;
		while(low+1<high){
			ll L=(low+high)/2;
			ll cnt=0;
			sort(all(plus));
			reverse(all(plus));
			for(auto x:minus){
				ll left=-1,right=plus.size();
				while(left+1<right){
					ll mid=(left+right)/2;
					if(x*plus[mid]<=L)left=mid;
					else right=mid;
				}
				cnt += left+1;
			}
			// reverse(all(plus));
			if(cnt<k)low=L;
			else high=L;
		}
		cout<<low+1<<endl;
	}else{
		k -= total_minus+total_zero;
		ll low=-1,high=1e18;

		rep(i,minus.size())minus[i]*=-1;
		sort(all(minus));
		sort(all(plus));
		while(low+1<high){
			ll L=(low+high)/2;
			ll cnt=0;
			rep(i,plus.size()){
				ll left = upper_bound(all(plus), L/plus[i]) - plus.begin();
				cnt += left;
				if(i<left)cnt--;
			}
			rep(i,minus.size()){
				ll left = upper_bound(all(minus), L/minus[i]) - minus.begin();
				cnt += left;
				if(i<left) cnt--;
			}
			cnt /= 2;
			if(cnt<k)low=L;
			else high=L;
		}
		cout<<low+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 4468
# Swap 0 or 1 Swap

N = int(input())
p = list(map(int, input().split()))
pn = sorted(p)

count = 0
for i in range(N):
    if p[i] == pn[i]:
        pass
    else:
        count = count + 1

if count == 2 or count == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.next());

        int count = 0;
        for (int i = 0; i < n; i++) {
            int p = Integer.parseInt(scanner.next());
            if (isPrime(p)) {
                count++;
            }
        }

        System.out.println(count);
    }

    private static boolean isPrime(int p) {
        if (p == 1) {
            return false;
        }

        if (p == 2) {
            return true;
        }

        if (p % 2 == 0) {
            return false;
        }

        for (int i = 3; i <= Math.ceil(Math.sqrt(p)); i += 2) {
            if (p % i == 0) {
                return false;
            }
        }

        return true;
    }
}

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

int main() {

    int n;
    cin >> n;
    vector<double> a(n);
    double out = 0;
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
        a.at(i) = pow(a.at(i), -1);
        out += a.at(i);
    }

    cout << pow(out, -1) <<endl;



}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,ans,a;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		while(a%2==0){
			ans++;
			a=a/2;
		}
	}
	cout<<ans;
	return 0;
} 

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

int main() {
  ll n;
  cin >> n;
  multiset<ll> s;
  for(ll i=0;i<(1<<n);i++) {
    ll tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  auto f=s.end();
  f--;
  vec al,cur;
  al.push_back(*f);
  s.erase(f);
  for(ll i=0;i<n;i++) {
    for(ll j:al) {
      auto k=s.lower_bound(j);
      if(k==s.begin()) {
        cout << "No" << endl;
        return 0;
      }
      k--;
      cur.push_back(*k);
      s.erase(k);
    }
    for(auto j:cur) {
      al.push_back(j);
    }
    cur.clear();
  }
  cout << "Yes" << endl;
}

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

struct UnionFind {
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) par[i] = i;
  }

  int find(int x) {
    return x == par[x] ? x : par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] > sizes[y]) swap(x, y);

    par[x] = y;
    sizes[y] += sizes[x];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};

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

    int N, M; cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    UnionFind uf(N);
    vector<long long> ans(M);
    ans[M-1] = 1LL * N * (N-1) / 2;
    for (int i = M-1; i > 0; i--) {
        ans[i-1] = ans[i];
        if (!uf.same(A[i], B[i])) {
            ans[i-1] -= 1LL * uf.size(A[i]) * uf.size(B[i]);
            uf.unite(A[i], B[i]);
        }
    }
    for (int i = 0; i < M; i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
 int n,k;
 k = 0;
 ll ans;
 ans =0;
 cin>>n;
 vector<int> vec(n);
 fr(i,n){
     cin>>vec[i];
     k += vec[i];
 }
 fr(i,n){
     ans += (k-vec[i])*vec[i];
 }
 cout<<ans/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ld pi = (acos(-1));
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; }




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n; cin >> n;
  vector<int> h(n);
  rep(i,0,n) cin >> h[i];
  vector<int> dp(n);
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  rep(i,2,n){
    dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    Int k, x;
    cin >> k >> x;
    vector<Int> v;

    Int cur = x-(k-1);
    while(cur <= x+(k-1)){
        if(cur < -1000000){
            cur++;
            continue;
        }
        if(cur > 1000000){
            break;
        }
        v.push_back(cur);
        cur++;
    }
    for(Int i=0; i<v.size(); i++){
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		if(s.length()%2!=0) {
			System.out.println("No");
			System.exit(0);
		}
		for(int i=0;i<=s.length()-2;i+=2) {
			if(!s.substring(i, i+2).equals("hi")) {
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 21844
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
//~ #include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, C; cin >> n >> C;
	vector<vector<pair<int,int>>> rangesTmp(C, vector<pair<int,int>>());
	forn(i,n) {
		int s, t, c; cin >> s >> t >> c; c--;
		s *= 2, t *= 2;
		rangesTmp[c].push_back({s,t});
	}
	forn(i,C) sort(all(rangesTmp[i]));

	vector<pair<int,int>> ranges; ranges.reserve(n);
	forn(i,C) {
		auto cur = rangesTmp[i];
		forn(j, cur.size()) {
			if (j + 1 < (int)cur.size() && cur[j].S == cur[j + 1].F) {
				cur[j + 1].F = cur[j].F;
			} else {
				ranges.push_back({cur[j].F - 1, cur[j].S});
			}
		}
	}
	sort(all(ranges));
	
	priority_queue<int, vector<int>, greater<int>> available; available.push(-5);
	forn(i,ranges.size()) {
		if (available.top() > ranges[i].F) available.push(ranges[i].F);
		available.pop();
		available.push(ranges[i].S);
	}
	cout << available.size() << endl;
	
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,j,i,k,a=0,p; map<string,int>mp; map<int,int>sm; string str;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>str; cin>>k;
        mp[str]=i; a=a+k; sm[i]=a;
    }

    cin>>str; p=mp[str];  cout<<a-sm[p]<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin >> s;
    int cnt=0,ans=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            cnt++;
            ans = max(ans,cnt);
        }
        else
        {
            cnt = 0;
        }
        
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3616
var
	M,L,R,ans,ll,rr:int64;
    k,i,x,y,xl,yl,limx,limy,xx,yy,id,ie:Longint;
    dp:array[1..60,1..2,1..2]of int64;
begin
	read(L,R);
    M:=1000000007;
    ll:=1;
    rr:=2;
    for k:=1 to 60 do begin
    	if(rr<=L)or(R<ll)then begin
        	ll:=ll*2;
            rr:=rr*2;
        	continue;
        end;
        for i:=1 to k do begin
        	dp[i,1,1]:=0;
        	dp[i,1,2]:=0;
        	dp[i,2,1]:=0;
        	dp[i,2,2]:=0;
        end;
        if L<=ll then if rr-1<=R then dp[1,2,2]:=1 else dp[1,2,1]:=1 else if rr-1<=R then dp[1,1,2]:=1 else dp[1,1,1]:=1;
        for i:=1 to k-1 do begin
        	x:=(L>>(k-1-i))mod 2;
            y:=(R>>(k-1-i))mod 2;
            for xl:=1 to 2 do begin
            	if xl=1 then limx:=x else limx:=0;
                for yl:=1 to 2 do begin
                	if dp[i,xl,yl]=0 then continue;
                	if yl=1 then limy:=y else limy:=1;
                    for yy:=0 to limy do begin
                    	for xx:=limx to yy do begin
                        	if(xl=2)or(xx>limx)then id:=2 else id:=1;
                            if(yl=2)or(yy<limy)then ie:=2 else ie:=1;
                            dp[i+1,id,ie]:=(dp[i+1,id,ie]+dp[i,xl,yl])mod M;
                        end;
                    end;
                end;
            end;
        end;
        ll:=ll*2;
        rr:=rr*2;
        ans:=(ans+dp[k,1,1]+dp[k,1,2]+dp[k,2,1]+dp[k,2,2])mod M;
    end;
    writeln(ans);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long
int dp[500][500];
int ar[500],n;

int rec(int i,int j)
{
    if(i==j)
        return ar[i];
    
    if(i>j)
        return 0;
    
    if(dp[i][j]!=LONG_MAX)
        return dp[i][j];
        

    for(int k=i;k<j;++k)
    {
        int x,y,z=rec(i,k)+rec(k+1,j);
        if(i==k)
        x=0;
        else
        x=dp[k][i];
        if(k+1==j)
        y=0;
        else
        y=dp[j][k+1];
        
        if(dp[j][i]>x+y+z)
        dp[j][i]=x+y+z,dp[i][j]=z;
    }
    
    return dp[i][j];
}

signed main()
{
    cin>>n;
    for(int i=0;i<n;++i)
    cin>>ar[i];
    for(int i=0;i<n;++i)
    for(int j=0;j<n;++j)
    dp[i][j]=LONG_MAX;
    for(int i=0;i<n;++i)
    dp[i][i]=0;
    rec(0,n-1);
    cout<<dp[n-1][0];
    
}

Measured memory_bytes: 1792
/**
 * @File   : atcoder.cpp
 * @Author : pasnger
 * @Date   : 30/8/2020, 4:52:41 pm
 */

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

#define INF 8e18
#define int long long
#define f(i, a, b) for (int i = (a); i < (b); (i)++)
#define fe(i, a, b) for (int i = (a); i <= (b); (i)++)
#define rf(i, a, b) for (int i = (a); i > (b); (i)--)
#define rfe(i, a, b) for (int i = (a); i >= (b); (i)--)
#define ff(ele, cont) for (auto(ele) : (cont))
#define pb push_back

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef set<int> si;
typedef multiset<int> msi;

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
void DBG(){
  cerr << "]\n";
}
template <typename T, typename... Args>
void DBG(T first, Args... args){
  cerr << first;
  if (sizeof...(args))
    cerr << ", ";
  DBG(args...);
}

/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////

void solve(){
  string s;
  cin>>s;
  if(s[s.length()-1]!='s'){
    s += 's';
  }else{
    s += "es";
  }
  cout<<s<<"\n";
}

int32_t main() {
  #ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    freopen("in.txt", "r", stdin);
  // freopen("in2.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    for (int tt = 1; tt <= t; tt++)
    {
      //cout << "Case #"<<tt<<": ";
      solve();
    }
  #ifndef ONLINE_JUDGE
    cerr << "\nRun Time -> " << (double)(clock() - tStart) / CLOCKS_PER_SEC << " sec\n";
  #endif
}

Measured memory_bytes: 3648
///******* In the name of Allah *******///

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

int main()
{
    long int a,b,c,d,e,f,g,t,i,j,k,l1,l2,m,n,r,sum,ans_1,ans_2,ans_3,cnt,Max,Min,flag,swi1,swi2;
    double aa,bb,cc,dd,ee;
    char aaa[1013],bbb[1013],ccc[1013];
    cin>>n>>m;
    for(i=1; i<=n; i++)
    {
        aaa[i] = m + 48;
    }
    for(i=1; i<=m; i++)
    {
        bbb[i] = n + 48;
    }
    if(n<m)
    {
        for(i=1; i<=m; i++)
        {
            cout<<bbb[i];
        }
    }
    else if(m<n)
    {
        for(i=1; i<=n; i++)
        {
            cout<<aaa[i];
        }
    }
    else if(m==n)
    {
        for(i=1; i<=n; i++)
        {
            cout<<aaa[i];
        }
    }

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      s: Bytes,
   }
   let mut ans = 0;
   for i in 1..n {
      let mut c = 0;
      let mut now = 0;
      for j in 0..n - i {
         let k = j + i;
         if s[j] == s[k] {
            now += 1;
         } else {
            now = 0;
         }
         c = max(c, now);
      }

      c = min(i, c);
      ans = max(ans, c);
   }
   println!("{}", ans);
}


Measured memory_bytes: 2208
N,M =  list(map(int, input().split()))
H =  list(map(int, input().split()))
A = []
for i in range(M):
    a =  list(map(int, input().split()))
    A.append(a)



ans = [1] * N

for l in range(M):
    if H[A[l][0]-1] > H[A[l][1]-1]:
        ans[A[l][1]-1] = 0
    elif H[A[l][0]-1] == H[A[l][1]-1]:
        ans[A[l][1]-1] = 0
        ans[A[l][0]-1] = 0
    else:
         ans[A[l][0]-1] = 0

print(sum(ans))


Measured memory_bytes: 93360
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int qtd = 0, pairs = 0, odds = 0, res = 0;

    scanf("%d", &qtd);

    if (qtd % 2 == 0) {
        pairs = qtd/2;
        res = pairs * pairs;
    } else {
        pairs = (qtd-1)/2;
        res = pairs*(pairs+1);
    }

    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int S, h, m, s;
    scanf("%d", &S);
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 60;
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}

Measured memory_bytes: 592
(let ((c (make-array '(3 3) :element-type 'integer
                            :adjustable t))
      diff1
      diff2
      (ans "Yes"))
  (dotimes (i 3)
    (dotimes (j 3)
      (setf (aref c i j) (read))))
  (setf diff1 (- (aref c 2 1) (aref c 2 0)))
  (setf diff2 (- (aref c 2 2) (aref c 2 1)))
  (dotimes (i 2)
    (if (or (not (equal diff1 (- (aref c i 1) (aref c i 0)))) (not (equal diff2 (- (aref c i 2) (aref c i 1))))) (setf ans "No")))
  (setf diff1 (- (aref c 1 2) (aref c 0 2)))
  (setf diff2 (- (aref c 2 2) (aref c 1 2)))
  (dotimes (i 2)
    (if (or (not (equal diff1 (- (aref c 1 i) (aref c 0 i)))) (not (equal diff2 (- (aref c 2 i) (aref c 1 i))))) (setf ans "No")))
  (format t "~A~%" ans))


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

int main(){
    int memo[100001] = {};
    for(int i = 2; i < 100001; i++){
        int cnt = 0;
        for(int j = 2; j*j <= i; j++){
            if(i%j) continue;
            cnt++;
        }
        if(cnt > 1) memo[i]++;
    }
    for(int i = 2; i < 100001; i++) memo[i] += memo[i-1];

    int q;
    cin >> q;
    while(q-- > 0){
        int n;  cin >> n;
        cout << memo[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 3492
from fractions import gcd
k = int(input())
check = [[1 for _ in range(k+3)] for i in range(k+3)]
for i in range(1, k+2):
    for j in range(i, k+2):
        check[i][j] = gcd(i, j)

result = 0
for s in range(1, k+1):
    for t in range(1, k+1):
        n, m = sorted([s, t])
        x = check[n][m]
        for u in range(1, k+1): 
            y, z = sorted([x, u])
            result += check[y][z]
print(result)

Measured memory_bytes: 76128
package main

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

func main() {
	N := ReadInt()
	c := ReadString()

	var cw, cr int
	for i := 0; i < N; i++ {
		if c[i] == 'R' {
			cr++
		} else {
			cw++
		}
	}

	var w, r int
	for i := 0; i < N; i++ {
		if c[i] == 'W' && i < cr {
			w++
		}
		if c[i] == 'R' && i >= cr {
			r++
		}
	}
	fmt.Println(Max(w, r))
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 3204
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, M = map(int, readline().split())
    *A, = map(int, readline().split())
    *P, = map(int, readline().split())
    def lcm(m, n):
        m0 = m; n0 = n
        while n:
            m, n = n, m % n
        return m0//m*n0
    N2 = 1 << N
    Q = [1]*N2
    L = [1]*N2
    C = [0]*N2
    for i in range(N):
        L[1 << i] = A[i]
        Q[1 << i] = P[i] / 100
    ans = 0
    for state in range(1, N2):
        b = state & -state
        L[state] = lcm(L[state ^ b], L[b])
        C[state] = C[state ^ b] + 1
        Q[state] = Q[state ^ b] * Q[b]
        if C[state] % 2:
            ans += Q[state] * (M // L[state])
        else:
            ans -= Q[state] * (M // L[state])
    write("%.16f\n" % ans)
solve()


Measured memory_bytes: 164140
# ABC134
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = list(map(int, [input() for _ in range(n)]))
    SA = sorted(A)
    ma, ma2 = SA[-1], SA[-2]
    ans = [ma if i != ma else ma2 for i in A]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 23728
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	string s; cin >> s;

	if (s == "ABC") {
		cout << "ARC" << endl;
	}else {
		cout << "ABC" << endl;
	}

	return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n+1, 1e9);
    set<int> s;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        if (v[tmp] == 1e9) v[tmp] = 1;
        else v[tmp]++;
        s.insert(tmp);
    }
    sort(v.begin(), v.end());
    if (s.size() <= k) cout << 0 << endl;
    else {
        ll res = 0;
        for (int i = 0; i < s.size()-k; ++i) {
            res += v[i];
        }
        cout << res << endl;
    }
    return 0;
}


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

//BEGIN CUT HERE
struct UnionFind{
  int num;//連結成分の数
  vector<int> r,p;//そのグループのサイズ,自分の親っぽいやつ
  UnionFind(){}
  UnionFind(int n):num(n),r(n,1),p(n,0){iota(p.begin(),p.end(),0);}

  int find(int x){//どのグループに所属するか
    return (x==p[x]?x:p[x]=find(p[x]));//xがグループの名前と一致するまでxを親にする
  }

  bool same(int x,int y){//同じグループかどうか
    return find(x)==find(y);
  }

  void unite(int x,int y){//xとyを同じグループにする
    x=find(x);y=find(y);//xとyのグループの名前をどっちかが変える
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);//サイズが大きい方をxとする
    r[x]+=r[y];//yの親をxにする（今までyだったグループ名がxになる）
    p[y]=x;
    num--;
  }

  int size(int x){//グループの大きさ
    return r[find(x)];
  }

  int count() const{//グループの数
    return num;
  }
};
  //END CUT HERE
typedef pair<int,int> P;
const int INF=1e9;

signed main(){
  int n;cin>>n;
  vector<P> v(n);
  vector<int> x(n),y(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    v[i]=P(x[i],y[i]);
  }
  UnionFind uf(n);
  map<P,int> ansm;
  sort(v.begin(),v.end());
  set<P> s;s.insert(P(INF,INF));
  for(int i=n-1;i>=0;i--){
    auto it=s.lower_bound(P(v[i].second,0));
    if(it->first==INF){
      s.insert(P(v[i].second,i));
      continue;
    }
    while(it->first<INF){
      uf.unite(i,it->second);
      it++;
    }
  }
  for(int i=0;i<n;i++)ansm[P(v[i].first,v[i].second)]=uf.size(i);
  for(int i=0;i<n;i++)cout<<ansm[P(x[i],y[i])]<<endl;
}


Measured memory_bytes: 21128