akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll x[15], y[15], p[15];

ll res[16];
ll d0[1<<15][15];
ll d1[1<<15][15];

int bitcount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

void solve() {
    for (int i = 0; i < (1<<n); i++) {
        vector<ll> vec(1, 0);
        for (int j = 0; j < n; j++) {
            if ((i>>j)&1) {
                vec.push_back(x[j]);
            }
        }

        for (int j = 0; j < n; j++) {
            ll min_d = inf;
            for (ll v : vec) {
                min_d = min(min_d, abs(x[j]-v)*p[j]);
            }
            d0[i][j] = min_d;
        }
    }
    for (int i = 0; i < (1<<n); i++) {
        vector<ll> vec(1, 0);
        for (int j = 0; j < n; j++) {
            if ((i>>j)&1) {
                vec.push_back(y[j]);
            }
        }

        for (int j = 0; j < n; j++) {
            ll min_d = inf;
            for (ll v : vec) {
                min_d = min(min_d, abs(y[j]-v)*p[j]);
            }
            d1[i][j] = min_d;
        }
    }

    for (int i = 0; i < n; i++) {
        res[0] += min(d0[0][i], d1[0][i]);
    }
    for (int i = 1; i <= n; i++) {
        res[i] = inf;
    }
    
    for (int mask = 1; mask < (1<<n); mask++) {
        ll min_d = inf;
        for (int i = mask; ; i = (i-1) & mask) {
            ll val = 0;
            for (int j = 0; j < n; j++) {
                val += min(d0[i][j], d1[mask^i][j]);
            }
            min_d = min(min_d, val);
            if (i == 0) break;
        }
        const int cnt = bitcount(mask);
        res[cnt] = min(res[cnt], min_d);
    }

    for (int i = 0; i <= n; i++) {
        cout << res[i] << endl;
    }
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> p[i];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 10824
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
ll a[N];

int main(){
	int n; ll k; scanf("%d%lld", &n, &k);
	REP(i, n) scanf("%lld", a+i);
	sort(a, a + n);

	int p = 0;
	while(p < n && a[p] < 0) p++;
	int q = p;
	while(q < n && a[q] == 0) q++;

	ll mx = 2'000'000'000'000'000'000LL, mi = -mx;
	while(mx - mi > 1){
		ll md = (mi + mx) / 2; // count <= md
		ll cnt = 0;
		REP(i, n){
			if(a[i] == 0){
				if(md >= 0) cnt += n;
			} else {
				ll r = (md % a[i] + a[i]) % a[i];
				ll q = (md - r) / a[i];
				if(a[i] > 0){
					cnt += upper_bound(a, a+n, q) - a;
				} else {
					if(r) q++;
					cnt += a+n - lower_bound(a, a+n, q);
				}
			}
		}
		REP(i, n) if(a[i] * a[i] <= md) cnt--;
		cnt /= 2;
		DEBUG("(<=%lld)  ->  %lld\n", md, cnt);
		if(k <= cnt){
			mx = md;
		} else {
			mi = md;
		}
	}
	printf("%lld\n", mx);
}


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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  rep(i,0,n) cin >> v[i];
  rep(i,0,n) cin >> c[i];
  int ans=0;
  rep(i,0,n){
    if(v[i]>c[i]){
      ans= ans + v[i] - c[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100010;
int read(){
    int f=1,x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=min(b/a,c);
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    using Point = array<double, 2>;
    vector<Point> a(3);
    for (int i = 0; i < 3; i++) cin >> a[i][0] >> a[i][1];
    auto dist = [&](Point &p, Point &q) {
        return sqrt((p[0]-q[0])*(p[0]-q[0])+(p[1]-q[1])*(p[1]-q[1]));
    };
    vector<double> r(3);
    for (int i = 0; i < 3; i++) r[i] = dist(a[i], a[(i+1)%3]);
    auto T = [&](auto &a, auto &b, auto &c) {
        double th = acos((a*a+b*b-c*c)/(2*a*b))/2;
        return 1 / tan(th);
    };
    vector<double> t(3);
    for (int i = 0; i < 3; i++) t[i] = T(r[i], r[(i+1)%3], r[(i+2)%3]);
    double ans = 0;
    for (int i = 0; i < 3; i++) {
        double u = 2 + t[i] + t[(i+1)%3];
        ans = max(ans, r[(i+1)%3] / u);
    }
    cout << setprecision(12) << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
def MakingTriangle():
    
    num = int(input())

    data = list(map(int,input().split()))

    count = 0

    if num <= 2:
        print(0)
        
    else:
        
        for i in range(num - 2):
            
            for j in range(i+1, num-1):
            
                for k in range(j+1, num):
                    if (data[i] != data[j]) and (data[j] != data[k]) and (data[i] != data[k]):
                        
                        if (data[i] + data[j] > data[k]) and (data[j] + data[k] > data[i]) and (data[i] + data[k] > data[j]):

                            count = count + 1
            
        print(count)
        
if __name__ == '__main__':
    MakingTriangle()



Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n = 3;
	string s[n];
	for(int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	bool ok[n][n][4010];
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			for(int k = 0; k < 4010; ++k) {
				ok[i][j][k] = true;
			} 
		}
	}
	for(int l = 0; l < n; ++l) {
		for(int r = 0; r < n; ++r) {
			for(int i = 0; i < s[l].size(); ++i) {
				for(int j = 0; j < s[r].size() and i + j < s[l].size(); ++j) {
					if(s[l][i + j] != '?' and s[r][j] != '?' and s[l][i + j] != s[r][j]) {
						ok[l][r][i] = false;
					}
				}
			}
		}
	}
	vector<int> v = {0, 1, 2};
	int ans = INF;
	do {
		for(int i = 0; i <= s[v[0]].size(); ++i) {
			for(int j = 0; j <= max<int>(s[v[0]].size() - i, s[v[1]].size()); ++j) {
				if(ok[v[0]][v[1]][i] and ok[v[1]][v[2]][j] and ok[v[0]][v[2]][i + j]) {
					int n0 = s[v[0]].size() - (i + j);
					int n1 = s[v[1]].size() - j;
					int n2 = s[v[2]].size();
					ans = min<int>(ans, i + j + max({n0, n1, n2}));
				}
			}
		}
	} while(next_permutation(v.begin(), v.end()));
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 101010;
int main(){
	int a,b;
	cin>>a>>b; 
	if(a+b==15){
		cout<<"+";
	}
	else{
		if(a*b==15){
			cout<<"*";
		}
		else{
			cout<<"x";
		}
	}
	return 0;
}  

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

i32 dp[100010] = {0};

vector<vector<i32>> g;

int rec(int v) {
  if (dp[v] != -1)
    return dp[v];

  int res = 0;
  for (auto p : g[v]) {
    res = max(res, rec(p) + 1);
  }

  dp[v] = res;
  return res;
}

int main() {

  i32 n, m;
  cin >> n >> m;

  g.assign(n, vector<int>());

  rep(i, m) {
    i32 xi, yi;
    cin >> xi >> yi;
    xi--;
    yi--;
    g[xi].push_back(yi);
  }

  for (auto &d : dp)
    d = -1;

  int res = 0;
  for (int v = 0; v < n; v++)
    res = max(res, rec(v));

  cout << res;

  return 0;
}


Measured memory_bytes: 11044
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a,b) for(int i=int(a);i>int(b);--i)
using namespace std;
using ll = long long;

char c[12];
int len;
ll cur,ans;


int main()
{
  len = 0;
  while(cin>>c[len++]){}

  ans = 0L;
  rep(i,1<<(len-2)){
    cur = 0L;
    rep(j,len-1){
      if(j>0 && i&(1<<(j-1))){
        ans += cur;
        cur = 0L;
      }
      cur = cur*10 + (c[j]-'0');
    }
    ans += cur;
  }
  cout << ans << "\n";
}


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());

            Console.WriteLine(N * N - A);
        }
    }
}

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

double SUM(int p){
	return (1.0+p)/2.0;
}
int main(){
	int n,k;
    double ans=0.0;
    cin>>n>>k;
    double p[n+1];
    p[0]=0.0;
    for(int i=1;i<=n;i++){
        int q;
        cin>>q;
        p[i]=p[i-1]+SUM(q);
    }
    for(int i=0;i<=n-k;i++){
    	ans=max(ans,p[i+k]-p[i]);
    }
    cout<<setprecision(16)<<ans;
}

Measured memory_bytes: 5316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;

string s[3]={"HIT","HOMERUN","OUT"};


int main(){
	int n;
	cin>>n;
	rep(i,n){
		string t;
		int score=0,out=0;
		bool first=false,second=false,third=false;
		while(1){
			cin>>t;
			if(t==s[0]){
				if(third){
					score++;
					third=false;
				}
				if(second){
					third=true;
					second=false;
				}
				if(first){
					second=true;
				}
				first=true;
			}
			if(t==s[1]){
				score++;
				if(first){
					first=false;
					score++;
				}
				if(second){
					second=false;
					score++;
				}
				if(third){
					third=false;
					score++;
				}
			}
			if(t==s[2]){
				out++;
				if(out==3){
					cout<<score<<endl;
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 1220
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin>>s;
	cin>>N;
	vector<vector<vector<long long int>>>dp(s.size()+1,vector<vector<long long int>>(2,vector<long long int>(N+1)));
	dp[0][1][0]=1;
	for(int i=0;i<s.size();i++){
		dp[i+1][0][0]=1;
		for(int j=0;j<2;j++){
			for(int l=0;l<=N;l++){
				for(int k=0;k<10;k++){
					if(k>(s[i]-'0')&&j)continue;
					if(!l&&!k)continue;
					if(l+(!!k)>N)continue;
					dp[i+1][(j)&&s[i]-'0'==k][l+(!!k)]+=dp[i][j][l];
				}
			}
		}
	}
	cout<<dp.back()[0][N]+dp.back()[1][N]<<endl;
}


Measured memory_bytes: 256
def comb(n, r, mod):
    if n < 0 or r < 0 or r > n: return 0
    nu = 1
    de = 1
    for i in range(r):
        nu = nu * (n-i) % mod
        de = de * (i+1) % mod
    return nu * inv(de, mod) % mod
 
def inv(a, mod):
    b = mod
    p, q = 1, 0
    while b > 0:
        c = a//b
        d = a; a = b; b = d % b
        d = p; p = q; q = d-c*q
    return p+mod if p < 0 else p

x, y = map(int, input().split())

m = (2 * x -y) // 3
n = (2 * y -x) // 3
mod = 10**9+7
if n >= 0 and m >= 0 and (x + y) % 3 == 0:
  ans = comb(n+m, m, mod)
  print(ans)
else:
  print(0)
  

Measured memory_bytes: 62844
s = input()
q = int(input())
h,t = [],[]
p = 0

for i in range(q):
    c = input().split()
    if c[0] == '1':
        h,t = t,h
        p = 1-p
    else:
        if c[1] =='1':
            h.append(c[2])
        else:
            t.append(c[2])
if p ==1:
    s = s[::-1]
print("".join(h[::-1])+s+"".join(t))

Measured memory_bytes: 6252
#include<stdio.h>
#define MAX 100
#define INFTY 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim(void);


int n,M[MAX][MAX];

int main(){
  int i,j,min;


  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&min);
      if(min==-1) M[i][j]=INFTY;
      else M[i][j]=min;
    }
  }
  

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


  return 0;
}

int prim(){
  int u,v,minv,i,sum;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v] != INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    } 
  }

  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }

  return sum;
}



Measured memory_bytes: 2056
MOD=10**9+7
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def pow(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return pow(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * pow(n, r-1, mod) % mod

def com(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
h,w,a,b=map(int,input().split())
ans=ModInt(0)
mod=10**9+7
k=h-a
com1=[ModInt(0) for i in range(w-b)]
com2=[ModInt(0) for i in range(w-b)]
com1[0]=ModInt(com(k+b-1,b,mod))
com2[0]=com(a-1,0,mod)
for i in range(1,w-b):
    com1[i]=com1[i-1]*ModInt(k+b+i-1)/ModInt(b+i)
    com2[i]=com2[i-1]*ModInt(a+i-1)/ModInt(i)
# print(com1)
com2.reverse()
# print(com2)
for i in range(b+1,w+1):
    ans+=com1[i-b-1]*com2[i-b-1]
    # print(com1[i-b-1],com2[i-b-1])
    # print(com(k+i-2,i-1,mod),com(a+w-i-1,w-i,mod))
print(ans)

Measured memory_bytes: 92192
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	res := math.MinInt64
	products := make([]int, 4)
	products[0] = a * c
	products[1] = a * d
	products[2] = b * c
	products[3] = b * d
	for _, product := range products {
		if res < product {
			res = product
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 1772
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <numeric>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;



int main(void)
{
    int n;
    cin >> n;
    int ans = 0;
    int maxh = 0;
    REP(i,n)
    {
        int t;
        cin >> t;
        if(t >= maxh)
        {
            ans++;
        }
        maxh = max(t, maxh);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

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

    long s1 = 0, s2 = 0, s3 = 0, s4 = 0;
    for (int i = 0; i < n; i++) s4 += a[i];

    long res = s4;
    int i = 0, j = 0, k = 0;

    while (j < n) {

        while (i < j) {
            long ss1 = s1 + a[i];
            long ss2 = s2 - a[i];
            if (std::max(ss1, ss2) - std::min(ss1, ss2) < std::max(s1, s2) - std::min(s1, s2)) {
                s1 = ss1;
                s2 = ss2;
                i++;
            } else {
                break;
            }
        }

        while (k < n) {
            long ss3 = s3 + a[k];
            long ss4 = s4 - a[k];
            if (std::max(ss3, ss4) - std::min(ss3, ss4) < std::max(s3, s4) - std::min(s3, s4)) {
                s3 = ss3;
                s4 = ss4;
                k++;
            } else {
                break;
            }
        }

        long s = std::max(std::max(s1, s2), std::max(s3, s4)) - std::min(std::min(s1, s2), std::min(s3, s4));
        res = std::min(res, s);

        s2 += a[j];
        s3 -= a[j];
        j++;
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 1024
def main():
    num = int(input())
    data = [0 for i in range(num + 1)]
    data[0], data[1] = 2, 1
    for i in range(2, num + 1):
        data[i] = data[i - 1] + data[i -2]
    print(data[num])


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
using System;

class Program
{
    static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        double a = double.Parse(str[0]);
        double b = double.Parse(str[1]);

        if (a > b)
        {
            Console.WriteLine("a > b");
        }
        else
        {
            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else
            {
                Console.WriteLine("a == b");
            }

        }
    }
}

Measured memory_bytes: 9308
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string[] sar = s.Split(' ');
			int W = int.Parse(sar[0]);
			int H = int.Parse(sar[1]);
			int x = int.Parse(sar[2]);
			int y = int.Parse(sar[3]);
			int r = int.Parse(sar[4]);

			if (W - x >= r && x >= r)
			{
				if (H - y >= r && y >= r)
				{
					Console.WriteLine("Yes");
				}
				else { Console.WriteLine("No"); }
			}
			else { Console.WriteLine("No"); }
		}
	}
}

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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 1e5;

int n;

vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int cut[MAXN + 5];

inline void dfs(int u, int fa)
{
	for(auto v : adj[u]) if(v != fa)
		dfs(v, u);
	if(fa && !cut[u] && !cut[fa]) cut[u] = cut[fa] = 1;
}

inline void solve()
{
	dfs(1, 0);

	for(int i = 1; i <= n; ++i) if(!cut[i]) { puts("First"); return; }
	puts("Second");
}

int main()
{
	input();
	solve();

	return 0;
}



Measured memory_bytes: 6272
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int R = sc.nextInt();
		int C = sc.nextInt();
		int Q = sc.nextInt();

		char[][] S = new char[R][];
		for (int r = 0; r < R; r++) {
			S[r] = sc.next().toCharArray();
		}
		
		int[][] vs = new int[R+1][C+1];
		int[][] e0 = new int[R+1][C+1];
		int[][] e1 = new int[R+1][C+1];
		
		for (int r = 0; r < R; r++) {
			for (int c = 0; c < C; c++) {
				vs[r+1][c+1] = vs[r][c+1] + vs[r+1][c] - vs[r][c] + (S[r][c] =='1' ? 1 : 0);
			}
		}
		
		for (int r = 0; r < R; r++) {
			for (int c = 0; c + 1 < C; c++) {
				e0[r+1][c+1] = e0[r][c+1] + e0[r+1][c] - e0[r][c] + 
					(S[r][c] =='1' && S[r][c+1] =='1' ? 1 : 0);
			}
		}

		for (int r = 0; r + 1 < R; r++) {
			for (int c = 0; c < C; c++) {
				e1[r+1][c+1] = e1[r][c+1] + e1[r+1][c] - e1[r][c] + 
					(S[r][c] =='1' && S[r+1][c] == '1' ? 1 : 0);
			}
		}

		for (int q = 0; q < Q; q++) {
			int x1 = sc.nextInt() - 1;
			int y1 = sc.nextInt() - 1;
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			int V = vs[x2][y2] - vs[x2][y1] - vs[x1][y2] + vs[x1][y1];
			int E0 = e0[x2][y2-1] - e0[x2][y1] - e0[x1][y2-1] + e0[x1][y1];
			int E1 = e1[x2-1][y2] - e1[x2-1][y1] - e1[x1][y2] + e1[x1][y1];
			int ans = V - (E0 + E1);
			out.println(ans);
		}

	}

	static void tr(Object... os) { System.err.println(deepToString(os)); }

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 139768
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    for(int i = 0; i < n; i += 2)
    {
        if(a[i] & 1)
            ans++;
    }
    cout << ans << endl;
}

int main()
{
    int q = 1;
    //scanf("%d", &q);
    for(int i = 1; i <= q; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  cin >> N;

  string s;
  cin >> s;

  int ans = 1;
  REP(i, N-1){
    if(s[i] != s[i+1]) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  int n;
  ll k;
  cin >> n >> k;

  int a[n + 5];
  ll v[n + 5];
  REP(i, n) {
    cin >> a[i + 1];
    v[i + 1] = -1;
  }

  int now = 1;

  v[now] = 0;
  ll ct = 0;
  // bool loop = false;
  while (ct < k) {
    now = a[now];
    ct++;
    if (v[now] != -1 && ct != 0) {
      k -= v[now];
      ct -= v[now];
      // loop = true;
      break;
    } else {
      v[now] = ct;
    }
  }


  int b = k % ct;
  for(int i = 0; i < b; i++) {
    now = a[now];
  }

  cout << now << endl;
}



Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;

//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<n*800-int(n/15)*200<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();

			if ( n % 2 == 0 ) {
				System.out.println(n/2 - 1);
			}
			else {
				System.out.println(n/2);
			}
			
		}
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const LL INF = 1e18;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define Be begin()
#define En end()
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int main()
{
    // IOS;
    int n;
    LL k;
    cin >> n >> k;
    vector<LL> v(n);
    FOR(i, 0, n) { cin >> v[i]; }
    sort(v.Be, v.En);
    LL L = -INF, R = INF;
    while (L + 1 < R)
    {
        // cout << L << ' ' << R << '\n';
        LL M = (L + R) >> 1, cnt = 0;
        FOR(i, 0, n)
        {
            if (v[i] < 0)
            {
                int LL = -1, RR = n;
                while (LL + 1 < RR)
                {
                    int MM = (LL + RR) >> 1;
                    (v[i] * v[MM] < M) ? (RR = MM) : (LL = MM);
                }
                cnt += n - RR;
            }
            else
            {
                int LL = -1, RR = n;
                while (LL + 1 < RR)
                {
                    int MM = (LL + RR) >> 1;
                    (v[i] * v[MM] < M) ? (LL = MM) : (RR = MM);
                }
                cnt += RR;
            }
            if (v[i] * v[i] < M)
            {
                --cnt;
            }
        }
        cnt /= 2;
        // cout << M << ' ' << cnt << '\n';
        (cnt < k) ? (L = M) : (R = M);
    }
    cout << L << '\n';
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a;
int x,y;
bool p=0,q=0;

int main(){
	scanf("%d",&a);
	x=a/100;
	y=a%100;
	if(x>0&&x<=12) p=1;
	if(y>0&&y<=12) q=1;
	if(p==1&&q==1) printf("AMBIGUOUS\n");
	else if(p==1) printf("MMYY\n");
	else if(q==1) printf("YYMM\n");
	else printf("NA\n");
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>

using namespace std;

void outPut(int Array[3][10]){
    for(int i=0;i<3;i++){
     for(int j=0;j<10;j++){
         cout << " " << Array[i][j] ;
     }    
     cout << "\n" ;
    }
}


int main()
{
  int n ;
  cin >> n ;
  
  int A[3][10], B[3][10],C[3][10],D[3][10] ;
  for(int i=0;i<3;i++){
      for(int j=0;j<10;j++){
          A[i][j]=B[i][j]=C[i][j]=D[i][j] = 0 ;
      }
  }
  
  int count = 0;
  while(count<n){
      int b,f,r,v;
      cin >> b >> f >> r >> v ;
      
      if(b==1){
          A[f-1][r-1] += v ; 
      }else if(b==2){
          B[f-1][r-1] += v ; 
      }else if(b==3){
          C[f-1][r-1] += v ; 
      }else{
          D[f-1][r-1] += v ; 
      }
      count++ ;
  }
  
  outPut(A);
  for(int i=0;i<20;i++)cout << "#";
  cout << "\n" ;
  outPut(B);
  for(int i=0;i<20;i++)cout << "#";
  cout << "\n" ;
  outPut(C);
  for(int i=0;i<20;i++)cout << "#";
  cout << "\n" ;
  outPut(D);

  
    return 0;
}




Measured memory_bytes: 3096
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define sz(a) (int)(a).size()
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 50+5;
int cas=1;
int a[maxn];
void solve()
{
    int flag, mx = -1, pos;
    int n; scanf("%d", &n);
    for (int i = 1 ; i <= n ; i ++) {
        scanf("%d", a+i);
        if (abs(a[i]) > mx) {
            mx = abs(a[i]);
            flag = a[i] < 0 ? -1 : 1;
            pos = i;
        }
    }
    printf("%d\n", 2*n - 2);
    for (int i = 1 ; i <= n ; i ++) {
        if (i == pos) continue;
        printf("%d %d\n",pos, i);
    }
    if (flag == 1) {
        for (int i = 1 ; i < n ; i ++) {
            printf("%d %d\n", i, i+1);
        }
    }
    else {
        for (int i = n - 1 ; i >= 1 ; i --) {
            printf("%d %d\n", i+1, i);
        }
    }


}
int main()
{
   //  freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    CSF=LLIN(N-1)
    def solve(CSF):
        now = 0
        for i,(c,s,f) in enumerate(CSF):
            if now <= s: #そのまま最速で乗れる
                now = s + c
                continue
            else:
                if now%f != 0:
                    now += f - now%f
                now += c
        print(now)
    
    for i in range(N):
        solve(CSF[i:])


if __name__ == '__main__':
    main()

Measured memory_bytes: 40560
#!/usr/bin/env python3

def main():
    s = input()
    fi = int(s[:2])
    la = int(s[2:])
    flags = (can_be_month(fi), can_be_month(la))
    if flags == (True, True):
        res = "AMBIGUOUS"
    elif flags == (True, False):
        res = "MMYY"
    elif flags == (False, True):
        res = "YYMM"
    else:
        res = "NA"
    print(res)

def can_be_month(x):
    return 1 <= x <= 12

main()


Measured memory_bytes: 3064
#include <cstdio>
const int MAXN = 1000 + 5, mod = 1e9 + 7;
typedef long long ll;
inline int addmod(int a, int b) { return (a + b) % mod; }
inline int mulmod(ll a, int b) { return (a * b) % mod; }
inline int powmod(int a, int x) {
	ll cur = a, res = 1;
	while(x) {
		if(x & 1) res = (res * cur) % mod;
		x >>= 1;
		cur = (cur * cur) % mod;
	}
	return (int)res;
}
int fac[MAXN], inv_fac[MAXN];
inline int com(int n, int m) {
	return mulmod(fac[n], mulmod(inv_fac[n - m], inv_fac[m]));
}
int f[MAXN][MAXN], g[MAXN][MAXN];
bool vis[MAXN][MAXN];
int n, a, b, c, d;
int solve(int n_, int i) {
	if(n_ == 0) return 1;
	if(i > b) return 0;
	if(vis[n_][i]) return f[n_][i];
	int res = solve(n_, i + 1);
	for(int j = c; j <= d && i * j <= n_; j++) {
		res = addmod(res, mulmod(mulmod(com(n_, i * j), mulmod(g[i][j], inv_fac[j])), solve(n_ - i * j, i + 1)));
	}
	vis[n_][i] = true;
	return f[n_][i] = res;
}
int main() {
	fac[0] = 1; inv_fac[0] = powmod(fac[0], mod - 2);
	for(int i = 1; i < MAXN; i++) {
		fac[i] = mulmod(fac[i - 1], i);
		inv_fac[i] = powmod(fac[i], mod - 2);
	}
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	for(int i = a; i <= b; i++) {
		g[i][0] = 1;
		for(int j = 1; j <= d && i * j <= n; j++) g[i][j] = mulmod(com(i * j, i), g[i][j - 1]);
	}
	printf("%d\n", solve(n, a));
	return 0;
}

Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,T,cas=0;
    cin>>a>>b;
    if(a>b) cout<<"safe\n";
    else cout<<"unsafe\n";
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

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

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問状況

int n, m; // 変数
set<string> item;

int main() {
// input
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        item.insert(s);
    }
// solve
// output
    cout << item.size() << "\n";
}

Measured memory_bytes: 19200
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            var h = InputNumList();
            h.Add(1000000010);

            int i = 0;
            int cnt = 0;
            while (i < n)
            {
                int tmp = 0;
                bool flag = true;
                for (int j = i; flag == true; j++)
                {
                    if (h[j] < h[j + 1])
                    {
                        flag = false;
                        i = j + 1;
                    }
                    else
                    {
                        tmp++;
                    }
                }
                cnt = Math.Max(cnt, tmp);
            }
            WriteLine(cnt);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 31836
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

vector<bool> visited(105);
vector<vector<int>> edge(105);
bool dfs(int cur, int par) {
    // if a cycle doesn't exist, return true
    visited[cur] = true;
    bool ic = false;
    if (edge[cur].size() == 0) {
        return true;
    } else {
        for (int i = 0; i < edge[cur].size(); i++) {
            if (edge[cur][i] == par) {
                continue;
            }
            if (visited[edge[cur][i]]) {
                ic = true;
                break;
            } else {
                visited[edge[cur][i]] = true;
            }
            if (!dfs(edge[cur][i], cur)) {
                ic = true;
            }
        }
        if (ic) {
            return false;
        } else {
            return true;
        }
    }
}
int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % 2019;
    } else {
        return modpow(m, n - 1) * m % 2019;
    }
}
signed main() {
    long long v, e;
    cin >> v >> e;
    vector<int> ans;
    queue<int> zeros;
    vector<vector<int>> graph(v);
    vector<vector<int>> bgraph(v);
    vector<int> degree(v);
    vector<int> dp(v);
    REP(i, e) {
        // https/chess.com
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        bgraph[b - 1].push_back(a - 1);
        degree[b - 1]++;
    }
    REP(i, v) {
        if (degree[i] == 0) {
            zeros.push(i);
        }
    }
    vector<int> bans(v);
    while (zeros.size() > 0) {
        int cur = zeros.front();
        zeros.pop();
        ans.push_back(cur);
        bans[cur] = ans.size() - 1;
        for (int i = 0; i < graph[cur].size(); i++) {
            degree[graph[cur][i]]--;
            if (degree[graph[cur][i]] == 0) {
                zeros.push(graph[cur][i]);
            }
        }
    }
    int anss = 0;
    REP(i, v) {
        REP(j, bgraph[ans[i]].size()) { dp[i] = max(dp[bans[bgraph[ans[i]][j]]] + 1, dp[i]); }
    }
    REP(i, v) {
        if (dp[i] > anss) {
            anss = dp[i];
        }
    }
    cout << anss << endl;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, Q;
string S, SInitial;
set<int> st[26];
int type[30000];
int l[30000];
int r[30000];
char c[30000];
int idx[30000];

void input() {
    cin >> N;
    cin >> S;
    cin >> Q;
    for(int q = 0; q < Q; q++) {
        cin >> type[q];
        if(type[q] == 1) {
            cin >> idx[q] >> c[q];
        } else {
            cin >> l[q] >> r[q];
        }
    }
}

void solve() {
    SInitial = S;
    for(int i = 0; i < 26; i++) {
        st[i].clear();
        st[i].insert(N);
    }
    for(int i = 0; i < N; i++) {
        st[(int)(S[i] - 'a')].insert(i);
    }
    for(int q = 0; q < Q; q++) {
        if(type[q] == 1) {
            st[(int)(S[idx[q]-1] - 'a')].erase(idx[q] - 1);
            S[idx[q]-1] = c[q];
            st[(int)(S[idx[q]-1] - 'a')].insert(idx[q] - 1);
        } else {
            int ANS = 0;
            for(int i = 0; i < 26; i++) {
                auto itr = st[i].lower_bound(l[q] - 1);
                if(*itr <= r[q] - 1) ANS++;
            }
            cout << ANS << "\n";
        }
    }
    return;
}

int main() {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 25092
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int 
 
int main() {
  ll n, ct=0;
  cin >> n;
  string s;
  cin >> s;
  
  for(ll i=2;i<s.size() ; i++) {
      if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C') ct++;
  }
  cout << ct;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<limits.h>
#define ll long long
#define modulo 1000000007
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	int i,j,k;
	
	char a[h][w];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			cin>>a[i][j];
		}
	}
	
	int dp[h][w];
	bool flag = true;
	for(i=0;i<h;i++)
	{
		if(a[i][0] == '#')
		flag = false;
		
		if(flag)
		dp[i][0] = 1;
		else
		dp[i][0] = 0;
	}
	flag = true;
	for(j=0;j<w;j++)
	{
		if(a[0][j] == '#')
		flag = false;
		
		if(flag)
		dp[0][j] = 1;
		else
		dp[0][j] = 0;
	}
	
	for(i=1;i<h;i++)
	{
		for(j=1;j<w;j++)
		{
			dp[i][j] = 0;
			if(a[i-1][j] != '#')
			dp[i][j] += dp[i-1][j];
			
			if(a[i][j-1] != '#')
			dp[i][j] += dp[i][j-1];
			
			dp[i][j] %= modulo;
			dp[i][j] += modulo;
			dp[i][j] %= modulo;
		}
	}

	cout<<dp[h-1][w-1];
}

Measured memory_bytes: 5120
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll a,b,c,d;
    while (cin >> a>>b>>c>>d)
    {
        
        if(b>=c)cout<<"Yes\n";
        else if(d>=a)cout<<"No\n";
        else if((c/b+!!(c%b))<=(a/d+!!(a%d)))cout<<"Yes\n";
        else cout<<"No\n";
    }
}

Measured memory_bytes: 3600
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    A = [input() for _ in range(N)]
    print(len(set(A)))

if __name__ == '__main__':
    main()



Measured memory_bytes: 97780