akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int N;
    cin >> N;
    int a[N],b[N],c[N];
    for (int i=0; i<N; ++i)
    {
        cin >> a[i] >> b[i] >> c[i];
    }

    int dp[N+1][3];
    for (int i=0; i<N; ++i)
    {
        for (int j=0; j<3; ++j)
        {
            dp[i][j] = -inf;
        }
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i=0; i<N; ++i)
    {
        if (dp[i+1][0]<dp[i][1]+a[i+1] || dp[i+1][0]<dp[i][2]+a[i+1])
        {
            dp[i+1][0] = max(dp[i][1]+a[i+1],dp[i][2]+a[i+1]);         
        }

        if (dp[i+1][1]<dp[i][2]+b[i+1] || dp[i+1][1]<dp[i][0]+b[i+1])
        {
            dp[i+1][1] = max(dp[i][2]+b[i+1],dp[i][0]+b[i+1]);         
        }

        if (dp[i+1][2]<dp[i][0]+c[i+1] || dp[i+1][2]<dp[i][1]+c[i+1])
        {
            dp[i+1][2] = max(dp[i][0]+c[i+1],dp[i][1]+c[i+1]);         
        }
    }

    cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));

    return 0;
}

Measured memory_bytes: 2560
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace
import           Text.Printf


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons
getInt = readLn :: IO Int
getIntTuple = (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2)) <$> getIntVector

genGraph n x y = toUnDirectedGraph (n+1) . V.fromList $ (x,y) : zip [1..n-1] [2..n]

toDirectedGraph n input = V.create $ do
  graph <- VM.replicate n []
  V.forM_ input $ \(a,b) -> do
    VM.modify graph (b:) a
  return graph

toUnDirectedGraph n input = V.create $ do
  graph <- VM.replicate n []
  V.forM_ input $ \(a,b) -> do
    VM.modify graph (b:) a
    VM.modify graph (a:) b
  return graph

next :: V.Vector [Int] -> Int -> [Int]
next graph node = graph V.! node

dfs graph start goal = dfs' start []
  where
    next' = next graph
    dfs' now path
      | now == goal = return $ reverse $ now:path
      | otherwise = concatMap (\node -> dfs' node $ now:path) [x | x <- next' now, not (x `elem` path)]

bfs :: V.Vector [Int] -> Int -> Int -> Maybe [Int]
bfs graph start goal = bfs' [x : [start] | x <- next' start]
  where
    next' = next graph
    bfs' [] = fail "no Path"
    bfs' (path:queue)
      | goal == now = (return $ reverse path) `mplus` (bfs' queue)
      | otherwise = bfs' $ queue ++ [x : path | x <- next' now, not $ x `elem` path]
      where now = head path

solve' n x y = do
  let graph = genGraph n x y
  i <- [1..n-1]
  j <- [i+1..n]
  return $ (\n -> n - 1) . length . fromJust $ bfs graph i j

solve'' n x y = do
  let graph = genGraph n x y
  i <- [1..n-1]
  j <- [i+1..n]
  return $ fromJust $ bfs graph i j


solve n x y = VU.create $ do
  let graph = genGraph n x y
  dp <- VUM.replicate (n+1) (0 :: Int)
  forM_ [1..n-1] $ \i -> do
    forM_ [i+1 .. n] $ \j -> do
      -- let minPathLen = length . fromJust $ bfs graph i j
      -- trace (show minPathLen) $ VUM.modify dp (\n -> n+1) minPathLen
      let d1 = j - i
          d2 = abs (i-x) + abs (j-y) + 1
          k = min d1 d2
      VUM.modify dp (\n -> n+1) k
  return dp

main = do
  (n,x,y) <- getIntTuple
  let ans = solve n x y
  forM_ [1..n-1] $ \i -> do
    print $ ans VU.! i


Measured memory_bytes: 1020
from collections import deque
n,m = map(int, input().split())
way = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
#print(way)
stack = deque([0])
ans = [-1]*n
ans[0] = 0
flag = [True]*n
flag[0] = False
while stack:
    a = stack.pop()
    for i in way[a]:
        if (flag[i]):
            stack.appendleft(i)
            ans[i] = a
            flag[i] = False

if (-1 in ans):
    print("No")
else:
    print("Yes")
    for i in range(n):
        ans[i] += 1
    print(*ans[1:], sep="\n")

Measured memory_bytes: 39452
x = input()
a = x[::-1]
b = 0
c = 0
d = int(len(x))
while b + 1 <= d:
  if x[b] == a[b]:
    c = c
    b = b + 1
  else:
    c = c + 1
    b = b + 1
c = int(c/2)
print(c)

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

int n, ind=1, ans=0;
bool check=true;

int main(){
    cin >> n;
    int a[n];
    bool b[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
        b[i] = false;
    }
    while(true){
        if(b[ind-1]){
            check=false;
            break;
        }
        if(ind==2){
            break;
        }
        b[ind-1] = true;
        ind = a[ind-1];
        ans++;
    }
    ans = check? ans: -1;
    cout << ans << endl;
}


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

int main() {
	
	vector <int> v0={};

	int n, owo, contador=1, broken=0;
	
	cin>>n;
	
	for (int i=0;i<n;i++)
	{
		cin>>owo;
		v0.push_back(owo);
	}
	
	for (int i=0;i<v0.size();i++)
	{
		if (v0[i]==contador)
		{
			contador++;
		}
		else
		{
			broken++;
		}
	}
	
	
	if(contador==1)
	cout<<"-1";
	
	else
	cout<<broken;
	
	
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#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>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
const auto inf=LLONG_MAX; 

int main() 
{
	fastio
	//t_case
	{
		ll sum=0,f=0,ans=0,n,m=0,z=0,mx=inf,mn=-inf ;
		string s; cin>>s;
		fr(i,0,s.length()) {
			sum+=s[i]-'0';
		}
		if (sum%9==0) cout<<"Yes";
		else cout<<"No";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3752
N=int(input())
st=[]
for i in range(N):
  s,t=input().split()
  t=int(t)
  st.append((s,t))
X=input()

#st = sorted(st,key=lambda x:x[1])
flag=0
ans=0
for i in range(N):
  if flag: ans += st[i][1]
  if st[i][0]==X:flag=1
    
print(ans)

Measured memory_bytes: 9160
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BTapDance {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      int n = s.size();
      rep(i, n) {
        if (i%2==0) {
          if (s[i] == 'L') {
            cout << "No" << endl;
            return;
          }
        } else {
          if (s[i] == 'R') {
            cout << "No" << endl;
            return;
          }
        }
      }
      cout << "Yes" << endl;
    }
};

signed main() {
  BTapDance solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
// AOJ ALDS1_7_B Binary Trees
// 2018.5.1 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { int parent; int sibling; int depth, height; int k; int c[2]; } TREE;
TREE tree[30];

void calc_depth(int node, int d)
{
	int i;
	tree[node].depth = d;
	for (i = 0; i < tree[node].k; i++) calc_depth(tree[node].c[i], d+1);
}

int calc_height(int node)
{
	int i, h, t;

	h = 0;
	for (i = 0; i < tree[node].k; i++) {
		if ((t = calc_height(tree[node].c[i])+1) > h) h = t;
	}
	tree[node].height = h;
	return h;
}

int main()
{
	int n, i, id;
	int root, left, right;

	n = in();
	for (i = 0; i < n; i++) {
		id = in(), left = in(), right = in();
		if (left < 0 && right < 0) tree[id].k = 0;
		else if (left >= 0 && right >= 0) {
			tree[id].k = 2;
			tree[id].c[0] = left, tree[id].c[1] = right;
			tree[left].parent = id+1;
			tree[left].sibling = right+1;
			tree[right].parent = id+1;
			tree[right].sibling = left+1;
		} else {
			if (left < 0) left = right;
			tree[id].k = 1;
			tree[id].c[0] = left;
			tree[left].parent = id+1;

		}
	}
	for (root = 0; root < n; root++) {
		if (tree[root].parent == 0) break;
	}
	calc_depth(root, 0);
	calc_height(root);

	for (i = 0; i < n; i++) {
		printf("node %d:", i);
		printf(" parent = %d,", tree[i].parent-1);
		printf(" sibling = %d,", tree[i].sibling-1);
		printf(" degree = %d,", tree[i].k);
		printf(" depth = %d,", tree[i].depth);
		printf(" height = %d,", tree[i].height);
		if (i == root)          printf(" root");
		else if (tree[i].k == 0) printf(" leaf");
		else                    printf(" internal node");
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2100
N = int(input())
l = list(map(int, [input() for i in range(N)]))
v = 1
for i in range(100000):
    if l[v - 1] == 2:
        print(i+1)
        break
    else:
        v = l[v - 1]
        if i == 99999:
            print('-1')

Measured memory_bytes: 13356
h, w = map(int, input().split())
s = [input() for i in range(h)]
for i in range(h):
    for j in range(w):
        check = 0
        if s[i][j] == '#':
            if i != 0:
                if s[i - 1][j] == '#':
                    check += 1
            if j != 0:
                if s[i][j - 1] == '#':
                    check += 1
            if i != (h - 1):
                if s[i + 1][j] == '#':
                    check += 1
            if j != (w - 1):
                if s[i][j + 1] == '#':
                    check += 1
            if check == 0:
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    h,w = LI()
    a = [sys.stdin.readline() for i in range(h)]
    s = 0
    p = [None for i in range(w*h)]
    q = [None for j in range(w*h)]
    l = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                p[s] = (i,j)
                s += 1
            else:
                q[l] = (i,j)
                l += 1
    if s == h*w:
        print(0)
        quit()
    ans = 0
    M = w*h
    for i,j in q[:h*w-s]:
        m = M
        for x,y in p[:s]:
            if abs(i-x)+abs(j-y) < m:
                m = abs(i-x)+abs(j-y)
        if m > ans:
            ans = m
    print(ans)
    return

#B
def B():
    h,w,n = LI()
    sy,sx = LI()
    sy -= 1
    sx -= 1
    s = S()
    t = S()
    ks = list("LRUD")
    kt = list("RLDU")
    ds = [[0,-1],[0,1],[-1,0],[1,0]]
    dt = [[0,1],[0,-1],[1,0],[-1,0]]
    for i in range(4):
        y,x = [sy,sx]
        for j in range(n):
            if s[j] == ks[i]:
                y+=ds[i][0]
                x+=ds[i][1]
                if y < 0 or y >= h or x < 0 or x >= w:
                    print("NO")
                    quit()
            if t[j] == kt[i]:
                y += dt[i][0]
                x += dt[i][1]
                if y < 0:y = 0
                elif y >= h:y = h-1
                elif x < 0:x=0
                elif x >= w:x=w-1
    print("YES")
    return

#C
def C():
    def dijkstra(s):
        d = [float("inf") for i in range(n)]
        d[s] = 0
        q=[[0,s]]
        while q:
            dx,x = heappop(q)
            for y in v[x]:
                if dx+1 < d[y]:
                    d[y] = dx+1
                    heappush(q,[d[y],y])
        return d
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    d = dijkstra(0)
    l = d.index(max(d))
    d = dijkstra(l)
    m = max(d)+1
    if m%3 == 2:
        print("Second")
    else:
        print("First")
    return

#D
def D():
    n = I()
    return

#E
def E():
    n = I()
    return

#F
def F():
    n = I()
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 121036
fun main(args :Array<String>) {
    val MOD = 1000000007L
    val MAX = 3000
    val combination = Array<Array<Long>>(MAX) { Array<Long>(MAX) { 0 } }
    combination[0][0] = 1
    for (i in 1 until MAX) {
        for (j in 0..i) {
            val left = if (j - 1 >= 0) combination[i - 1][j - 1] else 0
            val right = combination[i - 1][j]
            combination[i][j] = (left + right) % MOD
        }
    }

    val (n, k) = readIntegerList()
    for (i in 1..k) {
        println((combination[n - k + 1][i] * combination[k - 1][i - 1]) % MOD)
    }
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

int main()
{
    int t=1;
    //cin>>t;
    
    while(t--)
    {
        long long int n;
        cin>>n;
        
        string ans="";
        
        while(n)
        {
            if(n%26==0)
            {
                ans += 'z';
                n=(n/26)-1;
            }
            else
            {
                ans += (n%26 + 'a' - 1);
                n=n/26;
            }
        }        
        reverse(ans.begin(), ans.end());
        cout<<ans;
    }    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){  
  int n,i;
  cin >> n >> i;

  cout << n-i+1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.*;

class Main {

    static int min(int a, int b) {
        return Math.min(a, b);
    }

    static int abs(int a) {
        return Math.abs(a);
    }

    static int get(String s)
    {
        return Integer.parseInt(s);
    }
    static long max(long a,long b)
    {
        return Long.max(a, b);
    }
    static int max(int a,int b,int c)
    {
        return Math.max(a, Math.max(b, c));
    }
    public static void main(String[] args) throws Exception 
    
    {
        PrintWriter p = new PrintWriter(System.out);
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        
        Object[] nw = Arrays.stream(bf.readLine().split(" ")).map(Integer::parseInt).toArray();
        int a =  (int)nw[0];
        int b = (int)nw[1];
        // int n = Integer.parseInt(bf.readLine());
        int[] w = new int[a],v = new int[a];
        // p.printf("%d %d \n",n,w);
        for (int i = 0; i < a; i++) {
            String[] temp = bf.readLine().split(" ");
            w[i] = get(temp[0]);
            v[i] = get(temp[1]);
            // c[i] = get(temp[2]);

        }
        
        long dp[] = new long[110000];
        for (int i = 0; i < a;  i++) 
        {
            for (int j = b; j >= 0; j--)
            {
                if(j+w[i] <= b)
                    dp[j+w[i]] = max(dp[j+w[i]], dp[j]+v[i]);
            }
        }
       
        Long ret = Arrays.stream(dp).max().getAsLong();
        p.println(ret);
        p.flush();
    }
}

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

int main() {
	string S;
	cin >> S;
	sort(S.begin(), S.end());
	for (int i = 0;i < S.size() - 1;++i) {
		if (S[i] == S[i + 1]) {
			puts("no");
			return 0;
		}
	}
	puts("yes");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main (void){
     
    int p;
    char buff[256];
    char buff1[256];
    char buff2[256];
     
    scanf("%s",buff1);
    scanf("%s",buff2);
    strcpy(buff,buff1);
    strcat(buff,buff1);
         
    //printf("%s\n",buff);
     
     
     
    if(strstr(buff,buff2) == 0){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
return 0;
}


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

int main() {
    int N, M;
    cin >> N;
    vector<string> blue(N);
    for(int i = 0; i < N; i++){
        cin >> blue.at(i);
    }
    cin >> M;
    vector<string> red(M);
    for(int i = 0; i < M; i++){
        cin >> red.at(i);
    }
    int ans = 0;
    int maxans = 0;
    for(int i = 0; i < N; i++){
        int bcnt = 1;
        int rcnt = 0;
        for(int j = 0; j < N; j++){
            if(i == j){
                continue;
            }
            if(blue.at(i) == blue.at(j)){
                bcnt++;
            }
        }
        for(int j = 0; j < M; j++){
            if(blue.at(i) == red.at(j)){
                rcnt--;
            }
        }
        ans = bcnt + rcnt;
        if(maxans < ans){
            maxans = ans;
        }
    }
    cout << maxans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s, t;
  cin >> s >> t;
  int s_l = s.size(), t_l = t.size();
  int ans = t_l;
  rep(i, s_l - t_l + 1) {
    string tmp = s.substr(i, t_l);
    int count = 0;
    rep(j, t_l) {
      if (tmp[j] == t[j]) count++;
    }
    ans = min(ans, t_l - count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
N = int(input())
ls = [-1]
for i in range(N):
  ls += [int(input())]

ans = 0
p = 0
for i in range(1,N+1):
  if ls[i-1]+1<ls[i]:
    print(-1)
    break
  if ls[i-1]+1==ls[i]:
    if i==N:
      ans += (ls[i])
    p = ls[i]
    continue
  else:
    if i==N:
      ans += ls[i]
    ans += p
    p = ls[i]
else:
  print(ans)

Measured memory_bytes: 11048
import math

a, b, h, m = map(int, input().split())

rshort = h * 30 + m * 0.5
rlong = m * 6

kakudo = min(abs(rlong-rshort), 360-abs(rlong-rshort))

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo)))
print(ans)

Measured memory_bytes: 9440
import sys
INPUT = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 9)


def main():
    S = INPUT()
    T = INPUT()

    cnt = 0
    for i in range(3):
        if S[i] == T[i]: cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.io.*;
import java.util.StringTokenizer;

public final class Main{
    public static void main(String[] args){
        FastScanner stdIn = new FastScanner(System.in);
        
        long a = stdIn.nextInt();
        String s = stdIn.next();

        if(a >= 3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public long nextInt() {
        return Integer.parseInt(next());
    }

}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.1415926535897932
int main(){
	string s;
	cin>>s;
	int n=s.length();
	string a="24579";
	string b="0168";
	for (int i=0;i<5;i++)
		if (s[n-1]==a[i])
			cout<<"hon"<<endl;
	for (int i=0;i<4;i++)
		if (s[n-1]==b[i])
			cout<<"pon"<<endl;
	if (s[n-1]=='3')
		cout<<"bon"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
	long a,b,ans;
	char c;
	cin>>a>>c;
	switch(c)
	{
		case '+' :
			cin>>b;
			ans=a+b;
			break;
			
		case '-' :
			cin>>b;
			ans=a-b;
			break;
	}
	
	cout<<ans;
}

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

long long dp[110][100010] = {0};

int main(){
    int n,W;
    cin >> n >> W;
    vector<int> w(n);
    vector<long long> v(n);
    rep(i,n) cin >> w[i] >> v[i];

    rep(i,n){
        for(int sum_w=0;sum_w<=W;sum_w++){
            if(sum_w>=w[i]){
                dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
            }

            dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w]);
        }
    }

    cout << dp[n][W] << endl;

}

Measured memory_bytes: 79360
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        a: [[usize; n]; n],
    }
    let mut dp = vec![0; 1 << n];
    let p = 1000000000 + 7;
    dp[0] = 1;
    for i in 1..(1 << n) {
        let mut k = n;
        for j in 0..n {
            k -= (i >> j) & 1;
        }
        let mut way: u64 = 0;
        for j in 0..n {
            if a[k][j] == 1 {
                way += dp[i ^ (1 << j)];
            }
        }
        dp[i] = way % p;
    }
    println! ("{}", dp[(1 << n) - 1]);
}

fn main() {
    run();
}


Measured memory_bytes: 20732
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{


    ll k,b,m,q;
    ll c,d,t,i,j,a,n;
    vector<ll> v,s;
    map< pair<ll,ll> ,pair<ll,ll> > ma,sa;
    map< pair<ll,ll> ,pair<ll,ll> > :: iterator it,ki;
    string st,et;
    cin>>st;
    cin>>et;
    a = st.size()+et.size();
    for(i=0;i<a;i++){
        if(i%2==0){
            cout<<st[0];
            st.erase(st.begin());
        }
        else if(i%2==1){
            cout<<et[0];
            et.erase(et.begin());
        }
    }
    cout<<endl;

}


Measured memory_bytes: 256
# 46
from collections import Counter
import sys
import math


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def prime_factrize(n):
    if n < 2:
        return []
    p_factors = []
    while n % 2 == 0:
        p_factors.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            p_factors.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        p_factors.append(n)
    return p_factors


# 素因数とその個数のタプルのリストを返す
def get_prime_counts(n):
    p_factors = prime_factrize(n)
    counter = Counter(p_factors)
    return list(counter.items())


def main():
    n, p = LI()
    primes = get_prime_counts(p)
    ans = 1
    for base, exp in primes:
        if exp >= n:
            ans *= base ** (exp // n)
    print(ans)


main()


Measured memory_bytes: 66480
N = int(input())

C = []
for _ in range(N):
    a, b = map(int, input().split())
    C.append((a, b))
C = list(sorted(C, key=lambda x: x[1]))

t = 0
for a, b in C:
    if t + a > b:
        print("No")
        break
    t += a
else:
    print("Yes")


Measured memory_bytes: 39060
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String s = sc.next();
		
		// 計算
		int result = 0;
		
		for(int i = 0; i < 1000; i++){
		    int a = i/100;
		    int b = (i%100)/10;
		    int c = i%10;
		    //System.out.println(a + " " + b + " " + c);
		    int indexA = s.indexOf(String.valueOf(a));
		    if(indexA >= 0){
		        int indexB = s.indexOf(String.valueOf(b), indexA + 1);
		        if(indexB > 0){
		            int indexC = s.indexOf(String.valueOf(c), indexB + 1);
		            if(indexC > 0) result++;
		        }
		    }
		    //String r = ".*" + a + ".*" + b + ".*" + c + ".*";
		    //boolean bool = s.matches(r);
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
ll dp[87];
ll getval(ll n)
{
    if(n==0)return 2;
    if(n==1)return 1;
    if(dp[n]!=-1)return dp[n];
    return dp[n]=getval(n-1)+getval(n-2);
}
int main()
{
	FastIO;
	memset(dp,-1,sizeof(dp));
	int test=1, tc=1;
	while(test--){
        ll n;
        cin>>n;
        ll ans;
        cout<<getval(n)<<endl;
    }
	return 0;
}





Measured memory_bytes: 256
require "bigdecimal"
require "bigdecimal/math"

include BigMath

a, b, c = gets.chomp.split.map(&:to_i)
ab = BigDecimal((a * b).to_s) 
if a + b + 2 * ab.sqrt(1000) < c
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1916
import javax.swing.plaf.synth.SynthTextAreaUI;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double ans = 0;
        for(int i = 0; i < n; i++){
            double x = sc.nextDouble();
            String u = sc.next();
            if(u.equals("BTC")){
                x *= 380000;
            }
            ans += x;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 24276
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
    out.print(s.charAt(0));
    out.print(s.length()-2);
    out.println(s.charAt(s.length()-1));    
}
}

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

#define pi 2*acos(0)
#define INF 1e16
#define MIN 1e-9
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define m_p make_pair
#define p_b push_back
#define n_p(a) next_permutation(all(a))
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define rev(s) reverse(all(s))
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define mem(a,k) memset(a,k,sizeof a)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define u_b(X,V) upper_bound(X.begin(),X.end(),V)
#define l_b(X,V) lower_bound(X.begin(),X.end(),V)
#define cnt(s,c) count(all(s),c)

//bitwise helpers
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

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

    string s;

    cin >> s;

    int year = stoi(s.substr(0, 4));
    int month = stoi(s.substr(5, 2));
    int day = stoi(s.substr(8, 2));

    if(year > 2019) {
        cout << "TBD" << endl;
    }
    else if(year < 2019) {
        cout << "Heisei" << endl;
    }
    else {
        if(month > 4) {
            cout << "TBD" << endl;
        }
        else if(month < 4) {
            cout << "Heisei" << endl;
        }
        else {
            if(day > 30) {
                cout << "TBD" << endl;
            }
            else if(day <= 30) {
                cout << "Heisei" << endl;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,E,F,G,H,I;
  cin>>A>>B>>C>>D>>E>>F>>G>>H>>I;
  if(A-D==B-E&&B-E==C-F&&D-G==E-H&&E-H==F-I&&A-B==D-E&&D-E==G-H&&B-C==E-F&&E-F==H-I){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;
typedef unsigned long long int ull;

ull gcd(ull a,ull b){
  if(b>a) swap(a,b);
  ull p = a/b;
  ull r = a%b;
  while(r!=0){
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

ull lcm(ull a,ull b){
  if(a==0||b==0) return 0;
  return a/gcd(a,b)*b;
}


int n;
ull t[110];

int main(){
  scanf("%d",&n);
  REP(i,n) scanf("%lld",&t[i]);
  ull ans = 1;
  REP(i,n){
    ans = lcm(ans,t[i]);
  }
  printf("%lld\n",ans);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

ABs = []
for n in range(N):
    a, b = map(int, input().split())
    ABs.append((a, b))

ABs.sort()
ans = 0
for a, b in ABs:
    num = min(b, M) 
    ans += num * a
    M -= num
print(ans)


Measured memory_bytes: 19436
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
 	string s;
 	cin >> s;
 	if (stoi(s.substr(0, 2)) <= 12 && stoi(s.substr(0, 2)) >= 1 && stoi(s.substr(2, 2)) <= 12 && stoi(s.substr(2, 2)) >= 1){
 		cout << "AMBIGUOUS" << endl;
 	}else if (stoi(s.substr(0, 2)) <= 12 && stoi(s.substr(0, 2)) >= 1){
 		cout << "MMYY" << endl;
 	}else if (stoi(s.substr(2, 2)) <= 12 && stoi(s.substr(2, 2)) >= 1){
 		cout << "YYMM" << endl;
 	}else{
 		cout << "NA" << endl;
 	}
 	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[0 for i in range(N)] 
P=[0 for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  P[A-1]+=1
  P[B-1]+=1
  if H[A-1]>H[B-1]:
    L[A-1]+=1
  if H[B-1]>H[A-1]:  
    L[B-1]+=1

count=0 
for i in range(N):
  if P[i]==L[i]:
    count+=1
print(count)

Measured memory_bytes: 20136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> ans(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
            ans[0] += a[i];
        else
            ans[0] -= a[i];
    }
    for (int i = 1; i < n; i++)
    {
        ans[i] = 2 * a[i - 1] - ans[i - 1];
    }
    for (int i = 0; i < n; i++)
    {
        cout << ans[i];
        if (i == n - 1)
            cout << endl;
        else
            cout << " ";
    }
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
  int n, d, x;
  cin >> n;
  cin >> d >> x;
  std::vector<int> a(n);
  REP(i,n) cin >> a[i];

  lint sum = 0;
  REP(i,n){
    sum += (d-1)/a[i] + 1;
  }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int N = scan.nextInt();

                long count = 0;

                for (long i = 1; i <= N; i++) {
                	long position = i;
                	while (position <= N) {
                		count += position;
                		position += i;
                	}
                }

                System.out.println(count);

                scan.close();

        }
}

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

int main() {
  string N;
  
  cin >> N;
  if(N[0] == N[1] && N[1] == N[2]) {
    cout << "Yes" << endl;
  } else if(N[1] == N[2] && N[2] == N[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] count = new int[4];

		for(int i=0; i<N; i++){
			String S = sc.next();
			if(S.equals("AC")){
				count[0]++;
			}else if(S.equals("WA")){
				count[1]++;
			}else if(S.equals("TLE")){
				count[2]++;
			}else {
				count[3]++;
			}
		}
		System.out.println("AC x "+count[0]);
		System.out.println("WA x "+count[1]);
		System.out.println("TLE x "+count[2]);
		System.out.println("RE x "+count[3]);
    }
}


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

int gcd(int a, int b){ //最大公約数 O(log(min(a,b)))
    if(b==0) return a;
    return gcd(b,a%b);
}

int main(){
    int n,x;
    cin >> n >> x;
    if(n==1){
        int s;
        cin >> s;
        cout << abs(s-x) << endl;
        return 0;
    }
    vector<int> y(n+1);
    for(int i=0;i<n;i++){
        int s;
        cin >> s;
        y[i]=s;
    }
    y[n]=x;
    sort(y.begin(),y.end());
    vector<int> h(n+1);
    for(int i=0;i<n;i++){
        h[i+1]=y[i+1]-y[i];
    }
    int ans=h[1];
    for(int i=2;i<n+1;i++){
        ans=gcd(ans,h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXN 300000
int n,cnt[MAXN+5],ans[MAXN+5];
LL sum[MAXN+5];
LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
  return x*F;
}
int main()
{
  n=read();
  for(int i=1;i<=n;i++){
    int x=read();
    cnt[x]++,sum[cnt[x]]++;
  }
  for(int i=1;i<=n;i++)sum[i]+=sum[i-1];
  int t=0;
  for(int k=n;k>=1;k--){
    while(t<n&&sum[t+1]>=1LL*k*(t+1))t++;
    ans[k]=t;
  }
  for(int i=1;i<=n;i++)
  printf("%d\n",ans[i]);
}


Measured memory_bytes: 5504
N,K = gets.split.map(&:to_i)

ret = 0
(1..N).each do |i|
  # サイコロ確率
  d = 1.0 / N

  now = i
  loop do
    break if now >= K
    # 得点
    now *= 2
    # コイン表連続確率
    d /= 2
  end

  # 確率足し合わせ
  ret += d
end

puts ret

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int K, X;
    cin >> K >> X;
    for(int i = X - K + 1; i <= X + K - 1; i++) {
        cout << i << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
char a[15],b[15],j;

using namespace std;
int main()
{
    scanf("%s",&a[0]);
    int len = strlen(a);
    for(int i=0;i<len;i++){
        if(a[i]=='0'){
            b[j]='0';
            j++;
        }
        else if(a[i]=='1'){
            b[j]='1';
            j++;
        }
        
        else if(a[i]=='B'){
            if(j!=0){
                j--;
            }
        }
    }
    for(int i=0;i<j;i++){
        printf("%c",b[i]);
    }
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int64, int > Pi;
const int64 INF = 1LL << 58;
int N, M, X, node[100000];
struct edge{
  int to, height;
};
vector< edge > info[100000];
bool used[100000];
int64 Dijkstra(){
  priority_queue< Pi > que;
  que.push( Pi( X, 0));
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.second == N - 1) return X + node[N - 1] - p.first * 2;
    if(used[p.second]++) continue;
    for(int i = 0; i < info[p.second].size(); i++){
      edge e = info[p.second][i];
      if(e.height > node[p.second]) continue; //0以下になりそう(たぶん
      que.push( Pi( min( p.first - e.height, (int64)node[e.to]), e.to));
    }
  }
  return -1;
}

int main()
{
  scanf("%d %d %d", &N, &M, &X);
  for(int i = 0; i < N; i++){
    scanf("%d", node + i);
  }
  for(int i = 0; i < M; i++){
    int A, B, T;
    scanf("%d %d %d", &A, &B, &T);
    A--, B--;
    info[A].push_back((edge){ B, T});
    info[B].push_back((edge){ A, T});
  }
  printf("%lld\n", Dijkstra());
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    REP(i,n) cin >> l[i];
    sort(RALL(l));
    int ans = 0;
    REP(i,k) {
        ans += l[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
 
n = int(input())
#n,k = [int(i) for i in readline().split()]
#a = [int(i) for i in readline().split()]
s = input()

#1: 大きいのとつながる 

res = [(i&1)^(1 if c == "B" else 0) for i,c in enumerate(s)]
#print(res)

ans = 1
num = 0
MOD = 10**9+7
for i in res:
    if i: num += 1
    else:
        ans = ans*num%MOD
        num -= 1
if num != 0: ans = 0


for i in range(1,n+1):
    ans = ans*i%MOD 

print(ans)        





    

Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 const int mod=1e9+7; 
 ll L,R; ll f[64][2][2][2][2];
 int l[100],r[100]; 
 ll dfs(int x,int fl,int fr,int s,int ht)
 {	if(x<0)return 1;
 	ll &ans=f[x][fl][fr][s][ht];
	 	if(ans)return ans;	
		 	for(int i=0;i<2;i++)
			 	{		for(int j=0;j<2;j++){		
				 	int tl=fl,tr=fr,ts=s,tt=ht;		
					 	if(!tt&&i)if(i!=j)continue;	
						 		if((j&i)!=j)continue;	
								 		if(!tl&&j<l[x])continue;
										 			if(!tr&&i>r[x])continue;
													 	
										if(j>l[x])tl=1;if(i<r[x])tr=1;if(j<i)ts=1;if(j)tt=1;	
												ans+=dfs(x-1,tl,tr,ts,tt);
													}
				}
	ans%=mod;	return ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);	
		cin>>L>>R;
			for(int i=63;i>=0;i--)	{
					l[i]=(bool)((1ll<<i)&L);r[i]=(bool((1ll<<i)&R));
						}		
						cout<<dfs(63,0,0,0,0);	
							return 0;
}
							


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

int main() {
	char S[11];
	int N, K;
	cin >> N >> S >> K;
	for (int i = 0; i < N; i++)
	{
		if (S[i] != S[K-1])
		{
			S[i] = '*';
		}
	}
	cout << S;
	return 0;
}

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

int main()
{
   // Input
   int N;
   cin >> N;
   vector<int> vec(N);
   for (int i = 0; i < N; i++)
   {
      cin >> vec.at(i);
   }

   // Search max
   int alice = 0;
   int bob = 0;
   int index = 0;

   for (int j = 0; j < N; j++)   // 全N個を0にしつつ、
   {
      for (int i = 0; i < N; i++)   // ベクトルの中からmaxを探索
      {
         if (vec.at(index) < vec.at(i))
         {
            index = i;
         }
      }
      if (j%2==0) alice  += vec.at(index);
      if (j%2!=0) bob    += vec.at(index);
      vec.at(index) = 0;

   }
   cout << alice - bob << endl;
}

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

int main(){
  int A, B, K, M;
  
  cin >> A >> B >> K;
  
  if(A > B){
    M = B;
  }
  else{
    M = A;
  }
  
  int a[100] = {};
  int k = 0;
  
  for(int i = M; i > 0; i--){
    if(A % i == 0 && B % i == 0){
      a[k] = i;
      k += 1;
    }
  }
  
  cout << a[K-1] << endl;
  
  return 0;
}
      


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

const ll MOD = 1000000007;

ll f(ll n, ll k) {
    ll ret = 1;
    while (n--) {
        ret *= k;
        ret %= MOD;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n; cin >> n;
    cout << (f(n, 10) - 2 * f(n, 9) + f(n, 8) + 3ll * MOD) % MOD << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair

#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++)     
void fastIO(void);

void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);




ll vis[N],v[N],ans[N];
ll n,q;
vector<ll> g[N];

void solve(ll node, ll sum){
   if(vis[node]==1)
    return;
   vis[node]=1;
   ans[node] = sum+v[node];
   rep(i,g[node].size()){
      solve(g[node][i],ans[node]);
   }
}


int main()
{
   
   cin>>n>>q;
   ll a,b;
   rep(i,n-1){
      cin>>a>>b;
      g[a].push_back(b);
      g[b].push_back(a);      
   }
   rep(i,q){
      cin>>a>>b;
      v[a]+=b;
   }
   solve(1,0);
   rep1(i,n+1) cout<<ans[i]<<" ";
   cout<<endl;


   
}























void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}

void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m)+m)%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}


Measured memory_bytes: 27392
#include<cstdio>
#include<cstring>
using namespace std;
#define N 10
char s[N+5];
long long  ans;
int main()
{
	scanf("%s",s);
	int lens=strlen(s);
	int num=lens-1;
	int lim=1<<(num);
	for(int i=0;i<=lim-1;i++)
	{
		long long sum=s[0]-'0';
		for(int j=0;j<num;j++)
		if((1<<j)&i)
			ans+=sum,sum=s[j+1]-'0';
		else 
			sum=10*sum+s[j+1]-'0';
		ans+=sum;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256