akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define mod 998244353

// 文字の総和のmod 3の値は不変
// 到達不可能な状態を数える
// N != 3 なら置き換え前が存在する任意の状態に行ける

// F_mod 上でのべき乗, 蟻本p115
ll modPow(ll x, ll n) {
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + mod;
    return x;
}

ll dp[200005][3][3] = {}; // dp[N][i][j] N文字目まで並べて総和iで最後尾j

int main() {
    string S;
    cin >> S;
    int N = S.size();
    ll sum = S[N-1];
    bitset<2> flag;
    for (int i = 0; i < N - 1; ++i) {
        if (S[i] == S[i+1]) flag[0] = 1;
        else flag[1] = 1;
        sum += S[i];
    }
    if (! flag[1]) {
        cout << 1 << "\n";
        return 0;
    }

    ll ans = modPow(3, N-1);
    if (N % 3 != 0) {
        ans = sub(ans, modPow(2, N-1));
        if (! flag[0]) (ans += 1) %= mod;
    } else if (N == 3) {
        if (sum % 3) {
            ans = 6;
            if (! flag[0]) (ans += 1) %= mod;
        } else {
            ans = 3;
        }
    } else {
        dp[1][0][0] = dp[1][1][1] = dp[1][2][2] = 1;
        for (int i = 2; i <= N; ++i) {
            (dp[i][0][0] += dp[i-1][0][1] + dp[i-1][0][2]) %= mod;
            (dp[i][0][1] += dp[i-1][2][0] + dp[i-1][2][2]) %= mod;
            (dp[i][0][2] += dp[i-1][1][0] + dp[i-1][1][1]) %= mod;
            (dp[i][1][0] += dp[i-1][1][1] + dp[i-1][1][2]) %= mod;
            (dp[i][1][1] += dp[i-1][0][0] + dp[i-1][0][2]) %= mod;
            (dp[i][1][2] += dp[i-1][2][0] + dp[i-1][2][1]) %= mod;
            (dp[i][2][0] += dp[i-1][2][1] + dp[i-1][2][2]) %= mod;
            (dp[i][2][1] += dp[i-1][1][0] + dp[i-1][1][2]) %= mod;
            (dp[i][2][2] += dp[i-1][0][0] + dp[i-1][0][1]) %= mod;
        }
        ll s = (dp[N][0][0] + dp[N][0][1] + dp[N][0][2]) % mod;
        ll m = (dp[N][1][0] + dp[N][1][1] + dp[N][1][2]) % mod;
        if (sum % 3) {
            ans = sub(ans, m);
        } else {
            ans = sub(ans, s);
        }
        if (! flag[0]) (ans += 1) %= mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 14596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n-1;i++){
      if(a.at(i)==a.at(i+1)){
        cout<<"NO"<<endl;
          return 0;
      }
  }
      cout<<"YES"<<endl;
}


Measured memory_bytes: 3964
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc161
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            List<string> s = new List<string>();
            for (int i = 0; i < n; i++)
            {
                s.Add(Console.ReadLine());
            }
            var ans = s.Distinct().Count();
            Console.WriteLine(ans);


        }
    }
}

Measured memory_bytes: 48256
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
uint N, A;
cin >> N >> A;
    cout << N*N-A;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split(" "))
ab = [list(map(int, input().split(" "))) for _ in range(m)]

l = [set() for _ in range(n)]
for a_i, b_i in ab:
	l[a_i-1].add(b_i-1)
	l[b_i-1].add(a_i-1)

# print(l)

def dfs(num, visited=set()):
	visited = visited | {num}
	can_moves = l[num] - visited
	# print(num, visited, can_moves)
	if not can_moves:
		# print(visited, n)
		return (len(visited) == n)

	sum_num = 0
	for can_move in can_moves:
		sum_num += dfs(can_move, visited)
	return sum_num

print(dfs(0))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int n, i;
    vector<int> length_vec;
    cin >> n;
    for(i = 0; i < n; i++){
        int value_in;
        //cin >> length_vec[i];
        cin >> value_in;
        //length_vec[i] = value_in;
        length_vec.push_back(value_in);
    }
    sort(length_vec.begin(), length_vec.end());
    
    int length_sum = 0;
    for(i = 0; i < n - 1; i++){
        length_sum += length_vec[i];
    }
    //cout << length_sum << " " << length_vec[n - 1] << endl;
    if(length_vec[n - 1] < length_sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {

	
	// test #1
//	public static void main(String args[]) {
//		System.out.println("staring #1");
//		Scanner sc = new Scanner(System.in);
//		
//		int a = sc.nextInt();
//		
//		int b = sc.nextInt();
//		int c = sc.nextInt();
//		String s = sc.next();
//		
//		System.out.println(a+b+c+" "+s);
//		sc.close();
//	}

	// test #1  0322
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int cntN = sc.nextInt();		// 偶数
		int cntM = sc.nextInt();		// 奇数
		
		int pat1=1;
		int pat2=1;
		
		int ctr=0;
		
		// pattern 1 ( N+N )
		for (int i=cntN; i>0 && ctr<2;i--) {
			pat1=pat1*i;
			ctr++;
		}
		pat1 = pat1/2;

		
		ctr=0;
		// pattern 2 ( M+M )
		for (int i=cntM; i>0 && ctr<2; i--) {
			pat2=pat2*i;
			ctr++;
		}
		pat2 = pat2/2;
		
		log( pat1+pat2);
		sc.close();
	}

	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}
	
}


Measured memory_bytes: 23124
n = gets.to_i
words = []
blue_words = []
red_words = []
for i in 1..n
  s = gets.chomp
  words << s
  blue_words << s
end
m = gets.to_i
for i in 1..m
  t = gets.chomp
  words << t
  red_words << t
end
words.uniq!

sums = [0]
words.each do |w|
#   p "#{blue_words.count(w)} #{red_words.count(w)}"
  sums << blue_words.count(w) - red_words.count(w)
end

puts sums.max

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(r);i--)
#define se          second
#define fi          first

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    LL n, h;cin >> n >> h;
    vector<LL> a(n), b(n);
    inc(i, 0, n){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());reverse(a.begin(), a.end());
    sort(b.begin(), b.end());reverse(b.begin(), b.end());
    int i = 0;
    int j = 0;
    int ans = 0;
    while(h > 0){
        if(a[i] < b[j]){
            h -= b[j];
            ans++;
            j++;
        }else{
            ans += (h+a[i]-1)/a[i];
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
import itertools
def LI():return list(map(int,input().split()))

n,m,q=LI()
abcd=[]
for _ in range(q):
    a,b,c,d=LI()
    a-=1
    b-=1
    abcd.append((a,b,c,d))

# 数列Aの生成
Alist=itertools.combinations_with_replacement(range(m),n)
ans=0
for A in Alist:
    cnt=0
    for a,b,c,d in abcd:
        if A[b]-A[a]==c:
            cnt+=d
    ans=max(ans,cnt)
print(ans)
    

Measured memory_bytes: 67960
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;


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


#define all(c) c.begin(), c.end()


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


vector<int> prefixFunction(const string& s) {
    int n = (int)s.length();
    vector<int> res(n);
    for (int i = 1; i < n; ++i) {
        int j = res[i - 1];
        while (j > 0 && s[i] != s[j]) {
            j = res[j - 1];
        }
        if (s[i] == s[j]) {
            ++j;
        }
        res[i] = j;
    }
    return res;
}


bool isCyclic(int p, int n) {
  int k = n - p;
  if(k > 0 && k < n && n % k == 0) {
    return true;
  }
  return false;
}

void solve(istream& in, ostream& out) {
  auto s = next<string>(in);
  bool allEq = true;
  FOR(i, s.length()) if (s[i] != s[0]) {
    allEq = false;
      break;
  }
  if (allEq) {
    out << s.length() << "\n";
    out << 1 << "\n";
    return;
  }

  auto rs = s;
  reverse(all(rs));
  auto n = (int)s.length();

  auto ps = prefixFunction(s);
  auto rps = prefixFunction(rs);
  int k = n - ps[n-1];
  if (k > 0 && k < n && n % k == 0) {
    out << 2 << "\n";
    int res = 0;
    for (int i = 0; i < n-1; ++i) {
      int rn = n - (i + 1);
      int j = n - 1 - i - 1;
      if (isCyclic(ps[i], i + 1) || isCyclic(rps[j], rn)) {
        continue;
      } else {
        ++res;
      }
    }
    out << res << "\n";
  } else {
    out << 1 << "\n" << 1 << "\n";
  }
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 5276
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];

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

    for (auto &&i : s) {
        cout << i;
    }
    cout << endl;
}


Measured memory_bytes: 3668
#include<stdio.h>
int main(){
	int a,b=0,c=0,n,j,i;
	scanf("%d",&n);
	for(j=1;j<=n;j+=2)
	{for(i=1;i<=j;i++)
	{
		if(j%i==0)
		{b++;}
		
		
		
	}
	if(b==8)
	{c++;}
    b=0;
}
	

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

	


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

int M[10000000];

int main(){
  while(1){
  int n,d;
  cin>>n>>d;
  if(n==0&&d==0)break;
  
  memset(M,-1,sizeof(M));
  int cnt=0;
  while(n){
    int s = (n/d) * d;
    n -= s;
    if(M[n]!=-1)break;
    M[n] = cnt++;
    n*=10;
  }


  if(n == 0)cnt = M[n];
  cout<<M[n]<<" "<<cnt-M[n]<<endl;  
  }
  return 0;
}

Measured memory_bytes: 42112
#include <ctype.h>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;

inline std::string ToLower(const std::string& s) {
  std::string r;
  r.reserve(s.length());
  char b[2] = {0};
  for (auto c : s) {
    b[0] = tolower(c);
    r.append(b);
  }
  return r;
}

int main() {
  string w;
  cin >> w;
  w = ToLower(w);

  string s;
  size_t n = 0;
  while (cin >> s) {
    s = ToLower(s);
    if (s == "END_OF_TEXT")
      break;
    if (s == w)
      ++n;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3216
import java.util.*;
public class Main {
 
         
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            boolean [] prime = new boolean[1000001];
             for(int i=3;i<=1000000;i+=2)prime[i]=true;
             prime[2]=true;
             int limit =(int)Math.sqrt(1000000);
             for(int i=3;i<=limit;i++){
                if(prime[i]){
                    for(int j=i*i;j<=1000000;j+=i*2)prime[j]=false;
                }
            }
             
            while(true){
                int k=scan.nextInt();
                if(k==0)break;
                int ans=0;
                for(int i=2;i<=k/2;i++){
                    if(prime[i]&&prime[k-i])ans++;
                 
                }
                
                System.out.println(ans);
            }
        }
}

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

int main(){
    int N, a[120];

    cin >> N;
    for(int i = 0; i < N; i++)cin >> a[i];

    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;

    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            Alice += a[i];
        } else {
            Bob += a[i];
        } 
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include<cstdio>
const int maxn=100005;
int pos[maxn],a[maxn<<1];
int main()
{
    long long n,x,m,ans=0,pp=0,ppp=0;
    scanf("%lld%lld%lld",&n,&x,&m);
    ans+=x;
    a[1]=x;
    for (int i = 2; i <= n; i++)
    {
        x=x*x%m;
        a[i]=x;
        if(pos[x])
        {
            pp=pos[x];
            ppp=i;
            // ans+=x;
            break;
        }
        else
        {
            pos[x]=i;
            ans+=x;
        }
    }
    // printf("%lld\n",ppp);
    if(pp)
    {
        long long t=0;
        for (int i = pp; i < ppp; i++)
        {
            t+=a[i];
        }
        ans-=t;
        n-=(pp-1);
        ans+=n/(ppp-pp)*t;
        int board=pp+n%(ppp-pp);
        for (int i = pp; i < board; i++)
        {
            ans+=a[i];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2260
s = list(input())
cnt,ans = 0,[]
agct = ["A","G","C","T"]
for i in range(len(s)):
    if s[i] in agct:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
if cnt > 0:
  ans.append(cnt)
print(max(ans))


Measured memory_bytes: 9032
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
vector<int> to[200001];
int from[200001];
bool cycle[200001];
bool visited[200001];
int label[200001];

int main(){
  cin >> n;
  for(int i=0;i<n;++i){
    label[i]=-1;
    int a;
    cin>>a;
    a--;
    from[i]=a;
    to[a].push_back(i);
  }
  
  int v = 0;
  visited[0]=true;
  while(true){
    if(visited[from[v]]){
      for(int w=from[v];w!=v;w=from[w])
	cycle[w]=true;
      cycle[v]=true;
      break;
    }
    v=from[v];
    visited[v]=true;
  }
  memset(visited,0,sizeof(visited));
  
  queue<int> Q;
  for(int i=0;i<n;++i)
    if(to[i].size()==0)
      Q.push(i);
  while(!Q.empty()){
    int q = Q.front(); Q.pop();
    if(!cycle[q]){
      int x=0;
      vector<int> tolabel;
      for(int t:to[q])
	if(label[t]!=-1)
	  tolabel.push_back(label[t]);
      sort(tolabel.begin(),tolabel.end());
      for(int i:tolabel){
	if(x==i)
	  ++x;
      }
      label[q]=x;
      Q.push(from[q]);
    }
  }

  int p = -1;
  for(int i=0;i<n;++i)
    if(cycle[i])
      p=i;
  if(p==-1){
    cout << "POSSIBLE" << endl;
  }
  else{
    vector<int> tolabel;
    for(int i:to[p])
      if(label[i]!=-1)
	tolabel.push_back(label[i]);
    sort(tolabel.begin(), tolabel.end());

    int x=0;

    for(int i:tolabel)
      if(i==x)
	++x;
    int y=x+1;
    for(int i:tolabel)
      if(i==y)
	++y;
    label[p]=x;
    bool flg1 = true;
    for(int w=from[p];w!=p;w=from[w]){
      int z=0;
      vector<int> Z;
      for(int i:to[w])
	Z.push_back(label[i]);
      sort(Z.begin(), Z.end());
      for(int i:Z)
	if(z==i)
	  ++z;
      label[w]=z;
    }
    tolabel.clear();
    for(int i:to[p])
      tolabel.push_back(label[i]);
    sort(tolabel.begin(), tolabel.end());
    int r=0;
    for(int i:tolabel)
      if(i==r)
	++r;
    if(r!=x)
      flg1 = false;
	
    bool flg2 = true;
    for(int i=0;i<n;++i)
      if(cycle[i])
	label[i]=-1;
    label[p]=y;
    
    for(int w=from[p];w!=p;w=from[w]){
      int z=0;
      vector<int> Z;
      for(int i:to[w])
	Z.push_back(label[i]);
      sort(Z.begin(), Z.end());
      for(int i:Z)
	if(z==i)
	  ++z;
      label[w]=z;
    }

    tolabel.clear();
    for(int i:to[p])
      tolabel.push_back(label[i]);
    sort(tolabel.begin(), tolabel.end());
    r=0;
    for(int i:tolabel)
      if(r==i)
	++r;
    if(r!=y)
      flg2=false;

    if(!flg1 && !flg2)
      cout << "IM";
    cout << "POSSIBLE" << endl;
  }
  
  return 0;
}


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll N, P;

int main() {
    string s;
    cin >> s;
    if (s.size() < 26) {
        bool b[26] = {};
        REP(i, s.size())b[s[i] - 'a'] = true;
        REP(i, 26)if (!b[i]) {
                s += 'a' + i;
                break;
            }
        cout << s << endl;
        return 0;
    }
    string t = s;
    next_permutation(s.begin(), s.end());
    string res = "";
    REP(i, s.size()) {
        res += s[i];
        if (s[i] != t[i])break;
    }
    if (res == "a")cout << -1 << endl;
    else cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const double pi=3.1415926535;

int main(){
  double n;
  fix(12);
  cin>>n;
  co(2*pi*n);
  return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, T;
  cin>>N>>T;
  ll t[N];
  for(int i=0;i<N;++i) cin>>t[i];
  ll ans = 0;
  for(int i=1;i<N;++i) {
    if(t[i]-t[i-1]>T) ans += T;
    else ans += t[i]-t[i-1];
  }
  ans += T;
  cout<<ans<<endl;
}



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

public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
	long a=ob.nextInt();
	long b=ob.nextInt();
	long c=ob.nextInt();
	long d=ob.nextInt();
	long s1=a*c;
	long s2=a*d;
	long s3=b*c;
	long s4=b*d;
		long s5=Math.max(s1, s2);
		long s6=Math.max(s3, s4);
		System.out.println(Math.max(s5, s6));
	}
}


Measured memory_bytes: 27088
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  int n, t;
  cin >> n >> t;
  vector<pair<int, int>> a(n);;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(), a.end());
  vector<vector<long long>> dp(n + 1, vector<long long>(6666));
  for (int i = 0; i < n; i++) {
    for (int u = 0; u < t; u++) {
      dp[i + 1][u + a[i].first] = max(dp[i][u + a[i].first], dp[i][u] + a[i].second);
    }
    for (int u = 0; u < 6666; u++) {
      dp[i + 1][u] = max(dp[i + 1][u], dp[i][u]);
    }
  }
  cout << *max_element(dp[n].begin(), dp[n].end()) << '\n';
  return 0;
}

Measured memory_bytes: 156800
#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n){
    //cout << n << endl;
    if(n==0)return false;
    if(n==1)return false;
    if(n==2)return true;
    double sq = sqrt(n);
    for(long long i = 2; i <= sq; i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
int main(){
    long long x;
    cin >> x;
    while(true){
        if(isPrime(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }
    return 0;
}

Measured memory_bytes: 3660
N = int(input())
A = [int(i) for i in input().split()]

values = [int(i) for i in range(1,len(A)+1)]
A_list = dict(zip(A, values))
ans = []
for i in range(1,N+1):
  ans.append(A_list[i])
print(" ".join(map(str,ans)))


Measured memory_bytes: 25308
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    ll L,R;cin>>L>>R;
    if(R-L>2019){
        cout<<0<<endl;
        return 0;
    }
    ll ans=2018;
    rep(i,L,R) rep(j,i+1,R+1){
        ans=min(ans,(ll)i*j%2019);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//<============ Author --> @venom ============>//
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fo(i,n)           for(int i=0;i<n;i++)
#define int               long long
#define pb                emplace_back
#define mp                make_pair
#define ff                first
#define ss                second
#define all(x)            x.begin(), x.end()
#define sortall(x)        sort(all(x))
#define sortrev(x)        sort(all(x), greater<int>())
#define w(x)              int x; cin>>x; while(x--)
#define trunc(x,y)        fixed<<setprecision(y)<<x
#define mk(arr, n, type)  type *arr=new type[n];
#define PI                3.1415926535897932384626
#define mod               1000000007
#define inf               1e9 + 5
#define FIO               ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int, int>    pi;
typedef vector<int>       vi;
typedef vector<pi>        vpi;
typedef vector<vi>        vvi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
const int N = 3e5, M = N;
int mpow(int base, int exp);
int gcd(int a, int b) {if (a == 0) return b; return gcd(b % a, a);}
//<----------------------------------------------------------------------------->//
void fastIO()
{
  FIO;
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
}

char grid[1002][1002];

int solve(int n, int m)
{
  int dp[n + 1][m + 1];

  dp[n][m] = 1;

  for (int i = n; i >= 1; i--)
  {
    for (int j = m; j >= 1; j--)
    {
      if (i == n && j == m)
        continue;

      if (grid[i][j] == '#')
        dp[i][j] = 0;

      else
        dp[i][j] = (((i == n) ? 0 : dp[i + 1][j]) + ((j == m) ? 0 : dp[i][j + 1])) % mod;
    }
  }

  return dp[1][1];
}

int32_t main()
{
  FIO;

  int n, m;
  cin >> n >> m;

  for (int i = 1; i <= n; i++)
  {
    for (int j = 1; j <= m; j++)
    {
      cin >> grid[i][j];
    }
  }

  cout << solve(n, m);

  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((int)result * base) % mod;
    base = ((int)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

Measured memory_bytes: 9088
#include<stdio.h>
int main(void)
{
	int n,m,i;
	scanf("%d%d",&n,&m);
	if(n<m)
	{
		for(i=0;i<m;i++)
			printf("%d",n);
	}
	else
		for(i=0;i<n;i++)
			printf("%d",m);
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

constexpr ll INFLL = 1e18;

int main() {
    int N;
    cin >> N;
    vector<vector<pii>> g(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        g[a - 1].emplace_back(b - 1, c);
        g[b - 1].emplace_back(a - 1, c);
    }

    vector<ll> dist(N, INFLL);
    int Q, K;
    cin >> Q >> K;
    K--;
    dist[K] = 0;
    function<void(int, int, ll)> dfs = [&](int v, int p, ll sum) {
        dist[v] = sum;
        for(auto& e : g[v]) {
            if(e.first == p) continue;
            dfs(e.first, v, sum + e.second);
        }
    };
    dfs(K, -1, 0);

    while(Q--) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
}


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

using ll = long long;
constexpr ll INF = 1000000000;
constexpr ll mod = 1e9 + 7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
	string a, b;
	cin >> a >> b;

	int cnt = 0;

	for (int i = 0; i < a.length(); i++) {
		if (a[i] != b[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    string s,t;
    cin >>s >>t;

    sort(all(s));
    sort(all(t));
    reverse(all(t));
    cout << (s<t?"Yes":"No") << endl;
    return 0;
}


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

int main()
{
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int power = 0;
  for (int i = 0; i < n; i++)
    power += a[i];
  if (power >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(void){
	int N,K;
	cin >> N >> K;
	vector<int> D(K);
	for(int i=0;i<K;i++){
		cin >> D[i];
	}


	for(int i=N;1;i++){
		string s = to_string(i);
		bool ok = true;
		for(int j=0;j<s.size();j++){
			bool tmp = true;
			for(int k=0;k<K;k++){
				if(D[k] == s[j] - '0'){
					tmp = false;
					break;
				}
			}
			if(!tmp){
				ok = false;
				break;
			}
		}
		if(ok){
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    vector<bool> connect_n(n,false);
    connect_n[n-1] = true;
    vector<int> from_1;
    REP(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if(a[i]==n-1){
            connect_n[b[i]] = true;
        }
        if(b[i]==n-1){
            connect_n[a[i]] = true;
        }
        if(a[i]==0){
            from_1.push_back(b[i]);
        }
        if(b[i]==0){
            from_1.push_back(a[i]);
        }
    }
    bool res = false;
    REP(i,from_1.size()){
        if(connect_n[from_1[i]])res = true;
    }
    if(res){
        put("POSSIBLE");
    }else{
        put("IMPOSSIBLE");
    }
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll N;
  cin>>N;
  ll a[N];
  ll rui[N];
  ll ans,sum;

  sum=0;
  FOR(i,0,N-1){
    cin>>a[i];
    sum=sum+a[i];
  }
  rui[0]=a[0];
  FOR(i,1,N-1){
    rui[i]=rui[i-1]+a[i];
  }
  ans=9223372036854775800;
  FOR(i,0,N-2){
    ans=min(ans,abs(sum-2*rui[i]));
  }

  cout<<ans<<endl;



}
 


Measured memory_bytes: 3328
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[3],i,j;
    for(i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    for(j=0;j<3;j++){
        cout<<a[j];
        if(j==2){
            continue;
        }
        cout<<" ";
    }
    cout<<endl;
return 0;
}



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

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

const int INF = 1e9;

using namespace std;

int main() {
    int n;
    list<int> a;
    scanf("%d", &n);
    REP(i, n){
        char ope[11];
        scanf("%s", ope);
        if(ope[0] == 'i'){
            int x;
            scanf("%d", &x);
            a.push_front(x);
        } else if(ope[6] == 'F'){
            a.pop_front();
        } else if(ope[6] == 'L') {
            a.pop_back();
        } else if(ope[0] == 'd') {
            int x;
            scanf("%d", &x);
            for(list<int>::iterator s = a.begin(); s != a.end(); s++){
                if(*s == x){
                    a.erase(s);
                    break;
                }
            }
        }
    }

    bool first = true;
    for(list<int>::iterator s = a.begin();s != a.end();s++){
        if(first)
            first = false;
        else{
            printf(" ");
        }//cout << *s << " ";
        printf("%d", *s);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 32360
def check(A):
  check_result = []
  for i in range(1, len(A)):
    check_result.append(list(set(A[i-1])&set(A[i])))
  if len(check_result) != len(A):
    return check_result
  return False

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
result = []
for i in range(len(A)):
  A[i].pop(0)
while True:
  check_result = check(A)
  if check_result:
    A = check_result
  else:
    if not A[0]:
      print(0)
      break
    else:
      print(len(A[0]))
      break

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

#define ll long long
#define ar array

const int mxN=1e5;
int x, y, a, b, c, p[mxN+1], q[mxN+1], r[2*mxN];
ll ans;

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

	cin >> x >> y >> a >> b >> c;
	for(int i=0; i<a; ++i)
		cin >> p[i];
	sort(p, p+a);
	for(int i=0; i<b; ++i)
		cin >> q[i];
	sort(q, q+b);
	p[a]=q[b]=1e9;
	for(int i=0; i<c; ++i)
		cin >> r[i];
	c=max(x+y, c);
	sort(r, r+c);
	for(int i=0; i<x; ++i)
		ans+=p[a-1-i];
	for(int i=0; i<y; ++i)
		ans+=q[b-1-i];
	for(int i=0, j1=a-x, j2=b-y; i<x+y; ++i) {
		if(r[c-1-i]<=p[j1]&&r[c-1-i]<=q[j2])
			break;
		ans+=r[c-1-i];
		if(p[j1]<q[j2])
			ans-=p[j1++];
		else
			ans-=q[j2++];
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << *max_element(ALL(a)) - *min_element(ALL(a)) << "\n";
}

Measured memory_bytes: 3600
let cnt = ref 0

let insertion_sort (a : int array) n g =
  for i = g to n - 1 do
    let v = a.(i) in
    let j = ref (i - g) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+g) <- a.(!j);
      j := !j - g;
      incr cnt;
    done;
    a.(!j+g) <- v;
  done

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc) in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  let g = generate_g n in
  List.iter (fun g -> insertion_sort a n g) g;
  g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  let g = shell_sort a n in
  print_int (List.length g);
  print_newline ();
  match g with
  | [] -> assert false;
  | hd :: tl -> print_int hd; List.iter (fun x -> print_string " "; print_int x) tl;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

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

int a[20];
bool b[40001];
int main() {
	int n; scanf("%d", &n);
	b[0] = true;
	rep(i, n) {
		int a; scanf("%d", &a);
		for (int j = 40000; j >= a; j--)b[j] |= b[j - a];
	}
	int q; scanf("%d", &q);
	rep(i, q) {
		int m; scanf("%d", &m);
		puts(b[m] ? "yes" : "no");
	}
}

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

int main(void) {

	//0005
	/*
	int a, b, G, R, L, r;
	while (cin >> a >> b) {
		R = a;
		L = b;
		int tmp;
		if (b > a) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (1) {
			r = a%b;
			if (r == 0)break;
			a = b;
			b = r;
		}
		G = b;
		R = R / G;
		L = L / G;
		cout << G << " " << R*L * G << endl;
	}
	*/
	//0006
	/*
	string name;
	cin >> name;
	int L = name.size();
	string Ans;
	for (int i = 0; i < L; i++) {
		Ans += name.substr(L-i-1, 1);
	}
	cout << Ans << endl;
	*/
	//0007
	/*
	int Dept = 100000;
	int week;
	cin >> week;
	for (int i = 0; i < week; i++) {
		Dept = Dept * 1.05;
		if (Dept % 1000 == 0) {
			Dept = (Dept / 1000);
		}
		else {
			Dept = (Dept / 1000 + 1);
		}
		Dept = Dept * 1000;
	}
	cout << Dept << endl;
	*/
	//0008
	int a, b, c, d;
	int n;
	int count[51];
	for (int i = 0; i < 51; i++) {
		count[i] = 0;
	}
	for (a = 0; a < 10; a++) {
		for (b = 0; b < 10; b++) {
			for (c = 0; c < 10; c++) {
				for (d = 0; d < 10; d++) {
					count[a + b + c + d]++;
				}
			}
		}
	}
	while (cin >> n) {
		cout << count[n] << endl;
	}
	return 0;
}

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

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(v,a,b) for(int v=(a); v<=(b); v++)
#define fr(v,a,b) for(int v=(a); v>=(b); v--)
#define rng(v,a,b) for(int v=(a); v<(b); v++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<typename T> T& chmax(T& a, T b) { a = a > b ? a : b; return a;}
template<typename T> T& chmin(T& a, T b) { a = a < b ? a : b; return a;}
const int maxn=1e5+5;
int a[maxn];
int main()
{
	int n; cin >> n;
	int res = 0;
	fo(i,1,n) {
		cin >> a[i];
		res ^= a[i];
	}
	int cnt = 0;
	fo(i,1,n) {
		if((res ^ a[i]) == a[i]) cnt++;
	}
	if(cnt == n) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		for(int i=0;i<7;i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a-b);
		}
	}
}

Measured memory_bytes: 17364
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() << endl;
}

Measured memory_bytes: 19072
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int n, a[1000000];
vector<pair<int, int>>D;
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; D.push_back(make_pair(a[i], i)); }
	sort(D.begin(), D.end()); for (int i = 0; i < D.size(); i++)a[D[i].second] = i;
	int sum = 0;
	for (int i = 0; i < n; i += 2)if (a[i] % 2 == 1)sum++;
	cout << sum << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, x, y;
	scanf("%d%d%d", &n, &x, &y);

	int diff = abs(x-y);
	if (diff % 2 == 0) cout<<"Alice"<<endl;
	else cout<<"Borys "<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	scanf("%d", &N);
	int count[N+1];
	for(int i = 0 ; i <= N ; i++){
		count[i] = 0;
	}
	for(int i = 2 ; i <= N ; i = i+2){
		int number = 0;
		int j = i;
		while(j % 2 == 0){
			number++;
			j /= 2;
		}
		count[i] = number;
	}
	int Max, Maxindex = 1;
	for(int i = 0 ; i <= N ; i++){
		if(Max < count[i]){
			Max = count[i];
			Maxindex = i;
		}
	}
	printf("%d\n", Maxindex);
}

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

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
#define int long long

signed main(){

	int n,x,y;
	cin>>n;
	int a[1000000]={0};
	for(int i=0;i<n;i++){
		cin>>x>>y;
		for(int j=x;j<=y;j++){
			a[j]++;
		}
	}

	// for(int i=0;i<20;i++){
	// 	cout<<a[i]<<" ";
	// }cout<<endl;

	int ans=0;

	for(int i=0;i<100001;i++){
		if(a[i]!=0)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	puts((10*b+c)%4==0?"YES":"NO");
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {  
      int n,x;
      cin>>n>>x;
      int sum=0;
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
          sum+=a[i];
      }
      sort(a,a+n);
      int ans=(x-sum)/a[0];
      cout<<ans+n;
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3656
n=int(input())
s=input()
c=s.count
r,g,b=c('R'),c('G'),c('B')
t=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=j*2-i
    if k<n:
      if s[i]+s[j]+s[k] in ('RGB','RBG','GRB','GBR','BRG','BGR'):
        t+=1
print(r*g*b-t)

Measured memory_bytes: 68352
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

template <class T> int digits_sum(T x) {
    int ans = 0;
    while (x != 0) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

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

    ll N;
    cin >> N;

    ll ans = INF64;
    FOR(a, 1, N) {
        ll b   = N - a;
        ll sum = digits_sum(a) + digits_sum(b);
        chmin(ans, sum);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
ABC = sorted(list(map(int, input().split())))
if (ABC[2]%2 == ABC[1]%2 and ABC[2]%2 != ABC[0]%2) or (ABC[2]%2 != ABC[1]%2 and ABC[2]%2 == ABC[0]%2):
    print(1+((ABC[2]+1)*2-(ABC[0]+ABC[1]+1))//2)
else:
    print((ABC[2]*2-(ABC[0]+ABC[1]))//2)


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

using namespace std;

int main()
{
    int n;

    while (cin >> n) {
        int arr[n];

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

        int dp[n];

        for (int i = 0; i < n; i++) dp[i] = 1e9;

        dp[0] = 0;

        for (int i = 1; i < n; i++) {
            if (i - 1 >= 0) {
                dp[i] = min(dp[i], dp[i - 1] + abs(arr[i] - arr[i - 1]));
            }
            if (i - 2 >= 0) {
                dp[i] = min(dp[i], dp[i - 2] + abs(arr[i] - arr[i - 2]));
            }
        }

        cout << dp[n - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1024