akhauriyash/Code-Regression huggingface dataset:
package main

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

/*-----------Main-----------*/

func main() {
	x := readI()
	if x >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1780
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define LLint long long int
#define Lint long int
#define Ldouble long double

// class UnionFind;

// bool sortBySec(const pair<int, int>& a, const pair<int, int>& b);
// int modExp(int x, int n, int m);
// int mmi(int x, int m);

int n;

void solve() {
    cin >> n;
    set<string> seen;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (seen.count(s) == 1) {
        } else {
            seen.insert(s);
            cnt++;
        }
    }
    cout << cnt;
}

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

    solve();

    return EXIT_SUCCESS;
}

// Helpers.
/*
bool sortBySec(const pair<int, int>& a, const pair<int, int>& b) {
    return (a.second < b.second);
}
*/
// Modular arithmetic.
/*
int modExp(const int x, const int n, const int m) {
    if (n == 0) {
        return 1;
    }
    LLint u = modExp(x, n / 2, m);
    return n % 2 == 0 ? (u * u) % m : (((u * u) % m) * x) % m;
}
*/
/*
int mmi(const int x, const int m) { return modExp(x, m - 2, m); }
*/
// Union find data structure.
/*
class UnionFind {
   public:
    vector<int> link;
    vector<int> size;

    UnionFind(int n) {
        link = vector<int>(n);
        size = vector<int>(n);
        for (int i = 0; i < n; i++) {
            link[i] = i;
            size[i] = 1;
        }
    }

    int find(int x) {
        while (x != link[x]) {
            x = link[x];
        }
        return x;
    }

    bool same(int a, int b) { return find(a) == find(b); }

    void unite(int a, int b) {
        a = find(a);
        b = find(b);
        if (size[a] < size[b]) {
            swap(a, b);
        }
        size[a] += size[b];
        link[b] = a;
    }
};
*/


Measured memory_bytes: 19228
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        //変数定義
        int h,m;
        String str,str1,tmp;
        StringBuffer sb;

        while(true){
            //カードの山文字列受取
            str = sc.nextLine();

            //終了条件定義
            if(str.equals("-")) break;
            
            //シャッフル回数受取
            str1 = sc.nextLine();
            m = Integer.parseInt(str1);

            //Stringクラス→StringBufferクラス
            sb = new StringBuffer(str);

            for(int i = 0;i < m;i++){
                //h受取
                str1 = sc.nextLine();
                h = Integer.parseInt(str1);
                //文字列分割
                tmp = sb.substring(0,h);
                //末尾に文字列追加
                sb.append(tmp);
                //頭の文字列削除
                sb.delete(0,h);
            }
            System.out.println(sb);
        }
    }
}


Measured memory_bytes: 26448
N,K=map(int, input().split())

h=[]

for _ in range(N):
    h.append(int(input()))

h.sort()

ans = float("inf")

for i in range(N-K+1):
    tmp = h[i+K-1] - h[i]
    if tmp < ans:
        ans = tmp

print(ans)

Measured memory_bytes: 7384
#include <iostream>
#include <queue>
using namespace std;
int w, h, n;
char map[1024][1024];
// 各点到当前工厂的距?
int d[1024][1024];
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};

int factory[16][2];
typedef pair<int, int> P;



//************************************
// Method:    bfs
// FullName:  bfs
// Access:    public
// Returns:   int
// Qualifier:
// Parameter: const int & sx 起点x
// Parameter: const int & sy 起点y
// Parameter: const int & gx ?点x
// Parameter: const int & gy ?点y
//************************************
int bfs(const int& sx, const int& sy, const int& gx, const int& gy)
{
	//memset(d, -1, sizeof(d));
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			d[j][i] = -1;
		}
	}
	queue<P> que;
	que.push(P(sx, sy));
	d[sx][sy] = 0;
	while (que.size())
	{
		const P p = que.front(); que.pop();
		// 如果是?点就?束
		if (p.first == gx && p.second == gy)
		{
			break;
		}

		// 四方向漫游
		for (int i = 0; i < 4; ++i)
		{
			int nx = p.first + direction[i][0];
			int ny = p.second + direction[i][1];
			// 是否可以移?，并且?点没有???
			if (0 <= nx && nx < w && 0 <= ny && ny < h && map[nx][ny] != 'X' && d[nx][ny] == -1)
			{
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}

	return d[gx][gy];
}

///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{

	cin >> h >> w >> n;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> map[j][i];
		}
	}

	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (map[j][i] == 'S')
			{
				factory[0][0] = j;
				factory[0][1] = i;
				map[j][i] = '.';
			}
			else if (isdigit(map[j][i]))
			{
				int index = map[j][i] - '0';
				factory[index][0] = j;
				factory[index][1] = i;
			}
		}
	}

	int step = 0;
	for (int i = 0; i < n; ++i)
	{
		// 按?序吃遍中?
		step += bfs(factory[i][0], factory[i][1], factory[i + 1][0], factory[i + 1][1]);
	}

	cout << step << endl;

	return 0;
}
///////////////////////////End Sub//////////////////////////////////

Measured memory_bytes: 8136
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int N = sc.nextInt();
		String[] in1 = new String[N];
		String[] in2 = new String[N];
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			in1[i] = s;
			in2[i] = s;
		}

		// BubbleSort
		for (int i = 1; i < N; i++) {
			for (int j = N - 1; j >= i; j--) {
				if (in1[j].charAt(1) < in1[j - 1].charAt(1)) {
					String tmp = in1[j];
					in1[j] = in1[j - 1];
					in1[j - 1] = tmp;
				}
			}
		}

		// SelectionSort
		for (int i = 0; i < N; i++) {
			int min = i;
			for (int j = i + 1; j < N; j++) {
				if (in2[min].charAt(1) > in2[j].charAt(1)) {
					min = j;
				}
			}
			String tmp = in2[i];
			in2[i] = in2[min];
			in2[min] = tmp;
		}

		print(in1);
		System.out.println("Stable");
		print(in2);
		System.out.println(match(in1, in2) ? "Stable" : "Not stable");
	}

	void print(String[] s) {
		for (int i = 0; i < s.length; i++) {
			System.out.print((i == 0 ? "" : " ") + s[i]);
		}
		System.out.println();
	}

	boolean match(String[] s1, String[] s2) {
		for (int i = 0; i < s1.length; i++) {
			if (!s1[i].equals(s2[i])) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17328
from collections import deque
INF=10**18
h,w=map(int,input().split())
e=[input() for _ in range(h)]
cnt=0
for i in range(h):
  for j in range(w):
    if e[i][j]=='.':cnt+=1
dx=[-1,0,1,0]
dy=[0,-1,0,1]
sx,sy=0,0
gx,gy=h-1,w-1
q=deque([(sx,sy)])
d=[[INF]*w for _ in range(h)]
d[sx][sy]=1
while q:
  x,y=q.popleft()
  for i in range(4):
    nx=x+dx[i]
    ny=y+dy[i]
    if 0<=nx<h and 0<=ny<w and e[nx][ny]=='.' and d[nx][ny]==INF:
      q.append((nx,ny))
      d[nx][ny]=d[x][y]+1
if d[gx][gy]==INF:print(-1)
else:print(cnt-d[gx][gy])

Measured memory_bytes: 74132
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const ll INF = 1LL << 50;
const double EPS = 1E-10;

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

int nums[200];

int main(){
	int n;
	while(cin >> n){
		rep(i, n) cin >> nums[i];
		sort(nums, nums + n);
		int res = 0;
		int t = 0;
		rep(i, n){
			res += nums[i] + t;
			t += nums[i];
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

long long int comb(int n, int r)
{
    int i;
    long long int res=1;
    for(i=1;i<=r;i++){
        res=res*(n-i+1)/i;
    }
    return res;
}

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

    int N,P,odd=0,even=0;
    cin>>N>>P;
    for(int i = 0; i < N; i++){
        int t;
        cin>>t;
        if(t%2==0) even++;
        else odd++;
    }
    vector< vector<long long int> > memo;
    int m = max(even, odd);
    memo.resize(m+1);
    for(int i = 0; i <= m; i++){
        memo[i].resize(m+1);
        for(int j = 0; j <= m; j++)
            memo[i][j] = -1;
    }
    long long int ceven = 0, codd = 0, tmp;
    for(int i = 0; i <= even; i++){ //偶数の組み合わせ
        if(even>=i){
            if(memo[even][i] == -1){
                memo[even][i] = comb(even, i);
                memo[even][even-i] = memo[even][i];
            }
            ceven += memo[even][i];
        }
    }
    if(P==0){
        for(int i = 0; i <= odd; i++){
            int r = i*2;
            if(odd>=r){
                if(memo[odd][r] == -1){
                    memo[odd][r] = comb(odd, r);
                    memo[odd][odd-r] = memo[odd][r];
                }
                codd += memo[odd][r];
            }
        }
    }else{
        for(int i = 0; i <= odd; i++){
            int r = i*2+1;
            if(odd>=r){
                if(memo[odd][r] == -1){
                    memo[odd][r] = comb(odd, r);
                    memo[odd][odd-r] = memo[odd][r];
                }
                codd += memo[odd][r];
            }
        }
    }
    cout<<codd*ceven<<endl;
    return 0;
}

Measured memory_bytes: 256
alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)

n = int(input())
S = list(input())

for i in range(len(S)):
    a = alpha2num(S[i])
    a += n
    a %= 26
    if (a==0):
        a=26
    S[i] = num2alpha(a)

print(''.join(S))



Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  char c; cin >> c;
  cout << (char)(c + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())

"""
if A == 1 and B == 2 or A == 2 and B == 1:
    print(3)
elif A == 1 and B == 3 or A == 3 and B == 1:
    print(2)
elif A == 2 and B == 3 or A == 3 and B == 2:
    print(1)
"""

"""
if A > B:
    A, B = B, A

if A == 1 and B == 2:
    print(3)
if A == 2 and B == 3:
    print(1)
if A == 1 and B == 3:
    print(2)
"""

"""
for i in range(1,4):
    if A != i and B != i:
        print(i)
"""
print(6 - (A + B))


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int a[9][9];

int main()
{
    int h, w, k;
    cin >> h >> w >> k;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c;
            cin >> c;

            if(c == '#')
                a[i][j] = 1;
        }
    }

    int ans = 0;
    for(int r = 0; r < (1 << h); r++){
        for(int c = 0; c < (1 << w); c++){

            int cnt = 0;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(!a[i][j])
                        continue;

                    if(((r >> i) & 1) || ((c >> j) & 1))
                        continue;

                    cnt++;
                }
            }
            if(cnt == k)
                ans++;
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3580
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    n = int(input())
    divs = sorted(divisor(n))
    ans = 0
    for div in divs[1:]:
        if n % div == 0 and len(factorization(div)) == 1:
            n /= div
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9560
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,a[200005];
signed main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=n-1;i>=0;i-=2)cout<<a[i]<<" ";
	for(int i=n%2;i<n;i+=2)cout<<a[i]<<" ";
	cout<<endl;
}


Measured memory_bytes: 3712
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int N;
	vector<int> A(10 ^ 9);

	cin >> N;

	A.resize(N);
	fill(A.begin(), A.end(),0);
	int count = 0;
	FOR(i, 0, N) {
		cin >> A[i];
		if (!(A[i] % 2 == 0)) { cout << count << endl; return 0; }
	}
	while (true) {
		FOR(i, 0, N) {
			A[i] /= 2;
		}
		count++;
		FOR(i, 0, N) {
			if (!(A[i] % 2 == 0)) { cout << count << endl; return 0; }
		}
	}
}


Measured memory_bytes: 256
n=input()
l=[0]+list(map(int,input().split()))+[0]
ans=0
pre=0
for i in l:ans+=abs(pre-i);pre=i
for i in range(1,int(n)+1):
  dif=-abs(l[i]-l[i-1])-abs(l[i]-l[i+1])+abs(l[i-1]-l[i+1])
  if l[i]in(l[i-1],l[i+1]):print(ans)
  elif l[i]<l[i-1]:
    print(ans if l[i+1]<l[i] else ans+dif)
  else:print(ans if l[i+1]>l[i] else ans+dif)

Measured memory_bytes: 20620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define dd double
#define pb push_back
#define mp make_pair
#define f first
#define s second
int main()
{
	int k,i;
	cin>>k;
	for(i=0;i<k;i++)
    {
        printf("ACL");
    }
}


Measured memory_bytes: 3768
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    readln.split.to!(int[]).sort().pipe!"a[0]+a[1]==a[2]".pipe!(a => a?"Yes":"No").writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500;
int dist[maxn][maxn];
char g[maxn][maxn];
int main(){
  int n, m; cin >> n >> m;
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> g[i][j];
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) dist[i][j] = -1;
  int tot = 0;
  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) tot += g[i][j] == '.';
  dist[0][0] = 0;
  queue<pair<int,int>> q;
  q.push({0,0});
  while(!q.empty()){
    int x, y; tie(x, y) = q.front(); q.pop();
    for(int dx = -1; dx <= 1; dx++) for(int dy = -1; dy <= 1; dy++){
      if(abs(dx) + abs(dy) != 1) continue;
      int nx = x + dx, ny = y + dy;
      if(nx >= 0 && nx < n && ny >= 0 && ny < m && g[nx][ny] == '.' && dist[nx][ny] == -1){
        dist[nx][ny] = dist[x][y] + 1;
        q.push({nx, ny});
      }
    }
  }
  if(dist[n - 1][m - 1] == -1) cout << -1 << endl;
  else cout << tot - dist[n - 1][m - 1] - 1 << endl;
  return 0;
}


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

int main() {
    int n,m;
    cin >> n >> m;
    map<int,int> ma;
    for(int i=0; i<n; i++){
        int k;
        cin >> k;
        for(int j=0; j<k; j++){
            int a;
            cin >> a;
            ma[a]++;
        }
    }
    int ans = 0;
    for(auto x : ma){
        if(x.second == n) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	string S;

	cin >> S;

	int type = 0;

	if(((S[0] - '0') * 10 + (S[1] - '0')) > 0 &&  ((S[0] - '0') * 10 + (S[1] - '0')) <= 12 ) type += 1;
	if(((S[2] - '0') * 10 + (S[3] - '0')) > 0 &&  ((S[2] - '0') * 10 + (S[3] - '0')) <= 12 ) type += 2;

	switch(type){
		case 0:
			cout << "NA" << endl; break;
		case 1:
			cout << "MMYY" << endl; break;
		case 2:
			cout << "YYMM" << endl; break;
		case 3:
			cout << "AMBIGUOUS" << endl; break;
	}

	return 0;
}


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

int main() {
    int n;
    cin>>n;
    set<string> s;
    for(int i=0;i<n;i++){
         string a;
         cin>>a;
         s.insert(a);
    }
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 19256
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;
	
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if((0 <= (x - r)) && ((x + r) <= W) && (0 <= (y - r)) && ((y + r) <= H)){
		printf("Yes\n");
	} else{	
		printf("No\n");
	}
	
	return(0);
}



Measured memory_bytes: 1792
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for a in [1, -1]:
    for b in [1, -1]:
        for c in [1, -1]:
            s = []
            for x, y, z in xyz:
                s.append(a*x + b*y + c*z)
            s.sort(reverse=True)
            ans = max(ans, sum(s[:M]))
print(ans)


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

int main() {
    long long n, a, sum = 0;
    long long maxi = -1000000, mini = 1000000;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a;
        sum += a;
        if(maxi < a) {
            maxi = a;
        }
        if(a < mini) {
            mini = a;
        }
    }
    cout << mini << " " << maxi << " " << sum << endl;
    return 0;
}




Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(){
	int H, W;
	while(cin >> H >> W  && H != 0 && W != 0){
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((j + i) % 2 == 0 ){
					cout << "#";
				}else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define _GLIBCXX_DEBUG
using namespace std;
// 模範解答
int main() {
  int N;
  cin >> N;
  vector<int> dp(N+1);
  dp[0] = 0;
  for (int i=1;i<=N;i++){
        dp[i] = dp[i-1]+1;  // 一円単位で引き出す 場合について
        for (int j=6;i-j >= 0;j*=6) {
        dp[i] = min (dp[i],dp[i-j]+1);
        }
        for (int j = 9; i-j >= 0; j*= 9) {
        dp[i] = min(dp[i],dp[i-j]+1);
        }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int m; cin >> m;
  cout << 24 - m + 24 << endl;
  return;
}

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


Measured memory_bytes: 256
/*
偶数項を正とする場合と
奇数項を正とする場合の２通りを
シミュレーションする.
どちらも試してみて、手数が小さい方を答えとする.
https://jpliterature.hatenablog.com/entry/abc059-c-sequence
*/

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    // 奇数項を正の値にする
    long long minA = 0, sumA = 0;
    
    for (int i = 0; i < n; i++){
        sumA += a[i];
        if (i % 2 == 0){
            if (sumA <= 0){
                minA += abs(sumA) + 1;
                sumA += abs(sumA) + 1;
            }
        }
        else{
            if (sumA >= 0){
                minA += abs(sumA) + 1;
                sumA -= abs(sumA) + 1;
            }
        }
    
    }
   
    // 偶数項を正の値にする
    long long minB = 0, sumB = 0;
    
    for (int i = 0; i < n; i++){
        sumB += a[i];
        if (i % 2 != 0){
            if (sumB <= 0){
                minB += abs(sumB) + 1;
                sumB += abs(sumB) + 1;
            
            }
        }
        else{
            if (sumB >= 0){
                minB += abs(sumB) + 1;
                sumB -= abs(sumB) + 1;
            }
        }
    }
    
    
    long long ans = min(minA, minB);
    cout << ans << endl;
}

Measured memory_bytes: 640
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let mut d = read![[i64]];

    d.sort();
    let mut di = 0;

    let mut abc = 0;
    let mut arc = N;

    let mut count = 0;
    let mut K = 1;

    while K <= 100000 {
        if abc == arc {
            count += 1;
        }

        while di < d.len() && d[di] == K {
            abc += 1;
            arc -= 1;
            di += 1;
        }
        K += 1;
    }

    println!("{}", count)
}


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

typedef long long int lli;

const int N = 1e5 + 5;
lli n, k;

lli a[N];
lli kSet[40][2]; //[i][0] is contribution of ith bit when k's ith bit is set to 0; [i][1] is defined similarly.
lli kFreiSet[40]; //[i] The maximum value when the first i bits are free

lli solve(int pos, lli curr, bool freiheit) {
	if(freiheit) return kFreiSet[pos];

	lli ans = 0;
	//Try setting pos to 0
	if(pos == 0) {
		ans = kSet[pos][0];
	} else if (k&((lli)1 << pos)) {
		ans = kSet[pos][0] + solve(pos-1, curr, true);
	} else {
		ans = kSet[pos][0] + solve(pos-1, curr, freiheit);
	}
	
	//Try setting pos to 1
	if(curr + ((lli)1 << pos) <= k) {
		if(pos == 0) {
			ans = max(ans, kSet[pos][1]);
		} else {
			ans = max(ans, kSet[pos][1] + solve(pos-1, curr + ((lli)1 << pos), freiheit));
		}
	}
	return ans;
}

lli solve() {
	return solve(39, 0, false);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	
	for(int i = 0; i < 40; i++) {
		lli summeZero = 0;
		lli summeOne = 0;
		for(int j = 0; j < n; j++) {
			summeZero += (a[j]&((lli)1 << i));
			summeOne += (a[j]&((lli)1 << i))^((lli)1 << i);
		}
		kSet[i][0] = summeZero;
		kSet[i][1] = summeOne;
	}
	
	kFreiSet[0] = max(kSet[0][0], kSet[0][1]);
	for(int i = 1; i < 40; i++) {
		kFreiSet[i] = kFreiSet[i-1] + max(kSet[i][0], kSet[i][1]);
	}
	
	cout << solve() << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

const int M_N=100000;

LL bit[M_N+1],n;

LL sum(int i){
    LL s=0;
    while(i>0){
        s+=bit[i];
        i=i&(i-1);
    }
    return s;
}

void add(int i,int x){
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
}

int main(){
    int q;
    cin >> n >> q;
    for(int i=0;i<q;i++){
        int com,x,y;
        cin >> com >> x >> y;
        if(com==0) add(x,y);
        if(com==1) cout << sum(y)-sum(x-1) << endl;
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int n,m,a,b;
	int counter[51]={};
	cin>>n>>m;
	REP(i,m){
		cin>>a>>b;
		counter[a]++;
		counter[b]++;
	}

	FOR(i,1,n+1) cout<<counter[i]<<endl;
	return 0;
}



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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define UNIQUE(o) (o).erase(unique(sort(all((o)))))

typedef long long ll;
const int N = 100;
const int T = 1e4;
int n, m, t;
int a[T+1];

int main() {
  scanf("%d%d%d ", &n, &m, &t);
  memset(a, 0, sizeof(a));
  REP(i,n) {
    int x;
    scanf("%d ", &x);
    FOR(j,x-m,x+m+1) if (j>=0 && j<=t) a[j] = 1;
  }
  int res = 0;
  REP(i,t) if (!a[i] || !a[i+1]) res++;
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 3256
S=[i for i in input()]
n=len(S)
for i in range(2,n-2+1,2):
  m=int((n-i)/2)
  SF=S[0:m]
  SR=S[m:m*2]
  if SF==SR:
    #print(SF,SR)
    print(len(SF+SR))
    break

Measured memory_bytes: 2940
package main

import (
	"fmt"
	"io"
	"os"
)

func run(input io.Reader, output io.Writer) int {
	var n, r int
	fmt.Fscanf(input, "%d %d\n", &n, &r)

	if n < 10 {
		fmt.Println(r + (100 * (10 - n)))
	} else {
		fmt.Println(r)
	}
	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	char[][] map = new char[8][];
	for ( int i = 0; i < 8; i++ ) {
	    map[i] = stdin.nextLine().toCharArray();
	}

	System.out.println(90);
	for ( int i = 0; i < 8; ++i ){
	    for( int j = 7; j >= 0; j-- ) {
		System.out.print( map[j][i] );
	    }
	    System.out.println();
	}
	
	System.out.println(180);
	for ( int i = 7; i >= 0; i-- ){
	    for( int j = 7; j >= 0; j-- ) {
		System.out.print( map[i][j] );
	    }
	    System.out.println();
	}
	
	System.out.println(270);
	for ( int i = 7; i >= 0; i-- ){
	    for( int j = 0; j < 8; j++ ) {
		System.out.print( map[j][i] );
	    }
	    System.out.println();
	}
    }    
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  vector<int> s(m);
  vector<int> c(m);
  for(int i = 0; i < m; i++){
    cin >> s[i] >> c[i];
    s[i]--;
  }
  bool ans = true;
  for(int i=0;i<m;i++){
    if(n > 1 && s[i] == 0 && c[i] == 0){
      ans = false;
    }
    if(a[s[i]] == -1 || a[s[i]] == c[i]){
      a[s[i]] = c[i];
    }else{
      ans = false;
    }
  }
  if(ans == false){
    cout << -1 << endl;
  }else{
    if(a[0] == -1){
      if(n == 1){
        a[0] = 0;
      }else{
        a[0] = 1;
      }
    }
    
    if(n > 1){
      for(int i = 1; i < n; i++){
        if(a[i] == -1) a[i] = 0;
      }
    }
    for(int i = 0; i < n; i++){
      cout << a[i];
    }
    cout << endl;
  }
}

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

int main() {
    int64_t n, k, q;
    cin >> n >> k >> q;

    vector<int64_t> answerer(q);
    for(int i = 0; i < q; i++) {
        cin >> answerer[i];
        answerer[i]--;
    }
    
    vector<int64_t> ans_num(n, 0);
    for(int i = 0; i < q; i++) {
        ans_num[answerer[i]]++;
    }

    for(int i = 0; i < n; i++) {
        if(ans_num[i] <= q - k) cout << "No" << endl;
        else                    cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int t,n,m,a,p[100005],ans[100005],tmp[100005],i;
int x[100005];
long long k;
double s=0;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d",&x[i]);
	for(i=n;i>=2;--i)
		x[i]-=x[i-1];
	for(i=1;i<=n;++i)
		ans[i]=p[i]=i;
	scanf("%d %lld",&m,&k);
	for(i=1;i<=m;++i)
	{
		scanf("%d",&a);
		swap(p[a],p[a+1]);
	}
	for(i=1;i<=n;++i)
		tmp[p[i]]=i;
	for(i=1;i<=n;++i)
		p[i]=tmp[i];
	while(k)
	{
		if(k&1)
		{
			for(i=1;i<=n;++i)
				tmp[i]=p[ans[i]];
			for(i=1;i<=n;++i)
				ans[i]=tmp[i];
		}
		for(i=1;i<=n;++i)
			tmp[i]=p[p[i]];
		for(i=1;i<=n;++i)
			p[i]=tmp[i];
		k>>=1;
	}
	for(i=1;i<=n;++i)
		tmp[ans[i]]=x[i];
	for(i=1;i<=n;++i)
	{
		s+=tmp[i];
		printf("%.12lf\n",s);
	}
}

Measured memory_bytes: 4096
A, B = map(int,input().split())
import fractions
_gcd = fractions.gcd(A, B)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

l = make_divisors(_gcd)
if len(l)==1:
    print(1)
    quit()
l.sort()
aa=False
for x in l:
    if x%2==0:
        aa=x
        break
if aa:
    l2 = [x for x in l if x%2]
    l2.append(aa)
else:
    l2 = l[:]
for i,x in enumerate(l2):
    for y in l2[i+1:]:
        if fractions.gcd(x, y) != 1 and y in l2:
            l2.remove(y)
print(len(l2))


Measured memory_bytes: 5304
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

if P == Q:
    ans = 0
else:
    PQ = [P] + [Q]
    PQ = sorted(PQ)

    li = list(range(N))
    li = list(map(lambda x: x + 1, li))

    i = 0
    j = 0
    a = []
    for v in itertools.permutations(li, N):
        j += 1
        if PQ[i] == v:
            a.append(j)
            if i == 1:
                break
            else:
                i += 1

    ans = a[1] - a[0]

print(ans)


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  long long p=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    p+=a[i];
  }
  
  long long ans=pow(10,14);
  long long q=0;
  
  for(int i=0;i<n-1;i++){
    q+=a[i];
    p-=a[i];
    ans=min(ans,max(p-q,q-p));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4036
#include <vector>
#include <iostream>
#include <complex>
#include <cstdio>

#define pb push_back
#define fs first
#define sc second
#define sz size()
using namespace std;

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef pair<P, D> C;
typedef vector<P> Poly;
const D EPS=1e-12;


namespace std{
  bool operator<(const P &a, const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

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

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

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

P rotate(P v, double s){
  return P(real(v)*cos(s) - imag(v) * sin(s), real(v)*sin(s) + imag(v) * cos(s));
}

D arg(P a, P b, P c){ return acos(dot(b-a, c-a)/(abs(b-a)*abs(c-a)));}
D arg(D a, D b, D c){return acos((b*b+c*c-a*a)/(2*b*c));}

int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b, c) > EPS) return 1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < -EPS) return 2;
  if(abs(b) < abs(c)) return -2;
  return 0;
}

bool para(L a, L b){return abs(cross(a.fs - a.sc, b.fs-b.sc))<EPS;}

vector<P> cp_cir_to_cir(C a, C b){
  vector<P> v;
  D 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));
  return v;
}

D area(Poly p){
  if(p.sz<3) return 0;
  D res = cross(p[p.sz-1],p[0]);
  for(int i=1;i<p.sz;i++) res += cross(p[i-1], p[i]);
  return res/2;
}

int main(){
  int n;
  int k=0;
  while(scanf("%d", &n)){
    if(n==0) break;
  vector<P> v;
  D x, y;
  for(int i=0;i<n;i++){
    scanf("%lf %lf", &x, &y);
    v.pb(P(x, y));
  }
  printf("%d %.1lf\n", k+1, -area(v));
  k++;
  }
  return 0;
}





Measured memory_bytes: 3220
N = int(input())
A_int_list = list(map(int, input().split()))

for i in A_int_list:
    if i % 2 == 1:
        continue
    else:
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            print('DENIED')
            exit()

print('APPROVED')


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b,ans;

main() {
    cin >> a >> b;
    repo(i,a,b+1) {
        if (i%10 == i/10000 && (i%10000)/1000 == (i%100)/10) ans++;
    }
    ct(ans)
}






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

typedef long long ll;
static const ll INF = 1ll<<60;
static const ll MOD = 1e9+7;

int main(){
    int L,R,d;
    cin>>L>>R>>d;

    int ans = 0;

    for(int i=L; i<=R; i++){
        if(i%d == 0) ans++;
    }

    cout<<ans<<endl;
}

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

int main(){
    int N; cin >> N;
    double x[11];
    string u[11];
    for(int i=0; i < N; i++) cin >> x[i] >> u[i];

    double sum=0;

    for(int i=0; i < N; i++) {
        if (u[i] == "BTC") x[i] *= 380000.0;
        sum += x[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int N; cin >> N;
VI t(N+1), x(N+1), y(N+1); 
t[0] = x[0] = y[0] = 0;
rep(i, 0, N) scanf("%d %d %d", &t[i+1], &x[i+1], &y[i+1]);

int dt, dist;
rep(i, 0, N){
    dt = t[i+1] - t[i];
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dist > dt || dist % 2 != dt % 2) {
        cout << "No" << "\n"; 
        return 0;
    }
    
}

cout << "Yes" << "\n";

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.


Measured memory_bytes: 1408
# ABC143D - Triangles
def binary_search(cur: int, upper_bound: int = 1 << 60, lower_bound: int = -1) -> int:
    ok, ng, ret = upper_bound, lower_bound, 0
    while ok > ng:
        if L[ok] + L[ng] > cur:
            ret += ok - ng
            ok -= 1
        else:
            ng += 1
    return ret


def main():
    # fix the longest edge -> binary search
    global L
    N, *L = map(int, open(0).read().split())
    L.sort()
    ans = sum(binary_search(L[i], i - 1, 0) for i in range(N - 1, 1, -1))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
long long q,a,b,ans;
int main()
{
	scanf("%lld",&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%lld%lld",&a,&b);
		if(a>b)swap(a,b);
		if(a==b||a==b-1)
			ans=2*(a-1);
		else
		{
			long long c=sqrt(a*b);
			if(c*c==a*b)c--;
			if(c*(c+1)<a*b)
				ans=2*c-1;
			else
				ans=2*c-2;
		}
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)

graph = Hash.new { |h, k| h[k] = [] }
m.times do
  a, b = gets.split.map(&:to_i)
  graph[a].push(b)
  graph[b].push(a)
end

dist = Array.new(n + 1, -1)
dist[1] = 0

que = []
que.push(1)

ans = Array.new(n + 1, -1)

until que.empty?
  v = que.shift

  graph[v].each do |nv|
    next if dist[nv] != -1

    dist[nv] = dist[v] + 1
    que.push(nv)
    ans[nv] = v
  end
end

puts "Yes"
puts ans[2..-1]


Measured memory_bytes: 35060
#include<iostream>
#include<cstdio>
#include<queue>
#include<map>
using namespace std;
typedef pair<unsigned short,unsigned short> P;
typedef pair<unsigned char,int> T;
typedef pair<T,P> PP;
#define rep(i,n) for(i=0;i<n;i++)
#define MAX 1000
char F[MAX][MAX];
char Dx[]={1,0,-1,0},Dy[]={0,1,0,-1};
unsigned short h,w,n,x,y,nx,ny;
P dist[10];
int bfs()
{
  bool used[9][MAX][MAX]={};
  int c,res=0,u=0;
  unsigned char t,i;
  PP p;
  queue<PP> q;
  rep(i,9)
    q.push(PP(T(i+'1',0),dist[i]));
  while(!q.empty()){
    p=q.front();
    q.pop();
    t=p.first.first;
    if(u&(1<<(t-'1')))continue;
    c=p.first.second;
    x=p.second.first;
    y=p.second.second;
    c++;
    rep(i,4){
      nx=x+Dx[i]; ny=y+Dy[i];
      if(nx<w&&ny<h&&F[ny][nx]!='X'&&!used[t-'1'][ny][nx]){
        used[t-'1'][ny][nx]=true;
        if(F[ny][nx]==t){
          u|=(1<<(t-'1'));
          res+=c;
        }
        else{
          q.push(PP(T(t,c),P(nx,ny)));          
        }
      }
    }
  }
  return res;
}
int main(void)
{
  unsigned short i,j;
  int res;
  scanf("%hd%hd%hd",&h,&w,&n);
  rep(i,h) rep(j,w){
    scanf(" %c",F[i]+j);
    if(F[i][j]=='S')
      dist[0]=P(j,i);
    else if(F[i][j]!='X'&&F[i][j]!='.')
      dist[F[i][j]-'0']=P(j,i);
  }
  res=bfs();
  printf("%d\n",res);
  return 0;
}

Measured memory_bytes: 0
unittest
{
	assert( [ "3 3", "1 2 1", "1 3 1", "2 3 3" ].parse.expand.solve == 1 );
	assert( [ "3 2", "1 2 1", "2 3 1" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto abcs = new long[ 3 ][ nm[ 1 ] ];
	foreach( ref abc; abcs )
	{
		input.popFront;
		abc = input.front.split.to!( long[] );
		abc[ 0 .. 2 ] -= 1;
	}
	return tuple( nm[ 0 ], abcs );
}

auto solve( long n, long[ 3 ][] abcs )
{
	auto dss = warshallfloyd!( true )( n, abcs );
	auto ans = 0L;
	foreach( abc; abcs )
	{
		ans += ( dss[ abc[ 0 ] ][ abc[ 1 ] ] < abc[ 2 ] );
	}
	return ans;
}

// 正負の重み付きグラフの全二点間最短経路探索（ワーシャルフロイド法）
auto warshallfloyd( bool undirected = false )( long n, long[ 3 ][] es )
{
	auto dss = new long[][]( n, n );
	foreach( i, ref ds; dss )
	{
		ds[] = long.max;
		ds[ i ] = 0;
	}
	foreach( e; es )
	{
		dss[ e[ 0 ] ][ e[ 1 ] ] = e[ 2 ];
		static if( undirected ) dss[ e[ 1 ] ][ e[ 0 ] ] = e[ 2 ];
	}
	
	foreach( p; 0L .. dss.length )
	{
		foreach( f; 0L .. dss.length )
		{
			foreach( t; 0L .. dss.length )
			{
				if( dss[ f ][ p ] == long.max || dss[ p ][ t ] == long.max ) continue;
				dss[ f ][ t ] = min( dss[ f ][ t ], dss[ f ][ p ] + dss[ p ][ t ] );
			}
		}
	}
	return dss;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    string s;
    LL k;
    cin >> s >> k;
    for (int i = 0; i < k; i++) {
        if (s[i] != '1') {
            std::cout << s[i] << std::endl;
            return 0;
        }
    }
    std::cout << 1 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
char a[202];
int main(void){
    int i,cnt;
    scanf("%s",a);
    for(i=strlen(a)/2;--i;){
        cnt=0;
        for(int j=0;j<i;++j)if(a[j]==a[j+i])++cnt;
        if(cnt==i)break;
    }
    printf("%d\n",i*2);
}

Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

int main(){
	for(int n;~scanf("%d",&n);){
		int deg[7]={},node;
		bool wf[7][7]={};
		rep(u,7)	wf[u][u]=true;
		rep(i,n){
			int domi;	scanf("%d",&domi);
			int u=domi/10,v=domi%10;
			deg[u]++,deg[v]++;
			wf[u][v]=wf[v][u]=true;
			node=u;
		}

		rep(k,7)rep(i,7)rep(j,7)	wf[i][j]|=wf[i][k]&wf[k][j];
		bool ok=true;
		rep(u,7) if(deg[u]>0 && !wf[node][u]) ok=false;
		if(!ok){ puts("No"); continue; }

		int cnt=0;
		rep(u,7)if(deg[u]%2==1) cnt++;
		puts(cnt<=2?"Yes":"No");
	}

	return 0;
}

Measured memory_bytes: 0
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CSkolemXORTree {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;

        if ((N & -N) == N) {
            cout << "No" << endl;
            return;
        }

        cout << "Yes" << endl;

        vector<P> ans;
        ans.emplace_back(N + 1, 2);

        for (int i = 2; i + 1 <= N; i += 2) {
            ans.emplace_back(i, i + 1);
            ans.emplace_back(i + 1, 1);
            ans.emplace_back(1, N + i);
            ans.emplace_back(N + i, N + i + 1);
        }

        if (N % 2 == 0) {
            int i = N & -N;
            int t = N ^ 1 ^ i;
            if (i % 2 == 0) i += N;
            if (t % 2 == 0) t += N;
            ans.emplace_back(N, i);
            ans.emplace_back(2 * N, t);
        }

        REP(i, ans.size()) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CSkolemXORTree solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6384