akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int X = sc.nextInt();
      if(A>X){
        System.out.println("NO");
      }else if(X-A<=B){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }
}

Measured memory_bytes: 35588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region sieve
struct sieve
{
    int n;
    vector<int> f, primes;

    sieve(int n = 1) : n(n), f(n + 1)
    {
        for (int i = 2; i <= n; i++)
        {
            if (f[i])
                continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i)
            {
                if (!f[j])
                    f[j] = i;
            }
        }
    }

    bool isPrime(int x)
    {
        return f[x] == x;
    }

    vector<int> factorList(int x)
    {
        vector<int> res;
        while (x != 1)
        {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x)
    {
        auto fl = factorList(x);
        if (fl.size() == 0)
        {
            return {};
        }
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl)
        {
            if (res.back().first == p)
            {
                res.back().second++;
            }
            else
            {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int big = a[n - 1];
    vint mark(big + 1);
    int ans = 0;
    rep(i, n)
    {
        mark[a[i]]++;
        if (mark[a[i]] > 1)
        {
            continue;
        }
        for (int j = a[i] * 2; j <= big; j += a[i])
        {
            mark[j]++;
        }
    }

    rep(i, n)
    {
        if (mark[a[i]] > 1)
        {
            continue;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8008
def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a

def lcm(a, b):
    """Return lowest common multiple."""
    return a * b // gcd(a, b)

N = int(input())
T = int(input())
for i in range(1, N):
    T = lcm(int(input()), T)
print(T)

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie

intt n;

int main() {

	cin >> n;

	string ans = "";
	while (n) {
		int r = n % 26;
		if (r == 0) {
			ans += 'z';
			n -= 26;
			n /= 26;
		}
		else {
			ans += char('a' + r - 1);
			// also n /= 26 only is enough
			n -= r;
			n /= 26;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3636
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N,M;
int man[10001];
int big[501];
int price[500];
int dp[501][10001];
int cost[501];
int ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	for (int i = 0; i < N; i++)cin >> man[i];
	for (int i = 1; i <= M; i++)cin >> big[i] >> price[i];
	stable_sort(man, man + N);
	reverse(man, man + N);
	for (int i = 1; i < N; i++) man[i] = man[i - 1] + man[i];
	for (int i = N; i >= 1; i--)man[i] = man[i - 1];
	man[0] = 0;
	for (int i = 0; i <= M; i++) {
		for (int j = 0; j <= N; j++) {
			dp[i][j] = MOD;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 0; j <= N; j++)dp[i][j] = dp[i - 1][j];
		for (int j = 0; j <= N; j++) {
			dp[i][min(j + big[i], N)] = min(dp[i][min(j+big[i], N)], dp[i - 1][j] + price[i]);
		//	cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}
	for (int i = N; i >= 0; i--) {
		if (!dp[M][i])cost[i] = dp[M][i];
		else if (!cost[i + 1])cost[i] = dp[M][i];
		else cost[i] = min(cost[i + 1], dp[M][i]);
	}
	for (int i = 0; i <= N; i++) {
	//	cout << i << " " << man[i] << " " << cost[i] << endl;
		if (!cost[i])continue;
		ans = max(man[i] - cost[i], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22800
#include <map>
#include <unordered_map>
#include <set>
#include <vector>
#include <cstring>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <algorithm>
#include <time.h>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <random>
#include <iterator>
#include <cassert>
#include <cstdint>
#include <string>
#pragma comment(linker, "/STACK:10000000000")

using namespace std;

#define LLD "%I64d"

void print_str(const char* s)
{
	while (*s != 0)
	{
		putchar(*s);
		s++;
	}
}

template<typename T> void scan(T &t)
{
	cin >> t;
}

template<> void scan<int>(int &t)
{
	scanf("%d", &t);
}

template<> void scan<long long>(long long &t)
{
	scanf(LLD, &t);
}

template<> void scan<string>(string &t)
{
	cin >> t;
}

template<> void scan<char*>(char* &t)
{
	scanf("%s", t);
}

template<> void scan<char>(char &t)
{
	t = getchar();
	while (t <= 32)
		t = getchar();
}

template<typename T> void scan(vector<T> &t)
{
	for (int i = 0; i < t.size(); i++)
	{
		scan(t[i]);
	}
}


template<typename T, typename... Ts> void scan(T& t, Ts&... ts)
{
	scan(t);
	scan(ts...);
}

template<typename T> void print(T t)
{
	cout << t;
}

template<> void print<string>(string s)
{
	print_str(s.c_str());
}

template<> void print<int>(int t)
{
	printf("%d", t);
}

template<> void print<long long>(long long t)
{
	printf(LLD, t);
}

template<> void print<char>(char t)
{
	putchar(t);
}

template<> void print<const char*>(const char* t)
{
	print_str(t);
}

template<typename T, typename V> void print(pair<T, V> t)
{
	printf("(");
	print(t.first);
	printf(", ");
	print(t.second);
	printf(")");
}

template<typename T, typename... Ts> void print(T t, Ts... ts)
{
	print(t);
	print(ts...);
}

#define TASK "nocross"
#define X first
#define Y second

const int INF = 1e9;
const long long LINF = 3e18;
const int maxN = 1e5 + 100;
const int maxM = 58;
const int K = 10000;
const int SIZE = (1 << 18);
const int mb = 30;
const long long MOD = 1e9 + 7;
const long long P = 127;
const double EPS = 1e-8;

mt19937_64 random_generator;

long long random(long long l, long long r)
{
	uniform_int_distribution<long long> dist(l, r);
	long long res = dist(random_generator);
	return res;
}

namespace solution
{
}

namespace bruteforce
{
}

void init(bool testing = false)
{

}

void gen(int seed)
{
}

int a[maxN];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen(TASK".in", "r", stdin);
	//freopen(TASK".out", "w", stdout);
#endif

	long long n, m;
	cin >> n >> m;
	long long s = n, cc = m / 2;

	if (s >= cc)
	{
		cout << cc;
	}
	else
	{
		cout << s + (cc - s) / 2LL;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A+B > C+D){
        puts("Left");
        return 0;
    }else if(A+B == C+D){
        puts("Balanced");
        return 0;
    }else{
        puts("Right");
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String s=sc.next();
        char ch=s.charAt(0);
        if (ch>='A'&&ch<='Z'){
            System.out.println("A");
        }
        else{
            System.out.println("a");
        }

    }
}


Measured memory_bytes: 35740
T = input()
S = ''
p,q,r,s = 'maerd','esare','remaerd','resare'
for i in range(len(T)):
    S += T[len(T)-i-1]
while len(S) >= 5:
    x = S[:5]
    y = S[:6]
    z = S[:7]
    if x == p or x == q:
        if len(S) > 5:
            S = S[5:]
        else:
            S = ''
    elif y == s:
        if len(S) > 6:
            S = S[6:]
        else:
            S = ''
    elif z == r:
        if len(S) > 7:
            S = S[7:]
        else:
            S = ''
    else:
        break
ans = 'NO'
if len(S) == 0:
    ans = 'YES'
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 100005
#define ll long long int
long long int MOD=998244353;
long long int mod=1e9+7;
long long int INF=1e18;

int main()
{
    ll n,k;
    cin>>n>>k;
    long double a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]=(a[i]+1.0)/2.0;
    }
    long double b[n+1];
    b[0]=0.0;
    for(int i=1;i<=n;i++)
        b[i]=a[i-1]+b[i-1];
    long double ans=0.0;
    for(int i=k;i<=n;i++)
        ans=max(ans,b[i]-b[i-k]);
    cout<<fixed<<setprecision(12)<<ans;
    return 0;
}


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

class Bit:
    def __init__(self, n):
        self.n = n
        self.tree = [0]*(n+1)
        self.el = [0]*(n+1)
        self.depth = n.bit_length()

    def sum(self, i):
        """ 区間[0,i) の総和を求める """
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1) )- 1
        return s

    def add(self, i, x):
        self.el[i] += x
        while i < self.n:
            self.tree[i] += x
            i |= i + 1

    def get(self, i, j=None):
        """ 部分区間和 [i, j) """
        if j is None:
            return self.el[i]
        if i == 0:
            return self.sum(j)
        return self.sum(j) - self.sum(i)

    def lower_bound(self, x, equal=False):
        """ (a0+a1+...+ai < x となる最大の i, その時の a0+a1+...+ai )
             a0+a1+...+ai <= x としたい場合は equal = True         """
        sum_ = 0
        pos = -1    # 1-indexed の時は pos = 0
        if not equal:
            for i in range(self.depth, -1, -1):
                k = pos + (1 << i)
                if k <= self.n and sum_ + self.tree[k] < x:
                    sum_ += self.tree[k]
                    pos += 1 << i
        if equal:
            for i in range(self.depth, -1, -1):
                k = pos + (1 << i)
                if k <= self.n and sum_ + self.tree[k] <= x:
                    sum_ += self.tree[k]
                    pos += 1 << i
        return pos, sum_

    def __getitem__(self, s):
        """ [a0, a1, a2, ...] """
        return self.el[s]

    def __iter__(self):
        """ [a0, a1, a2, ...] """
        for s in self.el[:self.n]:
            yield s

    def __str__(self):
        text1 = " ".join(["element: "] + list(map(str, self)))
        text2 = " ".join(["cumsum:  "] + list(str(self.sum(i)) for i in range(1, self.n + 1)))
        return "\n".join((text1, text2))


class BitImos:
    def __init__(self, n):
        self.n = n
        self.p = Bit(self.n + 1)
        self.q = Bit(self.n + 1)

    def add(self, s, t, x):
        """ 区間は閉区間 [s,t] で与えられる。原理は Imos法 と同じ。"""
        t += 1
        self.p.add(s, -x * s)
        self.p.add(t, x * t)
        self.q.add(s, x)
        self.q.add(t, -x)

    def sum(self, s, t):
        """ 半閉区間[s,t)の累積和を与える """
        return self.p.sum(t) + self.q.sum(t) * t - self.p.sum(s) - self.q.sum(s) * s

    def __getitem__(self, s):
        """ 区間加算後の s 番目の要素をO(log N)で取り出す。Imos法だとこの操作にO(N)かかる。"""
        return self.q.sum(s+1)

    def __iter__(self):
        """ max(self) で普段 Imos法 でやってることが出来る。"""
        for t in range(self.n):
            yield self.q.sum(t+1)

    def __str__(self):
        text1 = " ".join(["element: "] + list(map(str, self)))
        return text1

N, Q = map(int, input().split())
BI = BitImos(N)

for _ in range(Q):
    q = list(map(int, input().split()))
    if q[0] == 0:
        BI.add(q[1]-1,q[2]-1,q[3])
    else:
        print(BI[q[1]-1])




Measured memory_bytes: 17536
N = int(input())
S = input()
Q = int(input())
query = tuple(map(int, input().split()))

for k in query:
    D = 0
    M = 0
    DM = 0
    res = 0
    for i, s in enumerate(S):
        if i >= k:
            if S[i - k] == "D":
                DM -= M
                D -= 1
            elif S[i - k] == "M":
                M -= 1
        if s == "D":
            D += 1
        elif s == "M":
            M += 1
            DM += D
        elif s == "C":
            res += DM
    print(res)

Measured memory_bytes: 75680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    cout << setprecision(10)<< ((double)(w*h)/2) << " ";
    if(x==(double)w/2 && y==(double)h/2) cout << 1 << endl;
    else cout << 0 << endl;
}



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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
template <typename T>
void dump_stack(std::stack<T>& stack) {
  std::stack<T> temp;
  while (!stack.empty()) {
    T top = stack.top(); stack.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.top(); temp.pop();
    stack.push(top);
  }
}
template <typename T>
void dump_queue(std::queue<T>& queue) {
  std::queue<T> temp;
  while (!queue.empty()) {
    T top = queue.front(); queue.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.front(); temp.pop();
    queue.push(top);
  }
}

typedef long long ll;




int main(){
  int n,q,a; cin >>n;
  vector<int> S(n+1);
  rep(i,n) {
    cin >> S[i];
  }
  cin >> q;
  int c=0;
  rep(i,q) {
    cin >> a;
    int left = 0;
    int right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (S[mid] == a) {
        c++;
        break;
      } else if(a < S[mid]) {
        right = mid;
      } else {
        left = mid +1;
      }
    }
  }
  
  cout << c << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int dp[100000];
int main() {
	string s;
    int n, q, l, r;
    cin >> n >> q >> s;
	for(int i=1; i<s.size(); i++) {
    	if(s[i] == 'C' && s[i - 1] == 'A') {
    		dp[i] = dp[i - 1] + 1;
		}
		else dp[i] = dp[i - 1];
	}
    for(int i=0; i<q; i++) {
    	scanf("%d%d", &l, &r);
		printf("%d\n", dp[r - 1] - dp[l - 1]);
	}
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#define min(x, y) ((x)<(y) ? (x) : (y))
int main(){
  int n;  scanf("%d", &n);
	int ans = 1<<30;
  while(n--){
    int a;  scanf("%d", &a);
    int count = 0;
    while(a % 2 == 0){
      count++;
      a >>= 1;
    }
    ans = min(ans, count);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1684
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int h[maxn],e[maxn],ne[maxn],idx;
vector<int>color[maxn];
typedef pair<int,int>PII;
map<PII,int>ans;
vector<PII>bc;
void add(int a,int b) {
	e[idx]=b;
	ne[idx]=h[a];
	h[a]=idx++;
} 
int mx=0;
void dfs(int x) {
	int rs=1;
//	for(auto item:color[x]) cout<<item<<' ';cout<<'\n';
	for(int i=h[x];i!=-1;i=ne[i]) {
		int j=e[i];
		while(find(color[x].begin(),color[x].end(),rs)!=color[x].end()) rs++;
		color[x].push_back(rs);
		color[j].push_back(rs);
		ans[{x,j}]=rs;
		mx=max(mx,rs);
		dfs(j);
	}
}
int Xiaobo()
{
	int n;
	cin>>n;
	memset(h,-1,sizeof h);
	for(int i=1;i<n;i++) {
		int a,b;
		cin>>a>>b;
		add(a,b);
		bc.push_back({a,b});
	}
	dfs(1);
	cout<<mx<<'\n';
	for(auto item:bc) {
		cout<<ans[item]<<'\n';
	}
	return 0;
}


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

int main(){
	int N; cin>>N;
	ll ans = 0;
	ll count = 0;
	int pre, now; cin>>pre;;
	for(int i=1; i<N; ++i){
		cin>>now;
		ans = max(ans, (count = pre>=now? count+1: 0));
		pre = now;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
int main()
{
    fio;
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
    return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[2][101],arr[2][101];
ll n;
ll solve(ll x,ll y)
{
    if(x>1||y>n)
        return 0;
    if(dp[x][y]!=-1)
        return dp[x][y];
    ll ans=-1;
    ans=max(ans,solve(x+1,y)+arr[x][y]);
    ans=max(ans,solve(x,y+1)+arr[x][y]);
    return dp[x][y]=ans;
}
int main()
{
  scanf("%lld",&n);
  for(int i=0;i<2;i++)
  {
      for(int j=0;j<n;j++)
        scanf("%lld",&arr[i][j]);
  }
  memset(dp,-1,sizeof(dp));
  cout<<solve(0,0)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#define P pair<long long,pair<int,int>>
using namespace std;
int main(){
  int H,W,Ch,Dh,Cw,Dw;
  cin>>H>>W;
  cin>>Ch>>Cw;
  cin>>Dh>>Dw;
  string S[1000];
  for(int i=0;i<H;i++){
    cin>>S[i];
  }
  priority_queue<P,vector<P>,greater<P>> que;
  que.push(make_pair(0,make_pair(Ch-1,Cw-1)));
  int search[1000][1000]; //（縦、横）
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++) search[i][j]=-1;
  }
  int dh[4]={1,0,-1,0};
  int dw[4]={0,1,0,-1};
  int ddh[20]={2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1,0,1,2,2,1,-1,-1,1};
  int ddw[20]={0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1,1,1,-1,-1};
  while(!que.empty()){
    long long n=que.top().first;
    int h=que.top().second.first;
    int w=que.top().second.second;
    que.pop();
    if(search[h][w]==-1){
    search[h][w]=n;
    for(int i=0;i<4;i++){
      if(h+dh[i]<H&&h+dh[i]>=0&&w+dw[i]<W&&w+dw[i]>=0){
        if(search[h+dh[i]][w+dw[i]]==-1&&S[h+dh[i]][w+dw[i]]=='.'){
          que.push(make_pair(n,make_pair(h+dh[i],w+dw[i])));
        }
      }
    }
    for(int i=0;i<20;i++){
      if(h+ddh[i]<H&&h+ddh[i]>=0&&w+ddw[i]<W&&w+ddw[i]>=0){
        if(search[h+ddh[i]][w+ddw[i]]==-1&&S[h+ddh[i]][w+ddw[i]]=='.'){
          que.push(make_pair(n+1,make_pair(h+ddh[i],w+ddw[i])));
        }
      }
    }
    }
  }
  cout<<search[Dh-1][Dw-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 10124
N = int(input())
ST = [list(input().split()) for _ in range(N)]
X = input()
for i,st in enumerate(ST):
  s=st[0]
  if X==s:
    r = i
    break
    
if r==(N-1):
  print(0)
  
else:
  ST=ST[r+1::]
  ans = 0
  for st in ST:
    ans += int(st[1])
    
  print(ans)

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

int main(){
  string s;
  
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy";
  }
  
  if(s=="Cloudy"){
    cout<<"Rainy";
  }
  
  if(s=="Rainy"){
    cout<<"Sunny";
  }
  
}

Measured memory_bytes: 256
def a(al, s1, s2):
	if len(s1)==0:
		st = s2+s1
		n_list = st.split("+")
		ans = 0
		for n in n_list:
			ans = ans + int(n)
		al.append(ans)
	elif len(s2)==0:
		a(al, s1[1:], s2+s1[0])
	else:
		a(al, s1[1:], s2+s1[0])
		a(al, s1[1:], s2+"+"+s1[0])

s = input()
a_list = []
a(a_list, s, "")

ans = 0
for a in a_list:
	ans += a

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

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

	return 0;
}


Measured memory_bytes: 3628
x, n = map(int, input().split())
p = list(map(int, input().split()))

for i in range(100):
  y1 = x+i
  y2 = x-i
  if y2 not in p:
    print (y2)
    exit()
  if y1 not in p:
    print (y1)
    exit()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 5/27/2020

 8:09-

 */

int A,B;

void paint(vector<string> &A, int cnt, char c) {
  REP(k,cnt) {
    int i=k/24,j=k%24;
    A[2*i+1][2*j+1]=c;
  }
}
void solve() {
  vector<string> L(100,string(50,'.')),R(100,string(50,'#'));
  paint(L,B-1,'#'),paint(R,A-1,'.');
  cout<<100<<" "<<100<<endl;
  REP(i,100) {
    cout<<L[i]<<R[i]<<endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>A>>B;
  solve();

  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
takahashi, aoki = gets.split.map(&:to_i)
(N-1).times do
  # puts "t: #{takahashi}, a: #{aoki}"
  t_ratio, a_ratio = gets.split.map(&:to_i)
  scale = nil
  if takahashi > t_ratio || aoki > a_ratio
    t_scale = takahashi / t_ratio
    t_scale += 1 if takahashi % t_ratio != 0
    a_scale = aoki / a_ratio
    a_scale += 1 if aoki % a_ratio != 0
    scale = [t_scale, a_scale].max
  else
    scale = 1
  end
  takahashi = t_ratio * scale
  aoki      = a_ratio * scale
end

# puts "t: #{takahashi}, a: #{aoki}"
puts takahashi + aoki


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

int main(void){
    char string[11];
    scanf("%s",string);
    int min=1000;
    for(int i=0;i<=strlen(string)-3;i++){
        int a=((int)string[i]-48)*100+((int)string[i+1]-48)*10+(int)string[i+2]-48;
        //printf("%d\n",a);
        int ab=abs(753-a);
        if(ab<min) min=ab;
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<queue>
#include<stack> 
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps=1e-8;
const double inf=0x3f3f3f3f;
const int maxn=515;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};

int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0); 
	string str1,str2;
	cin>>str1;
	cin>>str2;
	int n=str1.size();
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(str1[i]!=str2[i]) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3836
// Marcin Knapik
#include<bits/stdc++.h>

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

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
  
const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m, k, q;

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

    cin >> n >> k;
    vll dp(N, BIG_INF);
    dp[0] = 0;
    ll ans = 0;

    FOR(i, n){
    	int a, b;
    	cin >> a >> b;

    	for(int i = n*1000; i >= b; i--){
    		setmin(dp[i], dp[i-b] + a);
    		if(dp[i] <= k)
    			setmax(ans, (ll)i);
    	}
    }
    cout << ans << '\n';
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int, n);
  OUT(180*(n-2))BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

ll sums(vector<ll> vec) {
  ll limit = vec.size();
  ll sumvec = 0;
  for (int k = 1; k <= limit; ++k) {
    sumvec += (k - 1) * vec[k-1] - (limit - k) * vec[k-1];
    sumvec %= MOD;
  }

  return (sumvec + MOD);
}

int main() {
  ll n,m;
  vector<ll> x, y;

  cin >> n >> m;

  x = vector<ll>(n), y = vector<ll>(m);

  rep(i,n) {
    scanf("%lld", &x[i]);
  }
  rep(i,m) {
    scanf("%lld", &y[i]);
  }
  
  ll sumx = sums(x);
  ll sumy = sums(y);

  cout << (sumx * sumy) % MOD << endl;
}


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

using namespace std;

int main(){
  string a,b;
  cin >> a >> b;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  cout << ((a<b) ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Chocolate with Heart Marks
public class Main{

	int minimumSteinerTree(List<Integer> vs, int[][] e, int n){
		int K = vs.size(), INF = 1<<29;
		if(K<=1)return 0;
		int[][] wf = new int[n][n];
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf[i][j]=e[i][j];
		for(int i=0;i<n;i++)wf[i][i]=0;
		for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf[i][j]=Math.min(wf[i][j], wf[i][k]+wf[k][j]);
		
		int[][] dp = new int[1<<K][n];
		for(int[]d:dp)Arrays.fill(d, INF);
		for(int p=0;p<K;p++)for(int q=0;q<n;q++)dp[1<<p][q]=wf[vs.get(p)][q];
		
		for(int S=1;S<1<<K;S++){
			if((S&(S-1))==0)continue;
			for(int p=0;p<n;p++)for(int sub=0;sub<S;sub++){
				if((S|sub)==S){
					dp[S][p] = Math.min(dp[S][p], dp[sub][p]+dp[S-sub][p]);
				}
			}
			for(int p=0;p<n;p++)for(int q=0;q<n;q++){
				dp[S][p] = Math.min(dp[S][p], dp[S][q]+wf[q][p]);
			}
		}
		int res = INF;
		for(int S=0;S<1<<K;S++)for(int q=0;q<n;q++){
			res = Math.min(res, dp[S][q] + dp[((1<<K)-1)-S][q]);
		}
		return res;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
		for(;;){
			int h = sc.nextInt(), w = sc.nextInt();
			if((h|w)==0)break;
			int[][] e = new int[h*w][h*w];
			for(int[]a:e)Arrays.fill(a, 1<<29);
			List<Integer> vs = new ArrayList<Integer>();
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(sc.nextInt()==1)vs.add(i*w+j);
				for(int k=0;k<4;k++){
					int ni = i+d[k][0], nj = j+d[k][1];
					if(0<=ni&&ni<h&&0<=nj&&nj<w)e[i*w+j][ni*w+nj]=1;
				}
			}
			System.out.println(h*w-minimumSteinerTree(vs, e, h*w)-1);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
# Different Strokes
n = int(input())
a, b = list(), list()
ab = list()
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
    ab.append((a_, b_))
ans = 0
ab.sort(key=(lambda x: sum(x)), reverse=True)
for i, ab_ in enumerate(ab):
    if i % 2 == 0:
        ans += ab_[0]
    else:
        ans -= ab_[1]
print(ans)


Measured memory_bytes: 23420
fn qb() -> i32 {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let mut num : i32 = input.trim_right().parse().unwrap();
    loop {
        let mut check = num;
        let mut one = check % 10;
        loop {
            check /= 10;
            let ten = check % 10;
            if one != ten {
                break
            }
            one = ten;
        }
        if check == 0 {
            return num;
        }
        num += 1;
    }
}

fn main() {
   println!("{}", qb());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF  = 1<<30;


struct item {
  int v, w;
  bool operator<(const item &r) const { return w < r.w; }
  void operator+=(const item &r) { w += r.w, v += r.v; }
};


vector<item> enum_powerset(const vector<item> &is) {
  vector<item> a = {{0, 0}};
  vector<item> c;
  c.reserve(1<<sz(is));
  for (auto &i : is) {
    auto b = a;
    for (auto &e : b) e += i;
    merge(all(a), all(b), back_inserter(c));
    swap(a, c);
    c.clear();
  }
  return a;
}


int solve(const vector<item> &is, int W) {
  int n = sz(is);
  auto a = enum_powerset({is.begin(), is.begin() + n/2});
  auto b = enum_powerset({is.begin() + n/2, is.end()});
  reverse(all(a));
 
  int ans = 0;
  int vbmax = -INF;
  auto itr = b.begin();
  for (auto &[va, wa] : a) {
    if (wa > W) continue;
    while (itr != b.end() && wa + itr->w <= W) {
      chmax(vbmax, itr->v);
      ++itr;
    }
    chmax(ans, va + vbmax);
  }
  return ans;
}


int main() {
  int n; cin >> n;
  vector<item> is(n);
  for (auto &[v, w] : is) cin >> v >> w;
  is.insert(is.begin(), {0, 0});

  int q; cin >> q;
  rep(_, q) {
    int v, l; cin >> v >> l;
    vector<item> qi;
    while (v) {
      qi.push_back(is[v]);
      v /= 2;
    }
    cout << solve(qi, l) << '\n';
  }
}


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

import sys
import math

def rectArea(h, w):
    return h * w


for d in sys.stdin:
    area = 0
    d = int(d)
    for i in range(0, 600, d):
        area += rectArea(i*i, d)

    print(area)

Measured memory_bytes: 6784
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int n,fir[30],len[200010],id[200010],tot[30];
int ch[1000010][27],sz[1000010],letter[1000010][27],cnt=1;
long long ans;
string str[200010];
map<string,int> vis;
void insert(string str)
{
 int len=str.length(),x=1,i;
 for(i=0;i<26;i++)
  fir[i]=-1;
 
 for(i=0;i<len;i++)
  if(fir[str[i]-'a']==-1)
  {
   fir[str[i]-'a']=i;
   tot[str[i]-'a']++;
  }
 
 if(len==1)
 {
  ans+=tot[str[0]-'a']-1;
  return ;
 }
 
 for(i=len-1;i>=0;i--)
 {
  int y=str[i]-'a';
  if(!ch[x][y])
   ch[x][y]=++cnt;
  x=ch[x][y];
  sz[x]++;
  
  if(i==1)
   ans+=letter[x][str[0]-'a'];
  
  for(int j=0;j<26;j++)if((~fir[j])&&fir[j]<i)
   letter[x][j]++;
 }
}
bool cmp(int i,int j){return len[i]>len[j];}
int main(){
 cin>>n;
 for(int i=1;i<=n;i++){
  cin>>str[i];
  len[i]=str[i].length();
  id[i]=i;
 }
 sort(id+1,id+n+1,cmp);
 for(int i=1;i<=n;i++){
  insert(str[id[i]]);
  if(!vis.count(str[id[i]]))
   vis[str[id[i]]]=1;
  else ans+=vis[str[id[i]]];
 }
 cout<<ans<<endl;
 system("pause");
}


Measured memory_bytes: 226856
n = int(input())
l = [int(v) for v in input().split()]
pairs = 0
for i in range(len(l)):
    for j in range(i + 1, len(l)):
        for k in range(j + 1, len(l)):
            a = l[i]
            b = l[j]
            c = l[k]
            if a == b or b == c or c == a:
                continue
            else:
                if a + b <= c or b + c <= a or c + a <= b:
                    continue
                else:
                    pairs += 1
print(pairs)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i;
  int chk = 1;
  for(i=0;i<s.length();i++){
    if(i%2==0){
      if(s[i]=='L')chk=0;
    }else{
      if(s[i]=='R')chk=0;
    }
  }
  if(chk==0)cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		for(int i=1; i<=n; i++)
		{
			boolean is = false;
			for(int j=i; j>0; j/=10)
			{
				if(j%10 == 3)
				{
					is = true;
					break;
				}
			}
			if(i%3 == 0)
			{
				is = true;
			}
			
			if(is)
			{
				System.out.print(" ");
				System.out.print(i);
			}
		}
		System.out.println("");
	}
}

Measured memory_bytes: 31504
#include <iostream>

using namespace std;

int main() {

  long long n, m, k = 1000000000000000001;
  cin >> n >> m;
  n = n % m;
  for(int i = 1;i <= 4;i++){
    k = min(n, k);
    n = abs(n - m);
  }
  k = min(n, k);
  cout << k;
  return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
#include <unistd.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i,n){
        cin >> s[i];
    }
    string t="";
    REP(i,n){
        
    }
    int res= 0;
    REP(i,n){
        REP(j,s[i].size()-1){
            if(s[i][j]=='A'&&s[i][j+1]=='B')res++;
        }
    }
    int a=0,b=0,c=0;
    REP(i,n){
        if(s[i].front()=='B'&&s[i].back()=='A')c++;
        else if(s[i].front()=='B')b++;
        else if(s[i].back()=='A')a++;
    }
    if(c>0){
        if(a>0&&b>0){
            res+=min(a,b)+c;
        }else if(a!=0||b!=0){
            res+=c;
        }else{
            res+=c-1;
        }
    }else{
        res+=min(a,b);
    }
    
    put(res);
    
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++)cin >> A[i];

    int lb = 0;
    int ub = 1e+09;
    while(ub - lb > 1){
        int mid = (ub + lb) / 2;
        int count = 0;
        for(int i = 0; i < n; i++){
            if (A[i] > mid){
                count += (A[i] + mid - 1)/mid - 1;
            }
        }
        if (count > k)lb = mid;
        else ub = mid;
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 3688
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll a[51] = {0};
ll p[51] = {0};

ll solve(ll N, ll X){
    if(N == 0 && X == 1) return 1;
    if(X == 1) return 0;
    if(1 < X && X <= (1 + a[N-1])) return solve(N-1, X-1);
    if(X == (2 + a[N-1])) return p[N-1] + 1;
    if(X > (2 + a[N-1]) && X <= (2 + 2 * a[N-1])){
        return p[N-1] + 1 + solve(N-1, X-2-a[N-1]);
    }
    else{
        return 2 * p[N-1] + 1;
    }
}

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


    ll N, X;
    cin >> N >> X;

    a[0] = 1;
    p[0] = 1;
    FOR(i,1,51){
        a[i] = 2 * a[i-1] + 3;
        p[i] = 2 * p[i-1] + 1;
    }

    cout << solve(N,X) << endl;
    return 0;
}

Measured memory_bytes: 256
//#include "SaveFuncs.cpp"

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
string strMulti(string t, int n) { string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }

/*****/

int Main()
{
	ll A, B;
	cin >> A >> B;

	if (A < B)	swap(A, B);

	ll ret = A + B;

	if (ret % 2 == 1)
	{
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	cout << ret / 2 << endl;

	return 0;
}

/*****/

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

	Main();

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    scanf("%d %d", &n, &m);
    printf("%d", (n * n - n + m * m - m) / 2);
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define N 100010
using namespace std;
int main() 
{
	ll n,m;
	cin>>n>>m;
	vector<ll> l;
	vector<ll> r;
	for(int i=0;i<m;i++)
	{
		ll a,b;
		cin>>a>>b;
		l.push_back(a);
		r.push_back(b);
	}
	ll max_l,min_r;
	vector<ll>::iterator iter_l=max_element(l.begin(),l.end());
	vector<ll>::iterator iter_r=min_element(r.begin(),r.end());
	size_t index_l=distance(l.begin(),iter_l);
	size_t index_r=distance(r.begin(),iter_r);
	max_l=l[index_l];
	min_r=r[index_r];
	ll ans=0;
	if(max_l<=min_r)
	{
		ans=min_r-max_l+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    double sum = 0.0;
    for(int i = 0; i < n; ++i) {
        double m;
        string s;
        cin >> m >> s;
        if( s == "JPY" ) sum += m;
        else sum += 380000.0 * m;

    }
    printf("%lf\n", sum);
    return 0;
}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

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 S(): return input()


def main():
    n = I()
    if n%10 == 9 or n//10 == 9:
        return 'Yes'

    return 'No'

print(main())





Measured memory_bytes: 8132