akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;
void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

Node* listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key )
    cur = cur->next;
  return cur;
}

void deleteNode(Node *t) {
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) insert(key);
    else if ( strlen(com) == 6 ) deleteKey(key);
    else if ( com[6] == 'F' ) deleteFirst();
    else deleteLast();
  }

  printList();

  return 0;
}


Measured memory_bytes: 33832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

// dijkstra
struct dijkstra {
    struct edge{int to, cost;};
    int V;
    vint d;
    vint prev;
    vector<vector<edge>> G;

    dijkstra(int n) {init(n);} 

    void init(int n) {
        V = n;
        G.resize(V);
        d.resize(V);
        prev.resize(V);
        rep(i,V) d[i] = inf;
        rep(i,V) prev[i] = -1;
    }

    void add_edge(int s, int t, int cost) {
        s--; t--;
        edge e;
        e.to = t; e.cost = cost;
        G[s].push_back(e);
    }

    void run(int s) {
        s--;
        priority_queue<P, vector<P>, greater<P>> q;
        d[s] = 0;
        q.push(P(0,s));
        while (!q.empty()) {
            P e = q.top(); q.pop();
            int v = e.second;
            if (d[v] < e.first) continue;
            for (auto e: G[v]) {
                if (chmin(d[e.to],d[v]+e.cost)) {
                    prev[e.to] = v;
                    q.push(P(d[e.to],e.to));
                }
            }
        }
    }
};

int main() {
    int n, m; cin >> n >> m;
    dijkstra dj(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        dj.add_edge(a,b,1);
        dj.add_edge(b,a,1);
    }
    dj.run(1);
    for (int i = 1; i < n; i++) {
        if (dj.prev[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << dj.prev[i]+1 << endl;
    }
}

Measured memory_bytes: 13484
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, K, R, S, P int
var T string

func main() {
	sc.Split(bufio.ScanWords)
	N, K = nextInt(), nextInt()
	R, S, P = nextInt(), nextInt(), nextInt()
	T = nextStr()
	runeT := []rune(T)

	ans := 0
	for k := 0; k < K; k++ {
		var last bool
		for i := k; i < N; i += K {
			//2回連続の場合は、falseにする
			if i >= K && runeT[i-K] == runeT[i] && last {
				last = false
			} else {
				//fmt.Println(string(runeT[i]))
				if string(runeT[i]) == "s" {
					ans += R
				} else if string(runeT[i]) == "r" {
					ans += P
				} else {
					ans += S
				}
				last = true
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String n = sc.next();
		
		if(n.length() <= k) System.out.println(n);
		else System.out.println(n.substring(0, k) + "...");
		
	}

}


Measured memory_bytes: 38592
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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() {
	int i, j, k;
	
	int N, M, K;

	int B[200001];
	int S[200001] = { 0 };
	cin >> N;
//	N = 200000;
	rep(i, 1, N + 1) {
		cin >> B[i];
		//B[i] = 1;
	}
	int Ans[200001] = { 0 };
	for (i = N; i > 0; i--)
	{
		if (S[i] % 2 != B[i]) {
			Ans[i] = 1;
		}
		if (Ans[i] == 0)
			continue;
		bool isAdd[200001] = { false };
		int I = i;
		int J = sqrt(i) + 1;
		S[1]++;
		isAdd[1] = true;
		for (j = 2; j <= J; )
		{
			if (!isAdd[I]) {
				S[I] += 1;
				isAdd[I] = true;
			}
			if (I % j == 0) {
				if (!isAdd[j]) {
					S[j] += 1;
					isAdd[j] = true;
				}

				I /= j;

			}
			else
				j++;
		}
		if (!isAdd[I] && I != i) {
			S[I] += 1;
		}
	}

	vector<int> ans;
	rep(i, 1, N + 1) {
		if (Ans[i] == 1) {
			ans.push_back(i);
		}
	}

//	cout << ans.size() << endl;
//	for (auto& x : ans) {
//		cout << x << " ";
//	}
		
	vector<int> result;
	int AA[200001] = { 0 };
	int aa[200001] = { 0 };
	for (i = N; i >0 ; i--)
	{
		for (j = i; j <= N; j+=i)
		{
			AA[i] ^= aa[j];
		}
		if (AA[i] % 2 != B[i]) {
			aa[i] = 1;
			result.push_back(i);
		}
	}
	cout << result.size() << endl;
	for (auto& x : result)
		cout << x << " ";

	return 0;

}


Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 101
int N;
string w[MAX_N];
int main(void){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> w[i];
		for(int j=0; j<i; j++){
			if(w[i] == w[j]){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	for(int i=0; i<N-1; i++){
		if(w[i][w[i].size()-1] != w[i+1][0]){
			cerr << w[i][w[i].size()-1] << ' ' << w[i+1][0] << endl;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> x(n), y(n), h(n);
	pair<pair<int, int>, int> tmp;
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0) tmp = make_pair(make_pair(x[i], y[i]), h[i]);
	}
	pair<pair<int, int>, int> ans = make_pair(make_pair(-1, -1), -1);
	for (int i = 0; i <= 100; ++i) {
		for (int j = 0; j <= 100; ++j) {
			int ht = tmp.second + abs(tmp.first.first - i) + abs(tmp.first.second - j);
			bool flag = true;
			for (int k = 0; k < n; ++k)
				if (max(ht - abs(x[k] - i) - abs(y[k] - j), 0) != h[k]) flag = false;
			if (flag) ans = make_pair(make_pair(i, j), ht);
		}
	}
	cout << ans.first.first << " " << ans.first.second << " " << ans.second << endl;
	
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            Console.WriteLine(a - b + 1);
        }
    }
}


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

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
#define MOD 1000000007
#define TIME system("date +%M:%S.%N")
using Graph = vector<vector<int>>;
using ll = long long;
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

#define x first
#define y second
#define mp make_pair
using Pos = pair<int,int>;
#define ppp(v) cerr << #v << "(" << v.x << "," << v.y << ")"
#define cr cerr << endl;

int main() {
  int n;cin>>n;
  vector<Pos> red(n);
  vector<Pos> blue(n);
  vector<bool> done(n,false); // red flag : true = 処理, false = 未処理
  rep(i,n) {
    int a,b;cin>>a>>b;
    red[i] = mp(a,b);
  }
  rep(i,n) {
    int a,b;cin>>a>>b;
    blue[i] = mp(a,b);
  }
  sort(ALL(blue));

  int ans = 0;
  rep(i,n) {
    Pos p = blue[i];
    Pos q = mp(-1,-1);
    int idx = -1;
    rep(j,n) {
      if (done[j]) continue;
      Pos r = red[j];
      if (r.x < p.x && r.y < p.y && q.y < r.y) {
        q = r;
        idx = j;
      }
    }
    if (idx != -1) {
      ans++;
      done[idx] = true;
    } 
  }

  cout << ans << endl;
}


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

int main(){

  double ax,ay,bx,by,cx,cy,dx,dy;
  double n,s,t;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;

    s = (ay - by) / (ax - bx);
    t = (cy - dy) / (cx - dx);

    if(s == t) cout << "YES" << endl;
    else cout << "NO" << endl;

  }
}

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


int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> B(N);
  for(int i = 0; i < N; ++i){
    cin >> P[i];
    --P[i];
    B[P[i]] = i;
  }
  multiset<long long> S;
  S.insert(-1);
  S.insert(-1);
  S.insert(N);
  S.insert(N);
  long long ans = 0;
  for(long long i = N-1; i >= 0; --i){
    S.insert(B[i]);
    auto itr = S.find(B[i]);
    long long n = *next(itr,1);
    long long nn = *next(itr,2);
    long long p = *prev(itr,1);
    long long pp = *prev(itr,2);
    ans += (i+1)*((nn-n)*(B[i]-p) +
                  (p-pp)*(n-B[i]));
  }
  cout << ans << endl;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
constexpr int N = 1e5+10;
bool isPrime[N];

void initPrime(int n){
    if(n%2==0) return;
    for(int i=3;i<n;i+=2){
        if(n%i==0){
            return;
        }
    }
    isPrime[n]=true;
}

int main(){
    vector<int> s(N,0);
    isPrime[2]=true;
    for(int i=3;i<N;i+=2){
        initPrime(i);
        s[i]+=s[i-2]+( isPrime[i]&&isPrime[(i+1)/2] );
    }
    int q,l,r;
    cin>>q;
    while(q){
        cin>>l>>r;
        cout<<s[r]-(l-1?s[l-2]:0)<<"\n";
        q--;
    }
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <float.h>
#include <cmath>
using namespace std;

int main() {
	
	double ideal = 22;
	double min = DBL_MAX;
	int minId=1000000;
	
	int n;
	
	float id;
	float hght;
	float wght;
	
	double BMI;
	
	
	while(cin>>n,n){
		
		min = DBL_MAX;
		
		for(int i=0;i<n;++i){
			cin >> id >> hght >> wght;
			BMI = wght / (hght*hght) * 10000;
			
			if(fabs(BMI-ideal) < min){min=fabs(BMI-ideal);minId=id;}
			else if(fabs(BMI-ideal) == min){
				if(id<minId){
					min=fabs(BMI-ideal);
					minId=id;
				}
			}
		}
		cout << minId << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1228
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    N := nextInt()
    A := nextInt()
    x := nextInts(N)
    
    // 個数と合計のDPテーブルを作成
    dp := make([][]int, N + 1)
	for i := 0; i < N + 1; i++ {
		dp[i] = make([]int, 50 * 50 + 1)
	}
    
	for j := 0; j < N; j++ {
		for i := 50 * 50; i >= 0; i-- {
			if i - x[j] < 0 {
                // 合計が最大値を超過したらスキップ
				continue
			}
			for k := N - 1; k >= 0; k-- {
				dp[k + 1][i] += dp[k][i - x[j]]
				if k == 0 && i == x[j] {
					dp[k + 1][i] ++
				}
			}
		}
	}
	ans := 0
	for i := 50 * 50; i >= 0; i-- {
		for k := 0; k <= N; k++ {
			if dp[k][i] > 0 {
				if k * A == i {
					ans += dp[k][i]
				}
			}
		}
	}
	fmt.Println(ans)
}
 
/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;


int main(){
  long long N, C;
  long long x[100010] = {}, v[100010] = {};
  cin >> N >> C;
  for(int i = 1; i <= N; i++){
    cin >> x[i] >> v[i];
  }
  x[N+1] = C;
  long long forward_sum[100001] = {}, backward_sum[100001] = {};
  long long ans = 0;
  for(int i = 1; i <= N; i++){
    forward_sum[i] = forward_sum[i-1] - (x[i] - x[i-1]) + v[i];
    backward_sum[i] = backward_sum[i-1] - (x[N+1 +1 - i] - x[N+1+1-i-1]) + v[N+1-i];
    ans = max(forward_sum[i], ans);
    ans = max(backward_sum[i], ans);
  }
  // forward[i].first番目までのところまで進んでforward[i].secondだけ得点を得るのがi番目
  pair<long long, long long>forward[100001], backward[100001];

  // 前に進んでから後ろに戻るパターン
  for(int i = 1; i <= N; i++){
    forward[i].first = forward[i-i].first;
    forward[i].second = forward[i-1].second;
    if(forward_sum[i] - x[i] > forward[i].second){
      forward[i].first = i;
      forward[i].second = forward_sum[i] - x[i];
    }

    backward[i].first = backward[i-1].first;
    backward[i].second = backward[i-1].second;
    if(backward_sum[i] > backward[i-1].second){
      backward[i].first = i;
      backward[i].second = backward_sum[i];
    }
  }
  for(int i = 1; i <= N; i++){
    ans = max(ans, forward[i].second + backward[N-i].second);
  }

  // 後ろに進んでから前に戻るパターン
  for(int i = 1; i <= N; i++){
    forward[i].first = forward[i-1].first;
    forward[i].second = forward[i-1].second;
    if(forward_sum[i] > forward[i-1].second){
      forward[i].first = i;
      forward[i].second = forward_sum[i];
    }

    backward[i].first = backward[i-1].first;
    backward[i].second = backward[i-1].second;
    if(backward_sum[i] - (x[N+1] - x[N+1-i]) > backward[i].second){
      backward[i].first = i;
      backward[i].second = backward_sum[i] - (x[N+1] - x[N+1-i]);
    }
  }
  for(int i = 1; i <= N; i++){
    ans = max(ans, forward[i].second + backward[N-i].second);
  }
  

  
  cout << ans << endl;
}

Measured memory_bytes: 6528
H,W = map(int,input().split())

cost_matrix = [] ##adjacency matrix
for i in range(10):
    cost_matrix.append([int(x) for x in input().split()])

freq = [0 for x in range(10)]
for i in range(H):
    row = [int(x) for x in input().split()]
    for i in range(10):
        freq[i] += row.count(i)

##Floyd-Warshall
for k in range(10):
    for i in range(10):
        for j in range(10):
            if cost_matrix[i][k] == -1 or cost_matrix[k][j] == -1:
                continue
            if cost_matrix[i][j] == -1 or cost_matrix[i][j] > cost_matrix[i][k] + cost_matrix[k][j]:
                cost_matrix[i][j] = cost_matrix[i][k] + cost_matrix[k][j]

ans = 0
for i in range(10):
    ans += freq[i] * cost_matrix[i][1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

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

ll gcd(ll a, ll b) 
{ 
    if (a == 0) return b; 
    return gcd(b % a, a); 
} 

ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
ll mulmod(ll a, ll b, ll mod) 
{ 
    ll res = 0; 
    a = a % mod; 
    while (b > 0) 
    { 
        if (b % 2 == 1) res = (res + a) % mod; 
        a = (a * 2) % mod; 
        b /= 2; 
    }  
    return res % mod; 
} 

int binarySearch(long long int arr[], int l, long long int r, long long int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        // If the element is present at the middle 
        // itself 
        if (arr[mid] == x) 
            return mid; 
  
        // If element is smaller than mid, then 
        // it can only be present in left subarray 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
  
        // Else the element can only be present 
        // in right subarray 
        return binarySearch(arr, mid + 1, r, x); 
    } 
  
    // We reach here when element is not 
    // present in array 
    return -1; 
}

int main(){
    ayush();
    fastio;

    ll t; t=1;
    while(t--){
        string a,b; cin>>a>>b;
        ll n = a.length();
        
        ll ans=0;
        rep(i,n){
            if(a[i]!=b[i]) ans++;
        }
        cout<<ans;
    }   
    return 0;
}


Measured memory_bytes: 3820
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int X = int.Parse(s[0]);
        int Y = int.Parse(s[1]);
        Console.WriteLine(X + Y / 2);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100 + 5;

int n, m;
char gra[MAXN][MAXN];
short sum[MAXN][MAXN];
int ex, ey;
short f[MAXN][MAXN][MAXN][MAXN];

int get_sum(int x1, int y1, int x2, int y2)
{
	if(x1 > x2 || y1 > y2)
		return 0;
	return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}

int dp(int x1, int y1, int x2, int y2)
{
	if(x1 > x2 || y1 > y2)
		return 0;
	if(f[x1][y1][x2][y2] != -1)
		return f[x1][y1][x2][y2];
	int ret = 0, tot = get_sum(x1, y1, x2, y2);
	// cut left
	if(ret < tot)
		ret = max(ret, dp(x1, y1 + 1, x2, y2) + 
			(y1 + m - y2 < ey ? 0 : get_sum(max(x1, ex - n + x2), y1, min(x2, ex + x1 - 1), y1)));
	// cut right
	if(ret < tot)
		ret = max(ret, dp(x1, y1, x2, y2 - 1) +
			(y2 + 1 - y1 > ey ? 0 : get_sum(max(x1, ex - n + x2), y2, min(x2, ex + x1 - 1), y2)));
	// cut up
	if(ret < tot)
		ret = max(ret, dp(x1 + 1, y1, x2, y2) + 
			(x1 + n - x2 < ex ? 0 : get_sum(x1, max(y1, ey - m + y2), x1, min(y2, ey + y1 - 1))));
	// cut up
	if(ret < tot)
		ret = max(ret, dp(x1, y1, x2 - 1, y2) + 
			(x2 + 1 - x1 > ex ? 0 : get_sum(x2, max(y1, ey - m + y2), x2, min(y2, ey + y1 - 1))));
	// cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << ret << endl;
	return f[x1][y1][x2][y2] = ret;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> (gra[i] + 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + (gra[i][j] == 'o');
			if(gra[i][j] == 'E')
				ex = i, ey = j;
		}
	// cout << sum[n][m] << endl;

	memset(f, -1, sizeof(f));

	int ans = dp(1, 1, n, m);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 237824
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll a, b;
	cin >> a >> b;
	ll ans = 1e18;
	if(a <= b){
		ans = b - a;
		ans = min(ans, 1 + abs(-a - b));
	}
	else{
		if(a >= 0) ans = 1 + abs(-a - b);
		ans = min(ans, 2 + abs(a - b));	
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3652
#include <iostream>
int main()
{
  int n,a[3];
  std::cin>>n;
  a[0]=n/100;
  a[1]=n/10-10*a[0];
  a[2]=n-a[1]*10-a[0]*100;
  for(int i=0;i<3;i++){
    if(a[i]==1){
      a[i]=9;
    }
    else{
      a[i]=1;
    }
  }
  for(int i=0;i<3;i++){
    std::cout<<a[i];
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

const double PI = 3.141592653;
const double toRad = PI/180;

int main()
{
	double a,b,c;
    cin>>a>>b>>c;
    cout.setf(ios::fixed);
    //double sinc;
    //sinc = sin(c*toRad);
    //cout<<sinc<<endl;
    //cout<<c<<endl;
    //cout<<sin(c)<<endl;
    //cout<<cos(c)<<endl;
    double S,L,h;
    S = (a*b*sin(c*toRad))/2;
    L = a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c*toRad));
    h = b*sin(c*toRad);
    
    cout<<setprecision(8)<<S<<endl<<L<<endl<<h<<endl;
    
	return 0;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define P pair<ll, ll>
using ll = int64_t;
using namespace std;
#define ketasuu(n) fixed << setprecision(n)
#define btoe(p) p.begin(), p.end()
#define etob(p) p.rbegin(), p.rend()

//define gcd and lcm (using 64bit)
ll gcd(ll a, ll b)
{
    if (a < b)
    {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main(){
    ll n, m;
    cin >> n >> m;
    bool ok=true;
    vector<ll> p(n);
    ll l=1;
    rep(i,n) cin>>p[i];
    rep(i,n){
        p[i]/=2;
        l=lcm(l,p[i]);
        if(l>m){
            ok=false;
            break;
        }
    }
    if(ok){
        rep(i,n){
            if((l/p[i])%2==0){
                ok=false;
                break;
            }
        }
    }
    if(!ok){
        cout<<0<<endl;
        return 0;
    }
    ll ans=(m+l)/(2*l);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    string S, T, Ts, Ss;
    cin >> S >> T;
    Ts = T.at(T.size()-1);
    Ss = S + Ts;

    if(Ss == T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3564
//
//AtCoder Beginner Contest 116
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> h(n);
    int maxH = -1;
    REP(i, n){
        cin >> h[i];
        maxH = max(maxH, h[i]);
    }

    int ans=0;
    FOR(i,1,maxH){
        bool onFlag = false;
        REP(j, n){
            if (h[j] >= i){
                if (!onFlag) ans++;
                onFlag = true;
            }else{
                onFlag = false;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,m;
    cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1 << endl;
    }else if (n == 1 || m == 1){
        cout << max(n,m) - 2 << endl;
    }else{
        cout << (n - 2) * (m - 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))
#define DWORD_MAX		(0xFFFFFFFF)

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;
typedef pair<int, int> P;

#define N_MAX	(100000)
#define M_MAX	(1000)
#define H_MAX	(1000)
#define W_MAX	(1000)

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
typedef struct {
	int no;
	int weight;
} NODE_INFO_ST;
vector<NODE_INFO_ST> nodeInfo[N_MAX];
int nodeColor[N_MAX];

// メイン
int main()
{
	// 入力値
	int N;
	cin >> N;
	REP(i, (N - 1)) {
		int nodeNo1;
		int nodeNo2;
		int weight;
		NODE_INFO_ST stOne1;
		NODE_INFO_ST stOne2;

		cin >> nodeNo1;
		nodeNo1--;
		cin >> nodeNo2;
		nodeNo2--;
		cin >> weight;

		stOne1.no = nodeNo1;
		stOne1.weight = weight;
		stOne2.no = nodeNo2;
		stOne2.weight = weight;

		nodeInfo[nodeNo1].push_back(stOne2);
		nodeInfo[nodeNo2].push_back(stOne1);
	}
	
	// 初期値
	REP(i, N) {
		nodeColor[i] = -1;
	}

	// 0始まり
	queue<int> execQue;
	nodeColor[0] = 0;
	execQue.push(0);
	while (0 < execQue.size()) {
		int execCnt = execQue.size();
		while (0 < execCnt) {
			int execNo = execQue.front();
			int nowColor = nodeColor[execNo];
			execQue.pop();
			execCnt--;
			for (auto nodeOne : nodeInfo[execNo]) {
				if (nodeColor[nodeOne.no] == -1) {
					if (IsEven(nodeOne.weight)) {
						nodeColor[nodeOne.no] = nowColor;
					} else {
						nodeColor[nodeOne.no] = (nowColor == 0) ? 1 : 0;
					}
					execQue.push(nodeOne.no);
				}
			}
		}
	}

	REP(i, N) {
		cout << nodeColor[i] << endl;
	}
	cout << endl;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 10004;

ll n;
vector<ll> edge[MAXN];
ll deg[MAXN];
vector<ll> c;
ll ans[MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n-1) {
        ll u,v;
        cin >> u >> v;
        edge[u].eb(v);
        edge[v].eb(u);
        deg[u]++;
        deg[v]++;
    }
    REP1 (i,n) {
        ll num;
        cin >> num;
        c.eb(num);
    }

    sort(ALL(c));
    ll sum = 0;
    REP (t,n) {
        ll idx = min_element(deg+1,deg+n+1) - deg;
        ans[idx] = c[t];
        sum += deg[idx] * c[t];
        for (auto v : edge[idx]) {
            deg[v]--;
        }
        deg[idx] = INF;
    }

    cout << sum << endl;
    REP1 (i,n) {
        cout << ans[i] << " \n"[i==n];
    }
    return 0;
}


Measured memory_bytes: 1280
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, m ] <- map read . words <$> getLine
	xs <- reverse . sort <$> readInts
	let
		ds = reverse $ sort $ zipWith (-) xs $ tail xs
	print $ sum $ drop ( n - 1 ) ds

Measured memory_bytes: 18812
use std::io::Read;
fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let k: i32 = iter.next().unwrap().parse().unwrap();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a: Vec<i32> = (0..n).map(|_| iter.next().unwrap().parse().unwrap()).collect();

    let mut ans = k - (a[0] + k -a[n-1]);

    for i in 0..n-1 {
        let j = i+1;
        let d = (a[i] - a[j]).abs();
        ans = std::cmp::min(ans, k - d);
    }

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


Measured memory_bytes: 6396
using System;
using System.Linq;
using System.Collections.Generic;

class Bmondai
{
    static void Main()
    {
        var nk= Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = nk[0];
        var K = nk[1];
        var h = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var dp = new int[N];
        dp[0] = 0;
        var index = 0;
        for (int i = 1; i < N; ++i) dp[i] = int.MaxValue;
        while (index < N)
        {
            for (int i=1;i<=K;++i)
            {
                if (N <= index + i) break;
                dp[index + i] = Math.Min(dp[index+i],Math.Abs(h[index+i]-h[index])+dp[index]);
            }
            index++;
        }
        Console.WriteLine(dp[N-1]);
    }
}

Measured memory_bytes: 20064
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,m;
  int array[100005];
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>array[i];
  }
  
  sort(array,array+m);
  for(int i=0;i<m-1;i++){
    array[i]=array[i+1]-array[i];
  }
  sort(array,array+m-1);
  
  long long sum=0;
  for(int i=0;i<m-n;i++){
    sum+=array[i];
  }
  cout<<sum<<endl;
  return(0);
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		
		long sum = 0;
		for(int i=1; i<N+1; i++) {
			if(i%3==0 && i%5==0)
				continue;
			if(i%3==0)
				continue;
			if(i%5==0)
				continue;
			
			sum += i;
		}
		
		System.out.println(sum);
	}

}

Measured memory_bytes: 32648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;




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


int n,count = 0;
cin >> n;
vvi v(n,vector<int>(2));
rep(i,n) cin >> v[i][0] >> v[i][1];

Sort(v);

count += v[0][0];
count += (v[n-1][0] - v[0][0]);
count += v[n-1][1];

cout << count << endl;



//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
long long f[51]={1};
long long p[51]={1};
long long patty (int n,long long x)
{
    if(x>=f[n]-1) return p[n];
    if(x<=1) return 0;
    if(x<=f[n-1]+1) return patty(n-1,x-1);
    if(x==f[n-1]+2) return p[n-1]+1;
    if(x<=f[n]-1) return p[n-1]+1+patty(n-1,x-f[n-1]-2);
}
int main()
{
    int n;
    long long x;
    cin>>n>>x;
    for(int i=1;i<51;i++)
    {
        f[i]=2*f[i-1]+3;
        p[i]=2*p[i-1]+1;
    }
    cout<<patty(n,x);
return 0;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(int, input().split()))

count = 0
switch = 'on'

while True:
    for i in range(n):
        if li[i]%2 == 0:
            li[i] = int(li[i]/2)
        else:
            print(count)
            switch = 'off'
            break
    count += 1

    if switch == 'off':
        break


Measured memory_bytes: 2940
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_B&lang=jp

#include<iostream>
 using namespace std;

int main(){

    double r ;
    cin >> r ;
    
    std::cout << std::fixed;
    cout <<  r * r * 3.1415926535897932387 << " " << 2 * r * 3.1415926535897932387 << endl ;  
    return 0;

}


Measured memory_bytes: 3284
N, *h = $stdin.read.split(/\s/).map(&:to_i)

count = 0
while not (h.all? 0)
  i = 0
  i += 1 while (i < h.size) and (h[i] == 0)

  while (i < h.size) and (h[i] != 0)
    h[i] -= 1
    i += 1
  end

  count += 1
end

puts count


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

int gcd(int n, int m){
  if(n%m==0) return m;
  else return gcd(m, n%m);
}

int main(){
    long long a,b; int g; cin>>a>>b; g = gcd(a, b);
    long long ans = a*b/g;
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int _;
int cnt[maxn];
int main()
{
    fastio();
    int n,x;
    cin>>n;
    for(int i=1;i<n;i++) {cin>>x;cnt[x]++;}
    for(int i=1;i<=n;i++) cout<<cnt[i]<<endl;
    return 0;
}


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

//+=と=+に注意
//バケツは{0}で初期化しないと不具合を生じる
const int INF = 1001000000;

int main(){
  int n,m,en=0,res=0;
  string b[110],r[110];

  cin >> n;
  for(int i=0;i<n;++i){
    cin >> b[i];
  }

  cin >> m;
  for(int i=0;i<m;i++){
    cin >> r[i];
  }

  for(int i=0;i<n;i++){
    res=0;
    for(int j=0;j<n;j++){
      if(b[i]==b[j])res++;
    }
    for(int k=0;k<m;k++){
      if(b[i]==r[k])res--;
    }
    en=max(en,res);
  }

  cout << en << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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



int main(){
    int N,A,B;
cin>>N;
if(N==1){
out("Hello World");
}
else{
cin>>A>>B;
out(A+B);
}

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		if(n % 2 == 0){
			ans = (n / 2) * (n / 2);
		}else{
			ans = (n / 2 + 1) * (n / 2);
		}
		System.out.println(ans);
	}
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][13];

void Main() {
    int n;
    cin >> n;
    priority_queue<double, vector<double>, greater<>> V;
    for (int i = 0; i < n; ++i) {
        int v;
        cin >> v;
        V.push(v);
    }

    while (V.size() != 1) {
        double a = V.top();
        V.pop();
        double b = V.top();
        V.pop();
        V.push((a + b) / 2);
    }
    cout << abs(V.top()) << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb emplace_back
#define pi pair<int,int>
using namespace std;
const int maxn = 1e2 + 4;

int n, w;
int W[maxn], V[maxn];
ll dp[maxn][100004];

int main(){
	cin>>n>>w;
	for (int i = 0; i < n; ++i){
		cin>>W[i]>>V[i];
	}
	for (int i = 1; i <= 100000; ++i){
		dp[0][i] = 1e18;
	}
	dp[0][V[0]] = W[0];
	for (int i = 1; i < n; ++i){
		for (int j = 0; j <= 100000; ++j){
			if (V[i] <= j){
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-V[i]] + W[i]);
			}
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	ll ans = 0;
	for (int i = 100000; i >= 0; --i){
		if (dp[n-1][i] > 0 && dp[n-1][i] <= w){
			ans = i;
			break;
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 80128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    ll c[N];
    for(int i = 0; i < N; i++) cin >> c[i];

    sort(c, c + N);

    ll p[N + 5]; //2^i
    p[0] = 1;
    for(int i = 1; i < N + 5; i++) {
        p[i] = p[i - 1] * 2 % MOD;
    }

    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ll tmp = c[i];
        tmp *= p[i];
        tmp %= MOD;

        int r = N - i - 1;
        if(r == 0) {
            tmp *= p[r];
        } else {
            tmp *= (p[r] + (r * p[r - 1]) % MOD);
        }
        tmp %= MOD;

        ans += tmp;
        ans %= MOD;
    }

    ans *= p[N];
    ans %= MOD;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328