akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
typedef long long ll;

using namespace std;

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

	cin>>n;

	vector<ll> p(n);

	for (size_t i = 0; i < n; i++) {
			cin>>p[i];
	}
	ll ans = 0;
  ll dp[200001];
  for (size_t i = 0; i < 200001; i++) {
  	dp[i] = 999999999999;
  }
	dp[0] = p[0];
	ans += 1;
	if (n == 1) {
		cout << ans;
		return 0;
	}
	dp[1] = min(p[0], p[1]);
	if (p[0] >= p[1]) {
		ans += 1;
	}
	if (n == 2) {
		cout << ans;
		return 0;
	}

	
	for (size_t i = 2; i < n; i++) {
		if (dp[i - 1] >= p[i]) {
			ans += 1;
		}
		dp[i] = min(dp[i - 1], p[i]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3328
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int t[2],a[2],b[2];
    cin>>t[0]>>t[1]>>a[0]>>a[1]>>b[0]>>b[1];
    int p=(a[0]-b[0])*t[0];
    int q=(a[1]-b[1])*t[1];
    if(p>0){
        p*=-1;
        q*=-1;
    }
    if(p+q<0){
        cout<<0<<endl;
    }
    else if(p+q==0){
        cout<<"infinity"<<endl;
    }
    else{
        // kサイクル目が終わると、点は k × (P + Q) の位置にあります。
        // その次のサイクルで 0 の位置を何回通ることになるでしょうか？

        int s=(-p)/(p+q);
        int t=(-p)%(p+q);
        if(t==0){
            cout<<s*2<<endl;
        }
        else{
            cout<<s*2+1<<endl;
        }
    }
    
}

Measured memory_bytes: 256
<?php
$n = int();
for($i = 0; $i < $n; $i++){
    list($X[], $Y[]) = ints();
}
$min = 10**10;
//2点を直径とする円に他の点が全て含まれる場合
for($i = 0; $i < $n; $i++){
    for($j = $i+1; $j < $n; $j++){
        $x = ($X[$i] + $X[$j])/2;
        $y = ($Y[$i] + $Y[$j])/2;
        $r2 = (($X[$i] - $X[$j]) ** 2 + ($Y[$i] - $Y[$j]) ** 2 ) / 4;
        if(enclose($x, $y, $r2)){
            $min = min($min, $r2);
        }
    }
}
for($i = 0; $i < $n; $i++){
    for($j = $i+1; $j < $n; $j++){
        for($k = $j+1; $k < $n; $k++){
            list($x, $y, $r2) = circleWith3Points($X[$i],$Y[$i],$X[$j],$Y[$j],$X[$k],$Y[$k]);
            if($r2 > 0 && enclose($x, $y, $r2)){
                $min = min($min, $r2);
            }
        }
    }
}
echo $min**0.5;

function circleWith3Points($x1, $y1, $x2, $y2, $x3, $y3){
    //二辺のベクトルを出す
    $xd1 = $x2-$x1;
    $yd1 = $y2-$y1;
    $xd2 = $x3-$x1;
    $yd2 = $y3-$y1;

    list($xd1, $yd1, $xd2, $yd2) = [$yd1, -$xd1, $yd2, -$xd2];//90度回転させて法線にする
    //二辺の中点を求める
    $x12 = ($x1+$x2)/2;
    $x13 = ($x1+$x3)/2;
    $y12 = ($y1+$y2)/2;
    $y13 = ($y1+$y3)/2;

    //以上より2直線の方程式は以下のように表現できる
    // xd1(Y-y12) = yd1(X-x12)
    // xd2(Y-y13) = yd2(X-x13)
    //整理すると
    // - yd1 * X + xd1 * Y - xd1 * y12 + yd1 * x12 = 0
    // - yd2 * X + xd2 * Y - xd2 * y13 + yd2 * x13 = 0
    $a1 = - $yd1;
    $b1 =   $xd1;
    $c1 = - $xd1 * $y12 + $yd1 * $x12;
    $a2 = - $yd2;
    $b2 =   $xd2;
    $c2 = - $xd2 * $y13 + $yd2 * $x13;
    if($a1*$b2 - $a2*$b1 == 0){
        return [-1,-1,-1];
    }
    $x = ($b1*$c2 - $b2*$c1)/($a1*$b2 - $a2*$b1); 
    $y = ($a2*$c1 - $a1*$c2)/($a1*$b2 - $a2*$b1); 
    $r2 = ($x1-$x)**2 + ($y1-$y)**2;
    return [$x, $y, $r2];
}
function enclose($x, $y, $r2){
    global $X, $Y, $n;
    $flag = true;
    for($i = 0; $i < $n; $i++){
        if(sqrt(($X[$i]-$x)**2 + ($Y[$i]-$y)**2) > sqrt($r2) + 10**-6){
            $flag = false;
        }
    }
    return $flag;
}

function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4604
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int length = arr.length;
		int[] counts = new int[length];
		int rCount = 0;
		for (int i = 0; i < length; i++) {
		    if (arr[i] == 'R') {
		        rCount++;
		    } else {
		        counts[i - 1] += rCount / 2 + rCount % 2;
		        counts[i] += rCount / 2;
		        rCount = 0;
		    }
		}
		int lCount = 0;
		for (int i = length - 1; i >= 0; i--) {
		    if (arr[i] == 'L') {
		        lCount++;
		    } else {
		        counts[i + 1] += lCount / 2 + lCount % 2;
		        counts[i] += lCount / 2;
		        lCount = 0;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < length; i++) {
		    if (i > 0) {
		        sb.append(" ");
		    }
		    sb.append(counts[i]);
		}
		System.out.println(sb);
   }
}


Measured memory_bytes: 40848
#include<bits/stdc++.h>
#define all(x)     (x).begin() , (x).end()
typedef long long int ll;
using namespace std;

const ll     mod = 1e9+7;
const double eps = 1e-9;


int n,m;
const int N=1e5+10;
vector<int>adj[N];
int dp[N];

int dfs(int i) {
    if(dp[i]!=-1)
        return dp[i];
    int cur=0;
    for(int j:adj[i])
            cur=max(cur,dfs(j));
    return dp[i]=cur+1;
}

void solve(){
    cin >> n  >> m;
    memset(dp,-1,sizeof(dp));
    while(m--) {
        int l,r;
        cin >> l >> r;
        l-- , r--;
        adj[l].push_back(r);
    }
    for(int i=0;i<n;++i) {
        dfs(i);
    }
    int ans=0;
    for(int i=0;i<n;++i)
        ans=max(ans,dp[i]);
    cout << ans-1 << "\n";
}


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


Measured memory_bytes: 11416
from collections import Counter
n = int(input())
s = [input() for _ in [0] * n]
s = Counter(s)
a = max(s.values())
b = s.most_common()[:list(s.values()).count(a)]
b = sorted(b, key=lambda x: x[0])
for i in b:
    print(i[0])


Measured memory_bytes: 48368
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  string s,t;
  cin >> s >> t;
  int a = s.size();
  int ans = 0;
  for(int i=0;i<a;i++){
    if(s.at(i) != t.at(i))ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3872
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

void solve(int mat[][7],int i, int j){

}

int main()
{
	fastio;
	int h,w,k,i,j;
	vector<vector<char>>mat,temp1,temp2; 
	vector<char> v(8);
	mat.push_back(v);
	mat.push_back(v);
	mat.push_back(v);
	mat.push_back(v);
	mat.push_back(v);
	mat.push_back(v);
	mat.push_back(v);
	mat.push_back(v);
	cin>>h>>w>>k;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>mat[i][j];
		}
	}
	temp1 = mat;
	temp2 = mat;
	int cnt=0;
	int rows = pow(2,h)-1,cols = pow(2,w)-1;
	for(i=0;i<rows;i++){
		temp1 = mat;
		int temp = i;
		int z = 0;
		while(temp){
			if(temp%2){
				for(j=0;j<w;j++){
					temp1[z][j]='.';
				}
			}
			temp/=2;
			z++;
		}

		for(j=0;j<cols;j++){
			temp2 = temp1;
			// for(int c=0;c<h;c++){
			// 	for(int b=0;b<w;b++){
			// 		cout<<temp2[c][b]<<" ";
			// 	}
			// 	cout<<endl;
			// }
			int temp = j;
			int z=0;
			while(temp){
				if(temp%2){
					for(int x=0;x<h;x++){
						temp2[x][z]='.';
					}
				}
				temp/=2;
				z++;
			}
			int currcnt=0;
			for(int x=0;x<h;x++){
				for(z=0;z<w;z++){
					if(temp2[x][z]=='#'){
						currcnt++;
					}
				}
			}
			//cout<<i<<" "<<j<<" "<<currcnt<<endl;
			if(currcnt==k){
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int main(){
  long a,b,c;
  while(cin>>a>>b>>c, a|b|c){
    long bx=-1,by=-1;
    long bestxy = INF;
    long bestaxby = INF;
    auto exec = [&](long x, long y){
      if(x+y < bestxy){
        bx = x; by =y;
        bestxy = x+y;
        bestaxby = a*x+b*y;
      }
      else if(x+y == bestxy && a*x+b*y<bestaxby){
        bx = x; by =y;
        bestaxby = a*x+b*y;
      }
    };
    rep(x,100001){
      if( (c+x*a)%b == 0) exec(x, (c+x*a)/b);
      if( (c-x*a)%b == 0) exec(x, abs(c-x*a)/b);
    }
    cout << bx << " " << by << endl;
  }

  return 0;
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i, begin, end) for(__typeof(end) i=begin; i<end; i++)
#define per(i, begin, end) for(__typeof(end) i=begin; i>=end; i--)

const int nax=1e5+5;
vector<int> g[nax];
vector<int> dp(nax), topo, vis(nax);
 
void dfs(int u){
	vis[u] = 1;
	for(int v:g[u])	if(!vis[v])
		dfs(v);
	topo.pb(u);
}
 
int main()
{
	#include<bits/stdc++.h>
    using namespace std;
    
	int n, m, u, v;
	cin >> n >> m;
	rep(i, 0, m){
		cin >> u >> v;
		g[u].pb(v);
	}
	for(int i=1; i<=n; i++)	if(!vis[i])
		dfs(i);
	reverse(topo.begin(), topo.end());
	for(auto u:topo){
		for(int v:g[u])
			dp[v] = max(dp[v], 1+dp[u]);
	}
	printf("%d\n", *max_element(dp.begin(), dp.end()));
}
 

Measured memory_bytes: 12140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long LL;

int main(){
    int n,m,like[30],k,a,cnt=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        like[i]=0;
    }
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>a;
            like[a-1]++;
        }
    }
    for(int i=0;i<m;i++){
        if(like[i]==n)cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()

    # 負数、 0数、 正数
    neg, zero, pos = [], [], []
    for a in A:
        if a < 0:
            neg.append(a)
        elif a == 0:
            zero.append(a)
        else:
            pos.append(a)
    neg.sort()
    pos.sort()

    prod_neg = len(neg) * len(pos)
    prod_zero = len(zero) * (len(neg)+len(pos))+len(zero)*(len(zero)-1)//2
    prod_pos = len(neg)*(len(neg)-1)//2 + len(pos)*(len(pos)-1)//2
    # print(prod_neg, prod_zero, prod_pos)
    # print(prod_neg+prod_zero+prod_pos)
    # print(N*(N-1)//2)

    if prod_neg >= K:
        # 二分探索
        left = neg[0]*pos[-1]-1
        right = 0
        while right-left > 1:
            mid = (right + left)//2
            # しゃくとり法
            counter = 0
            ns, ps = 0, 0
            for ns in range(len(neg)):
                while ps < len(pos) and neg[ns]*pos[ps] > mid:
                    ps += 1
                if ps == len(pos):
                    break
                counter += len(pos)-ps
            # print("{} in [{}, {}]  => {}".format(mid, left, right, counter))
            if counter < K:
                left = mid
            else:
                right = mid
        print(right)
    elif prod_zero + prod_neg >= K:
        print(0)
    else:
        neg.sort(reverse=True)
        # 二分探索
        left = 0
        right = 0
        if len(neg) > 0:
            right = max(neg[-1]**2, right)
        if len(pos) > 0:
            right = max(pos[-1]**2, right)
        right += 1
        while right - left > 1:
            mid = (left + right)//2
            # しゃくとり法
            counter = 0
            start, end = 0, len(pos)-1
            # print("{} in [{}, {}]".format(mid, left, right))
            for start in range(len(pos)):
                while end >= start and pos[start]*pos[end] >= mid:
                    end -= 1
                if end <= start:
                    break
                counter += end-start
                # print("addA: ", end-start)
            start, end = 0, len(neg)-1
            for start in range(len(neg)):
                while end >= start and neg[start]*neg[end] >= mid:
                    end -= 1
                if end <= start:
                    break
                counter += end-start
                # print("addB: ", end-start)
            # print("counter: {}".format(counter))
            if counter < K-prod_neg-prod_zero:
                left = mid
            else:
                right = mid
        print(left)


if __name__ == '__main__':
    main()


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

int main(){
  int t1,t2;
  ll a1,a2,b1,b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;

  a1=a1*t1;
  a2=a2*t2;
  b1=b1*t1;
  b2=b2*t2;
  if(a1+a2<b1+b2){
    swap(a1,b1);
    swap(a2,b2);
  }
  if(a1+a2==b1+b2){
    cout << "infinity" << endl;
    return 0;
  }else{
    if(a1>b1){
      cout << "0" << endl;
      return 0;
    }else{
      ll c=b1-a1;
      ll d=(a1+a2)-(b1+b2);
      ll ans;
      if(c%d==0) ans=c/d*2;
      else ans=c/d*2+1;

      cout << ans << endl;
    }
  }
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int64_t> pq;
  int64_t A;
  rep(i,N) {
    cin >> A;
    pq.push(A);
  }
  int m = M;
  int64_t v;
  while(m > 0) {
    if ( pq.empty() ) {
      break;
    }
    v = pq.top();
    pq.pop();
//    cout << v << "-->";
    v = v / 2;
//    cout << v << endl;
    m--;
    if ( v > 0 ) {
      pq.push(v);
    }
  }
  int64_t sum = 0;
  while(!pq.empty()) {
    v = pq.top();
//    cout << v << endl;
    pq.pop();
    sum += v;
  }
  cout << sum << endl;
}

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

namespace ABC145A
{
	class Program
	{
		static void Main(string[] args)
		{
			int r,n;
			var word = Console.ReadLine().Split(' ');
			r = int.Parse(word[0]);
			n = r * r;
			Console.WriteLine(n);

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int s[10003],t[503];
	int n,q;
	cin>>n;REP(i,n)cin>>s[i];
	cin>>q;REP(i,q)cin>>t[i];
	int ct = 0;
	REP(i,q){
		REP(j,n){
			if(s[j] == t[i]){ct++;break;}
		}
	}
	cout << ct << endl;
  return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int E[n+1] = {}, W[n+1] = {};
    for (int i = 1; i <= n; i++) {
        E[i] += E[i-1];
        W[i] += W[i-1];
        if (s[i-1] == 'E') E[i]++;
        else W[i]++;
    }
    int ans = 1e9;
    for (int i = 1; i <= n; i++) {
        chmin(ans, n - 1 - (E[i-1] + W[n] - W[i]));
    }
    cout << ans << endl;
}

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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;

int main() {
	int n; cin >> n;
	vector<int> a(n), order(n);
	rep(i,n) cin >> a[i];
	rep(i,n) order[a[i] - 1] = i;

	set<int> st;
	st.insert(-1);
	st.insert(n);

	ll ans = 0;
	rep(i,n) {
		auto itr = st.lower_bound(order[i]);
		ll right = (*itr) - order[i];
		itr--;
		ll left = order[i] - (*itr);
		ll tmp = a[order[i]] * left * right;
		ans += tmp;
		st.insert(order[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 11136
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
		String s;
		String[] t;
		int a;
		try{
			while((s=reader.readLine()) !=null){
				a=Integer.parseInt(s);
				String[] n =new String[a];
				for(int j =0;j<a;j++){
					t=reader.readLine().split(" ");
					int[] r=new int[3];
					for(int i=0;i<t.length;i++){
						r[i] =Integer.parseInt(t[i]);
					}
					Arrays.sort(r);
					if(r[0] ==0 ||r[1] ==0 ||r[2] ==0){System.out.println("NO");}
					if(((r[0])*(r[0]))+((r[1])*(r[1])) ==((r[2])*(r[2]))){
						n[j] ="YES";
					}else{
						n[j] ="NO";
					}
				}
				for(int k =0;k<a;k++){
					System.out.println(n[k]);
				}
				continue;
			}
		}catch(IOException e){
			System.exit(0);
		}
	}
}

Measured memory_bytes: 20208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>void chmin(T &a,T b){a=min(a,b);}
using namespace std;

void solve(){
	string s;
	cin>>s;
	int k;
	cin>>k;
	rep(i,s.size()){//前から見ていく。
		int sum;
		sum=26-(int)(s[i]-'a');
		sum%=26;
		if(k-sum>=0){
			s[i]='a';//'a'に出来るならする。出来ないなら操作しない。
			k-=sum;
		}
	}
	if(k>0){
		k%=26;//余った分は末尾を操作
		if(s.back()+k>'z'){
			int add=(s.back()+k-'z')%26-1;
			s.back()='a'+add;
		}
		else s.back()+=k;
	}
	cout<<s<<endl;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 592
/*
N M
s1 c1
 
⋮
 
sM cM
 
 
*/
 
#include<iostream>
#include<string>
using namespace std;
 
int main(void) {
  	int N, M;
  	cin >> N >> M;
  	int s[M];
  	int c[M];
  
  	for (int m = 0; m < M; m++){ cin >> s[m] >> c[m]; }
  	
  	int startnum = 1;
  	for (int n = 1; n < N; n++){
      startnum *= 10;
    }
  	int endnum = startnum*10 - 1;
  	if(N == 1) startnum = 0;
  	
  	
    for (int n = startnum; n <= endnum; n++){
        bool allok = true;
      	
      	for (int i = 0; i < M; i++){
			int kirisute = n;
          	for (int count = 0; count < N - s[i]; count++){
	          kirisute /= 10;
	        }
          	//if(n > 700) cout << c[i] << endl;
	        if (kirisute % 10 == c[i]) ;
          	else {allok = false; break;}
        }
      	if (allok) {cout << n << endl; return 0;}
    }
  	cout << -1 << endl;
  
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

vector<string> v;

void gen(const string &s, char c, int n) {
  if (n == 0) {
    v.push_back(s);
    return;
  }
  for (char x = 'a'; x <= c; ++x) {
    gen(s+x, max((char)(x+1), c), n-1);
  }
}

void solve() {
  int n; cin >> n;
  gen("a", 'b', n-1);
  sort(v.begin(), v.end());
  for (const string &s: v) {
    cout << s << endl;
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 7252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e3+6;
const int mod = 1e9+7;
const int inf = 1e8;
void solve(){
    int x;
    cin>>x;
    if(x<1200)cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    bool g=false;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            g=true;
            break;
        }
    }
    if(!g) cout<<"NG"<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int x,a;cin>>x>>a;
    if(x<a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
aa = 0
mi = 10 ** 10
flag = True
for _ in range(n):
    a, b = [int(i) for i in input().split()]
    aa += a
    if a != b:
        flag = False
    if a > b:
        mi = min(mi, b)
if flag:
    print(0)
else:
    print(aa-(mi if mi != 10**10 else 0))


Measured memory_bytes: 3060
#include<cstdio>
#include<vector>

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

using namespace std;

const int INF=1<<29;

struct Rect{ int t,l,b,r,id; };

int n,ans[10];

void simulate(vector<Rect> rc,int &order){
	while(!rc.empty()){
		int i0=0;
		rep(i,rc.size()){
			if(rc[i0].l>rc[i].l || (rc[i0].l==rc[i].l && rc[i0].t>rc[i].t)) i0=i;
		}
		ans[rc[i0].id]=order++;

		int r=INF,x1=rc[i0].l,x2=rc[i0].r,y=rc[i0].b;
		rc.erase(rc.begin()+i0);
		rep(i,rc.size()){
			if(rc[i].t<y && y<rc[i].b && rc[i].l<=x2) r=min(r,rc[i].l);
		}

		vector<Rect> next;
		rep(i,rc.size()){
			if(rc[i].b<=y && x1<=rc[i].l && rc[i].r<=r){
				next.push_back(rc[i]);
				rc.erase(rc.begin()+i);
				i--;
			}
		}
		if(!next.empty()) simulate(next,order);
	}
}

int main(){
	for(int T=0,n;scanf("%d",&n),n;T++){
		if(T) putchar('\n');

		vector<Rect> rc(n);
		rep(i,n){
			scanf("%d%d%d%d",&rc[i].l,&rc[i].t,&rc[i].r,&rc[i].b);
			if(rc[i].t>rc[i].b) swap(rc[i].t,rc[i].b);
			if(rc[i].l>rc[i].r) swap(rc[i].l,rc[i].r);
			rc[i].id=i;
		}

		int order=1;
		simulate(rc,order);

		rep(i,n) printf("%d\n",ans[i]);
	}

	return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> d(K);
  vector<bool> hvany(N,false);
  int a;
  for (int i=0; i<K; i++) {
    cin >> d.at(i);
    for (int j=0; j<d.at(i); j++) {
      cin >> a;
      hvany.at(a-1) = true;
    }
  }
  int sum=0;
  for (int i=0; i<N; i++) {
    if ( hvany.at(i)  == false ) sum++ ;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int x[9],y[9];
int ans=0,a,b;
void print_permutation(int n,int *A,int cur)
{
    if (cur==n)
    {
        ans++;
        int p1=0,p2=0;
        for (int i=0;i<n;i++) 
        {   
            if (A[i]!=x[i]) p1=1;
            if (A[i]!=y[i]) p2=1;
        }
        if (!p1) a=ans;
        if (!p2) b=ans;
    }
    else for (int i=1;i<=n;i++)
    {
        int ok=1;
        for (int j=0;j<cur;j++)
            if (A[j]==i) ok=0;
        if (ok) {A[cur]=i; print_permutation(n,A,cur+1);}
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,A[9];
    cin>>n;
    for (int i=0;i<n;i++)
        cin>>x[i];
    for (int i=0;i<n;i++)
        cin>>y[i];
    print_permutation(n,A,0);
    cout<<abs(a-b)<<'\n';
    return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)
print(ans)


Measured memory_bytes: 2940
class Node{
  constructor(id, parent, children) {
    this.id = id;
    this.parent = parent;
    this.children = children;
  }

  get type() {
    if (this.parent === null) return 'root';
    if (this.children.length === 0) return 'leaf';
    return 'internal node';
  }

  get depth() {
    const getDepth = (node, i) => {
      return node.parent === null ? i : getDepth(node.parent, i + 1);
    };
    return getDepth(this, 0);
  }

  toString() {
    return `node ${this.id}: parent = ${this.parent !== null ? this.parent.id : -1}, depth = ${this.depth}, ${this.type}, [${this.children.map(n => n.id).join(', ')}]`;
  }
};

class Tree {
  static get Node() {
    return Node;
  }

  constructor(n) {
    this.nodes = [];
  }

  add(id, childrenIds) {
    let node = this.find(id);
    childrenIds.forEach((cid) => {
      let c = this.find(cid);
      c.parent = node;
      c.id = cid;
      node.children.push(c);
    })
  }

  find(id) { return this.nodes[id] || (this.nodes[id] = new Tree.Node(id, null, []));}

  print() { console.log(this.nodes.sort((a, b) => a.id - b.id).map(n => n.toString()).join('\n')); }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let tree = new Tree(n);
  let id, k, childrenIds;
  lines.map(l => l.split(' ')).forEach(function(line) {
    id = Number(line.shift());
    k = Number(line.shift());
    childrenIds = line.map(Number);
    tree.add(id, childrenIds);
  });
  tree.print();
})();



Measured memory_bytes: 158076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll h, n, a;
	cin >> h >> n;
	
	ll ans = 0;
	rep(i, 1, n){
		cin >> a;
		ans += a;
	}
	if(ans >= h){
		print("Yes")
	}
	else{
		print("No")
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


// queueを用いた場合の実装(経路復元無し)
const int MAX_E = 100100;
const int MAX_V = 100100;
struct edge{int to, cost;};
int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int last[MAX_V];

void dijkstra(int s){
  // greater<PII>を指定することでfirstが小さい順に取り出せるようにする
  priority_queue<PII, vector<PII>, greater<PII> > que;
  fill(d,d+V,INF); d[s] = 0; last[s]=0; que.push(MP(0,s));
  while(!que.empty()){
    PII p = que.top(); que.pop();
    int v = p.second;
    if(d[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e = G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to] = d[v]+e.cost; last[e.to]=v;
        que.push(PII(d[e.to], e.to));
      }
    }
  }
}

signed main(){
	int n,m; cin>>n>>m; V=n;
	rep(i,m){
		int a,b; cin>>a>>b; a--; b--;
		edge e1,e2; e1.to=b, e1.cost=1;
		e2.to=a, e2.cost=1; G[a].PB(e1); G[b].PB(e2);
	}
	dijkstra(0);
	cout<<"Yes"<<endl;
	reps(i,n-1) cout<<last[i]+1<<endl;


	return 0;
}


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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i=0; i<=a; i++){
        int a_i = 500*i;
        if(a_i > x){
            break;
        }
        for(int j=0; j<=b; j++){
            int b_j = a_i + j*100;
            if(b_j > x){
                break;
            }
            for(int k=0; k<=c; k++){
                int c_k = b_j + k*50;
                if(c_k == x){
                    ans++;
                    break;
                }
                if(c_k > x){
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ac=(b)/c - (a-1)/c;
  ll ad=(b)/d - (a-1)/d;
  ll lcm=(c*d)/gcd(c,d);
  ll dup=(b)/lcm - (a-1)/lcm;
  cout<<(b-a+1)-(ac+ad-dup);
}

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

int intervalValue(int i){
	return  (pow(3.0,i) - 1) / 2;
}

int intervalValueNumber(int n){
	if( n == 1) return 1;
	int i;
	for( i = 0; intervalValue(i) < n; i++){
	}
	return i-1;
}
int insertionSort(int A[],int n,int g){
	int cnt = 0;
	for(int i = g ; i <= n-1; i++){
		int v = A[i];
		int j = i - g;
		while( j >= 0 && A[j] > v){
			A[j+g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j+g] = v;
	}
	return cnt;
}
int shellSort(int A[],int n){
	int cnt = 0;
	int m = intervalValueNumber(n);
	int *G = new int[m];
	cout << m << endl;
	for(int i = 0; i < m;i++){
		G[i] = intervalValue(m-i);
	}
	for(int i = 0 ; i < m; i++){
		cnt += insertionSort(A,n,G[i]);
	}
	cout << G[0];
	for(int i = 1; i < m; i++){
		cout <<" "<<G[i];
	}
	cout<<endl;
	delete[] G;
	return cnt;
}
void printArray(int A[],int n){
	for(int i = 0; i < n ; i++){
		cout << A[i] << endl;
	}
}

int main()
{
	int n;
	cin >> n ;
	int *A = new int[n];
	for(int i = 0 ; i < n; i++){
		cin >> A[i];
	}
	int count = shellSort(A,n);
	cout << count<<endl;
	printArray(A,n);
	delete[] A;
	return 0;
}





Measured memory_bytes: 6684
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 200
int main() {
	char s[N] = "", x[N]="", ss[N] = "", *p1, *p2;
	int i= 0,j,k,flg = 0;
	char n[2][5] = { {"No"},{"Yes"} };
	fgets(s,sizeof(s),stdin);
	fgets(x,sizeof(x),stdin);
	
	s[strlen(s) - 1] = '\0';
	x[strlen(x) - 1] = '\0';
	strcat(ss, s);
	strcat(s, ss);
	p1 = s;

	while (i<=strlen(s)-strlen(x)) {
		j = 0;
		if (s[i] == x[j]) {
			for (k = 1; k <= strlen(x); k++)
				if (x[j + k] != s[i + k]) break;
		}
		if (k == strlen(x)) {
			flg = 1;
			break;
		}
		i++;
	}

	printf("%s\n", n[flg]);
	return 0;
}

Measured memory_bytes: 524
N,K=map(int,input().split())
A=list(map(int,input().split()))

ans=0

for i in range(N):
    first_num = len([x for x in A[i+1:] if A[i]>x])
    roop_num = len([x for x in A if A[i]>x])
    ans += first_num*K
    ans += roop_num*(K*(K-1))//2

ans = ans%(10**9+7)

print(str(ans))

Measured memory_bytes: 43996
#include <bits/stdc++.h>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <list>
using namespace std;
	
int main(){
	int N;
	cin >> N;
	int A[N];
	int B[N];
	for (int i = 0;i<N;i++){
		cin >> A[i];
	}
	for (int i = 0;i<N;i++){
		cin >> B[i];
	}
	int count = 0;
	long int sumMinus = 0;
	for (int i = 0;i<N;i++){
		if (B[i] > A[i]){
			count++;
			sumMinus = sumMinus + (B[i] - A[i]);
		}
	}
	int C[N];
	for(int i = 0;i<N;i++){
		C[i] = A[i]-B[i];
	}
	int size = sizeof(C)/sizeof(C[0]);
	sort(C,C + size);
	int loop = 1;
	int i = N-1;
	if (C[N-1] <= 0)
		loop = 0;
	if (sumMinus == 0)
		loop = 0;
	while(loop){
		sumMinus = sumMinus - C[i];
		count++;
		if (sumMinus <= 0)
			loop = 0;
		i--;
		if (C[i] <= 0)
			loop = 0;
	}
	if (sumMinus > 0)
		cout << -1 << endl;
	else
		cout << count << endl;
}

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

const int N=2e5+5;
const int MOD=1e9+7;
typedef pair<long long,long long> pll;
int n,t,ans=1,add,c0,c1;
map<pll,int> m[2];
int Pow[N];

long long GCD(long long x,long long y){
	if(y==0ll) return x;
	return GCD(y,x%y);
}

int main(){
	Pow[0]=1;
	for(int i=1;i<N;i++) Pow[i]=1ll*Pow[i-1]*2%MOD;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		long long x,y;
		scanf("%lld%lld",&x,&y);
		if(x==0ll){
			if(y==0ll) add++;
			else c0++;
		}else if(y==0ll) c1++;
		else{
			int s=0;
			if(x<0ll){
				x=-x;
				y=-y;
			}
			if(y<0ll){
				s=1;
				y=-y;
			}
			long long g=GCD(x,y);
			x/=g;y/=g;
			m[s][make_pair(x,y)]++;
		}
	}
	for(map<pll,int>::iterator it=m[0].begin();it!=m[0].end();it++){
		pll i=it->first;
		pll j=make_pair(i.second,i.first);
		ans=1ll*(Pow[it->second]+Pow[m[1][j]]-1)%MOD*ans%MOD;
	}
	for(map<pll,int>::iterator it=m[1].begin();it!=m[1].end();it++){
		pll i=it->first;
		pll j=make_pair(i.second,i.first);
		if(m[0].find(j)==m[0].end()) ans=1ll*ans*Pow[it->second]%MOD;
	}
	ans=1ll*ans*(Pow[c0]+Pow[c1]-1)%MOD;
	ans=(ans+add)%MOD;
	ans=(ans+MOD-1)%MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 23288
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

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

Measured memory_bytes: 19168
# -*- coding: utf-8 -*-

import sys
import os
import math

for s in sys.stdin:

    n = int(s)
    if n == 0:
        break
    P = []

    for i in range(n):
        x, y = map(float, input().split(','))
        P.append(complex(x, y))

    def get_intersections(p0, p1):
        """
        :type p0: complex
        :type p1: complex
        :return:
        """
        dist = abs(p0 - p1)

        if dist > 2:
            return []
        elif dist == 2:
            return [(p0 + p1) / 2]
        else:
            m = (p0 + p1) / 2
            v = m - p0
            w = complex(v.imag, -v.real)
            n = w / abs(w)
            d = abs(v)
            l = math.sqrt(1 - d ** 2)

            inter0 = m + l * n
            inter1 = m - l * n
            return [inter0, inter1]


    intersections = []
    for i in range(n):
        for j in range(i+1, n):
            intersections += get_intersections(P[i], P[j])

    counts = []

    # each intersection, it is in how many circles?
    for intersection in intersections:
        cnt = 0
        for p in P:
            if abs(intersection - p) <= 1.01:
                cnt += 1
        counts.append(cnt)

    if counts:
        print(max(counts))
    else:
        print(1)

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int A[100010];
int main(){

    cin >> N;
    bool is_even = true;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] % 2 == 1) is_even = false;
    }
    if(is_even){
        cout << "second" << endl;
    }
    else {
        cout << "first" << endl;
    }

    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	s := getString()

	fmt.Printf("%c%d%c\n", s[0], len(s)-2, s[len(s)-1])
}


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

#define MAX_N (500)
#define MAX_C (30)
#define INF (1000000000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, C, Ds[MAX_N * MAX_N], cs[MAX_N * MAX_N];
  scanf("%d %d", &N, &C);
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      scanf("%d", &Ds[j + i * C]);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%d", &cs[j + i * N]);
      cs[j + i * N]--;  // NOTE : changed input
    }
  }

  // count how many colors there are in each group
  int num_colors[3 * MAX_C] = {};
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      const int color = cs[j + i * N], group = (i + j) % 3;
      num_colors[color + group * C]++;
    }
  }

  // solve
  int ans = INF;
  for (int c0 = 0; c0 < C; c0++) {    // color of first group
    for (int c1 = 0; c1 < C; c1++) {  // color of second group
      if (c1 == c0) {
        continue;
      }
      for (int c2 = 0; c2 < C; c2++) {  // color of third group
        if (c2 == c0 || c2 == c1) {
          continue;
        }
        // calculate the cost to change colors
        int cost = 0;
        for (int c = 0; c < C; c++) {
          cost += num_colors[c + 0 * C] * Ds[c0 + c * C];
        }
        for (int c = 0; c < C; c++) {
          cost += num_colors[c + 1 * C] * Ds[c1 + c * C];
        }
        for (int c = 0; c < C; c++) {
          cost += num_colors[c + 2 * C] * Ds[c2 + c * C];
        }
        ans = min(ans, cost);
      }
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
unsigned long long a=2,b=1,c;int n;
int main(){
	scanf("%lld",&n);
	if (n==1){
		puts("1");
		return 0;
	}else if (n==0){
		puts("2");
		return 0;
	}
	for (int i=2;i<=n;++i){
		c=a+b;
		a=b;
		b=c;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;*/
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef vector<int> vec;
//typedef pair<int,int> pii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define fi first
#define se second
/*#define tupfi(v,i) get<0>(v[i])
#define tupse(v,i) get<1>(v[i])
#define tupth(v,i) get<2>(v[i])
#define mt make_tuple */
#define pb push_back
#define mp make_pair
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--)
#define endl "\n"
typedef long long ll;
int main(){
ios::sync_with_stdio(0);
cin.tie(0); 
	ll t;t=1;
	while(t--){
			int a,b,c;
			cin>>a>>b>>c;
			cout<<c<<" "<<a<<" "<<b<<endl;
	}
	return 0;
	}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS )

class Point {
public:
	double x, y;
	Point(double x = 0, double y = 0) :
			x(x), y(y) {
	}

	Point operator +(Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator *(double a) {
		return Point(x * a, y * a);
	}
	Point operator /(double a) {
		return Point(x / a, y / a);
	}

	double abs() {
		return sqrt(norm());
	}
	double norm() {
		return x * x + y * y;
	}
	bool operator <(const Point& p) const {
		return x != p.x ? x < p.x : y < p.y;
	}
	bool operator ==(const Point& p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;

class Segment {
public:
	Point p1, p2;
};

double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

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

bool isOrthogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
	return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

int main() {

	int q;
	scanf("%d", &q);

	for (int i = 0; i < q; ++i) {
		int p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y;
		scanf("%d %d %d %d %d %d %d %d", &p0x, &p0y, &p1x, &p1y, &p2x, &p2y, &p3x, &p3y);
		Point p1(p0x, p0y);
		Point p2(p1x, p1y);
		Point p3(p2x, p2y);
		Point p4(p3x, p3y);

		Segment s1;
		s1.p1 = p1;
		s1.p2 = p2;

		Segment s2;
		s2.p1 = p3;
		s2.p2 = p4;

		if (isOrthogonal(s1, s2)) {
			cout << 1 << endl;
		} else if (isParallel(s1, s2)) {
			cout << 2 << endl;
		} else {
			cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3244