akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

int mdays[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

int main(void) {
  int a, b;

  std::string str;
  std::cin >> str;
  a = std::stoi(str);
  std::cin >> str;
  b = std::stoi(str);

  size_t count = 0;

  for (int i = 0; i < a; i++) {
    int days = (i != a - 1) ? mdays[i] : b;
    for (int j = 0; j < days; j++) {
      if (i == j) {
        //std::cout << i << "/" << j << "@" << days << std::endl;
        ++count;
      }
    }
  }

  std::cout << count << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
w = s.count(".")
b = s.count("#")
ans = w
new_w = 0
new_b = 0
for i in range(n):
  if s[i] == ".":
    new_w += 1
  else:
    new_b += 1
  if new_b + (w - new_w) < ans:
    ans = new_b + (w - new_w)
print(ans)

Measured memory_bytes: 3500
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int x,y;
    scanf("%d %d",&x, &y);
    if(y % 2 == 1){
        printf("No");
    } else if (y >= 2 * x && y <= 4 * x){
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}


Measured memory_bytes: 3256
from collections import Counter
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]

if m == 0:
    print(1)
    exit()
    
g = [[] for _ in range(n)]
visited = [-1] * n
for a, b in ab:
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)
# print(g)
def dfs(start):
    global visited
    if visited[start] != -1:
        return 1
    stack = []
    stack.append(start)
    visited[start] = start
    while stack:
        root = stack.pop()
        for j in g[root]:
            if visited[j] == -1:
                visited[j] = start
                stack.append(j)

for i in range(n):
    dfs(i)
# print(visited)
tmp = Counter(visited)
# print(tmp)
p = sorted([v for i, v in tmp.items() if v != 1])
island = len(p)
# print(island)
if island == 1:
    print(n)
else:
    print(p[-1])

Measured memory_bytes: 135664
from collections import deque
h = int(input())
# stack = deque([h])
# count = 0
# while (len(stack) >= 1):
#     hp = stack.pop()
#     count += 1
#     if (hp == 1):
#         continue
#     else:
#         hp = hp//2
#         stack.append(hp)
#         stack.append(hp)
# print(count)
count = 0
hueru_ryo = 1
while h > 0:
    h = h//2
    count += hueru_ryo
    hueru_ryo *= 2
print(count)


Measured memory_bytes: 3316
#include<stdio.h>

#define MAX 2000000
#define INFTY (1<<30)
int H,A[MAX+1];

void swap(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
  return;
}

void maxHeapify(int i){
   int l,r,largest;
  l = 2*i;
  r = 2*i+1;

  if(l<=H && A[l]>A[i])largest = l;

  else largest = i;
  if(r<=H && A[r] > A[largest])largest = r;
  if(largest != i){
    swap(&A[i],&A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1)return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  if(key < A[i])return;
  A[i] = key;
  while(i>1 && A[i/2]<A[i]){
    swap(&A[i],&A[i/2]);
    i=i/2;
  }
}
void insert(int key){
  H++;
  A[H] = -INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n')break;
    if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
   int m,d;
   cin >>  m >> d;
   int ans=0;
   for(int i=1;i<=m;i++){
       for(int j=1;j<=d;j++){
           int x=j/10;
           int y=j%10;
            if(x>=2 && y>=2 && x*y==i)ans++;
               
       }
   }
   cout << ans << endl;
}



    
   


Measured memory_bytes: 3592
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0][0], 10);
    let v_c = input[1][0];
    let countW = 0;
    let countR = 0;
    
    for (let i = 0; i < v_c.length; i++){
        if (v_c[i] === 'W') countW ++;
        else countR ++;
    }

    let selectedR = countR;

    for (let i = 0; i < countR; i++){
        if (v_c[i] === 'R') selectedR --;
    }
    
	console.log(Math.min(countW, selectedR));
	
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32476
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int[] ar = {1, 3, 5, 7, 8, 10, 12};
            int[] arr = {4, 6, 9, 11};
            int[] arrr = {2};

            int x = in.nextInt();
            int y = in.nextInt();

            boolean isX = false;
            boolean isY = false;

            for (int i = 0; i < ar.length; ++i) {
                if (x == ar[i]) {
                    isX = true;
                }

                if (y == ar[i]) {
                    isY = true;
                }
            }

            if (isX && isY) {
                out.println("Yes");
                return;
            }

            isX = false;
            isY = false;
            for (int i = 0; i < arr.length; ++i) {
                if (x == arr[i]) {
                    isX = true;
                }

                if (y == arr[i]) {
                    isY = true;
                }
            }

            if (isX && isY) {
                out.println("Yes");
                return;
            }

            out.println("No");

        }

    }
}



Measured memory_bytes: 21712
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

inline s64 calc(s64 x, s64 y)
{
    static const s64 s = 32;
    return (x << s) | y;
}

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

    int h, w, n;
    cin >> h >> w >> n;

    vs64 vec;
    rep (i, n)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        rep (j, 3)
        {
            rep (k, 3)
            {
                int y = a - j;
                int x = b - k;
                if (IN(0, h - 2, y) && IN(0, w - 2, x))
                {
                    vec.push_back(calc(x, y));
                }
            }
        }
    }
    sort(vec.begin(), vec.end());

    vs32 ans(10, 0);
    int idx = 0;
    while (idx < vec.size())
    {
        int cnt = 0;
        s64 temp = vec[idx];
        while (idx < vec.size() && vec[idx] == temp) {++cnt; ++idx;}
        ++ans[cnt];
    }

    s64 zero = (s64)(h - 2) * (w - 2);
    rep (i, 10) zero -= ans[i];

    cout << zero << "\n";
    for (int i = 1; i < 10; ++i)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 10476
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
int idx;
const int MAXN=1e5+10;
int N;
ll L;
int ch[MAXN][2];
ll lowbit(ll x)
{
    return x&(-x);
}
void read()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>L;
    for(int u=0;u<N;u++){
        string s;
        cin>>s;
        int flag=0;
        for(char c:s){
            int t=c-'0';
            if(ch[flag][t]==0)ch[flag][t]=++idx;
            flag=ch[flag][t];
        }
    }
}
ll glb=0;
void dfs(int rt,int d)
{
    if(ch[rt][0])dfs(ch[rt][0],d+1);
    else glb=glb^lowbit(L-d);
    if(ch[rt][1])dfs(ch[rt][1],d+1);
    else glb=glb^lowbit(L-d);
}
void solve()
{
    read();
    dfs(0,0);
    if(glb)cout<<"Alice";
    else cout<<"Bob";
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 3548
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

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

int main(){

	double n, k;
	cin >> n >> k;
	double sum = 0;
	REP(i, 1, n+1) {
		double s;
		if( i < k ){
			int required = ceil( log2 ( k/(double)i ));
			s = 1 / (n * pow(2, required));
		} else {
			s = 1/n;
		}
		sum += s;
	}

	printf("%.9f\n", sum);
	return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    ans=set()
    for i in range(N):
        ans.add(ST())
    print(len(ans))
if __name__ == '__main__':
    main()

Measured memory_bytes: 102024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

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


int main() {
	string p;
	cin >> p;
	int x = 0;
	for (int i = 0; i < p.size(); i++) {
		if (p[i] == '+')x++;
		else x--;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
ll fact(ll n){
    ll p=1;
    f(i,1,n+1){
        p*=i;
    }
    return p;
}
int32_t main() {
    fast();
    ll n;
    cin >> n;
    vector<pair<ldb,ldb> >q(n);
    f(i,0,n){
        cin >> q[i].F >> q[i].S;
    }
    sort(all(q));
    ldb dist=0;
    do{
        ldb d1=0.0;
        f(i,0,n-1){
            d1+=hypot(q[i].F-q[i+1].F,q[i].S-q[i+1].S);
        }
        dist+=d1;

    }
    while(next_permutation(all(q)));
    cout<<setprecision(6)<<fixed<<dist/(fact(n));

    cerr << "\nTime taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

bool p[100001] = {};
bool like[100001] = {};
ll c[100001] = {};
int main() {
	ll q; cin >> q;
	rep(i, 2, 100001)p[i] = true;
	rep(i, 2, 100001)like[i] = true;
	like[0] = p[0] = false;
	like[0] = p[1] = false;

	for (int i = 2; i*i < 100001; i++) {
		if (p[i]) {
			for (int j = 2; i*j < 100001; j++) {
				p[i*j] = false;
				like[i*j] = false;
			}
		}
	}

	rep(i, 2, 100001) {
		if (p[i] && p[(i + 1) / 2]) {
		}
		else {
			like[i] = false;
		}
	}

	rep(i, 2, 100001) {
		c[i] += c[i - 1] + ((like[i]) ? 1 : 0);
	}

	rep(i, 0, q) {
		ll l, r; cin >> l >> r;
		cout << c[r] - c[l - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<math.h>
#include<cmath>
using namespace std;
const long double PI = 3.14159265358979323846L, t = 360.0;

int main()
{
	long double hlen, mlen, h, m, ans, o1, o2, angle;
	scanf("%Lf %Lf %Lf %Lf", &hlen, &mlen, &h, &m);
	o1 = h * 30 ;
	o2 = m * 6;
	o1 = h * 30 + (o2 / 12);
	angle = min(abs(o1 - o2), t - abs(o1 - o2));
	ans = hlen * hlen + mlen * mlen - 2 * hlen * mlen * cos(angle * PI/180);
	ans = sqrt(ans);
	cout << setprecision(12) << ans << endl;
	return 0;
}


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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    for (int i=0; i<N; i++) {
        cin >> m.at(i);
    }
    sort(m.begin(), m.end());
    int rem = X;
    for (int i=0; i<N; i++) {
        rem -= m.at(i);
    }
    int num;
    num = rem / m.at(0);
    int ans;
    ans = N + num;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    
    ll a,b,count=0;
    ss s;
    cin >> a >> b >>s;
    rep(i,SIZE(s))if(s[i] == '-')count++;
    if(SIZE(s) == a+b+1 && s[a] == '-' && count == 1)
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        ll a, b; cin >> a >> b;
        a--; b--;
        d.merge(a, b);
    }
    vector<vector<int>> gp = d.groups();
    cout << gp.size() - 1 << endl;
}

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

int main(){
    int r;
    cin >> r;
    string ans;
    if (r<1200) {
        ans = "ABC";
    }else if (r<2800) {
        ans = "ARC";
    }
    else
    {
        ans = "AGC";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    ll start = 60 * H1 + M1;
    ll finish = 60 * H2 + M2;

    cout << finish - start - K << "\n";
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                if (i == 0 || i == H - 1) {
                    for (int j = 0; j < W; j++) {
                        System.out.printf("#");
                    }

                } else {
                    for (int j = 0; j < W; j++) {

                        if (j == 0) {
                            System.out.printf("#");
                        } else if (j == W - 1) {
                            System.out.printf("#");
                        } else {
                            System.out.printf(".");
                        }
                    }
                }
                System.out.printf("\n");
            }

                    System.out.printf("\n");
        }
    }
}



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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


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

int	main() {
	long N, P;
	cin >>N >>P;
	vector<vector<long>> U(0);
	long PP=sqrt(P)+2;
	vector<bool> PR(PP, true);
	long UU=2;
	while (true) {
		if (UU>=PP) break;
		if (PR.at(UU)) {
			for (int i=UU+UU; i<PP; i+=UU)
				PR.at(i)=false;
			if (0==P%UU) {
				U.push_back({1, UU});
				P /=UU;
				while (0==P%UU) {
					U.at(U.size()-1).at(0)++;
					P /=UU;
				}
			}
		}
		if (2==UU)
			UU=3;
		else
			UU +=2;
		if (P<pow(UU, N))
			break;
	}
	long SS=1;
	if (1!=P)
		U.push_back({1, P});
	if (0<U.size()) {
		sort(U.begin(), U.end());
		reverse(U.begin(), U.end());
		long i=0;
		while (U.at(i).at(0)>=N) {
			long UUU=U.at(i).at(0);
			UUU /=N;
			for (int j=0; j<UUU; j++)
				SS *= U.at(i).at(1);
			i++;
			if (i==U.size())
				break;
		}
	}
	cout <<SS <<endl;
	return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N){
    VI ans;
    int x = 1;
    while(ans.size() != N) {
        x++;
        if(x%10 != 1) continue;
        bool flag = true;
        for(int i=2; i*i <= x; i++) {
            if(x % i == 0) {
                flag = false;
                break;
            }
        }

        if(flag) {
            ans.PB(x);
        }
    }

    cout << ans[0];
    REP1(i, N) cout << " " << ans[i];
    cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<cctype>
using namespace std;
string S;
int cur;
int expression();
int digit(){
    assert(isdigit(S[cur]));
    int n=S[cur]-'0';
    cur=cur+1;
    return n;
}
int number(){
    int n=digit();
    while(cur<S.size()&&isdigit(S[cur])){
        n=n*10+digit();
    }
    return n;
}
int factor(){
    if(S[cur]!='(') return number();
    cur+=1;
    int n=expression();
    assert(S[cur]==')');
    cur+=1;
    return n;
}
int term(){
    int a=factor();
    while(cur<S.size()&&(S[cur]=='*'||S[cur]=='/')){
        char op=S[cur++];
        int b=factor();
        if(op=='*'){
            a*=b;
        }
        else a/=b;
    }
    return a;
}
int expression() {
    int sum=term();
    while(cur<S.size()&&(S[cur]=='+'||S[cur]=='-')){
        char op=S[cur++];
        int b=term();
        if(op=='+'){
            sum+=b;
        }
        else sum-=b;
    }
    return sum;
}
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        cur=0;
        cin>>S;
        cout<<expression()<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   string S;
   cin >> S;
   int N = S.size();
   int ans = N;
   for (char c = 'a'; c <= 'z'; ++c) {
      if (!count(S.begin(), S.end(), c)) continue;
      string T = S;
      int sz = N;
      while (T != string(sz, c)) {
         string newT;
         for (int i = 0; i < sz - 1; ++i) {
            if (T[i] == c || T[i + 1] == c) {
               newT += c;
            } else {
               newT += T[i + (rand() & 1)];
            }
         }
         T = newT;
         --sz;
      }
      ans = min(ans, N - sz);
   }
   cout << ans << "\n";
   return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n, m; cin >> n >> m;
    vector<int> x(n); rep(i, n) cin >> x[i];
    sort(x.begin(), x.end());
    vector<vector<int>> y(m);
    rep(i, n) {
        y[x[i] % m].push_back(x[i]);
    }
    vector<int> cnt(m);
    rep(i, n-1) {
        if (x[i+1] == x[i]) {
            cnt[x[i]%m]++;
            i++;
        }
    }
    int ans = 0;
    rep(i, m) {
        int p1 = i;
        int p2 = (m - i) % m;
        if (p2 < p1) continue;
        // 0 の時も m/2 も対応できるので。m=1でやられないためにも下手な場合わけをしない。
        if (p2 == p1) {
            ans += y[p1].size() / 2;
            continue;
        }
        int n1 = y[p1].size();
        int n2 = y[p2].size();
        if (n1 < n2) {
            swap(p1, p2);
            swap(n1, n2);
        }

        if (2 * cnt[p1] >= n1 - n2) {
            ans += (n1 + n2) / 2;
        } else {
            ans += cnt[p1] + n2;
        }
    }

    cout << ans << endl;

    return 0;
}


    


Measured memory_bytes: 6528
//
// Created by watemus on 04.07.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FF first
#define SS second

using ll = long long;
using ld = long double;

template<typename T>
using vec = std::vector<T>;

template<typename T>
using uset = std::unordered_set<T>;

template<typename T1, typename T2>
using umap = std::unordered_map<T1, T2>;

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
const ld PI = acos(-1);
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

vec<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

void run() {
  int n, k;
  cin >> n >> k;
  vec<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(ALL(a));
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

signed main() {
#ifdef LOCAL
  std::freopen("input.txt", "r", stdin);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
#endif
  int t = 1;
  //cin >> t;
  while (t--) {
    run();
  }
  return 0;
}



Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String weather = scan.next();
		String re = "";

		switch (weather) {
		case "Sunny":
			re = "Cloudy";
			break;
		case "Cloudy":
			re = "Rainy";
			break;
		case "Rainy":
			re = "Sunny";
			break;
		}

		System.out.println(re);
		scan.close();

	}

}


Measured memory_bytes: 21588
#include<stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);


	if (a == b) {
		if (b == c)
			printf("1");else
		if (b != c)printf("2");

	}
	else	
	if (a != b) {
		if (b == c)printf("2");else
		if (a == c)printf("2");else
		if (b != c)printf("3");
	}
	else
	if (a == c) {
		if (a != b) printf("2");
	}
	

		return 0;
}				


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

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

fn main() {
    let mut n: usize = read();
    let mut m: usize = read();
    if m < n { std::mem::swap(&mut n, &mut m); }
    let ans = match (n, m) {
        (1, 1) => 1,
        (1, 2) => 0,
        (1, _) => m - 2,
        (_, _) => (n - 2) * (m - 2),
    };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <sstream>

using namespace std;

bool isPalindrome(string s) {
  return equal(s.begin(), s.end(), s.rbegin());
}

int main() {
  
  int n; cin >> n;
  string ans;
  for(int i=0;;i++) {
    int data = n-i;
    
    if(data<0) {
    }
    else {
      stringstream ss; ss << data;
      if(isPalindrome(ss.str())) {
        ans = ss.str();
        break;
      }
    }
    
    data = n+i;
    stringstream ss; ss << data;
    if(isPalindrome(ss.str())) {
      ans = ss.str();
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
static const int MAX=100;
static const int INF=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
int n,M[MAX][MAX];

int prim(){
  int u,minv,d[MAX],p[MAX],color[MAX];
  for(int i=0;i<n;i++){d[i]=INF; p[i]=-1; color[i]=WHITE;}
  d[0]=0;
  while(1){
    minv=INF; u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){u=i; minv=d[i];}
    }
    if(u==-1)break;  color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INF){
        if(d[v]>M[u][v]){d[v]=M[u][v]; p[v]=u; color[v]=GRAY;}
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){if(p[i]!=-1)sum+=M[i][p[i]];}
  return sum;
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e; cin >> e;
      if(e==-1)M[i][j]=INF;
      else M[i][j]=e;
    }
  }
  cout << prim() << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    int flag=0;
    long long int MIN=1e9;
    long long int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]<0){
            a[i]*=-1;
            flag++;
        }
        MIN=min(MIN,a[i]);
        ans+=a[i];
    }
    if(flag%2==1)ans-=(MIN*2);
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  ll N, K;
  cin >> N >> K;
  ll h[100100];
  rep(i, N) cin >> h[i];
  
  ll min_h = 10000000000000000;
  
  sort(h, h+N);
  
  rep(i, N-K+1){
  	min_h = min(min_h, h[i+K-1] - h[i]);
    //cout << min_h << endl;
  }
  
  cout << min_h << endl;
  
    
}

Measured memory_bytes: 1024
N = int(input())
a_list = [int(x) for x in input().split()]
del_list = []
cr = 1
num = 0
for i in range(N):
  if a_list[i] > i+1:
    a_list[i] = -1
for i in range(N):
  if a_list[i] == -1:
    num += 1
    continue
  if a_list[i] != cr:
    a_list[i] = -1
    continue
  cr+=1

l = [x for x in a_list if x == -1]
if len(l) == N:
  print("-1")
else:
  print(len(l))

Measured memory_bytes: 25768
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>

template<typename T>
void fin(T const& v){ std::cout << v << std::endl; exit(0); }
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<std::vector<char>> a(N, std::vector<char>(N));
  for(auto& av: a) for(auto& ai: av) std::cin >> ai;
  bool ok = false;
  int nz = -1;
  for(int i = 0; i < N; ++i) {
    for(auto ai: a[i]) if(ai=='#') { ok = true; break; }
    if(ok) { nz = i; break; }
  }
  if(!ok) fin(-1);
  
  int ans = N+N;
  for(int i = 0; i < N; ++i) {
    int j = 0;
    for(; j < N; ++j) if(a[j][i] == '#') break;
    auto ac = a;
    int c = 0;
    if(j == N) {
      ++c;
      for(int l = 0; l < N; ++l) ac[l][i] = a[nz][l];
      j = 0;
      for(; j < N; ++j) if(ac[j][i] == '#') break;
      auto acc = ac;
      for(int k = 0; k < N; ++k) if(ac[i][k] != '#') {
        ++c;
        for(int l = 0; l < N; ++l) ac[l][k] = acc[j][l];
      }
    } else {
      for(int k = 0; k < N; ++k) if(ac[i][k] != '#') {
        ++c;
        for(int l = 0; l < N; ++l) ac[l][k] = a[j][l];
      }
    }
    for(int k = 0; k < N; ++k) {
      bool ok = true;
      for(int l = 0; l < N; ++l) if(ac[l][k] != '#') { ok = false; break; }
      if(!ok) ++c;
    }
    ans = std::min(ans, c);
  }
  fin(ans);
  return 0;
}




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

int main() {
	int n;
    cin >> n;
    vector<int> V(n);
    vector<int> C(n);
    for (int i = 0; i < n; ++i) {
        cin >> V[i];  
    }
    for (int i = 0; i < n; ++i) {
        cin >> C[i];  
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int temp = V[i] > C[i] ? V[i] - C[i] : 0;
        ans += temp;
    }
    cout << ans << endl;
    return 0;
}

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

void main() {
    string str = readln.chomp;
    int n = readln.chomp.to!int;
    int a, b;
    foreach (i; 0 .. n) {
        string[] tmp = readln.chomp.split;
        a = tmp[1].to!int, b = tmp[2].to!int + 1;
        if (tmp[0] == "print") {
            str[a..b].writeln;
        } else if (tmp[0] == "reverse") {
            str = str[0..a] ~ str[a..b].to!(char[]).reverse.to!string ~ str[b..$];
        } else {
            str = str[0..a] ~ tmp[3] ~ str[b..$];
        }
    }
}


Measured memory_bytes: 2484
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++) {
        if (n % i == 0 && n / i < 10) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
namespace q1
{
    class q2
    {
        static void Main()
        {
            string[] AB = Console.ReadLine().Split();
            int A = int.Parse(AB[0]);
            int B = int.Parse(AB[1]);
            if(A>B)
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("unsafe");
            }
        }
    }
}


Measured memory_bytes: 27528
n, d = map(int, input().split())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
ans = 0
for i in range(n):
    if ( x[i] ** 2 + y[i] ** 2 ) ** 0.5 <= d:
        ans += 1

print(ans)

Measured memory_bytes: 116632
#include <iostream>
using namespace std;
int ran(int n);

int main()
{
   int N,A,B;
   int k;
   int su=0;
   cin >> N >> A >> B;
    for (int i=1;i<=N;i++)
    {
        k=ran(i);
        if ((A<=k)&(k<=B))
        {
            su=su+i;
        }
    }
    cout << su << endl;
return 0;
}

int ran(int n)
{
    int s=0;
    while (n>=10)
    {
        s=s+n%10;
        n=n/10;
    }
    s=s+n;
return s;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Contest
{


    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0];
            int m = input[1];
            int x = input[2];

            int[] c = new int[n];
            int[][] a = new int[n][];
            
            for(int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                c[i] = input[0];
                a[i] = new int[m];
                for(int j = 0; j < m; j++)
                {
                    
                    a[i][j] = input[j + 1];
                }

            }

            
            long ans = 10000000;

            for(int i = 1; i < (1 << n); i++)
            {
                int bit = 1;
                int shift = 0;
                long cost = 0;
                long[] skills = new long[m];

                while (i >= bit)
                {
                    if((i & bit) == bit)
                    {
                        cost += c[shift];
                        skills = skills.Zip(a[shift], (skill, y) => skill + y).ToArray();
                    }
                    shift++;
                    bit = bit << 1;
                }

                if(skills.All(skill => skill >= x))
                {
                    ans = Math.Min(ans, cost);
                }

            }
            if (ans == 10000000)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(ans);

            }
        }
    }
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  int n;
  cin >> n;
  int ans = (10000-n);
  ans = ans % 1000;

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


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int isPrimeNum(int x)
{
	int n;
	if (x == 2) return 1;
	if (x < 2 || x % 2 == 0) return 0;
	for (n = 3; n <= sqrt((double)x); n += 2)
		if (x % n == 0) return 0;
	return 1;
}

int main() {
	int x;
	cin >> x;
	while (!isPrimeNum(x)) x++;
	cout << x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
int p[200005];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i];
    int mn=1000000000;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(mn>=p[i]) ans++;
        mn=min(mn,p[i]);
        //cout<<mn<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

vector<vector<int>> g;
vector<int> dp;

int rec(int v){
    if (dp[v]) return dp[v];
    for(int to : g[v]){
        dp[v] = max(dp[v], rec(to)+1);
    }
    return dp[v];
}

int main(void){
    int n,m;
    cin >> n >> m;
    g.resize(n);
    dp.resize(n);
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--,y--;
        g[y].push_back(x);
    }
    int res = 0;
    rep(i,n) res = max(res,rec(i));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int s,w;
  cin>>s>>w;
  if(s<=w){
    cout<<"unsafe"<<endl;
  }
  else{
    cout<<"safe"<<endl;
  }
  return 0;
}

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

int main() {
    vector<int> v;
    int N;
    cin >> N;
    for (int i = 0; i < N;i ++) {
        int n;
        cin >> n;
        v.push_back(n);
    }

    sort(v.begin(), v.end());

    int a[100010] = {0};
    for (int i = 0; i < N; i++) {
        a[v[i]]++;
    }

    int ans = 0;
    for (int i = 0; i < 100005; i++) {
        ans = max(a[i-1] + a[i] + a[i+1], ans);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1144
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int INF = 1000000000;

vector< vector<int> > T;
int l, Size;

void Stworz(int n, vector<int> a)
{
    int p = 1;
    while (p < n)
        p *= 2;
    l = p;
    Size = 2 * p - 1;
    vector<int> x;
    for (int i = 0; i <= Size; ++i)
        T.push_back(x);
    for (int i = 0; i < n; ++i)
        T[i + l].push_back(a[i]);
    for (int i = l - 1; i >= 1; --i)
    {
        for (int j = 0; j < T[2 * i].size(); ++j)
            T[i].push_back(T[2 * i][j]);
        for (int j = 0; j < T[2 * i + 1].size(); ++j)
            T[i].push_back(T[2 * i + 1][j]);
        sort(T[i].begin(), T[i].end());
    }
}

int Ile(vector<int>& a, int x)
{
    int l = 0, p = a.size() - 1, s, r = -1;
    while (l <= p)
    {
        s = (l + p) / 2;
        if (a[s] >= x)
        {
            r = s;
            p = s - 1;
        }
        else
            l = s + 1;
    }
    if (r == -1)
        return 0;
    return a.size() - r;
}

int Pyt(int a, int b)
{
    int ogr = b + 1;
    a += l;
    b += l;
    int wyn = Ile(T[a], ogr);
    if (a != b)
        wyn += Ile(T[b], ogr);
    while (a / 2 != b / 2)
    {
        if (a % 2 == 0)
            wyn += Ile(T[a + 1], ogr);
        if (b % 2 == 1)
            wyn += Ile(T[b - 1], ogr);
        a /= 2;
        b /= 2;
    }
    return wyn;
}

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
        --a[i];
    }
    vector<int> nast(n, INF);
    vector<int> b(n);
    for (int i = n - 1; i >= 0; --i)
    {
        b[i] = nast[a[i]];
        nast[a[i]] = i;
    }
    Stworz(n, b);
    for (int i = 0; i < q; ++i)
    {
        int l, r;
        scanf("%d %d", &l, &r);
        --l;
        --r;
        printf("%d\n", Pyt(l, r));
    }
    return 0;
}


Measured memory_bytes: 99576
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 1e9 + 7;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) {
  return power(x, MOD - 2);
}

vector<ll> fact, factInv;
void initFact(int N) {
  fact.resize(N + 1);
  factInv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  factInv[N] = inverse(fact[N]);
  for (int i = N - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % MOD;
  }
}

ll choose(int n, int k) {
  if (k > n) {
    return 0;
  } else {
    return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD;
  }
}

ll f(ll pA, ll pB, ll pC, ll N) {
  ll res = 0;
  for (int b = 0; b < N; b++) {
    ll e = 1;
    e = e * power(pA, N) % MOD;
    e = e * power(pB, b) % MOD;
    e = e * choose(N - 1 + b, b) % MOD;
    e = e * (N + b) % MOD;
    e = e * inverse(power((1 - pC + MOD) % MOD, N + b + 1)) % MOD;
    res = (res + e) %  MOD;
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  initFact(300000);
  ll N, A, B, C;
  while (cin >> N >> A >> B >> C) {
    ll pA = A * inverse(100) % MOD;
    ll pB = B * inverse(100) % MOD;
    ll pC = C * inverse(100) % MOD;
    ll res = (f(pA, pB, pC, N) + f(pB, pA, pC, N)) % MOD;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 4992