akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <string>
#include <vector>

using Key = std::string;

struct Query {
    short kind;
    Key key, left, right;
    int value;
};

using Queries = std::vector<Query>;

void run(const Queries& queries);
int main(void) {
    int q;
    std::cin >> q;

    Queries queries{};
    for (int i = 0; i < q; ++i) {
        Query query{};

        std::cin >> query.kind;
        switch (query.kind) {
            case 0:
                std::cin >> query.key >> query.value;
                break;
            case 1:
            case 2:
                std::cin >> query.key;
                break;
            case 3:
                std::cin >> query.left >> query.right;
        }

        queries.push_back(query);
    }

    run(queries);
}

void run(const Queries& queries) {
    std::map<Key, int> my_map{};
    for (auto iter_query = queries.begin(); iter_query != queries.end();
         ++iter_query) {
        auto query = *iter_query;
        switch (query.kind) {
            case 0:
                /// insert
                if (my_map.find(query.key) == my_map.end())
                    my_map.insert(std::make_pair(query.key, query.value));
                else
                    my_map[query.key] = query.value;
                break;
            case 1:
                /// get
                if (my_map.find(query.key) == my_map.end())
                    std::cout << 0 << std::endl;
                else
                    std::cout << my_map[query.key] << std::endl;
                break;
            case 2:
                /// delete
                my_map.erase(query.key);
                break;
            case 3:
                /// dump
                for (auto iter = my_map.lower_bound(query.left);
                     iter != my_map.upper_bound(query.right); ++iter) {
                    auto member = *iter;
                    std::cout << member.first << ' ' << member.second
                              << std::endl;
                }
        }
    }
}


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


#define MAX_N 1000005

int a,b;

int main(){
	cin>>a>>b;

	if(a==b){
		puts("Draw");
	}
	else if(a==1){
		puts("Alice");
	}
	else if(b==1){
		puts("Bob");
	}
	else {
		puts(a>b?"Alice":"Bob");
	}

	return 0;
}

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

vector< long long > tab; 
stack< long long > S;
long long n, q, x, sp[100010], j;
map< pair< int, long long >, long long > mapka;
priority_queue< pair< int, long long > > Q;
pair< int, long long > p;
int i;
long long w;
int bs( int pocz, int kon, long long v )
{
	if( pocz == kon )return pocz;
	int mid = ( pocz + kon ) / 2;
	if( tab[mid] >= v )return bs( pocz, mid, v );
	else return bs( mid+1, kon, v );
}	
void licz( )
{
	while( !Q.empty() )
	{
		p = Q.top();
		Q.pop();
		i = p.first;
		x = p.second;
		w = mapka[p];
//		cout<<i<<" "<<x<<" "<<w<<endl;
		if( i == 0 )
		{
			sp[1] += w, sp[x+1] -= w;
			continue;
		}
		if( x <= tab[i-1] )
		{	
			j = bs( 0, i-1, x );
//			cout<<"bs "<<j<<endl;
			if( mapka[ make_pair( j, x ) ] == 0 )
			{
				Q.push( make_pair( j, x ) );
//				cout<<"wrzucam"<<endl;
			}
			mapka[ make_pair( j, x ) ] += w;
		}
		else
		{
			if( mapka[ make_pair( i-1, tab[i-1] ) ] == 0 )Q.push( make_pair( i-1, tab[i-1] ) );
			mapka[ make_pair( i-1, tab[i-1] ) ] += ( ( x/tab[i-1] ) * w );
			if( mapka[ make_pair( i-1, x%tab[i-1] ) ] == 0 )Q.push( make_pair( i-1, x%tab[i-1] ) );
			mapka[ make_pair( i-1, x%tab[i-1] ) ] += w; 
		}	
	}
}
int main()
{
//	ios_base::sync_with_stdio( 0 );
//	cin.tie( 0 );
	scanf( "%lld%lld", &n, &q );
	for( int a = 1; a <= q; a++ )
	{
		scanf( "%lld", &x );
		while( S.size() && S.top() >= x )S.pop();
		S.push( x ); 
	}
	while( !S.empty() )
	{
		tab.push_back( S.top() );
		S.pop();	
	}
	tab.push_back( n );
	reverse( tab.begin(), tab.end() );
//	for( int a = 1; a < tab.size(); a++ )cout<<tab[a]<<" ";
//	cout<<endl;
	mapka[ make_pair( tab.size() - 1, tab.back() ) ] = 1;
	Q.push( make_pair( tab.size()-1, tab.back() ) );
	
	licz( );
	for( int a = 1; a <= n; a++ )
	{
		sp[a] += sp[a-1];	
		printf( "%lld\n", sp[a] );
	}
	return 0;	
	
}

Measured memory_bytes: 47404
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
int main()
{
  using ll = long long;
  using vll = vector<ll>;
  ll N, K;
  cin >> N >> K;
  vll height(N), dp(N);
  for (auto &i : height) { cin >> i; }
  dp[0] = 0;
  for (auto i = 1; i < N; ++i) {
    ll minH = LLONG_MAX;
    for (auto j = i-1; j >= 0 && i - j <= K ; --j) {
      minH = min(minH, dp[j] + abs(height[j] - height[i]));
    }
    dp[i] = minH;
  }
  cout << dp[N-1];
}


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

long long gcd(long long a, long long b) {
	long long old_a, old_b;
	while (b != 0) {
		old_a = a;
		a = b;
		old_b = b;
		b = old_a % b;
	}
	return old_b;
}

long long lcm(long long a, long long b) {
	long long g = gcd(a, b);
	return a / g * b;
}

int main() {
	long long n, t[110], ans = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		ans = lcm(ans, t[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<30)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

int a[220000];
int ans[220000];
vector<int> dp(220000, INF);
vector<int> edge[220000];


void dfs(int x, int last = -1){
    int changed_index = lower_bound(dp.begin(), dp.end(), a[x]) - dp.begin();
    int last_value = dp[changed_index];
    
    dp[changed_index] = a[x];
    ans[x] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    for(auto to:edge[x]){        
        if(to == last)continue;
        dfs(to, x);
    }
    dp[changed_index] = last_value;
}


int main(){
    int n, u, v;
    cin >> n;
    for(int i = 0;i < n;i++)cin >> a[i];
    for(int i = 0;i < n-1;i++){
        cin >> u >> v;u--,v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(0);

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

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

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

	int x;
	cin >> x;

	if (x == 7 || x == 5 || x == 3) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	m := make(map[int]struct{})
	for i := 0; i < n; i++ {
		t := readInt()
		if _, ok := m[t]; ok {
			fmt.Println("NO")
			return
		}
		m[t] = struct{}{}
	}

	fmt.Println("YES")
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 7296
function main(input){
    let lines = input.split("\n").map(line=>line.toLowerCase());
    let target = lines.shift().toLowerCase();
    let count = 0;
    for(let i=0;i<lines.length-1;i++){
        let words = lines[i].split(" ");
        for(let j=0;j<words.length;j++){
            if(words[j]===target) count++;
        }
    }
    console.log(count);
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 15156
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " = " << (x) << endl
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

int32_t main()
{
	SYNC
	int n,k; cin >> n >> k;
	vi v(n);
	rep(i,0,n)	cin >> v[i];
	sort(all(v));
	int ans = 0;
	rep(i,0,k)	ans += v[i];
	cout << ans;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  vector<int> ans(N);
  int count = 0;
  for(int i = N - 1; i >= 0; i--) {
    int sum = 0;
    for(int j = 2; j * (i + 1) - 1 < N; j++) {
      sum += ans.at(j * (i + 1) - 1);
    }
    sum %= 2;
    ans.at(i) = (data.at(i) + sum) % 2;
    if(ans.at(i) == 1) {
      count++;
    }
  }
  cout << count << endl;
  for(int i = 0; i < N; i++) {
    if(ans.at(i) == 1) {
      cout << i + 1 << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 4756
/* Author - Ankur Kumar Singh 
	IDE :- Offine Linux
	
 ---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
/* variable type :- */
	# define ll long long int
	# define ld long double
	# define I int
/* map */
	# define abc  pair<long long int,long long int>
	map < pair < abc,abc > , long long int > pqr;
	map <  pair < long long int,long long int > ,long long int > xyz;	
/* vector */
	# define pb push_back
	# define pp pop_back
	# define ff first
	# define ss second
	# define mp make_pair
	# define ac accumulate
/* pairs */
	vector<pair<ll,ll>>a;
	vector<pair<pair<int,int>,pair<int,int> > > b;
	vector<pair<ll,pair<ll,ll>>>c;
 
bool compare( const pair<long long int,long long int>&x , const pair<long long int,long long int>&y )
{
	return x.ff>y.ff;
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
        return (a.ss < b.ss);
}
int main()
{
	ll x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	ll d1=x2-x1,d2=y2-y1;
	ll y3=y2+d1;
	ll y4=y1+d1;
	ll x3=x2-d2;
	ll x4=x1-d2;
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int,int>>> q(n);
  for (int i = 0; i < m; i++) {
    int l, r, c;
    cin >> l >> r >> c;
    q[r-1].emplace_back(l-1,c);
  }
  ll B = 1;
  while (B < n) B *= 2;
  vector<ll> mi(B*2, 1e18);
  for (int i = 0; i < n; i++) {
    ll v = 1e18;
    if (i == 0) v = 0;
    for (auto p : q[i]) {
      int l = p.first, c = p.second;
      ll val = mi[l+=B];
      for (; l; l >>= 1) {
	if (l%2 == 0)
	  val = min(val, mi[l+1]);
      }
      v = min(v, val+c);
    }
    mi[i+B] = v;
    for (int j = (i+B)/2; j; j >>= 1) {
      mi[j] = min(mi[j*2], mi[j*2+1]);
    }
  }
  ll ans = mi[B+n-1];
  if (ans >= 1e17) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 7680
from collections import deque
nq = list(map(int, input().split()))
n = nq[0]
q = nq[1]
process = [input().split() for _ in range(n)]
ps = deque([[p[0], int(p[1])] for p in process])
time = 0
ans = []

while len(ps):
    p = ps.popleft()
    if p[1] > q:
        p[1] -= q
        ps.append(p)
        time += q
    else:
        time += p[1]
        ans.append((p[0], str(time)))
        
for a in ans:
     print(' '.join(a))   
        



Measured memory_bytes: 24080
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,ans=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
    	cin>>a;
		if(a>=k) ans++; 
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
mod = 1000000007
ans = 0
list = [[0,0] for i in range(N)]
I = 0
J = 0
for i in range(N):
  for j in range(i):
    if A[j] < A[i]:
      list[i][0] += 1
      I += 1
      J += 1
  for k in range(i+1,N):
    if A[k] < A[i]:
      list[i][1] += 1
      J += 1
#print(list)
for i in range(N):
  ans += K*list[i][1] + K*(K-1)*(list[i][0]+list[i][1])//2                     
print(ans%mod)
                          
                          
                          
                          
                          
                          
                          
         


Measured memory_bytes: 9116
s = input()
ans = 1
for i in range(len(s)):
    if i %2 == 0:
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
            pass
        else:
            ans = 0
    else:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
            pass
        else:
            ans = 0
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		if(i%2==0){
			if(s[i] == 'L'){
				cout << "No";
				return 0;
			}
		}else{
			if(s[i] == 'R'){
				cout << "No";
				return 0;
			}
		}	
	}	
	cout << "Yes";
	return 0;
}

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

using namespace std;

bool is_digit(char c) {
    return c >= '0' && c <= '9';
}

int main() {
    long long n;
    cin >> n;
    long long res = 0;
    for (long long i = 1; i <= n; ++i) {
        long long j = n / i;
        res += i * (j * (j + 1) / 2);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		boolean[] map = new boolean[M];
		Arrays.fill(map, true);
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		}
		
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (map[i])
				ans++;
		}
		
		System.out.println(ans);
	}
	
}


Measured memory_bytes: 24148
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
# Tree
class Tree
  attr_accessor :edges

  def initialize(ar,n,*option)
    @ar = ar
    @edges = build_edges(@ar,n)
  end

  def build_edges(ar,n)
    edges = Array.new(n){[]}
    ar.size.times do |i|
      edges[ar[i][0]-1] << [ar[i][1],ar[i][2]]
      edges[ar[i][1]-1] << [ar[i][0],ar[i][2]]
    end
    edges
  end

  def route(st, en, stack=[], current=nil) 
    # 外から呼ぶときはcurrentに値がない
    current = st if current.nil?

    stack << current
    # 見つかった
    return stack if current==en

    nears = @edges[current-1].map{|i|i[0]}
    nears.each do |i|
      # 同じ辺は探索しない
      next if stack.include?(i)

      ans = route(st,en,stack,i)
      # 見つかってたら返す
      return ans if ans[-1]==en
    end
    # 見つからない
    stack.pop
    stack
  end
end

n=gi
abc=(n-1).times.map{gsmi}

tree=Tree.new(abc,n)
ans=[]

q,k=gsmi
dist=Array.new(n,10**15)
dist[k-1]=0

stack=[k]
while stack.size>0
  tar=stack.pop
  to=tree.edges[tar-1]
  d_base = dist[tar-1]
  to.each do |j,d|
    d1=d_base+d
    if dist[j-1]>d1
      dist[j-1]=d1
      stack<<j
    end
  end
end

#pu dist:dist.to_s

q.times do |qq|
  x,y=gsmi
  ans<< dist[x-1]+dist[y-1]
end
puts ans

Measured memory_bytes: 44540
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
#define INFTY 1<<29
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 10000007;
// static const int MAX = 100005;
static const int NMAX = 1005;
static const int KEY = 4096;


// typedef priority_queue<int, greater<int>> RevQ;
int N, M;
int a, b;
vector<int> q[NMAX], p(NMAX), C(NMAX);


// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }

int main(){
  cin >> N;
  int flag = 0;
  REP(i, 1, 10) {
    a = N/i;
    b = N%i;
    if (a < 10 && b == 0) {
      flag = 1;
      cout << "Yes" << endl;
      break;
    }
  }
  if (flag == 0) {
    cout << "No" << endl;
  }
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

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

   string S;
   cin>>S;
   vector<int>a(S.size());
   for(int i=0;i<S.size();i++)a[i] = atoi(S.substr(i,1).c_str());
   //for(int i=0;i<S.size();i++)cout<<a[i]<<endl;
   int bit = pow(2,S.size()-1);
   //cout<<bit<<endl;
   ll ans = 0;
   for(int i=0;i<bit;i++){
      //cout<<i<<endl;
      ll buf = a[0];
      for(int j=1;j<S.size();j++){
         if(i & (1<<(j-1))){
            ans += buf;
            buf = a[j];
         }
         else{
            buf = 10*buf+a[j];
         }
      }
      ans += buf;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, cnt = 0; cin >> N;
  vector<vector<pair<int, bool>>> honest(N, vector<pair<int, bool>> (0));
  for(int i = 0; i < N; i++) {
    int A; cin >> A;
    for(int j = 0; j < A; j++) {
      int x; bool y; cin >> x >> y; x--;
      honest.at(i).push_back(make_pair(x, y));
    }
  }
  for(int i = 0; i < (1 << N); i++) {
    bitset<15> board(i);
    bool judge = false;
    for(int j = 0; j < N; j++) {
      if(!board.test(j)) continue;
      for(int k = 0; k < honest.at(j).size(); k++) {
        if(honest.at(j).at(k).second != board.test(honest.at(j).at(k).first)) {
          judge = true;
          break;
        }
      }
      if(judge) break;
    }
    if(judge) continue;
    cnt = max(cnt, (int)board.count());
  }
  cout << cnt << endl;
}

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

int main(void)
{
    int n,i,ans=0;
    //int* c,v;
    scanf("%d",&n);
    //c=malloc((n)*sizeof(int));
    //v=malloc((n)*sizeof(int));
    int c[n],v[n];
    for(i=0; i<n; i++){
        scanf("%d",&v[i]);
    }
    for(i=0; i<n; i++){
        scanf("%d",&c[i]);
    }
    
    for(i=0; i<n; i++){
        if(v[i]>c[i]){
            ans+=v[i]-c[i];
        }
    }
    printf("%d",ans);
    return 0;
}

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

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

int main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    queue<pair<int,int>> que;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                que.push(make_pair(i,j));
                d[i][j]=0;
            }else{
                d[i][j]=-1;
            }
        }
    }
    while(!que.empty()){
        auto p=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&d[nx][ny]==-1){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
    int ans=-INF;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(ans,d[i][j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13456
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.max(a+b,Math.max(a-b,a*b)));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    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 int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25312
mod=10**9+7
s=input()
n=len(s)
dp=[[0]*4 for _ in range(n+1)]
abc="ABC"
dp[n][3]=1
for i in range(n-1,-1,-1):
    for j in range(4):
        if j==3:
            m=0
            if s[i]=="?":
                m=3
            else:
                m=1
            dp[i][j]=(m*dp[i+1][j])%mod
        else:
            m1=0
            m2=0
            if s[i]=="?":
                m1=3
                m2=1
            else:
                m1=1
                if s[i]==abc[j]:
                    m2=1
                else:
                    m2=0
            dp[i][j]=(m1*dp[i+1][j]+m2*dp[i+1][j+1])%mod
print(dp[0][0])


Measured memory_bytes: 27600
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<vector>
#include<map>
using namespace std;
#define fr first
#define sc second
#define INFTY 1000000
typedef pair< int,int > iiP;
typedef pair< int,iiP > P;
//盗賊の人数 , 場所 , カネ
struct edge{
  int to,kyori,people;
  edge(){}
  edge(int to,int kyori,int people):to(to),kyori(kyori),people(people){};
};
int N,M,L;
int min_people[101][101];
//場所 , カネ
vector< vector<edge> > info;
int dijkstra();
int main(){
  while(cin >> N >> M >> L && (N||M||L)){
      info.resize(N + 1);
      for(int i=0,a,b,d,e;i<M;i++){
	cin >> a >> b >> d >> e;
	info[a].push_back(edge(b,d,e));
	info[b].push_back(edge(a,d,e));
      }
      cout << dijkstra() << endl;
      info.clear();
    }
}
int dijkstra(){
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
      min_people[i][j] = INFTY;
    }
  }
  
   priority_queue< P,vector<P>,greater<P> > que;
  que.push(P(0,iiP(1,L)));

  while(!que.empty()){
    P p = que.top();
    int peop = p.fr , now = p.sc.fr , money = p.sc.sc ;
    que.pop();
    if( now == N ) return peop;
    if( peop > min_people[now][money]) continue;
    for(int i=0;i<info[now].size();i++){
      edge e = info[now][i];
      if ( peop < min_people[e.to][money - e.kyori] && money >= e.kyori){ //やとってみよ
	min_people[e.to][money - e.kyori] = peop;
	que.push(P(peop,iiP(e.to,money-e.kyori)));
      }
      if( peop + e.people < min_people[e.to][money]){ //やとうのヤダ
	min_people[e.to][money] = peop + e.people;
	que.push(P(min_people[e.to][money],iiP(e.to,money)));
      }
    }
  }
}

Measured memory_bytes: 1476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
ll dp[3010][3010];
void Main(){
    ll n;cin>>n;
    ll t;cin>>t;
    vector<pair<ll,ll>> x(n);
    For(i,0,n) cin>>x[i].first>>x[i].second;
    sort(ALL(x));
    vector<ll> a(n),b(n);
    For(i,0,n){
        a[i]=x[i].first;
        b[i]=x[i].second;
    }
    For(i,0,3010){
        dp[0][i]=0;
        dp[i][0]=0;
    }
    For(i,0,n){
        For(j,0,t){
            dp[i+1][j]=dp[i][j];
            ans=max(ans,dp[i+1][j]+b[i]);
            if(j>=a[i]) dp[i+1][j]=max(dp[i+1][j],dp[i][j-a[i]]+b[i]);
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 70912
class Problem
  attr_accessor :a, :b, :c, :n, :m, :k, :h, :w, :x, :y, :ans
  def initialize
    @h, @w, @k = gets.to_s.split.map{ |v| v.to_i }
    @c = Array.new(h){ gets.chomp }
  end

  def solve
    ans = 0
    0.upto(2**h-1) do |hbit|
      0.upto(2**w-1) do |wbit|
        ans += 1 if cnt(hbit,wbit) == k
      end
    end
    puts ans
  end

  def cnt(hbit, wbit)
    ans = 0
    h.times do |y|
      w.times do |x|
        next if c[y][x] == "."
        next if hbit[y] == 1
        next if wbit[x] == 1
        ans += 1
      end
    end
    ans
  end
end

pb = Problem.new
pb.solve

Measured memory_bytes: 14316
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define pi acos(-1.0)
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int main()
{
	//cwk;
	double r;
	cin>>r;
	printf("%.10lf\n",2.0*pi*r);

	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int m = INF;
    int len = S.length();
    rep(i, len-1) {
        if(S[i] != S[i+1]) {
            m = min(m, max(i+1, len-i-1));
        }
    }
    if( m == INF) {
        cout << S.length() << endl;
        return 0;
    }
    cout << m << endl;

     return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb emplace_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720000000000ll;

void solve()
  {
   int n;
   cin>>n;
   int mx = n/1000;
   int ans = (mx+1)*1000 - n;
   if(ans%1000 == 0)
     ans = 0;
   cout<<ans;
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3608
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
vector<int> dp(100010, INF);

int main(){
    int N;
    cin >> N;
    dp[0] = 0;
    for(int i = 1; i <= N; i++){
        dp[i] = dp[i-1] + 1;
        for(int j = 1; j <= 7; j++){
            if(i >= pow(6, j)){
                dp[i] = min(dp[i], dp[i-pow(6, j)] + 1);
            }
            if(i >= pow(9, j)){
                dp[i] = min(dp[i], dp[i-pow(9, j)] + 1);
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 640
s=input()
if s[5]=='0':
  m=int(s[6])
else:
  m=int(s[5:7])
if s[8]=='0':
  d=int(s[9])
else:
  d=int(s[8:10])
x='TBD'
if m<4:
  x='Heisei'
elif m==4 and d<=30:
  x='Heisei'
print(x)
  

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ull n,k,s;
    cin>>n>>k>>s;
    ulvec a(n,s);
    if(k!=0){
        if(s!=1000000000){
            for(int i=k;i<n;i++)a[i]=s+1;
        }else{
            for(int i=k;i<n;i++)a[i]=1;
        }
    }else{
        if(s!=1000000000){
            for(int i=0;i<n;i++)a[i]=s+1;
        }else{
            for(int i=0;i<n;i++)a[i]=1;
        }
    }
    rep(i,n)cout<<a[i]<<' ';
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<string.h>
#define min(a,b) (a<b?a:b)
int N,T[20][20],dp[1<<20];

int main()
{
	for(;;)
	{
		memset(dp,0x7f,sizeof(dp));
		dp[0]=0;
		scanf("%d",&N);
		if(!N)break;
		for(int i=0;i<N;i++)
			for(int j=0;j<=N;j++)
				scanf("%d",&T[i][j]); 
		for(int i=0;i<1<<N;i++)
		{
			for(int j=0;j<N;j++)
			{
				if(!(i>>j&1))
				{
					int tmp=T[j][0];
					for(int k=0;k<N;k++)
						if(i>>k&1)
							tmp=min(tmp,T[j][k+1]);
					dp[i|1<<j]=min(dp[i|1<<j],dp[i]+tmp);
				}
			}
		}
		printf("%d\n",dp[(1<<N)-1]);
	}
	return 0;
}

Measured memory_bytes: 5132
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m, c; cin>>n>>m>>c;
  int ans=0; int b[21];
  for(int i=0; i<m; i++) cin>>b[i];
  for(int i=0; i<n; i++){
    int s=c;
    for(int j=0; j<m; j++){
      int a; cin>>a;
      s+=(a*b[j]);
    }
    if(s>0) ans++;
  }
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>


int main(void)
{
	int i, a, b, c, na, nb, nc;

	while(scanf("%d%d%d", &a, &b, &c)==3)
	{
		for(i=0;;i++)
		{
			if(a%2==1 || b%2==1 || c%2==1) break;
			na=(b+c)/2;
			nb=(c+a)/2;
			nc=(a+b)/2;
			if(na==nb && nb==nc)
			{
				i=-1;
				break;
			}
			a=na;
			b=nb;
			c=nc;
		}
		printf("%d\n", i);
	}

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void){
    int X,Y,A,B,C, P[100000],Q[100000],R[100000];
    std::cin >> X >> Y >> A >> B >> C;
    for(int a=0;a<A;a++){
        std::cin >> P[a];
    }
    for(int a=0;a<B;a++){
        std::cin >> Q[a];
    }
    for(int a=0;a<C;a++){
        std::cin >> R[a];
    }
    qsort(P,A,sizeof(int),compare_int);
    qsort(Q,B,sizeof(int),compare_int);
    std::vector<int> vec;
    for(int a=0;a<X;a++){
        vec.push_back(P[a]);
    }
    for(int a=0;a<Y;a++){
        vec.push_back(Q[a]);
    }
    for(int a=0;a<C;a++){
        vec.push_back(R[a]);
    }
    std::sort(vec.begin(),vec.end(),std::greater<int>());
    long long int count=0;
    for(int a=0;a<X+Y;a++){
        count+=vec[a];
    }
    std::cout << count;
}


Measured memory_bytes: 4080
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		if(a > b*2){
			System.out.println(a-b*2);
		} else {
			System.out.println(0);
		}
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22484
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i > 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

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

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

using namespace std;


class D {
	int n, MAX_ORDER;
	string s;
public:
	D()
	{
		cin >> n >> MAX_ORDER >> s;
	}
	void solve()
	{
		int ans{ 1 };
		int streak{ 1 };
		int n_order{ (s[0] == '0') ? 1 : 0 };
		int left{ 0 }, right{ 1 };
		char currentGroup{ s[0] };

		while (right < n)
		{
			if (left >= right)
			{
				if (left >= n)
					break;
				right = left + 1;
				n_order = (s[left] == '0') ? 1 : 0;
				currentGroup = s[left];
				continue;
			}

			if (s[right] != currentGroup)
			{
				if (s[right] == '0') // 1 -> 0
				{
					currentGroup = '0';
					if (n_order >= MAX_ORDER)
					{
						char last{ s[left++] };
						while (!(s[left] == '1' && last == '0') && left < right)
						{
							last = s[left++];
						}
					}
					else // (n_order < MAX_ORDER)
					{
						++n_order;
					}
				}
				else // (s[right] == '1') // 0 -> 1
				{
					currentGroup = '1';
				}
			}

			chmax(ans, right - left + 1);
			++right;
		}
	
		cout << ans << endl;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 512
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a = nl()

print(max(a) - min(a))

Measured memory_bytes: 3828
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i]-'0');
	}
	return d;
}
int N,M;
int main()
{
	cin >> N >> M;
	cout << (N - 1) * N / 2 + (M - 1) * M / 2;


}

Measured memory_bytes: 256
# coding: utf-8
import bisect
N,M=map(int,input().split())
L=[[] for i in range(N)]
#print(L)
D=[]

for i in range(M):
    p,y=map(int,input().split())
    L[p-1].append(y)
    D.append([p,y])

#print(L)

for i in range(N):
    L[i].sort()
    
#print(L)

for i in range(M):
    ans=str(D[i][0]).zfill(6)+str(bisect.bisect_left(L[D[i][0]-1],D[i][1])+1).zfill(6)
    print(ans)

Measured memory_bytes: 76320
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string a, b, c;
    //string a1, b1, c1;
    cin >> a >> b >> c;
    transform(a.begin(), a.end(), a.begin(), ::toupper);
    transform(b.begin(), b.end(), b.begin(), ::toupper);
    transform(c.begin(), c.end(), c.begin(), ::toupper);

    cout << a[0] << b[0] << c[0] << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
*A, = map(int, input().split())


def isOk(m):
    k = 0
    for a in A:
        if a > m:
            k += a//m
            if a % m == 0:
                k -= 1
    if k <= K:
        return True
    else:
        return False


l, r = 10**19, 1
while abs(r-l) > 1:
    m = (l+r)//2
    if isOk(m):
        l = m
    else:
        r = m

if isOk(r):
    print(r)
else:
    print(l)


Measured memory_bytes: 95336
N, M = gets.chomp.split(" ").map(&:to_i)
K = []
I = Hash.new{|h, k| h[k] = Array.new}
M.times{|i|
  a, = gets.chomp.split(" ").map(&:to_i)
  c = gets.chomp.split(" ").map(&:to_i)
  K << [a, c.inject(0){|r, cc| r + (1 << (cc - 1))}]
  c.each{|cc| I[cc] << i}
}

INF = 10 ** 8
DP = Array.new(1 << N, INF)
DP[0] = 0
bef = [0]
(1..N).each{|n|
  nxt = []
  I[n].each{|i|
    bef.each{|b|
      prz, key = K[i]
      sum = DP[b] + prz
      kys = b | key
      DP[kys] = sum if DP[kys] > sum
      nxt << kys
    }
  }
  bef = nxt.uniq
}

puts DP[(1 << N) - 1] == INF ? -1 : DP[(1 << N) - 1]


Measured memory_bytes: 7928
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse = True)
#print(C)
sosu = 10 ** 9 + 7
K = dict()
K[-1] = 1
K[0] = 1
for i in range(1, N+1):
    a = K[i-1] * 2 % sosu
    K[i] = a
ans = 0
for i in range(N):
    #for j in range(1,circle):##j番目に大きい
    #    kkk = c(i, j-1) * 2 ** (N-i-1)###i+1番目に大きいものがj番目に大きくなるような選び方
    #    ans += C[i] * kake * j * kkk
    ans += (C[i] * K[N] * (K[i] + i * K[i-1]) * K[N-i-1]) % sosu
    ans %= sosu
print(int(ans))







Measured memory_bytes: 44068
import sys, math
x = int(sys.stdin.readline())

L = [i**5 for i in range(10000)]
flag = False
for i in range(10000):
    for j in range(10000):
        if L[i] - L[j]==x:
            print(i, j)
            flag = True
            break
        elif L[i] + L[j]==x:
            print(i, -j)
            flag = True
            break
    if flag ==True:
        break
else:
    print('No')

Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((b * 10 + c) % 4 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <map>

typedef long long int ll;
using namespace std;
int main() {
	int N,x;
	cin>>N;
	string y;
	vector<string> name(N," ");
	vector<int> point(N,0);
	vector<string> check_name(N," ");
	vector<int> check(N,0);
	vector<int> score(N,0);
	vector<int> num;
	for(int i=0;i<N;i++){
		cin >> y>>x;
		name[i]=y;
		check_name[i]=y;
		point[i]=x;
		check[i]=x;
	}
	sort(name.begin(),name.end());
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(name[i]==check_name[j]){
				num.push_back(point[j]);
			}
		}
		sort(num.begin(),num.end());
		for(int j=0;j<num.size();j++){
			for(int k=0;k<N;k++){
				if(name[i]==check_name[k]&&num[num.size()-1-j]==point[k]){
					score[i+j]=k+1;
				}
			}
		}
		i=i+num.size()-1;
		num.clear();
	}
	/*sort(check.begin(),check.end());
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(check[i]==point[j]){
				score[j]=N-i;
				break;
			}
		}
	}*/
	for(int i=0;i<N;i++){
		cout<<score[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	ll N, M, K;
	cin >> N >> M >> K;

	vector<ll> Ai(N+1,0);
	vector<ll> Bi(M+1,0);
	ll t;

	ll sa = 0;
	ll sb = 0;
	for (ll i = 1; i <= N; ++i)
	{
		cin >> t;
		Ai.at(i) = t + Ai.at(i - 1);
		if (Ai.at(i) <= K)
		{ 
			sa++;
		}
	}
	for (ll i = 1; i <= M; ++i)
	{
		cin >> t;
		Bi.at(i) = t + Bi.at(i - 1);
		if (Bi.at(i) <= K)
		{
			sb++;
		}
	}

	ll read_cnt = 0;
	ll last_j = sb;
	for (ll i = 0; i <= sa; ++i)
	{
		for (ll j = last_j; j >= 0; --j)
		{
			if ((Ai.at(i) + Bi.at(j)) <= K)
			{
				read_cnt = max(read_cnt, (i + j));
				last_j = j;
				break;
			}
		}
	}

	cout << read_cnt << endl;
	return 0;
}

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

int main() {
    ll K, N; cin >> K >> N;
    vector<ll> v(N);
    cin >> v[0];
    ll max_dis = 0;
    for (int i = 1; i < N; ++i) {
        cin >> v[i];
        ll prev_dis = min(v[i] - v[i - 1], K - (v[i] - v[i - 1]));
        max_dis = max(max_dis, prev_dis);
    }
    ll firsthouse_lasthouse_dis = min(v[0] + K - v[N - 1], v[N - 1] - v[0]);
    max_dis = max(max_dis, firsthouse_lasthouse_dis);
    cout << K - max_dis << endl;
}

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

int main(){
  char word[11],sent[50],end[20]="END_OF_TEXT";
  int cnt=0;
  scanf("%s",word);
  while(1){
    scanf(" %s",sent);
    if(strcmp(sent,end)){
      if(!(strcasecmp(sent,word))) cnt+=1;}
    else{
      printf("%d\n",cnt);
      break;}
    }
  return 0;}

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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  ll sum = 0;
  rep(i, n) sum += a.at(i);
  bool flag = false;
  if(sum >= h) flag = true;
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3652
N, M = map(int, input().split())

table1 = ''
table2 = ''

for i in range(2 * N):
    if i < N:
        table1 += input()
    else:
        table2 += input()
        
count = 0
for i, j in zip(table1, table2):
    if i != j:
        count+=1
print(count)


Measured memory_bytes: 13444