akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int res = 0;
    for (int a=0; a <= A; ++a){
        for (int b=0; b <= B; ++b){
            for (int c=0; c <= C; ++c){
                int total = 500*a + 100*b + 50*c;
                if (total == X) ++res;
            }
        }
    }
    cout << res << endl;
}


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

int main(){
    long long int N;
    cin>>N;
    long long int A,B;
    long long int min=9223372036854775807;
    for(long long int i=1;i<=sqrt(N);i++){
        if(N%i==0){
            if((N/i)-1<min){
                min=((N/i)-1);
                B=i;
                A=(N/i);
            }
        }
    }
    cout<<A+B-2<<endl;
    return 0;
}

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

int main(){
    ll a,b;
    ll v,w;
    ll t;
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    ll kyori=abs(a-b);
    ll sa=v-w;
    if(sa*t>=kyori)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
int main()
{
    char s[100],i,a,x=0;
    scanf("%s",&s);
    a=strlen(s);
    for(i=0;i<a;i++){
        if((i+1)%2!=0&&s[i+1]=='R'){
            printf("No\n");
            x=1;
            break;
        }
        else if((i+1)%2==0&&s[i+1]=='L'){
            printf("No\n");
            x=1;
            break;
        }
        if(s[0]=='L'){
            printf("No\n");
            x=1;
            break;
        }
    }
    if(x==0){
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
const int INF = 1000000000000;
signed main() {
	int n, m, no = 0; string s; cin >> n >> m >> s;
	vector<int>cnt;
	reverse(s.begin(), s.end());
	for (int h = 0; h <= n; h++) {
		for (int i = min(n - h, m); i > 0; i--) {
			if (s[h + i] == '0') { 
				if (h + i == n) {
					cnt.push_back(i);
					reverse(cnt.begin(),cnt.end());
					for (int j = 0; j < cnt.size(); j++) {
						if (j == 0) { cout << cnt[j]; }
						else { cout << ' ' << cnt[j]; }
					}
					cout << endl;
					return 0;
				}
				cnt.push_back(i); h = h + i - 1; no = 1;
				break;
			}
		}
		if (no == 0) { cout << -1 << endl; return 0; }no = 0;
	}
	return 0;
}

Measured memory_bytes: 1528
def get_collision(A,ans):
    A.sort()
    nowkey = -10**10
    prevcoor = -10**10
    ret = ans[0]
    for key, coor, a in A:
        if key != nowkey:
            if a == 1:
                nowkey = key
                prevcoor = coor
                continue
            else:
                continue
        if a == 1:
            prevcoor = coor
            continue
        if (coor - prevcoor)*5 < ret:
            ret = (coor - prevcoor)*5
    ans[0] = ret

def main():
    N = int( input())
    XYU = [ tuple( input().split()) for _ in range(N)]
    U = []
    R = []
    D = []
    L = []
    for x, y, u in XYU:
        x, y = int(x), int(y)
        if u == "U":
            U.append((x,y))
        elif u == "D":
            D.append((x,y))
        elif u == "L":
            L.append((x,y))
        else:
            R.append((x,y))
    ans = [10**10]

    UD = [(x,y,1) for x, y in U] + [(x,y,-1) for x, y in D]
    get_collision(UD, ans)
    LR = [(y,x,1) for x, y in R] + [(y,x,-1) for x, y in L]
    get_collision(LR, ans)
    RU = [(x+y,x-y,1) for x, y in R] + [(x+y,x-y,-1) for x,y in U]
    get_collision(RU, ans)
    LD = [(x+y,x-y,1) for x, y in D] + [(x+y,x-y,-1) for x,y in L]
    get_collision(LD,ans)
    LU = [(x-y,x+y,1) for x,y in U] + [(x-y,x+y,-1) for x,y in L]
    get_collision(LU,ans)
    RD = [(x-y,x+y,1) for x,y in R] + [(x-y,x+y,-1) for x,y in D]
    get_collision(RD,ans)
    if ans[0] < 10**10:
        print(ans[0])
    else:
        print("SAFE")
        
if __name__ == '__main__':
    main()


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

money = 1000
ad = 0
for i in range(n - 1):
    if a[i + 1] > a[i]:
        buy_stock = (money // a[i])
        buy_money = buy_stock * a[i]
        sel = buy_stock * a[i + 1]
        remain = money - buy_money
        money = remain + sel
    #print(money)

print(money)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll n,k;
ll ar[100001][3];
ll dp[100001][3]={0};
int main()
{
	cin>>n;
	for(ll i=0;i<n;i++)
	cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
	for(ll i=0;i<3;i++)
	dp[0][i]=ar[0][i];
	for(ll i=1;i<100001;i++)
	{
		for(ll j=0;j<3;j++)
		{
			for(ll k=0;k<3;k++)
			if(j!=k)
			dp[i][j]=max(dp[i][j],ar[i][j]+dp[i-1][k]);
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
 int k,a,b;
  cin>>k>>a>>b;
  int flag=0;
  for(int i=a;i<=b;i++){
   if(i%k==0){
     flag=1;
     break;
   }
  }
  if(flag==1)
    cout<<"OK\n";
  else
    cout<<"NG\n";
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int n;
int a[55];
bool check(){
	for (int i=1;i<n;i++)
		if (a[i]+1!=a[i+1]) return false;
	return true;
}
int main()

{
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i];

	if (check()){
		cout<<"YES"<<endl;
		return 0;
	}
	
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if (i!=j){
				swap(a[i],a[j]);
				if (check()){
					cout<<"YES"<<endl;
					return 0;
				}
				swap(a[i],a[j]);
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 384
# coding: utf-8

II = lambda: int(input())
MI = lambda: map(int, input().split())


def make_cells(h, w):
    cells = set()
    for i in range(h):
        for j in range(w):
            cells.add((i, j))
    return cells

def make_bcells(h, w, m):
    cells = set()
    for i in range(h):
        for j in range(w):
            if m[i][j]:
                cells.add((i, j))
    return cells


def search(sc, bcells_yet, m, H, W):
    valid = lambda cell: cell[0] >= 0 and cell[0] < H and cell[1] >= 0 and cell[1] < W
    color = lambda cell: m[cell[0]][cell[1]]

    ccnt = {0:0, 1:1}
    wcells_searched = set()

    q = set()
    q.add(sc)
    while len(q) > 0:
        c = q.pop()
        dirs = filter(valid, [(c[0] + 1, c[1]), (c[0] - 1, c[1]), (c[0], c[1] + 1), (c[0], c[1] - 1)])
        for nc in dirs:
            if color(nc) != color(c):
                if color(nc) and nc in bcells_yet:
                    bcells_yet.remove(nc)
                    ccnt[1] += 1
                    q.add(nc)
                elif not color(nc) and nc not in wcells_searched:
                    wcells_searched.add(nc)
                    ccnt[0] += 1
                    q.add(nc)
    return ccnt[0] * ccnt[1]


def main():
    H, W = MI()

    m = []
    for h in range(H):
        m.append(tuple(map(lambda c:c == "#", input())))

    bcells = make_bcells(H, W, m)

    ans = 0
    while len(bcells) > 0:
        ans += search(bcells.pop(), bcells, m, H, W)
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 18408
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && a == c){
        cout << 1 << endl;
    }
    else if(a == b || a == c || b == c){
        cout << 2 << endl;
    }
    else{
        cout << 3 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long s = cin.Long();
			// S = x2y3 - x3y2
			long x1 = 0;
			long y1 = 0;
			long x2 = 1000000000;
			long y2 = -1;
			long y3 = s / x2;
			long x3 = s % x2;

			if (x3 == 0) {
				Console.WriteLine($"{x1} {y1} {x2} {1} {x3} {y3}");
			} else {
				Console.WriteLine($"{x1} {y1 + 1} {x2} {y2 + 1} {x3} {y3 + 1}");
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char s[3005], t[3005];
	cin >> s >> t;
	int n = strlen(s);
	int m = strlen(t);

	// creates the dp table of longest common length
	vector<vector<int>> dp (n+1, vector<int> (m+1, 0));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i-1] == t[j-1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	// now we just need to figure out the actual string
	int longest = dp[n][m];
	char ans[longest];
	int count = longest - 1;
	while (n > 0 && m > 0) {
		if (s[n-1] == t[m-1]) {
			ans[count] = s[n-1];
			n--; m--;
			count--;
		} else {
			if (dp[n][m-1] > dp[n-1][m])
				m--;
			else 
				n--;
		}
	}
	for (auto ch : ans)
		cout << ch;
}

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

using namespace std;

int main() {

    int n;
    cin >> n;

    pair<int, int> data[n];

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

    double sol = 0;
    for(int r = 0; r < 100; r++) {
        random_shuffle(data, data + n);
        for(int i = 0; i < n; i++) {
            double x = data[i].first, y = data[i].second, c = sqrt(pow(x, 2) + pow(y, 2));
            for(int j = 0; j < n; j++) {
                if(i == j) continue;
                x += data[j].first;
                y += data[j].second;
                double length = sqrt(pow(x, 2) + pow(y, 2));
                if(length > c) c = length;
                else {
                    x -= data[j].first;
                    y -= data[j].second;
                }
            }
            sol = max(c, sol);
        }
    }

    cout << fixed << setprecision(20) << sol << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())

mod = 10**9 + 7
MAX = 1_000_000


def gen_primes(n):
    n = int(n**0.5) + 2
    is_prime = [True]*n
    is_prime[0] = is_prime[1] = False
    for i in range(2, n):
        if is_prime[i]:
            for j in range(2*i, n, i):
                is_prime[j] = False
    return [i for i, flag in enumerate(is_prime) if flag]


C = [0]*(MAX+1)
primes = gen_primes(MAX)


def prime_fact(n):
    cnt = 0
    for p in primes:
        if n % p:
            continue
        while n % p == 0:
            cnt += 1
            n //= p
        C[p] = max(C[p], cnt)
        cnt = 0
    if n != 1:
        C[n] = 1


for a in A:
    prime_fact(a)

lcm = 1
for i, c in enumerate(C):
    if c:
        lcm = lcm * pow(i, c, mod) % mod

ans = 0
for a in A:
    ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod
print(ans)


Measured memory_bytes: 17740
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

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

  int32_t N;
  cin >> N;
  vector<int32_t> A(N);
  for (int32_t i = 0; i < N; ++i) {
    int32_t a;
    cin >> a;
    A[a - 1] = i + 1;
  }
  for (int32_t i = 0; i < N; ++i) {
    if (i != 0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define mp(a,b)   make_pair(a,b)
#define ll        long long
#define mp(a,b)   make_pair(a,b)
#define si(n)     scanf("%d",&n)
#define sl(n)     scanf("%lld",&n)
#define pi(n)     printf("%d\n",n)
#define pl(n)     printf("%lld\n",n)
#define           newline cout << endl;
#define           ff first
#define           ss second
#define           pii pair<int, int>
#define           pll pair<ll, ll>
using namespace std;

template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}

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

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int main(){
  //clock_t tStart = clock();
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  int X[n],Y[m];
  for(int i=0;i<n;i++){
    cin >> X[i];
  }
  sort(X,X+n);
  for(int i=0;i<m;i++){
    cin >> Y[i];
  }
  sort(Y,Y+m);
  bool f = 0;
  for(int i=x+1;i<=y;i++){
    // trace("X,y,i",X[n-1],Y[m-1],i);
    if(X[n-1]<i && Y[0]>=i){
      f=1;
      break;
    }
  }
  if(f){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
  //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}

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

int check(vector <int> &A, int rank, int sum, vector <int> &num){
	if (rank < A.size()){
		check(A, rank+1, sum, num);
		int tmp = sum + A[rank];
		if (tmp < num.size()){
			check(A, rank+1, tmp, num);
		}
	}else{
		num[sum]=1;
	}

	return 0;
}

int main(void){
	int n, q, max_m=0, rank=0, sum=0;

	cin >> n;
	vector <int> A(n);
	for(int i=0; i<n; i++){
		cin >> A[i];
	}

	cin >> q;
	vector <int> M(q);
	for(int i=0; i<q; i++){
		cin >> M[i];
		if (M[i]>max_m) max_m = M[i];
	}
	vector <int> num(max_m+1);
	check(A, rank, sum, num);

	for (int i=0; i<q; i++){
		if (num[M[i]]==1) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

def calc(S):
    N = len(S)
    r = 0
    d = [0] * 2019
    p = 1
    d[0] = 1
    for i in range(N):
        r = (r + int(S[N - 1 - i]) * p) % 2019
        p = (p * 10) % 2019
        d[r] += 1
    ans = 0
    for c in d:
        ans += c * (c - 1) // 2
    return ans


S = input()
print(calc(S))

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

using namespace std;

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    auto getRadian = [](double x, double y) {
        return atan2(x, y);
    };

    double V = a * a * b;
    double rad;
    if (x * 2 > V) {
        double d = 2 * (V - x) / (a * a);
        rad = getRadian(a, d);
    } else {
        double d = 2 * x / (a * b);
        rad = getRadian(d, b);
    }
    cout.precision(10);
    cout << 90 - rad * 180 / M_PI;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string>
#include<string.h>
using namespace std;

int main(){
	for (int a = 0;; a++){
		int n;
		int s[1001];
		cin >> n;
		if (n == 0)break;
		double ave = 0;
		for (int i = 1; i <= n; i++){
			cin >> s[i];
			ave += s[i];
		}
		double m = ave / n;
		double A = 0;
		for (int j = 1; j <= n; j++){
			A+=((s[j] - m)*(s[j] - m));
		}
		A /= n;
		printf("%f\n", sqrt(A));
	}
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
int main()
{
string h;
cin>>h;
for (int i = 0; i < h.length()-1; i++)
{
    if(h[i]==h[i+1])
    return cout<<"Bad",0;
}
cout<<"Good"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  VEC<int>a(m);
  VEC<int>cs(n+1,0);
  REP(i,0,m){
    int a ;
    cin>>a;
    ++cs[a];
  }    
  REP(i,1,n+1){
    cs[i]+=cs[i-1];
  }
  cout<<min(cs[n]-cs[x], cs[x])<<endl;

  return 0;
}


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

using namespace std;

const long long mod = 1000000007;

long long A, B;

long long xs[100100];
int N;

const long long inf = 1e18;

long long dp[100100];

long long sum[100100];

long long get(int l, int r){
	// [l, r]
	if(l > r) return 0;
	if(l == 0) return sum[r];
	return sum[r] - sum[l - 1];
}

long long solve(){
/*	xs[0] = -inf;
	xs[N - 1] = inf * 3;
	for(int i = 0; i < vec.size(); ++i){
		xs[i + 1] = vec[i];
	}*/
	for(int i = 0; i < N; ++i){
		dp[i] = 0;
	}
	dp[0] = 1;
	for(int i = 0; i < N; ++i){
		sum[i] = 0;
	}
	sum[0] = 1;
	int l = 0, r = 0;
	for(int i = 1; i < N; ++i){
		dp[i] = get(l, r);
		if(i + 1 == N) break;
		while(xs[i + 1] - xs[r + 1] >= B) r++;
		if(xs[i] - xs[i - 1] >= A){
			// nothing
		}else if(xs[i] - xs[i - 2] >= A){
			l = i - 1;
		}else{
			l = i;
		}
		sum[i] = (sum[i - 1] + dp[i]) % mod;
	}
	long long ans = dp[N - 1];
	ans %= mod;
	ans += mod;
	ans %= mod;
	return ans;
}

void input(){
	scanf("%d", &N);
	scanf("%lld%lld", &A, &B);
	if(A > B) swap(A, B);
	xs[0] = -inf;
	for(int i = 1; i <= N; ++i){
		scanf("%lld", xs + i);
	}
	xs[N + 1] = inf * 3;
	N += 2;
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2688
K, N = map(int, input().split())
A = list(map(int, input().split()))
d_A = []
for i in range(N - 1):
  d_A.append(A[i + 1] - A[i])
d_A.append(K - A[N - 1] + A[0])
print(K - max(d_A))

Measured memory_bytes: 86140
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	add := A + B
	sub := A - B
	mul := A * B
	max := -100000000
	for _, x := range []int{add, sub, mul} {
		if x > max {
			max = x
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn bellman_ford(n: usize, m:usize, es: &mut [(usize, usize, i64)], s:usize, t:usize) -> Option<i64> {
    let mut dist = vec![1<<50;n];
    dist[s] = 0;
    let mut count = 0;
    let mut upd = vec![false;n];
    let mut dwn = vec![false;n];
    upd[s] = true;
    dwn[t] = true;
    // st
    loop { // this loop V-1
        count+=1;
        let mut update = false;
        for i in 0..m {
            if dist[es[i].0] != 1<<50 && dist[es[i].1] > dist[es[i].0] + es[i].2 {
                dist[es[i].1] = dist[es[i].0] + es[i].2;
                update = true;
            }
            upd[es[i].1] |= upd[es[i].0];
            dwn[es[i].0] |= dwn[es[i].1];
        }
        if update == false {
            break;
        }
        if count >= n{
            break;
        }
    }

    // println!("{:?}", upd);
    // println!("{:?}", dwn);
    for i in 0..m {
        if upd[es[i].1] && dwn[es[i].1] && dist[es[i].1] > dist[es[i].0] + es[i].2 {
            return None;
        }
    }
    Some(dist[t])
}

fn main() {
    input!{
        n:usize,
        m:usize,
        p:i64,
        mut es: [(usize1, usize1, i64);m],    
    }
    for i in 0..m {
        es[i].2 = p - es[i].2;
    }
    // println!("{:?}", es);
    let mut ans:i64 = -1;
    match bellman_ford(n,m,&mut es,0,n-1) {
        Some(s) => {
            ans = std::cmp::max(0,-s)
        },
        None => {}
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;
import java.math.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    BigInteger[] A = new BigInteger[N];
    BigInteger sum = BigInteger.ONE;
    
    for(int i=0; i<N; i++){
      A[i] = sc.nextBigInteger();
      if(A[i].compareTo(BigInteger.ZERO) == 0){
        System.out.println(0);
        System.exit(0);
      }
    }
    
    for(int i=0; i<N; i++){
      sum = sum.multiply(A[i]);
      if(sum.compareTo(new BigInteger("1000000000000000000")) == 1){
        System.out.println(-1);
        System.exit(0);
      }
    }
    
    System.out.println(sum);
  }
}

Measured memory_bytes: 69304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string S,T;
    cin>>S>>T;
    rep(i,S.size()){
        if(S.at(i)!=T.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int kiyaku(int n) {
	int ans = n;
	for (int i = 2; i <= n; i++) {
		if (prime(i)) {
			if (n%i == 0) {
				ans /= i;
				ans *= (i - 1);
			}
		}
	}
	return ans;
}
/*Library End!*/

signed main() {
	int n, m;
	cin >> n >> m;
	cout << ((n - m) * 100 + m * 1900)*pow(2, m) << endl;
	endre;
}


Measured memory_bytes: 256
import kotlin.math.*
fun main(args: Array<String>) {
    var (n, m) = readLine()!!.split(" ").map{it.toLong()}
    if (n%2 == 1L) {
        for (i in 1..m) {
            println("${i} ${n-i+1}") 
        }
    } else {
        for (i in 1..m) {
            if (n-i-i+1 > n/2)
                println("${i} ${n-i+1}")
            else
                println("${i} ${n-i}")
        }
    }
}


Measured memory_bytes: 56160
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=10100;i++)
    {
        int x=(8*i)/100,y=(10*i)/100;
        if(a==x&&b==y) 
        {
            cout<<i;
            return 0;
        }
    }
    cout<<"-1";
}
    

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  REP(i, n) { cin >> a[i]; }
  double mid = 0;
  REP(i, n) { mid += a[i]; }
  mid /= n;

  int ans = 0;
  double m = 10000;
  REP(i, n) {
    if (m > abs(a[i] - mid)) {
      ans = i;
      m = abs(a[i] - mid);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    string s;
    int ans;
    cin >> s;
    int s_size = s.size();
    int start, end;
    for (int i = 0; i < s_size - 1; i++) {
    	if (s[i] == 'A') {
    		start = i;
    		break;
    	}
    }

   	for (int i = s_size - 1; i > 0; i--) {
    	if (s[i] == 'Z') {
    		end = i;
    		break;
    	}
    }
    ans = end - start + 1;
    cout << ans << endl;
}


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

using namespace std;

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

  int N;
  cin >> N;

  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());

  long long ans = 0;
  for (int a = 0; a < N; a++) {
    for (int b = a + 1; b < N; b++) {
      int idx = lower_bound(L.begin(), L.end(), L[a] + L[b]) - L.begin();
      int ng = N - idx;
      ans += (N - b - 1 - ng);
    }
  }
  cout << ans << "\n";

  return 0;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
	string s; cin >> s; cout << s.substr(0, 3) << endl;
}

Measured memory_bytes: 3572
def collatz(n):
    return n // 2 if n % 2 == 0 else 3 * n + 1


def solve(string):
    s = int(string)
    checks = set([])
    for _ in range(10**6):
        if s in checks:
            break
        else:
            checks.add(s)
            s = collatz(s)
    return str(len(checks) + 1)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int n; cin>>n;
    vector<int> S(n);
    REP(i,n) cin >> S[i];
    int q; cin >> q;
    vector<int> T(n);
    REP(i,q)  cin>>T[i];
    int ans = 0;
    REP(i,q){
        if(binary_search(ALL(S),T[i])) ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String low_az = "abcdefghijklmnopqrstuvwxyz";
		String up_az =  "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		String str="";
		int[] cnt;

		cnt = new int[low_az.length()];

		for ( int i = 0 ; i < low_az.length() ; i ++ ) {
			cnt[i]=0;
		}

		Scanner sc= new Scanner( System.in );

		while( sc.hasNext() ) {

			str = sc.nextLine();

			for ( int j = 0 ; j < str.length() ; j++ ) {
				for ( int i = 0 ; i < low_az.length() ; i ++ ) {
					if ( str.charAt(j) == low_az.charAt(i) || str.charAt(j) == up_az.charAt(i) ) {
						cnt[i]++;
					}
				}
			}
		}

		for ( int i = 0 ; i < low_az.length() ; i ++ ) {

			System.out.println( low_az.charAt(i) + " : " + cnt[i] );
		}
		sc.close();
	}
}


Measured memory_bytes: 26080
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def ceil(x,y):
  return (x-1)//y+1


def solve_binary(mid,k):
    return k < XH[mid][0]

def binary_search(s,n,k):
    ok=n
    ng=s
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve_binary(mid,k):
            ok=mid
        else:
            ng=mid
    return ok

n,D,A=map(int,input().split())
XH=[tuple(map(int,input().split())) for i in range(n)]
XH.sort(key=lambda tup: tup[0])
XH.append((inf,0))
data=[0]*(n+1)
if D==0:
    for xi,hi in XH:
        count += ceil(hi,A)
        # print(count)
    print(count)
    exit()
for i in range(n):
    xi,hi = XH[i]
    hi-=data[i]
    K=max(0,ceil(hi,A)*A); count += max(0,ceil(hi,A))
    data[i]+=K; data[binary_search(i,n,xi+2*D)]-=K
    data[i+1]+=data[i]
print(count)
# print(data)

Measured memory_bytes: 78684
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b&&a != 0) {
		if (a < b)swap(a, b);
		int num = 0;
		while (b) {
			a %= b;
			swap(a, b);
			++num;
		}
		cout << a << ' ' << num << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)

int main(){
    int a,b;
    cin>>a>>b;
    a=a-1, b=b-1;
    cout<<(b+a-1)/a<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e6 + 9;

const int M = 998244353, G = 3;

int qpow(int a, int b) {
 if(b == 0) return 1;
 int t = qpow(a, b/2);
 t = t * t % M;
 if(b & 1) return t * a % M;
 else return t;
}

int inv(int n) {
 return qpow(n, M - 2);
}

int pos[N];

void NTT(int* a, int k, bool inverse = false) {
 for(int i=1;i<(1<<k);i++) pos[i] = (pos[i>>1] >> 1) | ((i & 1) << (k - 1));
 for(int i=0;i<(1<<k);i++) if(pos[i] < i) swap(a[pos[i]], a[i]);
 for(int len = 2; len <= (1 << k); len <<= 1) {
  int omega = qpow(G, (M - 1) / len);
  if(inverse) omega = inv(omega);
  for(int i = 0; i < (1 << k); i += len) {
   int cur = 1;
   for(int j = i; j < i + len / 2; j++) {
    int l = a[j], r = a[j+len/2];
    a[j] = (l + r * cur % M) % M;
    a[j+len/2] = (l - r * cur % M + M) % M;
    cur = cur * omega % M;
   }
  }
 }
}

int a[N], b[N];

signed main()
{
 
 int n, m, k;
 cin >> n >> m >> k;
 int boook = 18;
 a[0] = m;
 b[0] = m - 1;
 b[1] = 1;
 NTT(a, boook);
 NTT(b, boook);
 for(int i = 0; i < (1 << boook); i++) {
  a[i] = a[i] * qpow(b[i], n-1) % M;
 }
 NTT(a, boook, true);
 int ans = 0;
 for(int i = 0; i <= k; i++) {
  ans += a[i] * inv(1 << boook) % M;
 }
 ans %= M;
 cout << ans << endl;
}


Measured memory_bytes: 9748
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(){
  const ll C=200000;
  int i,j,cnt=0;
  int n,m;
  cin>>n>>m;
  int x[m],y[m];
  for(i=0;i<m;i++)cin>>x[i]>>y[i];
  int flg=0;
  ll p[n+1];
  p[1]=C;
  for(i=2;i<=n;i++)p[i]=1;
  for(i=0;i<m;i++){
    if(p[x[i]]>=C){
      p[x[i]]-=C;
      p[y[i]]+=C;
    }else{
      p[x[i]]--;
      p[y[i]]++;
    }
    if(p[y[i]]>C)p[y[i]]+=(p[y[i]]%C)*(C-1);
  }
  for(i=1;i<=n;i++){
    if(p[i]>=C)cnt++;
  }
  cout<<cnt;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans = 999;
  for(int i = 0; i < N - 2; i++){
    int num = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + S[i+2] - '0';
    ans = min(ans, abs(num - 753));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
int main(){
    string s;
    cin>>s;
    transform(s.begin(),s.end(),s.begin(),::tolower);
    int ans=0;
    while(true){
        string u;
        cin>>u;
        if(u=="END_OF_TEXT")break;
        transform(u.begin(),u.end(),u.begin(),::tolower);
        if(s==u)ans++;
        
        
    }
    
    cout<<ans<<endl;
    
    return 0;
}


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

island = [[]for i in range(n+1)]

for i in range(m):
    a,b = map(int, input().split(' '))
    island[a].append(b)
    island[b].append(a)

flag = True

for i in island[1]:
    for k in island[i]:
        if k == n:
            print('POSSIBLE')
            flag = False
            break
    if flag is False:
        break

if flag is True:
    print('IMPOSSIBLE') 


Measured memory_bytes: 38320
//#include <tourist>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
using mint = modint998244353;
struct S
{
    mint x, w;
    S(mint x = 0, mint w = 1) : x(x), w(w) {} //コンストラクタ,メンバイニシャライザ
};
S op(S a, S b)
{
    return S(a.x * b.w + b.x, a.w * b.w);
}
S e()
{
    return S(); //デフォルトをコンストラクタで単位元を指定した
}

S mapping(int f, S a)
{
    if (f == 0)
        return a;
    return S((a.w - 1) / 9 * f, a.w);
}
//f○gはgが先
int composition(int f, int g)
{
    if (f == 0)
        return g;
    return f;
}
int id() { return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, q;
    cin >> n >> q;
    lazy_segtree<S, op, e, int, mapping, composition, id> t(n);
    rep(i,n){
        t.set(i,S(1,10));
    }
    rep(i,q){
        int l,r,d;
        cin>>l>>r>>d;
        --l;
        t.apply(l,r,d);
        cout<<t.prod(0,n).x.val()<<"\n";
    }
}

Measured memory_bytes: 9840
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll A, B, C;
  cin >> A >> B >> C;
  ll K;
  cin >> K;
  ll counter = 0;
  while(A>=B){
    B*=2;
    counter++;
  }
  while(B>=C){
    C*=2;
    counter++;
  }
  if(counter <= K) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3648
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CXYZTriplets solver = new CXYZTriplets();
        solver.solve(1, in, out);
        out.close();
    }

    static class CXYZTriplets {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int[] dp = new int[6 * (int) 1e4 + 1];

            for (int x = 1; x < 100; x++) {
                for (int y = 1; y < 100; y++) {
                    for (int z = 1; z < 100; z++) {
                        int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                        dp[tmp]++;
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= n; i++)
                sb.append(dp[i] + "\n");

            System.out.print(sb);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 36920
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define f0(s,a,b) for(lli s=a;s<b;s++)
#define f1(s,a,b) for(lli s=a;s<=b;s++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define print(x) cout<< #x <<"=" <<x<<"\n";
#define out(x) cout<<x;
#define  Y cout<<"YES\n";
#define N cout<<"NO\n";

int main()
{
    fast
    set < string > st;
    lli n;
    string  s;
    cin>>n;
    while(n--)
    {   
        cin>>s;
       // print(s)
        st.insert(s);

    }
    cout<<(lli)st.size();

}
//a+b=a⊕b+2∗(a &b)
//__builtin_popcount(number)
//cout<<fixed<<setpricision(8)<<output<<"\n";

Measured memory_bytes: 19244
import sys
from operator import itemgetter
import collections
import math


def r(n, a):
    a.sort(reverse=True)
    side = [0, 0]
    s = 0
    i = 0
    for i in range(s, n - 1):
        if a[i] == a[i + 1]:
            side[0] = a[i]
            break
    s = i + 2
    for i in range(s, n - 1):
    	if a[i] == a[i + 1]:
            side[1] = a[i]
            break
    return side[0] * side[1]


def main():
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    print(r(n, a))


if __name__ == '__main__':
    main()


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

#define zcin(type, a) type a; cin >> a;
#define zcout(a, sep1, b, sep2) cout << a << sep1 << b << sep2;
#define zfor(i, b, n) for (int i = b; i < n; ++i)
#define pb push_back
#define pi 3.14159

using namespace std;

int main()
{
	#ifdef ME
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif

	zcin(int, r);
	
	cout << 2*pi*r;


	return 0;
}


Measured memory_bytes: 3788
N, Q = map(int, input().split())
L, R = [None] * Q, [None] * Q

S = input()

for i in range(Q):
    L[i], R[i] = map(int, input().split())

counts = [0] * N
count_tmp = 0
is_before_char_A = False

for i in range(N):
    if S[i] == 'A':
        is_before_char_A = True
        counts[i] = count_tmp
        continue
    if S[i] == 'C' and is_before_char_A:
        count_tmp += 1

    counts[i] = count_tmp
    is_before_char_A = False
    #if S[i-1] == 'A' and S[i] == 'C':
    #    count_tmp += 1

# print(counts)

for i in range(Q):
    print(counts[R[i] - 1] - counts[L[i] - 1])

Measured memory_bytes: 58456
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int N;
  cin>>N;
    cout<<N*(N+1)/2;
return 0;}


Measured memory_bytes: 3460
n = int(input())
action = []
for i in range(n):
    action.append(list(map(int,input().split())))

memo = []
for i in range(n):
    memo.append([-1]*3)

def dp(i, a):
    if i == 0:
        return action[0][a]
    elif memo[i][a] != -1:
        return memo[i][a]
    else:
        memo[i][a] = max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]
        return memo[i][a]

import sys
sys.setrecursionlimit(1000000)
print(max([dp(n-1,a) for a in range(3)]))


Measured memory_bytes: 180504
def post(P, I):
    if len(I)==0:
        return ""
    elif len(I)==1:
        return I[0]
    else:
        root = I.index(P[0])
        right = len(P)
        for i in I[root+1:]:
            if P.index(i) < right:
                right = P.index(i)
        return post(P[1:right],I[:root]) + " " + post(P[right:], I[root+1:]) + " " + I[root]
    
n = int(input())
P = input().split()
I = input().split()
ans = ""
for i in post(P,I).split():
    ans+=i + " "
print(ans[:-1])


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()%
//#define int long long

signed main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    
    int ans = 0;
    reps(i,1,n-2){
        if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
        if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256