akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> V(N); cin >> V;
    vector<int> C(N); cin >> C;

    int ans = 0;
    for (int i = 0; i <= N; i++)
        if (V[i] > C[i]) ans += V[i] - C[i];
    
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = stdin.ReadInt()
	}

	c := NewCounter()
	for i := 0; i < n; i++ {
		c.Increment(a[i])
	}

	sum := 0
	for _, k := range c.Keys() {
		v := c.Get(k)
		sum += v * (v - 1) / 2
	}

	for i := 0; i < n; i++ {
		v := c.Get(a[i])
		count := sum
		count -= v * (v - 1) / 2
		count += (v - 1) * (v - 2) / 2
		stdout.Println(count)
	}

}

type Counter map[interface{}]int

func NewCounter() *Counter {
	return &Counter{}
}

func (c *Counter) put(key interface{}, v int) {
	d := map[interface{}]int(*c)
	d[key] = v
}

func (c *Counter) Increment(key interface{}) {
	c.put(key, c.Get(key)+1)
}

func (c *Counter) Decrement(key interface{}) {
	v := c.Get(key)
	if v > 0 {
		c.put(key, v-1)
	}
}

func (c *Counter) Get(key interface{}) int {
	d := map[interface{}]int(*c)
	if v, ok := d[key]; ok {
		return v
	} else {
		return 0
	}
}

func (c *Counter) Keys() []interface{} {
	d := map[interface{}]int(*c)
	keys := []interface{}{}
	for key := range d {
		if c.Get(key) > 0 {
			keys = append(keys, key)
		}
	}
	return keys
}

func (c *Counter) String() string {
	strs := []string{}
	for _, key := range c.Keys() {
		strs = append(strs, fmt.Sprintf("%v => %d", key, c.Get(key)))
	}
	return "[" + strings.Join(strs, ", ") + "]"
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 26516
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner S = new Scanner(System.in);
		
		while(true){
			int n = S.nextInt();
			int x = S.nextInt();
			
			if(n == 0 && x == 0)
				break;
			
			int count = 0;
		
			for(int i = 1;i <= n - 2;i++){
				for(int j = i + 1;j <= n - 1;j++){
					for(int k = j + 1;k <= n;k++){
						if(i + j + k == x)
							count++;
					}
				}
			}
			
			System.out.println(count);
		}
		
	}
}

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

int main() {
 ll x;
  cin >> x;
  for(ll i=-120;i<120;i++){
    for(ll j=-120;j<120;j++){
      if(pow(i,5.0)-pow(j,5.0)==x){
    cout << i << " " << j << endl;
    return 0;
      }
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin>>s>>t;
	int len=s.size();
	if(s==t){
		cout<<"Yes"<<'\n';
		return 0;
	}
	char u[114];
	REP(i, s.size()){
		bool ok=true;
		REP(j, len){
			if(s[(j+i)%len]!=t[j]){
				ok=false;
				break;
			}
		}
		if(ok){
			cout<<"Yes"<<'\n';
			return 0;
		}
	}
	cout<<"No"<<'\n';
	return 0;
}


Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let ps = [|[]; []|]
let _ = Array.iteri (fun i a -> ps.(i mod 2) <- a :: ps.(i mod 2)) a_s;
  List.(ps.(1 - n mod 2) @ rev @@ ps.(n mod 2) |> iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n)); print_newline ()

Measured memory_bytes: 17152
from sys import stdin
def main():
    input=stdin.readline 
    n=int(input())
    H=[int(_) for _ in input().split()]
    H[0]-=1
    for i in range(1,n):
        if H[i-1]<H[i]:H[i]-=1
        elif H[i-1]>H[i]:
            print("No")
            break
    else:print("Yes")
if __name__=='__main__':
    main()

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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;

using ll = long long;

using namespace std;

vector<string> ans;
int n;

void solve(int i, string s){
    if(i == n){
        ans.push_back(s);
        return;
    }
    char c = *max_element(s.begin(), s.end());
    if(s == ""){
        solve(i + 1, s + 'a');
    }else
    if(c == 'z'){
        for(int j = 0;j < 26;j++){
            char w = 'a' + j;
            solve(i + 1, s + w);
        }
    }else{
        for(int j = 0;j <= c - 'a' + 1;j++){
            char w = 'a' + j;
            //cout<<w<<endl;
            solve(i + 1, s + w);
        }
    }
}

signed main() {
    cin >> n;
    solve(0, "");
    for(auto a : ans){
        cout<<a<<endl;
    }
}




Measured memory_bytes: 7328
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]

last=[0]*26


for d in range(1,D+1):
    ans=[]
    for choice in range(1,27):
        ans_tmp=0
        ans_tmp+=s[d-1][choice-1]
        for i in range(26):
            if i+1==choice:
                continue
            ans_tmp-=c[i]*(d-last[i])*(5+(D-d)//36)
        ans.append((ans_tmp,choice))
    _,case=max(ans)
    last[case-1]=d
    print(case)



Measured memory_bytes: 9288
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int X;
	cin >> X;
	int kyu = 0;
	if(X >= 400 && X < 600){
		kyu = 8;
	}else if(X < 800){
		kyu = 7;
	}else if(X < 1000){
		kyu = 6;
	}else if(X < 1200){
		kyu = 5;
	}else if(X < 1400){
		kyu = 4;
	}else if(X < 1600){
		kyu = 3;
	}else if(X < 1800){
		kyu = 2;
	}else{
		kyu = 1;
	}
	cout << kyu << endl;
	return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
  else cout <<"No" << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
	fast;
	//string s;
	vector<int> v;
	map<int,int> mp;
	int n,k,c=0,t=1;
	//cin>>t;
	while(t--){
	
		cin>>n>>k;
		if(n>=k) n=n%k;
		cout<<min(n,k-n);
	}
	return 0;
}



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

int main() {
    
    
    int N,M,K;
    cin>>N>>M>>K;
    int count;
    bool ans=false;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=M;j++){
            count=M*i+(N-2*i)*j;
            if (count==K) ans=true;
        }
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

int main(){
  int N;
  cin >> N;
  vector<int> button(N);
  vector<int> reg(N);
  
  int i;
  for(i = 0 ; i < N ; i++){
    cin >> button.at(i);
  }
  
  int count = 0,on = 1;
  while(true){
    
    reg.at(on - 1)++;
    on = button.at(on - 1);
    
    if(reg.at(on - 1) == 2){
      cout << -1 << endl;
      break;
    }
    
    count++;
    
    if(on == 2){
      cout << count << endl;
      break;
    }
    
    if(on == button.at(on - 1)){
      cout << -1 << endl;
      break;
    }
  }
    
  }

Measured memory_bytes: 1024
unittest
{
	assert( [ "3", "3", "1", "2" ].parse.expand.solve == 2 );
	assert( [ "4", "3", "4", "1", "2" ].parse.expand.solve == -1 );
	assert( [ "5", "3", "3", "4", "2", "4" ].parse.expand.solve == 3 );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.strip.to!( long );
	}
	return tuple( as );
}

auto solve( long[] as )
{
	auto ps = new bool[ as.length ];
	auto i = 0L;
	auto c = 0L;
	
	while( i != 1 )
	{
		if( ps[ i ] ) return -1;
		ps[ i ] = true;
		i = as[ i ] - 1;
		c++;
	}
	
	return c;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
#define endl '\n'
#define pb(a) push_back(a)
#define ALL(x) x.begin(), x.end()
#define SIZE(x) int(x.size())
#define IOS ios::sync_with_stdio(0);


int main() {
	IOS;
	int  n,k;
	cin>>n>>k;
	vector<int>p(n);
	for(int i=0;i<n;++i) cin>>p[i];
	sort(ALL(p));
	int ans=0;
	for(int i=0;i<k;++i) ans+=p[i];
	cout<<ans<<endl;
	return 0;
	
} 

Measured memory_bytes: 3632
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    l = []
    for _ in range(40):
        cnt = 0
        for i in range(n):
            if a[i] & 1:
                cnt += 1
            a[i] >>= 1
        l.append(cnt)

    pows = [1]
    for _ in range(39):
        pows.append(pows[-1] * 2)

    if k == 0:
        print(sum([l[i] * pows[i] for i in range(40)]))
        exit()

    # when it does not use the biggest bit of k
    ans1 = 0
    for i in range(k.bit_length() - 1):
        if l[i] < n - l[i]:
            ans1 += (n - l[i]) * pows[i]
        else:
            ans1 += l[i] * pows[i]
    for i in range(k.bit_length() - 1, 40):
        ans1 += l[i] * pows[i]

    # when it use the biggest bit of k
    ans2 = 0
    ans3 = 0
    for i in range(40):
        if l[i] < n - l[i]:
            if k & 1:
                ans2 += (n - l[i]) * pows[i]
            else:
                ans2 += l[i] * pows[i]
            ans3 += (n - l[i]) * pows[i]
        else:
            if k & 1:
                ans2 = ans3 + l[i] * pows[i]
            else:
                ans2 += l[i] * pows[i]
            ans3 += l[i] * pows[i]
        k >>= 1

    print(max(ans1, ans2))

main()

Measured memory_bytes: 86988
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;

int main(){
  string dict = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  int N;
  cin >> N;
  string s;
  cin >> s;

  string ans;
  for(int i = 0;i < s.size();i++){
    for(int j = 0;j < 26;j++){
      if(s[i] == dict[j]){
	ans += dict[(j+N)%26];
	break;
      }
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int x = nxt(), y = nxt(), i = 0;
    while(1){
        int a = floor((double)i*0.08), b = floor((double)i*0.1);
        if(a==x && b == y) {
            printf("%d\n", i);
            return 0;
        }
        else if(a > x && b > y){
            printf("-1\n");
            return 0;
        }
        i++;
    }
    return 0;
}



Measured memory_bytes: 256
# ABC071 C - Make a Rectangle
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))

first = 0
second = 0

d = defaultdict(int)
for a in A:
    d[a] += 1

A = set(A)
A = list(A)
A.sort(reverse=True)

for a in A:
    if 4 <= d[a]:
        if first>0:
            second = a
            break
        first = a
        second = a
        break
    elif 2<= d[a] <4:
        if first==0:
            first = a
            continue
        if first>0:
            second = a
            break

if first*second == 0:
    print(0)
else:
    print(first*second)

Measured memory_bytes: 20900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
  vector<vector<lint>> a;
    bool t[100000];
   lint ans=0;
  void dfs(lint to,lint from=-1){
        t[to]=true;
      for(lint g:a[to]){
            if(t[g]==true)continue;
            dfs(g,to);
      }
      
  }
    
  int main(){
   lint N,M;
   cin>>N>>M;
   a.resize(100000);
    fill(t,t+N,false);
    rep(i,M){
        lint x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        a[x].push_back(y);
        a[y].push_back(x);     
    }
        rep(i,N){
            if(t[i]==false){
                dfs(i);
                ans++;
            }
        }
           
    cout<<ans;
  }
  

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

using namespace std;

int main()
{
    int k,n;
    cin>>k>>n;
    
    vector<int> A(n+1);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    
    A[n]=k;
    
    //cout<<A[n]<<endl;
    
    int sum=0;
    vector<int> B(n+1);
    
    for(int i=0;i<n;i++){
        B[i]=(A[i+1]-A[i]);    
    }
    
    B[n]=A[0]+(k-A[n-1]);
    //sort(B.begin(),B.end());
    
    //for(int i=0;i<n-1;i++){
      //      sum+=B[i];
    //}
    sum=k- *max_element(B.begin(),B.end());
    
   cout<<sum;
    
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N);
  bitset<4000005> bit = 1;
  ll sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
    bit |= bit << A[i];
  }
  FOR(i, (sum + 1) / 2, sum + 1) {
    if (bit[i]) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll x,y;
    cin>>x>>y;
    ll ans;
    if(x<y){
        if(x*y>=0) ans=abs(y-x);
        else ans=abs(x+y)+1;
    }
    else{
        if(x*y>0) ans=abs(x-y)+2;
        else ans=abs(x+y)+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
object Main {

  class UnionFind(par: Array[Int]) {

    def root(x: Int): Int =
      if (par(x) == x) x
      else {
        par(x) = root(par(x))
        par(x)
      }

    def unite(x: Int, y: Int): Unit = {
      val rx = root(par(x))
      val ry = root(par(y))
      if (rx != ry)
        par(rx) = ry
    }

    def same(x: Int, y: Int): Boolean =
      root(par(x)) == root(par(y))

  }

  object UnionFind {
    def apply(N: Int): UnionFind =
      new UnionFind(Array.range(0, N))
  }

  def main(args: Array[String]): Unit = {
    // 頂点数が最大50頂点, 辺の数は最大50本.
    // 50本の辺について全て以下を試す
    // 対象の辺以外の全ての辺を繋いだDisjointSetを作り,
    // 対象の辺を繋ぐ前にすでに連結しているかを確認する.
    val sc = new java.util.Scanner(System.in)

    val N, M = sc.nextInt()

    case class Bridge(a: Int, b: Int)

    val bridges = new Array[Bridge](M)
    (0 until M) foreach { i =>
      val a, b = sc.nextInt()
      bridges(i) = Bridge(a-1,b-1)
    }

    var i = 0
    var count = 0
    while (i < M) {
      val set = UnionFind(N)
      var j = 0
      while (j < M) {
        if (i != j) {
          val bridge = bridges(j)
          set.unite(bridge.a, bridge.b)
        }
        j += 1
      }
      val bridge = bridges(i)
      if (!set.same(bridge.a, bridge.b))
        count += 1
      i += 1
    }

    println(count)
  }

}

Measured memory_bytes: 25548
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iterator>
#include <cstring>
using namespace std;

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

	string s;
	int n;
	map<char, int> c;
	long long sol = 0;

	cin >> s;
	n = s.size();
	for (char x : s) {
		c[x]++;
	}
	for (char x : s) {
		sol += n - c[x];
	}
	cout << sol/2+1;
}

Measured memory_bytes: 720
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, D):
    return math.ceil(N / (2*D+1))


def main():
    N, D = read_int_n()
    print(slv(N, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6852
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint N, M;
llint dp[305][305][305];

int main(void)
{
	cin >> N >> M;
	
	dp[0][0][1] = 1;
	for(int i = 0; i < M; i++){
		for(int j = 0; j <= N; j++){
			for(int k = 0; k <= N; k++){
				if(N-(j+k) > 0){
					dp[i+1][j+1][k] += dp[i][j][k] * (N-(j+k)) % mod;
					dp[i+1][j+1][k] %= mod;
				}
				if(j > 0){
					dp[i+1][j][k] += dp[i][j][k] * j % mod;
					dp[i+1][j][k] %= mod;
				}
				if(k > 0){
					dp[i+1][0][j+k] += dp[i][j][k] * k % mod;
					dp[i+1][0][j+k] %= mod;
				}
			}
		}
	}
	
	cout << dp[M][0][N] << endl;
	return 0;
}

Measured memory_bytes: 218624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n;
	cin >> n;

	cout << (n - 2) * 180 << endl;

	return 0;
}


Measured memory_bytes: 892
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

grid = [list(input()) for s in range(H)]
search = [[float('inf')] * W for _ in range(H)]

dq = deque([])
dq.append((Ch, Cw, 0))
search[Ch][Cw] = 0

direction = [[-1, 0], [0, -1], [1, 0], [0, 1]]

while dq:
    r, c, cur_cost = dq.popleft()

    for x, y in direction:
        r_new = r + x
        c_new = c + y

        if r_new < 0 or r_new >= H or c_new < 0 or c_new >= W or \
                search[r_new][c_new] <= cur_cost or grid[r_new][c_new] == '#':
            continue

        dq.appendleft((r_new, c_new, cur_cost))
        search[r_new][c_new] = cur_cost

    for x in range(-2, 3):
        r_new = r + x
        if r_new < 0 or r_new >= H:
            continue

        for y in range(-2, 3):
            c_new = c + y

            if c_new < 0 or c_new >= W or search[r_new][c_new] <= cur_cost + 1 or grid[r_new][c_new] == '#':
                continue

            dq.append((r_new, c_new, cur_cost + 1))
            search[r_new][c_new] = cur_cost + 1


if search[Dh][Dw] == float('inf'):
    print(-1)
else:
    print(search[Dh][Dw])


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b;cin>>a>>b;
    string s;
    cin>>s;
    if (s[a]=='-'){
        bool pos=true;
        for (int i=0;i<a+b+1;i++){
            if (i!=a){
                if ((s[i]-'0')<0||(s[i]-'0')>9){
                    pos=false;
                    break;
                }
            }
        }if (pos)cout<<"Yes";
        else cout<<"No";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

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

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  string s;
  std::cin >> s;

  int right = 0;
  int left = 0;
  int down = 0;
  int up = 0;
  for(int idx = 0; idx < s.size(); idx++){
    if(s[idx] == 'S') down += 1;
    if(s[idx] == 'N') up += 1;
    if(s[idx] == 'W') left += 1;
    if(s[idx] == 'E')  right += 1;
  }
  if((up && down) || (!bool(up) && !bool(down))){
    if((right && left) || (!bool(right) && !bool(left))){
      std::cout << "Yes" << '\n';
      return 0;
    }
  }
  std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 1144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;

public class Main {

	private static final int MAX = 1000000;

	public static void main(String[] args) {

		HashSet<Integer> hs = new HashSet<Integer>();
		Integer[] il;

		//
		for (int i = 2; i < MAX; i++) {
			hs.add(i);
		}

		for (int i = 2; i < MAX; i++) {
			hs.contains(Integer.valueOf(i));
			for (int j = 2; i * j < MAX; j++) {
				hs.remove(Integer.valueOf(i * j));
			}
		}

		il = hs.toArray(new Integer[0]);
		Arrays.sort(il);

		//
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		ArrayList<Integer> al = new ArrayList<Integer>();

		try {
			while ((s = br.readLine()) != null) {
				al.add(Integer.valueOf(s));
			}
			for (Integer i : al) {
				int count = 0;
				for (int j = 0; j < il.length; j++) {
					if (il[j] <= i)
						count++;
					else
						continue;
				}
				System.out.println(count);
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 181400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define clr(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll MOD = 1e9+7;
const int maxn = 2e3 + 5;
// head

int x[maxn], y[maxn];

int main() 
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif

    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7)
        cout << "YES" << endl;
    else
        cout << "NO" <<endl;
            
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;
vector<long long int> v;


long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int ret = mypow(a, b / 2);
    ret = ret * ret % mod;
    if (b % 2 == 1) ret *= a;
    return ret % mod;
}

long long int fac(long long int n) {
    return v[n];
    long long int res = 1;
    for (long long int i = 1; i <= n; i++) {
        res *= i;
        res %= mod;
    }
    return res;
}

long long int myc(long long int m, long long int n) {
    if (n == 0) return 1;
    return fac(m) * mypow(fac(n), mod - 2) % mod * mypow(fac(m - n), mod - 2) % mod;
}

long long int f(long long int a, long long int b) {
    return myc(a - 1, b - 1);
}

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    
    int n = s.size();

    v.push_back(1);
    for (int i = 1; i <= n + k; i++) {
        v.push_back(v.back() * (long long int)i % mod);
    }

    long long int res = 0;
    vector<long long int> ll;
    for (int i = n; i <= n + k; i++) {
        // [i][n]
        long long int t = mypow(25, i - n) * f(i + 1, n + 1) % mod;
        // cout << i + 1 << " " << n + 1 << " " << f(i + 1, n + 1) << " ";
        ll.push_back(t);
    }
    for (int i = 0; i < ll.size(); i++) {
        if (i + 1 < ll.size()) res *= 26;
        res += ll[i];
        res %= mod;
        
    }
    cout << res << endl;
}


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

int main(){
  int N; cin >> N;
  vector<int> L(N);
  for(int i=0; i<N; i++) cin >> L[i];
  sort(L.begin(),L.end());
  
  int count=0;
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      for(int k=j+1; k<N; k++){
        if(L[i]+L[j]>L[k]) count++;
        else break;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int h1, h2, k1, k2, a, b, c, d, H, K;
  cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
  H = h1*a + (h1/10)*c + h2*b + (h2/20)*d;
  K = k1*a + (k1/10)*c + k2*b + (k2/20)*d;
  if ( H > K )          cout << "hiroshi" << endl;
  else if ( H < K )     cout << "kenjiro" << endl;
  else                  cout << "even" << endl;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main()
{   int a,i,x;
    char str[10000];
    scanf("%d",&a);
    scanf("%s",str);
    for(i=0;str[i]!='\0';i++)
    {
        str[i]=str[i]+a;
        if(str[i]>90)
        {    x=str[i]-90;
             str[i]=64+x;
        }

        

    }
    printf("%s",str);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
  	int n = 5;
  	for(int i=0;i<n;i++) {
      cin >> a[i];
    }
  	sort(a, a+n);
  	int k = 0;
  	cin >> k;
  	cout << (((a[4] - a[0]) > k) ? ":(" : "Yay!");
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
import sys
N, K = map(int, input().split())
An = list(map(int, input().split()))

for cnt in range(K):
    tmp = [0]*(N+1)
    for i in range(N):
        power = An[i]
        left = max(0, i-power)
        right = min(N, i+power+1)
        tmp[left] += 1
        tmp[right] -= 1
    An = list(accumulate(tmp))[:-1]
    if cnt > 40:
        An = [N]*N
        print(*An)
        sys.exit()
print(*An)


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

        double ans = 0;
        for(int i = 1; i<=N; i++) {
            int now = i;
            double pro = 1;
            while(now < K) {
                now *= 2;
                pro /= 2;
            }
            ans += (double)(1/(double)N)*(pro);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n; cin >> n;
  cout << n * (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include "stdio.h"

int main(void){
  int x,y,i,j,k;
  for(i = 0; i <10000;i++){
    scanf("%d %d", &x, &y);
    if((x == 0) && (y == 0))break;
    for(k = 0; k < y;k++){
      printf("#");
    }
    printf("\n");
    for(j = 1; j < x-1; j++){
      for(k = 0; k < y;k++){
        if((k == 0) || (k == (y-1))){
          printf("#");
        }else{
          printf(".");
        }
      }
      printf("\n");
    }
    for(k = 0; k < y;k++){
      printf("#");
    }
    printf("\n");
    printf("\n");
  }
}



Measured memory_bytes: 2036
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  s << "]";
  return s;
}


signed main()
{
  int N; cin >> N;
  vec<int> a(3*N);
  rep(i, 0, 3*N) {
    cin >> a[i];
  }

  priority_queue< int,vec<int>,greater<int> > que1;
  vec<int> smax(N+1);
  rep(i, 0, N) {
    que1.push(a[i]);
    smax[0] += a[i];
  }
  rep(i, 0, N) {
    int m = que1.top();
    if (m < a[i+N]) {
      que1.pop();
      que1.push(a[i+N]);
      smax[i+1] = smax[i] + a[i+N] - m;
    } else {
      smax[i+1] = smax[i];
    }
  }

  priority_queue< int > que2;
  vec<int> smin(N+1);
  rep(i, 0, N) {
    que2.push(a[3*N-1 - i]);
    smin[0] += a[3*N-1 - i];
  }
  rep(i, 0, N) {
    int m = que2.top();
    if (m > a[2*N-1 - i]) {
      que2.pop();
      que2.push(a[2*N-1 - i]);
      smin[i+1] = smin[i] + a[2*N-1 - i] - m;
    } else {
      smin[i+1] = smin[i];
    }
  }

  int score = -INF;
  rep(i, 0, N+1) {
    score = max(score, smax[i] - smin[N-i]);
  }

  cout << score << endl;

  return 0;
}


Measured memory_bytes: 6516
N = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
  for i in range(N):
    if a[i] % 2 != 0 or a[i] == 0:
      print(cnt)
      exit()
    else:
      a[i] = a[i] // 2
  cnt += 1

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

using namespace std;

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

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {

  int d; cin >> d;
  cout << "Christmas";
  for(int i=25; i>d; i--){
    cout << " Eve";
  }
  cout << endl;

  return 0;
}



///


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let s: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let N = s.len();
    let (a, b) = (0..(N - 1)).map(|i| {
        if s[i] == s[i + 1] {
            (i as i64 + 1, i as i64 + 2)
        } else if i < N - 2 && s[i] == s[i + 2] {
            (i as i64 + 1, i as i64 + 3)
        } else {
            (-1, -1)
        }
    }).max().unwrap();
    let ans = format!("{} {}", a, b);

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
	long long int a,b,i,ans,maxi;
	cin>>a>>b;
	ans=a*b;
	i=1;
	while((i<=a)&&(i<=b)){
		if((a%i==0)&&(b%i==0))maxi=i;
		if((i>a)||(i>b))break;
		i++;
	}
	ans/=maxi;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,L[203];
	scan(N);
	rep(i,2*N){
		scan(L[i]);
	}
	sort(L,L+2*N);
	int ans=0;
	rep(i,2*N){
		if(i%2==0) ans+=L[i];
	}
	prin(ans);
	return 0;
}


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

int main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
 
#define endl	"\n"
#define pb 		push_back
#define mp 		make_pair
#define MOD 	1000000007
#define INF 	(long long int)1e9
#define EPS 	1e-9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long int
#define ret     return
#define NUM 	100020
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

int main(){
	fastio();
	//input();

	ll n,w;
	cin>>n>>w;
	vector<ll>val,wt;
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		val.push_back(b);
		wt.push_back(a);
	}
	ll dp[n+1][w+1];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<=w;j++){
			if(i==0){
				if(wt[i]>j) dp[i][j] = 0;
				else dp[i][j] = val[i];
			}
			else{
				if(wt[i]>j) dp[i][j] = dp[i-1][j];
				else{
					dp[i][j] = max(val[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
				}
			}
			
		}
		
	}
	/*for(int i=0;i<n;i++){
		for(int j=0;j<=w;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[n-1][w]<<endl;
	return 0;
}

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

int main(){
    string S;
    cin >> S;

    for(int i = 0; i < 3; i++){
        if(S.at(i) == 'R'){
            if(i == 0){
                if(S.at(1) == 'R' && S.at(2) == 'R'){
                    cout << 3 << endl;
                    return 0;
                }
                else if(S.at(1) == 'R'){
                    cout << 2 << endl;
                    return 0;
                }
                else{
                    cout << 1 << endl;
                    return 0;
                }
            }
            else if(i == 1){
                if(S.at(2) == 'R'){
                    cout << 2 << endl;
                    return 0;
                }
                else{
                    cout << 1 << endl;
                    return 0;
                }
            }
            else{
                cout << 1 << endl;
                return 0;
            }
            
        }
        else if(i == 2 && S.at(i) == 'S'){
            cout << 0 << endl;
            return 0;
        }
    } 
}

Measured memory_bytes: 3612
n=int(input())
x=input()
p=x.count('1')

#愚直に解く関数を定義
def solve(n):
    count=0
    while n:
        popcount=bin(n).count('1')
        n%=popcount
        count+=1
    return count+1

#popcount(x)が0,1だった場合に対応
if p==0:
    for i in range(n):
        print(1)
    exit()
elif p==1:
    z=x.index('1')
    t=pow(2,n-z-1,p+1)
    for i in range(n):
        if i==z:
            print(0)
        else:
            tmp=(t+pow(2,n-i-1,p+1))%(p+1)
            print(solve(tmp))
    exit()


#2^i mod(p+1),2^i mod(p-1)のリストを作成
a,b=[],[]
for i in range(n):
    a.append(pow(2,i,p+1))
    b.append(pow(2,i,p-1))

#x mod(p+1),x mod(p-1)を計算
a1,b1=0,0
for i in range(n):
    if x[-1-i]=='1':
        a1+=a[i]
        b1+=b[i]

#本計算
for i in range(n):
    if x[i]=='1':
        tmp=(b1-b[-1-i])%(p-1)
    else:
        tmp=(a1+a[-1-i])%(p+1)
    print(solve(tmp))

Measured memory_bytes: 25108
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <set>

using namespace std;

#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) > (b)) ? (b) : (a))
#define abs(a) (((a) > 0) ? (a) : (-(a)))
#define ll  long long


void solve()
{
    int n;
    cin >> n;
    vector<ll> a, b;
    while( n-- ){
        ll x, y;
        cin >> x >> y;
        a.push_back(x+y);
        b.push_back(x-y);
    }
    cout << max(
                (*max_element( a.begin(), a.end() )) - (*min_element( a.begin(), a.end() )),
                (*max_element( b.begin(), b.end() )) - (*min_element( b.begin(), b.end() ))
                ) << '\n';
    
}


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


Measured memory_bytes: 6692
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())
    A = list(map(int,input().split()))

    ans = 0
    max_tall = 0

    for n in range(1,N):
        max_tall = max(A[n-1],max_tall)
        ans += max(max_tall - A[n],0) 


    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 31408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int p[n];
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        ans += p[i];
    }
    sort(p, p + n);
    ans -= p[n - 1] / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();

        final int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
        }
        Arrays.sort(array);

        long sum = 0;
        for (int i = 0; i < n - k; i++) {
            sum += array[i];
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 64636
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);
#define mod 100000000
using namespace std;

inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
 ll Max=1e18+8;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
////////////////////////////////////////////////////////////////////////////////////

ll mem[100005][3],a[105],b[105],n,m,k;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
void init()
{
    memset(mem,-1,sizeof mem);
}

/////////////////////////////////////////////////////////////////////




int main()
{
    init();
    int T=1;
///   T=D();
    while(T-->0)
    {
        string st1,st2;
        cin >> st1>>st2;
        int a=st1.size();
        int b=st2.size();
        int c=a-b;
        int ans=1009,cnt=0;
        if(c<0)
            return puts("0"),0;
        for(int i=0;i<=c;i++)
        {

            for(int j=0;j<b;j++)
            {
            if(st1[i+j]!=st2[j])
                cnt++;
              ///  cout<<st1[i+j]<<" : "<<st2[i+j]<< " ";
             }
           ///  cout<<endl;
             ans=min(ans,cnt);
             cnt=0;

        }
        cout<<ans;


    }
}


Measured memory_bytes: 5968