akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
int n, m;
vector<vector<int>> graph;
void aoj(vector<int> bs) {
    REP(i, bs.size() - 1) { cout << bs[i] << " "; }
    cout << bs[bs.size() - 1] << endl;
}

signed main() {
    long long a;
    string b;
    cin >> a >> b;
    cout << a * (b[0] - '0') + (a * ((b[2] - '0') * 10 + (b[3] - '0'))) / 100 << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
    cin >> N;
    int K;
    cin >> K;
  	int A = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin>> x;
    if (x > (K - x)){
    A+=  (K - x) * 2;
    continue;
    }
    A+= x *2;
    }
  cout << A << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
n = N
cnt = 0
while n > 0:
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            cnt += 1
    n -= 1
for i in range(N):
    if i == N - 1:
        print(str(A[i]))
    else:
        print(str(A[i]) + " ", end = "")
print(cnt)

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

int main(int argc, char **argv)
{
	ll n;
  cin>>n;
  vector <ll> arr(n);
  for(ll i=0;i<n;i++) cin>>arr[i];
  ll min_req=arr[0];
  ll stool=0;
  for(ll i=1;i<n;i++){
    if (arr[i]<=min_req){
      stool+=min_req-arr[i];
    }
    else{
      min_req=arr[i];
    }
  }
  cout<<stool<<"\n";
	return 0;
}

Measured memory_bytes: 4848
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, M = reads()
shop = []
for _ in range(N):
  A, B = reads()
  shop.append((A, B))
shop.sort(); shop.reverse()

count = 0
ans = 0
while count < M:
  A, B = shop.pop()
  m = min(M - count, B)
  count += m
  ans += m * A
print(ans)



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

int main() {
    
    int n; cin >> n;
    vector<ll> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());      
    ll ans = 0;
    for (int j = 0; j < n; j++) {
        ll na = lower_bound(a.begin(), a.end(), b[j]) - a.begin();
        ll nc = c.end() - upper_bound(c.begin(), c.end(), b[j]);
        ans += na * nc;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

int main(){
    int a,b,c,x,y;

    cin >> a >> b >> c >> x >> y;

    int ans = 0;

    if (x < y){
        swap(x,y);
        swap(a,b);
    }

    int d = x - y;
    ans += min(y*(a+b),c*2*y);
    ans += min(d*a,d*c*2);
    cout << ans << endl;
}

Measured memory_bytes: 256
N = input() 
heights = input()

N = int(N)
heights = list(map(int, heights.split(' ')))

def solve_problem_dp(N, heights):
    if N == 1:
        return 0
    elif N == 2:
        return abs(heights[0] - heights[1])
    costs = [0] * len(heights)
    costs[1] = abs(heights[0] - heights[1])

    for i in range(2, len(heights)):
        cost_jump1 = abs(heights[i] - heights[i-1]) + costs[i-1]
        cost_jump2 = abs(heights[i] - heights[i-2]) + costs[i-2] 
        best_cost = min(cost_jump1, cost_jump2)
        costs[i] = best_cost
    
    return costs[-1]


print(solve_problem_dp(N, heights))


Measured memory_bytes: 14356
from math import gcd
from functools import reduce
NUM_MAX = 10**6 + 1
def solve(n, a):
    c = [0] * NUM_MAX
    for x in a:
        c[x] += 1
    t = any(sum(c[i::i]) > 1 for i in range(2, NUM_MAX))
    t += reduce(gcd, a) > 1
    return ["pairwise", "setwise", "not"][t] + " coprime"

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))


Measured memory_bytes: 133056
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	char s;
	cin >> s;
	if (s == 'A') {
		cout << "T" << endl;
	}
	if (s == 'T') {
		cout << 'A' << endl;
	}
	if (s == 'G') {
		cout << "C" << endl;
	}
	if (s == 'C') {
		cout << "G" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let v: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let r = v[0];
    let d = v[1];
    let mut x = v[2];
    for _ in 0..10 {
        x = r * x - d;
        println!("{}", x);
    }
}


Measured memory_bytes: 4352
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var data = Console.ReadLine().Split(' ');
            var result = new int[n];
            foreach(string str in data){
                result[int.Parse(str)-1]++;
            }
            foreach(int num in result)
            {
                Console.WriteLine(num);
            }
        }
    }
}


Measured memory_bytes: 41968
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 10L ^^ 16;

void main() {
    long L;
    int n;
    scan(L, n);
    auto x = iota(n).map!(i => readln.chomp.to!long).array;

    auto ans = max(solve(n, L, x), solve(n, L, x.map!(xi => L - xi).retro.array));

    writeln(ans);
}

long solve(int n, long L, long[] x) {
    auto y = x.map!(xi => L - xi).retro.array;

    auto xs = new long[](n + 1);
    foreach (i ; 0 .. n) {
        xs[i+1] = xs[i] + x[i];
    }

    auto ys = new long[](n + 1);
    foreach (i ; 0 .. n) {
        ys[i+1] = ys[i] + y[i];
    }

    debug {
        writeln("xs:", xs);
        writeln("y: ", y);
        writeln("ys:", ys);
    }

    long ans;

    foreach (i ; 1 .. n + 1) {
        int r = n - i;
        long tmp;

        if (i > r) {
            tmp = 2L * (xs[i] - xs[i - r - 1] + ys[r]) - x[i-1];
        }
        else {
            tmp = 2L * (xs[i] + ys[r] - ys[r - i]) - x[i-1];
        }

        debug {
            stderr.writefln("i: %d, tmp: %d", i, tmp);
        }

        ans = max(ans, tmp);
    }

    return ans;
}



























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 12412
#include <stdio.h>
#include <string.h>

int main(void)
{
	int num;
	unsigned char card[4][13];
	char c;
	int d;
	int ii, jj;
	char card_str[] = { 'S', 'H', 'C', 'D' };

	memset(&card[0][0], (int)0, sizeof(unsigned char) * 4 * 13);

	scanf("%d", &num);
	scanf("%c", &c);

	for (ii = 0; ii < num; ii++) {
		scanf("%c %d", &c, &d);
		if (c == 'S') {
			card[0][d - 1] = 1;
		} else if (c == 'H') {
			card[1][d - 1] = 1;
		} else if (c == 'C') {
			card[2][d - 1] = 1;
		} else if (c == 'D') {
			card[3][d - 1] = 1;
		}
		scanf("%c", &c);
	}

	for (ii = 0; ii < 4; ii++) {
		for (jj = 0; jj < 13; jj++) {
			if (card[ii][jj] != 1) {
				printf("%c %d\n", card_str[ii], jj + 1);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var t = Console.ReadLine();
            Console.WriteLine(t.Replace('?', 'D'));
        }
    }
}


Measured memory_bytes: 26972
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

const long long mod = 1e9 + 7;

int main() {
	int n;
    cin >> n;
    int* h;
    h = new int[n];

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

    for(int i = n-1; i > 0; i--){
        if(h[i] < h[i-1]) h[i-1]--;
        if(h[i] < h[i-1]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s;
	char ch;
	while(cin>>ch) s+=ch;
	sort(s.begin(),s.end());
	cout<<(s=="1479"?"YES":"NO")<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
int main()
{
  char s[1000000];
  char str1[1000000];
  char str2[1000000];
  int n,i;
  int r = 0, q = 0;
  
  scanf("%s",s);
  n = strlen(s);
  
  for(i = 0;i < n;i++){
    switch(i % 2){
      case 0: str1[i] = '0'; str2[i] = '1'; break;
      case 1: str1[i] = '1'; str2[i] = '0'; break;
    }
  }

  for(i = 0;i <= n;i++){
    if(s[i] != str1[i])
      r++;
    if(s[i] != str2[i])
      q++;
  }

  if(r <= q)
    printf("%d\n",r);
  else
    printf("%d\n",q);
  
  return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long t;
  cin>>t;
  int n=t;
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  if(t%sum==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

namespace ConsoleApplication1
{
    struct Rectangle
    {
        internal int height, pos;
    }

    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int H = input[0];
            int W = input[1];

            int[,] dp = new int[H, W + 1];

            for (int i = 0; i < H; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                for (int j = 0; j < W; j++)
                {
                    if (input[j] == 1) dp[i, j] = 0;
                    else dp[i, j] = i > 0 ? dp[i - 1, j] + 1 : 1;
                }
            }

            Stack<Rectangle> stk = new Stack<Rectangle>();
            int maxArea = 0;

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j <= W; j++)
                {
                    Rectangle rect;
                    rect.height = dp[i, j];
                    rect.pos = j;

                    if (stk.Count == 0)
                    {
                        stk.Push(rect);
                    }
                    else
                    {
                        if (stk.Peek().height < rect.height)
                        {
                            stk.Push(rect);
                        }
                        else if (stk.Peek().height > rect.height)
                        {
                            int target = j;

                            while (stk.Count > 0 && stk.Peek().height >= rect.height)
                            {
                                Rectangle pre = stk.Pop();
                                int area = pre.height * (j - pre.pos);
                                maxArea = Math.Max(maxArea, area);
                                target = pre.pos;
                            }
                            rect.pos = target;
                            stk.Push(rect);
                        }
                    }
                }
            }

            Console.WriteLine(maxArea);
        }
    }
}

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

#define PI 3.14159265358979323846264338327950L
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int arr[n + 10];
    memset(arr, 0, sizeof(arr));
    for (int i = 2; i <= n; i++) {
        int temp;
        cin >> temp;
        arr[temp]++;
    }
    for (int j = 1; j <= n; j++) {
        cout << arr[j] << "\n";
    }


}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int popcnt(int n)
{
    int ret = 0;
    while (n)
    {
        ret += n & 1;
        n >>= 1;
    }
    return ret;
}

int main()
{
    map<char, ll> mp;
    string march = "MARCH";
    int n;
    cin >> n;
    rep(i, n)
    {
        string s;
        cin >> s;
        mp[s[0]]++;
    }
    ll ans = 0;
    rep(i, 1 << 5)
    {
        if (popcnt(i) != 3)
            continue;
        ll tmp = 1;
        rep(j, 5)
        {
            if ((i >> j) & 1)
            {
                tmp *= mp[march[j]];
            }
        }
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
from sys import exit

S = input()

ans1 = 0
ans2 = 0

for i in range(len(S)):
    if i % 2 == 0:
        # 偶数
        if S[i] == '1':
            ans1 += 1
        else:
            ans2 += 1
    else:
        # 奇数
        if S[i] == '1':
            ans2 += 1
        else:
            ans1 += 1

ans = len(S) - max(ans1, ans2)
print(ans)


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

int k;
deque<int> q;
int d[100005];

void print(int x){
    int r=0;
    while(x){
        r+=x%10;
        x/=10;
    }
    cout<<r<<endl;
}

int main(){

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

    cin>>k;
    q.push_back(1);
    memset(d,0x3f,sizeof(d));
    d[1]=1;
    while(!q.empty()){
        int x=q.front();q.pop_front();
        if(d[(x+1)%k]>d[x]+1){
            d[(x+1)%k]=d[x]+1;
            q.push_back((x+1)%k);
        }
        if(d[(x*10)%k]>d[x]){
            d[(x*10)%k]=d[x];
            q.push_front((x*10)%k);
        }
    }
    cout<<d[0]<<endl;

    return 0;
}

Measured memory_bytes: 896
my ($n, $m) = split / /, <STDIN>;
my @xs = sort { $a->[0] <=> $b->[0] } map { [ split(/ /, <STDIN>) ] } 0..($n-1); # (A, B)
my $money = 0;
my $buy = 0;
for my $x (@xs) {
    my ($price, $stock) = @{$x};
    last if $m == $buy;

    my $dest = $m - $buy;
    if ($dest >= $stock) {
        $money += $price * $stock;
        $buy += $stock;
    } else {
        $money += $price * $dest;
        $buy += $dest;
    }
}
print $money, "\n";

Measured memory_bytes: 36604
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
int main() {
	int n, p, m;
	while (cin >> n >> p >> m&&n != 0) {
		double sum , x,parson;
		double  a = 0;
		for (int i = 0; i < n; i++) {
			cin >> x;
			a += x;
			if (i == p - 1) parson = x;
		}
		sum = ((a * 100 * (100 - m ))/ 100);
		if (parson == 0) cout << 0 << endl;
		else cout << floor(sum/parson) << endl;
	}
}

Measured memory_bytes: 3240
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val pList = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
  if (pList.isSorted()) {
    println("YES")
    return
  }
  for (i in 0 until n) {
    for (j in i + 1 until n) {
      val l = pList[i]
      val r = pList[j]
      pList[i] = r
      pList[j] = l
      if (pList.isSorted()) {
        println("YES")
        return
      }
      pList[i] = l
      pList[j] = r
    }
  }
  println("NO")
}

fun List<Int>.isSorted(): Boolean {
  this.forEachIndexed { i, v ->
    if (v != i + 1) return false
  }
  return true
}


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

h,w,m=map(int,input().split())
b=[]
for i in range(m):
    hi,wi=map(int,input().split())
    b.append((hi-1,wi-1))

H=[0]*h
W=[0]*w
for i in b:
    H[i[0]]+=1
    W[i[1]]+=1

hm=set()
wm=set()

hM=max(H)
for i in range(h):
    if H[i]==hM:
        hm.add(i)
wM=max(W)
for i in range(w):
    if W[i]==wM:
        wm.add(i)

count=0
for i in b:
    if i[0] in hm and i[1] in wm:
        count+=1

if len(hm)*len(wm)<=count:
    print(hM+wM-1)
else:
    print(hM+wM)

Measured memory_bytes: 153756
#AGC016-A Shrinking
"""
毎回消去される文字は選べるもんだと思っていたら、必ず最後尾
の文字が無くなる感じだった。
出現する文字全てに対し最も長いところが答え。
"""
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
s = readline().rstrip().decode('utf-8')

dic1 = defaultdict(int)
for i in s:
    dic1[i] += 1

lst1 = []
for i,j in dic1.items():
    lst1.append([j,i])
lst1.sort(reverse=True)

ans = 10**10
for i,j in lst1: #i,出現回数,j:文字
    target = j
    res = []
    res2 = 0
    for k in s:
        if k==target:
            res.append(res2)
            res2 = 0
        else:
            res2+=1
    res.append(res2)
    ans_res = max(res)
    ans = min(ans,ans_res)

print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m, tmp;
	cin >> n >> m;
	multiset<int> a;
	for ( int i = 0 ; i < n ; i++ ){
		cin >> tmp;
		a.insert(tmp);
	}

	for ( int i = 0 ; i < m ; i++ ){
		auto it = a.rbegin();
		int d = *it;
		it++;
		a.erase(it.base());
		a.insert(round(d/2));
	}

	ll sum = 0;
	for ( auto i : a ) {
		sum += i;
	}
	cout << sum << "\n";

	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

int main(int argc, char const *argv[])
{
    long long N;
    cin >> N;
    long long L;
    long long min = LONG_LONG_MAX;
    for (long long i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            L = i + (N / i) - 2;
            if (L < min) min = L;
        }
        
    }

    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
vector<char> vec;
 vec = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int i;
set<char> st;
cin >> S;

for (i = 0;i < S.size();i++) {
    st.insert(S.at(i));
}
for (i = 0;i < st.size();i++) {
    if (st.count(vec.at(i))) continue;
    else break;
}
if (i == vec.size()) cout << "None" << endl; 
else cout << vec.at(i) << endl;

return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, M; cin >> N >> M;
    ll res = M*1900 + (N-M)*100;
    
    cout << res * pow(2, M) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int sum=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >>a[i];
    sum+=a[i];
  }
  int ans =0;
  for(int i=0;i<n;i++)ans+=(sum-a[i])*a[i];
  ans/=2;
  cout << ans;
}
     

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){
  string s;
  cin>>s;
  for(int i = 0;i<12;i++){
    cout<<s[i];
    if(i == 3)
      cout<<" ";
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	result := true
	count := map[int]int{}
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		if count[tmp] != 0 {
			result = false
			break
		}
		count[tmp]++
	}
	if result {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 13056
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	int h, w;
	cin >> h >> w;
	vector<vector<int>> dp(10, vector<int>(10, INF));
	vector<vector<int>> c(10, vector<int>(10));
	rep(i, 10)
	{
		rep(j, 10)
		{
			cin >> c[i][j];
			dp[i][j] = c[i][j];
		}
	}
	vector<vector<int>> a(h, vector<int>(w));

	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
			}
		}
	}

	ll ans = 0;
	rep(i, h)
	{
		rep(j, w)
		{
			cin >> a[i][j];
			if (a[i][j] >= 0)
				ans += dp[a[i][j]][1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

const int  mod = 1e9 + 7;
const int e = 1e6 + 69;
const int base = 311;

ll a[e];
ll dp[e];

int main()
{
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i=k; i<=n+1; i++)
    {
        ll minn = (i-1)*(i)/2;
        ll maxx = (n - i + 1 + n) * (n - n + i - 1 + 1)/2;
        ans = (ans%mod + maxx - minn+1)%mod;
    }
    cout << ans%mod;

}


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

int main(){
    int N;
    int input[100][3];
    int h_min = 2000000000, h_max = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> input[i][0] >> input[i][1] >> input[i][2];
        h_min = min(h_min, input[i][2] - 200);
        h_max = max(h_max, input[i][2] + 200);
    }
    h_min = max(h_min, 1);

    for(int h = h_min; h <= h_max; h++){
        for(int cx = 0; cx <= 100; cx++){
            for(int cy = 0; cy <= 100; cy++){
                bool ok = true;
                for(int i = 0; i < N; i++){
                    if(input[i][2] != max(0, h - abs(input[i][0]-cx) - abs(input[i][1]-cy))){
                        ok = false;
                        break;
                    }
                }
                if(ok){
                    cout << cx << " " << cy << " " << h << endl;
                }
            }
        }
    }
}
                


Measured memory_bytes: 256
/**
    Problem: Exhausted?
    Source: Atcoder Regular Contest 076, problem F
*/

#include <cstdio>
#include <vector>

using namespace std;

const int N = 2e5 + 2;

int n, m;
vector<int> b[N];

class TTree
{
    #define lc (id * 2 + 1)
    #define rc (id * 2 + 2)
    #define mid (sl + sr) / 2
    int mx[1 << 19], laz[1 << 19];
    void Propagate(int id, int sl, int sr)
    {
        if (laz[id] != 0)
        {
            mx[id] += laz[id];
            if (sl < sr) laz[lc] += laz[id], laz[rc] += laz[id];
            laz[id] = 0;
        }
    }
public:
    void Init(int id, int sl, int sr)
    {
        if (sl < sr)
        {
            Init(lc, sl, mid), Init(rc, mid + 1, sr);
            mx[id] = max(mx[lc], mx[rc]);
        }
        else mx[id] = -(m - sl + 1);
    }
    void Update(int id, int sl, int sr, int ul, int ur, int v)
    {
        Propagate(id, sl, sr);
        if (ur < sl || sr < ul) return;
        if (ul <= sl && sr <= ur)
        {
            mx[id] += v;
            if (sl < sr) laz[lc] += v, laz[rc] += v;
            return;
        }
        Update(lc, sl, mid, ul, ur, v);
        Update(rc, mid + 1, sr, ul, ur, v);
        mx[id] = max(mx[lc], mx[rc]);
    }
    int Query(int id, int sl, int sr, int ql, int qr)
    {
        Propagate(id, sl, sr);
        if (qr < sl || sr < ql) return -N;
        if (ql <= sl && sr <= qr) return mx[id];
        return max(Query(lc, sl, mid, ql, qr), Query(rc, mid + 1, sr, ql, qr));
    }
    #undef lc
    #undef rc
    #undef mid
} tree;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i)
    {
        int l, r; scanf("%d %d", &l, &r);
        b[l].push_back(r);
    }
    tree.Init(0, 1, m + 1);
    int indep = max(n, m);                  // size of maximal independent set
                                            // initially it is equal to the max size of one side
    for (int l = 0; l <= m; ++l)            // we move our left pointer one by one
    {
        for (int v: b[l])
            tree.Update(0, 1, m + 1, 1, v, 1);
        indep = max(indep, m + tree.Query(0, 1, m + 1, l + 1, m + 1) - l);
    }
    int match = n + m - indep;              // size of maximum matching
    printf("%d", n - match);
    return 0;
}


Measured memory_bytes: 12672
#include<iostream>
#include<algorithm>
int n, q, data[300010];
int INF = (1LL << 31) - 1;

void init(int &n_) {
	int n = 1;
	while (n < n_)n *= 2;
	n_ = n;
	for (int i = 0; i < 2 * n - 1; i++)data[i] = INF;
}
void update(int k,int x) {
	k += n - 1;
	data[k] = x;
	while (k > 0) {
		k = (k - 1) / 2;
		data[k] = std::min(data[k * 2 + 1], data[k * 2 + 2]);
	}
}
int find(int a, int b, int k, int l,int r) {
	if (r <= a)return INF;
	if (b <= l)return INF;
	if (a <= l&&r <= b)return data[k];
	int val1 = find(a, b, k * 2 + 1, l, (r + l) / 2);
	int val2 = find(a, b, k * 2 + 2, (r + l) / 2, r);
	return std::min(val1,val2);
}

int main() {
	std::cin >> n >> q;
	init(n);
	for (int i = 0; i < q; i++) {
		int a, b, c;
		std::cin >> a >> b >> c;
		if (a == 0)update(b, c);
		else std::cout << find(b, c + 1, 0, 0, n) << std::endl;
	}
	return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)

const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool check_prime(int n)
{
    if(n<2)
        return false;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

int setbits(int n)
{
    int count=0;
    while(n)
    {
        if(n%2==1)
            count++;
        n>>=1;
    }
    return count;
}

int lcm(int a,int b)
{
    return (a*b)/__gcd(a,b);
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n,k;
    cin>>n>>k;
    vector <int> a(n);
    loop(i,0,n) cin>>a[i];

    while(k--)
    {
        vector <int> b(n);

        for(int i=0;i<n;i++)
        {
            int l=max(0LL,i-a[i]);
            int r=min(n-1,i+a[i]);
            b[l]++;
            if(r+1<n)
                b[r+1]--;
        }

        for(int i=1;i<n;i++)
            b[i]+=b[i-1];
        bool same=1;
        for(int i=0;i<n;i++)
        {
            if(a[i]!=b[i])
            {
                same=0;
            }

            a[i]=b[i];

        }
        if(same)
            break;
    }

    for(int i=0;i<n;i++)
        cout<<a[i]<< " ";


    return 0;
}


Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a; cin >> a;
	cout << 48 - a << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;
typedef pair<ll, ll> P;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> d(3);
    rep(i, 3) cin >> d[i];
    vector<P> q;
    rep(i, n) {
        string s;
        cin >> s;
        int a = 0, b = 1;
        if (s == "AB") a = 0, b = 1;
        if (s == "AC") a = 0, b = 2;
        if (s == "BC") a = 1, b = 2;
        q.emplace_back(a, b);
    }

    string ans;
    auto add = [&](int a, int b) {
        d[a]++;
        d[b]--;
        ans += 'A' + a;
    };
    q.emplace_back(0, 1);
    rep(i, n) {
        int a = q[i].first;
        int b = q[i].second;
        if (!d[a] && !d[b]) {
            cout << "No" << endl;
            return 0;
        }
        if (!d[a]) {
            add(a, b);
        } else if (!d[b]) {
            add(b, a);
        } else {
            int na =  q[i+1].first;
            int nb = q[i+1].second;
            if ( a == na || a == nb) {
                add(a, b);
            } else {
                add(b, a);
            }
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	double N;
	cin >> N;
	double L3 = N / 3.0;
	double ans = L3 * L3 * L3;
	printf("%.12f", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int l[11],v[2];
	int i,n;
	double s=0;
	for(;scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1])!=EOF;s=0){
		for(i=0;i<10;i++)s+=l[i];
		s=s*((double)v[0]/((double)v[0]+(double)v[1]));
		for(n=0,i=0;i<10;i++){
			n+=l[i];
			if(n>=s){printf("%d\n",i+1);break;}
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <cmath>
#include <string>

using namespace std;

int main(void) {
    long long n,m;
    cin >> n >> m;
    long long x[3] = {0},y[3]={0};
    if(n == 1)
        x[0] = 1;
    else {
        x[1] = 2;
        x[2] = n - 2;
    }
    if(m == 1)
        y[0] = 1;
    else {
        y[1] = 2;
        y[2] = m - 2;
    }
    long long ret = 0;
    for(int i = 0;i < 3;i++) {
        for(int ii = 0;ii < 3;ii++) {
            if(i % 2 == 0 && ii % 2 == 0)
                ret = ret + (x[i] * y[ii]);
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int sum = 1;
  for (int i = 0; i < N  - 1; i++) {
    if (vec.at(i) != vec.at(i + 1)) {
      sum ++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
total = 0
for i in range(N + 1):
    I = str(i)
    L = len(I)
    sum = 0
    for j in range(L):
        sum = sum + int(I[j])
    if A <= sum <= B:
        total = total + i
print(total)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 55565;
bool vis[N];
int prime[N];
int sum[60];
void init() {
	vis[1] = vis[0] = 1;
	for(int i = 2; i < N; i ++) {
		if(!vis[i]) {
			for(int j = i+i; j < N; j += i)
				vis[j] = 1;
		}
	}
}
bool isPrime(int x) {
	for(int i = 2; i <= sqrt(x); i ++) {
		if(x%i==0) return 0;
	}
	return 1;
}
int main() {
	init();
	int n;
	cin >> n;
	for(int i = 2; i < N; i ++) {
		if(!vis[i] && i%5 == 1) {
			printf("%d%c",i," \n"[--n==0]);
			if(n == 0) break;
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;


void linSearch(int arrN[], int arrQ[],int n,int q){
    
    int cnt = 0;
    
    for(int i=0; i < q; i++){
        for(int j=0; j < n; j++){
            if(arrQ[i]==arrN[j]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt <<endl;
}

int main(){
    int n, q;
    
    cin >> n;
    int arrN[n];
    for (int i=0; i< n; i++){
        cin >> arrN[i];
    }
    cin >> q;
    int arrQ[q];
    for (int i=0;i<q;i++){
        cin >> arrQ[i];
    }
    
    linSearch(arrN,arrQ,n,q);
    
    return 0;
}




Measured memory_bytes: 3116
#include <stdio.h>

long long cnt[10][10];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a=i;
		while(a/10)a/=10;
		cnt[a][i%10]++;
	}
	
	long long ans=0;
	for(int i=1;i<=9;i++)for(int j=1;j<=9;j++)ans+=cnt[i][j]*cnt[j][i];
	printf("%lld",ans);
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int n;
    cin >> n;
    vector<int> vi(n);
    REP(i, n)
    cin >> vi[i];
    sort(ALL(vi));
    int ans=0;
    REP(i,vi.size())
    FOR(j,i+1,vi.size())
    FOR(k,j+1,vi.size()){
        if(vi[i]==vi[j])
        continue;
        if(vi[k]==vi[j])
        continue;
        if(vi[i]+vi[j]>vi[k])
        ans++;
    }
    cout << ans << endl;

}

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

struct P
{
    int x,y;

    bool operator<(const P &a)const{

        if(y!=a.y) return y>a.y;
        return x>a.x;
    }

};

vector<int> v;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c;

int o[11];
int l[11];
int j[1];
int e;

//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000009,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
//stack<int> s;
//set<int> se;
//priority_queue<int> q;
//queue<int> q;
string r,r1;
//char r[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;


//deque<int> de;
//srand((int)time(NULL));




bool as(P a,P b)
{
    return a.x<b.x;
}

long long f(int a,long long n)
{
    if(a%2)
    {
        return n+1+(long long)a/2*(c-b);
    }
    return n+(long long)a/2*(c-b);
}

int main()
{
    scanf("%d %d %d",&a,&b,&c);
    if(b+1>=c||a<b)
    {
        printf("%d",a+1);
        return 0;
    }
    printf("%lld",f(a-b+1,b));

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << arr[k - 1];
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,k;
        cin>>n>>k;
        vl A(n);
        rep(i,n)cin>>A[i];
        cout<<(n-3+k)/(k-1)<<endl;
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  ll ans = 1001001001;
  for(ll i = 1; i*i <= m; i++){
    if(m % i != 0) continue;
    ll j = m / i;
    if(i >= n){
      ans = min(ans, i);
    }
    if(j >= n){
      ans = min(ans, j);
    }
  }
  if(ans == 1001001001) ans = m;
  ans = m/ans;
  cout << ans << endl;
  return 0;
}

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

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> posnum(n);
	for(int i = 0; i < n; i++)
		cin>>posnum[i];
	vector<bool> dp(k+1, false);
	for(int stone = 1; stone <= k; stone++){
		for(int num = 0; num < n; num++){
			if(stone >= posnum[num] && dp[stone-posnum[num]] == false){
				dp[stone] = true;
				break;
			}
		}
	}
	if(dp[k] == true)
		cout<<"First";
	else
		cout<<"Second";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int N, M;
    scanf("%d %d", &N, &M);

    int H[N]; // 展望台の標高
    int A[M]; // 道の両端の展望台の組み合わせ
    int B[M];

    for(int i=0; i<N; i++){
        scanf("%d", &H[i]);
    }

    for(int i=0; i<M; i++){
        scanf("%d %d", &A[i], &B[i]);
    }
    int count_ans = 0;
    int conut_node[N];
    int count_h[N];

    for(int i=0; i<N; i++){ // 初期化
        count_h[i] = 0;
        conut_node[i] = 0;
    }

    for(int i=0; i<M; i++){
        if(H[A[i]-1]>H[B[i]-1]){
            count_h[A[i]-1]++;
        }else if(H[A[i]-1]<H[B[i]-1]){
            count_h[B[i]-1]++;
        }
        conut_node[A[i]-1]++;
        conut_node[B[i]-1]++;
    }

    for(int i=0; i<N; i++){
        if(count_h[i] == conut_node[i]){
            count_ans++;
        }
    }
     printf("%d\n", count_ans);


    //for(int i=0; i<M; i++){
    //    printf("%d ", H[i]);
    //    printf("%d %d\n", A[i], B[i]);
    //}

   return 0;
}

Measured memory_bytes: 3664