akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int bit[2][200000];
void add(int t,int k,int x){
	while(k<200000){
		bit[t][k]+=x;
		k+=k&-k;
	}
}
int sum(int t,int k){
	int res=0;
	while(k){
		res+=bit[t][k];
		k-=k&-k;
	}
	return res;
}

vector<int>dat[2][50000];
int p[2][5000];

void init(int t,int k, int l, int r) {
	if (r - l == 1) {
		dat[t][k].push_back(p[t][l]); return;
	}
	int lb = k * 2 + 1, rb = k * 2 + 2;
	init(t,lb, l, (l + r) / 2);
	init(t,rb, (l + r) / 2, r);
	dat[t][k].resize(r - l);
	merge(dat[t][lb].begin(), dat[t][lb].end(), dat[t][rb].begin(), dat[t][rb].end(), dat[t][k].begin());
}
int query(int t,int a, int b, int c, int d, int k, int l, int r) {//[a,b),[c,d)
	if (b <= l || r <= a)return 0;
	if (a <= l&&r <= b) {
		int u = lower_bound(dat[t][k].begin(), dat[t][k].end(), d) - dat[t][k].begin();
		int v = lower_bound(dat[t][k].begin(), dat[t][k].end(), c) - dat[t][k].begin();
		return u - v;
	}
	int lb = query(t,a, b, c, d, k * 2 + 1, l, (l + r) / 2);
	int rb = query(t,a, b, c, d, k * 2 + 2, (l + r) / 2, r);
	return lb + rb;
}

string c[5000];
int a[5000];
ll dp[3000][3000];


signed main(){
	int n;scanf("%d",&n);
	rep(i,2*n){
		cin>>c[i]>>a[i];a[i]--;
		if(c[i]=="B"){
			p[0][a[i]]=i;
		}
		else{
			p[1][a[i]]=i;
		}
	}
	ll ans=0;
	int c1=0,c2=0;
	rep(i,2*n){
		if(c[i]=="B"){
			ans+=c1-sum(0,a[i]+1);
			c1++;
			add(0,a[i]+1,1);
		}
		else{
			ans+=c2-sum(1,a[i]+1);
			c2++;
			add(1,a[i]+1,1);
		}
	}
	int N=1;while(N<n)N<<=1;
	rep(i,2)init(i,0,0,N);
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	rep(i,n+1)rep(j,n+1){
		if(i<n){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+query(1,0,j,p[0][i],INF,0,0,N));
		}
		if(j<n){
			dp[i][j+1]=min(dp[i][j+1],dp[i][j]+query(0,0,i,p[1][j],INF,0,0,N));
		}
	}
	//for(int i=1;i<=n;i++)cout<<p[1][i]<<' ';
	//cout<<endl;
	/*rep(i,n+1){
		rep(j,n+1)cout<<dp[i][j]<<' ';
		cout<<endl;
	}*/
	cout<<dp[n][n]+ans<<endl;
}

Measured memory_bytes: 74496
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
def main():
    N, M, K = map(int, readline().split())
    A = [int(i) for i in readline().split()]
    B = [int(i) for i in readline().split()]

    #方針:A,Bそれぞれ前からi,j番目までとったときの合計がK以内であるときのi+jを求める
    #A,Bそれぞれの山の一番上の本だけを比較して時間が小さい方を選ぶことを繰り返すのは間違い。

    csumA = [0]
    for i in range(N):
        csumA.append(csumA[i] + A[i])

    csumB = [0]
    for i in range(M):
        csumB.append(csumB[i] + B[i])

    mx = 0
    for i in range(N+1):
        # r:= Aの山の上からi番目までの本を読むとき、残りの時間
        r = K-csumA[i]
        if r < 0:
            break
        left = -1
        right = M+1
        while right-left>1: 
            mid = (left+right)//2
            if r >= csumB[mid]:
                left = mid
            else:
                right = mid

        mx = max(mx, i+left)
    print(mx)

if __name__ == '__main__':
    main()


Measured memory_bytes: 140100
#include <iostream>
#include <math.h>

using namespace std;

int main(){
	int a[101] = {0};
	int b;
	int MAX = 0;

	while(cin >> b){
		a[b]++;
	}
	for(int j=1; j<101; j++){
		MAX = max(MAX, a[j]);
	}
	for(int m=1; m<101; m++){
		if(MAX == a[m]){
			cout << m << endl;
 		}
	}
}

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

void solve() {
    int n;
    cin >> n;
    bool fl = true;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x % 2 == 0) {
            fl &= (x % 3 == 0 || x % 5 == 0);
        }
    }
    if (fl) {
        cout << "APPROVED\n";
    } else {
        cout << "DENIED\n";
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string z;
int M,A,R,C,H;
int main(){
    while(cin>>z){
        switch(z[0]){
            case 'M':M++;break;
            case 'A':A++;break;
            case 'R':R++;break;
            case 'C':C++;break;
            case 'H':H++;break;
        }
    }
    long long int x=C+H,y=A+R,v=A*R,t=C*H;
    cout<<v*(M+x)+t*(M+y)+(M*x*y)<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N;
    cin>>N;
    vector<ll> A(N);
    ll ans=0;
    rep(i,N){
        if(i==0)cin>>A.at(i);
        else{
            cin>>A.at(i);
            if(A.at(i)<A.at(i-1)){
                ans+=A.at(i-1)-A.at(i);
                A.at(i)=A.at(i-1);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4764
N = input()
A = map(int, raw_input().split())

P = []
N = []
for a in A:
  if a>=0:
    P += [a]
  else:
    N += [a]
P.sort()
N.sort()

if len(N)%2==0:
  print sum(P)+sum(-t for t in N)
elif len(P)>0:
  print sum(P[1:])+sum(-t for t in N[:-1])+abs(P[0]+N[-1])
else:
  print sum(-t for t in N[:-1])+N[-1]


Measured memory_bytes: 11320
n = gets.to_i
d = gets.split.map(&:to_i)
m = gets.to_i
t = gets.split.map(&:to_i)

if m > n
  puts 'NO'
  exit
end

d.sort!
t.sort!

d.each do |nn|
  if t.empty?
    puts "YES"
    exit
  end
  if nn == t[0]
    t.shift
  end
end

if !t.empty?
  puts "NO"
else
  puts "YES"
end


Measured memory_bytes: 30588
n, m, s = map(int, input().split())
uvab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(n)]

M = 50 * n + 1
s = min(s, M - 1)

dp = [[float('inf')] * M for _ in range(n)]

import math
dp[0][s] = 0
c, d = cd[0][0], cd[0][1]
for jj in range(M):
    dp[0][jj] = min(dp[0][jj], dp[0][s] + max(math.ceil((jj - s) / c), 0) * d)

while True:
    flag = False

    for i in range(m):
        u1, v1, a, b = uvab[i][0] - 1, uvab[i][1] - 1, uvab[i][2], uvab[i][3]
        for u, v in [(u1, v1), (v1, u1)]:
            for j in range(M - a):
                tmp = dp[u][j + a] + b
                if tmp < dp[v][j]:
                    dp[v][j] = tmp
                    flag = True

            if flag:
                c, d = cd[v][0], cd[v][1]
                for jj in range(c, M):
                    tmp = dp[v][jj - c] + d
                    if tmp < dp[v][jj]:
                        dp[v][jj] = tmp

    if flag == False:
        break

for t in range(1, n):
    print(min(dp[t]))


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

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a >= k){
        cout << k << endl;
        return 0;
    }
    if(a + b >= k){
        cout << a << endl;
        return 0;
    }
    cout << 2*a + b - k << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
#define VMAX 10000

int main(){
    unsigned short *A, *B, maxNum = 0;
    int C[VMAX+1] = {};
    int n;
    
    scanf("%d", &n);
    
    A = (unsigned short*)malloc(sizeof(unsigned short)*n+1);
    B = (unsigned short*)malloc(sizeof(unsigned short)*n+1);
    
    for(int i = 0;i < n;++i){
        scanf("%hu",&A[i + 1]);
        maxNum = max(maxNum,A[i + 1]);
        C[A[i + 1]]++;
    }
    
    for(int i = 1;i <= maxNum;++i){
        C[i] = C[i] + C[i - 1];
    }
    
    for(int i = 1;i <= n;++i){
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }
    
    for(int i = 1;i <= n;++i){
        if(i > 1){
            printf(" ");
        }
        printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 10476
N,M = map(int,input().split())
A = []
B = []

for i in range(M):
  a,b = map(int,input().split())
  if a == 1:
    B.append(b)
  if b == N:
    A.append(a)

if len(set(A) & set(B)) != 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 27656
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
vector<int> preo, ino;

//memo
/*
   3 - 4 - 1
   p = [4] 3 1
   i = 3 [4] 1
   pos = 3 1 [4]

  							*fake binary search?* 
   4(root) -> in.4(root) -> p.(hidari)(ppos:1) range:inpos:0-1
   			  (orpos:1)  -> p.(migi)(ppos:2) range:inpos:2-(3)
			  			 -> print: 3 1 4
   */
void search(int l, int r){
	if(l >= r)return;
	static int i = 0;
	int j;
	int orpos;
	static bool zero = true; 
	int root = preo[i++];
	for(j=0;j<(int)ino.size();j++){
		if(ino[j] == root)
			break;
	}
	search(l, j);
	search(j+1, r);
	if(!zero) printf(" ");
	else zero = false;
	printf("%d", root);
}

int main(){
	int i, n;
	cin >> n;
	int tmp;
	rep(i, n){
		cin >> tmp;
		preo.pback(tmp);
	}
	rep(i, n){
		cin >> tmp;
		ino.pback(tmp);
	}
	search(0, n);
	cout << endl;
}



Measured memory_bytes: 3292
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n;
    ll d, a, ans = 0;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> v(n);
    vector<ll> sum(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; ++i) {
        if (i > 0)
            sum[i] += sum[i - 1];
        ll val = v[i].second - sum[i];
        if (val > 0) {
            ll cnt = val / a + (val % a > 0);
            ans += cnt;
            int suf = upper_bound(v.begin(), v.end(), make_pair(v[i].first + d * 2, INFL)) - v.begin();        
            sum[i] += cnt * a;
            sum[suf] -= cnt * a;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#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());
  int tmp = a.at(0);
  int flag = 0;
  for (int i = 1; i < a.size(); i++)
  {
    if(tmp == a.at(i)){
      flag = 1;
      cout << "NO";
      break;
    }
    tmp = a.at(i);
  }
  if(flag==0)
    cout << "YES";
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll mod = 1000000007, oo = 1000000009;

void Emsawy() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

#define clr(v,d)     memset(v, d, sizeof(v))
#define sz(v)	     ((int)((v).size()))
#define all(v)	     ((v).begin()), ((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define V	         vector
#define MP	         make_pair
#define bug(n)           cout<< #n <<" = "<< n << endl;
int dx[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, -1, 1 };

V<V<int> > adj;
const ll N = 1000 + 5;
int n, m, k, w;
ll a[N][3];

ll go(int mask) {
	V<ll> ans;
	for (int i = 0; i < n; i++) {
		ans.push_back(0);
		for (int j = 0; j < 3; j++) {
			if ((mask & (1 << j)))
				ans.back() += a[i][j] * -1;
			else
				ans.back() += a[i][j];
		}
	}
	sort(allr(ans));
	ll ret = 0;
	for (int i = 0; i < m; i++) {
		ret += ans[i];
	}
	return ret;
}

int main() {

	//Emsawy(); 
	while (cin >> n >> m) {
		for (int i = 0; i < n; i++)
			cin >> a[i][0] >> a[i][1] >> a[i][2];
		ll ans = 0;
		for (int i = 0; i < 8; i++) {
			ans = max(ans, go(i));
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin >> s;
  if(s==1||s==2){
    cout << 4 << endl;
    return 0;
  }
  int count=1;
  while(s!=4){
    if(s%2==0)
      s/=2;
    else
      s=3*s+1;
    count++;
  }
  cout << count+3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<long long> arr(n + 1), pre_sum(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		pre_sum[i] = pre_sum[i - 1] + arr[i];
	}

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

	long long ans = 0;
	int curr = 1;
	for (int i = 1; i <= n; ++i) {
		if (pre_sum[i] == pre_sum[i - 1]) {
			++curr;
		} else {
			ans += (long long) curr * (curr - 1) / 2;
			curr = 1;
		}
	}

	ans += (long long) curr * (curr - 1) / 2;
	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 6344
#include<iostream>
using namespace std;
int a[3][3],b[3][3];
main()
{
	for(int j=0;j<3;j++)
	{
		for(int i=0;i<3;i++)cin>>a[j][i];
		for(int i=1;i<3;i++)b[j][i-1]=a[j][i]-a[j][0];
	}
	int f=1;
	for(int i=0;i<2;i++)
	{
		f&=b[0][i]==b[1][i]&&b[0][i]==b[2][i];
	}
	cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int X,Y,x,y,r;
    cin>>X>>Y>>x>>y>>r;
    if( (x-r)>=0 && (x+r)<=X && (y-r)>=0 && (y+r)<=Y){cout<<"Yes"<<endl;}
    else {cout<<"No"<<endl;}
    return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
const double pi=3.14159265358979;
int main(){
	double a,b,c,h,m,i,j,k;
	cin>>a>>b>>h>>m;
	k=abs(h*30-m*5.5);
	k/=180.0;k*=pi;
	c=a*a+b*b-2*a*b*cos(k);
	c=sqrt(c);
	printf("%.12lf",c);
}

Measured memory_bytes: 4240
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    if N==0:
        if A[0] == 1:
            print(1)
        else:
            print(-1) 
        return 
    
    s = [0]*(N+1)
    s[N] = A[N]
    for i in range(N-1, -1, -1):
        s[i] = s[i+1] + A[i] 

    leafs = 0
    ans = 0
    for i, a in enumerate(A):
        leafs = leafs*2 + a
        rem = pow(2,i) - leafs
        if i<N:
            # print(sum(A[i+1:]), s[i+1])
            k = min(rem, s[i+1])
            ans+=k
    # print(leafs)

    rem = pow(2,N) - leafs    
    if rem<0:
        print(-1)
        return
    print(ans+sum(A))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 0 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 82140
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

// int main() {
//     ios::sync_with_stdio(false);
//     cin.tie(0);
    
//     int n;
//     cin >> n;
//     vi a(n);
//     rep(i, n) cin >> a[i];
//     deque<int> d;
//     rep(i, n) {
//         int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
//         if (p == 0) d.push_front(a[i]);
//         else d[p-1] = a[i];
//     }
//     cout << sz(d) << endl;
// }

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    reverse(a.begin(), a.end());
    // aの最長広義単調増加列の長さ
    vi dp(n, INF);
    rep(i, n) {
        int p = upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
        dp[p] = a[i];
    }
    int ans = -1;
    rep(i, n) {
        if (dp[i] == INF) {
            ans = i;
            break;
        }
    }
    if (ans == -1) ans = n;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
using namespace std;
int main(){
  int n;cin>>n;
  map<string, int> l;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    l.try_emplace(s,1);
  }
  cout << l.size() << endl;
  return 0;
}  


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

int main(void){
	long n;
	scanf("%ld", &n);
	char name[15] = "";
	int i = 0;
	do{
		n--;
		name[i++] = 'a' + n % 26;
		name[i] = '\0';
		n = n / 26;
	}while(n);
	i--;
	while(i >= 0)
		putchar(name[i--]);
	putchar(10);
	return 0;
}


Measured memory_bytes: 2004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll gcd(int a, int b)
{
    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, (a % b));
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N)
    {
        cin >> A.at(i);
    }
    sort(all(A));
    ll ans = gcd(A.at(1), A.at(0));
    rep(i, 2, N)
    {
        ans = gcd(A.at(i), ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;

int main() {
    int S, W;
    cin >> S >> W;
    if(W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
/* ダイトストラ法自作ライブラリ*/
/* option1:経路復元 => TRACE_ROUTE定義,trace配列に復元情報 
   option2:全頂点への最短距離 => ALL_VERTEX定義,ans配列に情報*/
/*頂点の開始番号を気をつける必要なし*/
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define dump1d_arr(array,i) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array,i,j) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define loINF (long)10000000000
#define shINF (short)10000
#define SORT(c) sort((c).begin(),(c).end())
#define ALL_VERTEX
//#define TRACE_ROUTE

using namespace std;
typedef pair<long,long> pr;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first;
	}
};
typedef priority_queue<pr,vector<pr>,Order> pq;
typedef vector<char> VC;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<pr> VP;
typedef vector<VP> VVP;

// global変数
long V;		//頂点数
VVP cost;	//辺の情報
long s;

#ifdef ALL_VERTEX
	VL ans;
#endif // ALL_VERTEX

#ifdef TRACE_ROUTE
	VL trace;
#endif // TRACE_ROUTE

//入力 
void input_gragh(void){
	long E; 
	long ver1,ver2,dis;

	cin >> V >> E >> s;		//V:頂点数 , E:辺数
	cost = VVP(V+1,VP(0)); // 辺の情報。隣接リスト

	REP(i,E){ //辺の情報を格納する。
		cin >> ver1 >> ver2 >> dis;
		/*有向グラフ ver1 ==> ver2 */
		cost[ver1].push_back(make_pair(ver2,dis));
	}
}

// 最短距離を返す ,  -1 :連結でない , loINF : ALL_VERTEX , 
long dijekstra(long start,long end){
	pq distance;
	pr minver;
	VC used(V+1,0);

	#ifdef ALL_VERTEX
		ans = VL(V+1,loINF); 
		end = -(loINF);
	#endif // ALL_VERTEX

	distance.push(make_pair(0,start));	//初期化 スタートの頂点は距離0

	while (!distance.empty()) {
		minver = distance.top();
		distance.pop();
		if (used[minver.second]) continue; //すでに使った頂点なら飛ばす

		#ifdef TRACE_ROUTE
			trace.push_back(minver.second); // 経路復元用に、確定した頂点の情報を格納
		#endif
		
		if (minver.second == end) break; //ゴールについたらやめる
		else {
			used[minver.second] = 1;    //頂点を使ったことを記録
			#ifdef ALL_VERTEX
				ans[minver.second] = minver.first;
			#endif // ALL_VERTEX
		}

		REP(i,cost[minver.second].size()) {
			if (used[cost[minver.second][i].first]) continue;
			distance.push(make_pair(minver.first+cost[minver.second][i].second,cost[minver.second][i].first));
		}	
	}
	#ifndef ALL_VERTEX
		if (minver.second == end) return minver.first; //最小距離を返す
		else return -1;
	#endif	
	return loINF; // 全ての頂点の最短距離を調べた。(ansを見る)
}

int main (void){
	input_gragh();
	long start = s;

	#ifdef ALL_VERTEX 
		if (dijekstra(start,loINF) == loINF){
			REP(i,ans.size()-1) {
				if (ans[i] == loINF) cout << "INF" << endl;
				else  cout << ans[i] << endl;
			}	//全頂点に対する距離の表示
		}
		exit(0);
	#endif

	long end;
	cin >> end;

	long ans_val = dijekstra(start,end);
	
	if (ans_val == -1) cerr << "Not connected" << endl; //連結でなかった場合。
	else {
		#ifdef TRACE_ROUTE
			REP(i,trace.size()) cout << trace[i] << endl; //経路復元
		#endif
		cout << ans_val << endl; 	//最短距離の表示
	}

 	return 0;
 }






Measured memory_bytes: 23960
for i in range(int(raw_input())):
	n,d = map(int, raw_input().split())
	if i == 0:
		a,b = n,d
	else:
		q = max((a+n-1)/n, (b+d-1)/d)
		a = n*q
		b = d*q



print a+b

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

typedef long long ll;

struct UnionFind {
	vector<ll> par, siz;

	UnionFind(ll N) : par(N), siz(N) {
		for(ll i = 0; i < N; ++i) { par[i] = i; siz[i] = 1; }
	}

	ll root(ll x){
		if(par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(ll x, ll y){
		ll rx = root(x);
		ll ry = root(y);
		if(rx == ry) return;

		if(siz[rx] < siz[ry]) swap(rx, ry);
		siz[rx] += siz[ry];
		par[ry] = rx;
	}

	bool same(ll x, ll y){
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}

	ll size(ll x){
		return siz[root(x)];
	}
};

int main(){
	ll N, M; cin >> N >> M;
	UnionFind uf(N);
	vector<ll> ans(M, 0);
	vector< pair<ll, ll> > input(M);

	for(ll i = 0; i < M; ++i){
		cin >> input[i].first >> input[i].second;
		input[i].first--;
		input[i].second--;
	}

	ans[M-1] = N*(N-1) / 2;
	for(ll i = M-1; i >= 1; --i){
		ll f = input[i].first, s = input[i].second;
		if(!uf.same(f, s)){
			ans[i-1] = ans[i] - uf.size(f) * uf.size(s);
		}else{
			ans[i-1] = ans[i];
		}
		uf.unite(f, s);
	}

	for(ll i = 0; i < M; ++i) cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		long[] map = new long[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextLong();
		}
		
		long[] l = new long[N];
		l[0] = map[0];
		for (int i = 1; i < N; i++) {
			l[i] = gcd(l[i-1], map[i]);
		}
		
		long[] r = new long[N];
		r[N-1] = map[N-1];
		for (int i = N-2; 0 <= i; i--) {
			r[i] = gcd(r[i+1], map[i]);
		}
		
		
		long ans = 0;
		for (int i = 0; i < N; i++) {
			if (i == 0) {
				ans = Math.max(ans, r[i+1]);
			} else if (i == N-1) {
				ans = Math.max(ans, l[i-1]);
			} else {
				ans = Math.max(ans, gcd(l[i-1], r[i+1]));
			}
		}
		
		
		System.out.println(ans);
		
	}
	
	
	static long gcd(long x, long y) {
		long tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }
        return y;
	}
	
}



Measured memory_bytes: 59556
import math
def dist(a,b,n):
    s=0
    m=0
    for i in range(len(a)):
        d=math.fabs(b[i]-a[i])
        m=max(m,d)
        s+=d**n
    return (s**(1/n),m)

n=int(input())
a=list(map(float,input().split()))
b=list(map(float,input().split()))
print('%.6f'%(dist(a,b,1)[0]))
print('%.6f'%(dist(a,b,2)[0]))
print('%.6f'%(dist(a,b,3)[0]))
print('%.6f'%(dist(a,b,1)[1]))

Measured memory_bytes: 7940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <set>

#define ll long long int
using namespace std;
void Solve()
{
    string s;
    cin >> s;
    vector<int> o(124);
    for(int i=0; i<s.size(); i++)
    {
        o [s[i] ]++;
    }
    for(int i=0; i<o.size(); i++)
    {
        if(o[i] & 1)
        {
            cout << "No";
            return;
        }
    }
    cout << "Yes";
    return;
}

int main()
{
    ios_base::sync_with_stdio( false );
    cin.tie( nullptr );
    {
        Solve();
        cout << '\n';
    }
    return 0;
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = LLONG_MAX;
const int inf = INT_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vector<vi> G(n);
    rep(i, m){
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    rep(i, n){
        cout << G[i].size() << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) ((a) & 1 == (b) & 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

ll N,M;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M;
	if(N * 2 >= M) esc(M / 2);
	ll k = qceil(M / 2 - N,2);
	ll ans = M / 2 - k;
	if(k) ans = max(ans,N + k - 1);
	esc(ans);
}




Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int partition(int A[],int p,int r){
    int x = A[r];
    int i = p-1;
    for(int j = p; j < r; j++){
        if(A[j] <= x){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}
 
int main(){
    int n,partition_point;
    scanf("%d",&n);
    int A[n];
    for(int i = 0; i < n; i++) scanf("%d",&A[i]);
 
    partition_point = partition(A,0,n-1);
 
    for(int i = 0; i < n-1; i++){
        if(i == partition_point){
            printf("[%d] ",A[i]);
        }else{
            printf("%d ",A[i]);
        }
    }
    if(partition_point == n-1){
        printf("[%d]\n",A[n-1]);
    }else{
        printf("%d\n",A[n-1]);
    }
}


Measured memory_bytes: 2980
#include <iostream>

int main(){
  long long w, h, x, y;
  std::cin >> w >> h >> x >> y;
  std::cout << w * h / 2.0 << " ";
  if (x * 2 == w && y * 2 == h) std::cout << 1;
  else std::cout << 0;
  std::cout << std::endl;
}

Measured memory_bytes: 256
import sys
N = int(input())
h = [int(a) for a in input().split()]

ans = 0
for j in range(max(h),0,-1):
    cnt=0
    for i in range(N):
        if cnt==0 and h[i]==j:
            cnt=1
            h[i]-=1

        elif cnt==1 and h[i] == j:
            h[i]-=1

        elif cnt==1 and h[i]!=j:
            cnt=0
            ans +=1


    if cnt ==1:
        ans+=1
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B, C;
    cin >> A >> B >> C;

    ll able[B];
    rep(i, B){
        able[i] = 0;
    }

    ll rBase = A % B;
    ll r = rBase;
    ll ans = 0;
    while(able[r] != 1){
        able[r] = 1;
        if(r == C){
            ans = 1;
            break;
        }
        r += rBase;
        r %= B;
    }

    if(ans == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a), ed_##i = (b); i <= ed_##i; ++i)

#define N 4010
int A, B, n;
int d[N], t;
char f[N], g[5];

int main() {
    scanf("%d%d", &A, &B);
    n = A + B;
    if(A <= B) return puts("Impossible"), 0;
    FOR(i, 0, n - 1){
        if(!t) d[++t] = i;
        else{
            printf("? %d %d\n", d[t], i), fflush(stdout);
            scanf("%s", g);
            *g == 'Y' ? d[++t] = i : --t;
        }
    }
    const int u = d[t];
    f[u] = 49;
    FOR(i, 0, n - 1) if(i != u){
        printf("? %d %d\n", u, i), fflush(stdout);
        scanf("%s", g);
        f[i] = (*g == 'Y') + 48;
    }
    printf("! %s\n", f), fflush(stdout);
    return 0;
}

Measured memory_bytes: 3872
s=list(input())
t=set()
for i in s:
  t.add(i)
for i in range(len(s)-1):
  t.add(s[i]+s[i+1])
for i in range(len(s)-2):
  t.add(s[i]+s[i+1]+s[i+2])
for i in range(len(s)-3):
  t.add(s[i]+s[i+1]+s[i+2]+s[i+3])
for i in range(len(s)-4):
  t.add(s[i]+s[i+1]+s[i+2]+s[i+3]+s[i+4])
u=list(t)
u.sort()
print(u[int(input())-1])

Measured memory_bytes: 4564
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18


void solve()
{
   int x,n,index[303]={0};
   cin>>x>>n;
   int arr[n+3];
   for(int i=1;i<=n;i++) { cin>>arr[i]; index[arr[i]]=1; }
   int A=x;
   int B=x;
   int ans1,ans2;
   for(int i=1;i<=150;i++)
   {
      if(index[A]==0) { ans1=A; break; }
      A++;
   }
   for(int i=1;i<=150;i++)
   {
      B--;
      if(B>=0)
      {
         if(index[B]==0) { ans2=B; break; }
      }
   }
   int AA=abs(x-A);
   int BB=abs(x-B);
   if(AA>=BB) cout<<B<<endl;
   else cout<<A<<endl;

}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; scanf("%d",&t); while(t--) solve();
    solve();
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define INF 1L << 50

signed main() {
  int d, g;
  cin >> d >> g;
  int p[d], c[d];
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
  }
  int ans = INF;
  for (int bit = 0; bit < (1 << d); bit++) {
    int problem = 0;
    int point = 0;
    for (int i = 0; i < d; i++) {
      if ((bit >> i) & 1) {
        problem += p[i];
        point += (1 + i) * 100 * p[i] + c[i];
      }
    }
    if (point >= g) {
      ans = min(ans, problem);
      continue;
    }
    for (int i = 0; i < d; i++) {
      if ((bit >> i) & 1) continue;
      if ((g - point) / ((i + 1) * 100) <= p[i]) {
        problem += (g - point) / ((i + 1) * 100);
        ans = min(ans, problem);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    s = a[0]

    for x in a[1:]:
        s ^= x

    res = [0] * n
    for i, x in enumerate(a):
        res[i] = s ^ x

    print(*res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97760
import math
from decimal import Decimal

A, B = input("").split()
A = int(A)
k = int(B[0]) * 100
k = k + int(B[2]) * 10
k = k + int(B[3])

result = Decimal(A*k) / Decimal(100)
result = math.trunc(result)

print(result)

Measured memory_bytes: 10092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)


int main(){
    int a, b;
    cin >> a >> b;
    if(a > 8 || b > 8){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll n; cin>>n;
 if(n>=1000) cout<<"ABD"<<endl;
  else cout<<"ABC"<<endl;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

# ユークリッドの互除法
# a が最大公約数になっている
while b:
    a, b = b, a % b

a_divisors = []

for i in range(1, int(a ** 0.5) + 1) :
    if a % i == 0 :
        a_divisors.append(i)
        if a // i != i :
            a_divisors.append(a // i)

a_divisors.sort()

print(a_divisors[len(a_divisors) - k])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    rep(i, N) --a[i];
    
    vector<int> pushed(N, 0);
    int cnt = 0;
    int now = 0;
    while (now != 1) {
        if (pushed[now]) {
            cout << -1 << endl;
            return 0;
        }
        pushed[now] = 1;
        now = a[now];
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
    int A,B,C,D,X,Y,N,L,M,P,Q;
    int ans = 0;
    cin>>A>>B;
        cout<<max(A+B,max(A-B,A*B))<<endl;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cmath>
     
    using namespace std;
     
    unsigned long long int N, l, m = 9999999999999;
     
    unsigned long long int ten(unsigned long long int ou);
     
    int main(){
    	
    	cin >> N;
    	
    	for(unsigned long long int i=1 ;i <= sqrt(N); i++){
    		if((N % i)==0 ){
    			l = ten(N/i);
    			if(l < m) m = l;
    		}
    	}
    	cout << m;
    }
     
    unsigned long long int ten(unsigned long long int ou){
    	unsigned long long int i;
    	for(i = 1; ;i++){
    		ou /= 10;
    		if(ou == 0) break;
    	}
    	return i;
    }

Measured memory_bytes: 256
#include<iostream>
using namespace std; 
typedef long long int ull;
void solve(string s) {
    ull res = 0;
    for(ull i = 0; i < s.length(); i++)
        res = ( res + (s[i] - '0') );
	if(res%9==0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}
int main()
{
	string str;
	getline(cin,str);
	solve(str);
}

Measured memory_bytes: 3776
s = input()
t = input()
s_length = len(s)
t_length = len(t)

dp = [[0]*(t_length + 1) for _ in range(s_length + 1)]
for i in range(s_length):
    for j in range(t_length):
        if s[i]==t[j]:
            dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j+1])
        
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1])

ans=""
i = s_length
j = t_length
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i-=1
    elif dp[i][j] == dp[i][j-1]:
        j-=1
    else:
        ans = s[i-1] + ans
        i-=1
        j-=1
print(ans)


Measured memory_bytes: 144564
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int solve(int size, int init, const string& s, const string& t)
{
    int left = 0;
    int right = size - 1;

    int n = s.size();
    for(int i=n-1; i>=0; --i){
        if(t[i] == 'L')
            right = min(right + 1, size - 1);
        else if(t[i] == 'R')
            left = max(left - 1, 0);

        if(s[i] == 'L')
            ++ left;
        else if(s[i] == 'R')
            -- right;
        if(left > right)
            return false;
    }

    return left <= init && init <= right;
}

int main()
{
    int n;
    vector<int> size(2), init(2);
    vector<string> s(2), sy(2), sx(2);

    for(int i=0; i<2; ++i)
        cin >> size[i];
    cin >> n;
    for(int i=0; i<2; ++i){
        cin >> init[i];
        -- init[i];
    }
    for(int i=0; i<2; ++i){
        cin >> s[i];
        sy[i].resize(n, '.');
        sx[i].resize(n, '.');
        for(int j=0; j<n; ++j){
            if(s[i][j] == 'L')
                sx[i][j] = 'L';
            else if(s[i][j] == 'R')
                sx[i][j] = 'R';
            else if(s[i][j] == 'U')
                sy[i][j] = 'L';
            else
                sy[i][j] = 'R';
        }
    }

    if(solve(size[0], init[0], sy[0], sy[1]) && solve(size[1], init[1], sx[0], sx[1]))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 1544
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main()
{
	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	printf("%.9f\n",sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)));
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<char> vec;
	rep(i, n) {
		if (i == 0) {
			vec.emplace_back(s[i]);
			continue;
		}
		if (vec.back() != s[i]) vec.emplace_back(s[i]);
	}
	cout << vec.size() << endl;
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

const int maxn = 1005;
int n;
int x[maxn], y[maxn], r[maxn];
bool vis[maxn];
double dis[maxn];

vector<pair<int, double> > G[maxn];

void add(int u, int v, double w){
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
}

double dijkstra(int s, int t){
    memset(vis, 0, sizeof(vis));
    for(int i = 0;i <= n + 1;i++){
        dis[i] = 1e18;
    }
    dis[s] = 0.0;
    priority_queue<pair<double, int> , vector<pair<double, int> >, greater<pair<double, int> > > pq;
    pq.push(make_pair(0, s));
    while(!pq.empty()){
        pair<double, int> p = pq.top();
        int u = p.second;
        pq.pop();
        if(vis[u])
            continue;
        vis[u] = true;
        for(auto edge : G[u]){
            int v = edge.first;
            double cost = edge.second;
            if(cost + dis[u] < dis[v]){
                dis[v] = dis[u] + cost;
                pq.push(make_pair(dis[v], v));
            }
        }
    }
    return dis[t];
}

int xs, ys, xt, yt;

long long sqr(int x){
    return 1LL * x * x;
}

long long dist(int i, int j){
    return sqr(x[i] - x[j]) + sqr(y[i] - y[j]);
}

int main(){
    cin >> xs >> ys >> xt >> yt;     
    cin >> n;
    for(int i = 1;i <= n;i++){
        scanf("%d%d%d", &x[i], &y[i], &r[i]);
    }
    x[0] = xs;
    y[0] = ys;
    x[n + 1] = xt;
    y[n + 1] = yt;
    for(int i = 0;i <= n + 1;i++){
        for(int j = i + 1;j <= n + 1;j++){
            double w = max(0.0, sqrt(dist(i, j)) - r[i] - r[j]);
            add(i, j, w);
        }
    }
    printf("%.10lf\n", dijkstra(0, n + 1));
    return 0;
}


Measured memory_bytes: 22164
#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>;

int main() {
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

ll K, A, B;

int main() {
	scanf("%lld%lld%lld", &K, &A, &B);
	if(A >= B) {
		printf("%lld\n", K + 1);
	}
	else if(K < A - 1) {
		printf("%lld\n", K + 1);
	}
	else {
		ll r = K + 1;
		K -= (A - 1);
		ll ans = A + (B - A) * (K / 2) + (K & 1);
		printf("%lld\n", max(ans, r));
	}
	return 0;
}


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

void update(int i,int x,vector<int>& node,int n) {
	i += n - 1;
	node[i] = x;
	while ( i > 0) {
		i = (i - 1) / 2;
		node[i] = min(node[2 * i + 1], node[2 * i + 2]);
	}
}
int find(int a,int b,int k,int l,int r, vector<int>& node) {
	if (r <= a || b <= l)return INT_MAX;
	if (a <= l && r <= b) return node[k];
	else {
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2, node);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r, node);
		return min(vl, vr);
	}
}


int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n_, q;  cin >> n_ >> q;
	int n = 1;
	while (n < n_) n *= 2;
	vector<int> node(2 * n - 1, INT_MAX);

	for (int i = 0; i < q; i++) {
		int com, x, y; cin >> com >> x >> y;
		if (com == 0) { update(x, y, node, n); }
		else {
			// ???????????????????????????????????????y + 1
			cout << find(x, y+1 , 0, 0, n, node) << endl;
		}
	}
}

Measured memory_bytes: 3808
input()
I=list(map(int,input().split()))
L=[0,0,0]
a=1
m=10**9+7
for i in I:
  if i in L:
  	a*=L.count(i)
  	L[L.index(i)]+=1
  	a%=m
  else:
    a=0
    break
print(a)

Measured memory_bytes: 14056
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
	int n;
	while (1) {
		cin >> n;
		if (!n) {
			return 0;
		}
		int temp[] = {5, 7, 5, 7, 7};
		vector<string> s(n);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}

		int stock = 0, pos = 0, ans = 0;
		for (int i = 0; i < n; i++) {
			stock = 0;
			pos = 0;
			for (int j = i; j < n; j++) {
				stock += s[j].size();
				if (stock == temp[pos]) {
					pos++;
					stock = 0;
				} else if (stock > temp[pos]) {
					break;
				}
				if (pos == 5) {
					ans = i + 1;
					break;
				}
			}
			if (ans > 0) {
				break;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1216