akhauriyash/Code-Regression huggingface dataset:
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

struct BIT {
  vi a;
  vi sg; // セグメント
  int N;
  BIT(int n) {
    N = n;
    a = vi(N+1, 0);
    sg = vi(N+1, 0);
  }

  // a1+a2+...+ai を求める
  int sum(int i) {
    int res = 0;
    while(i>0) {
      res += sg[i];
      i -= i&-i; // 末尾のビット値を減算
    }
    return res;
  }

  int sum(int l, int r) {
    return sum(r) - sum(l-1);
  }

  // ai に x を加える
  void add(int i, int x) {    
    while (i <= N) {
      sg[i] += x;
      i += i & -i; // 末尾のビット値を加算
    }
  }
};

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


  int N; cin>>N;
  string S; cin>>S;
  S = "0" + S;
  vector<BIT> vbit(26, BIT(N));
  FOR(i,1,N+1) {
    vbit[S[i]-'a'].add(i, 1);
  }

  int Q; cin>>Q;  
  REP(i,Q) {
    int Typ; cin>>Typ;
    if (Typ == 1) {
      int I; char C; cin>>I>>C;
      if (S[I] != C) {
        vbit[S[I]-'a'].add(I, -1);
        vbit[C - 'a'].add(I, 1);
        S[I] = C;
      }
    } else { assert(Typ == 2);
      int L,R; cin>>L>>R;
      int ans = 0;
      REP(j,26) {
        if (vbit[j].sum(L,R) > 0) ans++;
      }
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 106544
n = int(input())
a = list(map(int, input().split()))

ch1 = 0
for i in a:
	if(i == 0):
		print(0)
		ch1 = 1
		break

if(not ch1):
	ans = 1
	ch2 = 0
	for i in a:
		ans*=i
		if(ans > int(1e18)):
			print(-1)
			ch2 = 1
			break
	if(not ch2):
		print(ans)



Measured memory_bytes: 21656
import itertools

n = int(input())
l = list(map(int, input().split()))

cnt = 0
for v in itertools.combinations(l, 3):
    t = set(v)
    if len(t) == len(v) and (abs(v[0] - v[1]) < v[2] < v[0] + v[1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 9124
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define Mod 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}

int main()
{
    ll A,B,N;
    cin>>A>>B>>N;
    ll X=min(N,B-1);
    ll u=A*X;
    u/=B;
    ll v=X/B;
    v*=A;
    u-=v;
    cout<<u;

}


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

#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define kholo freopen("input.txt","r",stdin), freopen("output.txt","w",stdout)
ll a[200010];
ll cnt[200010];
int main() {
	ioso;// kholo;
	vector<int> dis;
	map<ll,ll> way;
	map<ll,ll> ans;
	ll n; cin >> n;
	for(int i=0;i<n;i++) {
		cin >> a[i];
		if(cnt[a[i]]<=0) {
			dis.push_back(a[i]);
		}
		cnt[a[i]]++;
	}

	sort(dis.begin(),dis.end());
	ll sum = 0;
	for(int i=0;i<dis.size();i++) {
		ll f = cnt[dis[i]];
		way[dis[i]] = (f*(f-1)/2);
		sum += way[dis[i]];
	}

	for(int i=0;i<dis.size();i++) {

		ans[dis[i]] = ((sum - way[dis[i]]) + (((cnt[dis[i]]-1)*(cnt[dis[i]]-2))/2)); 

	}

	for(int i=0;i<n;i++) {
		cout << ans[a[i]] << endl;
	}

}

Measured memory_bytes: 22392
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;

signed main(){
	cin>>S;
	int N=S.size();
	string t=S;
	reverse(t.begin(),t.end());
	if(S!=t){
		cout<<"No"<<endl;
		return 0;
	}
	string s;
	t="";
	REP(i,(N-1)/2){
		s+=S[i];
	}
	t=s;
	reverse(t.begin(),t.end());
	if(s!=t){
		cout<<"No"<<endl;
		return 0;
	}
	s="";t="";
	for(int i=(N+3)/2-1;i<S.size();i++){
		s+=S[i];
	}
	t=s;
	reverse(t.begin(),t.end());
	if(s!=t){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<math.h>

using namespace std;
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	if (n%m == 0)printf("0");
	else printf("1");
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, T;
	cin >> N >> T;

	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}
	
	vector<vector<int>>DP1(N+2, vector<int>(T+1,-INF));
	vector<vector<int>>DP2(N+2, vector<int>(T + 1, -INF));
	for (int t = 0; t <= T; ++t) {
		DP1[0][t] = 0;
		DP2[N + 1][t] = 0;
	}
	for (int i = 1; i <= N; ++i) {
		for (int t = 0; t < T; ++t) {//注文可能
			if (DP1[i - 1][t] >= 0) {//ある。
				//注文しない
				DP1[i][t] = max(DP1[i][t], DP1[i - 1][t]);

				//注文する
				int TT = t + A[i - 1];
				if (TT > T) {
					TT = T;
				}
				DP1[i][TT] = max(DP1[i][TT], DP1[i - 1][t] + B[i - 1]);
			}
		}
		DP1[i][T] = max(DP1[i][T], DP1[i - 1][T]);
	}

	for (int i = N; i >= 1; --i) {
		for (int t = 0; t < T; ++t) {//注文可能
			if (DP2[i + 1][t] >= 0) {//ある。
				//注文しない
				DP2[i][t] = max(DP2[i][t], DP2[i + 1][t]);

				//注文する
				int TT = t + A[i - 1];
				if (TT > T) {
					TT = T;
				}
				DP2[i][TT] = max(DP2[i][TT], DP2[i + 1][t] + B[i - 1]);
			}
		}
		DP2[i][T] = max(DP2[i][T], DP2[i + 1][T]);
	}
	
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		for (int t = 0; t < T; ++t) {
			//T-1の分配
			if (ans < DP1[i - 1][t] + B[i - 1] + DP2[i + 1][T-1-t]) {
				ans = DP1[i - 1][t] + B[i - 1] + DP2[i + 1][T-1-t];
			}
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 70912
#D問題
import math
H,W,A,B = map(int,input().split())
mod = 10**9 + 7

M = H+W-1
fact = [1 for i in range(M)]
for i in range(M):
    if i == 0:
        pass
    else:
        fact[i] = (fact[i-1]*i)%mod
        
refact = [1 for i in range(M)]
m = mod-2
b = bin(m)
b = b.lstrip("0b")
b = b[::-1]
m2 = len(b)
for i in range(M):    
    flog = [0 for j in range(m2)]
    for j in range(m2):
        if j == 0:
            flog[0] = fact[i]
        else:
            flog[j] = (flog[j-1]**2)%mod
    #print(flog)
    for j in range(m2):
        if b[j] == "1":
            refact[i]*=flog[j]
            refact[i]%=mod
            
row = B
wide = W-B
ans = 0
for i in range(wide):
    row = B+i
    C1 = (fact[H-A+row-1]*refact[H-A-1]*refact[row])%mod
    C2 = (fact[W+A-row-2]*refact[W-row-1]*refact[A-1])%mod
    #print(C1,C2)
    ans+=C1*C2
    ans%=mod

#print(fact)
#print(refact)

print(ans)

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

int main(){
  char S[4];
  int i, j[10000], k=0;
  for(i=0; i<10000; i++){
    j[i] = 0;
  }
  cin >> S;
  for(i=0; i<4; i++){
      j[(int)S[i]]++;
  }
  
  for(i=0; i<10000; i++){
    if (j[i] == 2) k++;
  }
  
  if (k==2){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
  return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;

  vector<int> a;
  vector<int> b;
  vector<int> c;

  for (int n = 1; n <= N; ++n) {
    int A;
    cin >> A;
    a.push_back(A);
  }

  for (int n = 1; n <= N; ++n) {
    int B;
    cin >> B;
    b.push_back(B);
  }

  for (int n = 1; n < N; ++n) {
    int C;
    cin >> C;
    c.push_back(C);
  }

  int64_t result = 0;
  int prev = -1;
  for (int i : a) {
    result += b[i - 1];
    if (i == prev + 1) {
      result += c[prev - 1];
    }
    prev = i;
  }

  cout << result << endl;
}


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

int main() {
	int a[5];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]) {
		int b[4] = {};
		for (int i = 0; i < 5; i++) {
			if (a[i] == 1)b[1] = 1;
			else if (a[i] == 2)b[2] = 1;
			else if (a[i] == 3)b[3] = 1;
		}

		int f = b[1] + b[2] + b[3];
		if (f == 2)
			if (!b[1])
				for (int i = 0; i < 5; i++)
					a[i] = (a[i] == 2) ? 1 : 2;
			else if (!b[2])
				for (int i = 0; i < 5; i++)
					a[i] = (a[i] == 3) ? 1 : 2;
			else
				for (int i = 0; i < 5; i++)
					a[i] = (a[i] == 1) ? 1 : 2;
		else
			for (int i = 0; i < 5; i++)
				a[i] = 3;

		for (int i = 0; i < 5; i++)
			cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
  var x = chunk.split(" ");
  x1 = parseFloat(x[0]);
  y1 = parseFloat(x[1]);
  x2 = parseFloat(x[2]);
  y2 = parseFloat(x[3]);

  console.log(Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2)));
});

Measured memory_bytes: 15900
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
int queue[MAX];
int head,tail;
void intialize();
void push(int i);
int pop();
int isempty();
int isfull();
typedef struct {
  char name[10];
  int time;
} Process;

void intialize(){
  head=0;
  tail=0;
}
void push(int i){
  if(isfull()){
    printf("overflow\n");
    exit(1);
  }
  queue[tail]=i;
  if(tail+1==MAX)tail=0;
  else tail++;
}
int pop(){
  if(isempty()){
  printf("underflow\n");
  exit(1);
  }
  int x;
  x=queue[head];
  if(head+1==MAX)head=0;
  else head++;
  return x;

}
int isempty(){
  return head==tail;
}
int isfull(){
  return head==(tail+1)%MAX;
}
int main(){
  int n,q;
  int i;
  long int  sum_time=0;
  int now;
 Process process[MAX];
  intialize();
  scanf("%d %d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s %d",process[i].name,&process[i].time);
    push(i);
  }

  while(!isempty()){
    /* printf("queue ");
    for(i=head;i<tail;i++) printf("%d ",queue[i]);
    printf("\n");
    */
    now=pop();
    if(process[now].time<=q) {
      sum_time+=process[now].time;
      printf("%s %ld\n",process[now].name,sum_time);
    }
    else {
      process[now].time-=q;
      sum_time+=q;
      push(now);
    }
  }
  return 0;
}

Measured memory_bytes: 1776
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static List<int> dic = new List<int>();
        static void Main(string[] args)
        {
            var K = long.Parse(Console.ReadLine());
            var que = new Queue<long>();

            for (int i = 1; i <= 9; i++)
            {
                que.Enqueue(i);
            }

            long deq = 0L;
            for (int i = 0; i < K; i++)
            {
                deq = que.Dequeue();
                if(deq%10 != 0)
                {
                    que.Enqueue(deq * 10 + (deq % 10) - 1);
                }

                que.Enqueue(deq * 10 + (deq % 10));

                if ((deq % 10) != 9)
                {
                    que.Enqueue(deq * 10 + (deq % 10) + 1);
                }
            }

            Console.WriteLine(deq);

        }
    }

}


Measured memory_bytes: 31500
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int main()
{
	int n, q;
	int s[100000];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}

	cin >> q;
	int cnt = 0;
	for (int i = 0; i < q; i++)
	{
		int t;
		cin >> t;

		int left = 0;
		int right = n - 1;
		while (true)
		{
			if (t < s[left] || t > s[right])
			{
				break;
			}
			else if (right - left == 1)
			{
				if (t == s[left] || t == s[right])
				{
					cnt++;
					break;
				}
				else
				{
					break;
				}
			}
			else
			{
				if (t == s[(left + right) / 2])
				{
					cnt++;
					break;
				}
				else if (t < s[(left + right) / 2])
				{
					right = (left + right) / 2;
				}
				else if (t > s[(left + right) / 2])
				{
					left = (left + right) / 2;
				}
			}
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1548
#include"bits/stdc++.h"
using namespace std;

typedef pair<int, int> P;

void Main() {
  int N;
  cin >> N;
  vector<P> A(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[i] = P(a, i + 1);
  }

  sort(A.rbegin(), A.rend());

  long long ans = 0;
  long long dp[N + 1][N + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 0;
  for (int xy = 1; xy <= N; xy++) {
    for (int x = xy; x >= 0; x--) {
      int y = xy - x;
      int act = A[xy - 1].first;
      int ini_pos = A[xy - 1].second;
      long long xxx = 0, yyy = 0;
      if (x > 0) xxx = dp[y][x - 1] + (long long)act * abs(ini_pos - x);
      if (y > 0) yyy = dp[y - 1][x] + (long long)act * abs(N - y + 1 - ini_pos);
      dp[y][x] = max(xxx, yyy);
      if (xy == N) ans = max(ans, dp[y][x]);
    }
  }

  cout << ans << endl;
}

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

Measured memory_bytes: 34952
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        int[][] lr = new int[n][n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            lr[a][b]++;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 1; j < n; j++) {
                lr[i][j] += lr[i][j-1];
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int q1 = sc.nextInt()-1;
            int q2 = sc.nextInt()-1;
            int tmp =0;
            for (int j = q1; j <= q2; j++) {
                tmp += lr[j][q2];
            }
            sb.append(tmp + "\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

}


Measured memory_bytes: 153432
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let a = read_vec::<usize>();
    let mut a_dict = HashMap::new();
    for num in a {
        *a_dict.entry(num).or_insert(0) += 1;;
    }
    let mut vs = a_dict.values().cloned().collect::<Vec<_>>();
    vs.sort();
    let mut ans = 0;
    if vs.len() <= k {
        println!("{}", ans);
        return;
    }
    for i in 0..vs.len() - k {
        ans += vs[i];
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 17872
#include <iostream>
#include <string>
#include <vector>

template <typename T>
void print_vector(std::vector<T> v) {
    for (size_t i = 0, len = v.size(); i < len; i++) {
        std::cout << v[i];
        if (i != len - 1) {
            std::cout << ' ';
        }
    }
    std::cout << std::endl;
}

int main() {
    int n;
    std::string buf;

    std::cin >> n;
    std::vector<int> v;
    v.reserve(n);

    while (std::cin >> buf) {
        v.push_back(std::stoi(buf));
    }

    print_vector(v);
    for (size_t i = 1; i < n; i++) {
        int a = v[i];
        int j = i - 1;
        while (j >= 0 && v[j] > a) {
            v[j + 1] = v[j];
            j--;
        }
        v[j + 1] = a;
        print_vector(v);
    }
}



Measured memory_bytes: 3176
// Jump, and you will find out how to unfold your wings as you fall.

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=5010,mod=1e9+7;
const ll inf=1e18;

int dp1[maxn][maxn],dp2[maxn][maxn],a[maxn];
ll ans[maxn];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,A,B;cin>>n>>A>>B;
    for(int i=1;i<=n;i++){
	cin>>a[i];
    }
    a[n+1]=n+1;
    for(int i=0;i<=n+1;i++){
	for(int j=i+1;j<=n+1;j++){
	    dp1[i][j]=dp1[i][j-1]+(a[i]>a[j]);
	}
    }
    for(int j=n+1;j>=0;j--){
	for(int i=j-1;i>=0;i--){
	    dp2[i][j]=dp2[i+1][j]+(a[i]>a[j]);
	}
    }
    for(int r=1;r<=n+1;r++){
	ans[r]=inf;
	for(int l=0;l<r;l++){
	    if(a[l]>a[r] || dp1[l][r-1]+dp2[l+1][r]!=r-l-1) continue;
	    ans[r]=min(ans[r],ans[l]+1ll*A*dp2[l+1][r]+1ll*B*dp1[l][r-1]);
	}
    }
    return cout<<ans[n+1]<<endl,0;
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 195072
#include <bits/stdc++.h>
using namespace std;
int n, a[109];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	int ret = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < i; j++) {
			if(a[j] > a[i]) ret++;
		}
	}
	sort(a, a + n);
	for(int i = 0; i < n; i++) {
		if(i) cout << ' ';
		cout << a[i];
	}
	cout << endl;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int M,N;
int T[21][50010];
int coin[21];
int main()
{
    cin>>N>>M;
    for(int m=0;m<M;m++)
        cin>>coin[m];
    for(int m=1;m<=M;m++)
        for(int n=0;n<=N;n++)
        {
            if(m==1)
                T[m][n]=n;
            else if(m!=1&&coin[m-1]<n)
                T[m][n]=min(T[m-1][n],T[m][n-coin[m-1]]+1);
            else if(m!=1&&coin[m-1]>n)
                T[m][n]=T[m-1][n];
            else if(m!=1&&coin[m-1]==n)
                T[m][n]=1;
        }
        cout<<T[M][N]<<endl;
        return 0;
}


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

int main(){
	int D;
	cin>>D;
	if(D==25){
		cout<<"Christmas";
	}	else if(D==24){
		cout<<"Christmas Eve";
	}	else if(D==23){
		cout<<"Christmas Eve Eve";
	}	else{
		cout<<"Christmas Eve Eve Eve";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<int>v(N);
  long long K=0;
  for(int X=0;X<N;X++){
    cin>>v[X];
    K+=v[X];
  }
  int M;cin>>M;
  vector<int>P(M);
  vector<int>Q(M);
  vector<int>R(M);
  for(int X=0;X<M;X++){
    cin>>P[X]>>Q[X];
    cout<<K+(Q[X]-v[P[X]-1])<<endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define uns unsigned
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    vpii a(n);
    cin >> a;
    vvi v(m + 1, vi());
    for (int i = 0; i < n; i++)
        if (a[i].fi <= m)
            v[a[i].fi].push_back(a[i].se);
    pq<int> q;
    int res = 0;
    for (int i = m - 1; i >= 0; i--)
    {
        for (int j : v[m - i])
            q.push(j);
        if (sz(q))
            res += q.top(), q.pop();
    }
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 7168
from collections import deque
H,W=map(int,input().split())
S=["*"*(W+2) for _ in range(H+2)]
for i in range(1,H+1):
    S[i]="*"+input()+"*"

K=0
T=[[0]*(W+2) for _ in range(H+2)]
Neighborhood=[(0,1),(0,-1),(1,0),(-1,0)]
p=0

for y in range(1,H+1):
    for x in range(1,W+1):
        if T[y][x]==0:
            p+=1

            if S[y][x]=="#":
                Black,White=1,0
            elif S[y][x]==".":
                Black,White=0,1

            Q=deque([(x,y)])
            T[y][x]=p

            while Q:
                (u,v)=Q.popleft()
                for (a,b) in Neighborhood:
                    if S[v][u]=="#" and S[v+b][u+a]=="." and T[v+b][u+a]==0:
                        Q.append((u+a,v+b))
                        White+=1
                        T[v+b][u+a]=p
                    elif S[v][u]=="." and S[v+b][u+a]=="#" and T[v+b][u+a]==0:
                        Q.append((u+a,v+b))
                        Black+=1
                        T[v+b][u+a]=p

            K+=Black*White
print(K)

Measured memory_bytes: 77920
// In the Name of God
#include<bits/stdc++.h>

#define test(t) int t; cin>>t; while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long int
#define em emplace_back
#define pb push_back
#define INF 1e7+5
#define MOD int(1e9+7)
#define print printf
#define in scanf
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

template<class type>
void displaySingle(type &arr)
{
	for(auto i:arr)
		cout<<i<<" ";
	cout<<endl;
}

template<class type>
void displayDouble(type &arr)
{
	for(auto &&i : arr) 
	{
		for(auto &&j : i) 
			cout << j << " ";
		cout << std::endl;
	}
}

int main()
{
	fast
	string s,t;
	cin>>s;
	cin>>t;
	int m,n;
	m = s.size();
	n = t.size();
	vector <vector <int>> dp(m+1,vector <int>(n+1));
	FOR(i,1,m+1)
	{
		FOR(j,1,n+1)
		{
			if(s[i-1] == t[j-1])
				dp[i][j] = dp[i-1][j-1]+1;
			else
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string ans = "";
	int i = m,j = n;
	while(i > 0 && j > 0)
	{
		if(s[i-1] == t[j-1])
		{
			ans = s[i-1]+ans;
			i--;
			j--;
		}
		else if(dp[i][j] == dp[i-1][j])
			i--;
		else if(dp[i][j] == dp[i][j-1])
			j--;
	}
	cout<<ans<<endl;
	//cout<<dp[m][n]<<endl;
}

Measured memory_bytes: 38912
// https://atcoder.jp/contests/abc149/tasks/abc149_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

const int SZ = 1e5 + 10;

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int N> struct Prime {
    bool b[N + 1]; // trueなら素数
    constexpr Prime() : b() {
        for (int_fast64_t i = 0; i <= N; ++i)
            b[i] = true;
        b[0] = b[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            for (int_fast64_t j = i * i; j <= N; j += i)
                b[j] = false;
        }
    }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    constexpr auto prime = Prime<SZ>();
    while (true) {
        if (prime.b[X]) {
            cout << X << endl;
            break;
        }
        X++;
    }
    return 0;
}


Measured memory_bytes: 3764
n, k = map(int, input().split())
ans = 0
for a in range(1, n + 1):
    if (a % k == 0):
        ans += (n // k) ** 2
    else:
        q = a % k
        if (2 * q % k != 0):
            continue
        ans += ((n + q) // k) ** 2

print(ans)


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a > c || a+b < c){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,x,a[50][50],c[50],ans[4097],sum[50],cost,cnt;
void dfs(int cur)
{
	if(cur>n)
	{
		bool bad=0;
		for(int i=1;i<=m;i++)
			if(sum[i]<x)
			{
				bad=1;
				break;
			}
		if(bad==0)
			ans[++cnt]=cost;
		return;
	}
	dfs(cur+1);
	for(int i=1;i<=m;i++)
		sum[i]+=a[cur][i];
	cost+=c[cur];
	dfs(cur+1);
	for(int i=1;i<=m;i++)
		sum[i]-=a[cur][i];
	cost-=c[cur];
	return;
}
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	}
	dfs(1);
	sort(ans+1,ans+cnt+1);
	if(ans[1]==0)
		cout<<-1;
	else
		cout<<ans[1];
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

typedef pair<int, int> pii;
typedef long long LL;
typedef vector<int> VI;

inline int read(){
	int x = 0, ch = getchar(), f = 1;
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

int n;
int a[300005];
int main(){
	n = read();
	REP(i, 1, 3 * n) a[i] = read();
	sort(a + 1, a + 3 * n + 1);
	LL ans = 0;
	for (int i = 3 * n, j = 1; i >= j; i -= 2, ++j){
		// cerr << a[i - 1] << endl;
		ans += a[i - 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main ()
{
	int num,figure[1001][3],t,i,j,n;
	scanf("%d",&num);
	for(i=1;i<=num;i++)
	{
		for(j=0;j<3;j++)
		    scanf("%d",&figure[i][j]);     
	}	
	for(i=1;i<=num;i++)
	{
		for(n=0;n<2;n++)
		for(j=0;j<2-n;j++) 
		{
			if(figure[i][j]<figure[i][j+1])
			{
				t=figure[i][j];
			    figure[i][j]=figure[i][j+1];
			    figure[i][j+1]=t;
			}		
		}
		figure[i][0]*=figure[i][0];
		figure[i][1]*=figure[i][1];
		figure[i][2]*=figure[i][2];
		if(figure[i][0]==figure[i][1]+figure[i][2])
		    printf("YES\n");
		else    
	        printf("NO\n");
	}
	return 0;	
} 

Measured memory_bytes: 588
#ifndef ___Class_BIT
#define ___Class_BIT
#include <cstdlib>
#include <iostream>
template <class Type>
class BIT {
private:
	size_t size_; Type *v;
	inline Type sum(size_t r) { Type ret = 0; while (r > 0) ret += v[r], r -= r & -r; return ret; }
public:
	BIT() {};
	BIT(size_t size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v = (Type *)malloc(sizeof(Type) * (size_ + 1));
		for (size_t i = 0; i <= size_; i++) v[i] = 0;
	}
	inline void add(size_t i, Type x) { i++; while (i <= size_) v[i] += x, i += i & -i; }
	inline Type sum(size_t l, size_t r) { return sum(r) - sum(l); }
	bool operator[](size_t x) { return sum(x, x + 1); }
};
#endif

#include <cstdio>
#pragma warning(disable : 4996)
int n, q, c, x, y;
int main() {
	scanf("%d%d", &n, &q);
	BIT<int> b(n);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d", &c, &x, &y);
		if (!c) b.add(x - 1, y);
		else printf("%d\n", b.sum(x - 1, y));
	}
	return 0;
}

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

int main(){
  int N, manzoku;
  cin >> N;
  vector<int> A(60,0);
  vector<int> B(60,0);
  vector<int> C(60,0);
  for(int i=1; i<=N; i++){ cin >> A.at(i); }
  for(int i=1; i<=N; i++){ cin >> B.at(i); }
  for(int i=1; i<N; i++){ cin >> C.at(i); }
  
  manzoku = accumulate(B.begin(),B.end(),0);
  for(int i=1; i<=N; i++){
    if(A.at(i)+1 == A.at(i+1)){
      manzoku += C.at(A.at(i));
    }
  }
  cout << manzoku << endl;

  return 0;  
}
 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void printerror() {
    cout << "-1 -1 -1" << endl;
}

int main() {
    int N, Y;

    cin >> N >> Y;

    if(N * 1000 > Y || N * 10000 < Y) {
        printerror();
        return 0;
    }


    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= (N-i); j++) {
            if(j * 1000 + (N-i-j) * 5000 + i * 10000 == Y) {
                cout << i << " " << (N-i-j) << " " << j << endl;
                return 0;
            }
        }
    }

    printerror();
    return 0;

}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $s);
fscanf(STDIN, "%d %d", $a, $b);
 
for($i=$a; $i <= $b; $i++){
    if($i % $s === 0){
        $sum = "OK";
    }
}

if($sum == "OK"){
    $result ="OK";
}else{
    $result ="NG";
}

echo $result;


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

int main() {
  int N;
  cin >> N;
  set<string> S;
  for(int i = 0; i < N; i++){
    string  ST;
    cin >> ST;
    S.insert(ST);
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 19116
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e6;
vector<int> G[maxn];
int N,M, colr[maxn];

void dfs(const int u, const int c)
{
    colr[u] = c;
    FOR_ALL(v,G[u]) if (!colr[*v])
        dfs(*v,c);
}

int main()
{
    while (cin >> N >> M) {
        FOR(i,0,maxn) {
            G[i].clear();
            colr[i] = 0;
        }
        FOR(i,1,N+1) {
            int a; cin >> a;
            const int u = i;
            const int v = a+N;
            G[u].push_back(v);
            G[v].push_back(u);            
        }
        FOR(_,0,M) {
            int u,v; cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        FOR(u,1,N+1) if (!colr[u])
            dfs(u,u);
        int ans = 0;
        FOR(i,1,N+1) if (colr[i] == colr[i+N])
            ans++;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 35840
use std::cmp::{max, min};

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i64 = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut l: i64 = read(&mut stdin_lock, &mut buf, b' ');
    let mut r: i64 = read(&mut stdin_lock, &mut buf, b'\n');
    for _ in 1..m {
        l = max(l, read(&mut stdin_lock, &mut buf, b' '));
        r = min(r, read(&mut stdin_lock, &mut buf, b'\n'));
    }

    let ans = max(0, min(r, n) - l + 1);
    println!("{}", ans);
}


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

int main()
{
	long long int n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0)
	{
		cout << (b - a) / 2 << endl;
	}
	else
	{
		cout << (b - a - 1) / 2 + min(a, n - b + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <vector>
#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s=="abc"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

//問題数，コンプリートボーナス
long long score[10][2];

//2^depth
int D; 
long long G;

long long ans = 1000000000;

void printBits(vector <int> &bits){
    for(int i = 0; i < bits.size(); i++){
        cout << bits[i];
    }
    cout << endl;
}


int lastIndex(vector<int> bits){
    for(int i = D-1; i >= 0; i--){
        if(bits[i] == 0) return i;
    }
    return -1;
}

int calc(vector<int> bits){

    long long sum = 0;
    long long num = 0;
    for(int i = 0; i < D; i++){
        if(bits[i]){
            sum += score[i][0] * 100 * (i + 1);
            sum += score[i][1];
            num += score[i][0];
        }
    }

    if(sum >= G){
        if(num < ans){
            ans = num;
        }
    }
    else{
        int ind = lastIndex(bits);
        for(int i = 0; i < score[ind][0]-1; i++){
            sum += (ind + 1) * 100;
            num += 1;
            if(sum >= G){
                if(num < ans) ans = num;
            }
        }
    }

    /*
    printBits(bits);
    cout << sum <<  endl;
    */
   
    return 0;


}


// n進数 bit 列加算
int search(vector<int> bits, int depth){

    if(depth == D){
        //printBits(bits);
        calc(bits);
        return 0;
    }

    vector<int>bits1 = bits;
    vector<int>bits2 = bits;

    bits1[depth] = 1;
    bits2[depth] = 0;

    search(bits1, depth + 1);
    search(bits2, depth + 1);

}

int main(){
    
    cin >> D;
    cin >> G;

    for(int i = 0; i < D; i++){
        cin >> score[i][0];
        cin >> score[i][1];
    }

    vector<int> v(D);
    search(v, 0);
    cout << ans << endl;

}



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

using namespace std;

int main(void) {

	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	if (a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,b;
	cin >> a >> b;
	cout << a * (a - 1) / 2 + b * (b - 1) / 2 << endl;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())

coins = [(9 ** i) for i in range(1, 7)] + [(6 ** i) for i in range(1, 8)] + [1]
dp = [INF] * (N + 1)
dp[0] = 0
for i in range(len(coins)):
    for j in range(N + 1):
        if j + coins[i] > N:
            continue
        dp[j + coins[i]] = min(dp[j + coins[i]], dp[j] + 1)
print(dp[N])


Measured memory_bytes: 10008
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int A,B,m;
    cin >> A >> B >> m;

    vector<int> a(A),b(B);

    rep(i,A){
        cin >> a[i];
    }
    rep(i,B){
        cin >> b[i];
    }

    int minv = INF;
    rep(i,m){
        int x,y,c;
        cin >> x >> y >> c;
        --x,--y;

        chmin(minv,a[x] + b[y] - c);
    }

    sort(all(a));
    sort(all(b));

    cout << min(minv,a[0] + b[0]) << '\n';

    return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    ll n;
    cin >> n;

    for (ll i = n; ; i--) {
        if (i*i <= n) {
            cout << i*i << endl;
            return 0;
        }
    }

    return 0;
}

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

signed main(){
  lint N; cin >> N;
  vector<lint> a(N), b(N), c(N);
  lint ans = 0;
  for(lint i = 0; i < N; i++){
    cin >> a[i] >> b[i];
    c[i] = a[i] + b[i];
    ans -= b[i];
  }
  sort(c.begin(), c.end()); reverse(c.begin(), c.end());
  for(lint i = 0; i < N; i += 2) ans += c[i];
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#define maju 1919114514
using namespace std;

typedef struct abb {
	long long int a;
	long long int b;

	bool operator <(const abb& another) const {
		return b < another.b;
	}
};
int gcd(int a, int b) {
	int c = a % b;
	if (c == 0)return b;
	else return gcd(b, c);
}
int main() {
	int n;
	int i;
	bool yj = false;
	long long int sum = 0;
	cin >> n;
	vector<abb> co(n);
	for (i = 0; i < n; i++)cin >> co[i].a >> co[i].b;
	sort(co.begin(),co.end());
	//for (i = 0; i < n; i++)cout << co[i].a << " " << co[i].b << endl;
	for (i = 0; i < n; i++) {
		sum += co[i].a;
		if (sum > co[i].b)yj = true;
	}
	if (yj)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

int main(void) {

	int number[4];
	int a=0, b=0;
	scanf("%1d%1d%1d%1d",&number[0], &number[1], &number[2], &number[3]);
	if ((number[2] * 10 + number[3] < 13) && (number[2] * 10 + number[3] > 0))
		a = 1;
	if ((number[0] * 10 + number[1] < 13) && (number[0] * 10 + number[1] > 0))
		b = 1;
	if ((a==1)&&(b==0))
		printf("YYMM");
	if ((a == 0) && (b == 1))
		printf("MMYY");
	if ((a == 1) && (b == 1))
		printf("AMBIGUOUS");
	if ((a ==0 ) && (b == 0))
		printf("NA");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,q;
	ll k;
	cin>>n>>k>>q;
	int a;
	ll score[n],count[n];
	for(int i=1;i<=n;i++){
	
		score[i]=k;
		count[i]=0;
	}
	for(int i=1;i<=q;i++)
	{
		cin>>a;
		count[a]++;
	}
	for(int i=1;i<=n;i++)
	{
		score[i]=score[i]-(q-count[i]);
//		cout<<score[i]<<" "<<count[i]<<endl;
		if(score[i]<=0)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
using namespace std;
int main() {
	long long n, a, b, n1;
	int mod1 = 1000000005, mod2 = 1000000005;
	long long ans = 1, ans1 = 1, ans2 = 1;
	long long x = 2;
	cin >> n >> a >> b;
	n1 = n;
	long long a1 = 1, a2 = 1;
	long long b1 = 1, b2 = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % 1000000007;
		}
		x = x * x % 1000000007;
		n >>= 1;
	}
	ans = ans - 1;
	for (int i = 0; i < a; i++) {
		a1 = a1 * (n1 - i) % 1000000007;
		a2 = a2 * (a - i) % 1000000007;
	}
	while (mod1 > 0) {
		if ((mod1 & 1) == 1) {
			ans1 = ans1 * a2 % 1000000007;
		}
		a2 = a2 * a2 % 1000000007;
		mod1 >>= 1;
	}
	for (int j = 0; j < b; j++) {
		b1 = b1 * (n1 - j) % 1000000007;
		b2 = b2 * (b - j) % 1000000007;
	}
	while (mod2 > 0) {
		if ((mod2 & 1) == 1) {
			ans2 = ans2 * b2 % 1000000007;
		}
		b2 = b2 * b2 % 1000000007;
		mod2 >>= 1;
	}
	ans1 = ans1 * a1 % 1000000007;
	ans2 = ans2 * b1 % 1000000007;
	for (;;) {
		if (ans - ans1 - ans2 < 0) {
			ans += 1000000007;
		}
		else {
			break;
		}
	}
	cout << (ans - ans1 - ans2) % 1000000007 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool ispalin(string inp){
    bool ans =true;
    int x = inp.size();
    if (x%2==0){
        for(auto i =0; i< x/2; ++i){
            if(inp[i]!=inp[x-1-i]){
                ans=false;
            }
        }
    }
    else{
        for(auto i =0; i< (x-1)/2; ++i){
            if(inp[i]!=inp[x-1-i]){
                ans=false;
            }
        }
    }
    return ans;
}
int main(){
    string inp, inp1 = "", inp2 = "";
    cin >>inp;
    int x =inp.size();
    for(int i =0; i< (x-1)/2; ++i){
        inp1 += inp[i];
    }
    for(int i =(x+3)/2-1; i< x; ++i){
        inp2 += inp[i];
    }
    if(ispalin(inp)&&ispalin(inp1)&&ispalin(inp2)){
        cout << "Yes";
    }
    else{
        cout <<"No";
    }
}

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

using namespace std;

#define PB push_back
#define MP make_pair
#define X first
#define Y second

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)
#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for(typeof((c).begin())v=(c).begin();v!=(c).end();++v)
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

clock_t start;
void Time(bool timeIt) {
	if (!timeIt) return;
	clock_t end = clock();
	double elapsed_time = ((db)end - (db)start) / (db)CLOCKS_PER_SEC;
	printf("Time elapsed = %0.4lf\n", elapsed_time); 
}

#define LINF (long long)1e18
#define EPS 1e-9
#define INF 1000000007ll
#define SIZE 300010
#define MAX_A 1000010

int LIS(vi vec, int n) {
	set<int> s;
	for (int i = 1 ; i <= n ; ++i) {
		set<int>::iterator it = s.lower_bound(vec[i]);
		if (it != s.end()) s.erase(it);
		s.insert(vec[i]);
	}
	return s.size();
}

int LDS(vi vec, int n) {
	for (int i = 1 ; i <= n ; ++i) vec[i] = -vec[i];
	set<int> s;
	for (int i = 1 ; i <= n ; ++i) {
		set<int>::iterator it = s.lower_bound(vec[i]);
		if (it != s.end()) s.erase(it);
		s.insert(vec[i]);
	}
	return s.size();
}

vi soln(int n, int a, int b) {
	int mn = min(a, b);
	if (a + b > n + 1 || 1ll * a * b < 1ll * n) {
		return vi(); 
	}

	vi ans(n + 2);
	int curr = 1, rem = n, num = 1, A = a, B = b;

	while (rem > 0) {
		if (a + b > rem && a <= rem) {
			int m = num + rem - a;
			for (int i = 0 ; i < a ; ++i) {
				ans[curr++] = m++; 
			}
			for (int i = 1 ; i <= rem - a ; ++i) {
				ans[curr++] = num + rem - a - i;
			}
			break;
		}
		
		for (int i = 1 ; i <= b ; ++i) {
			ans[curr++] = num + b - i;
		}
		--a;
		num = num + b;
		rem -= b;
	}

	return ans;
}

int main() {
	start = clock();

	int n, a, b;
	cin >> n >> a >> b;

	vi ans = soln(n, a, b);
	if (ans.empty()) cout << -1 << endl;
	else {
		for (int i = 1 ; i <= n ; ++i) cout << ans[i] << " "; 
		cout << endl;
	}

	Time(false);
	return 0;
}


Measured memory_bytes: 3328
w = input()
t = ""

while True:
    it = input()
    if it == "END_OF_TEXT":
        break
    it = it + " "
    t += it
t = str.lower(t)
t = t.split()

ans = 0

for i in t:
    if i == w:
        ans += 1

print(ans)


Measured memory_bytes: 5552