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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  string s, t;
  cin >> s;
  for (int i = 0; i < s.size(); i += 2) t += s[i];
  cout << t << endl;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S; cin >> S;
  int plus=0;
  int minus=0;
  for(int i=0;i<4;i++){
    if(S.at(i)=='+'){ plus++;}
    if(S.at(i)=='-'){ minus++;}
  }
  cout << plus-minus << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
set<int > se;

int main(){
	int n;
	cin >> n;

	vector<int > ar(n+1);

	for (int i = 1; i <= n; ++i)
	{
		/* code */
		cin >> ar[i];
	}

	int count =0;
	for (int i = 1 ; i<=n;  ++i)
	{
		/* code */
		if(i%2==1 && ar[i]%2==1 ){
			count++;
		}
	}

	cout << count << endl;

}

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

int main()
{
  string s;
  cin >> s;
  int a = 0, b = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '0') a++;
    else b++;
  }
  if(a != 0 && b != 0){
    cout << min(a, b)*2 << endl;
  }
  else {
    cout << 0 << endl;
  }
  system("pause");
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int ma = 0;
  int mi = 1 << 30;
  for(int i = 0;i<n;i++){
    int a;
    cin >> a;
    ma = max(ma,a);
    mi = min(a,mi);
  }
  cout << ma - mi;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,n; cin>>h>>n;
  int sum=0;
  rep(i,n){
    int a; cin>>a;
    sum+=a;
  }
  (sum>=h)?cout<<"Yes"<<endl:cout<<"No"<<endl;
}
 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long long N = 1000000000;
int main() {
  long long n; cin >> n;
  printf("0 0 %lld 1 %lld %lld\n", N
         ,(n + N - 1) / N * N - n ,(n + N - 1) / N);
}

Measured memory_bytes: 256
fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn main() {
    let (h, n) = input_pair::<usize>();
    let a: Vec<usize> = input_arr();
    println!("{}", if a.into_iter().sum::<usize>() < h { "No" } else { "Yes" });
}


Measured memory_bytes: 3516
#include <iostream>
#include <cmath>

using namespace std;

typedef struct myvector{
  double x;
  double y;
}Vector;

Vector sub_vector(Vector& a, Vector& b)
{
  Vector ret;
  ret.x = b.x - a.x;
  ret.y = b.y - a.y;
  return ret;
}

double cross_product(Vector& a, Vector& b)
{
  return a.x * b.y - b.x * a.y;
}

int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    Vector A, B, C, D;
    cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y;
    Vector AB = sub_vector(A, B);
    Vector CD = sub_vector(C, D);
    if(fabs(cross_product(AB, CD)) < 1.0e-10)
      cout << "YES" << endl;
    else 
      cout << "NO" << endl;
  }
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/


int main()
{
    ll n; cin >> n;
    ll res = n*(n-1)/2;
    cout << res << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;


int gcd(int a,int b) {
    int c=a%b;
    while (c>0) {
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}


int main() { 
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    int ans=a[0];
    for (int i=0;i<n;i++) {
        ans=gcd(ans,a[i]);
    }
    cout << ans << endl;
}

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

int main()
{
	int n;
	cin >> n;
	map<char, int> m;
	m['M'] = 0;
	m['A'] = 1;
	m['R'] = 2;
	m['C'] = 3;
	m['H'] = 4;
	vector<int> count(5);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		if (m.find(s[0]) != m.end()) {
			++count[m[s[0]]];
		}
	}

	long long ret = 0;
	int to = 1 << 5;
	for (int i = 0; i < to; ++i) {
		long long temp = 1;
		int ct = 0;
		for (int j = 0; j < 5; ++j) {
			if (i & 1 << j) {
				temp *= count[j];
				++ct;
			}
		}
		if (ct == 3) {
			ret += temp;
		}
	}
	cout << ret << endl;

	return 0;
}


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

int main(){
    string S;
    cin >> S;
    int G = 0, P = 0, ans = 0;
    for (auto c: S){
        if (c == 'g'){
            if (P + 1 <= G){
                ans += 1;
                P += 1;
            }else{
                G += 1;
            }
        }else{
            if (P + 1 <= G){
                P += 1;
            }else{
                ans -= 1;
                G += 1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>//cout << fixed からの cout << setprecision(n) << 小数　によって小数を整数部分含めてn桁表示できるようにする
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n,x,k;
  int cnt = 0;
  while(1){
  cin >> n >> x;
  if(n == 0 && x == 0) break;
  for(int i = 1;i < x+1;i++){
    for(int j = 1;j < x-i+1;j++){
      k = x - i - j;
      if(i != j && j != k && i != k && k != 0 && i <= n && j <= n && k <= n){
        //cout << i << " " << j << " " << k << endl;
        cnt++;
      }

    }
  }
  cnt = cnt / 6;
  cout << cnt << endl;
  cnt = 0;
  }

  return 0;
}



Measured memory_bytes: 3084
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

diff = [a[i] - b[i] for i in range(N)]
plus = sum(filter(lambda x: x > 0, diff))
minus_even = sum(filter(lambda x: x < 0 and x % 2 == 0, diff))
minus_odd = sum(x + 1 for x in diff if x < 0 and x % 2 == 1)

# print(plus)

if plus * 2 + minus_even + minus_odd > 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 43868
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/arc100/tasks/arc100_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = LINF;
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    vector<ll> cusum(N+1);
    for(int i = 0; i < N;i++) cusum[i+1] = cusum[i] + A[i];
    ll th = 1;
    for(ll m = 2; m <= N - 2;m++){
        ll Lsum = cusum[m], Rsum = cusum[N] - Lsum;
        ll lidx = lower_bound(cusum.begin()+1, cusum.end(), Lsum/2) - cusum.begin();
        ll ridx = lower_bound(cusum.begin()+1, cusum.end(), Lsum+Rsum/2) - cusum.begin();
        for(ll l = max(lidx-th,1LL); l <= min(lidx+th,m-1);l++){
            for(ll r = max(ridx-th,m+1); r <= min(ridx+th,N-1); r++){
                ll P = cusum[l], Q = cusum[m] - cusum[l], R = cusum[r] - cusum[m], S = cusum[N] - cusum[r];
                res = min(res,max({P,Q,R,S}) - min({P,Q,R,S}));
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int x, y; cin >> x >> y;
  cout << x + y/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define p pair<ll,ll>
#define fi first
#define se second
#define opti ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll N = 1e6+6;
ll t,i,j,k,n,m,q;
int main()
{
    opti
    ll a,b;
    cin>>n>>a>>b;
    bool f=0;
    while(1)
    {
        if(f==0)
        {
            if(b==a+1)
            {
                cout<<"Borys"<<endl;
                break;
            }
            else
            {
                f=1;
                a++;
            }
        }
        else
        {
            if(b==a+1)
            {
                cout<<"Alice"<<endl;
                break;
            }
            else
            {
                f=0;
                b--;
            }
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if(y%2==1){
    cout << "No" << endl;
  }
  else if(4*x>=y&&2*x<=y){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3644
Dice = Struct.new "Dice", :top, :back, :right, :left, :front, :bottom

x = readline.split " "
dice = Dice.new x[0], x[1], x[2], x[3], x[4], x[5]

def n d
  return Dice.new d.back, d.bottom, d.right, d.left, d.top, d.front
end

def w d
  return Dice.new d.right, d.back, d.bottom, d.top, d.front, d.left
end

def s d
  return Dice.new d.front, d.top, d.right, d.left, d.bottom, d.back
end

def e d
  return Dice.new d.left, d.back, d.top, d.bottom, d.front, d.right
end

c = readline.split ""

c.each do |c|
  case c
  when "W"
    dice = w dice
  when "E"
    dice = e dice
  when "S"
    dice = s dice
  when "N"
    dice = n dice
  end
end

puts dice.top


Measured memory_bytes: 6880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void){
    int N; cin >> N;
    vector<int> A(N),B(N),C(N);
    ll ans=0;

    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    for(int i=0; i<N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(C.begin(), C.end());

    for(int i=0; i<N; i++){
        ll a,b;
        auto it1=lower_bound(A.begin(), A.end(), B[i]);
        a=it1-A.begin();
        auto it2=upper_bound(C.begin(), C.end(), B[i]);
        b=C.end()-it2;
        ans+=a*b;
    }

    cout << ans << endl;
}

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

int main(){
    int n;cin>>n;
    int a[n];for(int i=0;i<n;i++)cin>>a[i];
    //int cnt=0;
    int m[100001];
    int flag=1;
    for(int i;i<n;i++){
        if(a[i]%2==n%2)flag=0;
        if(a[i]>=n)flag=0;
        else m[a[i]]++;
    }
    if(m[0]>=2)flag=0;
    long long ans=1;
    if(flag){
        for(int i=0;i<n/2;i++){
            (ans*=2)%=1000000007;
        }
    }
    ans%=1000000007;
    cout<<((flag)?ans:0)<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
const int MOD=1e9+7;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+  (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator-  (mint a){return MOD-a.x;}
inline mint operator-  (mint a,mint b){return a+-b;}
inline mint operator*  (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~  (mint x){return x<<MOD-2;}
inline mint operator/  (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}
#define MN 20
mint f[1<<MN-1][MN],ans;
int g[MN+5][MN+5];
int main()
{
	int n,m,i,j,k;
	n=read();m=read();k=read();
	while(k--)i=read(),j=read(),g[i][j]=read()+1;
	for(f[0][n-1]=i=1;i<=m;++i)
	{
		for(j=0;j<1<<n-1;++j)for(f[j][0]=f[j][n-1],k=1;k<n;++k)f[j][k]=0;
		for(j=0;j<1<<n-1;++j)for(k=1;k<n;++k)if(f[j][k-1].x)
		{
			f[j][k]+=f[j][k-1];
			if(j&(1<<n-k-1)){if(k>1&&!(j&(1<<n-k)))f[j^(3<<n-k-1)][k-2]+=f[j][k-1];}
			else if(k==n-1)f[j+1][k-1]+=f[j][k-1];
		}
		for(j=0;j<1<<n-1;++j)for(k=1;k<n;++k)
			if(g[i][k]&&((j>>n-k-1)&1)!=g[i][k]-1)f[j][n-1]=0;
	}
	for(i=0;i<1<<n-1;++i)ans+=f[i][n-1];
	printf("%d",ans);
}

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

// #define int long long

int N, M, T;

int main(){
	cin >> N >> M >> T;
	unordered_map < int, int > row, col;
	set < pair < int, int > > loc; 
	int rmax = 0, cmax = 0;
	while (T--){
		int A, B; cin >> A >> B;
		A -= 1; B -= 1;
		row[A] += 1;
		col[B] += 1;
		loc.insert({A, B});
		if (row[A] > rmax)
			rmax = row[A];
		if (col[B] > cmax)
			cmax = col[B];
	}	
	int fr = 0, fc = 0;
	for (auto x : row) fr += (x.second == rmax);
	for (auto y : col) fc += (y.second == cmax);

	// cout << rmax << " " << cmax;
	// cout  << "\n\n";
	// for (auto r : row) cout << r.first << " " << r.second << "\n";
	// cout << "\n\n";
	// for (auto r : col) cout << r.first << " " << r.second << "\n";
	// cout << "\n\n";

	int ct = 0;
	for (auto l : loc){
		if (row[l.first] == rmax && col[l.second] == cmax){
			ct += 1;
		}
	}
	// cout << ct << "\n";

	cout << rmax + cmax - (ct == fr*fc) << "\n";


}



Measured memory_bytes: 44336
import sys
input = sys.stdin.readline

def ceil(a, b):
    if a%b == 0:
        return a//b
    else:
        return a//b + 1

def f(l, r, a):
    # 区間[l, r]内の，最小・最大のaの倍数があれば返す
    min_ = ceil(l, a) * a
    max_ = (r // a) * a
    if min_ > max_:
        return False, min_, max_
    else:
        return True, min_, max_

def main():
    K = int(input())
    A = list(map(int, input().split()))[::-1]

    min_ = 2
    max_ = 2
    for i in range(K):
        jud, x, y = f(min_, max_, A[i])
        if not jud:
            print(-1)
            return
        min_ = x
        max_ = y + A[i] - 1
        # print(min_, max_)
    
    print(min_, max_)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14196
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle
using ll = long long ;
int main() {
    int n;
    cin >> n;

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

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }  
    cout << dp[n-1];  
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
s1=input()
s2=input()
mod=10**9+7

def rle(string):
    rle_str = string[0]
    rle_cnt = 1
    ans_l = []
    for i in range(1, len(string)):
        if rle_str == string[i]:
            rle_cnt += 1
        else:
            ans_l.append([rle_str, rle_cnt])
            rle_str = string[i]
            rle_cnt = 1
    ans_l.append([rle_str, rle_cnt])
    return ans_l

rle_s=rle(s1)

ans=rle_s[0][1]*3
left=rle_s[0][1]

for s, i in rle_s[1:]:
    if left==1 and i==1:
        ans*=2
    elif left==1 and i==2:
        ans*=2
    elif left==2 and i==1:
        ans*=1
    elif left==2 and i==2:
        ans*=3
    left=i

print(ans%mod)


Measured memory_bytes: 62036
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

template <class T = lint>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) { for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i]; }
	CuSum(int N) : cusum(N + 1) {}

	void add(int i, T x) { cusum[i + 1] += x; }
	void init() { for (int i = 0; i < (int)(cusum.size()) - 1; i++) cusum[i + 1] += cusum[i]; }

	T query(int l, int r) { return cusum[r] - cusum[l]; }  // partial sum of [l, r)
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, Q;
	string S;
	cin >> N >> Q >> S;

	vector<pair<int, int>> range(Q);
	for (int i = 0; i < Q; i++) cin >> range[i].first >> range[i].second;

	CuSum<int> ACsum(N);
	for (int i = 1; i < N; i++) if (S[i - 1] == 'A'&&S[i] == 'C') ACsum.add(i, 1);
	ACsum.init();

	for (int i = 0; i < Q; i++) cout << ACsum.query(range[i].first, range[i].second) << "\n";

	return 0;
}

Measured memory_bytes: 2256
n,ma,mb=map(int,input().split())
abc=[list(map(int,input().split())) for _ in range(n)]
a=[t[0] for t in abc]
b=[t[1] for t in abc]
c=[t[2] for t in abc]
mab=max(max(a),max(b))
dp=[[[1<<32 for _ in range(n*mab+1)] for _ in range(n*mab+1)] for _ in range(n+1)]
dp[0][0][0]=0
inf=1<<32
for i in range(n):
    for ca in range(n*mab):
        for cb in range(n*mab):
            if(dp[i][ca][cb]==inf):continue
            dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb])
            dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i])

ans=inf
for ca in range(1,n*mab):
    for cb in range(1,n*mab):
        if ca*mb==cb*ma:
            ans=min(ans,dp[n][ca][cb])
if ans==inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 97372
// problem: "https://atcoder.jp/contests/abc145/tasks/abc145_e"

#include<bits/stdc++.h>
#define Pair pair<int,int>

using namespace std;

bool func (Pair p1,Pair p2)
{
    if(p1.first == p2.first)
        return p1.second < p2.second;

    return p1.first > p2.first;
}

int maxH(int n,vector<Pair>&A,int t,vector<vector<int>>&V)
{
    if(n < 0 || t <= 0)
        return 0;

    if(V[n][t] == -1)
        V[n][t] = max(maxH(n-1,A,t-A[n].first,V)+A[n].second,maxH(n-1,A,t,V));

    return V[n][t];
}

int main()
{
    int n,t;
    cin>>n>>t;

    int i,a,b;
    vector<Pair>A;

    for(i=0;i!=n;i++)
    {
        cin>>a>>b;
        A.push_back(Pair(a,b));
    }

    sort(A.begin(),A.end(),func);       // define

    vector<vector<int>>V(n,vector<int>(t+1,-1));
    cout<<maxH(n-1,A,t,V);        // define

    // Test code
    // vector<Pair>B;
    // B.push_back(Pair(14,4));
    // B.push_back(Pair(12,3));
    // B.push_back(Pair(10,8));
    // B.push_back(Pair(20,4));
    // B.push_back(Pair(12,2));
    // B.push_back(Pair(14,1));
    // B.push_back(Pair(14,3));
    //
    // sort(B.begin(),B.end(),func);
    //
    // for(i=0;i!=7;i++)
    //     cout<<B[i].first<<' '<<B[i].second<<'\n';

    return 0;
}


Measured memory_bytes: 35840
// package app;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        String contestName = N >= 1000 ? "ABD" : "ABC";

        System.out.println(contestName);

    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define mod 1e9 + 7
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
void FIO(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("inputPrayag.txt", "r", stdin);
    freopen("outputPrayag.txt", "w", stdout);
    #endif
}
ll power(ll x, ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

int main(){
 FIO();
   int n;
   cin>>n;
   int x = n%10;
   if(x==2||x==4||x==5||x==7||x==9)
    cout<<"hon\n";
   else if(x==0||x==1||x==6||x==8) cout<<"pon\n";
   else if(x==3) cout<<"bon\n";
}


Measured memory_bytes: 3596
import sys

def warn(*m):
    print(m, file=sys.stderr)

D,*CS = map(int, open(0).read().split())
C = CS[:26]
S = [CS[26*i:26*(i+1)] for i in range(1, D+1)]

def imax(xs):
    m = -1
    i = 0
    for j, x in enumerate(xs):
        if x > m:
            i = j
            m = x
    return i

def ratio(xs):
    s = sum(xs)
    return [x / s for x in xs]

ds = [0] * 26

def pick(d):
    s = ratio(S[d])
    c = ratio([(1 + d - ds[i]) * x for i, x in enumerate(C)])
    return imax([x * y + x for x, y in zip(s, c)])

for d in range(D):
    i = pick(d)
    ds[i] = d + 1
    print(i + 1)


Measured memory_bytes: 10192
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int enda = 0, startb = 0, both = 0;
    int ans = 0;
    rep(i, 0, n){
        string s;
        cin >> s;
        if(s[0] == 'B' && s[s.size() - 1] == 'A') both++;
        else if(s[0] == 'B') startb++;
        else if(s[s.size() - 1] == 'A') enda++;
        rep(j, 0, s.size() - 1){
            if(s[j] == 'A' && s[j + 1] == 'B') ans++;
        }
    }
    if(both){
        ans += both - 1;
        if(enda){
            enda--;
            ans++;
        }
        if(startb){
            startb--;
            ans++;
        }
    }
    ans += min(enda, startb);
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n, *a = map(int, open(0).read().split())

    # b[0] == a[0] - a[1] + a[2] - a[3] + ...
    b = [sum(a) - 2 * sum(a[1::2])]

    for cur_a in a[:-1]:
        b.append(cur_a * 2 - b[-1])

    ans = b
    print(*ans)
    return()

if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;

int main() {
  int n; cin >> n;
  while(n--) {
    int n1 = 0, n2 = 0;
    string s1, s2; cin >> s1 >> s2;
    for(int i = 0; i < s1.size(); i++ ) {
      if(s1[i] == 'm') {
        if(i-1 != -1 && '1' <= s1[i-1] && s1[i-1] <= '9') n1 += 1000*(s1[i-1]-'0');
        else n1 += 1000;
      
      } else if(s1[i] == 'c') {
        if(i-1 != -1 && '1' <= s1[i-1] && s1[i-1] <= '9') n1 += 100*(s1[i-1]-'0');
        else n1 += 100;

      } else if(s1[i] == 'x') {
        if(i-1 != -1 && '1' <= s1[i-1] && s1[i-1] <= '9') n1 += 10*(s1[i-1]-'0');
        else n1 += 10;

      } else if(s1[i] == 'i') {
        if(i-1 != -1 && '1' <= s1[i-1] && s1[i-1] <= '9') n1 += s1[i-1]-'0';
        else n1 += 1;
      }
    }
    
    for(int i = 0; i < s2.size(); i++ ) {
      if(s2[i] == 'm') {
        if(i-1 != -1 && '1' <= s2[i-1] && s2[i-1] <= '9') n2 += 1000*(s2[i-1]-'0');
        else n2 += 1000;
      
      } else if(s2[i] == 'c') {
        if(i-1 != -1 && '1' <= s2[i-1] && s2[i-1] <= '9') n2 += 100*(s2[i-1]-'0');
        else n2 += 100;

      } else if(s2[i] == 'x') {
        if(i-1 != -1 && '1' <= s2[i-1] && s2[i-1] <= '9') n2 += 10*(s2[i-1]-'0');
        else n2 += 10;

      } else if(s2[i] == 'i') {
        if(i-1 != -1 && '1' <= s2[i-1] && s2[i-1] <= '9') n2 += s2[i-1]-'0';
        else n2 += 1;
      }
    }

    int sum = n1+n2;
    string ans;
    string c[4] = {"i", "x", "c", "m"}; 
    for(int i = 3; i >= 0; i--) {
      int p = sum / (int)pow(10, i);
      if(p > 0) {
        if(p > 1) ans += p+'0';
        ans += c[i];
      }
      sum %= (int)pow(10, i);
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1248
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
char a[4][4];
int main(){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin>>a[i][j];
		}
	}
	cout<<a[1][1]<<a[2][2]<<a[3][3]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>>  a(H+1,vector<char>(W+1,'#'));
  vector<vector<ll>>  dp(H+1,vector<ll>(W+1,0));
  string inp;
  for(int i=1;i<=H;i++){
    cin>>inp;
    for(int j=1;j<=W;j++){
      a[i][j]=inp[j-1];
    }
  }

  dp[1][1]=1;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(a[i][j]=='#') continue;
      (dp[i][j]+=dp[i-1][j]+dp[i][j-1])%=mod;
    }
  }
  cout<<dp[H][W]<<endl;
  return 0;
}



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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())

void solve(string S){
    vector<ll> v;
    rep(i, sz(S)-1) {
        if (S[i+1] != S[i]) {
            v.push_back(max(i+1, sz(S)-i-1));
        }
    }
    ll mn = sz(S);
    rep(i, sz(v)) {
        mn = min(mn, v[i]);
    }
    cout << mn << endl;
}

int main() {
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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


int main(){
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  vector<int> C;
  char pre = S[0];
  int count = 0;
  for(auto& s : S){
    if(s != pre){
      C.push_back(count);
      pre=s;
    }
    count++;
  }
  C.push_back(count);
 
  int ans, slow, fast;
  if(S[0]=='0'){
    slow = -2;
    fast = K * 2 - 1;
  }else{
    slow = -1;
    fast = K * 2;
  }
  
  if(fast >= C.size()){
    cout << C[C.size()-1] << endl;
    return 0;
  }

  ans = C[fast];
  slow+=2;
  fast+=2;
  for(; fast<C.size(); slow+=2, fast+=2){
    ans = max(ans, C[fast]-C[slow]);
  }
  if(S[S.size()-1]=='0'){
    ans = max(ans, C[C.size()-1] - C[C.size()-K*2-1]);
  }
  cout << ans << endl;
 
  return 0;
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  string s;
  cin >> s;
  cout << (s[0] == s[1] && s[1] == s[2] ? "No" : "Yes") << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define mxn 15
using namespace std;
char s[mxn][mxn];
int n,m,p[mxn],a[mxn];
string t[mxn|1];
bool mirror(int l,int r) {
	for(int i=0;i<n;i++)
		if(s[i][l]!=s[p[i]][r])
			return 0;
	return 1;
}
void dfscol(int d,bool b) {
	if(d==m) {	puts("YES");	exit(0);	}
	if(~a[d]) {	dfscol(d+1,b);	return;	}
	for(int i=d+1;i<m;i++)
		if(a[i]==-1&&mirror(d,i)) {
			a[d]=i,a[i]=d;
			dfscol(d+1,b);
			a[d]=-1,a[i]=-1;
		}
	if(b&&mirror(d,d))	a[d]=d,dfscol(d+1,0),a[d]=0;
}
void dfsrow(int d,bool b) {
	if(d==n) {	dfscol(0,m&1);	return;	}
	if(~p[d]) {	dfsrow(d+1,b);	return;	}
	for(int i=d+1;i<n;i++)
		if(p[i]==-1&&t[d]==t[i]) {
			p[d]=i,p[i]=d;
			dfsrow(d+1,b);
			p[d]=-1,p[i]=-1;
		}
	if(b)	p[d]=d,dfsrow(d+1,0),p[d]=0;
}
int main() {
	memset(p,-1,sizeof(p));
	memset(a,-1,sizeof(a));
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) {
		scanf("%s",s[i]);
		for(int j=0;j<m;j++)
			t[i]+=s[i][j];
		sort(t[i].begin(),t[i].end());
	}
	dfsrow(0,n&1);
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
long long a,b;
char s[10];
int main()
{
	cin>>a>>s;
	int len=strlen(s);
	for(int i=0;i<len;++i)
		if(isdigit(s[i]))b=b*10+s[i]-'0';
	long long c=a*b;
	c/=100;
	cout<<c;
	return 0;
}

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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;
string s;

ll lcm(ll a,ll b){
	
	return (a*b)/(__gcd(a,b));
}

void solve() 
{ 
int n;
cin>>n;
vector<int> v(n);
rep(i,n){
	cin>>v[i];
}
sort(allr(v));
ll ans=0;
ans=ans+v[0];
int cnt=0;
int j=1;
for(int i=2;i<n;i++){
	if(cnt<2){
		ans=ans+v[j];
		cnt++;
	}
	else if(cnt==2){
		cnt=0;
		j++;
		i--;
	}
}
cout<<ans;
}



int main(){

		solve();
		cout<<endl;


				
}
		

	

		

 



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

int main()
{

    int num = 1;
    int n,k;

    cin >> n >> k;

    for (int i = 0; i < n; i++)
    {
        if(num * 2 < num + k)
        {
            num *= 2;
        }
        else
        {
            num += k;
        }
    }
    cout << num << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    ll a, b, c, d;
    ll ans;
    cin >> a >> b >> c >> d;
    ans = max(a*c, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);

    cout << ans;
}

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

void push(int);
int pop();

int top;
int stack[100];

int main(){
  int x,a,b,n;
  int top = 0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a-b);
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a * b);
    } 
      else{
	n = atoi(s);
	push(n);
      }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int x){
  top++;
  stack[top] = x;
}

int pop(void){
  top--;
  return(stack[top+1]);
}



Measured memory_bytes: 2100
import sys
import itertools

def isAscending(p):
    temp = float('-inf')
    for e in p:
        if temp >= e:
            return False
        temp = e
    else:
        return True

n = int(input())
p = list(map(int, input().split()))

if isAscending(p):
    print('YES')
    sys.exit(0)

for i, j in itertools.combinations(range(n), 2):
    p[i], p[j] = p[j], p[i]
    # print(p)
    if isAscending(p):
        print('YES')
        break
    p[i], p[j] = p[j], p[i]
else:
    print('NO')


Measured memory_bytes: 3316
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int a[3], b[2];
	
	for(int i = 0; i < 3; ++i)
		scanf("%d", &a[i]);
	for(int i = 0; i < 2; ++i)
		scanf("%d", &b[i]);
	
	sort(a, a + 3);
	sort(b, b + 2);
	
	printf("%d\n", a[0] + b[0] - 50);
	
	return 0;
}

Measured memory_bytes: 1036
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    ll s,w; cin >> s >> w;
    if(s<=w){
        cout << "unsafe" <<endl;
    }else{
        cout << "safe" << endl;
    }
}

void b(){
   ll a,b,c,d; cin >> a >> b >> c >> d;
   while(a>0&&c>0){
       c-=b;
       a-=d;
   }

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

}

void c(){
    ll n; cin >> n;
    set<string> s;
    rep(i,n){
        string t;
        cin >> t;
        s.insert(t);
    }
    cout << s.size() << endl;
}

void d(){
    
}

void e(){

}

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





Measured memory_bytes: 19208
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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;

int main() {
    int n; cin >> n;

    map<ll, int, greater<int>> m;
    rep(i, n) {
        ll a; cin >> a;
        m[a] += 1;
    }

    ll x = 0, y = 0;
    for (auto kv: m) {
        ll len = kv.first;
        int num = kv.second;

        if (x == 0 && num > 1) {
            x = len;
            if (num >= 4) {
                y = len;
                break;
            }
            continue;
        }
        if (x != 0 && num > 1) {
            y = len;
            break;
        }
    }
    cout << x * y << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define pinf 0x7FFFFFFF
using namespace std;

class Graph {
  private:
    int V;
    vector <vector <int>> adj;
    vector <int> first;
    vector <int> height;
    vector <int> euler;
    void eulerUtil(int u, bool visited[], int h);
    vector <int> seg;
    void build(int idx, int ss, int se);
    int lca_query(int idx, int ss, int se, int qs, int qe);
  public:
    Graph(int n);
    void addEdge(int u, int v);    
    void euler_tour();
    void buildrmq();
    int lca(int u, int v);
};

Graph::Graph(int n) {
  this->V = n;
  adj.resize(n);
  first.resize(n);
  height.resize(n);
}

void Graph::addEdge(int u, int v) {
  adj[u].push_back(v);
}

void Graph::eulerUtil(int u, bool visited[], int h) {
  visited[u] = true;
  first[u] = euler.size();
  height[u] = h;
  euler.push_back(u);

  for (int i = 0; i < (int) adj[u].size(); i++) {
    int v = adj[u][i];
    if (!visited[v]) {
      eulerUtil(v, visited, h + 1);
      euler.push_back(u);
    }
  }
}

void Graph::euler_tour() {
  bool visited[V];
  fill(visited, visited + V, false);
  eulerUtil(0, visited, 0);
}


void Graph::build(int idx, int ss, int se) {
  if (ss == se) {
    seg[idx] = euler[ss];
    return;
  }

  int m = (ss + se) / 2;
  build(2 * idx, ss, m);
  build(2 * idx + 1, m + 1, se);
  //..store information based on the depth to be minimum in range

  seg[idx] = height[seg[2 * idx]] < height[seg[2 * idx + 1]] ? seg[2 * idx] : seg[2 * idx + 1];
}

void Graph::buildrmq() {
  int n = euler.size();
  seg.resize(4 * n);
  build(1, 0, n - 1);  
} 

int Graph::lca_query(int idx, int ss, int se, int qs, int qe) {
  if (qs > qe) {
    return pinf;
  }
  if (ss == qs && se == qe) {
    return seg[idx];
  }
  int m = (ss + se) / 2;
  int l = lca_query(2 * idx, ss, m, qs, min(m, qe));
  int r = lca_query(2 * idx + 1, m + 1, se, max(m + 1, qs), qe);
  if (l == pinf) {
    return r;
  } else if (r == pinf) {
    return l;
  } else {
    return height[l] < height[r] ? l : r;
  }
}

int Graph::lca(int u, int v) {
  int qs = first[u];
  int qe = first[v];
  if (qs > qe) {
    swap(qs, qe);
  }   
  int n = euler.size();
  return lca_query(1, 0, n - 1, qs, qe);
}

int main() {
  int n;
  cin >> n;
  Graph g(n);
  int k, v;
  for (int u = 0; u < n; u++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      //..v is children of u and 0 is the root of this tree
      g.addEdge(u, v);   
    } 
  }
  g.euler_tour();
  g.buildrmq();

  int q, ui, vi;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> ui >> vi;
    cout << g.lca(ui, vi) << '\n';
  } 
  return 0;
}


Measured memory_bytes: 19232
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}




void test_case() {

    int n;
    cin>>n;

    vec arr(n);
    rep(i,n) {
        cin>>arr[i];
    }

    int ans = INT_MAX;


    for(int i=0; i<=100; i++) {
        int j=0;
        for(auto it : arr) {
            j+= (it-i) * (it - i);
        }

        ans = min(ans, j);
    }

    cout<<ans<<endl;
    






}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    //cin >> t;
    while(t--)
    {   
        test_case();
    }
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)

int main() {
  string S;
  cin >> S;
  int ans = 1e9;
  for(int i = 0; i < S.size() - 2; i++) {
    ans = min(ans, abs(753 - atoi(S.substr(i, 3).c_str())));
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  int num;
  int max = 0;
  int min = pow(10,9);
  
  for(int i = 0; i < N; i++){
    cin >> num;
    max = max < num? num:max;
    min = min > num? num:min;
  }
  cout << max - min << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> ans;
  for (int i = 0; i < N; i++) {
    int tmp = A.at(i);
    while (tmp--) ans.push_back(i + 1);
  }
  vector<int> tmp;
  for (int i = 0, b = 0; i < (int) ans.size(); i++) {
    tmp.push_back(ans.at(i));
    if (tmp.size() == W) {
      if (b) reverse(tmp.begin(), tmp.end());
      for (int j = 0; j < W; j++) {
        if (j) cout << " ";
        cout << tmp.at(j);
      }
      cout << "\n";
      tmp.clear();
      b ^= 1;
    }
  }
}

Measured memory_bytes: 3676