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

using ll = long long;

using namespace std;

using P = pair<int, int>;
#define fi first
#define se second

int main() {
    int n;
    cin >> n;
    vector seats(n+2, vector(n+2, false));
    vector dist(n+2, vector(n+2, 0));
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            seats[i][j] = true;
            dist[i][j] = min({i, j, n+1-i, n+1-j});
        }
    }
    vector<P> leave;
    for (int i=0, pi; i<n*n; i++) {
        cin >> pi;
        pi--;
        leave.push_back({pi / n + 1, pi % n + 1});
    }
    int ans = 0;
    for (auto &li:leave) {
        seats[li.fi][li.se] = false;
        dist[li.fi][li.se]--;
        ans += dist[li.fi][li.se];
        deque<P> dq;
        dq.push_back(li);
        while (!dq.empty()) {
            P f = dq.front(); dq.pop_front();
            for (int x=max(f.fi-1, 0); x<=min(f.fi+1, n+1); x++) {
                for (int y=max(f.se-1, 0); y<=min(f.se+1, n+1); y++) {
                    if (x != f.fi && y != f.se) continue;
                    if (seats[x][y] && dist[x][y] > dist[f.fi][f.se] + 1) {
                        dist[x][y] = dist[f.fi][f.se] + 1;
                        dq.push_back({x, y});
                    } 
                    if (!seats[x][y] && dist[x][y] > dist[f.fi][f.se]) {
                        dist[x][y] = dist[f.fi][f.se];
                        dq.push_front({x, y});
                    }
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll N;
    cin>>N;
    vector<string> S(N);
    vector<ll> M(5);

    rep(i, N){
        cin>>S[i];
        if(S[i].at(0)=='M')M[0]++;
        if(S[i].at(0)=='A')M[1]++;
        if(S[i].at(0)=='R')M[2]++;
        if(S[i].at(0)=='C')M[3]++;
        if(S[i].at(0)=='H')M[4]++;
    }
    ll Ans=0;
    rep(i, 5){
        for(ll j=i+1; j<5; j++){
            for(ll k=j+1; k<5; k++){
                Ans+=M[i]*M[j]*M[k];
            }
        }
    }
    cout<<Ans<<endl;
}

Measured memory_bytes: 6144
#include <iostream>
    #include <cstdio>
    #include <cstring>
     
    using namespace std;
     
    int main() {
        char c11, c12, c13, c21, c22, c23;
        cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23;
        if (c11 != c23 || c12 != c22 || c13 != c21) puts("NO");
        else puts("YES");
        return 0;
    }

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

using namespace std;

int main() {
	int n; cin >> n;
	set<int> st;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		st.emplace(a);
	}
	cout << (st.size() == n ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 9600
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        final String N = sc.next();

        // final int X = sc.nextInt();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        StringBuffer sb = new StringBuffer(N);

        System.out.println(N.equals(sb.reverse().toString()) ? "Yes" : "No");

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 23892
"use strict";

function main(arg) {
    const input = arg.split("\n")
    const [X,N] = input[0].split(" ").map(x=>Number(x))
    if(N===0) {
        console.log(X)
        return
    }
    const p = input[1].split(" ").map(x=>Number(x))
    //console.log(X)
    //console.log(p)
    
    const sortedP = p.sort((a,b)=>a-b)
    //console.log(sortedP)
    
    let notMatched = []
    for(let i = sortedP[0]-1; i <= sortedP[N-1]+1; i++) {
        //console.log(`i=${i}, X=${X}`)
        if(sortedP.indexOf(i) < 0) {
            notMatched.push(i)
        }
    }
    //console.log(notMatched)
    
    let sortedNotMatched = notMatched.sort((a,b)=>Math.abs(X-a) - Math.abs(X-b))
    console.log(sortedNotMatched ? sortedNotMatched[0] : X)

}

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

Measured memory_bytes: 29648
#!/usr/bin/ruby
class TLLI
	def initialize
		@trianies=[nil,[0,0,0]]
	end
	def root_triany
		1
	end
	def allocate_triany
		siz=@trianies.size
		@trianies[siz]=[0,0,0]
		return siz
	end
	def set_a(id,value)
		return if !@trianies[id]
		@trianies[id][0]=value
	end
	def set_b(id,value)
		return if !@trianies[id]
		@trianies[id][1]=value
	end
	def set_c(id,value)
		return if !@trianies[id]
		@trianies[id][2]=value
	end
	def get_a(id)
		return if !@trianies[id]
		@trianies[id][0]
	end
	def get_b(id)
		return if !@trianies[id]
		@trianies[id][1]
	end
	def get_c(id)
		return if !@trianies[id]
		@trianies[id][2]
	end
end

$black={}
class SETI <TLLI # a=>key, b=>left, c=>right
	def set_entry(key)
		x=root_triany
		y=0
		while x!=0&&!(x==root_triany&&get_a(x)==0) #fixme
			y=x
			if key<get_a(x)
				x=get_b(x)
			else
				x=get_c(x)
			end
		end
		if y==0
			set_a(root_triany,key)
		else
			leaf=allocate_triany
			set_a(leaf,key)
			if key<get_a(y)
				set_b(y,leaf)
			else
				set_c(y,leaf)
			end
		end
	end
	def find_entry(key)
		t=root_triany
		loop{
			return true if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def delete_entry(key)
		left=false
		prev=nil
		t=root_triany
		loop{
			break if key==get_a(t)
			prev=t
			if key<get_a(t)
				t=get_b(t)
				left=true
				return false if t==0
			else
				t=get_c(t)
				left=false
				return false if t==0
			end
		}
		if get_b(t)>0&&get_c(t)>0
			children=inorder_internal(get_c(t))+[t]
			set_a(t,get_a(children[0]))

			prev=children[1]
			#left of parent of t
			if prev!=t
				set_b(prev,0)
				left=true
			else
				left=false
			end
			t=children[0]
		end
		if get_b(t)+get_c(t)>0
			n=get_b(t)+get_c(t)
			if left
				set_b(prev,n)
			else
				set_c(prev,n)
			end
		else
			if left
				set_b(prev,0)
			else
				set_c(prev,0)
			end
		end
	end
	def inorder_internal(t)
		t==0 ? [] : inorder_internal(get_b(t))+[t]
	end
	def print_preorder(t)
		return if t==0
		Kernel.print " #{get_a(t)}"
		print_preorder(get_b(t))
		print_preorder(get_c(t))
	end
	def print_inorder(t)
		return if t==0
		print_inorder(get_b(t))
		Kernel.print " #{get_a(t)}"
		print_inorder(get_c(t))
	end
	def print_postorder(t)
		return if t==0
		print_postorder(get_b(t))
		print_postorder(get_c(t))
		Kernel.print " #{get_a(t)}"
	end
	def print
		print_inorder(root_triany);puts
		print_preorder(root_triany);puts
	end
end

seti=SETI.new
$<.drop(1).each{|l|
	a=l.split
	if a[0]=='insert'
		seti.set_entry(a[1].to_i)
	elsif a[0]=='find'
		puts seti.find_entry(a[1].to_i) ? :yes : :no
	elsif a[0]=='delete'
		seti.delete_entry(a[1].to_i)
	elsif a[0]=='print'
		seti.print
	end
}

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

int main(){
    //入力
    int N,Y;
    cin >> N >> Y;

    //処理
    int a,b,c;//10000円，5000円，1000円札
    bool ans=false;
    for(a=0;a<=N;a++){
        if(ans) break;
        for(b=0;b<=N-a;b++){
            if(ans) break;
            c=N-(a+b);
            if(Y==10000*a+5000*b+1000*c){
                ans = true;
                cout << a << " " << b <<  " " << c << endl;
                break;
            }
        }
    }

    //出力
    if(!ans){
        cout << "-1 -1 -1" << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll n,a,b,c;
ll A=0,B=0,C=0;
vector<string>vs;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>a>>b>>c;
  // vs.resize(n);
  vector<char>vc;
  bool fl = false;
  for(int i=0;i<n;i++){
    string s;cin>>s;
    vs.pb(s);
  }
  for(int i=0;i<n;i++){
    if(vs[i] == "AB"){
      if(a > b){
	if(i!= n-1 && c == 0 && vs[i+1] == "AC" && a == 1){
	  b--,a++;vc.pb('A');
	}else{
	  b++,a--;vc.pb('B');
	}
      }else{
	if(i!= n-1 && c == 0 && vs[i+1] == "BC" && b == 1){
	  b++,a--;vc.pb('B');
	}else{
	  b--,a++;vc.pb('A');
	}
      }
    }else if(vs[i] == "BC"){
      if(b > c){
	if(i!= n-1 && a == 0 && vs[i+1] == "AB" && b == 1){
	  b++,c--;vc.pb('B');
	}else{
	  b--,c++;vc.pb('C');
	}
      }else{
	if(i!= n-1 && a == 0 && vs[i+1] == "AC" && c == 1){
	  b--,c++;vc.pb('C');
	}else{
	  b++,c--;vc.pb('B');
	}
      }
    }else{
      if(a > c){
	if(i!= n-1 && b == 0 && vs[i+1] == "AB" && a == 1){
	  c--,a++;vc.pb('A');
	}else{
	  c++,a--;vc.pb('C');
	}
      }else {
	if(i!= n-1 && b == 0 && vs[i+1] == "BC" && c == 1){
	  c++,a--;vc.pb('C');
	}else{
	  c--,a++;vc.pb('A');
	}
	//c--,a++;vc.pb('A');}
      }
    }
    if(a < 0 || b < 0 || c<0)fl = true;
  }
  if(fl){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
    for(auto c:vc)cout<<c<<endl;
  }
  return 0;
}


Measured memory_bytes: 7400
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

s = str(input())

cnt = 0
b_cnt = 0

for c in s:
    if c == 'B':
        b_cnt += 1
    else:
        cnt += b_cnt
print(cnt)


Measured memory_bytes: 5964
#include<bits/stdc++.h>
using namespace std;
   
int a[8]={},b[8]={},c[15]={},d[15]={},ans[8][8]={};
void dfs(int);
   
int main(){
  int n,r,c1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>r>>c1;
    ans[r][c1]=1;
  }
  dfs(0);
  return 0;
}
void dfs(int x){

  for(int i=0;i<8;i++){
    if(b[i]==1||c[x+i]==1||d[x-i+7]==1)continue;
    a[x]=i;
    b[i]=c[x+i]=d[x-i+7]=1;
    dfs(x+1);
    a[x]=b[i]=c[x+i]=d[x-i+7]=0;
  }


  if(x==8){
  for(int i=0;i<8;i++)
    for(int j=0;j<8;j++)
      if(ans[i][j]==1)
    if(a[i]!=j)return;
   
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++)
      if(a[i] == j)cout<<'Q';
      else cout<<'.';
    cout<<endl;
  }
  }
   

}



Measured memory_bytes: 3108
#include <stdio.h>
#include <math.h>

int day[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};

int isleapyear(int y);
int between_y1andy2_0(int y1, int m1, int d1, int y2, int m2, int d2);
int between_y1andy2_1(int y1, int m1, int d1, int y2, int m2, int d2);
int between_y1andy2_over1(int y1, int m1, int d1, int y2, int m2, int d2);

int main(void) {
    int y1, m1, d1, y2, m2, d2;
    int sum_day = 0;
    
    while(1) {
        
        scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2);
        
        if(y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) {
            break;
        }
        
        if(!(y2 - y1)) {
            sum_day = between_y1andy2_0(y1, m1, d1, y2, m2, d2);
        } else if(y2 - y1 == 1) {
            sum_day = between_y1andy2_1(y1, m1, d1, y2, m2, d2);
        } else if(y2 - y1 > 1) {
            sum_day = between_y1andy2_over1(y1, m1, d1, y2, m2, d2);
        } else {
            return(0);
        }
        
        printf("%d\n", sum_day);
        
    }
    
    return(0);
}

int isleapyear(int y) {
    return(((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)));
}

int between_y1andy2_0(int y1, int m1, int d1, int y2, int m2, int d2) {
    int sum_day = 0;
    int i;
    
    if(!(m2 - m1)) {
        sum_day += d2 - d1;
    } else if(m2 - m1 == 1) {
        sum_day += (day[isleapyear(y1)][m1] - d1) + d2;
    } else if(m2 - m1 > 1) {
        sum_day += (day[isleapyear(y1)][m1] - d1) + d2;
        
        for(i = m1 + 1; i < m2; i++) {
            sum_day += day[isleapyear(y1)][i];
        }
    }
    
    return(sum_day);
}

int between_y1andy2_1(int y1, int m1, int d1, int y2, int m2, int d2) {
    int sum_day = 0;
    int i;
    
    sum_day += (day[isleapyear(y1)][m1] - d1) + d2;
    
    for(i = m1 + 1; i <= 12; i++) {
        sum_day += day[isleapyear(y1)][i];
    }
    for(i = 1; i < m2; i++) {
        sum_day += day[isleapyear(y2)][i];
    }
    
    return(sum_day);
}

int between_y1andy2_over1(int y1, int m1, int d1, int y2, int m2, int d2) {
    int sum_day = 0;
    int i;
    
    sum_day += between_y1andy2_1(y1, m1, d1, y2, m2, d2);
    
    for(i = y1 + 1; i < y2; i++) {
        sum_day += 365 + isleapyear(i);
    }
    
    return(sum_day);
}

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

int main(void)
{
  int memory=0;
  int max;
  cin>>max;
  if(max==1)
  {
    cout<<1;
    return 0;
  }
else
{
  for(int i=2;i<=10;i++)
  {
    if(i*i>max)
    {
      break;
    }
    int num=i;
    while(num*i<=max)
    {
      num=num*i;
    }
    if(num>=memory)
    {
      memory=num;
    }
  }
  for(int i=11;i<=31;i++)
  {
    if(i*i>max)
    {
      break;
    }
    if(i*i>=memory)
    {
      memory=i*i;
    }
  }
  cout<<memory;
}
return 0;
}


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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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; }

int main() {
    ll K;
    cin >> K;
    
    vector<ll> used(K,0);
    ll amari = 7 % K;
    used[amari] += 1;
    ll ans = -1;
    REP(i,K){
        if ( amari == 0 ) {
            ans = i + 1;
            break;
        }
        amari =  ( amari * 10 + 7 ) % K;
        used[amari] += 1;
        if ( used[amari] == 2 ){
            ans = -1;
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 11152
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strings"
)

func main() {
	scan := bufio.NewScanner(os.Stdin)
	scan.Scan()
	in := strings.Split(scan.Text(), "")
	calcStack := NewStackV2(len(in))
	areaStack := NewStackV2(len(in))

	totalSum := 0
	for index, c := range in {
		if c == "\\" {
			calcStack.Push(index)
		} else if c == "/" && !calcStack.IsEmpty() {
			// 取出可以配对的 `\`
			a, _ := calcStack.Pop()
			// 计算横截面面积
			area := index - a.(int)
			// 横截面面积加入总面积
			totalSum += area

			// 将索引对加入面积栈
			for !areaStack.IsEmpty() {
				top, _ := areaStack.Top()
				if a.(int) < top.(Pair).first().(int) {
					area += top.(Pair).second().(int)
					areaStack.Pop()
				} else {
					break
				}
			}
			p := Pair{
				a,
				area,
			}
			areaStack.Push(p)
		}
	}

	fmt.Println(totalSum)
	areaSlice := []int{len(areaStack.GetBucket())}
	for _, i := range areaStack.GetBucket() {
		areaSlice = append(areaSlice, i.(Pair).second().(int))
	}
	trace(areaSlice)

}

type Pair [2]interface{}

func (p Pair) first() interface{} {
	return p[0]
}

func (p Pair) second() interface{} {
	return p[1]
}

func trace(in []int) {
	if len(in) > 0 {
		fmt.Print(in[0])
		for _, i := range in[1:] {
			fmt.Print(" ", i)
		}
	}

	fmt.Println("")
}

// 参考书籍实现版本
type StackV3 struct {
	top int
	capacity int
	bucket []interface{}
}

func NewStackV2(capacity int) StackV3 {
	return StackV3{
		top: 0,
		capacity: capacity,
		bucket: make([]interface{}, capacity),
	}
}

func (s *StackV3) Top() (interface{}, error) {
	if s.IsEmpty() {
		return 0, errors.New("栈空间已空")
	}

	x := s.bucket[s.top - 1]

	return x, nil
}

func (s *StackV3) Push(x interface{}) error {
	if s.IsFull() {
		return errors.New("栈空间已满")
	}

	s.bucket[s.top] = x
	s.top++

	return nil
}

func (s *StackV3) Pop() (interface{}, error) {
	if s.IsEmpty() {
		return 0, errors.New("栈空间已空")
	}

	x := s.bucket[s.top - 1]
	s.top--

	return x, nil
}

func (s *StackV3) IsFull() bool {
	return s.top >= s.capacity
}

func (s *StackV3) IsEmpty() bool {
	return s.top <= 0
}

func (s *StackV3) GetBucket() []interface{} {
	return s.bucket[:s.top]
}


Measured memory_bytes: 2020
#include <iostream>

using namespace std;

int main()
{
  int money = 0;
  bool check = false;
  cin >> money;
  while(money >= 0)
  {
    if(money % 7 == 0 || money % 4 == 0)
    {
      check = true;
      break;
    }
    money -= 7;
  }
  if(check)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
h,w = map(int, input().split())
c = []
for i in range(10):
  arr = list(map(int, input().split()))
  c.append(arr)
  
a = []
for i in range(h):
  arr = list(map(int, input().split()))
  a.append(arr)
  
for i in range(10):
  arr = c[i]
  kakutei = [False] * 10
  kakutei[i] = True

  kakutei_num = 1
  while kakutei_num != 10:
    min_num = 1000000
    index = -1
    for j in range(10):
      if not kakutei[j] and min_num > arr[j]:
        min_num = min(min_num, arr[j])
        index = j
      
    kakutei[index] = True
    kakutei_num += 1
    for j in range(10):
      c[i][j] = min(c[i][j], c[i][index] + c[index][j])
      
ans = 0
for i in range(h):
  for j in range(w):
    if a[i][j] == -1:
      continue
    
    n = a[i][j]
    ans += c[n][1]
'''    
for i in range(len(c)):
  print(c[i])
'''
print(ans)

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

using namespace std;

int main(){

    int n,m,k,a;
    cin >> n >> m;

    vector<int> v(m,0);

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

        cin >> k;

        for(int j = 0; j < k; j++){
            cin >> a;
            v[a - 1]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < m; i++){
        if(v[i] == n) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
s = input().strip()

# 0101010... または 1010101... のどちらかになるしかない。

count0 = 0
count1 = 0
for i, c in enumerate(s):
    if i % 2 == 0:
        if c == '0':
            count1 += 1
        else:
            count0 += 1
    else:
        if c == '0':
            count0 += 1
        else:
            count1 += 1

count = min(count0, count1)
print(count)


Measured memory_bytes: 3188
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    ll c[10][10] = {};
    rep(i, n)
    {
        auto k = i + 1;
        auto t = k % 10;
        auto h = k / (int)pow(10, (int)log10(k));
        c[h][t]++;
    }

    ll ans = 0;
    rep(i, 9)
    {
        rep(j, 9)
        {
            auto d = c[i + 1][j + 1] * c[j + 1][i + 1];
            ans += d;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h> 
using namespace std; 
  
// Driver program to test methods of graph class 
int main() 
{
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

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

using namespace std;

#define MOD 1000000007

int main(){
  int n; cin >> n;
  long long a=0,b=1;
  for(int i=0;i<n;++i){
    int q,x; cin >> q >> x;
    if(q==1) a*=x,b*=x;
    else if(q==2) a-=x;
    else a+=x;
  }
  cout << a << " " << b << endl;
  
  return 0;
}


Measured memory_bytes: 3080
import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        long [] dp = new long[w + 1];
        for(int i = 0; i < n; i++)
        {
            int w1 = sc.nextInt();
            int v = sc.nextInt();
            for(int j = w; j >= w1; j--)
                dp[j] = Math.max(dp[j], dp[j - w1] + v);
        }
        System.out.println(dp[w]);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second     
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)      for(int i=b-1;i>=a;i--)
#define trav(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN          1000000000000000000

using namespace std;

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 


//int dx[4]={0,0,1,-1};
//int dy[4]={1,-1,0,0};
// vector<int>adj[100001];
// int vis[100001]={0};
// vector<int>v1;

void solve()
{
    int n;
    cin>>n;
    int a;
    while(n>0)
    {
        a=n%10;
        if(a==7)
        {
            cout<<"Yes";
            return;
        }
        n=n/10;
    }
    cout<<"No";
}   
    


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define INF 900000000
  
using namespace std;
  
int n, k, c[5010], r[5010], cost[5010];
vector<int> road[5010];
vector<pair<int, int> > adj[5010];
bool done[5010];
pair<int, bool> alr[5010];
set<int> st;
  
int dijkstra ()
{
    for (int i=0; i<5010; i++) cost[i]=INF;
    cost[1]=0;
    priority_queue<pair<int, int> > que;
    memset(done, false, sizeof(done));
    que.push(make_pair(0,1));
    while (!que.empty())
    {
        int a=que.top().second;
        que.pop();
        if (done[a]) continue;
        done[a]=true;
        for (auto u : adj[a])
        {
            int b=u.first, w=u.second;
            if (cost[b]>cost[a]+w)
            {
                cost[b]=cost[a]+w;
                que.push(make_pair(-cost[b],b));
            }
        }
    }
    return cost[n];
}
  
int main()
{
    int a,b;
    cin>>n>>k;
    for (int i=1; i<=n; i++) cin>>c[i]>>r[i];
    for (int i=0; i<k; i++)
    {
        cin>>a>>b;
        road[a].push_back(b);
        road[b].push_back(a);
    }
    for (int i=1; i<=n; i++)
    {
        for (int i=0; i<5010; i++)
        {
            alr[i].first=INF;
            alr[i].second=false;
        }
        st.clear();
        //dfs(1, i, i);
    }
    
    //****
    for(int i=1;i<=n;i++){
	queue<pair<int,int> > Q;
	Q.push(make_pair(i,0));
	bool vis[5010]={0};
	while(!Q.empty()){
	    int x=Q.front().first,y=Q.front().second;
	    Q.pop();
	    if(vis[x])continue;
	    vis[x]=true;
	    if(y<r[i]){
		for(auto z:road[x])Q.push(make_pair(z,y+1));
	    }
	}
	for(int j=1;j<=n;j++)if(vis[j]){
	    adj[i].push_back(make_pair(j,c[i]));
	}
    }
    //*****
    
    cout<<dijkstra()<<'\n';
    return 0;
}



Measured memory_bytes: 127768
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;

    if (A == 0 && B == 0 || (A + B) % 2 != 0) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (A + B) / 2 << endl;
    }
}

Measured memory_bytes: 256
from itertools import accumulate
def is_prime(n):
   if n == 1:
       return False
   for i in range(2, int(n ** 0.5) + 1):
       if n % i == 0:
           return False
   return True

q = int(input())

l, r = [],[]
for _ in range(q):
    t, tt = map(int, input().split())
    l.append(t)
    r.append(tt)

m_r = max(r)

table = [0] * (m_r + 2)
for i in range(1, m_r + 1, 2):
    if is_prime(i) and is_prime((i + 1) // 2):
        table[i] = 1

c_table = list(accumulate(table))

for i in range(q):
    print(c_table[r[i]] - c_table[l[i]-1])

Measured memory_bytes: 69592
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n[55];
int x[50],y[50];

long long  ci(int a){
    long long  sum=1;
        for(int i=1;i<=a;i++){
        sum=sum*2;
        }
    return sum;
}

int main(){
    int a,b;
    int l=0,p=0;
    while(cin>>a>>b){
        for(int i=0;i<a;i++){
        cin>>n[i];

        if(n[i]%2==0){
            x[l++]=n[i];
        }else{
            y[p++]=n[i];
        }
    }
    if(b==0){
        if(p==0||p==1){
            cout<<ci(l)<<endl;
        }else{
            cout<<ci(l)*ci(p)/2<<endl;
        }
    }else{
        if(p==0){
            cout<<0<<endl;
        }else{
            if(l==0){
                cout<<ci(p)<<endl;
            }else{
                cout<<(ci(l))*ci(p)/2<<endl;
            }
        }
    }
        l=0;p=0;

    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int h,w,n;
int x[200005],y[200005];
vector<int>zip[200005];
int main(){
	scanf("%d%d%d",&h,&w,&n);

	for(int i=0;i<n;i++){
		int x,y; scanf("%d%d",&x,&y);
		zip[x].pb(y);
	}
	for(int i=1;i<=h;i++) SORT(zip[i]);
	int R = 1;
	for(int i=1;i<h;i++){
		if(zip[i+1].size() && zip[i+1][0] <= R){
			cout<<i<<endl;
			return 0;
		}
		R++;
		if(zip[i+1].size() && zip[i+1][0] == R){
			R--;
		}
	}
	cout<<h<<endl;
}

Measured memory_bytes: 12672
#include <iostream>
#include <algorithm>
#define FOR(i,n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, k, sum = 0;
	cin >> n >> k;
	int a[n];
	FOR(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	FOR(i, k) {
		sum += a[i];
	}
	cout << sum;
}

Measured memory_bytes: 3612
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      static final long MOD = 1000000007L;
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int K = Integer.parseInt(st.nextToken());
         String input = infile.readLine();
         int N = input.length();
         fac = new long[2000003];
         invfac = new long[2000003];
         fac[0] = invfac[0] = 1L;
         for(int i=1; i <= 2000002; i++)
            fac[i] = (fac[i-1]*i)%MOD;
         invfac[2000002] = power(fac[2000002], MOD-2, MOD);
         for(int i=2000001; i >= 1; i--)
            invfac[i] = (invfac[i+1]*(i+1))%MOD;
         long[] pow25 = new long[1000001];
         pow25[0] = 1L;
         for(int i=1; i <= 1000000; i++)
            pow25[i] = (pow25[i-1]*25)%MOD;
         long res = 0L;
         long pow26 = 1L;
         for(int suffix=0; suffix <= K; suffix++)
         {
            long temp = pow26;
            long mult = (pow25[K-suffix]*starbar(K-suffix, N-1))%MOD;
            temp = (temp*mult)%MOD;
            res += temp;
            if(res >= MOD)
               res -= MOD;
            pow26 *= 26;
            pow26 %= MOD;
         }
         System.out.println(res);
      }
      static long[] fac;
      static long[] invfac;
      public static long starbar(int stars, int bars)
      {
         long res = fac[stars+bars];
         res = (res*invfac[stars])%MOD;
         return (res*invfac[bars])%MOD;
      }
      public static long power(long x, long y, long p) 
      { 
         //0^0 = 1
         long res = 1L;      
         x = x%p;  
         while(y > 0) 
         { 
            if((y&1)==1) 
               res = (res*x)%p; 
            y >>= 1;
            x = (x*x)%p;  
         } 
         return res; 
      } 
   }

Measured memory_bytes: 85200
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <climits>
using namespace std;







int main() {


//  string s = "WBWBWBWBWB";
  string s;
  cin >> s;

  int num_term = 1;
  char c = s[0];
  for (int i = 1; i < s.size(); ++i) {
    if(c != s[i]){
      c = s[i];
      num_term++;
    }
  }

  cout << num_term - 1 << endl;


  return 0;
}



Measured memory_bytes: 512
package main

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

func main() {
	sc := NewScanner()
	K, N := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()

	mn := A[N-1] - A[0]
	mn = minA(mn, A[N-2]+(K-(A[N-1])))

	for i := 0; i < N-1; i++ {
		//fmt.Println(mn)
		mn = minA(mn, A[i]+(K-(A[i+1])))
		//fmt.Println(mn)

	}

	fmt.Println(mn)
}
func minA(a int, b int) int {
	if b < 0 {
		return a
	}
	if a < b {
		return a
	}
	return b
}

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

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

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

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

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

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

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

	return mp
}

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


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

int main() {
	char s[100005];
	int n,i,k=0,ln[100005],rn[100005],ll[100005],rr[100005],c[100005]={0};
	cin >> s;
	n=strlen(s);
	rn[1]=1;
	for(i=1;i<n;i++){
		if(s[i]!=s[i-1]){
			if(s[i]=='L'){
				k++;
				ll[k]=i+1;
				rr[k]=i;
				ln[k]=1;
				rn[k+1]=1;
			}
		} else {
			if(s[i]=='L') ln[k]++;
			else rn[k+1]++;
		}
	}
	for(i=1;i<=k;i++){
		c[ll[i]]+=(rn[i]-(rn[i]%2))/2;
		c[rr[i]]+=(rn[i]+(rn[i]%2))/2;
		c[rr[i]]+=(ln[i]-(ln[i]%2))/2;
		c[ll[i]]+=(ln[i]+(ln[i]%2))/2;
	}
	for(i=1;i<=n;i++){
		cout << c[i];
		if(i<n) cout << " ";
		else cout << endl;
	}
	return 0;
}

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

using namespace std;

#define int long long
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

#define PII pair<int, int>

#define ALL(v) v.begin(), v.end()

#ifdef DBG
#define _log(item) cout << #item << " = " << item << endl
#define _loga(array, val) cout << #array << "[" << val << "] = " << array[val] << endl
#else
#define _log(item)
#define _loga(array, val)
#endif

inline int gcd(int number1, int number2)
{
    int m = number1;
    int n = number2;
    if (number2 > number1) {
        m = number2;
        n = number1;
    }
    while (m != n) {
        int temp = n;
        n = m - n;
        m = temp;
    }
    return m;
}
inline int lcm(int number1, int number2)
{
    return number1 * number2 / gcd(number1, number2);
}

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

int original_d[150][150];
int d[150][150];

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

    int m;
    cin >> m;

    int INF = INT_MAX / 2;

    rep(i, 150){
        rep(j, 150){
            if(i != j){
                d[i][j] = INF;
                original_d[i][j] = INF;
            }
            else{
                d[i][j] = 0;
                original_d[i][j] = 0;
            }
        }
    }

    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
        original_d[a - 1][b - 1] = c;
        original_d[b - 1][a - 1] = c;
    }

    rep(k, n){
        rep(i, n){
            rep(j, n){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = 0;

    rep(i, n){
        rep(j, i){
            _log(i);
            _log(j);
            _log(d[i][j]);
            _log(original_d[i][j]);
            if(original_d[i][j] < INF && original_d[i][j] > d[i][j]){
                ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string>
#define pb push_back
#define ll long long
using namespace std;
int dp[3005][3005];
string getlcs(string& s1,string& s2,int len){
    string ans;
    int i=0,j=0;
    while(len>0){
        if(s1[i]==s2[j]){
            ans.push_back(s1[i]);
            i++;
            j++;
            len--;
        }
        else{
            if(dp[i+1][j]>dp[i][j+1]){
                i++;
            }
            else{
                j++;
            }
        }
    }
    return ans;
}
int lcs(int i,int j,string& s1,string& s2){
    if(i>=s1.size() or j>=s2.size()){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    if(s1[i]==s2[j]){
        return dp[i][j]=1+lcs(i+1,j+1,s1,s2);

    }
    else{
        int l=lcs(i+1,j,s1,s2);
        int r=lcs(i,j+1,s1,s2);
        return dp[i][j]=max(l,r);
    }
}
string solve(string s1,string s2){
    memset(dp,-1,sizeof dp);
    int x=lcs(0,0,s1,s2);
    return getlcs(s1,s2,x);

}
int main(){
    string s1,s2,s3="";
    cin>>s1>>s2;
    cout<<solve(s1,s2)<<endl;

}

Measured memory_bytes: 39352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int m = 0;
  int sum =  0;
  for(int i = 0;i<n;i++){
    int l;
    cin >> l;
    m  = max(m, l);
    sum +=l;
  }
  cout << ( m < (sum-m) ? "Yes" : "No");
}

Measured memory_bytes: 256
use std::cmp::max;
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut a: Vec<(u64, usize)> = a.iter().copied().enumerate().map(|(i, x)| (x, i)).collect();
    a.sort();
    a.reverse();
    let a = a;

    let mut solve = Solve {
        n,
        a,
    };
    solve.solve();
}

struct Solve {
    n: usize,
    a: Vec<(u64, usize)>,
}

impl Solve {
    fn solve(&mut self) {
        let n = self.n;
        let a = &self.a;
        // dbg!(a);

        // 大きい方からi個見て、左端からj個、右端からi - j個埋める
        let mut dp = vec![vec![0u64; n + 1]; n + 1];

        for i in 1..=n {
            for j in 0..=i {
                let (a_i, origin_i) = a[i - 1];
                if j > 0 {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + a_i * (origin_i as i64 - (j - 1) as i64).abs() as u64);
                }
                let k = i - j;
                if k > 0 {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j] + a_i * (origin_i as i64 - (n - k) as i64).abs() as u64);
                }
            }
        }

        let mut ans = 0u64;
        for j in 0..=n {
            ans = max(ans, dp[n][j]);
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 33476
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)

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

# range = xrange
# input = raw_input


def main():
    h = iin()
    ans = 0
    ch, ch1 = h, 1
    while ch*ch1 :
        ch //= 2
        ans += ch1
        ch1 *= 2

    print(ans)



            
        

        
main()
# threading.Thread(target=main).start()


Measured memory_bytes: 38384
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
using test = pair<int, int>;
vector<vector<test>> test_list;
int N;

bool judge(int bit) {
  for (int i = 0; i < N; i++) {
    if (!(bit & (1 << i))) continue;
    for (test t : test_list[i]) {
      int x = t.first;
      int y = t.second;
      if (y == 1 && !(bit & (1 << x))) return false;
      if (y == 0 && (bit & (1 << x))) return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  int A;
  test_list.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A;
    test_list[i].resize(A);
    for (int j = 0; j < A; j++) {
      cin >> test_list[i][j].first >> test_list[i][j].second;
      test_list[i][j].first--;
    }
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    if (judge(bit)) {
      int cnt = 0;
      for (int i = 0; i < N; i++) {
        if (bit & (1 << i)) cnt++;
      }
      ans = max(cnt, ans);
    }
  }
  cout << ans << endl;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n, k; cin >> n >> k;
  vector<int> h(n);
  REP(i, n) cin >> h[i];
  DESC(h);
  int ans = 1000000000;
  FOR(i, 0, n - k + 1) {
    int d = h[i] - h[i + k - 1];
    ans = min(d, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
MOD = int(1e9+7)
def main():
    n,k = map(int,input().split())
    ans = 0
    for i in range(k,n+2):
        # min_sum = sum(range(i))
        min_sum = i*(i-1)//2
        # max_sum = sum(range(n,n-i,-1))
        max_sum = (2*n-i+1)*(i)//2
        # print(min_sum,max_sum)
        ans = (ans + (max_sum-min_sum+1))%MOD
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 63148
import Data.Char(toLower)
main = do
  t <- getLine
  ss <- getContents
  let s = unwords $ takeWhile (/="END_OF_TEXT") $ words ss
  putStrLn $ show (solve s t)
  
solve :: String -> String -> Int
solve s t'= let v=words $ map toLower s
                t = map toLower t' in
            (length . filter (==t)) v

Measured memory_bytes: 3760
from itertools import product


N, M = map(int, input().split())


class WarshallFloyd(object):
    def __init__(self, graph):
        n = len(graph)
        dist = graph
        for k, i, j in product(range(n), repeat=3):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
        self.dist = dist

    def shortest_distance(self, start, goal):
        return self.dist[start][goal]


graph = [[float('inf') for _ in range(N)] for _ in range(N)]
edge = [None] * M
for i in range(M):
    a, b, c = map(int, input().split())
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c
    edge[i] = (a - 1, b - 1, c)

wf = WarshallFloyd(graph)
ans = 0
for e in edge:
    if wf.shortest_distance(e[0], e[1]) != e[2]:
        ans += 1
print(ans)


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

int IM(){
    cout << "Impossible" << endl;
    return 0;
}

int PO(){
    cout << "Possible" << endl;
    return 0;
}

int main(){

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());
    int dis = a[n - 1];
    
    vector<int> cnt(n, 0);
    for(int i = 0; i < n; i++){
        cnt[a[i]]++;
    }

    int num = (dis + 1) / 2;
    for(int i = 0; i < num; i++){
        if(cnt[dis - i] < 2) return IM();
        cnt[dis - i] -= 2;
    }
    if(dis % 2 == 0){
        if(cnt[dis - num] < 1) return IM();
        cnt[dis - num]--;
    }

    int able = (dis % 2 == 0) ? dis - num : dis - (num - 1);

    bool flag = true;
    for(int i = able; i >= 0; i--){
        if(cnt[i] > 0) return IM();
    }

    return PO();
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        exec();
    }

    static void exec() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(b==1) {
            System.out.println(0);
            System.exit(0);
        }

        if(a >= b) {
            System.out.println(1);
            System.exit(0);
        }

        int count = 1;
        int tmp = a;

        while(true) {
            tmp = tmp +( a-1 );
            count ++;
            if(tmp >= b) {
                break;
            }
        }
        System.out.println(count);

    }
}


Measured memory_bytes: 21844
import sys


n = int(sys.stdin.readline().strip())
hs = list(map(int, sys.stdin.readline().strip().split(' ')))


dp = [0]*n

for i in range(1, n):
    x = 10**10
    if i-1 >= 0:
        x = min(x, dp[i-1]+abs(hs[i]-hs[i-1]))
    if i-2 >= 0:
        x = min(x, dp[i-2]+abs(hs[i]-hs[i-2]))
    dp[i] = x
print(dp[n-1])

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

using namespace std;

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n;
   cin >> n;
   map<int, int> mp;
   for(int i = 0; i < n; i++) {
       int foo;
       cin >> foo;
       mp[foo]++;
   }
   int ans = 0;
   for(auto p : mp) {
       if(p.second & 1) ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 8200
#include<bits/stdc++.h>
using namespace std;
const int N=40005;
int n,i,j,x=2,y=3;
vector<int>ans;
inline void addx(){
	ans.push_back(x);
	ans.push_back(x+2);
	if(n!=19994 || (x!=2))ans.push_back(x+4);
	x+=6;
}
inline void addy(){
	ans.push_back(y);
	ans.push_back(y+6);y+=12;
}
int main(){
//	ios::sync_with_stdio(0);
	cin>>n;
	if(n==3){
		puts("2 5 63");
		return 0;
	}
	if(n==4){
		puts("2 5 20 63");
		return 0;
	}
	if(n==6){
		puts("2 4 3 9 15 21");
		return 0;
	}
	n-=5;
	addx();addy();
	for(i=0;i<5000;++i)
		if((n-i*3)%2==0 && (n-i*3)/2<2500)break;
	if(i==5000)i--;
	for(j=1;j<=i;++j){
		addx();
	}
	int en=(n-i*3)/2;
	if(n==19994)en=2499;
	for(j=1;j<=en;++j)
		addy();
//	for(i=n;i;i-=pre[i])if(pre[i]==3)addx();else addy();
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
//	assert(ans.size()==n+5);
	for(vector<int>::iterator it=ans.begin();it!=ans.end();++it)
		cout<<*it<<' ';
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = (a); (i) < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

int main(int argc, const char* argv[]) {
  u64 a, b;
  cin >> a >> b;
  
  u64 ret = 0;
  
  if(a > b) {
    ret = a;
    --a;
  } else {
    ret = b;
    --b;
  }
  
  if(a > b) {
    ret += a;
    --a;
  } else {
    ret += b;
    --b;
  }
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;
}

int main() {
    solve();
    
    return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)



int main() {
	li n;
	cin >> n;
	cout << 48 - n << endl;


	return 0;
}


Measured memory_bytes: 256