akhauriyash/Code-Regression huggingface dataset:
string = input()

strlist = list(string)
if strlist[0] != 'A':
	print('WA')
else:
	if 'C' not in strlist[2:-1]:
		print('WA')
	else:
		countA = strlist.count('A')
		countC = strlist.count('C')
		if countA == 1 or countC == 1:
			strlist.remove('A')
			strlist.remove('C')
			string1 = ''.join(strlist)
			if string1.islower():
				print('AC')
			else:
				print('WA')
		else:
			print('WA')


Measured memory_bytes: 3060
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009

#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector<int> prime;

void Prime() {
	prime.emplace_back(2);
	for (int i = 3; i <= 999999; i += 2) {
		bool f = false;
		for (int j = 3; j <= sqrt(i); j += 2) {
			if (i%j == 0) {
				f = true;
				break;
			}
		}
		if (!f) prime.emplace_back(i);
	}
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	Prime();
	int n;
	while (cin >> n) {
		cout << upper_bound(prime.begin(), prime.end(), n) - prime.begin() << endl;
	}
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

bool isSquare(ll n)
{
    ll ok = 0;
    ll ng = INF; // 注意
    while (abs(ok - ng) > 1)
    {
        ll mid = (ok + ng) / 2;
        (mid * mid <= n ? ok : ng) = mid;
    }
    return (ok * ok == n);
}

void Main()
{
    string a, b;
    cin >> a >> b;
    int c = stoi(a + b);
    if (isSquare(c))
    {
        Yes;
    }
    else
    {
        No;
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
    
sum_a = 0
for a in a_list:
    sum_a += a
count_a = 0
for a in a_list:
    if a >= sum_a / (4 * m):
        count_a += 1
if count_a >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
/*author : Yashvardhan
Wednesday, April 08, 2020
5:41 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 998244353;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

const int MX = 3005;
int dp[MX][MX];
int pref[MX][MX];

signed main()
{

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

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n,s;
	cin >> n >> s;

	vi arr(n + 1);
	for(int i = 1; i <= n; i++) cin >> arr[i];

	for(int i = 1; i <= n; i++){
		dp[i][arr[i]] = i;
		for(int j = arr[i]; j <= s; j++){
			dp[i][j] = (dp[i][j]%mod + pref[i-1][j - arr[i]]%mod)%mod;
		}

		for(int j = 1; j <= s; j++){
			pref[i][j] = (dp[i][j]%mod + pref[i-1][j]%mod)%mod;
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = (ans % mod + (( dp[i][s]% mod )*(n - i + 1) % mod) % mod) % mod;
	}
	
	cout << ans << endl;

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 141184
fn main() {
    proconio::input! {
        n: usize,
        x: String,
    }

    let bp = x.match_indices('1').count() as u64;
    let p = if bp == 1 { vec![2, 1] } else { vec![bp + 1, bp - 1] };

    let xr: Vec<char> = x.chars().rev().collect();

    let mut pows = vec![vec![1, 1]; n];
    let mut xv = if xr[0] == '1' { vec![1; 2] } else { vec![0; 2] };
    for i in 1..n {
        for j in 0..=1 {
            pows[i][j] = (pows[i - 1][j] * 2) % p[j];
            if xr[i] == '1' {
                xv[j] += pows[i][j];
                xv[j] %= p[j];
            }
        }
    }

    for i in (0..n).rev() {
        if bp == 1 && xr[i] == '1' {
            println!("0");
        } else {
            let xi = if xr[i] == '0' {
                (xv[0] + pows[i][0]) % p[0]
            } else {
                let p = if xv[1] >= pows[i][1] { 0 } else { p[1] };
                xv[1] + p - pows[i][1]
            };
            println!("{}", 1 + pop_pop_count(xi));
        }
    }
}

fn pop_pop_count(mut v: u64) -> u64 {
    if v == 1 {
        1
    } else {
        let mut r = 0;
        while v > 0 {
            v %= v.count_ones() as u64;
            r += 1;
        }
        r
    }
}


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


int main(){

  char N[8];

  scanf("%s",N);
  /*
  int A[N];
  int i;
  for(i=0;i<N;i++){
   scanf("%d",A[i]);
   }
  */

//  if (strcmp(N[3],N[4])==0 && strcmp(N[5],N[6])==0){
  if (N[2]==N[3] && N[4]==N[5]){
    printf("Yes");
  }
  else{
    printf("No");
  }







 return(0);
 }


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

using namespace std;

using ll = long long;

constexpr ll mod = 1e9 + 7;

constexpr int kMaxN = 1e5 + 7;

vector<int> edges[kMaxN];

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

  int n;
  cin >> n;

  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    edges[x].emplace_back(y);
    edges[y].emplace_back(x);
  }

  function<pair<ll, ll>(int, int)> dfs = [&] (int u, int p) -> pair<ll, ll> {
    pair<ll, ll> dp = {1, 1};
    for (int v: edges[u]) {
      if (v != p) {
        auto res = dfs(v, u);
        ll new_white = 0, new_black = 0;
        new_white = (dp.first * res.first + dp.first * res.second) % mod;
        new_black = dp.second * res.first % mod;

        dp = {new_white, new_black};
      }
    }

    return dp;
  };

  auto res = dfs(0, -1);

  cout << (res.first + res.second) % mod << '\n';

  return 0;
}


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

using namespace std;
using ll = long long;
const ll mod = 1000000007;

const int MAXN = 1005;
const int MAXV = MAXN * MAXN;

vector<vector<int>> hen;
int id[MAXN][MAXN];
int toid(int i, int j) {
    if(i > j)swap(i, j);
    return id[i][j];
}

vector<int> dist(MAXV);
vector<int> seen(MAXV); // 0 : まだ見てない / 1 : 計算中 / 2 : 計算済み

int dfs(int u) {
    if(seen[u]){
        if(seen[u] == 1)return -1;
        else return dist[u];
    }

    seen[u] = 1;
    dist[u] = 1;
    for(auto i : hen[u]){
        int res = dfs(i);
        if(res == -1)return -1;
        dist[u] = max(dist[u], res + 1);
    }
    seen[u] = 2;
    return dist[u];
}




int main()
{
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));
    for(int i = 0; i < n; i++)for(int j = 0; j < n - 1; j++)cin >> a[i][j], a[i][j]--;
    int m = 0;
    for(int i = 0; i < n; i++)for(int j = i + 1; j < n; j++)id[i][j] = m++;
    hen.resize(m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n - 1; j++)a[i][j] = toid(i, a[i][j]);
        for(int j = 0; j < n - 2; j++)hen[a[i][j]].push_back(a[i][j + 1]);
    }
    cerr << "yay" << endl;
    for(int i = 0; i < m; i++){
        int res = dfs(i);
        if(res == -1){
            cout << -1 << endl;
            return 0;
        }
    }
    cerr << "yay" << endl;
    cout << *max_element(dist.begin(), dist.end()) << endl;
}

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

int main () {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d) {
    cout << "Left" << endl;
  }
  else if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

#include <x86intrin.h>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

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

/*
  if (n % 2 == 0) {
    ll now = 0;
    for (int i = 0; i < n; i += 2) now += a[i];
    ll maximum = now;
    for (int i = n-2; i >= 0; i -= 2) {
      now += (a[i+1] - a[i]);
      if (now > maximum) maximum = now;
    }

    cout << maximum << endl;
  }
  else {
    vector<vector<ll> > dp(n+2, vector<ll>(3, (ll) -1e18));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    for (int i = 0; i < n; i++) {
      if (i+2 < n) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + a[i+2]);
      if (i+2 < n) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + a[i+2]);
      if (i+2 < n) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + a[i+2]);
      if (i+3 < n) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + a[i+3]);
      if (i+3 < n) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + a[i+3]);
      if (i+4 < n) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + a[i+4]);
    }

    cout << max(max(dp[n-3][0], dp[n-2][1]), dp[n-1][2]) << endl;
  }
*/

  vector<vector<ll> > dp(n/2, vector<ll>(3, (ll) -1e18));
  dp[0][0] = a[0];
  dp[0][1] = a[1];
  dp[0][2] = a[2];
  for (int i = 1; i < n/2; i++) {
    dp[i][0] = dp[i-1][0] + a[i*2];
    dp[i][1] = max(dp[i-1][0], dp[i-1][1]) + a[i*2+1];
    dp[i][2] = max(max(dp[i-1][0], dp[i-1][1]), dp[i-1][2]) + a[i*2+2];
  }

  ll ans = max(dp[n/2-1][0], dp[n/2-1][1]);
  if (n % 2 == 1) ans = max(ans, dp[n/2-1][2]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10292
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int d = int.Parse(input[0]) - 1;
        int x = int.Parse(input[1]);
        for (int i = 0; i < n; i++)
        {
            int a = int.Parse(Console.ReadLine());
            x += (d / a) + 1;
        }
        Console.WriteLine(x);
    }
}

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

using namespace std;

int Solve(const int m, int n) {
    const int MAX_Y = 7368792;
    vector<bool> y(MAX_Y, false);

    int idx = m;
    while (n--) {
        while (y[idx]) ++idx;
        for (int i = 1; i * idx < MAX_Y; ++i)
            y[i * idx] = true;
    }

    while (y[idx]) ++idx;

    return idx;
}

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

    int m, n;

    while (cin >> m >> n) {
        if (m == 0 && n == 0) break;
        cout << Solve(m, n) << '\n';
    }

    return 0;
}

Measured memory_bytes: 4056
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        int n = sc.nextInt();
        int[][] array = new int[r][c];
        
        int now = 1;
        for (int i = 0; i < r; i++) {
            String str = sc.next();
            for (int j = 0; j < c; j++) {
                if (str.charAt(j) == '.') {
                    array[i][j] = 0;
                } else {
                    array[i][j] = now;
                    now++;
                }
            }
        }
        
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                if (array[i][j] != 0) {
                    int p = array[i][j];
                    for (int k = j - 1; k >= 0; k--) {
                        if (array[i][k] == 0) {
                            array[i][k] = p;
                        } else {
                            break;
                        }
                    }
                }
            }
        }
        
        for (int i = r - 1; i >= 0; i--) {
            for (int j = c - 1; j >= 0; j--) {
                if (array[i][j] != 0) {
                    int q = array[i][j];
                    for (int k = j + 1; k < c; k++) {
                        array[i][k] = q;
                    }
                    break;
                }
            }
        }
        
        for (int i = r - 1; i >= 0; i--) {
            if (i != r - 1 && array[i][0] == 0) {
                for (int j = 0; j < c; j++) {
                    array[i][j] = array[i + 1][j];
                }
            }
        }

        for (int i = 0; i < r; i++) {
            if (i != 0 && array[i][0] == 0) {
                for (int j = 0; j < c; j++) {
                    array[i][j] = array[i - 1][j];
                }
            }
        }        
        
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                System.out.print(array[i][j]);
                if (j != c - 1) {
                    
                System.out.print(" ");
                }
            }
            if (i != r - 1) {
            System.out.println();
            }
        }
    }
}


Measured memory_bytes: 47396
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 
#define MAXM
#define mod
#define inf (1<<25)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> inline bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> inline bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
il void read(int &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
int n, k;
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	read(n), read(k);
	if(n >= 2 * k - 1) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int m,k;

int main()
{
    scanf("%d %d", &m, &k);
    if(k >= (1 << m))
    {
        printf("-1");
        return 0;
    }
    if(k == 0)
    {
        for(int i = 0;i < (1 << m);i++)
        {
            printf("%d %d ",i,i);
        }
        return 0;
    }
    int ans = 0;
    for(int i = 0;i < (1 << m);i++)
    {
        if(i == k) continue;
        ans ^= i;
    }
    if(ans == k)
    {
        printf("%d ",k);
        for(int i = 0;i < (1 << m);i++)
        {
            if(i == k) continue;
            printf("%d ",i);
        }
        printf("%d ",k);
        for(int i = (1 << m)-1;i >= 0;i--)
        {
            if(i == k) continue;
            printf("%d ",i);
        }
    }
    else printf("-1");
    return 0;
}

#endif // 1++


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		cout << "NO" << endl;
	} else if (abs(a - b) > (v - w) * t) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
#define QSIZE 100000

typedef struct list{
  char name[100];
  int t;
}LIST;
LIST queue[QSIZE];
  
int head,tail,n;
LIST dequeue(void);
void enqueue(LIST);

int main(){
  int time = 0;
  int i,q,num;
  LIST data;

  head=1;
  scanf("%d %d",&n,&q);
  tail=n+1;
  
  for(i=1;i<=n;i++){
    scanf("%s", queue[i].name);
    scanf("%d",&queue[i].t);
  }

  while(head!=tail){
    data =dequeue();
    if(q<data.t){
      num=q;
    }
    else{
      num=data.t;
    }
    data.t -= num;
    time += num;
    if(data.t>0){
      enqueue(data);
    }
     else{
       printf("%s %d\n",data.name,time);
     }
    }
}

void enqueue(LIST num){
  int next = (tail+1)%QSIZE;
  queue[tail] = num;
  tail =next;
}

LIST dequeue(void){
 LIST val;
  val = queue[head];
  head =(head+1)%QSIZE;
  return val;
}



Measured memory_bytes: 11916
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int H,W;
  cin>>H>>W;
  vector<string>s(H);
  for(int i=0;i<H;i++)cin>>s[i];
  vector<vector<int>>d(H,vector<int>(W,1));
  vector<vector<int>>dd(H,vector<int>(W,1));
  for(int i=0;i<H;i++){
    if(s[i][0]=='#')d[i][0]=0;
    for(int j=0;j<W-1;j++){
      if(s[i][j+1]=='#')d[i][j+1]=0;
      else d[i][j+1]=max(d[i][j+1],d[i][j]+1);
    }
  }
  for(int i=0;i<H;i++){
    if(s[i][W-1]=='#')d[i][W-1]=0;
    for(int j=W-1;j>=1;j--){
      if(s[i][j-1]=='#')d[i][j-1]=0;
      else d[i][j-1]=max(d[i][j-1],d[i][j]);
    }
  }
  for(int i=0;i<W;i++){
    if(s[0][i]=='#')dd[0][i]=0;
    for(int j=0;j<H-1;j++){
      if(s[j+1][i]=='#')dd[j+1][i]=0;
      else dd[j+1][i]=max(dd[j+1][i],dd[j][i]+1);
    }
  }
  for(int i=0;i<W;i++){
    if(s[H-1][i]=='#')dd[0][i]=0;
    for(int j=H-1;j>=1;j--){
      if(s[j-1][i]=='#')dd[j-1][i]=0;
      else dd[j-1][i]=max(dd[j-1][i],dd[j][i]);
    }
  }
  vector<vector<int>>ans(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans[i][j]=max(d[i][j]+dd[i][j]-1,0ll);
    }
  }
  ll res=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      res=max(res,ans[i][j]);
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 98560
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

ll dp[1002][1002];
bool used[1002 * 1002] = {};

void none() { cout << 0 << endl; }

signed main() {
    IOS();
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m);
    map<ll, ll> ma, mb;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (ma.count(a[i]) != 0) {
            none();
            return 0;
        }
        ma[a[i]] = i;
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
        if (mb.count(b[i]) != 0) {
            none();
            return 0;
        }
        mb[b[i]] = i;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll ans = 1;
    for (int i = n * m; i >= 1; --i) {
        int num = n * m - i;
        if (lower_bound(a.begin(), a.end(), i) !=
                upper_bound(a.begin(), a.end(), i) &&
            lower_bound(b.begin(), b.end(), i) !=
                upper_bound(b.begin(), b.end(), i)) {
            continue;
        } else if (lower_bound(a.begin(), a.end(), i) !=
                   upper_bound(a.begin(), a.end(), i)) {
            ans *= m - (lower_bound(b.begin(), b.end(), i) - b.begin());
        } else if (lower_bound(b.begin(), b.end(), i) !=
                   upper_bound(b.begin(), b.end(), i)) {
            ans *= n - (lower_bound(a.begin(), a.end(), i) - a.begin());
        } else {
            ll x = n - (lower_bound(a.begin(), a.end(), i) - a.begin());
            ll y = m - (lower_bound(b.begin(), b.end(), i) - b.begin());
            // cout << x * y - num << endl;

            ans *= x * y - num;
        }
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int dx[2] = {1, 0};
int dy[2] = {0, 1};

int main(){
    ll L,N;
    SCLLD2(L,N);
    static ll X[200002] = {};
    static ll Y[200002] = {};
    static ll S1[200002] = {};
    static ll S2[200002] = {};

    FORq(i,1,N){
        cin >> X[i];
    }

    FORq(i,1,N){
        Y[N+1-i] = L-X[i];
    }

    FORq(i,1,N){
        S1[i] = S1[i-1] + X[i];
        S2[i] = S2[i-1] + Y[i];
    }
    ll ans = 0;

    FORq(d,0,N){
        FORq(d1,0,1){
            FORq(d2,0,1){
                ll cx = min((ll)d,(N-(ll)d) + (-dy[d1]-dy[d2]+dx[d1]+dx[d2]) / 2);
                ll cy = min(N-(ll)d,(ll)d + (-dx[d1]-dx[d2]+dy[d1]+dy[d2]) / 2);
                if ((cx < 0) or (cy < 0)) continue;
                ll nans = 0;
                nans = 2 * (S1[d] - S1[d-cx]) + 2 * (S2[N-d] - S2[N-d-cy]);
                if (d2 == 1){
                    nans -= Y[N-d];
                }else{
                    nans -= X[d];
                }

                ans = max(nans,ans);
            }
        }
    }

    PRINTLLD(ans);
}

Measured memory_bytes: 6528
#include <vector>
#include <deque>
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>

static const int INF = 1001001001;

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1 && b == 1) {
		cout << "Draw" << endl;
	} else if (a == 1) {
		cout << "Alice" << endl;
	} else if (b == 1) {
		cout << "Bob" << endl;
	} else {
		if (a > b) {
			cout << "Alice" << endl;
		} else if (a == b) {
			cout << "Draw" << endl;
		} else {
			cout << "Bob" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const ll N=1024,MOD=1e9+7;
ll n,m,dp[N][N];
string s[N];
bool can(int i,int j) {
	return (0<=i && 0<=j && i<n && j<m && s[i][j]=='.');
}

ll solve(int i,int j) {
	if(dp[i][j]!=-1)return dp[i][j];
	ll res=(i==n-1 && j==m-1);
	if(can(i+1,j))res=(res+solve(i+1,j))%MOD;
	if(can(i,j+1))res=(res+solve(i,j+1))%MOD;
	dp[i][j]=res;
	return res;
}

int main(){FIN;
	mset(dp,-1);
	cin>>n>>m;
	fore(i,0,n)cin>>s[i];
	cout<<solve(0,0)<<endl;
}	

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

using namespace std;

#define llong long long 
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++i < n; )
#define rep1(i,n) for (int i = 0; i++ < n; )
#define len(x) ((int)x.size())

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, m;
  cin >> n >> m;
  long double ans = 0;
  long double t = 1;
  llong s = m * 1900 + (n - m) * 100;
  rep1(i, 10000) {
    ans += (llong)s * i * t / (1 << m);
    t *= (long double)((1 << m) - 1)/ (1 << m);
  }
  cout << round(ans);

  return 0;
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!

INF = 10**10

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    a1 = [A[i+left] for i in range(n1)]
    a2 = [A[i+mid] for i in range(n2)]
    a1.append(INF)
    a2.append(INF)
    
    a1_i = a2_i = 0
    
    for i in range(right-left):
        if a1[a1_i] <= a2[a2_i]:
            A[left+i] = a1[a1_i]
            a1_i += 1
        else:
            A[left+i] = a2[a2_i]
            a2_i += 1
    return right-left
    
def merge_sort(A, left, right):
    cnt = 0
    
    if left+1 < right:
        mid = (left + right) // 2
        cnt += merge_sort(A, left, mid)
        cnt += merge_sort(A, mid, right)
        
        cnt += merge(A, left, mid, right)
        
        #print('l={}, r={}, m={}'.format(left, right, mid))    
        #print(*A)
        
    return cnt

n = int(input())
S = [int(i) for i in input().split()]

cnt = merge_sort(S, 0, n)

print(*S)
print(cnt)



Measured memory_bytes: 63712
N,M,Q = list(map(int,input().split()))
list1 = [None for i in range(Q)]

for i in range(Q):
  list1[i] = list(map(int,input().split()))

ans = [0]
def dfs(x,n2,m1):
  if len(x) == n2:
    score = sum(x1[3] for x1 in list1 if x[x1[1]-1]-x[x1[0]-1] == x1[2])
    if score > ans[0]:
      ans[0] = score
  else:
    for i in range(1,m1+1,1):
      if i >= x[-1]:
        dfs(x+[i],n2,m1)

dfs([1],N,M)
print(ans[0])

Measured memory_bytes: 70252
#include <iostream>

using namespace std;

#define MAX 500000
int H, A[MAX + 1];

void maxHeapify(int i){
    int l, r, largest;

    l = 2 * i;
    r = 2 * i + 1;
    if( l<=H && A[l] > A[i])
        largest = l;
    else
        largest = i;
    if( r<= H && A[r] > A[largest] )
        largest = r;

    if( largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}


int main()
{
    cin >> H;

    for (int i = 1; i <= H; ++i){
        cin >> A[i];
    }

    for (int i = H/2; i >=1 ; --i){
        maxHeapify(i);
    }

    for (int i = 1; i <= H; ++i){
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		int n = p[0];
		int start = p[1];
		var x = Input().ToInt();
		
		List<int> sa = new List<int>(n);
		
		for(int i = 0; i < n; i++)
		{
			sa.Add(Math.Abs(start-x[i]));
		}
		long gcd = sa[0];
		for(int i = 1; i < n; i++)
		{
			gcd = GCD(gcd, sa[i]);
		}
		
		Console.WriteLine(gcd);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 26848
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define inf 1e9
#define mod 1e9 + 7
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
ll power(ll x, ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

int main(){
    
    string s;
    cin>>s;
    int n = s.length();
    ll ans=0;
    int p = 2019;
        map<int , int> mp;
        int t=0, p1=1;
        mp[0]++;
        for(int i=n-1; i>=0; i--){
            t = (t+(s[i]-'0')*p1)%p;
            p1 = (p1*10)%p;
            ans += mp[t];
            mp[t]++;
        }
    
    cout<<ans;
}

Measured memory_bytes: 3740
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>

int main(void)
{
	int i,n;
	double m,s;
	double str[1001]={0,}; 
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		m=0;
		s=0;
		for(i=0;i<n;i++){
			scanf("%lf",&str[i]);
			m+=str[i];
		}
		m/=n;
		for(i=0;i<n;i++) s+=(str[i]-m)*(str[i]-m);
		s=sqrt(s/n);
		printf("%lf\n",s);
	}
	return 0;   
}

Measured memory_bytes: 664
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
	int a = scanner.nextInt();
	int b = scanner.nextInt();
	int c = scanner.nextInt();
	int n = b-a;
	int m = c-b;	
	
	if(n==m){
	System.out.print("YES");
	}else{
	System.out.print("NO");
	}
    }
}


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

int main(){
    int N;
    cin >> N;
    string str[2];
    cin >> str[0] >> str[1];

    string result;
    for (int i = 0; i < str[0].length(); i++) {
        result += str[0][i];
        result += str[1][i];
    }


    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	ll x,y; cin >> x >> y;
	if(x*y>0){
		if(x<y){
			cout << y-x << endl;
		}
		else{
			cout << x-y+2 << endl;
		}
	}
	else if(x==0){
		if(y<0){
			cout << -y+1 << endl;
		}
		else{
			cout << y << endl;
		}
	}
	else if(y==0){
		if(x>0){
			cout << 1+x << endl;
		}
		else{
			cout << -x << endl;
		}
	}
	else{
		if(x<y){
			if(abs(x)<=abs(y))cout << min(y-x,y+x+1) << endl;
			else cout << min(y-x,-x-y+1) << endl;
		}
		else{
			if(abs(x)<=abs(y)) cout << 1-y-x << endl;
			else cout << 1+x+y << endl;
		}
	}
}

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


int main() {
	int N, K;
	cin >> N >> K;
	int cnt = 0;
	int ans = 1;
	while(cnt < N){
		ans = min(ans * 2, ans + K);
		cnt++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,y,h,w,a;
	while(cin>>n,n){
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>x>>y>>h>>w;
			int a=x+y+h;
			if(a<=60&&w<=2)ans+=600;
			else if(a<=80&&w<=5)ans+=800;
			else if(a<=100&&w<=10)ans+=1000;
			else if(a<=120&&w<=15)ans+=1200;
			else if(a<=140&&w<=20)ans+=1400;
			else if(a<=160&&w<=25)ans+=1600;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
// ABC161B.cpp
//
// m=1でa[i]が1,1,1,1,1,1,1 の場合、sum=7、sum/(4*1) = 7/4 = 1.75 = 1
//
// if(a[i]>=sum/(4*m))とすると 7/(4*1)=1なので
// a[i]>=1で"Yes"になってしまう
// 4*mを左辺に移項して、除算を使わないようにすれば
// if(a[i]*4*m >= sum)とすれば、
// if(a[i]*4*1 >= 7)で"No"となって正解を得る。
//
// if(a[i]>=sum(4*m)+1)とすると、例えば
// m=1でa[i]が2,2,2,2の場合、sum=8、sum/(4*1) = 8/4 = 2
// sum*(4*m)+1 = 2+1 = 3だから
// if(a[i]>=3)は"No"となり不正解になる

//#include "pch.h"
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int sum = 0;
	int a[1010] = {};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i]*4*m >= sum) cnt++; 
		// if (a[i] >= sum / (4 * m)) cnt++; //移項して除算を使わない
	}
	if (cnt >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define per(i,a,b)	for(ll i=a;i>b;i--)

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

ll mod = 1000000007;

using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	ll n,k;
	cin>>n>>k;
	map<ll,ll> m;
	while(k--){
		ll d;
		cin>>d;
		ll a[d];
		rep(i,0,d){
			cin>>a[i];
			m[a[i]]++;
		}
	}
	ll count=0;
	rep(i,1,n+1){
		if(!m[i]){
			count++;
		}
	}
	cout<<count;



	return 0;
}

Measured memory_bytes: 3660
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    public void solve() {
    	int N = ni();
    	int K = ni();
    	int[] H = ndi(N);
    	Arrays.sort(H);
    	long ans = 0;
    	for (int i = H.length - 1 - K; i >= 0; i--) {
			ans += H[i];
		}
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 64484
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,N,a,A;
  cin >> H >> N;
  for(int i = 0; i < N; i++){
    cin >> a;
    A += a;
  }
  if(A>=H) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

double area(double a, double b,
         double c, double d,
         double e , double f){
  double x1 = e - a;
  double y1 = f - b;
  double x2 = e - c;
  double y2 = f - d;
  return (x1 * y2 - x2 * y1)/2;
}

int main(void){
  int c = 1;
  int n;
  while(cin >> n,n){
    cout << c++; // inputnum

    double sum = 0;

    double bx,by;
    cin >> bx >> by;
    double px,py;
    cin >> px >> py;

    for(int i=0; i<n-2; i++){
      double x,y;
      cin >> x >> y;
      sum += area(bx,by,x,y,px,py);
      px = x;
      py = y;
    }
    printf(" %.1f\n",abs(sum));
  }

  return 0;
}

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

vector<string> s;

int main()
{
    ll n;
    ll ans;

    cin >> n;
    rep(i, n) {
        string s1;
        cin >> s1;
        s.push_back(s1);
    }

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

    ans = 1;
    rep(i, n-1) {
        if (s[i] != s[i + 1])
            ++ans;
    }

    std::cout << ans << endl;

    return(0);
}


Measured memory_bytes: 11668
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#define N 100005
using namespace std;
vector <int> vec[N];
int color[N];
int main(){
    queue <int> que;
    int n , x , y;
    scanf("%d",&n);
    for(int i = 1 ; i < n ; i ++){
        scanf("%d%d",&x,&y);
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    color[1] = 1 , color[n] = 2;
    int cnt[3] = {0 , 0};
    que.push(1) ;
    que.push(n);
    while(!que.empty()){
        int x = que.front();
        que.pop();
        cnt[color[x]] ++;

        for(int i = 0 ; i < vec[x].size() ; i ++){
            int v = vec[x][i];
            if(color[v]) continue;
            color[v] = color[x];
            que.push(v);
        }
    }
    if(cnt[2] >= cnt[1]){
        printf("Snuke\n");
    }else{
        printf("Fennec\n");
    }

}


Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    char c;
    cin>>c;
    if(c>='A' && c<='Z') cout<<'A';
    else cout<<'a';


    return 0;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), W = in.ni();
        int[] w = new int[n];
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = in.ni();
            v[i] = in.ni();
        }
        long[][] dp = new long[n+1][W+1];
        Arrays.fill(dp[0],0);
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= W; j++) {
                if(j-w[i-1]>=0) dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i-1]]+v[i-1]);
                else dp[i][j] = dp[i-1][j];
            }
        }
        out.println(dp[n][W]);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 127060
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb emplace_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
const int mod1 = 1000000007;
const int mod2 = 998244353;

int main()
{
	optimize
	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
	#endif

    lli x,k,d;
    cin>>x>>k>>d;

    if(x==0)
    {
    	if(k%2)
    		cout<<d<<endl;
    	else
    		cout<<0<<endl;
    }
    else if(x>0)
    {
    	lli npos = x-min((x/d), k)*d;
    	k -= min((x/d), k);

    	if(k%2)
    		cout<<abs(npos-d)<<endl;
    	else
    		cout<<abs(npos)<<endl;

    }
    else
    {
    	lli npos = x+min((-x/d), k)*d;
    	k -= min((-x/d), k);

    	if(k%2)
    		cout<<abs(npos+d)<<endl;
    	else
    		cout<<abs(npos)<<endl;
    }

    

	
	return 0;
}

Measured memory_bytes: 3636
MM = ('01','02','03','04','05','06','07','08','09','10','11','12')

S = str(input())

bool_MMYY = False
bool_YYMM = False
if S[:2] in MM:
  bool_MMYY = True
if S[2:] in MM:
  bool_YYMM = True

if bool_MMYY and bool_YYMM:
  ans = 'AMBIGUOUS'
elif bool_MMYY and (not bool_YYMM):
  ans = 'MMYY'
elif (not bool_MMYY) and bool_YYMM:
  ans = 'YYMM'
elif (not bool_MMYY) and (not bool_YYMM):
  ans = 'NA'
  
print(ans)



Measured memory_bytes: 3064
#include <cstdio>

const int N = 2e5 + 10;
const int M = 4e5 + 10;

int hd[N], nxt[M], to[M], cnt;
int deg[N][2];
int n, m;
char col[N];
int q[N], qhd, qtl, vis[N];

inline void adde(int x, int y) {
	cnt++;
	to[cnt] = y; nxt[cnt] = hd[x]; 
	hd[x] = cnt;
}

int main() {
	scanf("%d%d", &n, &m);
	scanf("%s", col+1);
	for (int i = 1, x, y; i <= m; ++i) {
		scanf("%d%d", &x, &y);
		adde(x, y);
		adde(y, x);
		deg[x][col[y] == 'B']++;
		deg[y][col[x] == 'B']++;
	}
	for (int i = 1; i <= n; ++i) {
		if (deg[i][0] == 0 || deg[i][1] == 0) vis[q[qtl++] = i] = 1;
	}
	while (qhd != qtl) {
		int x = q[qhd++];
		// printf("%d\n", x);
		// vis[x] = 1;
		for (int i = hd[x]; i; i = nxt[i]) if (!vis[to[i]]) {
			if (--deg[to[i]][col[x] == 'B'] == 0) {
				vis[to[i]] = 1;
				q[qtl++] = to[i];
			} 
		}
	}
	if (qtl == n) puts("No");
	else puts("Yes");
}


Measured memory_bytes: 7168