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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  int64_t r, s, p;
  std::cin >> r >> s >> p;
  std::string t;
  std::cin >> t;
  std::string tt = t;

  int64_t ans = 0;

  for (int64_t i = 0; i < t.size(); i++) {
    if (i < k) {
      if (t[i] == 'r') {
        ans += p;
      } else if (t[i] == 's') {
        ans += r;
      } else {
        ans += s;
      }
    } else {
      if (t[i] == tt[i - k]) {
        tt[i] = 'x';
      } else {
        if (t[i] == 'r') {
          ans += p;
        } else if (t[i] == 's') {
          ans += r;
        } else {
          ans += s;
        }
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
from functools import partial, reduce
from operator import mul
prod = partial(reduce, mul)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter
primes = list(range(1001))
primes[1] = 0
for i in range(2, int(1000 ** 0.5) + 1):
    if primes[i]:
        for j in range(2 * i, 1001, i):
            primes[j] = 0
primes = [p for p in primes if p != 0]

def main():
    N = II()
    primefactors = Counter()
    for n in range(1, N+1):
        for p in primes:
            if n == 1:
                break
            while n % p == 0:
                primefactors[p] += 1
                n //= p
    ans = reduce(lambda x, y: x * (y+1), primefactors.values(), 1) % MOD
    return ans

print(main())


Measured memory_bytes: 3572
import numpy as np
import itertools
import queue

def accept_input():
    N = int(input())
    xl = []
    ll = []
    for _ in range(N):
        x,l = map(int,input().split())
        xl.append(x)
        ll.append(l)
    return N,xl,ll


N,xl,ll = accept_input()
tl = [x+l for x,l in zip(xl,ll)]
argtl = np.argsort(tl)
robotl = []
for i in range(N):
    if robotl == []:
        robotl.append(argtl[i])
    else:
        curx = xl[robotl[-1]]
        curl = ll[robotl[-1]]
        if curx+curl <= xl[argtl[i]] - ll[argtl[i]]:
            robotl.append(argtl[i])
print(len(robotl))


Measured memory_bytes: 42592
x,y=map(int,input().strip().split())
nums = list(map(int, input().strip().split()))
ans=0
if y==0:
  print(x)
elif x not in nums:
  print(x)
else:
  for i in range(0,102):
    if i not in nums:
      if abs(x-i)<abs(x-ans):
        ans=i
  print(ans)

Measured memory_bytes: 9188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n,m; cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    ll sum = 0;
    rep(i,m) sum += a[i];
    if(sum > n){
        cout << -1 << endl;
        return 0;
    }
    cout << n-sum << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  string s; cin >> s;
  int x, y; cin >> x >> y;

  Graph move(2);  // (horizontal, vertical)
  int dist = 0;
  int direction = 0;

  for (auto c : s) {
    if (c == 'F') {
      ++dist;
    }
    else {
      move[direction].push_back(dist);
      dist = 0;
      direction = 1 - direction;
    }
  }
  move[direction].push_back(dist);

  if (!move[0].empty()) {
    x -= move[0][0];
    move[0].erase(move[0].begin());
  }

  int sum_x = accumulate(all(move[0]), 0);
  int sum_y = accumulate(all(move[1]), 0);

  if (abs(x) > sum_x || abs(y) > sum_y) {
    cout << "No\n";
    return 0;
  }

  boolGraph px, py;
  px.assign(move[0].size()+1, vb(sum_x*2+1, false));
  py.assign(move[1].size()+1, vb(sum_y*2+1, false));
  px[0][sum_x] = py[0][sum_y] = true;

  rep(i,move[0].size()) {
    rep(j,px[0].size()) {
      if (px[i][j]) {
        px[i+1][j-move[0][i]] = px[i+1][j+move[0][i]] = true;
      }
    }
  }

  rep(i,move[1].size()) {
    rep(j,py[0].size()) {
      if (py[i][j]) {
        py[i+1][j-move[1][i]] = py[i+1][j+move[1][i]] = true;
      }
    }
  }
  
  if (px[move[0].size()][x+sum_x] && py[move[1].size()][y+sum_y]) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        long[] s = new long[K + 1];
        long mod = 1000000007;
        for (int i = K; 0 < i; i--) {
            s[i] = pow(K/i, N, mod);
            for (int j = 2; i * j <= K; j++) {
                s[i] -= s[i*j];
            }
        }
        long ans = 0;
        for (int i = 1; i <= K; i++) {
            long t = i * s[i];
            t %= mod;
            ans += t;
            ans %= mod;
        }
        System.out.println(ans);
    }
    private long pow(long base, long d, long mod) {
        if (d == 0) {
            return 1;
        }
        if (d % 2 == 1) {
            long t = base * pow(base, d - 1, mod);
            t %= mod;
            return t;
        }
        long t = pow(base, d / 2, mod);
        t *= t;
        t %= mod;
        return t;
    }
}


Measured memory_bytes: 28332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int h,w;
  cin>>h>>w;
  int a[12]={0,2,0,1,0,1,0,0,1,0,1,0};
  if(a[h-1]==a[w-1]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def branchAndBound(N, items, lim_w):
	items.sort(key=lambda x: x[0] / x[1], reverse=True)
	Value = []
	Weight = []
	Ratio = []
	for v, w in items:
		Value.append(v)
		Weight.append(w)
		Ratio.append(v / w)

	def upperbound(cur, cur_w, cur_v):
		rest_w = lim_w - cur_w
		max_v = ub_v = cur_v
		for j in range(cur + 1, N):
			if Weight[j] <= rest_w:
				rest_w -= Weight[j]
				max_v += Value[j]
				ub_v = max_v
			else:
				ub_v += Ratio[j] * rest_w
				break
		return max_v, ub_v

	answer_v, ub_v = upperbound(-1, 0, 0)

	def dfs(cur, ub_v, cur_w, cur_v):
		nonlocal answer_v
		if answer_v > ub_v or cur == N:
			return
		if cur_w + Weight[cur] <= lim_w:
			dfs(cur + 1, ub_v, cur_w + Weight[cur], cur_v + Value[cur])
		max_v, ub_v = upperbound(cur, cur_w, cur_v)
		if max_v > answer_v:
			answer_v = max_v
		if ub_v > answer_v:
			dfs(cur + 1, ub_v, cur_w, cur_v)

	dfs(0, ub_v, 0, 0)

	return answer_v


def main():
	N, lim_w = map(int, input().split())
	items = [list(map(int, input().split())) for _ in range(N)]
	print(branchAndBound(N, items, lim_w))


if __name__ == "__main__":
	main()



Measured memory_bytes: 5628
#include<stdio.h>

long long int max(long long int a, long long int b){return a<b?b:a;}

int N, A[3000], dif, i, j;
long long int d[3000][3000];

int main(){
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d", A+i);
		d[i][i] = A[i];
	}
	for(dif=1; dif<N; dif++){
		for(i=0; i<N-dif; i++){
			j=i+dif;
			d[i][j] = max(A[i]-d[i+1][j], A[j]-d[i][j-1]);
		}
	}
	printf("%lld\n", d[0][N-1]);
}


Measured memory_bytes: 69888
#include<stdio.h>
int main(){
    int n,m,n_number,m_number,number;
    scanf("%d %d",&n,&m);
    n_number=(n*(n-1))/2;
    m_number=(m*(m-1))/2;
    number=n_number+m_number;
    printf("%d\n",number);
    return 0;
}


Measured memory_bytes: 128
N = int(input()) - 1
s = ''

M = 0
for i in range(1, 1000000):
    M += 26 ** i
    if M > N:
        break

N -= (M - 26**i)

for j in reversed(range(i)):
    K = N // (26 ** j)
    s += chr(K + 97)
    N -= K * (26 ** j)

print(s)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

int main(){
  string a,b;
  cin>>a>>b;
  rep(i,b.size()){
    cout<<a[i]<<b[i];
  }
  if(a.size()>b.size()){cout<<a[a.size()-1];}
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;
using namespace std;

void Main()
{
   int N;
   cin >> N;
   vector<int> H(N);
   for (auto &h : H)
      cin >> h;
   int count = 0;
   int max = 1;
   for (auto h : H)
   {
      if (max <= h)
      {
         max = h;
         count++;
      }
   }
   cout << count << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
char s[510];
char a[510][510],b[510][510];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i+=2){
		for(int j=0;j<m;j++){
			a[i][j]='.';
		}
	}
	for(int i=1;i<n;i+=2){
		for(int j=0;j<m;j++){
			a[i][j]='#';
		}
	}
	for(int i=0;i<n;i+=2){
		for(int j=0;j<m;j++){
			b[i][j]='#';
		}
	}
	for(int i=1;i<n;i+=2){
		for(int j=0;j<m;j++){
			b[i][j]='.';
		}
	}
	for(int i=0;i<n;i++){
		scanf("%s",s);
		for(int j=0;j<m;j++){
			if(s[j]=='#'){
				a[i][j]='#';
				b[i][j]='#';
			}
		}
	}
	for(int i=0;i<n;i++){
		a[i][0]='#',b[i][0]='.';
	}
	for(int i=0;i<n;i++){
		a[i][m-1]='.',b[i][m-1]='#';
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
			putchar(a[i][j]);
		putchar('\n');
	}
	putchar('\n');
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
			putchar(b[i][j]);
		putchar('\n');
	}
    return 0;
}

Measured memory_bytes: 1280
import math

def main():
    a,b,h,m = map(int, input().split())
    hd = math.pi/6*h + math.pi/360*m
    md = math.pi/30*m
    print(math.sqrt(a**2+b**2-2*a*b*math.cos(hd-md)))


if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  int n,k; cin>>n>>k;
  string s; cin>>s;
  
  vi nums;
  int now=1;
  int cnt=0;
  for(int i=0;i<n;i++){
    if(s[i] == '0'+now)cnt++;
    else{
      nums.push_back(cnt);
      now=1-now;
      cnt=1;
    }
  }
  nums.push_back(cnt);
  if(s[n-1]=='0')nums.push_back(0);
  int m=nums.size();
  vi sums(m+1);
  for(int i=0;i<m;i++){
    sums[i+1]=sums[i]+nums[i];
  }
  int ans=0;
  int point=2*k+1;
  for(int i=0;i<m+1;i+=2){
    int tmp=sums[min(point+i,m)]-sums[i];
    chmax(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1272
def nums():
    return list(map(int,input().split(" ")))
def num():
    return int(input())
def yakusu(n):
    res = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.add((i,int(n/i)))
    return res
"""
a,b = nums()
if a <= 9 and b <= 9:
    print(a * b)
else:
    print(-1)
"""
"""
n = num()
qq = []
for i in range(10):
    for j in range(10):
        qq.append(i * j)
if n in qq:
    print("Yes")
else:
    print("No")
"""
N = num()
y = yakusu(N)

min = -1

for i in y:
    x,y = i
    if min == -1:
        min = x + y
    elif min > x + y:
        min = x+y

print(min-2)

Measured memory_bytes: 39408
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : c : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . max 0 $ c - (a - b)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


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



int next_combitantion(int sub){
    int x=sub & -sub,y= sub+x;
    return (((sub&~y)/x)>>1)|y;
    
    
}

bool bitget(int a,int b){
  return a&1<<b;
}


int main(){
    int N,K;
    cin >> N >> K;
    vector<long long> A(N);
    for(long long &i:A)cin >> i;
    
    long long minc=numeric_limits<long long>::max();
    
    for(int i=(1<<K)-1;i<(1<<N);i=next_combitantion(i)){
        long long dis=0;
        long long pre=0;
        for(int j=0;j<N;j++){
            if(bitget(i, j)){
                if(A[j]<=pre){
                    dis+=pre-A[j]+1;
                    pre++;
                }else{
                    pre=max(pre,A[j]);
                }
            }else{
                
                pre=max(pre,A[j]);
               
            }
            
            
        }
        
        minc=min(minc,dis);
        
    }
    
    cout << minc << endl;
    
}

Measured memory_bytes: 3536
<?php
function read_matrix($row)
{
  $matrix = [];
  for ($i = 0; $i < $row; $i++) {
    $input = trim(fgets(STDIN));
    $matrix[] = explode(" ", $input);
  }
  return $matrix;
}

// main
$input = trim(fgets(STDIN));
List($n, $m, $l) = explode(" ", $input);

$matrix_a = read_matrix($n);
$matrix_b = read_matrix($m);

$matrix_c = array_fill(0, $n, array_fill(0, $l, 0));
for ($i = 0; $i < $n; $i++) {
  for ($j = 0; $j < $l; $j++) {
    for ($k = 0; $k < $m; $k++) {
      $matrix_c[$i][$j] += ($matrix_a[$i][$k] * $matrix_b[$k][$j]);
    }
  }
}

// answer
foreach ($matrix_c as $row) {
  echo implode(" ", $row) . PHP_EOL;
}

Measured memory_bytes: 20224
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
#define ll long long
int book[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n ; cin >> n;
    for (int i = 1 ; i <= 100 ; i++){
        for (int j = 1 ; j <= 100 ; j++){
            for (int k = 1 ; k <= 100 ; k++){
               if (i*i+j*j+k*k+i*j+j*k+i*k <= n)
                 book[i*i+j*j+k*k+i*j+j*k+i*k]++;
            }
        }
    }
    for (int i = 1 ; i <= n ; i++) cout << book[i] << endl;
    return 0;
}


Measured memory_bytes: 3564
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	

	int A,B;
	cin>>A>>B;
	if(A<=5)
	{
		cout<<0<<endl;
	}
	else if(A<=12)
	{
		cout<<B/2<<endl;
	}
	else
	{
		cout<<B<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int n,k;
    cin>>n>>k;
    set<int> s;
    for (int i = 0; i < n; ++i) s.insert(i);
    for (int i = 0; i < k; ++i) {
        int d;
        cin>>d;
        for(int j=0;j<d;++j){
            int a;
            cin>>a;
            s.erase(a-1);
        }
    }
    cout << s.size();
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    int ans=-n;
    rep(i,n){
        int a; cin>>a;
        ans+=a;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void yesno(bool c) { OUT(c ? "yes" : "no"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	vi A(N);
	REP(i, N) {
		A[i] = IN();
	}
	int ans = 0;
	REP(i, N) {
		int x = 0;
		int d = x * A[i] + 1;
		while (d <= D) {
			ans++;
			x++;
			d = x * A[i] + 1;

		}
	}
	OUT(ans + 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);
      int N = sc.nextInt();
      int[] A = new int[N+2];
      long sum = 0;
      A[0] = 0;
      A[N+1] = 0;
      for(int i=1;i<N+1;i++){
        A[i] = sc.nextInt();
        sum += Math.abs(A[i]-A[i-1]);
      }
      sum += Math.abs(A[N]);
      for(int i=1;i<N+1;i++){
        long ans = sum-(Math.abs(A[i]-A[i-1])+Math.abs(A[i+1]-A[i]))+Math.abs(A[i-1]-A[i+1]);
        System.out.println(ans);
      }     
    }
}

Measured memory_bytes: 60164
#include<bits/stdc++.h>
#define ll long long
#define cri const register int
#define re register
using namespace std;
int C[3002][3002],S[3002][3002];
inline int read(){
	int x;scanf("%d",&x);
	return x;
}
inline int mo(cri x,cri y){
	return x>=y?x-y:x;
}
inline int qpow(int a,int b,cri mod,int ans=1){
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
int main(){
	cri n=read(),mod=read();
	for(int i=0;i<=n;i++)
		for(int j=C[i][0]=1;j<=i;j++) C[i][j]=mo(C[i-1][j]+C[i-1][j-1],mod);
	for(int i=S[0][0]=1;i<=n+1;i++)
		for(int j=1;j<=i;j++) S[i][j]=(S[i-1][j-1]+1ll*S[i-1][j]*j)%mod;
	int pw=qpow(2,n,mod),ans=0;
	for(int i=0;i<=n;i++){
		int tmp=0;
		for(int j=0,Pw=1;j<=i;j++,Pw=1ll*Pw*pw%mod)
			tmp=(tmp+1ll*S[i+1][j+1]*Pw)%mod;
		ans=(ans+(i&1?mod-1ll:1ll)*C[n][i]%mod*qpow(2,qpow(2,n-i,mod-1),mod)%mod*tmp)%mod;
		pw=1ll*pw*(mod+1>>1)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 58672
N, K = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
ans = 10**18
for i in range(N-K+1):
    ans = min(ans, abs(X[i])+abs(X[i+K-1]-X[i]))
    ans = min(ans, abs(X[i+K-1])+abs(X[i+K-1]-X[i]))
print(ans)


Measured memory_bytes: 62576
S = input()

if S == 'SUN':
    a = 0
if S == 'MON':
    a = 1
if S == 'TUE':
    a = 2
if S == 'WED':
    a = 3
if S == 'THU':
    a = 4
if S == 'FRI':
    a = 5
if S == 'SAT':
    a = 6
    
print( 7-a )

Measured memory_bytes: 3060
def main():
    a, b, k = map(int, input().split())

    ans = set()

    for i in range(k):
        x = a + i
        if x <= b:
            ans.add(x)

        y = b - i
        if a <= y:
            ans.add(y)

    for i in sorted(list(ans)):
        print(i)


def main2():
    a, b, k = map(int, input().split())
    ans = []
    if 2 * k <= b - a + 1:
        for i in range(k):
            ans.append(a + i)
            ans.append(b - i)
    else:
        for i in range(a, b + 1):
            ans.append(i)

    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main2()


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	
	int W,H,x,y,r;
	int t,u,ri,l;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	
	t=y+r;
	u=y-r;
        ri=x+r;
	l=x-r;
	
	if((t>H)||(u<0)||(ri>W)||(l<0)){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	
	
	
	
	return 0;
	
}

Measured memory_bytes: 580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {

		double inta = 0;
		double intb = 0;

		//?§£????????°
		double intd = 0;
		double intr = 0;
		double dbf = 0.0;

		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String strInput = br.readLine();

			ArrayList<Double> NumList = new ArrayList<Double>();

			String[] strNumList = strInput.split(" ", 0);

			for (int i = 0; i < strNumList.length; i++) {
				NumList.add(Double.parseDouble(strNumList[i]));
			}

			inta = NumList.get(0);
			intb = NumList.get(1);

			intd = inta / intb;
			intr = inta % intb;
			dbf = (double)inta / (double)intb;

			System.out.println((int)intd + " " + intr + " " + String.format("%.5f", dbf));
		} catch (IOException e) {
			System.out.println(e);
		}catch (NumberFormatException e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 24684
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define all(x) x.begin(), x.end()
#define VI vector<int>
#define VS vector<string>
#define ll long long
#define INF 2e9
#define fir first
#define sec second
using namespace std;

void Main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    int multiple_ways = (2 * x == w) && (2 * y == h);
    long double area = ((long double)w) * h / 2;
    cout << area << " " << multiple_ways << endl;
}

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

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;
using std::min;

int
main()
{
  int N, L;
  cin >> N >> L;
  int e = (0 <= L ? 0 : min(N - 1, -L));
  cout << ((N * (N - 1) / 2) + N * L - (L + e)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


ll n,K,dp[51][51][3000];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>K;
    dp[0][0][0]=1;
    rep(i,n){
        rep(j,n){
            rep(k,n*n+1){
                dp[i+1][j][k+2*j]+=(2*j+1)*dp[i][j][k];
                dp[i+1][j][k+2*j]%=MOD;
                dp[i+1][j+1][k+2*(j+1)]+=dp[i][j][k];
                dp[i+1][j+1][k+2*(j+1)]%=MOD;
                if(j-1>=0){
                    dp[i+1][j-1][k+(j-1)*2]+=j*j*dp[i][j][k];
                    dp[i+1][j-1][k+(j-1)*2]%=MOD;
                }
            }
        }
    }
    cout<<dp[n][0][K]<<endl;
    return 0;
}

Measured memory_bytes: 60032
from functools import reduce
n = int(input())
a = list(map(int, input().split()))

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)
    

def gcd2(number):
    return reduce(gcd, number)

def lcm(x, y):
    return x * y // gcd(x, y)
def lcm2(number):
    return reduce(lcm, number)

m = lcm2(a) - 1
#print(m)
ans = 0
for i in range(n):
    ans += m % a[i]
print(ans)

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

int a[51], b[51];

vector <int> fix;
vector <int> cur;

vector <int> g[51];
bool vis[51];

void dfs(int nod) {
    vis[nod] = 1;
    for(auto it : g[nod]) {
        if(vis[it] == 0)
            dfs(it);
    }
}

inline bool check(vector <int> cur, int n) {
    int i;
    for(i = 0; i <= 50; i++) {
        g[i].clear();
    }
    for(auto it : cur) {
        for(i = 0; i <= 50; i++) {
            g[i].push_back(i % it);
        }
    }
    for(i = 1; i <= n; i++) {
        memset(vis, 0, sizeof(vis));
        dfs(a[i]);
        if(!vis[b[i]])
            return 0;
    }
    return 1;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for(i = 1; i <= n; i++) {
        cin >> b[i];
    }
    for(int k = 50; k >= 0; k--) {
        cur = fix;
        for(i = k; i >= 1; i--) {
            cur.push_back(i);
        }
        if(check(cur, n) == 0) {
            fix.push_back(k + 1);
            if(k == 50) {
                cout << -1;
                return 0;
            }
        }
    }
    ll ans = 0;
    for(auto it : fix) {
        ans += (1LL << it);
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  int k1 = (c-b);
  int k2 = (b-a);
  if(k1==k2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy";
    else if(s=="Cloudy")cout<<"Rainy";
    else cout<<"Sunny";

    return 0;
}


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

int main() {
  int N, a, b, c;
  cin >> N;
  a = N / 100;
  b = N % 100 / 10;
  c = N % 10;
  if (a == 7 || b == 7 || c == 7) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        String s = scan.next();
        
        int[] alf = new int[26];
        
        for(int i=0;i<s.length();i++)
        {
            alf[s.charAt(i)-'a']++;
        }
        
        for(int i=0;i<alf.length;i++)
        {
            if(alf[i]>1)
            {
                System.out.println("no");
                return;
            }
            
        }
        System.out.println("yes");
    }
}

Measured memory_bytes: 22868
#include<iostream>
using namespace std;
int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a > b > c)
	{
		cout << "No" << endl;
	}
	else if (a == b)
	{
		cout << "No" << endl;
	}
	else if (c == b)
	{
		cout << "No" << endl;
	}
	else if (a == c)
	{
		cout << "No" << endl;
	}
	else if (a > c)
	{
		cout << "No" << endl;
	}
	else if (a > b)
	{
		cout << "No" << endl;
	}
	else if (b > c)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                printf("#");
            }
            printf("\n");
        }
    printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1820
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007

typedef long long ll;

using namespace std;


int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
int gcd(int x, int y)
{
    if(x%y==0)return y;
    else if(y%x==0)return x;
    else return gcd(x%y,y%x);
}
ll gcd(ll x, ll y)
{
    if(x%y==0)return y;
    else if(y%x==0)return x;
    else return gcd(x%y,y%x);
}

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    k-=a[0];
    drep(i,n)
    {
        a[i]-=a[0];
    }
    int l=0;
    while((!(a[l]>0))&&l<n-1)
    {
        l++;
    }
    int g=a[l];
    if(g!=0){
        Rep(i,l,n)
        {
            g=gcd(g,a[i]);
        }
        if((!(k>a[n-1]))&&(k%g==0))
        {
            W("POSSIBLE")
        }
        else
        {
            W("IMPOSSIBLE")
        }
    }
    
    else
    {
        if(k==0)
        {
            W("POSSIBLE")
        }
        else
        {
            W("IMPOSSIBLE")
        }
    }
    return 0;
}

Measured memory_bytes: 640
N = int(input())
a = list(map(int, input().split()))

count_1 = 0
count_2 = 0
count_4 = 0

for i in range(N):
    if a[i] % 4 == 0:
        count_4 += 1
    elif a[i] % 2 == 0:
        count_2 += 1
    else:
        count_1 += 1

if count_2 == 0:
    if count_4 + 1 >= count_1:
        print('Yes')
    else:
        print('No')
else:
    if count_4 >= count_1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break


while True:
    m = int(input())
    if m == 0:
        break

    a = [0 for i in range(7)]
    b = [0 for i in range(7)]
    for i in range(m):
        a[i],b[i] = [int(j) for j in input().split()]

    dp = [[0 for i in range(1001)] for j in range(8)]
    dp[0][0] = 1
    for i in range(7):
        for j in range(1001):
            for k in range(b[i] + 1):
                if j + a[i]*k <= 1000:
                    dp[i+1][j + a[i]*k] += dp[i][j]

    g = int(input())
    for i in range(g):
        n = int(input())
        print(dp[m][n])





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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

LL f(int x1, int x2) {
    if(x1 == 1 && x2 == 1) {
        return 2;
    }else if(x1 == 1 && x2 == 2){
        return 2;
    }else if(x1 == 2 && x2 == 1){
        return 1;
    }else{
        return 3;
    }
}

int main() {
    int N;
    string s1, s2;
    cin >> N;
    cin >> s1;
    cin >> s2;
    vector<int> x;
    REP(i, N) {
        if(s1[i] == s2[i]) {
            x.push_back(1);
        }
        if(s1[i] != s2[i]) {
            x.push_back(2);
            i++;
        }
    }
    vector<LL> dp(x.size());
    dp[0] = x[0] == 1 ? 3 : 6;
    FOR(i, 1, x.size()) {
        dp[i] = (dp[i - 1]*f(x[i - 1], x[i]))%mod;
    }
    cout << dp[x.size() - 1] << endl;
    return 0;
}



Measured memory_bytes: 256
# 数値→アルファベット
def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)

n = input()
n = int(n)

ans = num2alpha(n)

print(ans)



Measured memory_bytes: 9148
#include<iostream>
using namespace std;
int main(void)
{
int n;
cin>>n;

for(int i=0;i<n;i++)
{
	int a[10]={0};
	for(int j=0;j<10;j++)
	{
	int x;
	cin>>x;
	a[j]=x;
	}
	int b=0,c=0,k;
		for(k=1;k<10;k++)
		{
			if(b<a[k])b=a[k];
			else if(c<a[k])c=a[k];
			else 
			{
			cout<<"NO"<<endl;
			break;
			}
		}
		if(k==10)cout<<"YES"<<endl;
	/*for(int i=0;i<10;i++)
	{
	cout<<b[i]<<" ";

	}
	cout<<endl;
	for(int i=0;i<10;i++)
	{
	cout<<c[i]<<" ";
	}
	for(int i=0;i<10-1;i++)
	{
		if(b[i]>b[i+1] && b[i+1]!=0 || c[i]>c[i+1] && c[i+1]!=0)
		{
		cout<<"NO"<<endl;
		break;
		}
	else 
		{
		cout<<"YES"<<endl;
		break;
		}
	}*/
}
return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1<<29)

int c[52][52];
int w,h;
void del(int y,int x){
	c[y][x]=0;
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(c[y+i][x+j])del(y+i,x+j);
		}
	}
}
int main(){
	while(cin>>w>>h,w||h){
		memset(c,0,sizeof(c));
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++)cin>>c[i][j];
		int ans=0;
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++)
				if(c[i][j]){
					ans++;
					del(i,j);
				}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1320
#pragma warning(disable: 4996)

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cmath>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

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

	string s;
	cin >> s;
	bool ok = true;
	if (s[2] != s[3]) ok = false;
	if (s[4] != s[5]) ok = false;
	cout << (ok ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
      	ios_base::sync_with_stdio(false);
      	cin.tie(NULL);
      	int n;
      	cin>>n;
      	int a[n];
      	int cnt[100001]={0};
      	long s=0;
      	for(int i=0;i<n;i++)
        {
          	cin>>a[i];
          	cnt[a[i]]++;
          	s+=a[i];
        }
      	int q;
      	cin>>q;
      	int b,c;
      	while(q--)
        {
          	cin>>b>>c;
          	s+=((c-b)*cnt[b]);
          	cout<<s<<endl;
          	cnt[c]+=cnt[b];
          	cnt[b]=0;
        }
    }

Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define ff(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b) 
string solve(int n){
    int d = n % 10;
    if(d == 2 or d == 4 or d == 5 or d == 7 or d == 9)
        return "hon";
    if(d == 0 or d == 1 or d == 6 or d == 8)
        return "pon";
    return "bon";
}
int main(){
    //FL;
    fin;
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(sz(s) > n){
        cout << s.substr(0, n);
        cout << "...\n"; 
    }else
    cout << s << '\n';
    time;
    return 0;
}   

Measured memory_bytes: 3792
n = int(input())
*a, = map(int, input().split())

ans = 0
for i in range(n):
    ans += a[i]*(-1)**i
ans /= 2

print(int(ans*2), end=' ')
for i in range(n-1):
    ans = a[i] - ans
    print(int(ans*2), end=' ')

Measured memory_bytes: 14092
s = input()
l = len(s)
ans = [1 for _ in range(l)]

for i in range(l):
	if s[i] == 'R':
		if s[i+1] == 'R':
			ans[i+2]+=ans[i]
			ans[i]=0
for i in range(l)[::-1]:
	if s[i] == 'L':
		if s[i-1] =='L':
			ans[i-2]+=ans[i]
			ans[i] = 0

# print(ans)
print(' '.join(map(str, ans)))

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

const int MAXN = 100000+5;

int N;
int sums[MAXN][3];
int vals[MAXN][3];
int aux1,aux2,aux3;
int maximo;
int previ=-1;

int main() {
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>vals[i][0]>>vals[i][1]>>vals[i][2];
	}
	for(int i=1;i<=N;i++){
		for(int j=0;j<3;j++){
			aux1 = vals[i][j]+sums[i-1][0];
			aux2 = vals[i][j]+sums[i-1][1];
			aux3 = vals[i][j]+sums[i-1][2];
			maximo = -1;
			if(aux1>maximo && j!=0){maximo=aux1;}
			if(aux2>maximo && j!=1){maximo=aux2;}
			if(aux3>maximo && j!=2){maximo=aux3;}
			sums[i][j]=maximo;
		}
	}
	aux1=max(sums[N][0],max(sums[N][1],sums[N][2]));
	cout<<aux1;
}

Measured memory_bytes: 2560
import Data.List (span)

main :: IO ()
main = do
  getLine
  hs <- map (read :: String -> Int) . words <$> getLine
  print (f hs)

f :: [Int] -> Int
f [] = 0
f xs
  =
    let
        m = minimum xs
        xss = splits (fmap (subtract m) xs)
      in
        m + sum (fmap f xss)

splits :: [Int] -> [[Int]]
splits [] = []
splits xs
  =
    let
        (px, sx) = span (> 0) xs
        sx' = dropWhile (== 0) sx
      in
        if null px then splits sx' else px : splits sx'


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    double A, B, H, M;
    
    cin >> A >> B >> H >> M;
    double Ax, Ay, Bx, By;
    
    Ax = A * cos((H + M/60)/12 * 360 * M_PI / 180);
    Ay = A * sin((H + M/60)/12 * 360 * M_PI / 180);
    Bx = B * cos(M/60 * 360 * M_PI / 180);
    By = B * sin(M/60 * 360 * M_PI / 180);
    
    cout << setprecision(15);
    cout << sqrt( pow(Ax - Bx, 2) + pow(Ay - By, 2) ) << endl;
    
    return 0;
    
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  ll k,q;
  cin >> k >> q;
  vector<ll> d(k);
  rep(i,k) cin >> d[i];
  rep(ii,q){
      ll n,x,m;
      cin >> n >> x >> m;
      n--;
      x=x%m;
      ll y=0;
      rep(i,k){
          y+=d[i]%m;
          if (d[i]%m==0) y+=m;
      }
      ll ans=0;
      ans=k*(n/k);
      ans-=(x+y*(n/k))/m;
      x=(x+y*(n/k))%m;
      rep(i,n%k){
          if (x+d[i]%m < m && d[i]%m!=0) ans++;
          x=(x+d[i]%m)%m; 
      }
      cout << ans << endl;
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

struct TT{
	LL a,b;
}tt,ss;
LL t,n,m,ans;
LL MOD=1e9+7;

int main()
{
	LL i,j,k,l,res;
	cin>>i>>j>>k;
	if(i==7&&j==5&&k==5)return 0*puts("YES");
	if(i==5&&j==7&&k==5)return 0*puts("YES");
	if(i==5&&j==5&&k==7)return 0*puts("YES");
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

N = int(input())
alist = list(map(int, input().split(" ")))

distribution = {}

def set(key):
    global distribution
    if not key in distribution:
        distribution[key] = 1
    else:
        distribution[key] += 1

for a in alist:
    set(a - 1)
    set(a)
    set(a + 1)

ret = -1
for value in distribution.values():
    if ret < value:
        ret = value
print(ret)


Measured memory_bytes: 19660
N,A,B = map(int, input().split())

ans = 0

for i in range(N+1):
    x = i%10
    if i >= 10:
        x += (i%100-i%10)/10
        if i >= 100:
            x += (i%1000-i%100)/100
            if i >= 1000:
                x += (i%10000-i%1000)/1000
                if i == 10000:
                    x=1
    if A <= x <= B:
        ans += i

print(ans)

Measured memory_bytes: 9132
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
long long int i,j, a, b, c, d,p[200001],q[2][200000],r[200000],n;
int main() {
	cin >> a >> b>>c;
	for (i = 0; i < a; i++) {
		cin >> d;
		if (d < b || d >= c)
			n++;
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
const int nmax=805;
int d1[]={-1,0,1,0};
int d2[]={0,-1,0,1};
pair<int,int> q[nmax*nmax];
string s[nmax];
int d[nmax][nmax];
int n,m,k,i,j,l1,c1,p,u,li,ci,lf,cf,ans;
int main()
{
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
        cin>>s[i];
        s[i]=" "+s[i];
        for(j=1;j<=m;j++)
            if(s[i][j]=='S')
        {
            l1=i;c1=j;
        }
        else
            if(s[i][j]=='#')
               d[i][j]=-1;
    }
    q[u=1]={l1,c1};
    d[l1][c1]=1;
    for(p=1;p<=u;p++)
    {
        li=q[p].first;ci=q[p].second;
        for(i=0;i<4;i++)
        {
            lf=li+d1[i];cf=ci+d2[i];
            if(lf>=1&&lf<=n&&cf>=1&&cf<=m&&(!d[lf][cf]))
            {
                q[++u]={lf,cf};
                d[lf][cf]=d[li][ci]+1;
            }
        }
    }
    ans=n*m+1;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
          if(d[i][j]>=1&&d[i][j]<=k+1)
          {
              ans=min(ans,(n-i+k-1)/k+1);
              ans=min(ans,(i-1+k-1)/k+1);
              ans=min(ans,(m-j+k-1)/k+1);
              ans=min(ans,(j-1+k-1)/k+1);
          }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8320
#include <iostream>

using namespace std;
int main(void)
{
	int input, hh, mm, ss;

	cin >> input;
	int time = 60;

	mm = input / time;
	ss = input % time;
	hh = mm / time;
	mm = mm%time;
	cout << hh << ":" << mm << ":" << ss << "\n";

	return 0;
}





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

int su[100001];
int main(){
	int n;
	scanf("%d",&n);
	long long pls[2] = {0, 0};
	long long now = 0;
	for(int i=0;i<n;i++){
		scanf("%d",&su[i]);
	}
	for(int j=0;j<2;j++){
		now = 0;
		for(int i=0;i<n;i++){
			now += su[i];
			if((i+j)%2){
				if(now <= 0){
					pls[j] += 1 - now;
					now = 1;
				}
			}else{
				if(now >= 0){
					pls[j] += now + 1;
					now = -1;
				}
			}
		}
	}
	printf("%lld\n", min(pls[0], pls[1]));
}

Measured memory_bytes: 640
/**
*    created: 28.06.2020 01:04:48
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
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;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    int ans = 0;
    rep2(k,1,n+1) {
        int d = n / k;
        ans += k * d * (d+1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10

from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

n = inp()
ans = 0
for i in range(1, n):
    ans += (n - 1) // i
print(ans)


Measured memory_bytes: 9944