akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
#include <ctype.h> // isdigit
#include <cassert>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(u) begin(u),end(u)
#define PB push_back
#define LE(n,m) ((n) < (m) + EPS * (abs(n) + abs(m)))
#define GE(n,m) ((n) + EPS * (abs(n) + abs(m)) > (m))
#define LT(n,m) ((n) + EPS * (abs(n) + abs(m)) < (m))
#define GT(n,m) ((n) > (m) + EPS * (abs(n) + abs(m)))
#define EQ(n,m) (abs((n)-(m)) < EPS * (abs(n) + abs(m)))

typedef long long int ll;
const int INF = (1<<30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;

typedef complex<double> P;

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    int N, W, D;
    cin >> N >> W >> D;
    int L = 2 * (W + D);
    P p1 = P(W, 0);
    P p2 = P(W, D);
    P p3 = P(0, D);
    P C = P(0, -1);
    
    //end, start
    vector<pair<int, int>> lines;
    
    for(int i=0; i<N; i++){
        int x, y; string f;
        cin >> x >> y >> f;
        P p = P(x, y);
        
        switch (f[0]) {
            case 'W':
                p = (p - p3) * C + p3;
            case 'N':
                p = (p - p2) * C + p2;
            case 'E':
                p = (p - p1) * C + p1;
            default:
                break;
        }
        lines.emplace_back(p.real()+p.imag(), p.real()-p.imag());
    }
    sort(lines.begin(), lines.end());
    
    int ans = INF;
    for(int s=0; s<N; s++){
        int tans = 0;
        int p = lines[0].first;
        int i = 0;
        while(i<N){
            while(i<N && lines[i].second <= p) i++;
            p = lines[i].first;
            tans++;
        }
        ans = min(ans, tans);
        
        lines[0].first += L;
        lines[0].second += L;
        sort(lines.begin(), lines.end());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
using namespace std;
int b[999999], n, c[999999];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d",&c[i]);
	}
	b[1] = 0;
	for (int i = 2; i <= n; i++) {
		b[i] = b[i / 2] + b[(i + 1) / 2] + i;
	}
	sort(c, c + n);
	for (int i = 0; i < n; i++) {
		printf("%d",c[i]);
		if (i < n - 1) {
			printf(" ");
		}
		else { printf("\n"); }
	}
	cout << b[n] << endl;
	return 0;
}

Measured memory_bytes: 7188
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    long long a, b, c;
    cin >> a >> b >> c;

    if(a%2 == 0 || b%2 == 0 || c%2 == 0){
        cout << 0 << endl;
        return 0;
    }

    cout << min(a*c, min(a*b, b*c)) << endl;
    return 0;
}


Measured memory_bytes: 504
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
res = 0
a = [str(i) for i in range(10)]
for num in itertools.product(a, repeat=3):
    p = 0
    for i,j in enumerate(s):
        if j == num[p]:
            p += 1
            if p == 3:
                break
    if p == 3:
        res += 1
print(res)

Measured memory_bytes: 69244
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;

//* Author :- Amey :P *//
void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}
 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}






int main(){

//   #ifndef ONLINE_JUDGE
//      freopen("input.txt", "r", stdin);
//   #endif
   ll n;
   cin>>n;
   ll a[n];
   ll sum = 0 ;
   for(int i = 0; i < n;i++){
        cin>>a[i];
        sum += a[i];
   }
   //cout<<sum<<endl;
   sum /= n;
  ll ans = 0 ,ans1 = 0 ;
 ll sum1 = sum+1;
  for(int i = 0; i < n;i++)
  {
      ans += abs(sum-a[i])*abs(sum-a[i]);
      ans1 += abs(sum1-a[i])*abs(sum1-a[i]);
  }
  cout<<min(ans,ans1)<<endl;


}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_PRIME = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

typedef complex<double> P;
const double precision = 1e-10;

bool EQ(double d, double e)
{
  return abs(d - e) < precision;
}

double cross(P a, P b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

bool parallel(P a, P b)
{
  return EQ(cross(a, b), 0.0);
}

int main(int argc, char **argv)
{
  vector<P> v(4);
  double x, y;
  int n;
  cin >> n;
  while (n--) {
    rep (i, 4) {
      cin >> x >> y;
      v[i] = P(x, y);
    }
    P p = v[1] - v[0];
    P q = v[3] - v[2];
    if (parallel(v[1] - v[0], v[3] - v[2]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 1232
while 1:
    try:
        w = int(input())
    except:
        break

    fun = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
    anslist = []
    for f in reversed(fun):
        if w - f >= 0:
            anslist.append(f)
            w -= f
    print(' '.join(str(ans) for ans in reversed(anslist)))



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  REP(i,1,10){
    int m = i*111;
    if(m>=n){
      cout<<m;
      return 0;
    }
  }

  return 0;
}


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

int main()
{
	ll A,B,C,D;
	string ans="Yes";
	cin>>A>>B>>C>>D;
	for(int i=0;A>0&&C>0;i++){
		if(i%2==0){
			C=C-B;
		}else{
			A=A-D;
		}
	}
	if(C>0){
		ans="No";
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3628
//#pragma GCC diagnostic error "-std=c++11"
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int n,a,b;
int ans[N];
int main(){
    cin>>n>>a>>b;
    rep(i,1,n){
        rep(j,i+1,n){
            int k=INF;
            if(j<=a)k=j-i;
            else k=min(k,min(j-i,abs(a-i)+abs(b-j)+1));
            ans[k]++;
        }
    }
    rep(i,1,n-1){
        cout<<ans[i]<<endl;
    }
	return 0;
}


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

int main(void) {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);

	int total = 0;
	for (int i = 1; i <= n; i++) {
		char nstr[6];
		sprintf(nstr, "%d", i);
		int nlen = strlen(nstr);

		int nnum = 0;
		for (int j = 0; j < nlen; j++) {
			nnum += nstr[j] - 48;
		}

		for (int j = a; j <= b; j++) {
			if (nnum == j) {
				total += i;
			}
		}
	}

	printf("%d\n", total);

	return 0;
}

Measured memory_bytes: 128
import scala.collection.mutable
import scala.io.StdIn._

case class Edge(to: Int, cost: Int)

object Main extends App {
  val n = readInt()
  val edges = for (i <- 0 until n) yield {
    val (_ :: k :: rest) = readLine().split(" ").map(_.toInt).toList
    for (j <- 0 until k) yield {
      Edge(rest(j * 2), rest(j * 2 + 1))
    }
  }

  val que = mutable.PriorityQueue(Edge(0, 0))(Ordering.by((e: Edge) => e.cost).reverse)
  val d = mutable.Seq.fill(n)(Int.MaxValue)
  d(0) = 0

  while (que.nonEmpty) {
    val edge = que.dequeue()
    if (d(edge.to) >= edge.cost) {
      edges(edge.to).foreach(e => {
        if (d(e.to) > d(edge.to) + e.cost) {
          d(e.to) = d(edge.to) + e.cost
          que.enqueue(e)
        }
      })
    }
  }

  d.zipWithIndex.foreach {
    case (x, i) => println(s"$i $x")
  }
}

Measured memory_bytes: 49084
# -*- coding:utf-8 -*-


def main(lst):
    left = lst[0] + lst[1]
    right = lst[2] + lst[3]
    if left > right:
        print("Left")
    elif right > left:
        print("Right")
    else:
        print("Balanced")


if __name__ == "__main__":
    lst = [int(val) for val in input().split()]
    main(lst)

Measured memory_bytes: 3060
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int A1 = int.Parse(ipt[0]);
    int A2 = int.Parse(ipt[1]);
    int A3 = int.Parse(ipt[2]);
    Console.WriteLine((A1 + A2 + A3 < 22) ? "win" : "bust");
  }
}


Measured memory_bytes: 11092
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;


struct Edge{
    int id;
    int to;
};

using Graph=vector<vector<Edge>>;

Graph g;
int mask[50];
ll dp[1<<20];
bool dfs(int v,int pre,int dest,int bit){
    if(v==dest) return true;
    for(auto &e:g[v]){
        if(e.to==pre) continue;
        bool ret=dfs(e.to,v,dest,bit);
        if(ret){
            mask[e.id]|=bit;
            return true;
        }
    }   
    return false; 
}

int main(){
    int n;
    cin>>n;
    g.resize(n);
    for(int i=0;i+1<n;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back({i,b});
        g[b].push_back({i,a});
    }
    
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        dfs(u,-1,v,1<<i);
    }
    dp[0]=1;
    for(int i=0;i<n-1;i++){
        for(int j=(1<<m)-1;j>=0;j--){
            dp[j|mask[i]]+=dp[j];
        }
    }
    cout<<dp[(1<<m)-1]<<endl;
    return 0;
}


Measured memory_bytes: 8448
N, K = map(int, input().split())
H = list(map(int, input().split()))

inf = float("INF")
dp = [inf] * N
dp[0] = 0
for i in range(N):
    for j in range(i+1,min(i+K+1, N)):
        dp[j] = min(dp[j], dp[i] + abs(H[i] - H[j]))

print(dp[N-1])

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

using namespace std;

typedef long long ll;

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

#define per(i, n) for (int i = n ; i >= 0 ; --i)

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

  ll n, k;
  cin >> n >> k;

  map<ll, ll> m;
  rep (i, n) {
    ll a;
    cin >> a;

    ++m[a];
  }

  vector<pair<ll, ll>> v;
  for (pair<ll, ll> p : m) {
    v.push_back(p);
  }

  sort(v.begin(), v.end(), [](pair<ll, ll> i, pair<ll, ll> j) -> bool {
    return i.second < j.second;
  });

  ll c = v.size() - k;
  ll result = 0;

  rep(i, v.size() - k) {
    result += v.at(i).second;
  }

  cout << result << '\n';

  return 0;
}

Measured memory_bytes: 19892
#include <stdio.h>
int main()
{
    long int N;
    scanf("%ld", &N);
    int s[100] = {0};
    do
    {
        if ((N - 1) / 26)
        {
            s[++s[0]] = (N - 1) % 26;
        }
        else
        {
            s[++s[0]] = N - 1;
        }
        N = (N - 1) / 26;
    } while (N);
    while (s[0])
        printf("%c", (char)(s[s[0]--] + (int)'a'));
    puts("");
    return 0;
}


Measured memory_bytes: 1648
N = int(input())
T = list(map(int, input().split()))

counter = []
for i in range(N):
    if T[i] % 4 == 0:
        count = 2
    elif T[i] % 2 == 0:
        count = 1
    else:
        count = 0
    counter.append(count)

c0 = counter.count(0)
c1 = counter.count(1)
c2 = counter.count(2)

if c0 - 1 <= c2 and c1 % 2 == 0:
    print('Yes')
elif c0 <= c2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include <iostream> 
#include <algorithm> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <iomanip>
 using  namespace std;
 int a, b, c, x, d;
int main ()
{
    cin >> a >> b >> c >> x;
     for ( int i = 0 ; i <= a; i ++ )
    {
        for ( int j = 0 ; j <= b; j ++ )
        {
            for ( int k = 0 ; k <= c; k ++ )
                 if (i * 500 + j * 100 + k * 50 == x) d ++ ;
        }
    }
    cout << d << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, C, D; cin >> A >> B >> C >> D;
	bool F[110] = { false };
	int ans = 0;
	eFOR(i, A, B)F[i] = 1;
	eFOR(i, C, D)ans += F[i];
	if (ans)ans--;
	cout << ans<< endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;


ll tani(string s)
{
    ll i,j,d=100,sm=0,x;

    for(i=0;i<3;i++)
    {
        x=s[i]-'0';
        sm+=x*d;
        d/=10;
    }



    return abs(753-sm);
}
int main()
{


    string s;

    ll i,j,d,p,k;
    ll mn=100000000000;

    cin>>s;

    string x="";

    for(i=0;i<=s.length()-3;i++)
    {
        j=i+2;
        x="";

        for(k=i;k<=j;k++)x+=s[k];

        d=tani(x);
        mn=min(mn,d);


    }

    cout<<mn<<endl;

    return 0;
}


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

using namespace std;

int main()
{
  int64_t n, cnt, sum;
  char s1[11];
  vector<string> s;

  cin >> n;

  for (int64_t i = 0; i < n; i++) {
    cin >> s1;
    sort(s1, s1+10);
    string s1_s(s1);
    s.push_back(s1_s);
  }
  sort(s.begin(), s.end());

  //for (auto it = s.begin(); it != s.end(); it++) {
  //  cout << *it << endl;
  //}

  sum = 0; cnt = 1;
  for (int64_t i = 1; i < n; i++) {
    if (s[i-1] == s[i]) {
      cnt++;
    } else {
      sum += cnt*(cnt-1)/2;
      cnt = 1;
    }
  }
  sum += cnt*(cnt-1)/2;

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 5748
import sys
from operator import itemgetter
from math import hypot
from itertools import takewhile, chain, combinations

def ntp(A: list, axis: int = -1):
    length = len(A)
    if length <= 4:
        return min([hypot(x1 - x2, y1 - y2) for (x1, y1), (x2, y2) in combinations(A, 2)])
    
    x_types = len(set(x for x, _ in A))
    axis1 = 2*x_types <= length
    axis2 = not axis1
    mid_idx = length//2
    
    if axis1 != axis:
        A.sort(key = itemgetter(axis1))
    Al, Ar = A[:mid_idx], A[mid_idx:]
    median = A[mid_idx][axis1]
    
    tmd = min(ntp(Al, axis1), ntp(Ar, axis1))
    
    midA = [p for p in chain(takewhile(lambda t: median - tmd < t[axis1], Al[::-1]),\
                             takewhile(lambda t: median + tmd > t[axis1], Ar))]
    midA.sort(key = itemgetter(axis2))
    for i, (x1, y1) in enumerate(midA):
        ub = (x1, y1)[axis2] + tmd
        for x2, y2 in takewhile(lambda t: t[axis2] < ub, midA[i+1:]):
            tmd = min(tmd, hypot(x1 - x2, y1 - y2))
    
    return tmd
n = int(sys.stdin.readline())
Points = [tuple(map(float, sys.stdin.readline().split())) for _ in [0]*n] 
print('{:.10f}'.format(ntp(Points)))



Measured memory_bytes: 24280
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    vector<int> A(5);
    for(int i = 0; i < 5; i++) cin >> A[i];
    int sum = 0;
    for(int i = 0; i < 5; i++){
        sum += (A[i] + 9)/ 10 * 10;
    }
    int min_n = 100000;
    for(int i = 0; i < 5; i++){
        int m = sum - ((A[i]+9) / 10 * 10);
        m += A[i];
        min_n = min(min_n, m);
    }
    cout << min_n << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=3005;
const ll inf=1e9+7;
double dp[maxn][maxn];
double p[maxn];
ll n,m;
int main()
{
    while(cin>>n>>m)
    {
        cout<<n*(n-1)/2+m*(m-1)/2<<"\n";
    }
}


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}


int g[2][105];
int dp[2][105];
int n;
int ans = 0;

int go(int x, int y) {
  if(x == 1 and y == n - 1) {
    return g[x][y];
  }
  if(dp[x][y] != -1) return dp[x][y];
  int cur = 0;
  if(x + 1 < 2) {
    cur = g[x][y] + go(x + 1, y);
  }
  if(y + 1 < n) {
    cur = max(cur, g[x][y] + go(x, y + 1));
  }
  return dp[x][y] = cur;
}

int main() {
  cin >> n;
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < n; j++) {
      cin >> g[i][j];
    }
  }
  memset(dp, -1, sizeof dp);
  cout << go(0, 0) << '\n';
}

Measured memory_bytes: 256
n, k = map(int, raw_input().split())
hs = map(int, raw_input().split())
oo = max(hs) * n + 1


dp = [oo] * n
dp[n - 1] = 0
for i in range(n - 2, -1, -1):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i] = min(dp[i], dp[i + j] + abs(hs[i] - hs[i + j]))
print(dp[0])


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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int t;
  cin >> t;
  int maxv = INT_MIN;
  int minv = t;
  for (int i = 1; i < n; i++) {
    cin >> t;
    maxv = max(maxv, t - minv);
    minv = min(minv, t);
  }

  cout << maxv << endl;
  return 0;
}



Measured memory_bytes: 3096
#!/usr/bin/env python3
s = input()
r = 0 
l = 0
i = 0
ans = [0]*len(s)
# 最終的な人数としては、RL になっている２つの場所以外は0でRLにはRLのRから
# 距離が偶数の点のかず、LにはRからの距離が奇数の数が入る
#　変数は返却のans配列とそれぞれに末端のRの位置l、RLの境のRの位置m , L の端の位置 r がある
bit = 0 # RLを通過しているかしていないか
#最後だけ入力されてない
while i != len(s)-1:
    i += 1
    if bit == 0 and s[i] == "R": continue
    elif bit == 0 and s[i] == "L":
        m = i-1 # m は最後のR　の位置
        bit = 1
    elif s[i] == "R":#次のブロックに入った
        r = i-1
        ans[m] = 1+(r-m)//2 + (m-l)//2
        ans[m+1] = r-l - ((r-m)//2 + (m-l)//2)
        l = i
        bit = 0
    if i == len(s)-1:
        r = i
        ans[m] = 1+(r-m)//2 + (m-l)//2
        ans[m+1] = r-l - ((r-m)//2 + (m-l)//2)
for s in ans:
    print(s,end=" ")
    



Measured memory_bytes: 51288
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}



signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int C, N, M;
  cin>>C>>N>>M;

  vector<_int> s(N), p(N);
  for(Int i=0;i<N;i++) cin>>s[i]>>p[i];
  vector<vector<_int> > dp(N+1, vector<_int>(C+1,-(_int)INF));
  dp[0][0] = 0;
  for(Int i=0;i<N;i++)
    for(Int j=0;j<=C;j++){
      Max(dp[i+1][j], dp[i][j]);
      if(j + s[i] <= C) Max(dp[i+1][ j+s[i] ], dp[i][j] + p[i]);
    }

  vector<_int> score = dp[N];
  for(Int i=1;i<=C;i++)  Max(score[i], score[i-1]);
  for(Int m = 1;m <= M;m++){
    Int ans = score[C / m] * m;
    cout<<ans<<endl;
    
  }
  

  return 0;
}



Measured memory_bytes: 383184
#include<bits/stdc++.h>
#define w while
#define loop(i,l,r) for(int i=l;i<r;i++)
#define ci cin>>
#define co cout<<
#define ll long long
using namespace std;
int main()
 { int t;
    ci t;
  double k = (1.0*t)/3.0;
  double ans = k*k*k;
  cout<<fixed << setprecision(6)<<ans;
}


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

int main(){
    int n, r;
    cin >> n >> r;
    if(n < 10){
        cout << r + 100 * (10 - n) << endl;
    }
    else{
        cout << r << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <deque>
using namespace std;
int main()
{
    deque<int> a;
    int q, query, tmp1, tmp2;
    cin >> q;
    for (int i=0; i<q; ++i){
        cin >> query;
        switch(query){
            case 0:
                cin >> tmp1 >> tmp2;
                if (tmp1 == 0){a.push_front(tmp2);}
                else if(tmp1 == 1){a.push_back(tmp2);}
                break;
            case 1:
                cin >> tmp1;
                cout << a[tmp1] << endl;
                break;
            case 2:
                cin >> tmp1;
                if (tmp1 == 0){a.pop_front();}
                else if(tmp1 == 1){a.pop_back();}
                break;
        }
    }
}


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

using namespace std;
using namespace std;
typedef long long ll;
#define endl "\n"
#define loop(n) for (ll i = 0; i < n; i++)
#define loop2(n) for (ll i = 0; i < n; i += 2)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
int Mint = INT_MAX;
ll Mlong = LLONG_MAX;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int pow(ll a, ll b) {
    if (b == 1)return a;
    if (b == 0) return 1;
    return a * pow(a, b - 1);
}

int n;
int operation = 0;

int counti = 0;


int solve(int s) {
    if (s == 0)
        return 0;
    if (s == 1)
        return 2;
    if (s == 2)
        return 4;



    //cout << s << endl;
    operation++;
    return solve(s - 1) + solve(s - 2);
}

int count = 0;
map<ll,ll> store;

ll ans(ll a) {
    if (a == 1)return 1;
    counti++;
    if (store[a] != 0)return store[a];
    return store[a] = 1 + ans(a / 2) + ans(a / 2);


}

int main() {
    fast();
    ll n;
    cin >> n;
    cout << ans(n)<<" ";

}


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

int main(){
  int N;
  cin >> N;
  vector<string> blue(N);
  for(int i = 0; i < N; i++){
    cin >> blue[i];
  }
  int M;
  cin >> M;
  vector<string> red(M);
  for(int i = 0; i < M; i++){
    cin >> red[i];
  }
  vector<int> point(N);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(blue[i] == blue[j]) point[i]++;
   }
    for(int k = 0; k < M; k++){
      if(blue[i] == red[k]) point[i]--;
    }
  }
  int max = *max_element(point.begin(), point.end());
  if(max > 0) cout << max << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
using namespace std;

int main(){
	char f[16][16] = {};
	int n, x, y;
	scanf("%d", &n);
	for(int d = 1; d <= n; ++d){
		for(int i = 0; i < 8; ++i){
			scanf(" %s", f[i + 4] + 4);
		}
		scanf("%d%d", &x, &y);

		queue<int> q;
		q.push(x + 3 << 8 | y + 3);

		while(!q.empty()){
			x = q.front() >> 8;
			y = q.front() & 0xff;
			for(int i = -3; i <= 3; ++i){
				if(f[y + i][x] == '1'){
					f[y + i][x] = '0';
					q.push(x << 8 | y + i);
				}
				if(f[y][x + i] == '1'){
					f[y][x + i] = '0';
					q.push(x + i << 8 | y);
				}
			}
			q.pop();
		}
		
		printf("Data %d:\n", d);
		for(int i = 0; i < 8; ++i){
			puts(f[i + 4] + 4);
		}
	}
}

Measured memory_bytes: 1044
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    cout << A * B;
    return 0;
}

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

using namespace std;

int const NMAX = 1e2;
int const WMAX = 1e5;
int n, w;
//a = 1, b = 2, c = 3;
int we[1 + NMAX], va[1 + NMAX];
long long dp[1 + NMAX][1 + WMAX];

int main() {
  cin >> n >> w;
  for(int i = 1; i <= n; i++) {
    cin >> we[i] >> va[i];
  }
  for(int i = 1; i <= n; i++) {
    for(int j = 0; j <= w; j++) {
      dp[i][j] = max(dp[i][j], dp[i-1][j]);
      if(j - we[i] >= 0) {
        dp[i][j] = max(dp[i][j], dp[i-1][j-we[i]] + va[i]);
      }
    }
  }
  cout << dp[n][w];
}


Measured memory_bytes: 78336
def main():
    M, D = map(int, input().split())
    count = 0

    for m in range(1, M+1):
        for d in range(1, D+1):
            if d < 22:
                continue
            d_str = str(d)
            d1 = int(d_str[0])
            d10 = int(d_str[1])
            if d1 >= 2 and d10 >= 2:
                if d1 * d10 == m:
                    count += 1
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using namespace internal;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	ll n, q;
	cin >> n >> q;
	fenwick_tree<ll> f(n);
	rep(i, n) {
		ll a;
		cin >> a;
		f.add(i,a);
	}
	ll ans;
	rep(i, q) {
		int op;
		cin >> op;
		if (op == 0) {
			ll p, x;
			cin >> p >> x;
			f.add(p,x);
		}
		else if (op == 1) {
			ll l, r;
			cin >> l >> r;
			ans = f.sum(l, r);
			cout << ans << endl;
		}
	}
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long

const ll inf = 1e18+7;
const int N = 1e6;
const int mod = 1e9+7;
ll a, b;
int main()
{	
	cin >>a >> b;
	if(b == 1){
		cout << 0;
		return 0;
	}
	int ans = 0;
	while(b>0){
		b-=a;
		if(b > 0)
			b++;
		ans++;
	}
	cout << ans;
 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    ll N,Q; Vll A;
    vector< Vll > to;
    cin >> N; A.rs(N); to.rs(N);

    repll(i,0,N-1){
        cin >> A[i];
        --A[i];
        to[A[i]].pb(i);//a -> b
        //to[A[i]].pb(i);//b -> a
  }

  repll(i,0,N){
      cout << to[i].size() << endl;
  }
}


Measured memory_bytes: 15876
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const int timeLimit = 1980;

i64 xor128()
{
  static i64 x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  i64 t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

i64 D;
i64 c[26];
i64 s[365][26];
vector<i64> ans;

i64 eval(vector<i64> &ans)
{
  i64 score = 0;
  i64 last[26] = {};
  for (i64 i = 0; i < D; i++)
  {
    score += s[i][ans[i]];
    last[ans[i]] = i + 1;
    for (i64 j = 0; j < 26; j++)
      score -= c[j] * (i + 1 - last[j]);
  }
  return score;
}

void solve()
{
  chrono::system_clock::time_point start = chrono::system_clock::now();
  i64 bestScore = -1e18, nowScore = -1e18, loop = 0;
  double C = timeLimit * 100, forceLine;
  i64 currentTime;
  vector<i64> now = ans;
  i64 t[10][3];
  while ((currentTime = chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now() - start).count() / 1000) < timeLimit)
  {
    forceLine = (timeLimit - currentTime) / C;
    i64 cCount = max(1LL, (i64)(forceLine * 1000));
    for (i64 i = 0; i < cCount; i++)
    {
      t[i][0] = xor128() % D;
      t[i][1] = xor128() % 26;
      t[i][2] = now[t[i][0]];
      now[t[i][0]] = t[i][1];
    }
    i64 score = eval(now);
    if (bestScore < score)
    {
      ans = now;
      bestScore = score;
    }
    if (nowScore < score || forceLine * 1000 > rand() % 1000)
    {
      nowScore = score;
    }
    else
    {
      for (i64 i = cCount - 1; 0 <= i; i--)
        now[t[i][0]] = t[i][2];
    }
    loop++;
  }
  cerr << "score: " << bestScore + (i64)(1e6) << endl
       << "loop: " << loop << endl;
}

void input()
{
  cin >> D;
  for (i64 i = 0; i < 26; i++)
    cin >> c[i];
  for (i64 i = 0; i < D; i++)
    for (i64 j = 0; j < 26; j++)
      cin >> s[i][j];
  ans.resize(D);
}

void output()
{
  for (i64 i = 0; i < D; i++)
    cout << ans[i] + 1 << endl;
}

int main()
{
  input();
  solve();
  output();
  return 0;
}


Measured memory_bytes: 3696
from collections import deque
L = int(input())
d = deque()
d_set = set()
clist = list(map(int, input().split()))
for i in range(L):
    c = clist[i]
    if c > 0:
        if c in d_set:
            print(i+1)
            break
        d.append(c)
        d_set.add(c)
    else:
        c *= -1
        if not d or d.pop() != c:
            print(i+1)
            break
        d_set.remove(c)
else:
    print("OK")



Measured memory_bytes: 6052
#include <stdio.h>
int main(){
  int n,k,q;
  scanf("%d%d%d", &n, &k, &q);
  //int a[n];
  int p[n];
  for (int i = 0; i < n; i++) {
    p[i] = 0;
  }
  for (int i = 0; i < q; i++) {
    int a;
    scanf("%d", &a);
    p[a-1]++;
  }
  for (int i = 0; i < n; i++) {
    if (p[i] > q - k) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,cnt=0,mini=INF;
    cin>>n;
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    rep(i,n){
        mini = min(mini, p[i]);
        if(mini == p[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 4824
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
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++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

//基本は全探索
//愚直だとN^3だけど、K番目だからK文字までで比べればNK^2おけ！！

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    string s; cin >> s;
    int N = s.size();
    int K; cin >> K;
    vector<string> vec;
    rep(i, N) {
        rep1(len, K) {
            if(i + len - 1 > N - 1) continue;
            string a;
            rep(j, len) {
                a += s[i + j];
            }
            vec.pb(a);
        }
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    cout << vec[K - 1] << endl;
	return 0;
}

Measured memory_bytes: 1660
#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<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

ll N,M,A[100010],B[100010],ans=0;
std::map<ll,ll> H;

ll comb(ll n,ll r){
	ll seki=1;
	for(int i=n;n-r<i;i--){
		seki*=i;
	}
	for(int i=1;i<=r;i++){
		seki/=i;
	}
	return seki;
}

int main(){
	ll count=0;
	cin>>N>>M;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,N){
		A[i+1]+=A[i];
		B[i+1]=A[i];
	}
	REP(i,N+1){
		H[B[i]]=0;
	}
	REP(i,N+1){
		B[i]%=M;
		H[B[i]]++;
	}
	for(auto x:H){
		ans+=comb(x.second,2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int ans=0;
    rep(i,len(s)){
      if(s[i]=='1'){
        ans++;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
s = input()
sr = s[-1::-1]
left = 0
right = 0
ans = 0
while (1):
    if left + right >= len(s) - 1:
        break
    if s[left] != sr[right]:
        if s[left] == 'x':
            left += 1
        elif sr[right] == 'x':
            right += 1
        else:
            print(-1)
            exit()
        ans += 1
    elif s[left] == sr[right]:
        left += 1
        right += 1

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const LL P = 1000000007;
LL f[1000000 + 233], g[1000000 + 233];

int main() {
	ios::sync_with_stdio(false);
	int n, d, h;
	cin >> n >> h >> d;
	LL fac = 1, sum = 0;
	for(int i = 1; i <= n; ++i) fac = fac * i % P, (sum += fac) %= P;
	f[0] = fac;
	memset(g, 0, sizeof(g));
	g[0] = f[0];
	for(int i = 1; i < h; ++i) {
//		for(int j = max(0, i - d); j < i; ++j)
//			f[i] += f[j];
		if(i - d <= 0) f[i] = g[i - 1];
		else f[i] = (g[i - 1] - g[i - d - 1]) % P;
		f[i] = f[i] % P * sum % P;
		g[i] = (g[i - 1] + f[i]) % P;
	}
	LL ans = 0;
	for(int j = max(0, h - d); j < h; ++j) ans += f[j];
	cout << (ans % P + P) % P << endl;
	return 0;
}


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

int main(){
    int N,T;
    cin >> N >> T;
    long long sum = T;
    int t1;
    int t2;
    cin >> t1;
    for(int i=0;i<N;i++){
        cin >> t2;
        if(t2-t1 < T){
            sum += t2-t1;
        }else{
            sum += T;
        }
        t1 = t2;
    }
    cout << sum;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM

#include <bits/stdc++.h>
#define loop(i,n) for(int i=0;i<n;i++)
#define pi acos(-1.00)

using namespace std;



int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;



}



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

using namespace std;
using i64 = std::int_fast64_t;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, W;
  cin >> N >> W;
  vector<i64> weight(N), value(N);
  for (int i = 0; i < N; i++) {
    cin >> weight[i] >> value[i];
  }

  vector<vector<i64>> dp(N + 1, vector<i64>(W + 1, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < W + 1; j++) {
      if (j - weight[i] >= 0)
        chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);
      chmax(dp[i + 1][j], dp[i][j]);
    }
  }
  cout << dp[N][W] << "\n";
  return 0;
}


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

int main(){
    
    string S;
    cin >> S;
    long long ans = 0;
    long long cont = 0;
    for(long long i = 0; i < S.size();i++){
        if(S[i]=='W'){
            ans += cont;
        }else{
            cont++;
        }
    }
    cout << ans <<endl;
}

    
    



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX_N=3005;
LL dp[MAX_N][MAX_N];
int a[MAX_N];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(n%2)dp[i][i]=a[i];
		else dp[i][i]=-a[i];
	}
	for(int l=2;l<=n;l++)
	{
		for(int i=1;i<=n;i++)
		{
			int j=i+l-1;
			if(j>n)continue;
			if(l%2!=n%2)dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
			else dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
		}
	}
	cout<<dp[1][n]<<endl;
	return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;
ll s;
vector<string> v;
ll res = 0;

void dfs(int step, vector<int> op){
  if(step == int(op.size())){
    ll count = 0;
    string now = v[0];
    for (int i = 0; i < int(op.size()); i++) {
      if(op[i] == 0){
        count += stoll(now);
        now = "";
      }
      now += v[i+1];
      // cout << now << endl;
    }
    res += count + stoll(now);
    return;
  }
  dfs(step+1, op);
  op[step] = 1;
  dfs(step+1, op);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  v = vector<string> (to_string(s).size());
  for (int i = 0; i < int(to_string(s).size()); i++) {
    v[i] = to_string(s)[i];
  }
  // print(v);
  vector<int> op(v.size() - 1);

  dfs(0, op);

  cout << res << endl;

}


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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    set <int> s={x1,x2,x3,x4,x5};
    for (int i=1;i<=5;i++){
        if(s.find(i)==s.end()){
            cout<<i<<"\n";
            break;
        }    
    }
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;


void knapsack(ll n,ll w,ll value[],ll wt[])
{
    ll dp[n+1][w+1];
    
    for(ll i=0;i<=w;i++)
    {
        dp[0][i]=0;
    }
    
    for(ll i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        
        {
            ll include=0;
            ll exclude=0;
            
            exclude=dp[i-1][j];
            
            if(wt[i-1]<=j)
            {
                include=value[i-1]+dp[i-1][j-wt[i-1]];
            }
            
            dp[i][j]=max(include,exclude);
        //    cout<<dp[i][j]<<" ";
        }
       // cout<<"\n";
    }
    
    cout<<dp[n][w];
    
    
    
}


int main() {

	    ll n;
	    cin>>n;
	    //cout<<n<<"\n";
	    ll w;
	    cin>>w;
	  //  cout<<w<<"\n";
	    ll value[n];
	     ll wt[n];
	    for(ll i=0;i<n;i++)
	    {
	          cin>>wt[i];
	        cin>>value[i];
	      
	    }
	  
	   knapsack(n,w,value,wt);
	 
	    
	
	return 0;
}


Measured memory_bytes: 79104
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

typedef long long ll;

//------------------------------------------------------------------------------
ll comb(ll n, ll k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k > n - k) k = n - k;
  if (k == 0) return 1;
  ll m = n - k;
  ll ret = 1;
  FOR(i, 1, k) ret = ret * (m + i) / i;
  return ret;
}

//------------------------------------------------------------------------------
const int N_MAX = 50;

int N, A, B;
ll v[N_MAX];

void solve() {
  sort(v, v + N, greater<ll>());

  double avg = 0;
  REP(i, A) avg += v[i];
  avg /= A;

  ll x = v[A - 1];
  int s = -1;
  int n = 0;
  REP(i, N) {
    if (v[i] == x) {
      if (s < 0) s = i;
      n++;
    }
  }

  ll pat = 0;
  if (s == 0) {
    FOR(i, A, B) pat += comb(n, i);
  } else {
    pat = comb(n, A - s);
  }

  printf("%.6f\n", avg);
  printf("%lld\n", pat);
}

void input() {
  scanf("%d%d%d", &N, &A, &B);
  REP(i, N) scanf("%lld", v + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%c\n",(abs(a-b)>abs(a-c))?'B':'A');
	return 0;
}

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

int dp[100005][5];

int main() {
	int n; cin >> n;
	vector<int> a(n + 1), b(n + 1), c(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];
	for (int i = 2; i <= n; i++) {
		dp[i][1] = max(dp[i - 2][1], max(dp[i - 1][2], dp[i - 1][3])) + a[i];
		dp[i][2] = max(dp[i - 2][2], max(dp[i - 1][1], dp[i - 1][3])) + b[i];
		dp[i][3] = max(dp[i - 2][3], max(dp[i - 1][1], dp[i - 1][2])) + c[i];
	}
	cout << max(max(dp[n][1], dp[n][2]), dp[n][3]) << '\n';
}


Measured memory_bytes: 6404
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int c[10];
  for (int i=1;i<10;i++) cin>>c[i];
  string ans="No";
  if((
   (c[1]-c[2])==(c[4]-c[5])
  )*
  (
   (c[1]-c[2])==(c[7]-c[8])
  )*
  (
   (c[2]-c[3])==(c[5]-c[6])
  )*
  (
   (c[2]-c[3])==(c[8]-c[9])
  )
  ) ans="Yes";
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256