akhauriyash/Code-Regression huggingface dataset:
#初期値の準備
challeng_count = int(input())
score = [0] * 2

#判定
for i in range(challeng_count):
    check_data = input().split()
    check_data_sort = sorted(check_data)
    if check_data[0] == check_data[1]:
        score[0] += 1
        score[1] += 1
    elif check_data[0] == check_data_sort[0]:
        score[1] += 3
    else:
        score[0] += 3

#結果表示
print(" ".join(map(str, score)))



Measured memory_bytes: 5604
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S1 = "";
string S2 = "";
ll cases;

int main() {
    go;
    cin >> S1 >> S2;
    if(S1.size() == S2.size()) {
    	if(S1 > S2) {
    		cout << "GREATER";
    	}
    	else if(S1 < S2) {
    		cout << "LESS";
    	}
    	else {
    		cout << "EQUAL";
    	}
    }
    else {
    	if(S1.size() > S2.size()) {
    		cout << "GREATER";
    	}
    	else {
    		cout << "LESS";
    	}
    }
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

int mat[9][9];
bool judge[9][9];

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

    for(int x = 0; x < n; x++){
        if(x)   cout << endl;

        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                cin >> mat[i][j];
                judge[i][j] = false;
            }
        }

        // horizontal
        for(int i = 0; i < 9; i++){
            int cnt[10] = {};
            for(int j = 0; j < 9; j++){
                cnt[mat[i][j]]++;
            }
            for(int j = 0; j < 9; j++){
                if(cnt[mat[i][j]] > 1)  judge[i][j] = true;
            }
        }

        // vertital
        for(int i = 0; i < 9; i++){
            int cnt[10] = {};
            for(int j = 0; j < 9; j++){
                cnt[mat[j][i]]++;
            }
            for(int j = 0; j < 9; j++){
                if(cnt[mat[j][i]] > 1)  judge[j][i] = true;
            }
        }

        // box
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                int cnt[10] = {};
                for(int k = 0; k < 3; k++){
                    for(int l = 0; l < 3; l++){
                        cnt[mat[3*i + k][3*j + l]]++;
                    }
                }
                for(int k = 0; k < 3; k++){
                    for(int l = 0; l < 3; l++){
                        if(cnt[mat[3*i + k][3*j + l]] > 1)
                            judge[3*i + k][3*j + l] = true;
                    }
                }
            }
        }
        
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                if(judge[i][j]) cout << "*";
                else            cout << " ";
                cout << mat[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3064
<?php
$S = trim(fgets(STDIN));

$array = str_split($S);

$answer = '';

for ($i = 0; $i < count($array); $i++) {
     if ($i % 2 === 0) {
         if($array[$i] === 'R' || $array[$i] === 'U' || $array[$i] === 'D') {
             continue;
         }else {
             $answer = 'No';
             break;
         }
     }else {
         if($array[$i] === 'L' || $array[$i] === 'U' || $array[$i] === 'D') {
             continue;
         }else {
             $answer = 'No';
             break;
         }
     }
}

if(empty($answer)) {
    echo('Yes');
}else {
    echo $answer;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int a,b,c,d,e;
  	cin>>a>>b>>c>>d>>e;
  	if(a!=1)	cout<<1<<endl;
  else if(b!=2)	cout<<2<<endl;
  else if(c!=3)	cout<<3<<endl;
  else if(d!=4)	cout<<4<<endl;
  else	cout<<5<<endl;
}

Measured memory_bytes: 3580
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=list(map(int,input().split()))
    suma=sum(A)
    tmpa=0
    halfa=suma/2
    b=INF
    for i in A:
        tmpa+=i
        b=min(abs(halfa-tmpa),b)
    print(int(b*2))
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 82084
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int l = s.size(), ans = 0;
    for(int i = 0; i < l/2; i++){
        if(s[i]!= s[l - 1 - i]){
            ans++;
        }
    }
    cout << ans;
}

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

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

    vector<int> a(9);
    for (int i=0; i<9; ++i) {
        a[i] = 111 * (i+1) ;
    }

    for (int i=0; i<9; ++i) {
        if (N <= a[i]) {
            cout << a[i] << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N,n;
    scanf("%d",&N);
    vector<int> a={};
    for(int i=0;i<N;i++){
        scanf("%d",&n);
        a.push_back(n);
    }
    sort(a.begin(),a.end(),greater<int>());
    int Alice=0,Bob=0;
    for(int i=0;i<N;i++){
        if(i%2==0){Alice+=a[i];}
        else{Bob+=a[i];}
    }
    cout<<Alice-Bob<<endl;
    return 0;
}


Measured memory_bytes: 384
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 i = Integer.parseInt(br.readLine());

		int [] su = new int[i];

		String str = br.readLine();
		String[] s = str.split(" ");

		for(int n = 0; n < i; n++){
			su[n] = Integer.parseInt(s[n]);
		}

		int max = su[0];
		int min = su[0];
		long sum = 0;

		for(int k = 0; k < su.length; k ++){
			if(max < su[k]){
				max = su[k];

			}else if (min > su[k]){
				min = su[k];
			}
			sum += su[k];
		}
		System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 28384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;cin>>n;
	int a[n];
	rep(i,n) cin>>a[i];

	ll ans=INF;
	for(int i=-100;i<101;i++){
		ll sum=0;
		for(int j=0;j<n;j++){
			sum+=(ll)pow(i-a[j],2);
		}
		ans=min(sum,ans);
	}

	cout<<ans<<"\n";
}

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

using namespace std;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}


unsigned long long getDiv(unsigned long long n, unsigned long long div){

    //long long cnt = 0;

    //for(long long cur = div; cur <= n; cur *= div)
    //    cnt += n / cur;

    return n / div;

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);

    unsigned long long a, b, x;

    cin >> a >> b >> x;

    if(a % x == 0)
        cout << getDiv(b, x) - getDiv(a, x) + 1;
    else
        cout << getDiv(b, x) - getDiv(a, x);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();

        long max = Long.MIN_VALUE;

        max = Math.max(max, a * c);
        max = Math.max(max, a * d);
        max = Math.max(max, b * c);
        max = Math.max(max, b * d);

        System.out.println(max);

    }
}


Measured memory_bytes: 35660
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, l;
    cin >> n >> l;
    
    int sum = 0;
    int best = 1e8;
    rep (i, n) {
        int x = l + i;
        sum += x;
        if (abs(best) > abs(x)) {
            best = x;
        }
    }

    sum -= best;
    println(sum)

    return 0;
}

Measured memory_bytes: 3636
package main

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

var (
	sc scanner
)

func main() {
	x := sc.nextInt()
	fmt.Println((x/500)*1000 + ((x%500)/5)*5)
}

/* template functions */

func init() {
	sc = scanner{
		buf: make([]string, 0, 10000),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 100)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}

func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}

func (s *scanner) resetCur() {
	s.cur = 0
}

func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}

func (s *scanner) nextByte() byte {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur][0]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i, _ := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}

func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur], 64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i, _ := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i], 64)
	}
	s.resetCur()
	return res
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// 切りあげ
func ceil(x float64) int {
	return int(math.Ceil(float64(x)))
}

// x^y % MOD
func pow(x, y int) (res int) {
	res = 1
	M := 1000000000 + 7
	for y > 0 {
		if (y & 1) == 1 {
			res = (res * x) % M
		}
		x = (x * x) % M
		y = y >> 1
	}
	return res
}

// lower_bound uses binary search to searches for x in a sorted slice of ints and returns the index as specified by Search.
// The return value is the index to insert x if x is not present (it could be len(a)). The slice must be sorted in ascending order.
//
// Searchable
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 60)
// => idx = 5
//
// No present
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 10000)
// => idx = 8

func lower_bound(a []int, x int) int {
	return sort.SearchInts(a, x)
}

func var_dump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}


Measured memory_bytes: 640
a,b,c,d=map(int,input().split())
i=0
j=0
while True:
  if c-b>0:
    c=c-b
    i+=1
  else:
    break
while True:
  if a-d>0:
    a-=d
    j+=1
  else:
    break
if i<=j:
  print('Yes')
else:
  print('No')
    

    
  


Measured memory_bytes: 9184
a,b,c = map(int,input().split())
k = int(input())
for i in range(k):
    if b <= a:
        b = 2*b
    elif c <= b:
        c = 2*c
    else:
        break
if a < b and b < c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61116
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

vector<int> wayResult;
bool isEndSearch = false;

void roadSearch(int N, int now, vector<set<int>> &road, vector<int> &isVisit, vector<int> &way) {
	if (now == N) {
		way.push_back(now);
		wayResult = vector<int>(way);
		return;
	}
	if (isVisit[now] > 0 || isEndSearch) {
		return;
	}
	isVisit[now] = 1;
	way.push_back(now);
	for (set<int>::iterator it = road[now].begin(); it != road[now].end(); it++) {
		roadSearch(N, *it, road, isVisit, way);
	}
	way.pop_back();
}

int roadVisit(int now, vector<set<int>> &road, vector<int> &isVisit) {
	if (isVisit[now] > 0) {
		return 0;
	}
	isVisit[now] = 1;
	int count = 1;
	for (set<int>::iterator it = road[now].begin(); it != road[now].end(); it++) {
		count += roadVisit(*it, road, isVisit);
	}
	return count;
}

int main(void) {
	int N, bufa, bufb;
	scanf("%d", &N);
	vector<set<int>> road = vector<set<int>>(N+1, set<int>());
	for (int i = 0; i < N - 1; i++) {
		scanf("%d %d", &bufa, &bufb);
		road[bufa].insert(bufb);
		road[bufb].insert(bufa);
	}

	vector<int> isVisit = vector<int>(N+1, 0);
	vector<int> way;
	roadSearch(N, 1, road, isVisit, way);

	auto wayLen = wayResult.size() -1;
	bufa = wayResult[wayLen/2];
	bufb = wayResult[wayLen / 2 + 1];
	road[bufa].erase(bufb);
	road[bufb].erase(bufa);

	isVisit = vector<int>(N + 1, 0);
	int countVisit = roadVisit(1, road, isVisit);
	if (countVisit > N / 2) {
		printf("Fennec\n");
	}
	else {
		printf("Snuke\n");
	}

	return 0;
}

Measured memory_bytes: 22268
# pythonっぽくなくてダサい
stops=[0,1,2,3,4,5,6,7,8,9,5,4,3,2,1]
istops=[[0],[1,14],[2,13],[3,12],[4,11],[5,10],[6],[7],[8],[9]]

def asloop(cur, end):
	result=[]
	for i in range(cur, cur+len(stops)):
		x=stops[i%len(stops)]
		result.append(x)
		if x==end:
			return	result

def asrecurse(cur, end, result=None):
	if result is None:
		result=[]
	x=stops[cur]
	result.append(x)
	next=(cur+1)%len(stops)
	if x==end:
		return	result
	return asrecurse(next, end, result)

def loop(start, end):
	result=[i for i in range(len(stops)+1)]
	for i in istops[start]:
		a=asloop(i, end)
		if len(a) < len(result):
			result=a
	return	result

nloop=int(input())
for i in range(nloop):
	inputs=input().split()
	result=loop(int(inputs[0]), int(inputs[1]))
	print(' '.join([str(x) for x in result]))


Measured memory_bytes: 5616
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    vector<int> nl;
    int mx = 0;
    do{
        int n;
        cin >> n;
        if (!cin.eof()){
            nl.push_back(n);
            mx = max(mx, n);
        }else{
            break;
        }
    }while(1);


    double r = sqrt(mx);

    list<int> sl;
    vector<int> primes;

    for (int i = 2; i <= mx; i++) {
        sl.push_back(i);
    }

    while (sl.front() <= r) {
        int p = sl.front();
        primes.push_back(p);
        sl.pop_front();

        auto i = sl.begin();
        while(i != sl.end()){
            if(*i % p == 0){
                i = sl.erase(i);
            }
            else {
                i++;
            }
        }
    }

    for (auto&& i : sl) {
        primes.push_back(i);
    }

    for (auto&& n : nl) {
        auto p = upper_bound(primes.begin(), primes.end(), n);
        cout << p - primes.begin() << endl;
    }

    return 0;
}

Measured memory_bytes: 34628
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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,k;
    cin>>n>>k;
    int a[n];
    rep(i,n) cin>>a[i];
    //dp[i]:iがtrueなら先手勝利可能、falseなら勝利不可能
    bool dp[k+1];
    dp[0]=false;
    for(int i=1;i<=k;i++){
        bool f=false;
        for(int j=0;j<n;j++){
            //1個でも負け(false)に遷移できるなら勝ち
            if(i-a[j]>=0){
                if(!dp[i-a[j]]) f=true; 
            }
        }
        dp[i]=f;
    }
    cout<<(dp[k]?"First":"Second")<<endl;
    return 0;
}

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

typedef long long ll;
const int N = 2e5 + 7;
const ll mod = 1e9 + 7;

ll n, a[N], sum[N];
int main() {
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = (sum[i - 1] + a[i]) % mod;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll cnt = sum[n] - sum[i];
        cnt = (cnt + mod) % mod;
        ans = (ans + cnt * a[i] % mod) % mod;
    }
    cout << ans << endl;
   
}

Measured memory_bytes: 6708
#include <iostream>
#include <vector>

int main(void)
{
    int N;
    std::cin >> N;

    std::vector<int> A;
    int ai;
    for (int i = 0; i < N; ++i)
    {
        std::cin >> ai;
        A.push_back(ai);
    }

    int cnt = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        if (A[i] == A[i+1])
        {
            ++cnt;
            ++i;
        }
    }

    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int divceil(int a, int b) {
	return (a + b - 1) / b;
}

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

	int K, P;
	cin >> K >> P;
	VI D(K);
	REP(i, K)cin >> D[i];

	REP(i, P) {
		int N, X, M;
		cin >> N >> X >> M;

		int L = X, E = 0;
		REP(i, K) {
			int num = divceil(N - 1 - i, K);
			L += (D[i] % M)*num;
			if (D[i] % M == 0)E += num;
		}
		cout << (N - 1) - (L / M - X / M) - E << endl;
	}



	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,x,sum=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>x;
      if(K<=x){
        sum=sum+(x-K)*2;
      }
    else{
      sum=sum+(min(x,K-x))*2;
    }
  }
  cout<<sum<<endl;
}     

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	double a;
	double maxv = 0;
	double minv = 1 << 12;
	int i = 0;
	while (cin >> a){
		maxv = max(maxv, a);
		minv = min(minv, a);
		i++;
	}
	cout << maxv - minv << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int main()
{
    int n;
    string s;
    int ans = 0;
    cin >> n >> s;
    rep(i,n-2)if(s.substr(i,3) == "ABC") ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  ll x,a,b;
  cin>>x>>a>>b;

  if(b-a<=0)cout<<"delicious"<<endl;
  else if(b-a<=x)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main()
{
  //Nの入力
  int N;
  cin >> N;
  //B_iの入力
  int B[N-1];
  for(int i = 1; i<N; i++){
    cin >> B[i];
  }
  
  /*for(int i = 1; i<N; i++){
    cout << B[i];
  }
  cout << endl;*/
  
  //B[N] = 0;
  //答えA_iの定義
  int A[N];
  int S = 0;
  
  A[1] = B[1];
  //cout << A[1];
  //cout << " ";
  S = A[1];
  for(int i = 2; i < N; i++){
    if(B[i] < B[i-1]){
      A[i] = B[i];
    } else {
      A[i] = B[i-1];
    }
    //cout << A[i];
    //cout << " ";
    S = S + A[i];
  }
  A[N] = B[N-1]; 	//最後
  
  //出力
  //cout << S;
  
  //debug
  //cout << endl;
  S = 0;
  for(int i = 1; i<N+1; i++){
    //cout << A[i];
    S = S + A[i];
  }
  cout << endl;
  cout << S;
  
  
  /*
  // 整数の入力
    int a;
    cin >> a;
    // スペース区切りの整数の入力
    int b,c;
    cin >> b >> c;
    // 文字列の入力
    string s;
    cin >> s;
    // 出力
    cout << (a+b+c) << " " << s << endl;
    return 0;
    */
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;
 
int main() {
  ll n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,a[100]={},ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=1; i<n; i++) {
    if(a[i]==a[i-1]) {
      a[i]=0;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

M1, D1 = rl()
M2, D2 = rl()
print(1 if M1 != M2 else 0)


Measured memory_bytes: 2940
///----------/// dylanrhodes ///----------///
#include <bits/stdc++.h>
#define f first
#define s second
#define reset(x,a) memset (x,a,sizeof(x))
#define task "D"

using namespace std;

const int MOD = 1e9 + 7;
const int N = 100005;
int n;
long long ans = 0;
int level[N],pa[N];
pair <int,pair<int,int> > t[N];
pair <int,pair<int,int> > edge[2*N];
int cnt = 0;

int Find (int u){
    if (pa[u] == u)
        return u;
    return Find(pa[u]);
}

void Un (int u,int v){
    int x = Find(u);
    int y = Find(v);
    if (x == y)
        return;
    if (level[x] == level[y])
        level[x] ++;
    if (level[x] > level[y])
        pa[y] = x;
    else pa[x] = y;
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//    freopen (task".inp","r",stdin);
//    freopen (task".out","w",stdout);

    cin >> n;
    for (int i = 1; i <= n; i++){
        pa[i] = i;
        cin >> t[i].f >> t[i].s.f;
        t[i].s.s = i;
    }

    sort(t+1,t+1+n);
    for (int i = 2; i <= n; i++){
        edge[++cnt].f = min(abs(t[i].s.f - t[i-1].s.f),abs(t[i].f - t[i-1].f));
        edge[cnt].s.f = t[i].s.s;
        edge[cnt].s.s = t[i-1].s.s;
    }
    for (int i = 1; i <= n; i++){
        int x = t[i].f;
        t[i].f = t[i].s.f;
        t[i].s.f = x;
    }
    sort(t+1,t+1+n);
    for (int i = 2; i <= n; i++){
        edge[++cnt].f = min(abs(t[i].s.f - t[i-1].s.f),abs(t[i].f - t[i-1].f));
        edge[cnt].s.f = t[i].s.s;
        edge[cnt].s.s = t[i-1].s.s;
    }

    sort(edge+1,edge+1+cnt);
    for (int i = 1; i <= cnt; i++){
        int x = Find(edge[i].s.f);
        int y = Find(edge[i].s.s);
        if (x != y){
            Un (x,y);
            ans += 1LL*edge[i].f;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int x;cin >> x;
    rep(i,100000){
        if(100*i <= x && x <= 105*i){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0  << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char s[200005];
int i,j;
int main(){
	scanf("%s",s);
	int len=strlen(s);
	for(i=0;i<len&&s[i]!='A';i++);
	for(j=len-1;j>=0&&s[j]!='Z';j--);
	printf("%d\n",j-i+1);
	return 0;
}

Measured memory_bytes: 384
def f(a, b, nodes, visited):
    if (a in visited):
        return False
    if (a == b):
        return True
    visited.append(a)
    for e in nodes[a]:
        if (f(e, b, nodes, visited)):
            return True
    return False


def main():
    n, m = [int(x) for x in input().split(' ')]
    nodes = {}
    edges = []
    for _ in range(m):
        a, b = [int(x) for x in input().split(' ')]
        if (a in nodes):
            nodes[a].append(b)
        else:
            nodes[a] = [b]
        if (b in nodes):
            nodes[b].append(a)
        else:
            nodes[b] = [a]
        edges.append((a, b))
    ans = 0
    for a, b in edges:
        nodes[a] = [x for x in nodes[a] if x != b]
        nodes[b] = [x for x in nodes[b] if x != a]
        if (not f(a, b, nodes, [])):
            ans += 1
        nodes[a].append(b)
        nodes[b].append(a)
    print(ans)


main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long int
using namespace std;

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

Measured memory_bytes: 256
import java.util.Scanner

import scala.io.StdIn._
object Main extends App {


  val n = scala.io.StdIn.readLine().toLong

  def solve(): String = {
    f(n)
  }

  def f(num: Long): String = {
    if(num == 0) ""
    else {
      val num0Index = num-1
      f(num0Index / 26) + ((num0Index % 26) + 'a').toChar
    }
  }

  println(solve())

}


Measured memory_bytes: 54780
#include<stdio.h>

int main(void){
    int n,x;
    int i,j,k;
    int count=0;

    while(1){
        scanf("%d %d",&n,&x);
        if(n==0&&x==0) break;
        count=0;

        for(i=1;i<n+1;i++){
            for(j=i+1;j<n+1;j++){
                for(k=j+1;k<n+1;k++){
                    if (i+j+k==x) count++;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;

int power(int a, int b){
	if(b==0){
		return 1;
	}
	if(b==1){
		return a%mod;
	}
	if(b%2==1){
		int A=power(a,b/2);
		A=(A*A)%mod;
		A=(a*A)%mod;
		return A;
	}
	else{
		int A=power(a,b/2);
		A=(A*A)%mod;
		// A=(a*A)%mod;
		return A;
	}
}
int h,w,a,b;
int fact[200005];
int ways(int f1,int f2, int t1, int t2){
	int num=fact[t1-f1+t2-f2];
	int den=(power(fact[t1-f1],mod-2)*power(fact[t2-f2],mod-2))%mod;
	int ans=(num*den)%mod;
	return ans;
}
int32_t main(){
	ios::sync_with_stdio(false);
	
	cin>>h>>w>>a>>b;
	// cout<<fun(h,w)<<"\n";
	fact[0]=1;
	for(int i=1;i<200005;i++){
		fact[i]=(i*fact[i-1])%mod;
	}
	int ans=0;
	 // deb(ways(1,1,1,1));
	for(int i=b+1;i<=w;i++){
		// deb(i);
		ans=(ans+(ways(1,1,h-a,i)*ways(h-a+1,i,h,w))%mod)%mod;
	}
	cout<<ans<<"\n";



	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main()
{
	ll n;
	cin >> n;
	vector<ll> av(n);
	ll firstPos = -1;
	for (ll i = 0; i < n; ++i ) {
		cin >> av[i];
		if (av[i] == 1) {
			firstPos = i;
		}
	}

	if (firstPos == -1) {
		cout << -1 << endl;
		return 0;
	}

	ll cur = 2;
	ll ret = firstPos;
	for (ll i = firstPos + 1; i < n; ++i) {
		if (av[i] == cur) {
			++cur;
		}
		else {
			++ret;
		}
	}

	cout << ret << endl;

	return 0;
}

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


using namespace std;
int alltime=0;
typedef struct pp {
	char name[100];
	int t;
}P;
P Q[900008];
int head=0, tail, n;
void enqueue(P p,int x) {
	p.t = x;
	Q[tail] = p;
	tail++;
}
P dequeue() {
	P x = Q[head];
	head++;
	return x;
}
int tailnum() {
	return tail;
}
int headnum() {
	return head;
}

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	cin >> n >> q;
	tail = n;
	for (int i = 0; i < n; i++) {
		cin >> Q[i].name >> Q[i].t;
	}
	while (tailnum()!=headnum()) {
		u = dequeue();
		c = u.t - q;
		if (c <= 0) {
			alltime += u.t;
			cout << u.name << " " << alltime << endl;
		}
		else {
			u.t = c;
			enqueue(u, u.t);
			alltime += q;
		}
		
	}
	
	return 0;
}




Measured memory_bytes: 22312
import sys
n = int(input())
s = [sys.stdin.readline().rstrip() for i in range(n)]
c = [60]*26
ans = []
# a ~ zまでの最小個数を求める
for i in s:
	t = [0]*26
	for j in i:
		t[ord(j)-97] += 1
	for i,j in enumerate(t):
		c[i] = min(j,c[i])
for i,j in enumerate(c):
	ans += chr(i+97)*j
print("".join(ans))

Measured memory_bytes: 3064
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,T = iim()
cost = 1001
for i in range(n):
    c,t = iim()
    if t <= T:
        cost = min(cost,c)
if cost == 1001:
    print('TLE')
else:
    print(cost)


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

//cmdで g++ test.cpp とするとコンパイルできる
typedef long long ll;
typedef pair<int,int> pii;

const int MOD=1000000007;

int main() {
    int N,M,K;
    cin>>N>>M>>K;
    vector<vector<int>> FR(N,vector<int>(0));
    vector<vector<int>> BL(N,vector<int>(0));
    vector<pii> pFR(M);
    vector<pii> pBL(K);
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        FR[a].push_back(b);
        FR[b].push_back(a);
        pFR.at(i)=make_pair(a,b);
    }
    for(int i=0;i<K;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        BL[a].push_back(b);
        BL[b].push_back(a);
        pBL.at(i)=make_pair(a,b);
    }
    vector<int> Group(N,-1);
    queue<int> Q;

    int group_index=0;
    for(int i=0;i<N;i++){
        if(Group[i]!=-1)continue;
        Group[i]=group_index;
        Q.push(i);
        while(!Q.empty()){
            int Qi=Q.front();
            Q.pop();
            int SZ=FR[Qi].size();
            for(int j=0;j<SZ;j++){
                if(Group[FR[Qi][j]]!=-1)continue;
                Group[FR[Qi][j]]=group_index;
                Q.push(FR[Qi][j]);
            }
        }
        group_index++;
    }
    vector<vector<int>> group_member(group_index,vector<int>(0));
    for(int i=0;i<N;i++){
        group_member[Group[i]].push_back(i);
    }
    vector<int> kouho(N);
    for(int i=0;i<N;i++){
        kouho[i]=group_member[Group[i]].size()-1;
    }
    for(int i=0;i<M;i++){
        int a=pFR[i].first,b=pFR[i].second;
        if(Group[a]==Group[b]){
            kouho[a]--;kouho[b]--;
        }
    }
    for(int i=0;i<K;i++){
        int a=pBL[i].first,b=pBL[i].second;
        if(Group[a]==Group[b]){
            kouho[a]--;kouho[b]--;
        }
    }
    for(int i=0;i<N-1;i++){
        cout<<kouho[i]<<" ";
    }
    cout<<kouho[N-1]<<endl;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> h(n);
	for(auto &x : h){
		cin>>x;
	}
	int ans = h[0];
	for(int i = 1; i < n; i++){
		ans += max(0, h[i] - h[i - 1]);
	}
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b;
	cin >> a >> b;
	if(a>b) cout << a-1 << endl;
	else cout << a << endl;
	

}


Measured memory_bytes: 256
from itertools import product

H,W,K=map(int,input().split())
c=[]
ans=0
for i in range(H):
    c.append(input())
for row_bit in product(range(2),repeat=H):
    for col_bit in product(range(2),repeat=W):
        count=0
        #print(row_bit,col_bit)
        for row in range(H):
            for col in range(W):
                if c[row][col]=="#" and (row_bit[row] and col_bit[col]):
                    count+=1
                    #print(row,col)
        if count==K:
            ans+=1
print(ans)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
 
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 1000000000000000007
 
using namespace std;
#define prime 1000000007
 
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
 
int n, m, v[10] = {0,2,5,5,4,5,6,3,7,6};
pair<ii, int> dp[10100];
ii c[10];
vi ans;
 
pair<ii, int> f(int at){
	if(at < 0) return {{-prime, -prime}, -prime};
	if(at == 0) return {{0, 0}, 0};
	if(dp[at] != mp(mp(-1, -1), -1)) return dp[at];
	pair<ii, int> res =  {{-prime, -prime}, -prime};
	for (int i = 0; i < m; ++i){
		pair<ii, int> aux = f(at-c[i].ff);
                aux.ff.ff++;
                aux.ss = at-c[i].ff;
                aux.ff.ss = c[i].ss;

		if(aux > res){
                     res = aux;
		}
	}
	return dp[at] = res;
}
 
int main(){
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++i){
		int x;
		scanf("%d", &x);
		c[i] = {v[x], x};
	}
	sort(c, c+m);
	for (int i = 0; i <= n; ++i){
		dp[i] = {{-1, -1}, -1};
	}
	auto a = f(n);
	int at = n;
	while(at){
		ans.pb(dp[at].ff.ss);
		at = dp[at].ss;
	}
	if(a.ff.ff != (int)ans.size()) while(1);
	// sort(ans.begin(), ans.end());
	// reverse(ans.begin(), ans.end());
	for(int l : ans) printf("%d", l);
	printf("\n");
 
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
    p1, p2, p3 = p[i-1], p[i], p[i+1]
    if p1 < p2 < p3 or p3 < p2 < p1:
        ans += 1
print(ans)

Measured memory_bytes: 3060
while (n,x = gets.chomp.split.map(&:to_i)) != [0, 0]
  p = 0
  (1..n-2).each do |a|
    (a+1..n-1).each do |b|
      (b+1..n).each do |c|
        p += 1 if a+b+c == x
      end
    end
  end
  puts p
end

Measured memory_bytes: 6108
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <tuple>
#include <utility>
#include <stdlib.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.begin(),x.end(),greater<int>())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	LL n, l;
	cin >> n >> l;
	LL sum = 0, num = 0;
	num = l + n - 1;
	
	rep(i, 1, n + 1) sum += (l + i - 1);
	rep(i, 1, n + 1) {
		int aji = l + i - 1;
		if (aji == 0) {
			cout << sum << endl;
			return 0;
		}
	}
	if (num <= 0) {
		cout << sum - num << endl;
	}
	else {
		cout << sum - l << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;


 public class Main
{
	public static void main (String[] args) throws java.lang.Exception{

	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b= a*a;
	int c= b*a;
	int d=a+b+c;
	
	System.out.println(d);
   sc.close();
	}

}

	



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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> s(n), t(n);
  vector<unsigned long long> u(n), v(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &s[i]);
  for (int i = 0; i < n; i++)
    scanf("%d", &t[i]);
  for (int i = 0; i < n; i++)
    scanf("%llu", &u[i]);
  for (int i = 0; i < n; i++)
    scanf("%llu", &v[i]);

  vector<vector<unsigned long long>> ans(n, vector<unsigned long long>(n));
  bool succ = true;
  for (int b = 0; succ && b < 64; b++) {
    vector<int> ub(n), vb(n);
    for (int i = 0; i < n; i++) ub[i] = (u[i] >> b) & 1;
    for (int i = 0; i < n; i++) vb[i] = (v[i] >> b) & 1;

    vector<vector<int>> now(n, vector<int>(n));
    for (int i = 0; i < n; i++)
      if (s[i] == 0 && ub[i] == 1)
        for (int j = 0; j < n; j++)
          now[i][j] = 1;

    for (int i = 0; i < n; i++)
      if (t[i] == 0 && vb[i] == 1)
        for (int j = 0; j < n; j++)
          now[j][i] = 1;

    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (s[i] == 1 && t[j] == 1 && ub[i] == 1 && vb[j] == 1)
          now[i][j] = 1;

    bool rf = false, cf = false;
    vector<int> rc, cc;
    for (int i = 0; i < n; i++) {
      if (ub[i] == 1) rf = true;
      if (vb[i] == 1) cf = true;

      if (s[i] == 0 && ub[i] == 0)
        rc.push_back(i);
      if (t[i] == 0 && vb[i] == 0)
        cc.push_back(i);
    }

    if (!cf) {
      int x = 0;
      for (int i = 0; i < n; i++)
        if (s[i] == 1 && ub[i] == 1) {
          if (cc.empty())
            succ = false;
          else {
            now[i][cc[x % cc.size()]] = 1;
            x++;
          }
        }
    }

    if (!rf) {
      int x = 0;
      for (int i = 0; i < n; i++)
        if (t[i] == 1 && vb[i] == 1) {
          if (rc.empty())
            succ = false;
          else {
            now[rc[x % rc.size()]][i] = 1;
            x++;
          }
        }
    }

    for (int i = 0; i < n; i++)
      if (s[i] == 0) {
        int f = 1;
        for (int j = 0; j < n; j++)
          f = f & now[i][j];
        if (f != ub[i])
          succ = false;
      }
      else {
        int f = 0;
        for (int j = 0; j < n; j++)
          f = f | now[i][j];
        if (f != ub[i])
          succ = false;
      }

    for (int i = 0; i < n; i++)
      if (t[i] == 0) {
        int f = 1;
        for (int j = 0; j < n; j++)
          f = f & now[j][i];
        if (f != vb[i])
          succ = false;
      }
      else {
        int f = 0;
        for (int j = 0; j < n; j++)
          f = f | now[j][i];
        if (f != vb[i])
          succ = false;
      }

    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        ans[i][j] += (static_cast<unsigned long long>(now[i][j]) << b);
  }

  if (succ)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        printf("%llu%c", ans[i][j], " \n"[j + 1 == n]);
  else
    printf("-1\n");

  return 0;
}

Measured memory_bytes: 8508
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

int main() {
	int H,W;
	string str;
	int a[101][101] = {};
	cin >> H >> W;

	int yoko[101] = {};
	int tate[101] = {};

	rep1(i, H) {
		cin >> str;
		rep1(ii, W) {
			if (str[ii - 1] == '#') {
				a[i][ii] = 1;
				yoko[i] += 1;
				tate[ii] += 1;
			}
		}
	}

	rep1(i, H) {
		rep1(ii, W) {
			if (yoko[i] != 0 && tate[ii] != 0) {
				if (a[i][ii] == 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
		}
		if (yoko[i] != 0) cout << "\n";
	}

	Would you please return 0;
}

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

S = [input() for i in range(N)]

a=0
b=0
c=0
d=0
for i in range(N):
    if S[i]=='AC':
        a=a+1
for i in range(N):
    if S[i]=='WA':
        b=b+1
for i in range(N):
    if S[i]=='TLE':
        c=c+1
for i in range(N):
    if S[i]=='RE':
        d=d+1

print('AC x {}'.format(a))
print('WA x {}'.format(b))
print('TLE x {}'.format(c))
print('RE x {}'.format(d))









Measured memory_bytes: 16328
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

func main() {
	sc.Split(bufio.ScanWords)

	S := []byte(getString())
	k := getInt()

	cnt := 1
	ans := 0
	for i := 1; i < len(S); i++ {
		if S[i] == S[i-1] {
			cnt++
		} else {
			ans += cnt / 2
			cnt = 1
		}
	}
	ans += cnt / 2

	if cnt == len(S) {
		out(len(S) * k / 2)
		return
	}

	c := S[0]
	left := 0
	for i := 0; i < len(S); i++ {
		if S[i] == c {
			left++
		} else {
			break
		}
	}
	right := 0
	for i := len(S) - 1; i >= 0; i-- {
		if S[i] == c {
			right++
		} else {
			break
		}
	}

	x := left/2 + right/2 - (left+right)/2

	// out(ans, x, left, right)
	out(ans*k - x*(k-1))
}


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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define fst first
#define scd second
#define PB push_back

using pii=pair<int,int>;
using vpii=vector<pii>;

const int inf = 1e9;

struct edge{int to,cost;};
vector<edge> G[3010];
int d[3010];

int n,m,k;

signed main()
{
	cin>>n>>m>>k;
	rep(i, m) {
		int a,b,l;cin>>a>>b>>l;
		--a,--b;
		G[a].PB(edge{b,l});
		G[b].PB(edge{a,l});
	}
	
	fill_n(d, n+1, inf);
	priority_queue<pii, vpii, greater<pii>> q;
	
	rep(i, k) {
		int a; cin >> a;
		--a;
		d[a] = 0;
		q.push(pii(0, a));
	}
	
	while (q.size()) {
		pii p = q.top(); q.pop();
		
		int v = p.scd;
		
		if (d[v] < p.fst) continue;
		
		for (edge &e : G[v]) {
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(pii(d[e.to], e.to));
			}
		}
	}
	
	//rep(i, n) cout<<"d["<<i<<"] = " << d[i]<<endl;
	
	int ans = 0;
	
	rep(v, n) {
		for (edge &e : G[v]) {
			int mi = min(d[v], d[e.to]), ma = max(d[v], d[e.to]);
			//printf("mi=%d,ma=%d,e.cost=%d\n",mi,ma,e.cost);
			ans = max(ans, ma + (int)ceil(double(e.cost - (ma - mi)) / 2.0));
		}
	}
	
	cout << ans << endl;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

const int INF = 99999999;
const int MAX_V = 1000;

struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];       // for DFS

// add graph the edge
void add_edge(int from, int to, int cap) {
    G[from].emplace_back((edge){to, cap, (int)G[to].size()});
    G[to].emplace_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    rep(i, G[v].size()) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}


signed main() {
	int V, E;
	cin >> V >> E;
	rep(i, E) {
		int u, v, c;
		cin >> u >> v >> c;
		add_edge(u, v, c);
	}
	cout << max_flow(0, V - 1) << endl;
}

Measured memory_bytes: 3184