akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

const int p = 998244353;
const int N_MAX = 300000;
long long fact[N_MAX+1];

void init(int n) {
	fact[0] = 1;
	for(int i=1;i<=n;i++) fact[i] = (fact[i-1] * i) % p;
}
long long inv(long long x) {
	long long r0 = x, r1 = p;
	long long a0 = 1, a1 = 0;
	long long b0 = 0, b1 = 1;
	while(r1 > 0) {
		long long q1 = r0 / r1;
		long long r2 = r0 % r1;
		long long a2 = a0 - q1 * a1;
		long long b2 = b0 - q1 * b1;
		r0 = r1;
		r1 = r2;
		a0 = a1;
		a1 = a2;
		b0 = b1;
		b1 = b2;
	}
	a0 %= p;
	if(a0 < 0) a0 += p;
	return a0;
}

int main() {
	long long n, a, b, k;
	cin >> n >> a >> b >> k;
	init(n);
	long long count = 0;
	for(long long x=0;x<=n;x++) {
		long long t = k - a * x;
		if(t < 0 || b * n < t || t % b != 0) continue;
		long long y = t / b;
		long long cmbx = (((fact[n] * inv(fact[x])) % p) * inv(fact[n-x])) % p;
		long long cmby = (((fact[n] * inv(fact[y])) % p) * inv(fact[n-y])) % p;
		count = (count + cmbx * cmby) % p;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[202020];
int main()
{
	int now=0,ans=0,l;
	scanf("%s",s);
	l=strlen(s);
	for(int i=0;i<l;i++)
		if(s[i]=='T')
		{
			now++;
			ans=max(now,ans);
		}
		else
			now--;
	printf("%d",ans*2);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    string S;

    cin >> S;

    if(S.length()%2 != 0){
        cout << "No" << endl;
        exit(0);
    }else{
        for(int i = 0; i <= S.length()-2; i+=2){
            if(S.substr(i,2) != "hi"){
                cout << "No" << endl;
                exit(0); 
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
X = int(input())

num_list = []
for i in range(1, int(1000**0.5)+1):
    for j in range(2, 11):
        if i**j <= 1000:
            num_list.append(i**j)

for num in sorted(num_list, reverse=True):
    if num <= X:
        print(num)
        break

Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      	int n,a;
      	cin>>n>>a;
      	n%=500;
      	if(n<=a)
        cout<<"Yes";
      	else
        cout<<"No";
      	cout<<endl;
    	return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
    unsigned long n;
    scanf("%lu", &n);
    unsigned long int a, b, steps, ans;
    
    for(int i=1; i<= sqrt(n); i++) {
        if(n%i==0) {
            a = i;
            b = n/a;
            steps = a + b - 2;
            if(i==1) {
                ans = steps;
            } else {
                if(steps<ans) {
                    ans = steps;
                }
            }
        }
    }
    
    printf("%lu", ans);

    return 0;
}

Measured memory_bytes: 128
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.List.Split (splitOneOf)

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve <$> replicateM n (map read <$> splitOneOf ": " <$> getLine) >>= mapM_ putStrLn
    main

solve :: [[Int]] -> [String]
solve xs = ["lunch " ++ ratio ls, "dinner " ++ ratio ds, "midnight " ++ ratio ms]
  where ms = filter (\(h:_) -> h >= 21 || h < 2) xs
        ds = filter (\(h:_) -> h >= 18 && h < 21) xs
        ls = filter (\(h:_) -> h >= 11 && h < 15) xs
ratio :: [[Int]] -> String
ratio xs | null xs = "no guest"
         | otherwise = show $ length (filter f xs) * 100 `div` length xs
  where f [h,sm,em] | sm > em = 60 + em - sm <= 8
                    | otherwise = em - sm <= 8



Measured memory_bytes: 4688
#include <iostream>
#include <queue>

#define W 100
#define B 200

using namespace std;

class PointQueue{
	public:
		queue<int> x;
		queue<int> y;

		void push(int px,int py);
		int frontX();
		int frontY();
		void pop();
		int size();
};

void PointQueue::push(int px,int py){
	x.push(px);
	y.push(py);
}

int PointQueue::frontX(){
	return x.front();
}
int PointQueue::frontY(){
	return y.front();
}

void PointQueue::pop(){
	x.pop();
	y.pop();
}

int PointQueue::size(){
	return x.size();
}

int max(int a,int b){
	if(a>=b)return a;
	else return b;
}

int data[52][52];
int flag[52][52];



int main(){

	PointQueue q;

	int w,h;
	while(cin>>w>>h){
		if(w==0&&h==0)break;

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

	for(int i=0;i<=h+1;i++){
		for(int j=0;j<=w+1;j++){
			char tmp;

			if(i==0 || i==h+1 || j==0 || j==w+1){
				data[i][j]=-1;
				flag[i][j]=1;
			}
			else{
				cin>>tmp;
				if(tmp=='.'){
					flag[i][j]=0;
					data[i][j]=0;
				}
				else if(tmp=='W'){
					data[i][j]=W;
					flag[i][j]=1;
				}
				else if(tmp=='B'){
					data[i][j]=B;
					flag[i][j]=1;
				}
			}
		}
	}

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			int state=0;
			int space=0;
			if(flag[i][j]==0){
				q.push(j,i);
				flag[i][j]=1;
				while(q.size()!=0){
					space++;
					int topX=q.frontX();
					int topY=q.frontY();
					q.pop();

					for(int k=0;k<4;k++){
						int nextX=dx[k]+topX;
						int nextY=dy[k]+topY;

						if(flag[nextY][nextX]==0){
							q.push(nextX,nextY);
							flag[nextY][nextX]=1;
						}
						else if(data[nextY][nextX]==W){
							if(state==B){
								space=-10000000;
							}
							else{
								state=W;
							}
						}
						else if(data[nextY][nextX]==B){
							if(state==W){
								space=-10000000;
							}
							else{
								state=B;
							}
						}
					}
				}
				if(state==W) ansW += max(0,space);
				else if(state==B) ansB += max(0,space);
			}
		}
	}

	cout<<ansB<<" "<<ansW<<endl;
	}

	return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int r,c, sum, sum_all=0;
	cin>>r>>c;
	vector<vector<int> > x(r, vector<int>(c));
	int i, j;
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
		cin>>x[i][j];	
		}
	}
	
	for(i=0;i<r;i++){
		sum=0;
		for(j=0;j<c;j++){
			sum += x[i][j];
			cout << x[i][j] << ' ';
		}
		cout << sum << endl;
	}
	for(j=0;j<c;j++){
		sum=0;
		for(i=0;i<r;i++){
			sum += x[i][j];
		}
		cout << sum;
		sum_all += sum;
		cout << ' ';
	}
	
	cout << sum_all << endl;
	return 0;
}

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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

const int _n = 2e6 + 10;
vector<int> Fact(_n), Inv(_n);
const int kmod = 1000000007;

int mul(int a, int b, int mod = kmod)
{
    return (long long)a * b % mod;
}

int add(int a, int b, int mod = kmod)
{
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b, int mod = kmod)
{
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int power(int base, int index, int mod = kmod)
{
    if (index == 0)
        return 1;
    int temp = power(base, index / 2, mod);
    temp = mul(temp, temp, mod);
    if (index & 1)
        temp = mul(temp, base, mod);
    return temp;
}

int mod_inv(int x, int mod = kmod)
{
    return power(x, kmod - 2);
}

void pre()
{
    Fact[0] = 1;
    for (int i = 1; i < _n; ++i)
        Fact[i] = mul(Fact[i - 1], i);
    Inv[_n - 1] = mod_inv(Fact[_n - 1]);
    for (int i = _n - 2; i >= 0; --i)
        Inv[i] = mul(Inv[i + 1], (1 + i));
}

int ncr(int n, int r)
{
    if (n < 0 || r < 0 || n - r < 0)
        return 0;
    return mul(Fact[n], mul(Inv[r], Inv[n - r]));
}

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int k;
        cin >> k;
        pre();
        int res = 0;
        string s;
        cin >> s;
        int n = s.length();
        for (int len = n; len <= n + k; len++)
            res = add(res, mul(ncr(len - 1, n - 1), mul(power(26, n + k - len), power(25, len - n))));
        cout << res << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 19908
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

int a,b,c,d;cin>>a>>b>>c>>d;
  
if((abs(b-a)<=d&&abs(c-b)<=d)||(abs(a-c)<=d)){
  cout<<"Yes"<<endl;
}else{
  cout<<"No"<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  ll n, m; cin >> n >> m;
  vector<vector<int>> M(n+1);
  Vl h(n+1);
  Rep(i, 1, n) cin >> h[i];
  rep(i, 0, m){
    ll a, b; cin >> a >> b;
    M[a].push_back(b);
    M[b].push_back(a);
  }


  ll cnt = 0;
  Rep(i, 1, n){
    ll H = h[i];
    bool f = true;
    rep(j, 0, M[i].size()){
      if(H <= h[M[i][j]]) f = false;
    }
    if(f) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 9068
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                int tmp = m * i + n * j - i * j * 2;
                if (tmp == k) {
                    out.println("Yes");
                    return;
                }
            }
        }

        out.println("No");
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());

    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 23252
from collections import defaultdict
import itertools

d = defaultdict(int)

N = int(input())
for _ in range(N):
    s = input()
    if s.startswith('M'):
        d['M'] += 1
    elif s.startswith('A'):
        d['A'] += 1
    elif s.startswith('R'):
        d['R'] += 1
    elif s.startswith('C'):
        d['C'] += 1
    elif s.startswith('H'):
        d['H'] += 1

answer = 0
for x, y, z in list(itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3)):
    answer += d[x] * d[y] * d[z]
print(answer)

Measured memory_bytes: 3316
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if lc == 1
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

kk = inputs[0][1]
str = inputs[1][0]

# body
if $debugFlag
  p kk
  p str
end

str[kk-1..kk-1] = str[kk-1..kk-1].downcase
puts str


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
using namespace std;


ll llmin(ll x, ll y){
	if (x < y) return x;
	return y;
}

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}


int main(){
	int n, x, t;
	cin >> n >> x >> t;
	if (n % x == 0) cout << n/x*t << endl;
	else cout << (n/x+1)*t << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
 
int main()
{
  int n;
  int ans;
  int i;
  bool approved = true;
 
  scanf("%d", &n);
  for (i = 0; i < n; i++)
  {
    scanf("%d", &ans);
    if (ans % 2 == 0 && ans % 5 != 0 && ans % 3 != 0)
    {
      approved = false;
    }
  }
  if (approved)
  {
    printf("APPROVED");
  }
  else
  {
    printf("DENIED");
  }
  return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
s = input()
l = []
count = 0
for i in range(n):
  count += 1
  if i == n-1:
    l.append(count)
  elif s[i] != s[i+1]:
    l.append(count)
    count = 0
if s[0] =="0":
  l = [0] + l
left = 0
count = 0
point = 0
ans = 0
for i in l:
  point += i
  count += 1
  ans = max(ans, point)
  if count > k*2:
    point -= (l[left]+l[left+1])
    left += 2
    if left >= len(l)-1:
      break
    count-=2
print(ans)

Measured memory_bytes: 4980
//////////////////////////////
// Author: whatisit
// Date: 2020-05-14 00:37 
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;

const int N = 11, Q = 51;
int n, m, q, A[N];
int a[Q], b[Q], c[Q], d[Q];
int ans;

void dfs(int dep, int pre) {
	if (dep == n+1) {
		int ret = 0;
		for (int i = 0; i < q; ++i) 
			if (A[b[i]] - A[a[i]] == c[i]) 
				ret += d[i];
		ans = max(ans, ret);
		return;
	}
	for (int i = pre; i <= m; ++i) {
		A[dep] = i;
		dfs(dep+1, i);
	}
}

void solve() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; ++i) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	dfs(1, 1);
	cout << ans;
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(0);
	solve();
	return 0;
}

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

balls=[]
for i in range(N):
  balls.append( [int(i) for i in input().split()])

ans=0
for i in range(0,N-1):
  for j in range(i+1,N):
    sax = balls[j][0]-balls[i][0]
    say = balls[j][1]-balls[i][1]
    merge=0
    for k in range(0,N):
      if([balls[k][0]+sax,balls[k][1]+say] in balls):
          merge+=1
    ans=max(ans,merge)
print(N-ans)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        String sr;
        Scanner scan = new Scanner(System.in);
        sr = scan.nextLine();
        scan.close();

        if(sr.equals("ABC")){
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 26936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    string s;
    cin>>s;
    rep(i,s.size()){
        cout<<"x";
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,k,i;
  
  scanf("%d", &k);
  scanf("%d %d", &a, &b);
  
  for(i=a;i<=b;i++){
    if(i%k==0){
      printf("OK"); goto flag;
    }
  }
  
  printf("NG");
  flag:;
  
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main() {
	char c[202];
	char *cp;
	int n[102][102],i,j,k,m=0,p,an=0;
    memset(n,0,sizeof(n));
	while(gets(c)!=NULL) {
     cp=c; k=1; p=0;
	 while(p<strlen(c)) {
      n[m+1][k++]=atoi(cp);
	  while(c[p]!=',' && p<strlen(c)) p++;
	  p++; cp=&c[p];
	 }
     m++;
	}
	for (i=1;i<=m/2+1;i++) for (j=1;j<=i;j++) {
		n[i][j]+=max(n[i-1][j],n[i-1][j-1]);
		n[m-i+1][j]+=max(n[m-i+2][j],n[m-i+2][j-1]);
        if (i==m/2+1) an=max(an,n[i][j]);
	}
	cout << an << endl;
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){
  long long int N, tmp;
  std::string str_tmp;
  std::vector<std::string> S;
  std::vector<long long int> T;

  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    std::cin >> str_tmp >> tmp;
    S.push_back(str_tmp);
    T.push_back(tmp);
  }
  std::cin >> str_tmp;

  long long int flag = 0;
  long long int ans = 0;
  for(long long int i = 0; i < N; i++){
    if(flag == 1){
      ans += T[i];
    }
    if(S[i] == str_tmp){
      flag = 1;
    }
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;
  
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc088/tasks/abc088_b
n = int(input())
a = [int(x) for x in input().split()]
alice = 0
bob = 0
for i, v in enumerate(sorted(a, reverse=True)):
    if (i % 2 == 0):
        alice += v
    else:
        bob += v
print(alice - bob)


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}


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

    cout << a * b / gcd(a, b) << endl;

}


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

int main() {
  int n, l;
  cin >> n >> l;
  int sum = 0, ans = 99999, tmp = 99999;
  for (int i = 1; i <= n; i++) {
    sum += l + i - 1;
    if (abs(l + i - 1) < tmp) {
      tmp = abs(l + i - 1);
      ans = l + i - 1;
    }
  }
  sum -= ans;
  cout << sum << endl;
  return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;

vector<ll> v(maxn);
vector<ll> mostposs(maxn);

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

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

    if (n == 0) {
        if (v[0] != 1) out(-1);
        out(1);
    }

    // ll activep = 1LL;
    // for (int i = 0; i <= n; i++) {
    //     if (v[i] > activep) out(-1);
    //     activep -= v[i];
    //     activep *= 2LL;
    // }

    if (v[0] > 0) {
        out(-1);
    }

    for (int i = n; i >= 0; i--) {
        mostposs[i] = v[i] + mostposs[i+1];
    }

    ll activep = 1LL;
    ll ans = 1LL;
    for (int i = 1; i <= n; i++) {
        activep *= 2LL;
        if (v[i] > activep) out(-1);
        ans += v[i]; // add leaves
        activep -= v[i]; // minus leaves bc they can't be parents to next level
        activep = min(mostposs[i+1],activep); // bound # of node that will be parents to next level
        ans += activep; // add parents of this level
    }
    
    out(ans);
    
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int d[] = new int[N];
		for(int i=0; i<N; i++) d[i] = sc.nextInt();
		sc.close();
		int cur = 0, count = 0;
		
		Arrays.sort(d); //昇順
		for(int i=0; i<N; i++) {
			if(cur != d[i]) count++;
			cur = d[i];
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 20820
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("inp.txt", "r", stdin);
	string s;
	cin >> s;
	sort(all(s));
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
      String str;
      String[] arr;
      int H=0;
      int W=0;
      while((str=mBufferedReader.readLine())!=null){
        arr=str.split(" ");
        H=Integer.parseInt(arr[0]);
        W=Integer.parseInt(arr[1]);
        if((H==0)&&(W==0)){
          break;
        }
        for(int i=0;i<H;i++){
          for(int j=0;j<W;j++){
            System.out.print("#");
          }
          System.out.print("\n");
        }
          System.out.print("\n");
      }
      mBufferedReader.close();
    }
}
        


Measured memory_bytes: 35964
#include<stdio.h>
int main(){
 int r,c;
 int i,j;
 int mat[101][101]={{}};
 scanf("%d %d",&r,&c); /*r=行、c=列*/
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&mat[i][j]);
    }
  }
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      mat[i][c]+=mat[i][j];
    }
  }
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      mat[r][j]+=mat[i][j];
    }
  }
  for(j=0;j<c;j++){
  mat[r][c]+=mat[r][j];
}
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      printf("%d",mat[i][j]);
      if(j!=c){
         printf(" ");
       }
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2144
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<cassert>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 10010

using namespace std;

struct Data{
  int from,to,cost;
  Data(int from=-1,int to=-1,int cost=-1):from(from),to(to),cost(cost){}
};

bool cmp(const Data& p1,const Data& p2){ return p1.cost < p2.cost; }

int par[MAX+1];

void init(){ rep(i,MAX)par[i] = i; }

int find(int x){
  if( x == par[x] )return x;
  return par[x] = find(par[x]);
}

void unit(int x,int y){
  x = find(x);
  y = find(y);
  if( x != y)par[x] = y;
}

bool same(int x,int y){ return find(x) == find(y); }

int kruskal(vector<Data>& G){
  sort(G.begin(),G.end(),cmp);
  init();
  vector<int> vec;
  for(int i=0;i<G.size();i++){
    Data data = G[i];
    if(!same(data.from,data.to)){
      unit(data.from,data.to);
      vec.push_back(G[i].cost);
    }
  }

  sort(vec.begin(),vec.end());
  int len = vec.size();

  return vec[len/2];

}


int n,m;

int main(){

  while(cin >> n >> m,n|m){
    vector<Data> G;
    rep(i,m){
      int s,t,c;
      cin >> s >> t >> c;
      s--,t--;
      G.push_back(Data(s,t,c));
    }
    cout << kruskal(G) << endl;
  }

  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<char>c(N);
    for (int i = 0; i < N; i++)
    {
        cin >> c.at(i);
    }
    int r = -1, w = N;
    for (int i = 0; i < N; i++)
    {
        if (w == N && c.at(i) == 'W')
        {
            w = i;
        }
        if (r == -1 && c.at(N-1-i) == 'R')
        {
            r = N - 1 - i;
        }
    }
    if (r < w)
    {
        cout << 0;
    }
    else
    {
        int rn = 0, wn = 0;
        for (int i = 0; i < r - w + 1; i++)
        {
            if (c.at(w+i) == 'W')
            {
                wn++;
            }
            if (c.at(w+i) == 'R')
            {
                rn++;
            }
        }
        int rna = rn, wna = wn;
        for (int i = 0; i < wn; i++)
        {
            if (c.at(r-i) == 'W')
            {
                wna--;
            }
        }
        for (int i = 0; i < rn; i++)
        {
            if (c.at(w+i) == 'R')
            {
                rna--;
            }
        }
        cout << min(wna, rna);
    }
}

Measured memory_bytes: 3624
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct
  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m <> i then begin
        let tmp = t.node.(i) in t.node.(i) <- t.node.(m); t.node.(m) <- tmp;
        max_heapify m
      end in
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    max_heapify 1;
    ret

  let push x t =
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      if i > 1 && M.compare t.node.(parent i) t.node.(i) < 0 then begin
        let tmp = t.node.(i) in t.node.(i) <- t.node.(parent i); t.node.(parent i) <- tmp;
        doit (parent i)
      end in
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    doit t.size
end

module H = MakeBinaryHeap(struct type t = (int * int) let compare x y = snd x - snd y end)

let dijkstra g n =
  let h = H.make 100000 (0, 0) in
  let d = Array.make n max_int in
  let b = Array.make n false in
  d.(0) <- 0;
  b.(0) <- true;
  H.push (0, 0) h;
  let rec duduwa u = function
    | [] -> ()
    | (v, c) :: tl when b.(v) = true || d.(v) <= d.(u) + c -> duduwa u tl
    | (v, c) :: tl ->
      d.(v) <- d.(u) + c;
      H.push (v, -d.(v)) h;
      duduwa u tl
  and doit () =
    if not (H.empty_p h) then begin
      let (u, x) = H.pop h in
      b.(u) <- true;
      if d.(u) >= -x then duduwa u g.(u);
      doit ()
    end in
  doit ();
  d

let rec make_pair acc = function
  | [] -> acc
  | v :: c :: tl -> make_pair ((v, c) :: acc) tl
  | _ -> exit 1

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let g = Array.make n [] in
  let rec read i =
    if i < n then
      match List.map int_of_string (split_on_char ' ' (read_line ())) with
      | u :: _ :: l -> g.(u) <- make_pair [] l; read (i + 1)
      | _ -> exit 1 in
  read 0;
  Array.iteri (fun i e -> Printf.printf "%d %d\n" i e) (dijkstra g n)

Measured memory_bytes: 30588
S = input()
x, y = map(int, input().split())

mem_x = []
mem_y = []
is_x = True
c = 0
S += 'T'
for s in S:
    if s == 'T':
        if is_x:
            if len(mem_x) == 0 or c != 0:
                mem_x.append(c)
            c = 0
        else:
            if c != 0:
                mem_y.append(c)
            c = 0
        is_x = not is_x
    else:
        c += 1

x = abs(x - mem_x.pop(0)) if len(mem_x) > 0 else abs(x)
y = abs(y)

for i in sorted(mem_x, reverse=True):
    x = abs(x-i)
for j in sorted(mem_y, reverse=True):
    y = abs(y-j)

if x == y == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vl a(n),b(n),c(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n){
        cin >> c[i];
    }
    sort(all(a)),sort(all(b)),sort(all(c));
    vl kazu(n);
    rep(i,n){
        kazu[i] = n-(upper_bound(all(c),b[i]) - c.begin());
    }
    vl sm(n+1);
    sm[n] = 0;
    rrep(i,n){
        sm[i] = sm[i+1] + kazu[i];
    }
    ll ans = 0;
    rep(i,n){
        int id = upper_bound(all(b),a[i]) - b.begin();
        ans += sm[id];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;cin >> x;
    
    ll ans=x/11*2;
    if(x%11>6){
        ans+=2;
    }
    else if(x%11>0){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a-b*d;
    f=1.0*a/b;
    printf("%d %d %lf\n",d,r,f);
    return 0;
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD   998244353
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    int r;
    cin >> r;

    cout<< r*r <<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
//Prime Number

#include<cstdio>
using namespace std;

int Isprime[1000000];
int prime[1000000];      //?´???°?????????????????????

//??¨??????????????????????????????????´???°?????????
void a_prime(){
    int n = 1000000;
    int p = 0;
    //??????????????§???????????????
    for(int i = 0; i < n; i++) Isprime[i] = 1;
    //0??¨1????´???°??§??????
    Isprime[0] = Isprime[1] = 0;
    for(int i = 2; i < n; i++){
        if(Isprime[i]) prime[p++] = i;
        for(int j = 2*i; j < n; j += i){
            Isprime[j] = 0;
        }
    }
    
    //?´???????????????£?????????
    for(int i = 1; i < n; i++) Isprime[i] += Isprime[i-1]; 
    
}


int main(void){
    int no;
    a_prime();
    while(scanf("%d", &no) != EOF){
        printf("%d\n", Isprime[no]);
    }
    
    return 0;
}

Measured memory_bytes: 7100
/*
* @Author: A.R
* @Date:   2019-04-20 18:13:30
* @Last Modified by:   A.R
* @Last Modified time: 2019-04-20 18:29:38
*/
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	string s;
	cin>>n>>s;
	vector<vector<int> > mat;
	mat.resize(s.length(),vector<int>(2	,0));
	for(int i=0;i<s.length();i++){
		if(i==0){
			if(s[i] == '#'){
		 		mat[0][0] = 0;
		 		mat[0][1] = 1;
			}
			else{
				mat[0][0] = 1;
				mat[0][1] = 0;
			}
		}
		else{
			if(s[i] == '#'){
				mat[i][0] = min(mat[i-1][0], mat[i-1][1]);
				mat[i][1] = mat[i-1][1] + 1;
			}
			else{
				mat[i][0] = min(mat[i-1][1], mat[i-1][0]) + 1;
				mat[i][1] = mat[i-1][1];
			}
		}
	}
	int l = s.length();
	cout<<min(mat[l-1][0],mat[l-1][1])<<"\n";
	return 0;
}

Measured memory_bytes: 11396
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
A=list(map(int,input().split()))
l=[None]*N
t=0
for i in range(N):
    t=(A[i]+t)%M
    l[i]=t
l.append(0)
l.sort()
c=0
a=0
t=-1
for i in l:
    if i==t:
        c+=1
    else:
        a+=c*(c-1)//2
        c=1
        t=i
a+=c*(c-1)//2
print(a)

Measured memory_bytes: 14480
import java.util.*;
 
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			sum += arr[i];
		}
		Arrays.sort(arr);
		if (arr[n - 1] < sum - arr[n - 1]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin >> a >> b >> c;
    if(b-a == c - b) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	if(n>=0)
	{
		if(m>=0)
		{
			if(n<=m) printf("%d\n",m-n);
			else
			{
				if(m==0) printf("%d\n",n+m+1);
				else printf("%d\n",n-m+2);
			}
		}
		else
		{
			printf("%d\n",abs(n-abs(m))+1);
		}
	}
	else
	{
		if(m<=0)
		{
			if(n<=m) printf("%d\n",m-n);
			else printf("%d\n",abs(m)-abs(n)+2);
		}
		else
		{
			printf("%d\n",abs(m-abs(n))+1);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long b(long n,long x){
    if((powl(2,n+1)-2)>=x){
        if(x==0) return(0);
        else return(b(n-1,x-1));
    }
    else if((powl(2,n+1)-1)==x){
        return(powl(2,n));
    }
    else if((powl(2,n+2)-4)>=x){
        return(b(n-1,x+1-powl(2,n+1))+powl(2,n));
    }
    else return(powl(2,n+1)-1);

}
int main(void)
{
    long n,x;
    cin >> n >> x;
    cout << b(n,x);
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string S; cin >> S;
    int len = S.length();
    ll total = 0;

    for (int msk = 0; msk < 1 << (len-1); msk++) {
        ll num = S[0] - '0';
        for (int i = 0; i < len-1; i++) {
            if (msk & (1 << i)) {
                total += num;
                num = 0;
            }
            num = num * 10 + (S[i+1] - '0');
        }
        total += num;
    }

    cout << total << "\n";



    return 0;
}

Measured memory_bytes: 256
class Ami

  def initialize(f,w) #[[from0,to0], [from1,to1],...[from(n-1),to(n-1]]
    @bar = f
    @w = w
    @n = f.length
  end

  def towhere(from)
    now = from
    0.upto(@n-1){|j|
      if @bar[j].first == now then
        now = @bar[j].last
      elsif @bar[j].last == now then
        now = @bar[j].first
      end
    }
    return now
  end

end

bar = []
w = gets.chomp.to_i  # pos number(yoko)
n = gets.chomp.to_i  # bar number(tate)
0.upto(n-1){|i|
  from,to = gets.chomp.split(',').map{|x| x.to_i}
  bar.push([from,to])
}

ami = Ami.new(bar,w)

p=[]
1.upto(w){|j|
  p[ami.towhere(j)]=j
}
p.shift
puts p

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	set<string> a;
	for(ll i=0;i<n;i++) {
		cin>>s;
		a.insert(s);
	}	
	cout<<a.size();
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 253572
from sys import stdin

class Sentinel():
    def __init__(self):
        self.value = None
        self.next = None
        self.prev = None

class Node():
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None

def Insert(key):
    node = Node(key)
    node.next = sent.next
    sent.next.prev = node
    sent.next = node
    node.prev = sent

def Search(key):
    p = sent.next
    while p.value != None:
        if p.value == key:
            return p
        else:
            p = p.next
    return False

def Delete(key):
    p = Search(key)
    if p != False:
        p.prev.next = p.next
        p.next.prev = p.prev

def DeleteF():
    p = sent.next
    p.prev.next = p.next
    p.next.prev = p.prev

def DeleteL():
    p = sent.prev
    p.prev.next = p.next
    p.next.prev = p.prev

sent = Sentinel()
sent.next = sent
sent.prev = sent

n = int(input())
for i in range(n):
    L = stdin.readline().split()
    if L[0] == 'insert':
        Insert(int(L[1]))
    elif L[0] == 'delete':
        Delete(int(L[1]))
    elif  L[0] == 'deleteFirst':
        DeleteF()
    elif  L[0] == 'deleteLast':
        DeleteL()

p = sent.next
tl = []
while True:
    tl.append(p.value)
    p = p.next
    if p.value == None:
        break
print(' '.join(str(x) for x in tl))


Measured memory_bytes: 203728
import java.math.BigInteger
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val (h, w) = readLongs()
    if (h == 1L || w == 1L) {
        print(1)
    } else {
        var r = h * w
        if (r % 2L == 1L) {
            r++
        }
        print(r / 2L)
    }
}


Measured memory_bytes: 36080
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int q;
	cin >> q;
	string head,tail;
	bool rev=false;
	for(int i=0;i<q;i++)
	{
		int t;
		cin >> t;
		if(t==1)
		{
			rev=!rev;
		}
		else
		{
			int f;
			cin >> f;
			char c;
			cin >> c;
			if((f==1 and rev==false) or (f==2 and rev==true))
			{
				head+=c;
			}
			else
				tail+=c;
		}
	}
	if(rev)
	{
		reverse(s.begin(),s.end());
		reverse(tail.begin(),tail.end());
		tail+=s;
		tail+=head;
		s=tail;
	}
	else
	{
		reverse(head.begin(),head.end());
		head+=s;
		head+=tail;
		s=head;
	}


	cout << s << endl;


}


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

int main() {
    int K;
    cin >> K;
    queue<ll> q({1, 2, 3, 4, 5, 6, 7, 8, 9});
    int k = 0;
    while (1) {
        ++k;
        ll X = q.front();
        q.pop();
        if (k == K) {
            cout << X << endl;
            return 0;
        }
        ll b = X % 10;
        if (b == 0) {
            q.push(X * 10 + 0), q.push(X * 10 + 1);
        } else if (b == 9) {
            q.push(X * 10 + 8), q.push(X * 10 + 9);
        } else {
            q.push(X * 10 + b - 1), q.push(X * 10 + b), q.push(X * 10 + b + 1);
        }
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct Chara{
	string name;
	ll vote;
	bool operator<(const Chara &c)const{
		if(vote!=c.vote) return vote>c.vote;
		return name<c.name;
	}
};

ll n,m,k,l;
vector<Chara> favs,unfavs;

bool Check(int x){
	if(x>k||x>m) return false;
	if(unfavs.size()<k-x+1) return true;

	ll cost=0;
	REP(i,0,x){
		cost+=max(0LL,unfavs[k-x].vote-favs[i].vote+(unfavs[k-x].name<favs[i].name));
		//if(cost>l) return false;
	}
	
	return cost<=l;
}

void Solve(){
	while(true){
		cin >> n >> m >> k >> l;
		if(n+m+k+l==0) break;
		Chara charas[100010];
		REP(i,0,n) cin >> charas[i].name >> charas[i].vote;
		unordered_set<string> fav_names;
		REP(i,0,m){
			string name;
			cin >> name;
			fav_names.insert(name);
		}
		favs.clear();
		unfavs.clear();
		REP(i,0,n){
			if(fav_names.find(charas[i].name)!=fav_names.end()) favs.push_back(charas[i]);
			else unfavs.push_back(charas[i]);
		}
		sort(favs.begin(),favs.end());
		sort(unfavs.begin(),unfavs.end());

		int lb=0,ub=min(m,k)+1;
		while(true){
			if(ub-lb<=1){
				if(Check(ub)) lb=ub;
				break;
			}
			int mid=(lb+ub)/2;
			if(Check(mid)) lb=mid;
			else ub=mid;
		}

		cout << lb << endl;
	}
}

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

Measured memory_bytes: 23920
s = gets.chomp
n = s.size

n.times do |i|
  if i > 0 && s[i] == s[i - 1]
    puts "#{i} #{i + 1}"
    exit
  elsif i > 1 && s[i] == s[i - 2]
    puts "#{i - 1} #{i + 1}"
    exit
  end
end
puts "-1 -1"


Measured memory_bytes: 14512
#include<stdio.h>
int main(){
  long int n,f=1,pn=0,mn=0,p=0,m=0,i,t;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&t);
    pn+=t;mn+=t;
    if(pn*f<=0){p+=(pn*f*-1)+1;pn=f;}
    if(mn*f>=0){m+=(mn*f)+1;mn=f*-1;}
    f*=-1;
  }
  printf("%ld",p<m?p:m);
}


Measured memory_bytes: 128