akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	//0001
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Integer[] mountain = new Integer[10];
		for(int i = 0; i< 10;i++){
			mountain[i] = Integer.parseInt(br.readLine());
		}
		Arrays.sort(mountain,Comparator.reverseOrder());

		for(int i=0;i<3;i++){
			System.out.println(mountain[i]);
		}
	}
}

Measured memory_bytes: 24100
#include <stdio.h>

int main(void) {
	int x=1, i=1;
	while(1){
		scanf("%d", &x);
		if(x==0){
			break;
		}
		printf("Case %d: %d\n", i, x);
		i++;
	}
	

	
	return 0;
}



Measured memory_bytes: 2032
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder str = new StringBuilder();
         
        String line;
        String[] imperative;
        int a;
        int b;
         
        str.append(scan.nextLine());
        int turns = Integer.parseInt(scan.nextLine());
         
        for (int i = 0; i < turns; i++) {
            line = scan.nextLine();
            imperative = line.split(" ");
            //imperative[1] => a?????????
            a = Integer.parseInt(imperative[1]);
            //imperative[2] => b?????????
            b = Integer.parseInt(imperative[2]) + 1;
             
            if(imperative[0].equals("print")){
                //??????=>print ???§?????????°???¨???
                System.out.println(str.substring(a, b));
            }else if(imperative[0].equals("reverse")){
                //??????=>reverse ???§?????????°
                //str???§??????¢??????????????±?????????????reverse???????????????????????????¢?????????str???????????????
                StringBuilder reverse = new StringBuilder();
                reverse.append((str.substring(a, b)));
                str.replace(a, b, (reverse.reverse()).toString());
            }else{
                //?????????print???reverse ???§???????????????????????????
                str.replace(a, b, imperative[3]);
            }
             
        }
         
    }
}

Measured memory_bytes: 28736
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int W, A, B;
	cin >> W >> A >> B;

	if (W >= abs(A - B)) co(0);
	else co(abs(A - B) - W);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
typedef long long ll;
inline int read() {
	int x=0,s=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') s=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return s*x;
}

const int MAXN=200005,Mo=1000000007;
int n,m,q,a[MAXN],b[MAXN],f[MAXN];
int main(){
	n=read();
	int sum=0,lx=101;
	FOR(i,1,n) {
		a[i]=read();
		sum+=a[i];
		if (a[i]%10!=0) lx=min(lx,a[i]);
	}
	if (sum%10!=0) printf("%d\n",sum);
	else {
		if (lx==101) puts("0");
		else printf("%d\n",sum-lx);
	}
	return 0;
}

/*
*/


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        exit(0)
    ans = 1
    MAX = 10**18
    for ai in a:
        ans *= ai
        if ans > MAX:
            print(-1)
            exit(0)
    print(ans)

if __name__ == "__main__":
    main()

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

typedef long in; 

in vis[100005],dp[100005];

vector<in> v[100005];

void dfs(in node)
{
    vis[node]=1;
    
    for(auto it:v[node])
    {
        if(!vis[it])
        dfs(it);
        
        dp[node]=max(dp[node],dp[it]+1);
    }
}

int main() 
{
    in n,m,i,ans=0;
    cin>>n>>m;
    
    for(i=0;i<m;++i)
    {
        in r,g;
        cin>>r>>g;
        
        v[r].push_back(g);
    }
	
	for(i=1;i<=n;++i)
	if(!vis[i])
	dfs(i);
	
	for(i=1;i<=n;++i)
	{
	    ans=max(ans,dp[i]);
	    //cout<<dp[i]<<" ";
	}
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 9344
n = int(input())
T = list(map(int, input().split()))
m = int(input())
D = [tuple(map(int, input().split())) for _ in range(m)]

sum_T = sum(T)
for i in range(m):
    print(sum_T - T[D[i][0] - 1] + D[i][1])


Measured memory_bytes: 9148
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    List<Long> strong = new ArrayList<Long>();
        
    for(int i=0;i<3*N;i++){
      long a = sc.nextInt();
      strong.add(a);
    }
    
    Collections.sort(strong);
    long num=0;
    
    for(int i=0;i<2*N;i++){
      if(i % 2 == 1){
        num += strong.get(3*N-1-i);
      }
    }
    
    System.out.println(num);
  }
}



Measured memory_bytes: 99932
/**
 * @Author:      G_bg
 * @DateTime:    2019-04-27 21:06:59
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=20+10;
int v[maxn],c[maxn];
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin >> n;
    for(int i = 1;i <= n;i++) cin >> v[i];
    for(int i = 1;i <= n;i++) cin >> c[i];
    int sum = 0;
    for(int i = 1;i <= n;i++){
        if(v[i]-c[i] > 0) sum += v[i]-c[i];
    }
    cout << sum << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

//?????????????´???°?????????
vector<int> a;

//m????????????????´???°??????????????????
//m??\????????????????????°??§???????????????????????????????????????
vector<int> f(int m) {
	vector<int> ret; //??????????????????
	for (int i = 0; i < a.size();i++) {
		if (m % a[i] == 0) {
			//?????£???????????°
			int t = m / a[i];
			//?????£???????????????????????°??§????????????continue
			if (t % 7 != 1 && t % 7 != 6)continue;
			//i???m????????????????´???°
			ret.push_back(a[i]);
		}
		if (a[i] >= m) {//m????????§???????????????????´???°??????????????§??????
			return ret;
		}
	}
}

int main() {

	for (int i = 1; i <= 300000; i++) {
		if (i % 7 == 1 || i % 7 == 6) {
			a.push_back(i);
		}
	}
	int n;
	while (cin >> n && n != 1) {
		//n????????????????´???°?????????????±???????
		vector<int> b = f(n);
		cout << n << ":";
		for (int i = 0; i < b.size();i++) {
			//1????????§???????´???°?????°???2?????????
			//n????????????????´??????°????????§??????
			if (b[i] > 1 && f(b[i]).size() == 2) {
				cout << " " << b[i];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,a,b,i,j,k,n,x;
    cin>>a>>b>>x;
    k=(b/x)-(a/x);
    if(a%x==0)
        k+=1;
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		List<int[]> list = new ArrayList<>();

		for(int i=1;i<=n;i++) {
			int ryouri[]=new int [4];
			ryouri[1] = Integer.parseInt(sc.next());
			ryouri[2] = Integer.parseInt(sc.next());
			ryouri[3] = ryouri[1]+ryouri[2];
			ryouri[0] = i;
			list.add(ryouri);
		}
		sc.close();
		list.sort((a1,a2)->a1[3]-a2[3]);
		Collections.reverse(list);
		boolean flag = true;
		long player1 = 0;
		long player2 = 0;

		for(int[] ryouri:list) {
			if(flag) {
				player1 += ryouri[1];
				flag = false;
			}else {
				player2 += ryouri[2];
				flag = true;
			}
		}

		System.out.println((player1 - player2));
	}

}


Measured memory_bytes: 64028
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int ans = (n - m) * 100 + 1900 * m;
	while (m > 0)
	{
		m--;
		ans *= 2;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

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

int dig[11000];
int a[11000];

int main(){
    int n;
    cin >> n;
    int t[6] = {1, 10, 100, 1000, 10000, 100000};
    for(int i = 0; i < n; i++){
        cin >> a[i];
        for(int j = 0; j < 5; j++){
            if(a[i] >= t[j]){
                dig[i] = j;
            }
        }
    }
    long long int n1 = INF, n2 = INF, n3 = INF;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j){
                continue;
            }
            long long int num = a[i] * t[dig[j] + 1] + a[j];
            if(num < n1){
                n3 = n2;
                n2 = n1;
                n1 = num;
            }else if(num < n2){
                n3 = n2;
                n2 = num;
            }else if(num < n3){
                n3 = num;
            }
        }
    }
    cout << n3 << endl;
    return 0;
}


Measured memory_bytes: 3156
package main

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

func main() {
	sc := NewScanner()
	H, A := sc.NextInt(), sc.NextInt()
	fmt.Println((H + A - 1) / A)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import java.util.Scanner

object Main {

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      val A = Array.fill[Double](N)(sc.nextInt)
      val ave = A.sum / N: Double
      println(math.sqrt(A.map(X => (X - ave) * (X - ave)).sum / N))
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 49680
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
int n,m,h,w,a[505][505];
ll sum[505][505];
int main(){
	scanf("%d%d%d%d",&n,&m,&h,&w);
	if(h==1&&w==1) return puts("No"),0;
	const int inf=1e9;
	for(int i=h;i<=n;i+=h){
		for(int p=w;p<=m;p+=w) a[i][p]=-inf;
	}
	for(int i=1;i<=n;i+=h){
		for(int p=1;p<=m;p+=w) a[i][p]=inf-1;
	}
	for(int i=1;i<=n;i++){
		for(int p=1;p<=m;p++) sum[i][p]=sum[i-1][p]+sum[i][p-1]-sum[i-1][p-1]+a[i][p];
	}
	if(sum[n][m]<=0) puts("No");
	else{
		puts("Yes");
		for(int i=1;i<=n;i++){
			for(int p=1;p<=m;p++) printf(p==m?"%d\n":"%d ",a[i][p]);
		}
	}
	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
set<string>s;
map<string,long long>ma;
set<string>::iterator it;
int main()
{
    int n;
    long long ans=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        getchar();
        char a[20];
        scanf("%s",a);
        sort(a,a+10);
        s.insert(a);
        ma[a]++;
    }
    for(it=s.begin(); it!=s.end(); it++)
        ans+=ma[*it]*(ma[*it]-1)/2;
    printf("%lld",ans);
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  int left = 0, right = 0;
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'A')
    {
      left = i;
      break;
    }
  }
  for (int i = n - 1; 0 <= i; i--)
  {
    if (s[i] == 'Z')
    {
      right = n - i;
      break;
    }
  }
  cout << n - left - right + 1 << endl;
}

Measured memory_bytes: 640
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    string S, T;
    scan(S, T);
    zip(S, T).map!"[a[0],a[1]]"().join().writeln();
}


Measured memory_bytes: 3720
import java.util.Scanner;


public class Main {

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

		int N = scanner.nextInt();
		int aMax=0;
		int bMax=0;
		int cMax=0;

		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];

		for(int i=0;i<N;i++) {
			a[i] = scanner.nextInt();
			b[i] = scanner.nextInt();
			c[i] = scanner.nextInt();
		}

		aMax = a[0];
		bMax = b[0];
		cMax = c[0];

		for(int i=1;i<N;i++){
			//i-1のデータを退避させる．
			int aTemp = aMax;
			int bTemp = bMax;
			int cTemp = cMax;

			aMax = a[i] + Math.max(bTemp, cTemp);
			bMax = b[i] + Math.max(aTemp, cTemp);
			cMax = c[i] + Math.max(aTemp, bTemp);
//			System.out.println(i + "日目にaを選んだ時の最大幸せ指数:" + aMax);
//			System.out.println(i + "日目にbを選んだ時の最大幸せ指数:" + bMax);
//			System.out.println(i + "日目にcを選んだ時の最大幸せ指数:" + cMax);
		}

		//Math.max で最大値比較
		System.out.println(Math.max(aMax, Math.max(bMax, cMax)));
		scanner.close();
	}

}


Measured memory_bytes: 91880
import heapq
n = int(input())
A = sorted(map(int, input().split()), reverse=True)

ans = A[0]
conf = [-A[1]]
for i, a in enumerate(A[2:]):
    x = -heapq.heappop(conf)
    ans += x
    if i == 0:
        heapq.heappush(conf, -x)
    heapq.heappush(conf, -a)
    heapq.heappush(conf, -a)
print(ans)


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

  int N, x;
  string color;

  cin >> N;
  x=0;

  for(int i = 0 ; i < N ; i++)
  {

    cin >> color;

    if(color == "Y")
    {
       x++;
    }

  }

  if(x!=0)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	char c;
	cin >> c;
	c += 1;
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int h,w;cin >> h >> w;
      char c[h + 5][w + 5];
      for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                  cin >> c[i][j];
            }
            for(int j = 0;j < 2;j++){
                  for(int k = 0;k < w;k++){
                        cout << c[i][k];
                  }
                  cout << "\n";
            }
      }
}

Measured memory_bytes: 256
s = input()
s_prime = ""
if s[0] != "A":
    # print(1)
    print("WA")
else:
    s_prime = s[1:]
    if s[2:-1].count("C") != 1:
        # print(2)
        print("WA")
    else:
        s_prime = s_prime.replace("C","")
        # print(s_prime)
        if s_prime.islower():
            # print(3)
            print("AC")
        else:
            # print(4)
            print("WA")

Measured memory_bytes: 3060
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Monad
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Storable as V
import qualified Data.Vector.Storable.Mutable as MV

main = do
    n <- readLn
    ps <- (flip V.snoc) 0.V.cons 0.V.unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine
    --
    let suma = V.sum $ V.map (\i -> c ps i (i-1)) $ V.fromList [1..n+1]
    --
    forM_ [1..n] $ \i -> do
        print $ suma - (c ps i (i-1)) - (c ps i (i+1)) + (c ps (i+1) (i-1))
    --
    where c ps i j = abs((ps V.! j) - (ps V.! i))


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


int main() {
    vector<int> A(3);
    for(int i=0;i<3;i++) cin >> A[i];

    int res = 0;
    vector<int> tmp(3);
    bool wataseru = true;

    while(wataseru&&A[0]%2==0&&A[1]%2==0&&A[2]%2==0){
        
        for(int i=0;i<3;i++) tmp[i]=A[i]/2;
        for(int i=0;i<3;i++){
            A[i]=0;
            for(int j=0;j<3;j++){
                if(i!=j) A[i]+=tmp[j];
            }
        }

        res++;

        if(A[0]==A[1]&&A[1]==A[2]&&A[0]%2==0){
            wataseru = false;
            res = -1;
        }
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int N;
  cin >> N;
  vector<ll> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  
  vector<ll> sums(N + 1, 0);
  for (int i = 0; i < N; i++) {
    sums[i + 1] = sums[i] + vec[i];
  }
  
  map<ll, ll> cnt;
  for (int i = 0; i <= N; i++) {
    cnt[sums[i]]++;
  }
  ll res = 0;
  for (auto it : cnt) {
    res += it.second * (it.second - 1) / 2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 15872
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();
    int[] arr = new int[n];
    for(int i = 0; i < n; i++) {
      arr[i] = sc.nextInt();
    }
    Arrays.sort(arr);
    long sum = 0;
    for(int i = 0; i < n - k; i++) {
      sum = sum + arr[i];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 63104
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const a = input[1].split(" ").map(n => Number(n));
  const gcd = (a, b) => {
    if (b === 0) return a;
    return gcd(b, a%b);
  }
  const l = [];
  for (let i = 0; i < n; i++) {
    if (i === 0) {
      l.push(a[i]);
      continue;
    }
    l.push(gcd(l[l.length-1], a[i]));
  }
  
  const r = [];
  for (let i = n - 1; 0 <= i; i--) {
    if (i === n-1) {
      r.push(a[i]);
      continue;
    }
    r.push(gcd(r[r.length-1], a[i]));
  }
  
  let result = 0;
  for (let i = 0; i < n; i++) {
    const num = gcd(i === 0 ? 0 : l[i-1], i === n-1 ? 0 : r[n-i-2]);
    if (result < num) result = num;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29592
import java.util.Scanner;
public class Main {
	static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ2582().doIt();
	}
	class AOJ2582{
		void doIt(){
			while(true){
				int n = in.nextInt();
				if(n==0)break;
				String[] input = new String[n];
				for(int i=0;i<n;i++)input[i] = in.next();
				boolean right = false;
				boolean left = false;
				boolean status = false;
				int cnt = 0;
				for(int i=0;i<n;i++){
					if(input[i].equals("lu"))left = true;
					else if(input[i].equals("ru"))right = true;
					else if(input[i].equals("ld"))left = false;
					else if(input[i].equals("rd"))right = false;
					if(right == left && right != status){
						status = right;
						cnt++;
					}
				}
				System.out.println(cnt);
			}
		}
	}
}

Measured memory_bytes: 26916
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    student = list()
    for i in range(N):
        student.append(i + 1)
    dic = dict(zip(A, student))
    dic_sorted = sorted(dic.items(), key=lambda x: x[0])
    
    ans = ""
    for i in range(N):
        ans += str(dic_sorted[i][1]) + " "
    print(ans[:-1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 33312
#include <iostream>
using namespace std;
int main(void){
    int i,x,N,c0,c1,c2,c3;
    c0=0;
    c1=0;
    c2=0;
    c3=0;
    
    cin >> N;
    
    string S[N];
    
    for(x=0;x<N;x++){
        cin >> S[x];
    }
    
    for(i=0;i<N;i++){
        if(S[i] == "AC"){
            c0++;
        }
        if(S[i] == "WA"){
            c1++;
        }
        if(S[i] == "TLE"){
            c2++;
        }
        if(S[i] == "RE"){
            c3++;
        }
    }
    
    cout << "AC x " << c0 << endl << "WA x " << c1 << endl << "TLE x " << c2 << endl << "RE x " << c3;
    
    return 0;
 
}


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

int main() {
    string s;
    cin >> s;
    int counts[26];
    for (int i = 0; i < 26; ++i) {
        counts[i] = 0;
    }
    for (int i = 0; i < s.size(); ++i) {
        counts[s[i] - 'A']++;
    }
    for (int i = 0; i < 26; ++i) {
        int c = counts[i];
        if (c == 1 || c == 3 || c == 4) {
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
ll solve2(int k, ll a, ll n) {
    if ((1LL << k) > a) return 1LL << n;
    return (1LL << n) - a + (1LL << k);
}

ll solve(ll a, ll b, int e) {
    if (((a >> e) & 1) == ((b >> e) & 1)) return solve(a, b, e - 1);
    int b_max_bit = -1;
    per(i, e) {
        if ((b >> i) & 1) {
            b_max_bit = i;
            break;
        }
    }
    return (1LL << e) - a % (1LL << e) + solve2(b_max_bit + 1, a % (1LL << e), e);
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (a == b) cout << "1\n";
    else cout << solve(a, b, 62) << "\n";
    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000000099;

vector<vector<ll>> v;
vector<vector<ll>> dp;

signed main(){
    ll h,w,k;
    cin>>h>>w>>k;
    v.resize(h+1,vector<ll>(w,0));
    
    dp.resize(w,vector<ll>(2,0));//0:ない 1:ある
    dp.at(0).at(1)=1;//埋める部分の端にあることを想定（ない場合は1,0を逆転)
    for(int i=1;i < w;i++)
    {
        dp.at(i).at(0)=dp.at(i-1).at(0)+dp.at(i-1).at(1);
        dp.at(i).at(1)=dp.at(i-1).at(0);
    }
   
    v.at(0).at(0)=1;
    if(w==1){
        cout << 1 << endl;
        return 0;
    }

    for(int i=1;i <= h;i++)
    {
        for(int j=0;j < w;j++)
        {
            if(j==0 || j==w-1){
                v.at(i).at(j)+=v.at(i-1).at(j)*(dp.at(w-1).at(0)+dp.at(w-1).at(1));//まっすぐ
                v.at(i).at(j)%=mod;
                if(j==w-1){
                    v.at(i).at(j)+=v.at(i-1).at(j-1)*(dp.at(w-2).at(0)+dp.at(w-2).at(1));
                    v.at(i).at(j)%=mod;
                }
                if(j==0){
                    v.at(i).at(j)+=v.at(i-1).at(j+1)*(dp.at(w-2).at(0)+dp.at(w-2).at(1));
                    v.at(i).at(j)%=mod;
                }  
            }else{
                v.at(i).at(j)+=v.at(i-1).at(j)*(dp.at(j).at(0)+dp.at(j).at(1))*(dp.at(w-1-j).at(0)+dp.at(w-1-j).at(1));
                v.at(i).at(j)%=mod;//関係ないところにひく
                
                v.at(i).at(j)+=v.at(i-1).at(j-1)*(dp.at(j-1).at(0)+dp.at(j-1).at(1))*(dp.at(w-j-1).at(0)+dp.at(w-j-1).at(1));
                v.at(i).at(j)%=mod;
                
                v.at(i).at(j)+=v.at(i-1).at(j+1)*(dp.at(j).at(0)+dp.at(j).at(1))*(dp.at(w-j-2).at(0)+dp.at(w-j-2).at(1));
                v.at(i).at(j)%=mod;
                
            }        
        }
    }
    cout << v.at(h).at(k-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define INF 100000000
using namespace std;
int main(void){
    int N;
    int W[110];
    
    cin >> N;
    for(int i=0;i<N;i++) cin >> W[i]; 
    
    int S1,S2;
    int dist_now = 1000;
    
    for(int T=1;T<N;T++){
        int S1 = 0,S2 = 0;
        for(int i=0;i<T;i++) {
            S1 += W[i];
          //  cout << S1 << " " << W[i] << " " << T << endl;
        }
        for(int j=T;j<N;j++) {
            S2 += W[j];
          //  cout << S2 << " " << W[j] << " " << T << endl;
        }
        int dist = abs(S1-S2);
        if(dist<dist_now) dist_now = dist;
    }

    cout << dist_now;

    return 0;
    
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {

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

		int n=in.nextInt();
		double sum=0.0;
		
		for(int i=0;i<n;i++) {
			double v=in.nextDouble();
			String s=in.next();
			
			if(s.equals("JPY"))sum+=v;
			else sum+=380000.0*v;
		}
		
		System.out.println(sum);
	}

}


Measured memory_bytes: 24020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
 
            int N = int.Parse(line);
            line = Console.ReadLine();
            string[] strs = line.Split(' ');
            List<int> A = new List<int>(); 
            for(int a = 0; a < N; a++)
            {
                A.Add(int.Parse(strs[a]));
            }
            int[] ArrayA = A.OrderByDescending(x => x).ToArray();
 
            long sum = 0;
 
            int next = 0;
            for(int i = 0; i < N;i++)
            {
                if (i == 0) continue;
                sum += ArrayA[next];
                if (i % 2 == 1) next++;
            }
 
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 51136
#include<iostream>
#include <string>

using namespace std;

double table[100000];

const int PIPOT = 10000;

int main()
{
	int x;

	cin >> x;

	for (long i = -PIPOT; i <= PIPOT; ++i)
	{
		double temp = i;
		table[i + PIPOT] = temp * temp * temp * temp * temp;
	}

	int a, b;

	bool ans = false;

	for (int i = -PIPOT; i <= PIPOT && !ans; ++i)
	{
		for (int j = -PIPOT; j <= PIPOT && !ans; ++j)
		{
			if (table[i + PIPOT] - table[j + PIPOT] == x)
			{
				a = i;
				b = j;
				ans = true;
			}
		}
	}


	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <vector>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a, b;
    cin >> a >> b;
    bool check(false);

    if ((1 <= a && a <= 9) && (1 <= b && b <= 9))
        cout << a * b << endl;
    else
        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int c=1000000007;
signed main()
{
   int n,p=0;
   cin>>n;
   string s;
   cin>>s;
   for(int i=0;i<s.size();)
   {
       p++;
       while(s[i]==s[i+1])
        i++;
       i++;
   }
   cout<<p;
}


Measured memory_bytes: 512
N,K,Q = map(int, input().split())
A = [int(i) for i in input().split()]
A+=[0]
S = sorted(A)
ans =[]
for i in range(1,N+1):
    if S[i]==S[i-1]:
        continue
    mi = S[i]
    L =[]
    x = 0
    for y in range(N+1):
        if A[y]<mi:
            if (y-x)>=K:
                L += sorted(A[x:y])[:y-x-K+1]
            x = y+1
    if len(L)<Q:
        continue
    L.sort()
    ans.append((L[Q-1]-mi))
print(min(ans))

Measured memory_bytes: 3188
function Main(input) {
	input = input.trim();
  var output = 0;
  for(var i = 0; i < input.length; i++){
    if(input.slice(i , i + 1) == "1"){
       output++;
       }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
extern crate core;
use std::collections::HashMap;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize m:i64)(list:[i64]));
    let mut sum = 0;
    let mut map = HashMap::new();
    for x in list
        .into_iter()
        .scan(0, |state, x| {
            *state = *state + x;
            Some(*state)
        })
        .map(|x| x % m)
    {
        let v = map.get(&x).cloned().unwrap_or(0);
        sum += if x == 0 { v + 1 } else { v };
        map_add(&mut map, x, 1);
    }
    sum.to_string()
}

pub fn map_add(map: &mut HashMap<i64, i64>, key: i64, add: i64) {
    let v = match map.get(&key) {
        Some(v) => *v + add,
        None => add,
    };
    map.insert(key, v);
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 2\n4 1 5" => "3",
    test2: "13 17\n29 7 5 7 9 51 7 13 8 55 42 9 81" => "6",
    test3: "10 400000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000" => "25",
}


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

int main() {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  int max = std::max(A, std::max(B, C));
  int min = std::min(A, std::min(B, C));
  int mid = A + B + C - max - min;
  printf("%d", 10 * max + mid + min);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a, &b);
	if(a<b){
	printf("a < b\n");
	}else if(a>b){
	printf("a > b\n");
	}else{printf("a == b\n");
	}
	return 0;
}	

Measured memory_bytes: 580
#include "bits/stdc++.h"

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  int a, b;
  cin >> a >> b;
  auto x = max(a + b, a- b);
  x = max(x, a * b);
  cout << x << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
const int MaxN = 1e5 + 5;
LL a[10];
char s[MaxN];
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		cin>>s;
		if(s[0] == 'M') a[1]++;
		else if(s[0] == 'A') a[2]++;
		else if(s[0] == 'R') a[3]++;
		else if(s[0] == 'C') a[4]++;
		else if(s[0] == 'H') a[5]++;
	}
	LL ans = 0;
	for(int i = 1; i <= 5; i++)
		for(int j = i+1; j <= 5; j++)
			for(int k = j+1; k <= 5; k++)
				ans += a[i]*a[j]*a[k];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;
int64_t _2n[200010];

void init2n()
{
  _2n[0] = 1;
  for (int i = 1; i <= 200000; i++)
    _2n[i] = (_2n[i - 1] * 2) % MOD;
}

int main()
{
  int64_t N, a, b, az = 0, bz = 0, z = 0, ans = 1;
  cin >> N;
  map<pair<int64_t, int64_t>, int64_t> mp;
  for (int i = 0; i < N; i++)
  {
    cin >> a >> b;
    if (a == 0 && b == 0)
    {
      z++;
      continue;
    }
    if (a == 0)
    {
      az++;
      continue;
    }
    if (b == 0)
    {
      bz++;
      continue;
    }
    int64_t g = gcd(a, b);
    a /= g;
    b /= g;
    if (a < 0) // NOTE: aは常に0以上
    {
      a = -a;
      b = -b;
    }
    mp[make_pair(a % MOD, b % MOD)]++;
  }
  init2n();
  for (auto it = mp.begin(); it != mp.end(); it++)
  {
    auto x = *it;
    auto k = x.first;
    int64_t v = x.second;
    if (v == 0)
      continue;
    int64_t na = k.second, nb = k.first;
    if (na < 0)
      na *= -1;
    else
      nb *= -1;
    if (mp.count(make_pair(na, nb)))
    {
      int64_t w = mp.at(make_pair(na, nb));
      int64_t x = (_2n[v] + _2n[w] - 1) % MOD;
      ans = (ans * x) % MOD;
      mp[make_pair(na, nb)] = 0;
    }
    else
    {
      ans = (ans * _2n[v]) % MOD;
    }
  }
  ans = ans * ((_2n[az] + _2n[bz] - 1) % MOD) % MOD;
  cout << (ans + z + MOD - 1) % MOD << endl;
}


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

int main(){
    int a, b, c;

    cin >> a >> b >> c;

    int mod = c%b;  
    bool found = false;
    int times = 2*a;
    int i=2;
    while (i <= b  && !found){
        if(times%b==mod){
            found = true;
        }
        times=i*a;
        i++;
    }
    
    if(found){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
typedef long long ll;

using namespace std;

int N, Q;
ll A[200010], B[200010];
multiset<ll> S;

int main() {
	cin >> N >> Q;
	rep(i, 0, 2 * N) cin >> A[i];
	rep(i, 0, 2 * N) cin >> B[i];
	ll ans = 0; bool odd = false;
	ans += A[0] + A[2 * N - 1];
	rep(i, 1, 2 * N - 1) {
		ans += max(A[i], B[i]);
		odd ^= (A[i] > B[i]);
		S.insert(abs(A[i] - B[i]));
	}
	while(Q--) {
		ll a, x, y;
		cin >> a >> x >> y; a--;
		if(a == 0 || a == 2 * N - 1) {
			ans += x - A[a];
			A[a] = x;
		}
		else {
			odd ^= (A[a] > B[a]);
			odd ^= (x > y);
			ans += max(x, y) - max(A[a], B[a]);
			S.erase(S.lower_bound(abs(A[a] - B[a])));
			S.insert(abs(x - y));
			A[a] = x; B[a] = y;
		}
		cout << (!odd ? ans : ans - (*S.begin())) << endl;
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> v(N);

  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }

  int cnt = 0;

  for(int i = 0; i < N-1; i++){
    if(v.at(i) > v.at(i+1) && cnt == 0){
      cnt++;
      for(int j = i+1; j < N-1; j++){
        if(v.at(j) > v.at(j+1)){
          int temp = v.at(i);
          v.at(i) = v.at(j+1);
          v.at(j+1) = temp;
        }
      }
    }
  }

  int flag = 0;
  for(int i = 0; i < N-1; i++){
    if(v.at(i) > v.at(i+1)){
      flag = 1;
    }
  }

  if(flag){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }

  return 0;
}


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

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

int main(){
	int n, i, j;
	scanf("%d", &n);
	int points_a[n+1], points_b[n+1], points_c[n+1], a, b, c, ans_a, ans_b, ans_c;
	for(i=0;i<n;i++) 
			scanf("%d %d %d", &points_a[i], &points_b[i], &points_c[i]);

	//int ans[4][n+1];
	ans_a = a = points_a[0];
	ans_b = b = points_b[0];
	ans_c = c = points_c[0];

	for(i=1;i<n;i++){
		ans_a = max(b, c) + points_a[i];
		ans_b = max(a, c) + points_b[i];
		ans_c = max(a, b) + points_c[i];

		a = ans_a;
		b = ans_b;
		c = ans_c;

	}
	/*for(i=0;i<n;i++)
			printf("%d ", i);
		printf("\n");
	for(j=0;j<3;j++){
		for(i=0;i<n;i++)
			printf("%d ", ans[i][j]);
		printf("\n");
	}*/
	printf("%d\n", max(ans_a, max(ans_b, ans_c)));
}


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

int K;
int main(){
    queue<long long> Q;
    cin >> K;
    for(int i=1;i<10;i++) Q.push(i);
    long long x = 0;
    for(int i=0;i<K;i++){
        x = Q.front();
        Q.pop();
        if(x%10 != 0){
            Q.push(10*x+x%10-1);
        }
        Q.push(10*x+x%10);
        if(x%10!=9){
            Q.push(10*x+x%10+1);
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int( input().strip() ) ; 
arr = list ( map  ( int , input().strip().split(" ") ) ) ; 


mod = pow ( 10,  9 ) + 7 ;

arr2 = [ 0 for x in range ( N ) ] ;
for x in range ( N -1 , 0 , -1 ) :
	if x == N -1  :
		arr2[x] = arr[x] ; 
	else :
		arr2[x] = ( arr[x] + arr2[x+1] ) % mod ;
t = 0 ; 
for x in range ( N -1 ) : 
	t += ( arr[x] * arr2[x+1] ) % mod ;
	t %= mod ; 
print ( t ) ;


Measured memory_bytes: 31204
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : VP{
    L(const P& a, const P& b){ resize(2); at(0)=a; at(1)=b; }
    L(){ resize(2); }
};
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B /A *(m[1]-m[0]);
}

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		VP v(3);
		for(int j=0; j<3; j++){
			double x,y;
			cin >> x >> y;
			v[j]=P(x, y);
		}
		L ort1( (v[0]+v[1])*0.5, (v[0]+v[1])*0.5 +(v[1]-v[0])*P(0,1) );
		L ort2( (v[1]+v[2])*0.5, (v[1]+v[2])*0.5 +(v[2]-v[1])*P(0,1) );
		P cp = crosspointLL(ort1, ort2);
		cout << fixed;
		cout << setprecision(3);
		cout << cp.X << " " << cp.Y << " " << abs(cp-v[0]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >>a>>b;
    int sum = 0;
    if(a > b){
        sum +=a;
        a--;
    }
    else{
        sum += b;
        b--;
    }
     if(a > b){
        sum +=a;
        a--;
    }
    else{
        sum += b;
        b--;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int to[1010][1010],c[1010][1010],h,w;
 
int Press(int y,int x){
  return y*1010+x;
}
 
struct P{
  int cost,y,x;
  bool operator<(const P&P1)const{
    return cost<P1.cost;
  };
  bool operator>(const P&P1)const{
    return cost>P1.cost;
  };
};
priority_queue<P,vector<P>,greater<P> >Q;
int main(){
  cin>>h>>w;
  lol(i,h)lol(j,w){
    cin>>c[i][j];
    P tmp;
    tmp.cost=c[i][j];
    tmp.y=i,tmp.x=j;
    Q.push(tmp);
    to[i][j]=-2;//?????????
  }
  while(!Q.empty()){
    P tmp=Q.top();
    Q.pop();
    int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
    set<int> st;
    bool ok=true;
    lol(i,4){
      int xx=tmp.x+dx[i],yy=tmp.y+dy[i];
      if(xx<0||yy<0||xx==w||yy==h)continue;
      if(to[yy][xx]==-1)ok=false;
      if(to[yy][xx]>=0)st.insert(to[yy][xx]);
    }
    if(st.size()>=2)ok=false;
    if(ok){
      if(st.size()>=1)to[tmp.y][tmp.x]=*st.begin();
      else to[tmp.y][tmp.x]=Press(tmp.y,tmp.x);
    }
    else to[tmp.y][tmp.x]=-1;
  }
  int ans=0;
  lol(i,h)lol(j,w){
    if(to[i][j]==-1)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 22560
fun main(args: Array<String>) {
    a92(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}


fun a92(args: Array<String>) {
    if (args.size != 4) {
        throw IllegalArgumentException()
    }
    val numList = args.map { it.toInt() }
    val train = numList.take(2).min() ?: 0
    val bus = numList.takeLast(2).min() ?: 0
    println(train + bus)
}

Measured memory_bytes: 31904
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> d;
    REP(i, k) {
        int di;
        cin >> di;
        d.push_back(di);
    }

    int ans;
    for(int i=n;;i++) {
        bool flag = true;
        int num = i;
        ans = i;
        string s = to_string(i);
        for(int j=0;j<s.size();j++) {
            int one_num = num%10;
            num /= 10;
            for(int k=0;k<d.size();k++) {
                if(one_num == d[k]){
                    flag = false;
                    break;
                }
            }
        }
        if(flag)
            break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
<?php

$n = trim(fgets (STDIN));
$nums = explode(" ", trim(fgets(STDIN)));
$array = [0];
// for($i=1; $i<$n; $i++){
// 	if($i===1){
// 		$array[$i]=abs($nums[$i]-$nums[0]);
// 	}else{
// 		$from_one_before_step = $array[$i-1] + abs($nums[$i]-$nums[$i-1]);
// 		$from_two_before_step = $array[$i-2] + abs($nums[$i]-$nums[$i-2]);
// 		$array[$i] = $from_one_before_step < $from_two_before_step ? $from_one_before_step : $from_two_before_step;
// 	}
// }
// echo $array[$n-1] . "\n";


for($i=0; $i<=$n-2; $i++){
	for($j=1; $j<=2; $j++){
		$cost = $array[$i] + abs($nums[$i+$j]-$nums[$i]);
		if(!isset($array[$i+$j])){
			$array[$i+$j] = $cost;
		}else{
			$array[$i+$j] = $cost < $array[$i+$j] ? $cost : $array[$i+$j];
		}
	}
}

echo $array[$n-1] . "\n";


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

int main() {
  long long k;
  cin >> k;
  long long a = k / 50 + 1LL;
  long long diff = a * 50LL - k;
  vector<long long> ans(50, 49LL + a);
  for(int i=0;i<50;i++) {
    if(i < diff) ans[i] -= (51 - diff);
    else ans[i] += diff;
  }
  cout << 50 << endl;
  for(int i=0;i<50;i++) {
    cout << ans[i];
    if(i == 49) cout << endl;
    else cout << " ";
  }
  return 0;
}


Measured memory_bytes: 256