akhauriyash/Code-Regression huggingface dataset:
import math
from collections import Counter, defaultdict
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

import math
deg = rri()
d = (-1,0)
cur = (-1, 0)
ans = 1
deg = 2*math.pi*deg/360

while (cur[0]**2+cur[1]**2)>1e-5:
    x, y = d
    new_x, new_y = math.cos(deg)*x-math.sin(deg)*y, math.sin(deg)*x+math.cos(deg)*y
    d = (new_x, new_y)
    cur = (cur[0]+new_x, cur[1]+new_y)
    ans+=1
print(ans)

Measured memory_bytes: 66276
n = int(input())
v = input().split()
c = input().split()

i = 0
list = []
list2 = [] 

while i < n:
    list.append(int(v[i]) - int(c[i]))
    if list[i] > 0:
        list2.append(list[i])
    i += 1
        
print(sum(list2))

Measured memory_bytes: 3060
from collections import defaultdict

N, K = map(int, input().split())
X = list(map(int, input().split()))

cs = [0] * (N + 1)
for i in range(N):
    cs[i + 1] = cs[i] + X[i]

y = [(cs[i] - i) % K for i in range(N + 1)]
ctr = defaultdict(int)
ans = 0
for i in range(N + 1):
    ans += ctr[y[i]]
    ctr[y[i]] += 1
    if i - K + 1 >= 0:
        ctr[y[i - K + 1]] -= 1

print(ans)


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

int main () {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  
  int days = n - sum;
  if (days >= 0)
    cout << days << endl;
  else
    cout << -1 << endl;
      
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define N 1000000007

ll power(ll x, ll n) {
    ll ans = 1;
    while (n > 0) {
        if (n % 2 == 1) {
            ans *= x;
            ans %= N;
        }
        x *= x;
        x %= N;
        n >>= 1;
    }
    return ans;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    ans += power(10, n);
    ans %= N;
    ans += (N - power(9, n)) % N;
    ans %= N;
    ans += (N - power(9, n)) % N;
    ans %= N;
    ans += power(8, n);
    ans %= N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    static public void main(String[] args) {

        Scanner s = new Scanner(System.in);
        double r = s.nextDouble();
        double f = r*r*Math.PI;
        double d = 2*r*Math.PI;

        String str = String.format("%.6f",f);
        String str2 = String.format("%.6f", d);
        System.out.println(str+" "+str2);
    }
}



Measured memory_bytes: 28296
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,M[52][52],F[52][52];
ll modexp(ll x,ll y,ll p){
	ll res=1;
	x=x%p;
	while(y>0){
		if(y%2)
			res=(res*x)%p;
		x=(x*x)%p;
		y=y/2;
	}
	return res;
}
void matrix_mul(ll M[52][52],ll F[52][52]){
	ll C[52][52]={0},i,j,z,k;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			z=0;
			for(k=0;k<n;k++){
				z=(z+(M[i][k]*F[k][j])%mod)%mod;
			}
			C[i][j]=z;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			M[i][j]=C[i][j];
		}
	}
}
void mat_power(ll b){
	if(b==0||b==1) return;
	mat_power(b/2);
	matrix_mul(M,M);
	if(b%2) matrix_mul(M,F);
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>k;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin>>M[i][j];
			F[i][j]=M[i][j];
		}
	}
	mat_power(k);

	ll an=0;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			an=(an%mod+M[i][j]%mod)%mod;
		}
	}
	cout<<an;
	return 0;
}

Measured memory_bytes: 384
//                _                                      
//  ___ _ __ ___ (_) __ ___      ___   _ _ __ ___  _ __  
// / __| '_ ` _ \| |/ _` \ \ /\ / / | | | '_ ` _ \| '_ \ 
// \__ \ | | | | | | (_| |\ V  V /| |_| | | | | | | |_) |
// |___/_| |_| |_|_|\__, | \_/\_/  \__,_|_| |_| |_| .__/ 
//                  |___/                         |_|  
//code by smigwump
//https://codeforces.com/blog/entry/62393
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
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--)


using namespace std;

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

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

    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n+1,0),b(m,0);
    ll asum=0,bsum=0;
    REP(i,0,n-1) {
        cin>>a[i];
        asum+=a[i];
    }
    REP(i,0,m-1) {
        cin>>b[i];
    }
    ll ans = 0;
    int j=0;
    PER(i,n,0) {
        asum-=a[i];
        if(asum<=k) {
            while(j<m && asum+bsum+b[j]<=k) {
                bsum+=b[j];
                j++;
            }
            ans = max(ans,i+j);
        }
    }
    cout<<ans<<"\n";
    
    
    return 0;
}

Measured memory_bytes: 6376
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<=(int)(n-1);i++)

int main() {
	int N;
	cin>>N;
	string S[N];
	rep(i,N) cin>>S[i];
	long long cM = 0;
	long long cA = 0;
	long long cR = 0;
	long long cC = 0;
	long long cH = 0;
	rep(i,N){
		if(S[i][0]=='M') cM++;
	}
	rep(i,N){
		if(S[i][0]=='A') cA++;
	}
	rep(i,N){
		if(S[i][0]=='R') cR++;
	}
	rep(i,N){
		if(S[i][0]=='C') cC++;
	}
	rep(i,N){
		if(S[i][0]=='H') cH++;
	}
	long long ans;
	ans = cM*cA*cR+cM*cA*cC+cM*cA*cH+cM*cR*cC+cM*cR*cH+cM*cC*cH+cA*cR*cC+cA*cR*cH+cA*cC*cH+cR*cC*cH;
  cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6144
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    string S;
    int N, K;
    cin >> N >> S >> K;
    for (int i = 0; i < N; i++) {
        cout << (S[i] != S[K - 1] ? '*' : S[i]);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ll n, k;
	cin >> n >> k;
	vl heights(n);

	FOR(i, 0, n) {
		cin >> heights[i];
	}

	vl minimums(n, oo);
	minimums[0] = 0;

	FOR(i, 0, n) {
		FOR(j, min(n - 1, i + 1), min(n, i + k + 1)) {
			minimums[j] = min(minimums[j], minimums[i] + abs(heights[j] - heights[i]));
		}
	}

	cout << minimums[n - 1] << endl;
}

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

int main() {
  int N; cin >> N;
  
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  
  int now = 0;
  int count = 0;
  for(int i=0;i<N;i = now){
    now = a.at(i) - 1;
    count++;
    if(now == 1){
      cout << count << endl;
      break;
    }
    else if(count == N){
      cout << -1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        sc.nextLine();
        String[][] S = new String[H][W];
        for(int i=0; i<H; i++) {
			S[i] = sc.next().split("");
		}
        sc.close();

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (S[i][j].equals(".")) {
                    int count = 0;
                    for (int a = -1; a <= 1; a++) {
                        if (i + a < 0 || H <= i + a) {
                            continue;
                        }
                        for (int b = -1; b <= 1; b++) {
                            if (j + b < 0 || W <= j + b) {
                                continue;
                            }
                            if ( S[i + a][j + b].equals("#")) {
                                count++;
                            }
                        }
                    }
                    S[i][j] = String.valueOf(count);
                }
                System.out.printf("%s", S[i][j]);
            }
            System.out.printf("\n");
        }
    }
}

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

const int INF = 2e9;

int main(){
    string s;
    cin >> s;
    deque<char> ans;
    rep(i,s.size()){
        ans.push_back(s[i]);
    }
    int q;
    cin >> q;
    bool rev = false;
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1){
            if(rev) rev = false;
            else rev = true;
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(rev) ans.push_back(c);
                else ans.push_front(c);
            }
            else{
                if(rev) ans.push_front(c);
                else ans.push_back(c);
            }
        }
    }
    int number = ans.size();
    if(rev){
        for(int i = number-1;i >= 0;i--){
            cout << ans[i];
        }
    }
    else{
        rep(i,number) cout << ans[i];
    }
}

Measured memory_bytes: 4028
package main

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

func countTwo(a int) int {
	cnt := 0
	for a%2 == 0 && a > 0 {
		a /= 2
		cnt++
	}
	return cnt
}

func main() {
	n, m := readInt(), readInt()

	b := readInt() / 2
	cnt2 := countTwo(b)
	com := lcm(1, b)
	for i := 1; i < n; i++ {
		b = readInt() / 2
		if countTwo(b) != cnt2 {
			fmt.Println(0)
			return
		}
		com = lcm(com, b)
	}

	fmt.Println((m/com + 1) / 2)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 3404
#include <iostream>
#include <cmath>
#include <iomanip>
#define PI 3.141592653589793
using namespace std;
int main(void){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double theta_h=((double)h+(double)m/60)/6*PI;
    double theta_m=(double)m/30*PI;
    double c=sqrt(a*a+b*b-2*a*b*cos(abs(theta_m-theta_h)));
    cout << fixed << setprecision(12) << c << endl;
    return 0;
}

Measured memory_bytes: 4228
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <tuple>

int main(int /*argc*/, char** /*argv*/)
{
	std::string S, T;
	std::cin >> S >> T;

	size_t min_diff = T.size();
	for (size_t i = 0; i <= S.size()-T.size(); ++i) {
		size_t diff = 0;
		for (size_t j = 0; j < T.size(); ++j) {
			if (T[j] != S[i+j]) {
				++diff;
			}
		}
		if (diff < min_diff) {
			min_diff = diff;
		}
	}
	std::cout << min_diff << std::endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    while (1)
    {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0)
            break;
        REP(i, h)
        {
            REP(j, w)
            {
                if ((i + j) % 2 == 0)
                    cout << "#";
                else
                {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
#include<iostream>
int main(){
    int S, h, m, s;
    std::cin >> S;
    h = S / 3600 % 24;
    m = S / 60 % 60;
    s = S % 60;
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vll s(n);
  for (ll i = 0; i < n; i++) cin >> s[i];
  sort(all(s));

  ll ans = 0;
  for (ll i = 0; i < n; i++) ans += s[i];
  if (ans / 10 == ans / 10.0) {
    for (ll i = 0; i < n; i++) {
      ans -= s[i];
      if (ans / 10 != ans / 10.0) break;
      if (i == n - 1) {
        ans = 0;
        break;
      }
      ans += s[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	var ret int
	for k, v := range a {
		if !even(k+1) && !even(v) {
			ret++
		}
	}
	fmt.Println(ret)
}

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

func even(n int) bool {
	if n%2 == 0 {
		return true
	}

	return false
}


Measured memory_bytes: 1780
H,W,K = map(int,input().split())
mod = 10**9+7
dp = [[0]*W for i in range(H+1)]

dp[0][0] = 1
for i in range(1,W):
    dp[0][i] = 0

for h in range(H):
    for w in range(W):
        
        for j in range((1<<W-1)):
            ok = True
            for k in range(1,W-1):
                if (j>>k)%2 == 1 and (j>>k-1)%2 == 1:
                    ok = False 
                    break
            if ok :
                #right
                if w < W-1 and (j>>w)%2 == 1:
                    dp[h+1][w+1] += dp[h][w]
                    dp[h+1][w+1] = dp[h+1][w+1]%mod
                #left
                elif w > 0 and (j>>w-1)%2 == 1:
                    dp[h+1][w-1] += dp[h][w]
                    dp[h+1][w-1] = dp[h+1][w-1]%mod
                else:
                    dp[h+1][w] += dp[h][w]
                    dp[h+1][w] = dp[h+1][w]%mod

print(dp[H][K-1]%mod)
            
             


Measured memory_bytes: 43888
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int n = abs(b - a);
	int m = abs(b - c);
	int x = abs(c - a);

	if (n <= d && m <= d) {
		cout << "Yes" << endl;
	}
	else if(x <= d){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 256
details = input().split()
N = int(details[0])
L = int(details[1])
counter = 0
new_list = []
number = 0
checker = True
for i in range(N):
    counter += L
    new_list.append(L+i)
    if number == 0 and ((L + i) >= 0) and checker == True:
        number += L + i
        checker = False
    elif number == 0 and (i == N-1) and checker == True:
        number += L + i
        checker = False
print(sum(new_list) - number)

Measured memory_bytes: 9212
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int H, W; string s[55];
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> s[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') cout << '#';
			else {
				int cnt = 0;
				for (int k = -1; k <= 1; k++) {
					for (int l = -1; l <= 1; l++) {
						int tx = i + k, ty = j + l;
						if (0 <= tx && tx < H && 0 <= ty && ty < W && s[tx][ty] == '#') {
							cnt++;
						}
					}
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}


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

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

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

    a = a-b-b;
    if(a<0){
        a = 0;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_ll.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_ll;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

struct range_minimum_query{
  ll fnc(ll a,ll b){
    ll ans = min(a,b);
    return ans;
  }

  ll n,INF;
  vector<ll> segtree;
  range_minimum_query(ll sz,ll inf=MOD){
    INF=inf;
    for(n = 1; n<sz;) n <<= 1;
    segtree.assign(2*n-1,INF);
  }
  ll find(ll l, ll r){return find(l,r,0,n,0);}
  ll find(ll l, ll r, ll a, ll b, ll k){
    if(b<=l || r<=a) return INF;
    else if(l<=a && b<=r) return segtree[k];
    else return fnc(find(l,r,a,(a+b)/2,2*k+1), find(l,r,(a+b)/2,b,2*k+2));
  }
  void update(ll i, ll x){
    i += n-1;
    segtree[i] = x;
    while(i>0){
      i = (i-1)/2;
      segtree[i] = fnc(segtree[2*i+1], segtree[2*i+2]);
    }
  }
};

int main(){
  ll n,q;
  cin>>n>>q;
  range_minimum_query rmq(n,((ll)1<<31)-1);
  for(ll i=0;i<q;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==0)rmq.update(b,c);
    else cout<<rmq.find(b,c+1)<<endl;
  }
}



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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};

bool solve(){
    int h, w, n;
    cin >> w >> h >> n;
    vector<P> pos(n);
    for(int i=0;i<n;i++){
        cin >> pos[i].first >> pos[i].second;
    }
    int ans = INF;
    for(int t=0;t<2;t++){
        sort(pos.begin(),pos.end());
        vector<int> maxi(n,0);
        for(int i=n-2;i>=0;i--){
            maxi[i] = max(maxi[i+1], pos[i+1].second);
        }
        for(int i=0;i<n;i++){
            ans = min(ans, pos[i].first + maxi[i]);
        }
        for(int i=0;i<n;i++){
            swap(pos[i].first, pos[i].second);
        }
    }
    cout << ans << endl;
    return false;
}

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



Measured memory_bytes: 3944
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l;
  cin >> n >> l;
  vector< string > s;
  for (int i = 0; i < n; ++i) {
    string line;
    cin >> line;
    s.push_back(line);
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < s.size(); ++i) {
    cout << s[i];
  }
  cout << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n,z,w;
  cin >> n >> z >> w;
  vector<ll> v(n);
  rep(i,n)cin >> v[i];
  if(n >= 2)cout  << max(abs(v.back()-w),abs(v.back()-v[n-2])) << endl;
  else cout << abs(v.back()-w) << endl;

  return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
const int mod = 998244353;
const int N = 100000;
int n, x;
long long a[N + 1], ni[N + 1];
long long f[N + 1];
long long calc(long long x, long long y)
{
    if (y < 0) return 0;
    long long z = 1;
    while (y)
    {
        if (y & 1) (z *= x) %= mod;
        (x *= x) %= mod, y /=2;
    }
    return z;
}
long long C(int x, int y)
{
    if (y < 0 || x < y) return 0;
    return a[x] * ni[y] % mod * ni[x - y] % mod;
}
int main()
{
    scanf("%d %d", &n, &x);
    a[0] = 1;
    for (int i = 1; i <= N ; i ++)
        a[i] =  a[i - 1] * i % mod;
    ni[N] = calc(a[N], mod - 2);
    for (int i = N - 1 ; i >= 0; i --)
        ni[i] = ni[i + 1] * (i + 1) % mod;
    f[0] = 1;
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 0; j <= i; j ++)
            if (i + j < x)
                f[i] += C(i, j);
        if (i + i > x && (x & 1))
            f[i] ++;
        if (i + i > x)
        {
            for (int j = 1; j <= i / 2 ; j++)
                if (j * 2 < x - 1)
                {
                    int sum = i - j * 2;
                    if (x - 1 - j * 2 - sum != sum)
                        f[i] += C(sum, x  - 1 - j * 2 - sum);
                }
        }
        f[i] %= mod;
    }
    long long ans = 0;
    for (int i = 0; i <= n ; i++) {
        (ans += f[i] * C(n, i)) %= mod;
    }
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  vector<int> s;
  s.assign(x.begin(), x.end());
  sort(s.begin(), s.end(), less<int>());

  rep(i, n) {
    int l = s[n / 2 - 1];
    int r = s[n / 2];
    int mid = x[i] <= l ? r : l;
    cout << mid << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			
			int n = sc.nextInt();
			int x = sc.nextInt();
			int cnt = 0;
			
			if (n==0 && x==0) {
				break;
			}
			
			for (int a=1 ; a<=n-2 ; a++) {
				for (int b=a+1 ; b<=n-1 ; b++) {
					for (int c=b+1 ; c<=n ; c++) {
						if(a+b+c == x) {
							cnt++;
						}
					}
				}
			}
			System.out.println(cnt+"");
		}
	}

}


Measured memory_bytes: 27348
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def pow_k(x, n, mod):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x = x * x % mod
        n //= 2

    return K * x % mod

n, a, b = MAP()
ans = pow_k(2,n,10**9+7) - 1

x0 = 1
y0 = 1
x1 = 1
y1 = 1
for i in range(1, max(a,b)+1):
    if i <= a:
        x0 = x0 * (n - i + 1) % (10**9+7)
        y0 = y0 * i % (10**9+7)
    if i <= b:
        x1 = x1 * (n - i + 1) % (10**9+7)
        y1 = y1 * i % (10**9+7)

ans -= x0*pow_k(y0,10**9+7-2,10**9+7) + x1*pow_k(y1,10**9+7-2,10**9+7)
print(ans % (10**9+7))

Measured memory_bytes: 10296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int counterfive=0;
    	int counterseven=0;

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

    		int buf=sc.nextInt();

    		if(buf==5) {
    			counterfive++;
    		}else if(buf==7) {
    			counterseven++;
    		}

    	}

    	if(counterfive==2 && counterseven==1) {
    		System.out.println("YES");
    	}else {
    		System.out.println("NO");
    	}

    }
}


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

int main()
{
	string a, b;
	cin >> a >> b;
	if (a == b)
	{
		printf("Yes");
		return 0;
	}
	else
	{
		for (int i = 1; i < a.length(); i++)
		{
			string c = a.substr(a.length() - i, i);
			c = c + a.substr(0, a.length() - i);
			if (c == b)
			{
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N, K;
long long P[5005];
long long C[5005];

int main(){
	cin >> N >> K;
	rep(i, N) {
		cin >> P[i];
		P[i]--;
	}
	rep(i, N){
		cin >> C[i];
	}

	long long ans = LONG_MIN;
	rep(start, N) {
		//cout << "start = " << start << endl;
		long long loopcost = 0;
		long long looplen = 0;

		long long cur = start;
		while(1) {
			loopcost += C[cur];
			looplen++;
			cur = P[cur];
			if(cur == start) {
				break;
			}
		}

		if(loopcost < 0) {
			//一周未満での最大を考える
			cur = start;

			long long maxlen = min(N, K);
			long long cost = 0;
			long long maxcost = LONG_MIN;
			rep(i, maxlen) {
				cost += C[cur];
				cur = P[cur];
				maxcost = max(maxcost, cost);
			}
			ans = max(ans, maxcost);
		} else {
			cur = start;

			long long loopnum = max(0LL, K/looplen - 2);
			long long cost = loopnum * loopcost;
			long long rest = K - loopnum * looplen;
			long long maxcost = LONG_MIN;


			rep(i, rest) {
				cost += C[cur];
				cur = P[cur];
				maxcost = max(maxcost, cost);
			}
			ans = max(ans, maxcost);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3696
import os

x,k,d=map(int,input().split())

x = abs(x)

ri=x//d
if ri <= k:
    nkr = k-ri
    if nkr%2==0:
        print(abs(x - ri*d))
    else:
        riso_a = abs(x-ri*d)
        print(min(abs(riso_a+d), abs(riso_a-d)))
elif ri > k:
   print(x - k*d)

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

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

    vector<string> s;
    string t;

    for(int i = 0; i < n; i++){
        cin >> t;
        if(t[0] == 'M' || t[0] == 'A' || t[0] == 'R' || t[0] == 'C' || t[0] == 'H'){
            s.push_back(t);
        }
    }

    sort(s.begin(), s.end());
    

    /*
    for(int i = 0; i< s.size(); i++){
        cout << s[i][0] << endl;
    }
    */

    long long int num[5] = {0,0,0,0,0};
    for(int i = 0; i < s.size(); i++){
        if(s[i][0] == 'M'){
            num[0]++;
        }
        else if(s[i][0] == 'A'){
            num[1]++;
        }
        else if(s[i][0] == 'R'){
            num[2]++;
        }
        else if(s[i][0] == 'C'){
            num[3]++;
        }
        else if(s[i][0] == 'H'){
            num[4]++;
        }
    }

    int c = 0;
    for(int i = 0; i < 5; i++){
        if(num[i] != 0){
            c++;
        }
        //cout << num[i] << endl;
        //cout << c << endl;
    }

    if(c < 3){
        cout << 0 << endl;
        return 0;
    }

    long long int ans = 0; 
    if(c == 3){
        ans = 1;
        for(int i = 0; i < 5; i++){
            if(num[i] != 0){
                ans *= num[i];
            }
        }
    }
    else {
        for(int i = 0; i < 3; i++){
            for(int j = i+1; j < 4; j++){
                for(int k = j+1; k < 5; k++){
                    ans += num[i] * num[j] * num[k];
                    //cout << "i:" << i << "j:" << j << "k:" << k << endl;
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 5748
// C++ implementation of the above approach 
#include<bits/stdc++.h> 
using namespace std; 

void CountTriangles(vector <int> A){ 

	int n=A.size(); 

	sort(A.begin(), A.end()); 

	int count = 0; 
	
	for( int i = n-1; i >= 1; i--){ 
		int l = 0, r = i-1; 
		while( l < r){ 
			if( A[l] + A[r] > A[i]){ 

				// If it is possible with a[l], a[r] 
				// and a[i] then it is also possible 
				// with a[l+1]..a[r-1],a[r] and a[i] 
				count += r - l ; 

				//checking for more possible solutions 
				r--; 
			} 
			else

				// if not possible check for 
				// higher values of arr[l] 
				l++; 
		} 
	} 
	cout<<count; 
} 
int main(){ 
	int n;
	cin>>n;
	vector<int> A(n);
	for(int i =0; i<n; i++)
	cin>>A[i];
	

	CountTriangles(A); 
	
}	 


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
  int n,k;cin >>n>>k;
  vector<int> h(n);
  rep(i,n)cin >> h[i];
  sort(ALL(h));

  ll ans=INF;
  rep(i,n-k+1){
    chmin(ans,(ll)(h[i+k-1]-h[i]));
  }
  cout <<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)


int main(){
    ll m,k;
    cin>>m>>k;
    if(k==0){
        fr(i,(1ll<<m)) cout<<i<<" "<<i<<" ";
        cout<<endl;
        return 0;
    }
    if(k>=(1ll<<m)){
        cout<<-1<<endl;
        return 0;
    }
    if(m==1){
        cout<<-1<<endl;
        return 0;
    }
    cout<<0<<" "<<k<<" "<<0<<" ";
    Fr(i,(1<<m)-1) if(i!=k) cout<<i<<" ";
    cout<<k<<" ";
    iFr(i,(1<<m)-1) if(i!=k) cout<<i<<" ";
    cout<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const i64 MOD = 1e9 + 7;

int main()
{
  i64 N, K;
  cin >> N >> K;
  i64 ans = 0, lim[2] = {0, N};
  for (i64 i = 1; i < K; i++)
  {
    (lim[0] += i) %= MOD;
    (lim[1] += N - i + MOD) %= MOD;
  }
  for (i64 i = K; i <= N + 1; i++)
  {
    (ans += lim[1] - lim[0] + 1 + MOD) %= MOD;
    (lim[0] += i) %= MOD;
    (lim[1] += N - i + MOD) %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
# n個の整数のリスト
num_list = []
# 偶数の桁数の整数のリスト
num_odd_list = []

# n個の整数のリストに代入
for i in range(1, n + 1):
    num_list.append(i)

# 偶数の桁数の整数をリストに代入
for j in num_list:
    if 10 <= j < 100 or 1000 <= j < 10000 or 100000<= j < 1000000:
       num_odd_list.append(j)

# 全体の整数の数から偶数の桁数の整数の数を引く
print(len(num_list) - len(num_odd_list))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  char c;
  cin >> c;
  c += 1;
  cout << c << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int a,b,k;cin >> a >> b >> k;
    int cnt=0;
    for(int i=min(a,b);i>=1;i--){
        if(a%i==0&&b%i==0){
            cnt++;
            if(cnt==k){
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << false << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n), c(n - 1);
    for (auto &e : a) { std::cin >> e; e--; }
    for (auto &e : b) std::cin >> e;
    for (auto &e : c) std::cin >> e;

    int ret = b[a[0]];
    for (int i = 1; i < n; i++) {
        ret += b[a[i]];
        if (a[i] - a[i - 1] == 1) ret += c[a[i - 1]];
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int m,n,i,j,a,b,sum,x=0;
    scanf("%d%d",&m,&n);
    a=m-1;
    b=n-1;
    sum=1;
    for(i=m;i>=a;i--)
    {
        sum*=i;

    }

    x+=sum/2;
    sum=1;
    for(j=n;j>=b;j--)
    {
        sum*=j;

    }

      x+=sum/2;
    printf("%d\n",x);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;

typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;

int main(){

long long X;
long long temp;
long long ans = 0;

cin >> X;

ans = ans + 1000*(X/500);

temp = X % 500;

ans = ans + 5*(temp/5);

cout << ans << endl;

return 0;

}   


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll k;
	cin >> k;
	for(ll i=0;i<k;i++){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << "1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
int n, a, b;
cin >> n >> a >> b;
if((n*a)<b){
	cout << n*a;
}
else{
	cout << b;
}
return 0;
}



Measured memory_bytes: 256
class SmallLargeOrEqual:
    def __init__(self, a, b):
        if a < b:
            print "a < b"
            return
        elif a > b:
            print "a > b"
            return
        else:
            print "a == b"
            return

if __name__ == "__main__":
    a,b = map(int,raw_input().split())
    SmallLargeOrEqual(a,b)

Measured memory_bytes: 6424
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[100110],ans;
int abs(int x){ return x<0?-x:x;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),ans+=abs(a[i]-a[i-1]);
	ans+=abs(0-a[n]);
	for(int i=1;i<=n;i++)
		printf("%d\n",ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
	return 0;
}
	

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
  int n[101];
  int i;
  int num;
  cin >> num;
  for(i=0;i<num;i++) cin >> n[i];
  cout << n[num-1];
  for(i=1;i<num;i++) cout <<" "<< n[num-i-1];
  cout << endl;
  return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>

using namespace std;

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

int main() {
	int n,ans=0;
	cin >> n;
	vector<int> p(n);

	for (int i = 0; i<n; i++) {
		cin >> p[i];
	}
	for (int j = 1; j < n - 1; j++) {
		if ((p[j] < p[j - 1]) ^ (p[j] < p[j + 1])) {
			ans++;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vector<ll> pos(N, INF);
  pos.at(0) = 0;
  vector<vector<ll>> ab(N);
  for (ll i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    ab.at(a - 1).push_back(b - 1);
  }
  for (ll i = 0; i < N; ++i) {
    if (pos.at(i) <= 1) {
      for (ll j = 0; j < ab.at(i).size(); ++j) {
        pos.at(ab.at(i).at(j)) = pos.at(i) + 1;
      }
    }
  }
  if (pos.at(N - 1) <= 2) {
    cout << "POSSIBLE" << "\n";
  }
  else {
    cout << "IMPOSSIBLE" << "\n";
  }
}


Measured memory_bytes: 13404
#include <stdio.h>

int main(void){
  int n;
  int b, f, r, v;
  int i, j, k;

  int tenants[4][3][10]= {{{}}};

  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    tenants[b-1][f-1][r-1] += v;
  }

  for(i=0; i<4; i++){
    for(j=0; j<3; j++){
      for(k=0; k<10; k++){
        printf(" %d", tenants[i][j][k]);  
      }
      printf("\n");
    }
    if(i != 3) printf("####################\n");
  }

  return 0;
}



Measured memory_bytes: 2068
using System;
public class Aprob {
    public static void Main() {
        string[] read = new string[3];
        read = Console.ReadLine().Split(' ');
        int A = int.Parse(read[0]);
        int B = int.Parse(read[1]);
        int C = int.Parse(read[2]);
        int kind = 3;
        if (A == B) {
            kind--;
        }
        if (B == C) {
            kind--;
        }
        if (C == A) {
            kind--;
        }
        if (kind == 0) {
            kind = 1;
        }
        Console.WriteLine(kind);
    }
}

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

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

using namespace std;

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

  int result=1;
  rep(i,n+1){
    if(pow(i,2)>n){
      result = (int)pow(i-1,2);
      break;
    }
  }

  cout<<result;

  return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int ans=0, total_bid=0;
    rep(i, n) cin >> a[i];
    rep(i ,n) total_bid += a[i];
    rep(i, n){
        if(a[i]*(4*m) >= total_bid){
            ans++;
        }
    }
    if(ans >= m) cout << "Yes" << endl;
    else         cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int Pay(int train,int taxi , int N){
    int Min = 0;
    if(train * N < taxi){
        Min = train * N;
    }else{
        Min = taxi;
    }
    return Min;
}


int main(){
    int N,A,B,i;
    int Minimum = 0;
    int flag = 1;
    int tmp;
    
    scanf("%d %d %d",&N ,&A,&B);
    Minimum = Pay(A , B , N);
    printf("%d",Minimum);
    
    
}


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


def solve(S: str):
    max_len = 0
    def isvalid(s):
        return s in ['A', 'C', 'G', 'T']

    for i in range(len(S)):
        if not isvalid(S[i]):
            continue
        j = i + 1
        while j < len(S) and isvalid(S[j]):
            j += 1
        max_len = j-i if j-i > max_len else max_len
    print(max_len)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//rohitaas_15
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> o_set;
#define ll  long long
#define int ll
#define um(a,b) unordered_map<a,b>
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define f(a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define show(x) cout<<x<<"\n"
#define printvector(v,n) f(0,n-1){cout<<v[i]<<" ";}
#define input(v,n) f(0,n-1){cin>>v[i];}
#define vr vector<ll>
#define check() cout<<"hi"<<"\n"
#define MOD 1000000007
//#define endl "\n"
#define len() length()
#define maxv(v) *max_element(all(v));
#define minv(v) *min_element(all(v));
#define sumv(v) accumulate(all(v),0)
#define test() ll t;cin>>t;while(t--)
ll search(vr arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
ll CmP(ll n, ll r, ll p=MOD){if (r==0)return 1;ll fac[n+1];fac[0] = 1;for (ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p; return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p; }
/*ll constructSTUtil(vr v,ll start,ll end,int *st,ll index)
{
	if(start==end)
	{
		st[index]=v[start];
		return st[index];
	}
	ll mid=(start+end)/2;
	st[index]=constructSTUtil(v,start,mid,st,2*index)+constructSTUtil(v,mid+1,end,st,2*index+1);
	return st[index];
}
ll *constructST(vr v,ll n)
{
	ll po=(ll)(ceil(log2(n)));
	ll msize=2*power(2,po)+1;
	vr st[msize];
	constructSTUtil(v,0,n-1,st,1);
	return st;
}*/
ll ask1(ll y)
{
	cout<<1<<" "<<y<<endl;
	ll x;
	cin>>x;
	return x;
}
bool compare(pair<pii,pii> &a,pair<pii,pii> &b)
{
	return (a.ss).ss<(b.ss).ss;
}
signed main()
{
	/*
	#ifndef ONLINE_JUDGE
	 freopen("input.txt","r",stdin);
	 freopen("output.txt","w",stdout);
	 #endif
	 //*/
	 /*ll t;
	 cin>>t;
	 ll cccc=t;
	 while(t--)
	 {
	 */
	 	ll a,b,n;
	 	cin>>a>>b>>n;
	 	if(b==1)
        {
            show(0);
        }
        else
        {
            if(n<b-1)
            {
                ll temp=(a*n)/b;
                show(temp);
            }
            else
            {
                ll temp=(a*(b-1))/b;
                show(temp);
            }
        }
	 //}
	/*cout<<"Case #"<<cccc-t<<": ";*/

}


Measured memory_bytes: 3628