akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;
 
 
#define FILENAME ""
 
const ll MAXN = 100002;

                          
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    //freopen("sum2.in", "r", stdin);
    //freopen("sum2.out", "w", stdout);
	ll n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
	 	for (int j = 1; j <= 9; j++) {
	 	 	if (i*j == n) {
	 	 	 	re cout << "Yes", 0;
	 	 	}
	 	}
	}
	cout << "No";
    re 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        arr[x-1]=i+1;
    }
    for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}



Measured memory_bytes: 3956
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

#define MAX 100005

int main(void)
{
  char s[MAX];
  vector<char> u;
  vector<char> v;
  int q, sens = 0, i;
  
  scanf("%s%d", s, &q);
  
  while (q--) {
    int t;
    scanf("%d", &t);
    if (t == 1)
      sens++;
    else {
      int f;
      char c, ch;
      scanf("%d%c%c", &f, &c, &ch);
      if ((sens + f) % 2)
        u.push_back(ch);
      else
        v.push_back(ch);
    }
  }
  
  if (sens % 2 == 0) {
    for (i = u.size()-1; i >= 0; i--)
      putchar(u[i]);
    printf("%s", s);
    for (i = 0; i < v.size(); i++)
      putchar(v[i]);
  } else {
    for (i = v.size()-1; i >= 0; i--)
      putchar(v[i]);
    for (i = strlen(s)-1; i >= 0; i--)
      putchar(s[i]);
    for (i = 0; i < u.size(); i++)
      putchar(u[i]);
  }
  
  putchar('\n');
  
  return 0;
}


Measured memory_bytes: 1024
package main

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

type Dataset struct {
	t int
	x int
	y int
}

func abs(n int) int {
	if n < 0 {
		n = -n
	}
	return n
}

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	n, _ := strconv.Atoi(s.Text())

	dataset := make([]Dataset, n+1)
	dataset[0] = Dataset{0, 0, 0}
	for i := 1; s.Scan(); i++ {
		data := strings.Split(s.Text(), " ")
		t, _ := strconv.Atoi(data[0])
		x, _ := strconv.Atoi(data[1])
		y, _ := strconv.Atoi(data[2])
		dataset[i] = Dataset{t, x, y}
	}

	for i := 0; i < n; i++ {
		dt := dataset[i+1].t - dataset[i].t
		dxy := abs(dataset[i+1].x-dataset[i].x) + abs(dataset[i+1].y-dataset[i].y)
		if dt < dxy || dt%2 != dxy%2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

typedef long long ll;
typedef pair<int,int> pri;
const int INF = 1e9 + 7;
const ll LINF = 1LL<<61;

int n,m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	int k = min(n,m);
	int l = max(n,m);
	if(k==l){
		for(int i = 0; i < n; i++) cout << k;
	}else{
		for(int i = 0; i < l; i++) cout << k;
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
readline = sys.stdin.readline

class BIT:
    #1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.p = 2**(n.bit_length() - 1)
        self.dep = n.bit_length()
    def get(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
    
    def bl(self, v):
        if v <= 0:
            return -1
        s = 0
        k = self.p
        for _ in range(self.dep):
            if s + k <= self.size and self.tree[s+k] < v:
                s += k
                v -= self.tree[s+k]
            k //= 2
        return s + 1

N = int(readline())
W = [0]*N
B = [0]*N
for i in range(1, 2*N+1):
    c, a = readline().split()
    if c == 'W':
        W[int(a)-1] = i
    else:
        B[int(a)-1] = i

cw = [0]*(N+1)
cb = [0]*(N+1)
T = BIT(2*N)
for i in range(N):
    cw[i+1] = i-T.get(W[i])
    T.add(W[i], 1)
T = BIT(2*N)
for i in range(N):
    cb[i+1] = i-T.get(B[i])
    T.add(B[i], 1)

invw = [None] + [[0] + list(accumulate([1 if W[i] < B[j] else 0 for j in range(N)])) for i in range(N)]
invb = [None] + [[0] + list(accumulate([1 if B[i] < W[j] else 0 for j in range(N)])) for i in range(N)]
    
inf = 10**9+7
dp = [[inf]*(N+1) for _ in range(N+1)]
dp[0][0] = 0
for s in range(2*N):
    for w in range(max(0, s-N), min(N+1, s+1)):
        b = s-w
        if w != N:
            dp[w+1][b] = min(dp[w+1][b], dp[w][b] + invw[w+1][b] + cw[w+1])
        if b != N:
            dp[w][b+1] = min(dp[w][b+1], dp[w][b] + invb[b+1][w] + cb[b+1])
print(dp[N][N])

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

using namespace std;

int main(){
	int a, b, c, x, y;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	int flag = (2*c < a + b);
	if(flag){
		int sum = 0;
		if(x < y){
			sum += 2 * c * x;
			if(2*c < b){
				printf("%d\n", sum + (y - x) * 2 * c);
			}
			else{
				printf("%d\n", sum + (y - x) * b);
			}
		}
		else{
			sum += 2*c *y;
			if(2*c < a){
				printf("%d\n", sum + (x - y) * 2 * c);
			}
			else{
				printf("%d\n", sum + (x - y) * a);
			}
		}
	}
	else{
		printf("%lld\n",1ll* x * a +1ll* y * b);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int n, m, ans;
int tag[maxn * 4], mx[maxn * 4];
pair<int, int> a[maxn];
void pushdown(int x) {
    if(tag[x]) {
    	tag[x << 1] += tag[x];
    	tag[x << 1 | 1] += tag[x];
    	mx[x << 1] += tag[x];
    	mx[x << 1 | 1] += tag[x];
    	tag[x] = 0;
    }
}
int query(int l, int r, int x, int a, int b) {
    if(l > b || r < a) {
   		return 0;
    }
    if(l >= a && r <= b) {
    	return mx[x];
    }
    pushdown(x);
   	int mid = (l + r) >> 1;
   	return max(query(l, mid, x << 1, a, b), query(mid + 1, r, x << 1 | 1, a, b));
}
void update(int l, int r, int x, int a, int b, int d) {
   	if(l > b || r < a) {
   		return;
   	}
   	if(l >= a && r <= b) {
   		mx[x] += d;
   		tag[x] += d;
   		return;
   	}
   	pushdown(x);
   	int mid = (l + r) >> 1;
   	update(l, mid, x << 1, a, b, d);
   	update(mid + 1, r, x << 1 | 1, a, b, d);
   	mx[x] = max(mx[x << 1], mx[x << 1 | 1]);
}
void build(int l, int r, int x) {
	if(l == r) {
		mx[x] = -m + r - 1;
		return;
 	}
 	int mid = (l + r) >> 1;
 	build(l, mid, x << 1);
 	build(mid + 1, r, x << 1 | 1);
 	mx[x] = max(mx[x << 1], mx[x << 1 | 1]);
}
int main() {
   	scanf("%d%d", &n, &m);
   	for(int i = 1; i <= n; ++i) {
    	scanf("%d%d", &a[i].first, &a[i].second);
    }
   	sort(a + 1, a + n + 1);
   	build(1, m + 1, 1);
   	for(int i = 0, j = 1; i <= m; ++i) {
   		while(j <= n && a[j].first <= i) {
			update(1, m + 1, 1, 1, a[j].second, 1);	
			++j;
		}
		ans = max(ans, query(1, m + 1, 1, i + 1, m + 1) - i);
	}
    printf("%d\n", max(ans, n - m));
   	return 0;
}

Measured memory_bytes: 9984
from operator import itemgetter

N, M = [int(i) for i in input().strip().split(' ')]
A = [int(i) for i in input().strip().split(' ')]
A = sorted(A, reverse=True)

X = []
for _ in range(M):
  (b, c) = [int(i) for i in input().strip().split(' ')]
  X.append((b, c))

X = sorted(X, reverse=True, key=itemgetter(1))
if M < N:
  for _ in range(N - M):
    X.append((0, 0))

v = 0
ai = 0
xi = 0

while N > 0:
  a = A[ai]
  n, x = X[xi]
  if a > x:
    N -= 1
    ai += 1
    v += a
  else:
    if n > N:
      n = N
    N -= n
    xi += 1
    v += x * n

print(v)

Measured memory_bytes: 22940
#include <iostream>

using namespace std;

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

  switch (N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MAXN = 1e5 + 5;
ll A, B, C, X, Y;
ll ans = 1e18;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> A >> B >> C >> X >> Y;
	// not A
	ans = min(ans, 2 * X * C + max(0ll, (Y - X)) * B);
	// not B
	ans = min(ans, 2 * Y * C + max(0ll, (X - Y)) * A);
	// not C
	ans = min(ans, X * A + Y * B);
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut s: String = read();
    s = s.chars().rev().collect::<String>();
    let v = vec!("dream", "dreamer", "erase", "eraser");
    let v:Vec<String> = v.into_iter().map(|p| {
        p.chars().rev().collect::<String>()
    }).collect();

    while !s.is_empty() {
        let found = v.iter().find(|&z| { s.starts_with(z) } );
        match found {
            Some(z) => s = s.trim_left_matches(z).to_string(),
            None => {
                println!("NO");
                return;
            }
        }
    }
    println!("YES");
}

Measured memory_bytes: 4476
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;

void solution()
{
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << '\n';
}

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


Measured memory_bytes: 3648
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int a,b,k;
  cin >> k >> a >> b;
  if(b/k - (a-1)/k > 0) cout << "OK" << endl;
  else cout << "NG" << endl; 
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n),s(n+1);
    rep(i,n)cin >> a[i];
    s[0]=0;
    rep(i,n)s[i+1]=s[i]+a[i];
    ll min_diff=1e15;
    rep(i,n){
        //[0,i)を二等分
        int l=0,r=i;
        while(r-l>1){
            int m=(l+r)/2;
            if(s[m]*2>s[i])r=m;
            else l=m;
        }
        ll b_sum[2]={s[l],s[r]},c_sum[2]={s[i]-s[l],s[i]-s[r]};
        //[i,n)を二等分
        l=i;
        r=n;
        while(r-l>1){
            int m=(l+r)/2;
            if((s[m]-s[i])*2>s[n]-s[i])r=m;
            else l=m;
        }
        ll d_sum[2]={s[l]-s[i],s[r]-s[i]},e_sum[2]={s[n]-s[l],s[n]-s[r]};
        rep(j,2)rep(k,2){
            ll sum_all[4]={b_sum[j],c_sum[j],d_sum[k],e_sum[k]};
            sort(sum_all,sum_all+4);
            min_diff=min(min_diff,sum_all[3]-sum_all[0]);
        }
    }
    cout << min_diff << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size() + 1;
  vector<int> L(N), R(N);
  for (int i = 0, tmp = 0; i < S.size(); i++) {
    if (S.at(i) == '<') tmp++; 
    else tmp = 0;
    L.at(i + 1) = tmp;
  }
  reverse(S.begin(), S.end());
  for (int i = 0, tmp = 0; i < S.size(); i++) {
    if (S.at(i) == '>') tmp++; 
    else tmp = 0;
    R.at(i + 1) = tmp;
  }
  reverse(R.begin(), R.end());
  long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += max(L.at(i), R.at(i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N, M;
int A[110];


int main() {
    cin >> N >> M;
    double sum = 0;
    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] >= sum/(double)(4*M)) {
            cnt++;
        }
    }

    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;

    

    return 0;
}

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

using namespace std;

string to_string(int x){
    stringstream s;
    s << x;

    return s.str();
}

int main(){
    string s;
    cin >> s;
    string res = s.substr(0, 1);
    res += to_string(s.length() - 2);
    res += s[s.length() - 1];
    cout << res;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
signed main() {
	vector<int>v;
	multiset<int>s;
	int g = 0;
	cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		int tmp = read();
		s.insert(tmp);
		g = max(g, tmp);
	}
	v.push_back(g);
	s.erase(s.find(g));
	for (int i = 0; i < n; i++) {
		vector<int>uv;
		for (auto eml : v) {
			auto it = s.lower_bound(eml);
			if (it == s.begin()) {
				cout << "No\n";
				return 0;
			}
			it--;
			uv.push_back(*it);
			s.erase(it);
		}
		for (auto eml : uv) {
			v.push_back(eml);
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 15460
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	for (int i = 1; i <= k; i++){
		if (b <= a){
			b = b * 2;
		}
		else if (c <= b){
			c = c * 2;
		}

		if (a < b&&b < c){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

    void yes(bool fl = true){
            if(fl) cout << "YES\n";
            else cout << "Yes\n";
    }
    void no(bool fl = true){
        if(fl) cout << "NO\n";
        else cout << "No\n";
    }  

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q;
        ll mod = 1e9 + 7;
        


        void solve(){
            string str;
            cin >> str;
            int n = str.size();
            vector<int> v(1,0);
            map<int,int> mp;
            int curr = 1;
            for(int i=n-1; i>= 0; i--){
                int value = (str[i] - '0') * curr % 2019;
                v.pb(value);
                curr *= 10;
                curr %= 2019;
            }
            mp[0] = 1;
            for(int i=1; i<v.size(); i++){
                v[i] = (v[i] + v[i-1]) % 2019;
                mp[v[i]]++;
            }
            ll cnt  = 0;
            for(auto x : mp){
                //cout << x.first << " " << x.second << endl;
                cnt += (x.second) * (x.second -1 )/2;
            }
            cout << cnt;
        }  
            
        int main(){
        ios_base::sync_with_stdio(false);
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        int cases = 1;
        //cin >> cases;
    
        while(cases--){ 
            solve();
        }

        return 0;

        }

Measured memory_bytes: 4456
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long count = 0;
  int a;
  string s;
  cin >> a;
  cin >> s;
  
  
  for(int i=0; i<a; i++){
      for(int j=i+1; j<a; j++){
          if(s[i] == s[j]) continue;
          for(int k=j+1; k<a; k++){
              if(j-i != k-j && s[i] != s[k] && s[j] != s[k]) count++;
          }
      }
  }

  cout << count << endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

const ll inf = 900000000000000000;

ll dp[(1 << 12)];

int main() {
    optimize();
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < (1 << N); ++i) dp[i] = inf;
    for (int i = 0; i < M; ++i) {
        ll a, b;
        cin >> a >> b;
        int mask = 0;
        for (int j = 0; j < b; ++j) {
            int c;
            cin >> c;
            c--;
            mask |= (1 << c);
        }
        // cout << mask << endl;
        dp[mask] = min(dp[mask], a);
    }
    for (int mask1 = 0; mask1 < (1 << N); ++mask1) {
        for (int mask2 = 0; mask2 < (1 << N); ++mask2) {
            if (mask1 == mask2) continue;
            if (mask1 & (((1 << N) - 1) ^ mask2) && dp[mask1] < inf && dp[mask2] < inf) dp[mask1 | mask2] = min(dp[mask1 | mask2], dp[mask1] + dp[mask2]);
        }
    }
    cout << (dp[(1 << N) - 1] == inf ? -1 : dp[(1 << N) - 1]) << endl;
    return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    for (;;) {
        int n; cin >> n;
        if (!n) break;

        vector<ll> v(n);
        ll sum = 0;
        rep(i, 0, n) cin >> v[i], sum += v[i];
        int ans = 0;
        rep(i, 0, n) if (v[i] * n <= sum) ans++;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=1e2+10;
double a[N];
int main()
{
	int n,m;
	cin>>n>>m;
	double sum=0;
	rep(i,1,n)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	double mi=sum/(4*m);
	int ans=0;
	rep(i,1,n){
        if(a[i]>=mi) ans++;
	}
	printf("%s",ans>=m?"Yes":"No");

}


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

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;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return sizes[root(x)];
    }

};

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

    int n;
    cin >> n;

    const int INF = 1e9;

    vector<int> dp(100010, INF);

    dp[0] = 0;

    for(int i = 1; i <= n; ++i) {
        int power = 1;
        while(power <= i) {
            dp[i] = min(dp[i], dp[i-power] + 1);
            power *= 6;
        }
        int p = 1;
        while(p <= i) {
            dp[i] = min(dp[i], dp[i-p] + 1);
            p *= 9;
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>

int main(void){
    double x;
    double sum;
    int i;
    while(scanf("%lf",&x)==1){
        sum=x;
        for(i=2;i<=10;i++){
            if(i%2==0)x*=2;
            else x/=3;
            sum+=x;
        }
        printf("%lf\n",sum);
    }

    return 0;
}



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



void solve() {
    string S;
    ll K;
    cin >> S >> K;
    ll N = (ll)S.size();

    vector<Vl> pos(26);
    for (ll i = 0; i < N; i++) {
        ll idx = S[i] - 'a';
        pos[idx].emplace_back(i);
    }

    vector<string> cans;
    string ans;
    for (ll i = 0; i < 26; i++) {
        cans.clear();
        for (const auto& idx : pos[i]) {
            for (ll j = 0; j < K; j++) {
                if (idx + j < N) {
                    cans.emplace_back(S.substr(idx, j + 1));
                }
                else {
                    break;
                }
            }
        }
        sort(cans.begin(), cans.end());
        cans.erase(unique(cans.begin(), cans.end()), cans.end());
        if ((ll)cans.size() >= K) {
            ans = cans[K - 1];
            break;
        }
        else {
            K -= (ll)cans.size();
        }
    }

    cout << ans << endl;
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib> 
#include <string>
#include <iomanip>

using namespace std;

int main() {
	double ans;
	int n;
	cin >>n;
	vector <double> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >>a.at(i);

	}
	for (int i = 0; i < n; i++)
	{
		ans += 1/a.at(i);
	}

	std::cout << std::setprecision(20) << 1/ans;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
	char a[1000];
	cin>>a;
	long long n;
	cin>>n;
	int i;
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]!='1')
		{
			break;
		}
	}
	if(i>n-1)
	{
		cout<<1;
	}
	else
	{
		cout<<a[i];
	}
	return 0;
}

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

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	int n;
	scanf("%d", &n);
	int c, d;
	
	for (int i = 1;i <= 9;i++)
	{
		c = n%i;
		d = n / i;
		if (c == 0)
		{
			if (1 <= d&&d <= 9)
			{
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll A[1<<20];int n;ll sum = 0;
ll a = 0, b = 0;

int main() {
	ios::sync_with_stdio(false);
    //freopen("input.in","r",stdin);
 	//freopen("output.out","w",stdout);
	cin>>n;
	rep(i, n) {
		cin>>A[i];
		sum += A[i];
	}

	a = A[0];
	b = sum-a;

	ll ans = abs(a-b);
	for(int i = 1;i < n-1;i++) {
		a += A[i];
		b -= A[i];
		ans = min(ans, abs(a-b));
	}

	cout<<ans<<endl;

	return 0;
}


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

int main(){
    bool isok=true;
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i==a) isok&=s[i]=='-';
        else isok&=isdigit(s[i]);
    }
    cout<<(isok?"Yes":"No")<<endl;
    return 0;
}

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

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

	int n; cin >> n;
	vector<long long> a(n), b(n);
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	long long cnt = 0;
	for(int i = 0; i < n; i++){
		if((a[i] + cnt) % b[i] == 0) continue;
		else cnt += b[i] - ((a[i] + cnt) % b[i]); 
	}
	cout << cnt << endl;
	return 0;	
}
  

Measured memory_bytes: 1792
import sys
N,T = [int(n) for n in input().split()]
# N = int(input())
A = [int(n) for n in input().split()]

minv = 10**10
difmax = 0
ans = 0
for i in range(N):
    minv = min(minv,A[i])
    if(difmax < A[i]-minv):
        difmax = A[i]-minv
        ans = 1
    elif difmax == A[i]-minv:
        ans+=1
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    ll sum1 = 0;
    ll ans1 = 0;
    // 正 -> 負
    int cur = 1;
    REP(i,n){
        sum1 += a[i];
        if(sum1 * cur <= 0){
            ans1 += abs(sum1 - cur);
            sum1 = cur;
        }
        cur *= -1;
    }

    // 負 -> 正
    ll sum2 = 0;
    ll ans2 = 0;
    cur = -1;
    REP(i,n){
        sum2 += a[i];
        if(sum2 * cur <= 0){
            ans2 += abs(sum2 - cur);
            sum2 = cur;
        }
        cur *= -1;
    }

    cout << min(ans1, ans2) << endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n; cin>>n;
    map<string, int> m;
    For(i, 0, n){
        string s; cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int a,b,c,ans=0;
	cin>>a>>b>>c;	
	for(int i=a;i<=b;i++)
	{
		if(c%i==0)ans++;
	}
	cout<<ans<<endl;
	return 0;	
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }



int main() {
    int a,b,t; cin >>a >> b>>t;
    int ans =0;
    for(int i=a;i<=t;i+=a){
        ans +=b;
    }
    cout <<ans <<endl;
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int g = 0;
	int p = 0;
	for(auto c: s){
		if(c == 'g') g++;
		else p++;
	}
	if (g - p <= 1) {
		cout << 0;
	} else {
		cout << (g - p) / 2;
	}
	return 0;
}

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

int main() {
  string s; cin >> s;
  int add = 0;
  rep(i,3) if(s[i] == 'o') add += 100;
  cout << add + 700 << endl;
}


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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	string g;
	for(char x : s){
		if(!g.empty() && g.back() == 'S' && x == 'T'){
			g.pop_back();
		} else {
			g += x;
		}
	}
	cout << g.size() << '\n';
}

Measured memory_bytes: 916
import numpy as np
import math
A, B, C, D = [int(i) for i in input().split()]
 
large = np.max([C, D])
small = np.min([C, D])
#print(large)
#print(small)
#quo = large // small
#rem = large % small
g = large
while small != 0:
    large, small = small, large % small
#    print(large)
#    print(small)
 
g = large
#print(g)
 
l = C * D // g
 
num_B_1 = B // C
num_B_2 = B // D
num_B_3 = B // l
num_B = B - (num_B_1 + num_B_2 - num_B_3)

num_A_1 = (A - 1) // C
num_A_2 = (A - 1) // D
num_A_3 = (A - 1) // l
num_A = (A - 1) - (num_A_1 + num_A_2 - num_A_3)
 
print(num_B - num_A)

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

static const int N=1000;

int lcs(string x,string y){
    int c[N+1][N+1];
    int m=x.size();
    int n=y.size();
    int maxl =0;
    x=' '+x;
    y=' '+y;
    for(int i=0;i<=m;i++)c[i][0]=0;
    for(int j=1;j<=n;j++)c[0][j]=0;
    
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(x[i]==y[j]){
                c[i][j]=c[i-1][j-1]+1;
            }else{
                c[i][j]=max(c[i-1][j],c[i][j-1]);
            }
            maxl=max(maxl,c[i][j]);
        }
    }
    return maxl;
    }
    int main(){
        string s1,s2;
        int n;cin>>n;
        for(int i=0;i<n;i++){
            cin>>s1>>s2;
            cout<<lcs(s1,s2)<<endl;
        }
        return 0;
    }


Measured memory_bytes: 6904
#include <stdio.h>

int main(void){
  int a, b, c;
  int count = 0;
  scanf("%d %d %d", &a, &b, &c);
  if(a != b) count++;
  if(b != c) count++;
  if(c != a) count++;
  if(count == 0) count++;
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

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



int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll n; scanf("%lld", &n);
	vector<ll> h(n); for (ll i = 0; i < n; i++) scanf("%lld", &h[i]);
	stack<pair<int, int>> st;
	vector<ll> left(n);
	for (ll i = 0; i < n; i++) {
		ll cnt = 1;
		while (!st.empty() && st.top().first >= h[i]) {
			cnt += st.top().second;
			st.pop();
		}
		left[i] = cnt;
		st.emplace(h[i], cnt);
	}
	while (!st.empty()) st.pop();
	vector<ll> right(n);
	for (ll i = n - 1; i >= 0; i--) {
		ll cnt = 1;
		while (!st.empty() && st.top().first >= h[i]) {
			cnt += st.top().second;
			st.pop();
		}
		right[i] = cnt;
		st.emplace(h[i], cnt);
	}
	ll res = 0;
	for (ll i = 0; i < n; i++) {
		ll cnt = left[i] + right[i] - 1;
		chmax(res, h[i] * cnt);
	}
	
	cout << res << endl;
	return 0;
}



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

c=0
for e,i in enumerate(A):
    for j in A[e:]:
        if i>j:c+=K*(K+1)//2
        if i<j:c+=K*(K-1)//2
            
print(c%(10**9+7))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int A,B,C;
void Solve() {
    read(A);read(B);read(C);
    if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {out(0);enter;}
    else {
	out(min(min(1LL * A * B,1LL * B * C),1LL * A * C));enter;
    }
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
 
#define all(v) v.begin(),v.end()
#define test() int t;cin>>t;while(t--) 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9+7;

int main()
{   
    fastio
    int n;
    string str;
    cin>>n;
    cin>>str;
    int addr, addw;
    vi pfx_sumw(n+1), pfx_sumr(n+1);
    for (int i = 0; i < n; i++)
    {
        addr=0;
        addw=0;
        if(str[i]=='R')addr = 1;
        else addw = 1;
        pfx_sumr[i+1]=addr+pfx_sumr[i];
        pfx_sumw[i+1]=addw+pfx_sumw[i];
    }
    int mn = n;
    for (int i = 0; i <=n; i++)
    {
        mn=min(mn, max(pfx_sumw[i], pfx_sumr[n]-pfx_sumr[i]));
    }
    cout<<mn<<endl;
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;

int main(){

    fastio ;

    ll n;
    vector<double> p(3005);
    vector<vector<double>> dp(3005 , vector<double>(3005));

    cin >> n;
    for(ll i = 1; i <= n; i++) cin >> p[i];

    // OPTIMAL SUB-PROBLEM :

    // BASE CASE :

    dp[1][1] = p[1];
    dp[0][0] = 1;
    for(ll i = 1; i <= n; i++) dp[i][0] = (1-p[i])*dp[i-1][0];
    for(ll i = 2; i <= n; i++) dp[1][i] = 0;

    // RECURSIVE RELATION :


    for(ll i = 2; i <= n; i++){
        for(ll j = 1; j <= n; j++){
            dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
        }
    }

    // OPTIMAL SOLUION :

    double total  = 0;

    for(ll i = floor(n/2)+1 ; i <= n; i++) total += dp[n][i];
    cout << fixed << setprecision(9);

    cout << total;
}




Measured memory_bytes: 70912
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <numeric>
#define ll long long 
#define Y "YES"
#define N "NO"
#define elif else if
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define rep(i,a,n) for(int i=a; i<n; i++)
#define per(i,a,n) for(int i=n; i>=0; i--)
#define pii pair<int,int>
#define wolfe ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int main () { 
    wolfe;
    string s;
    cin >> s;
    int n = s.size();
    int sum = 0;
    rep(i,0,n) {
        sum += s[i] - '0';
        if(n==1 && s[i]=='0') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(sum%9==0) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    
    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
string s;
cin>>s;
map<char,bool> m;
rep(i,s.size()){
    m[s[i]]=true;
}
for(char i='a';i<='z';i++){
    if(!m[i]){
        cout<<i<<endl;
        return 0;
    }
}
cout<<"None"<<endl;

  return 0;
}


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

int main()
{
	// cinはscanfより基本的に遅い
	// sync_with_studio()を事前に書いておくとcinでも速度向上が期待出来る！

	bool flg = false;
	int n, p, cur;
	int curP;
	vector<int> s; 
	
	while (cin >> n >> p) {
		if (n == 0 && p == 0) {
			break;
		}
		// 初期化処理
		cur = 0;
		curP = p;
		s.clear();
		s.resize(n);

		// 現在の候補者が碗から石を取り出す
		// 番号が降ってあるわけではない！
		while (true) {
			// 現在ターンである候補者が1つ取り出す
			if (curP > 0) {
				s[cur]++;
				curP--;
			} else if (curP == 0 && s[cur] > 0) {// 手元に小石があれば全て碗の中に入れる
				curP += s[cur];
				s[cur] = 0;
			}
			
			// 条件を満たして入れば終了
			if (curP == 0) {
				flg = true;
				for (int i = 0; i < s.size(); i++) {
					if (s[i] > 0 && i != cur) {
						flg = false;// 条件満たさず
						break;
					}
				}
				if (flg) {
					cout << cur << endl;
					break;
				}
			}

			// 次の候補者へ
			cur++;
			if (cur == n) cur = 0;
		}
	}

	return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i,n) for(ul i=0;i<n;i++)

ul L, R, N, M, Q;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> Q;
    P LR[M];
    auto pq = vector<P> (Q, make_pair(0, 0));
    auto train_table = vector<vector<int>> (N + 1, vector<int>(N + 1, 0));
    auto cum = vector<vector<int>> (N + 1, vector<int>(N + 1, 0));
    REP(itr, M) {
      cin >> LR[itr].first >> LR[itr].second;
      ++train_table[LR[itr].first][LR[itr].second];
    }
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        cum[i][j] = cum[i][j-1] + train_table[i][j];
      }
    }

    for (ul itr = 0; itr < Q ; ++itr) {
      cin >> pq[itr].first >> pq[itr].second;
      int ans = 0;
      for (ul j = pq[itr].first; j <= pq[itr].second; ++j) {
        ans += cum[j][pq[itr].second];
      }
      cout << ans << endl;
    }
}


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

int n, k, d[10];

bool contains(int n)
{
    while (n)
    {
        if (d[n%10]) return 1;
        n /= 10;
    }
    return 0;
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < k; i++)
    {
        int x;
        cin >> x;
        d[x] = 1;
    }
    while (contains(n)) n++;
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256