akhauriyash/Code-Regression huggingface dataset:
program abc158a
   implicit none
   character(3)::a
   integer::check

      read *,a
      if (a(1:1)==a(2:2).and.a(2:2)==a(3:3).and.a(3:3)==a(1:1)) then
         check=0
      else
         check=1
      end if

      if (check==0) then
         print *,'No'
      else
         print *,'Yes'
      end if
      stop
   end program abc158a

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    yukari<pair<int, int>> g(n);
    akari<int> d(n), ans(n - 1, -1);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back({b, i});
        g[b].push_back({a, i});
        d[a]++, d[b]++;
    }
    int k = *max_element(d.begin(), d.end());
    auto dfs = [&](auto &&dfs, int v, int p, int c = -1) -> void {
        int cur = d[v];
        for (auto &e : g[v])
        {
            if (e.first == p)
            {
                continue;
            }
            if (cur == c)
            {
                cur--;
            }
            ans[e.second] = cur--;
            dfs(dfs, e.first, v, ans[e.second]);
        }
    };
    dfs(dfs, 0, -1);
    cout << k << endl;
    for (int i = 0; i < n - 1; i++)
    {
        cout << ans[i] << '\n';
    }
}

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


Measured memory_bytes: 7296
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
n,a,b = map(int,input().split())
mod=10**9+7
print((pow(2,n,mod)-1-cmb(n,a,mod)-cmb(n,b,mod))%mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  int m;
  std::cin >> m;
  cout(24 + (24 - m));
}

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

a.sort(reverse=True)
stack = list()
stack.append(a[0])

if n == 2:
    print(stack[0])
    exit(0)

for i in range((len(a) // 2) + 1):
    stack.append(a[i + 1])
    stack.append(a[i + 1])

print(sum(stack[:n-1]))


Measured memory_bytes: 103212
S=list(input())
data=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(data)):
    if data[i] not in S:
        print(data[i])
        break
else:
    print('None')

Measured memory_bytes: 67104
#include<stdio.h>

void show(int A[],int N){
  for (int i = 0; i < N; i++) {
    printf("%d",A[i] );
    if(i!=N-1)printf(" " );
  }
  printf("\n");
}

int  bubble (int A[],int N){
  int i ,j;
  int c=0;
  j=N;
  int sw;
for(int j=0;j<N;j++)
  for (i= N-1; j<i; i--) {
    if(A[i]<A[i-1]){
      sw=A[i-1];
      A[i-1]=A[i];
      A[i]=sw;
      c++;
    }
  }
  show(A,N);
  return c;
}

int main(){
  int A[100];
  int N;
scanf("%d\n",&N);
for (int i = 0; i < N; i++) scanf("%d",&A[i]);
printf("%d\n",bubble(A,N) );
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (510)

int main()
{
	int N, M, Q;
	scanf("%d%d%d", &N, &M, &Q);

	int sum[MAX_N][MAX_N];
	memset(sum, 0, sizeof(sum));
	for (int i = 0; i < M; i++) {
		int L, R;
		scanf("%d%d", &L, &R);
		sum[L][R]++;
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			sum[i][j] += sum[i - 1][j];
			sum[i][j] += sum[i][j - 1];
			sum[i][j] -= sum[i - 1][j - 1];
		}
	}

	for (int i = 0; i < Q; i++) {
		int l, r;
		scanf("%d%d", &l, &r);

		int res = sum[r][r];
		res -= sum[l - 1][r];
		res -= sum[r][l -1];
		res += sum[l - 1][l - 1];
		printf("%d\n", res);
	}

	return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		double y500 =  Math.floor(X/500);
		double T = (X-y500*500);
		double y5 =  Math.floor(T/5);
		int ans = (int) ((int)y500*1000+y5*5);
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>
#include <functional>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

vector<ll> p = { 1 }, b = { 1 };

ll solve(ll n, ll x) {
	if (n == 0)return x <= 0 ? 0 : 1;
	else if (x <= 1 + b[n - 1]) return solve(n - 1, x - 1);
	else return p[n - 1] + 1 + solve(n - 1, x - 2 - b[n - 1]);
}

int main() {
	ll n, x;
	cin >> n >> x;

	for (ll i = 1; i <= n; i++)
	{
		p.push_back(2 * p[i - 1] + 1);
		b.push_back(2 * b[i - 1] + 3);
	}

	cout << solve(n, x) << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

from random import randint
# n = 3
# l = n
# A = [randint(1,l) for i in range(n)]
# B = [randint(1,l) for i in range(n)]
# A.sort()
# B.sort()
# print(A,B)

# A = [1,1,2,4,5]
# B = [1,1,2,3,5]

C = [-1] * (n+2)
D = [-1] * (n+2)
for i in range(1, n):
    if A[i-1] != A[i]:
        C[A[i-1]] = i-1
C[A[-1]] = n-1

ind = 0
D[B[0]] = 0
for i in range(1, n):
    if B[i-1] != B[i]:
        D[B[i]] = i

# print(C,D)

sh = 0
for i in range(n+2):
    if C[i] != -1 and D[i] != -1:
        sh = max(sh, C[i]-D[i]+1)

# print("sh",sh)

N = [B[(i-sh)%n] for i in range(n)]
ng = 0
# print("N",N)
for i in range(n):
    if N[i] == A[i]:
        ng = 1
        break

if ng == 1:
    print("No")
else:
    print("Yes")
    print(*N)

Measured memory_bytes: 125676
#include <iostream>

using namespace std;

typedef long long ll;

ll calc(ll X, ll Y) {
    ll c;
    while (X <= Y) {
        X *= 2;
        c++;
    }
    return c;
}

int main() {

    ll X, Y;
    scanf("%lld %lld", &X, &Y);

    printf("%lld\n", calc(X, Y));

    return 0;
}


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

int main() {
        int N;
        std::cin >> N;
        std::vector<int> A;

        for (int i = 0; i < N; i++) {
                int x;
                std::cin >> x;
                A.push_back(x);
        }

        std::cout << A[0];
        for (int i = 1; i < N; i++) {
                std::cout << " " << A[i];
        }
        std::cout << std::endl;

        for (int i = 1; i <= N - 1; i++) {
                int v = A[i];
                int j = i - 1;

                while (j >= 0 && A[j] > v) {
                        A[j+1] = A[j];
                        j--;
                }
                A[j+1] = v;

                std::cout << A[0];
                for (int i = 1; i < N; i++) {
                        std::cout << " " << A[i];
                }
                std::cout << std::endl;
        }
}



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

int n, m;
char brd[500][500];
int cnt = 0;
vector<P> v[30];

int main(){
	cin >> n >> m;
	rep(i,n) rep(j,m){
		cin >> brd[i][j];
		if(brd[i][j] != '.') v[brd[i][j]-'A'].push_back(P(i,j));
	}
	while(true){
		bool end = true;
		rep(i,30){
			if(v[i].size() == 0) continue;
			bool ok1 = true, ok2 = true;
			int xx1 = v[i][0].first,yy1 = v[i][0].second;
			int xx2 = v[i][1].first,yy2 = v[i][1].second;
			int x1 = xx1, y1 = yy1, x2 = xx2, y2 = yy2;
			if(x1 > x2){
				swap(x1,x2);
				swap(y1,y2);
			}
			if(abs(x2-x1)+abs(y2-y1) == 1) continue;
			if(y1 < y2){
				for(int j = x1; j <= x2; j++){
					if(brd[j][y1]!='.'&&brd[j][y1]-'A'!=i) ok1 = false;
					if(brd[j][y2]!='.'&&brd[j][y2]-'A'!=i) ok2 = false;
				}
				for(int j = y1; j <= y2; j++){
					if(brd[x1][j]!='.'&&brd[x1][j]-'A'!=i) ok2 = false;
					if(brd[x2][j]!='.'&&brd[x2][j]-'A'!=i) ok1 = false;
				}
				if(ok1 == false && ok2 == false) continue;
				cnt += 2;
				brd[xx1][yy1] = '.'; brd[xx2][yy2] = '.';
				end = false;
				v[i].clear();
			} else{
				for(int j = x1; j <= x2; j++){
					if(brd[j][y1]!='.'&&brd[j][y1]-'A'!=i) ok1 = false;
					if(brd[j][y2]!='.'&&brd[j][y2]-'A'!=i) ok2 = false;
				}
				for(int j = y2; j <= y1; j++){
					if(brd[x1][j]!='.'&&brd[x1][j]-'A'!=i) ok2 = false;
					if(brd[x2][j]!='.'&&brd[x2][j]-'A'!=i) ok1 = false;
				}
				if(ok1 == false && ok2 == false) continue;
				cnt += 2;
				brd[xx1][yy1] = '.'; brd[xx2][yy2] = '.';
				end = false;
				v[i].clear();
			}
		}
		if(end) break;
	}
	cout << cnt << endl;
}

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



int main()
{
	int a, b;
	char total[16];
	while (scanf("%d %d", &a, &b) != EOF)
	{
		sprintf(total, "%d", a + b);
		printf("%d\n", strlen(total));
	}
	return 0;
}

Measured memory_bytes: 1040
/* 例が通らないので解説見た */
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b) do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x) cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

u64 layer[51] = {0};
u64 patty[51] = {0};

void init() {
  layer[1] = 1;
  patty[1] = 1;
  repd(i, 2, 51) {
    layer[i] = 2 * layer[i-1] + 3;
    patty[i] = 2 * patty[i-1] + 1;
  }
}

int main(int argc, const char* argv[]) {
  u64 primes[25] = { 2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 
                     31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
                     73, 79, 83, 89, 97
                   };
  u64 nums[25] = {0};
  
  u64 n;
  cin >> n;
  
  for(u64 i = 2; i <= n; ++i) {
    u64 tmp = i;
    for(u64 j = 0; j < 25; ++j) {
      while(tmp % primes[j] == 0) {
        ++nums[j];
        tmp /= primes[j];
      }
    }
  }
  
  u64 ret = 0;
  
  rep(i, 25) {
    if(nums[i] < 2) continue;
    rep(j, 25) {
      if( (i == j) || (nums[j] < 4) ) continue;
      repd(k, j + 1, 25) {
        if( (i == k) || (nums[k] < 4) ) continue;
        ++ret;
      }
    }
  }
  
  /* 
   *  75 = 3 * 5 * 5 -> p^2 * q^4 * r^4
   *  75 = 5 * 15    -> p^4 * q^14       <---
   *  75 = 3 * 25    -> p^2 * q^24       <--- この3つ考えてなくて回答できず
   *  75 = 1 * 75    -> p^74             <---
   */
  rep(i, 25) {
    if(nums[i] < 4) continue;
    rep(j, 25) {
      if( (i == j) || (nums[j] < 14) ) continue;
      ++ret;
    }
  }
  rep(i, 25) {
    if(nums[i] < 2) continue;
    rep(j, 25) {
      if( (i == j) || (nums[j] < 24) ) continue;
      ++ret;
    }
  }
  rep(i, 25) {
    if(nums[i] < 74) continue;
    ++ret;
  }
  
  cout << ret << endl;
  
  return 0;
}

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

using namespace std;

int gcd(int a,int b) {
	return b==0?a:gcd(b,a%b);	
}

int main()
{
	int n;
	cin>>n;
	long long int sum=0;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			for(int k=1;k<=n;k++) {
				sum+=gcd(k,gcd(i,j));				
			}
		}
	}
	cout<<sum<<'\n';
	return 0; 
} 

Measured memory_bytes: 3636
import sys
from itertools import accumulate
N, K = map(int, input().split())
dt = [tuple(map(int, sys.stdin.readline().split()))[::-1] for _ in range(N)]
dt.sort()
ans = sum([d for d, t in dt[N-K:]])
repet = []
seen = set()
for _ in range(K):
    d, t = dt.pop()
    if t not in seen:
        seen.add(t)
    else:
        repet.append(d)
sp = len(seen)
repet.append(0)
uniq = [0]
for _ in range(N-K):
    d, t = dt.pop()
    if t not in seen:
        uniq.append(d)
        seen.add(t)
repet = list(accumulate(repet[::-1]))
uniq = list(accumulate(uniq))
print(ans + max([(sp + i)**2 - r + u for i, (r, u) in enumerate(zip(repet, uniq))]))


Measured memory_bytes: 60636
import math

n = int(input())
a=[]

for j in range(n):
    x = [int(i) for i in input().split()]
    a.append(x)

def dist(i,j):
    b = ((a[i][1]-a[j][1])**2+(a[i][0]-a[j][0])**2)**0.5
    if b<0:
        print("false")
    return b

sum=0
for i in range(n):
    for j in range(n):
        if j==i:
            pass
        else:
            sum += dist(i,j)

print(sum*math.factorial(n-1)/math.factorial(n))

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
d = int(input())

# 電車の運賃リスト
train = [a,b]
# バスの運賃リスト
bus = [c,d]
# 電車のバスのそれぞれ最安値を足し合わせる
print(min(train)+ min(bus))

Measured memory_bytes: 9012
n = int(input())
res = [-1] * n
def do(a, b):
    #print("do",a,b)
    if a >= n:
        return
    res[a] = b
    if a == n - 1:
        print("".join(list(map(lambda x: chr(ord("a") - 1 + x), res))))
        return
    for i in range(1, max(res[0:a+1])+2):
        do(a + 1, i)
do(0, 1)


Measured memory_bytes: 76596
program E;
    type point=record
        x:double;
        y:double;
    end;
    type circle=record
        center:point;
        rad:double;
    end;
    function distance(_a,_b:point):double; overload;
    begin
        distance:=sqrt((_a.x-_b.x)*(_a.x-_b.x)+(_a.y-_b.y)*(_a.y-_b.y));
    end;
    function distance(_a:point;_r:circle):double; overload;
        var _:double;
    begin
        _:=distance(_a,_r.center)-_r.rad;
        if _>0 then distance:=_ else distance:=0;
    end;
    function distance(_a,_b:circle):double; overload;
        var _:double;
    begin
        _:=distance(_a.center,_b.center)-_a.rad-_b.rad;
        if _>0 then distance:=_ else distance:=0;
    end;
    function min(_a,_b:double):double;
    begin
        if _a<_b then min:=_a else min:=_b;
    end;
    var S,T:point;
    var N,i,j,pt:integer;
    var C:array [1..1200] of circle;
    var DIJK:array [1..1200] of double;
    var USED:array [1..1200] of boolean;
    var map:array [0..1200,0..1200] of double;
    var M:double;
begin
    readln(S.x,S.y,T.x,T.y);
    readln(N);
    for i:=1 to N do readln(C[i].center.x,C[i].center.y,C[i].rad);
    map[0,N+1]:=distance(S,T);
    map[N+1,0]:=distance(S,T);
    for i:=1 to N do
    begin
        map[0,i]:=distance(S,C[i]);map[i,0]:=map[0,i];
        map[N+1,i]:=distance(T,C[i]);map[i,N+1]:=map[N+1,i];
    end;
    for i:=1 to N do
    begin
        map[i,i]:=0;
        for j:=i+1 to N do
        begin
            map[i,j]:=distance(C[i],C[j]);
            map[j,i]:=map[i,j];
        end;
    end;
    for i:=1 to N+1 do
    begin
        DIJK[i]:=map[0,i]; 
        used[i]:=false;       
    end;
    for j:=1 to N+1 do
    begin
        M:=1000000000000;
        for i:=1 to N+1 do
            if used[i]=false then
                if DIJK[i]<M then
                begin
                    pt:=i;
                    M:=DIJK[i];
                end;
        used[pt]:=true;
        for i:=1 to N+1 do
            if used[i]=false then
                DIJK[i]:=min(DIJK[i],DIJK[pt]+map[i,pt]);
    end;
    writeln(DIJK[N+1]:10:10);
end.

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define repr(i,a,n) for (int i=a;i<n;i++)
#define rrep(i,a,n) for (int i=n-1;i>=a;i--)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define fi first
#define se second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;

void solve() {
	int n;
	cin >> n;
	double odd = 0, even = 0, div = 0;
	rep(i, n + 1) {
		if (i % 2)odd++;
		else even++;
	}
	div = odd / (double)n;
	cout << fixed << setprecision(10) << div << endl;

}

signed main()
{
	int tc;
	tc = 1;
	//	cin >> tc;
	while (tc--) {
		solve();
	}


}

Measured memory_bytes: 256
/*
g++ -std=c++11 -o2 -Wall Nikkei_A.cpp -o .\out\Nikkei_A.out
.\out\Nikkei_A.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  int ans1, ans2;
  ans1 = min(a, b);
  ans2 = max(a + b - n, 0);
  cout << ans1 << " " << ans2 << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
signed main(){
	int n;
	cin >> n;
	if (n < 105)cout << 0 << endl;
	else if (n < 135)cout << 1 << endl;
	else if (n < 165)cout << 2 << endl;
	else if (n < 189)cout << 3 << endl;
	else if (n < 195)cout << 4 << endl;
	else cout << 5 << endl;
  ll
}

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

int main() {
    int H, W;
    cin >> H >> W;
    string board[60];
    int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
    int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
    for(int i = 0; i < H; i++) {
        cin >> board[i];
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(board[i][j] == '.') {
                int count = 0;
                for(int k = 0; k < 8; k++) {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x >= 0 && x < H && y >=0 && y < W && board[x][y] =='#') {
                        count++;
                    }
                }
                board[i][j] = '0' + count;
            }
        }
    }
    for(int i = 0; i < H; i++) {
        cout << board[i] << endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = -1;
    if (a + b >= c) {
        ans = b + c;
    }else{
        ans = b + (a + b + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)


  val MOD = 1e9.toLong + 7
  val N, M = in.next().toInt
  val S = new Array[Int](N+1)
  val T = new Array[Int](M+1)
  for (i <- 1 to N)
    S(i) = in.next().toInt
  for (i <- 1 to M)
    T(i) = in.next().toInt

  //
  val imos = Array.ofDim[Long](N+1, M+1)
  val dp = Array.ofDim[Long](N+1, M+1)
  for (n <- 1 to N) {
    for (m <- 1 to M) {
      if (S(n) == T(m)) {
        dp(n)(m) = imos(n-1)(m-1) + 1
        dp(n)(m) %= MOD
      }

      imos(n)(m) = imos(n-1)(m) + imos(n)(m-1) - imos(n-1)(m-1)
      if (imos(n)(m) < 0)
        imos(n)(m) += MOD
      imos(n)(m) %= MOD
      imos(n)(m) += dp(n)(m)
      imos(n)(m) %= MOD
    }
  }


  println((imos(N)(M) + 1) % MOD)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 114800
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

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


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

int n;
long long c[200002];
int main() {
	cin >> n;
	c[0] = 0;
	map<long long, int>mp;
	mp[c[0]]++;
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		c[i + 1] = c[i] + a;
		mp[c[i + 1]]++;
	}
	long long ans = 0;
	for (auto a : mp) {
		int p = a.second;
		if (p >= 2) {
			ans += nCr(p, 2);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 14336
str = input()
q = int(input())

for _ in range(q):
    line = input().split()
    c = line[0]
    a = int(line[1])
    b = int(line[2]) + 1

    if c == 'replace':
        str = str[:a] + line[3] + str[b:]
    elif c == 'reverse':
        str = str[:a] + str[a:b][::-1] + str[b:]
    else:
        print(str[a:b])


Measured memory_bytes: 5612
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] l = new int[m];
        int[] r = new int[m];
        for(int i = 0; i < m; i++){
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
        
        int maxL = 1;
        int minR = n;
        for(int i = 0; i < m; i++){
            if(l[i] > maxL){
                maxL = l[i];
            }
            if(r[i] < minR){
                minR = r[i];
            }
        }
        
        if((minR - maxL) < 0){
            System.out.println(0);
        }else{
            System.out.println(minR - maxL +1);
        }
    }
}

Measured memory_bytes: 50876
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    ll n, m;
    cin >> n >> m;
    if (abs(n - m) >= 2)cout << 0 << endl;
    else {
        ll ans = 1;
        if (n == m) {
            for (ll i = 2; i <= n; i++) {
                ans *= i;
                ans %= MOD;
            }
            ans *= ans;
            ans %= MOD;
            ans *= 2;
            ans %= MOD;
        }
        else {
            for (int i = 2; i <= min(n, m); i++) {
                ans *= i;
                ans %= MOD;
            }
            ans *= ans;
            ans %= MOD;
            ans *= max(n, m);
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}
int fp(int a,int b){
	if(b==0) return 1;
	int x=fp(a,b/2);
	x=(x*x)%mod;
	if(b&1) x=(x*a)%mod;
	return x;
}


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 int a;
 cin>>a;
 cout<<a+a*a+a*a*a;

}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
	int n,m,i,x,y;
	int a[55]={0};
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> x >> y;
		a[x]++;
		a[y]++;
	}
	for(i=1;i<=n;i++){
		cout << a[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << setprecision(n) << var << endl

//----------------------------------------------------------------

int main(void) {
  int a, b, t;
  cin >> a >> b >> t;

  int i=1, ans=0;
  while(i*a<=t){
    ans += b;
    i++;
  }

  prt(ans);
}


Measured memory_bytes: 256
//  main.cpp
//  
//
//  Created by ?????° on 2016/11/10.
//  Copyright ?? 2016??´ ?????°. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <map>
#include <string>
using namespace std;
int main()
{
    int x;
    cin>>x;
    cout<<x*x*x<<endl;
    return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define foreach(i,c) for(__typeof(c.begin())i=c.begin();i!=(c).end();i++)
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int cnt=0;
	FORN(i,n){
		FORN(j,m){
			int p=j%10;
			int q=j/10;
			if(p>=2&&q>=2&&p*q==i){
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
	ll n,k,c,i;
	cin>>n>>k>>c;
	string st;
	cin>>st;
	int L[k],R[k];
	int z=0;
	for(i=0;i<n;i++)
	{
		if(st[i]=='o'&&z<k)
		{
		L[z++]=i;
		i+=c;
		}
	}
	z=k-1;
	for(i=n-1;i>=0;i--)
	{
		if(st[i]=='o'&&z>=0)
		{
		R[z--]=i;
		i-=c;
		}
	}
	for(i=0;i<k;i++)
	{
		//cout<<L[i]<<" "<<R[i]<<endl;
		
		if(L[i]==R[i])
		cout<<L[i]+1<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

int main(){
	string s;
	cin>>s;
	vector<char>front,back;
	int q;
	cin>>q;
	int tmp=0;
	bool ok=true;
	while(q--){
		int a;
		cin>>a;
		if(a==1){
			tmp++;
			ok=true;
		}else{
			ok=false;
			int b;
			cin>>b;
			char c;
			cin>>c;
			if(b==1&&tmp%2==0)front.push_back(c);
			else if(b==1&&tmp%2)back.push_back(c);
			else if(b==2&&tmp%2==0)back.push_back(c);
			else front.push_back(c);
		}
	}
	if(tmp%2)reverse(s.begin(),s.end());
	if(tmp%2==0){
		for(int i=0;i<front.size();i++){
			s.insert(s.begin(),front[i]);
		}
		for(int i=0;i<back.size();i++){
			s.push_back(back[i]);
		}
	}else{
		for(int i=0;i<back.size();i++){
                	s.insert(s.begin(),back[i]);
       	 	}
        	for(int i=0;i<front.size();i++){
                	s.push_back(front[i]);
        	}
	}
	cout<<s<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    string O, E;
    cin >> O >> E;

    int len_o = O.length(), len_e = E.length();
    for( int i = 0, j = 0; i < len_o || j < len_e; ++i, ++j ){
        if( i < len_o ) cout << O.c_str()[i];
        if( j < len_e ) cout << E.c_str()[j];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

const double PI = 3.14159265358979323846;

int main() {
  int n;

  cin >> n;

  cout << 2 * PI * n << endl;

  return 0;
}

Measured memory_bytes: 3804
def getlist():
	return list(map(int, input().split()))

N, L = getlist()

a = []
for i in range(N):
	a.append(L + i)

ans = sum(a)
vv = float("inf")
v = float("inf")
for i in a:
	if abs(i) < v:
		v = abs(i)
		vv = i

print(ans - vv)


Measured memory_bytes: 3060
#coding:utf-8
#全探索
import itertools
n = int(input())
#permutationすると各結果がタプルで返るので入力をタプルにする
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

#全部の並べ替えパターンを列挙,ついでにソートしておく
pattern = sorted(list(itertools.permutations(p)))
#print(pattern)
print(abs(pattern.index(p) - pattern.index(q)))


Measured memory_bytes: 8436
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int N;

    cin >> N;

    set<string> S;

    char l;
    bool cont = true;

    for(int i = 0; i < N; i++){
        string s;
        cin >> s;

        if(i == 0){
            l = s[s.length()-1];
            S.insert(s);
        }else{
            if(l != s[0] || S.count(s) != 0){
                cont = false;
            }else{
                S.insert(s);
                l = s[s.length()-1];
            }
        }
    }

    if(cont){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  int count=0;
  cin >>S;
  cin >>T;
  for(int i=0;i<3;i++){
      if (S[i]==T[i])
      count++;
  }
  cout <<count<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, os
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
if os.environ.get("USER") == "shun":
    def debug(*args): print(*args, file=sys.stderr)
else:
    print("NO DEBUG", file=sys.stderr)
    def debug(*args): pass
def exit(): sys.exit(0)


k, a, b = map(int, input().split())


if b - a <= 1:
    print(k + 1)
else:
    if k < a:
        print(k+1)
        exit()
    remain = k - (a-1)
    x = remain // 2
    y = remain - 2*x
    print(a + x*(b-a) + y)


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

#include <algorithm>
#include <vector>
#include <cstdio>
#include <random>
#include <functional>


int main() {
    int N, Y, d = 0, A = -1, B = -1, C =-1, c;
    cin >> N >> Y;
    for (int a = 0; a <= N; ++a){
      for(int b = 0; b <= N-a; ++b){
       c = N-a-b;
          
          if(10000*a+5000*b+1000*c == Y && a+b+c == N){
            A = a;
            B = b;
            C = c;
            d = 1;
            break;
          }
          
        if(d) break;
      }
      if(d) break; /* a break */
    }
            
    cout << A << ' ' << B << ' ' << C << endl;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(100005);

mint f(int n, int k) {
  if (n < 0) return 0;
  mint res = comb(n, k);
  res *= comb.fact[k];
  return res;
}

vector<int> to[100005];
int k;
mint ans;
void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u, v);
  }
  int nk = (p==-1) ? k : k - 2;
  int c = (p==-1) ? to[v].size() + 1 : to[v].size() - 1;
  ans *= f(nk, c);
}

int main() {
  int n;
  cin >> n >> k;
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = 1;
  dfs(0);
  cout << ans.x << '\n';
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m,k;
    cin>>m>>k;
    ll n = 1LL<<m;

    if(k>=n){
        cout<<-1<<endl;
        return 0;
    }
    if(m==1&&k==0){
        cout<<1<<" "<<1<<" "<<0<<" "<<0<<endl;
        return 0;
    }
    if(m==1&&k==1){
        cout<<-1<<endl;
        return 0;
    }

    Vec v;
    rep(i,n){
        if(i!=k){
            v.pb(i);
        }
    }
    rep(i,v.size()){
        cout<<v[i]<<" ";
    }
    cout<<k<<" ";
    reverse(ALL(v));
    rep(i,v.size()){
        cout<<v[i]<<" ";
    }
    cout<<k<<" ";
    return  0;
}


Measured memory_bytes: 2932
// https://atcoder.jp/contests/abc137/tasks/abc137_c
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    map<string, ll> st;
    REP(i, n) {
        cin >> s;
        sort(ALL(s));
        if (st.count(s) == 0) {
            st[s] = 1;
        } else {
            st[s]++;
        }
    }
    ll ans = 0;
    for (auto x : st) {
        ans += x.second * (x.second - 1);
    }
    cout << ans / 2 << endl;

    return 0;
}


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

void show(int* a, int n){
    
    int i;
    for(i = 0; i < n; i++){
        if(i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

void insertionSort(int* a, int n){

    int i, j, v;

    for(i = 1; i < n; i++){
        v = a[i];
        j = i - 1;
        while((j >= 0) && (a[j] > v)){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        show(a, n);
    }
}

int main(){

    int N;
    int* A;
    cin >> N;

    A = new int [N];
    if(A == NULL) return 0;

    for(int i = 0; i < N; i++) cin >> A[i];
    show(A, N);
    insertionSort(A, N);

    delete [] A;

    return 0;
}

Measured memory_bytes: 1192
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    var S = input.split('\n');
    var K = S[0].split(' ')[0];
    var N = S[0].split(' ')[1];
    var A = S[1].split(' ');
    var count = 0;
    for (var i = 0; i < N; i++) {
        var sa = A[i] - A[i + 1];
        if (Math.abs(sa) > count) {
            count = Math.abs(sa);
        }
    }
    if (K - (A[N - 1] - A[0]) > count) {
        count = K - (A[N - 1] - A[0]);        
    }
    console.log(K - count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

using ll = long long;

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

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

int main() {
  ll N;
  cin>>N;
  vector<ll> S(N);
  map<ll,ll> m;
  for(ll i = 0LL ; i< N; i++) {
    ll A;
    cin>>A;
    if(i==0LL) S[i]=A;
    else S[i]=S[i-1LL]+A;
    m[S[i]]++;
  }
  ll ans = 0LL;
  m[0]++;
  for(auto x:m){
    ans+=x.second*(x.second-1LL)/2LL;
  }
  cout<<ans<<endl;
}

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

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	char input ;
	cin >> input ;  
	if(input >= 65 &&input <= 90)
	{
		cout << "A" ;
	}
	else 
	{
		cout << "a" ; 
	}
}



Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <stack>
#include <utility>
#include <algorithm>

using namespace std;

const int kNil = -1;

enum class Color {
  kWhite,
  kGrey,
  kBlack,
};

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

template <class Edge>
bool DFSVisitCycleDetection(const typename vector<Edge>::size_type node_now,
       typename vector<Edge>::size_type & time,
       const vector<vector<Edge>> & adjacency_list,
       vector<int> & d,
       vector<int> & f,
       vector<Color> & color,
       vector<int> & parent) {
  color[node_now] = Color::kGrey;
  d[node_now] = time++;
  for (const auto & e: adjacency_list[node_now]) {
    if (color[e.v] == Color::kGrey) { return true; }
    if (color[e.v] == Color::kWhite) {
      parent[e.v] = node_now;
      if (DFSVisitCycleDetection(e.v, time, adjacency_list, d, f, color, parent)) {
        return true;
      }
    }
  }
  color[node_now] = Color::kBlack;
  f[node_now] = time++;

  return false;
}

template <class Edge>
bool DFSCycleDetection(const vector<Edge> & edges,
       typename vector<Edge>::size_type node_num) {
  using size_type = typename vector<Edge>::size_type;

  vector<vector<Edge>> adjacency_list(node_num, vector<Edge>());
  for (const auto & e: edges) {
    adjacency_list[e.u].push_back(e);
  }

  vector<int> d(node_num);
  vector<int> f(node_num);
  vector<Color> color(node_num, Color::kWhite);
  vector<int> parent(node_num, kNil);
  size_type time = 0;

  for (unsigned i = 0; i < node_num; ++i) {
    if (color[i] == Color::kWhite) {
      if (DFSVisitCycleDetection(i, time, adjacency_list, d, f, color, parent)) {
        return true;
      }
    }
  }

  return false;
}

int main(int argc, char const *argv[]) {
  using w_type = unsigned;

  vector<Edge<w_type>> edges;
  unsigned V, E;
  cin >> V >> E;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    w_type w;
    cin >> u >> v;
    edges.emplace_back(u, v, 1);
  }

  auto result = DFSCycleDetection(edges, V);
  if (result) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 3132
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	mm := make([]map[rune]int, n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		mm[i] = make(map[rune]int)
		for _, c := range s {
			mm[i][c]++
		}
	}

	cs := make([]int, 27)
	for i := 0; i < 27; i++ {
		cs[i] = 999999
	}

	for i := 0; i < 27; i++ {
		for j := 0; j < n; j++ {
			t := mm[j][rune('a'+i)]
			if t < cs[i] {
				cs[i] = t
			}
		}
		for j := 0; j < cs[i]; j++ {
			fmt.Printf("%c", 'a'+i)
		}
	}
	fmt.Println()
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void) {
   int h, n;
   int i;
   int max = 0;

   scanf("%d %d",&h, &n);
   int a[n];

   for(i = 0; i < n; i++) {
      scanf("%d",&a[i]);
   }

   for(i = 0; i < n; i++) {
      max += a[i];
   }

   if(h - max <= 0) {
      printf("Yes\n");
   } else {
      printf("No\n");
   }
   return 0;
}


Measured memory_bytes: 1988
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 1e5 + 10;
const int M = (int) 101;
const ll big =  (1LL << 51);
const ll LINF = (ll) 2e18;
const int INF = (int) 1e9 + 7;
const int INF1 = (int) 1e9 + 3;
const double EPS = (double) 1e-6;
const double PI =  3.14159265359;

int n;
ll max_a, max_b;
ll s[N];
int dp1[N], dp2[N], DP1[N], DP2[N];

void add(int &x, int y) {
  x += y;
  if (x >= INF)
    x -= INF;
}

int get(ll x) {
  return upper_bound(s, s + n + 1, x) - s;
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int t[2][4 * N], p[2][4 * N];

void push(int id, int v, int nemp) {
  if (p[id][v] == -1) 
    return;
  t[id][v] = (nemp + 1) * p[id][v];
  if (nemp) {
    p[id][v + v] = p[id][v];
    p[id][v + v + 1] = p[id][v];
  }
  p[id][v] = -1;
}

void upd(int id, int L, int R, int val, int v = 1, int l = 0, int r = n) {
  push(id, v, r - l);
  if (L > R) return;
  if (l > R || L > r) 
    return;
  if (L <= l && r <= R) {
    p[id][v] = val;
    push(id, v, r - l);
    return;
  }
  int m = (l + r) / 2;
  upd(id, L, R, val, v + v, l, m);
  upd(id, L, R, val, v + v + 1, m + 1, r);
  add(t[id][v] = t[id][v + v], t[id][v + v + 1]);
}

int get(int id, int L, int R, int v = 1, int l = 0, int r = n) {
  push(id, v, r - l);
  if (L > R) return 0;
  if (l > R || L > r) return 0;
  if (L <= l && r <= R) return t[id][v];
  int m = (l + r) / 2;
  return sum(get(id, L, R, v + v, l, m), get(id, L, R, v + v + 1, m + 1, r));
}

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n >> max_a >> max_b;
    for (int i = 1; i <= n; i++) {
      cin >> s[i];
    }
    memset(p, -1, sizeof(p));
    s[0] = -LINF;
    int prev1 = 0, prev2 = 0;
    for (int i = 1; i <= n; i++) {
      if (i == 1) {
        dp1[0] = 1;
        dp2[0] = 1;
        upd(0, 0, 0, 1);
        upd(1, 0, 0, 1);
        continue;
      }
      int val1 = get(0, 0, min(i - 1, get(s[i] - max_b)) - 1);
      int val2 = get(1, 0, min(i - 1, get(s[i] - max_a)) - 1);
      upd(0, i - 1, i - 1, val2);
      upd(1, i - 1, i - 1, val1);
      /*
      for (int last_a = 0; last_a < get(s[i] - max_a); last_a++) {
        add(dp1[i - 1], dp2[last_a]);
      }
      for (int last_b = 0; last_b < get(s[i] - max_b); last_b++) {
        add(dp2[i - 1], dp1[last_b]);
      }
      */
      if (s[i] - s[i - 1] < max_b) {
        while (prev1 < i - 1) {
          upd(1, prev1, prev1, 0);
          prev1++;
        } 
      }
      if (s[i] - s[i - 1] < max_a) {
        while (prev2 < i - 1) {
          upd(0, prev2, prev2, 0);
          prev2++;
        } 
      }
    }
    cout << sum(get(0, 0, n - 1), get(1, 0, n - 1));
    return 0;
}

Measured memory_bytes: 8960