akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

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

#define endl "\n"

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;}

typedef long long lint;
lint MOD=1000000007;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n,k;
	cin>>n>>k;
	lint ans=0;
	for(lint i=k;i<=n+1;i++){
		lint max=i*(n+n-i+1)/2;
		lint min=i*(i-1)/2;
		ans+=(max-min+1)%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long r1, c1, r2, c2;
long long fac[2000005], ifac[2000005];

long long power(long long a, long long n) {
    long long res = 1;
    while (n) {
        if (n & 1) res = (res * a) % mod;
        n >>= 1;
        a = (a * a) % mod;
    }
    return res;
}

long long comb(int n, int k) {
    return fac[n] * ifac[k] % mod * ifac[n - k] % mod;
}

long long f(int r, int c) {
    long long res = 0;
    for (int i = 0; i <= r; i++) {
        res = (res + comb(i + 1 + c, c)) % mod;
    }
    return res;
}

void pre() {
    fac[0] = ifac[0] = 1;
    for (int i = 1; i < 2000005; i++) {
        fac[i] = (fac[i - 1] * i) % mod;
        ifac[i] = power(fac[i], mod - 2) % mod;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    pre();
    cin >> r1 >> c1 >> r2 >> c2;

    cout << ((f(r2, c2) - f(r1 - 1, c2) - f(r2, c1 - 1) + f(r1 - 1, c1 - 1)) % mod + mod) % mod << '\n';
}


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

namespace ConsoleApp1
{
    class Program3
    {
        static void Main()
        {
            int a = int.Parse(Console.ReadLine());
            int b = a;

            while (a > 10)
            {
                a = a - 10;
            }
            if (a == 9)
            {
                Console.Write("Yes");
            }
            else
            {
                if(b/10 == 9)
                {
                    Console.Write("Yes");
                }
                else
                Console.Write("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
const ll INF = 1000000005;
int main(void) {
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  reverse(h.begin(), h.end());
  ll minh = INF;
  rep(i, n) {
    if(h[i] > minh + 1) {
      cout << "No" << endl;
      return 0;
    }
    minh = min(minh, h[i]);
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1024
t=input()
ans = ""
for i in range(len(t)):
    if (i % 2 == 1) and (t[i] == "R"):
        ans = "No"
        break
    elif (i % 2 == 0) and (t[i] == "L"):
        ans = "No"
        break

if ans == "No":
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9112
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		int a,b,c;
		int i,cnt=0;

		Scanner scan = new Scanner(System.in);

	    a = scan.nextInt();
	    b = scan.nextInt();
	    c = scan.nextInt();

	    for(i=a; i<=b; i++)
	    {
	    	cnt = (c%i==0) ? ++cnt : cnt;
	    }

	    System.out.println(cnt);

		scan.close();
	}
}

Measured memory_bytes: 26248
open System 

type Explicit =          
    static member inline ($) (_:int32, _:Explicit) = int
    static member inline ($) (_:int64, _:Explicit) = int64

let inline convert (value:'a): 'b = 
    (Unchecked.defaultof<'b> $ Unchecked.defaultof<Explicit>) value

let inline fromInt (x: int): 'a = convert x

module NumericLiteralG =
    let inline FromZero(): ^a = LanguagePrimitives.GenericZero
    let inline FromOne(): ^a = LanguagePrimitives.GenericOne
    let inline FromInt32 n = fromInt n

let R() = Console.ReadLine()

let comb2 (x: int64): int64 = 
    x * (x - 1L) / 2L

let f (xs: int64 array): int64 list =
    let g =
        xs 
        |> Array.map int64
        |> Array.groupBy id 
        |> Array.map (fun (k, v) -> k, int64 <| Array.length v)
    let m = 
        g
        |> Map.ofArray
    let all =     
        g
        |> Array.map snd
        |> Array.fold (fun acc x -> 
            if x < 2L then acc 
            else acc + comb2 x
        ) 0L
    [ for x in xs do 
        all - comb2 m.[x] + comb2 (m.[x] - 1L)
    ]

let N = R()
let A = R().Split() |> Array.map (string >> int64)

f A 
|> List.iter (printfn "%i")


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

const double EPS = 1.0e-6;
int main()
{
	int l[10];
	int v1,v2;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2) > 0){
		int suml = 0;
		for(int i=0; i<10; i++){
			suml += l[i];
		}
		double time = 1.0*suml / (v1+v2);
		double miti = time*v1 - EPS;
		int ans = 0;
		for(int i=0, sl=0; i<10+1; i++){
			if(miti < sl){
				ans = i;
				break;
			}
			sl += l[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
struct UnionFind {
    vector<int> r;
    int n;
    UnionFind(int a) {
        n = a;
        r.assign(a + 1, -1);
    }
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
    void unite(int a, int b) {
        int x = root(a);
        int y = root(b);
        if (x == y) return;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return;
    }
    int query(int x) {
        return -r[root(x)];
    }
};
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);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<pair<int, int>> pos;
    vector<int> f(n + 1);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        f[y] = i + 1;
        pos.push_back(make_pair(x, y));
    }
    sort(pos.begin(), pos.end());
    UnionFind uf(n);
    set<int, greater<int>> se;
    for (pair<int, int> p : pos) {
        auto it = se.insert(p.second).first;
        int id1 = f[p.second];
        auto i = it;
        i++;
        for (i; i != se.end(); i++) {
            int id2 = f[(*i)];
            uf.unite(id1, id2);
            i = se.erase(it);
            it = i;
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << uf.query(i) << endl;
    }
}

Measured memory_bytes: 10884
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c;cin>>a>>b;
  rep(i,b){
    cin>>c;
    a-=c;
  }
  if(a<=0)cout<<"Yes";
  else cout<<"No";

}



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

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

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int main() {
    int n;
    cin >> n;
    int d[n];
    rep(i, n, 0) cin >> d[i];
    int ans = 1;

    sort(d, d + n);
    int temp = d[0];
    for (int j = 1; j < n; j++) {
        if (temp < d[j]) {
            temp = d[j];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def e(x,y):
 A[y][x]='0'
 for d in range(-3,4):
  0<=x+d<8 and A[y][x+d]=='1'and e(x+d,y)
  0<=y+d<8 and A[y+d][x]=='1'and e(x,y+d)
for i in range(int(input())):
 print(f'Data {i+1}:')
 input()
 A=[list(input())for _ in[0]*8]
 e(int(input())-1,int(input())-1)
 for r in A:print(*r,sep='')


Measured memory_bytes: 5632
package main

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

func main() {
	s := readString()
	t := readString()

	available := make([]bool, 26)
	for _, b := range []byte(s) {
		available[b-'a'] = true
	}
	for _, b := range []byte(t) {
		if !available[b-'a'] {
			fmt.Println(-1)
			return
		}
	}

	lut := make([][]int, 26)
	s2 := []byte(s + s)
	for b := range available {
		if !available[b] {
			continue
		}
		lut[b] = make([]int, len(s))
		j := 0
		for i := len(s2) - 1; i >= 0; i-- {
			if int(s2[i]) == b+'a' {
				j = 0
			} else {
				j++
			}
			if i < len(s) {
				lut[b][i] = j
			}
		}
	}

	i := 0
	for _, b := range []byte(t) {
		i += lut[b-'a'][i%len(s)] + 1
	}
	fmt.Println(i)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}


Measured memory_bytes: 22784
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int upper_bound(const vector<int>& array, int v)
{
    int l = 0, r = array.size();
    while(l < r)
    {
        int mid = (l + r) / 2;
        if(array[mid] <= v)
        {
            l = mid + 1;
        }
        else{
            r = mid;
        }
    }
    return r;
}


int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    vector<long long> AB(N), BC(N);
    for(int i=0;i<N;++i) cin >> A[i];
    for(int i=0;i<N;++i) cin >> B[i];
    for(int i=0;i<N;++i) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    for(int i=0;i<N;++i) BC[i] = N - upper_bound(C, B[i]);
    for(int i=N-2;i>=0;--i){
        BC[i] += BC[i+1];
    }

    for(int i=0;i<N;++i)
    {
        int key = upper_bound(B, A[i]);
        ans += BC[key];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 string s;
 cin >> s;
 if(s.at(0)=='9' ||s.at(1)=='9')cout << "Yes" << endl;
 else cout << "No" << endl;

}

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

const int N = 2e5 + 10;

int n;
multiset<int> ms;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ms.insert(x);
  }
  int ans = 0;
  while (!ms.empty()) {
    int largest = *prev(ms.end());
    ms.erase(prev(ms.end()));
    int k;
    for (int i = 0; i < 31; ++i) {
      if ((1 << i) > largest) {
        k = (1 << i) - largest;
        break;
      }
    }
    auto p = ms.lower_bound(k);
    if (p != ms.end() && *p == k) {
      ms.erase(p);
      ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    int ans = INF;
    for(int i = 1; i < n; i++){
        int a = i, b = n-i;
        int temp = 0;
        while(a > 0){
            temp += a % 10;
            a /= 10;
        }
        while(b > 0){
            temp += b % 10;
            b /= 10;
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

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

#define pb emplace_back
#define fi first
#define se second
#define m_p make_pair
#define vi vector<int>
#define pi pair<int, int>
#define mem(a,b) memset(a,b,sizeof(a))
#define el cout<<endl
#define sz(a) (int)a.size()
const int mod = (int)1e9+7;
typedef long long int ll;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = (int)1e5+5;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int ans=0;
	for(int i=0;i<5;i++){
		int x;
		cin>>x;
		if(x==0){
			ans = i+1;
		}
	}
	cout<<ans;el;

}

ll power(ll a,ll b, ll md=mod){
	ll r=1;
	while(b){
		if(b%2) 
			r=(r*a)%md;
		a=(a*a)%md;
		b>>=1;
	}
	return r;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int X[100], Y[100];

int main() {
  int L, R, cal, result;
  int i, j;
  scanf ("%d %d", &L, &R);
  
  result = 2019;
  for (i=L;(i<R) && (i<L+2019); i++) {
//      printf ("i=%d, j=%d\n", i, j);
      for (j=i+1;(j<=R) && (j<i+2020); j++) {
//      printf ("i=%d, j=%d\n", i, j);
//      printf ("a");
          cal = ((i%2019)*(j%2019))%2019;
          if (cal<result) result = cal;
      }
  }
  
  
  printf("%d", result);
  return 0;
}




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

int main() {
    int A, B;
	cin >> A >> B;
	
    if(B%A == 0){
        cout << A+B << endl;
    }else{
        cout << B-A << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != 0)
			{
				var sb = new StringBuilder();
				char[][] grida = new char[n][];
				char[][] gridb = new char[n][];
				List<char>[] gridx = new List<char>[(n * 2) - 1];
				List<char>[] gridy = new List<char>[(n * 2) - 1];

				for (int i = 0; i < n; i++)
				{
					gridb[i] = new char[n];
				}
				for (int i = 0; i < n; i++)
				{
					grida[i] = Console.ReadLine().ToArray();
					for (int j = 0; j < n; j++)
					{
						gridb[j][i] = grida[i][j];
					}
				}

				for (int i = 0; i < (n * 2) - 1; i++)
				{
					gridx[i] = new List<char>();
					gridy[i] = new List<char>();
				}
				for (int i = 0; i < n; i++)
				{
					for (int j = 0; j < n; j++)
					{
						gridx[i + j].Add(grida[i][j]);
						gridy[i + j].Add(grida[i][n - 1 - j]);
					}
				}

				for (int i = 0; i < n; i++)
				{
					sb.Append(new string(grida[i]) + "\n");
					sb.Append(new string(gridb[i]) + "\n");
				}

				for (int i = 0; i < (n * 2) - 1; i++)
				{
					sb.Append(new string(gridx[i].ToArray()) + "\n");
					sb.Append(new string(gridy[i].ToArray()) + "\n");
				}

				while (n-- != 0)
				{
					var p = new string(Enumerable.Repeat('1', n + 1).ToArray());
					if (sb.ToString().Contains(p)) break;
				}
				Console.WriteLine(n + 1);
			}
		}
	}
}

Measured memory_bytes: 9596
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N), B(N);
		REP(i, N) cin>>A[i]>>B[i];
		sort(ALL(A));
		sort(ALL(B));
		ll ans=0;
		if(N%2==1) {
			ans = B[N/2]-A[N/2]+1;
		} else {
			ans = B[N/2-1]+B[N/2]-(A[N/2-1]+A[N/2])+1;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 6048
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define N 1000005
#define BB(V) V[V.size()-2]
#define ex(V) return printf(V),0
using namespace std;
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	if(k==0){
		printf("%lld",(ll)n*n);
		return 0;
	}
	ll ans=0;
	for(int i=k+1;i<=n;i++){
		ans+=((n+1)/i)*(i-k)+max((n+1)%i,k)-k;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll fact[100005];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

int n;
ll a[100005];
ll sum[100005];

int main(void){
	fact[0]=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	for(int i=0;i<n;i++){
		sum[i+1]=sum[i]+mod_inverse(i+1,MOD);
		sum[i+1]%=MOD;
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=a[i]*sum[i+1]%MOD;
		ans+=a[i]*sum[n-i]%MOD;
		ans-=a[i]*sum[1]%MOD;
		ans%=MOD;
		if(ans<0)ans+=MOD;
	}
	ans*=fact[n];
	ans%=MOD;
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 2560
<?php
fscanf(STDIN, "%s", $s);
$m = strlen($s) - 2;
$x = 999;
for ($i = 0; $i < $m; $i++) {
	$d = abs(753 - substr($s, $i, 3));
	if ($d < $x) $x = $d;
}
echo $x;

Measured memory_bytes: 4604
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int n;
  cin>>n;
  vector<vector<pair<ll,ll>>> v(n);
  rep(i,n) {
    int m;
    cin>>m;
    vector<pair<ll,ll>> vp(m);
    rep(j,m) {
      int x, y;
      cin>>x>>y;
      vp.push_back(make_pair(x,y));
    }
    v[i] = vp;
  }
  ll ans = 0;
  
  for(int i=0; i<(1<<n); i++) {
    bool f = true;
    for(int j=0; j<n; j++) {
      if(i&(1<<j)) {
	for(auto p : v[j]) {
	  f = f and ((p.second and (i&(1<<(p.first-1)))) or (!p.second and !(i&(1<<(p.first-1)))));
	}	
      }
    }
    if(f) {
      ll tmp = 0;
      rep(j,n)
	if(i&(1<<j)) tmp++;
      ans = max(ans, tmp);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


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

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

    uint64_t sum = 0;
    for (uint64_t i = 1; i < N + 1; i++)
    {
        if ((i % 3 != 0) && (i % 5 != 0))
        {
            sum += i;
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3596
#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() {
  cin.sync_with_stdio(0);
  ll n;
  cin >> n;
  vb stones(n);

  FOR(i,0,n) {
	  char c;
	  cin >> c;
	  stones[i] = c == 'R';
  }

  ll r = 0;
  FOR(i,0,n) {
	  if (stones[i]) {
		  r++;
	  }
  }

  ll wrong = 0;
  FOR(i,r,n) {
	  if (stones[i]) {
		  wrong++;
	  }
  }

  cout << wrong << endl;
}


Measured memory_bytes: 3612
#include <string.h>
#include <iostream>
#include <vector>
#define N_MAX_DIGIT 5

using namespace std;

void apart(vector<int> &aparted, int toBeAparted) {
    for (int i = 0; i < aparted.size(); i++) {
        aparted[i] = toBeAparted % 10;
        toBeAparted /= 10;
    }
}

int sum(vector<int> toBeSummed) {
    int summed = 0;
    for (int i = 0; i < toBeSummed.size(); i++) {
        summed += toBeSummed[i];
    }
    return summed;
}

int main() {
    int n = 0;
    int a = 0;
    int b = 0;
    int result;
    vector<int> aparted(N_MAX_DIGIT, 0);

    scanf("%d%d%d", &n, &a, &b);

    for (int i = 1; i <= n; i++) {
        apart(aparted, i);
        int summed = sum(aparted);
        if (summed >= a && summed <= b) {
            result += i;
        }
    }

    printf("%d", result);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int N; cin >> N;
    vector<int> L(N); rep(i, N) cin >> L[i];

    map<int64, int> m;
    int64 ans = 0;
    rep(i, N) {
        int64 a = L[i] + i;
        int64 b = i - L[i];

        ans += m[b];
        m[a]++;
    }

    cout << ans << endl;
}

// a 3 3 b 3 1
// i 2 3 j 5 6

// a + i == j - b

Measured memory_bytes: 26472
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	if(a*b>c*d){
		printf("%d\n",a*b);
	}else{
		printf("%d\n",c*d);
	}
	
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define MOD pow(10,9)+7
#define LLINF pow(2,61)-1
#define INF pow(2,29)-1


int main() {
  double a, b, x; cin >> a >> b >> x;
  x /= a;

  double result = 0;
  if (a*b/2>=x) {
    double t = x*2/b;
    result = atan(b/t)/M_PI*180;
  }
  else {
    double t = (a*b-x)*2/a;
    result = atan(t/a)/M_PI*180;
  }
  cout << fixed << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 512
// AOJ 2447 A Two Floors Dungeon
// 2018.2.2 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define QMAX 800000
typedef struct { short s; char f, r, c; } Q;
Q q[QMAX+10]; int top, end;

int S;
char map[53][53];
char sw[11][53][53];
int mov[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
int memo[1024][2][53][53];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int check(int s, int f, int r, int c)
{
	int i, g;

	if (map[r][c] == '|') return 1;
	g = map[r][c] == '^' || isupper(map[r][c]);
	for (i = 0; i < S; i++) if ((s >> i) & 1) g ^= sw[i][r][c];
	return g == f;
}

void enq(int ns, int nf, int nr, int nc, int s, int f, int r, int c)
{
	if (memo[ns][nf][nr][nc]) return;
	memo[ns][nf][nr][nc] = memo[s][f][r][c] + 1;
	q[end].s = ns, q[end].f = nf, q[end].r = nr, q[end++].c = nc;
}

int calc(int sr, int sc)
{
	int k, s, f, r, c, nr, nc;

	q[0].r = sr, q[0].c = sc, top = 0, end = 1;
	memo[0][0][sr][sc] = 1;
	while (top != end) {
		if (end >= QMAX) break;
		s = q[top].s, f = q[top].f, r = q[top].r, c = q[top++].c;
		if (map[r][c] == '&') return memo[s][f][r][c]-1;
		if (map[r][c] == '|') enq(s, f ^ 1, r, c, s, f, r, c);
		if (isalpha(map[r][c])) {
			k = (map[r][c] & 0x1f) - 1;
			enq(s ^ (1 << k), f ^ sw[k][r][c], r, c, s, f, r, c);
		}
		for (k = 0; k < 4; k++) {
			nr = r + mov[k][0], nc = c + mov[k][1];
			if (map[nr][nc] == '#') continue;
			if (check(s, f, nr, nc)) enq(s, f, nr, nc, s, f, r, c);
		}
	}
	return -1;
}

int main()
{
	int W, H, i, r, c, sr, sc; 
	char buf[53];

	W = in(), H = in();
	sr = -1;
	for (r = 0; r < H; r++) {
		fgets(map[r], 53, stdin);
		if (sr >= 0) continue;
		for (c = 0; c < W; c++) {
			if (map[r][c] == '%') sr = r, sc = c;
		}
	}

	S = in();
	for (i = 0; i < S; i++) {
		for (r = 0; r < H; r++) {
			fgets(buf, 53, stdin);
			for (c = 0; c < W; c++) {
				if (buf[c] == '*') sw[i][r][c] = 1;
			}
		}
	}
	printf("%d\n", calc(sr, sc));
	return 0;
}


Measured memory_bytes: 23824
#include <algorithm>
#include <iostream>

using namespace std;

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

    if ((a < 0 && 0 < b) || (c < 0 && 0 < d)) {
        cout << max({ a * c, a * d, b * c, b * d, 0LL }) << endl;
    } else {
        cout << max({ a * c, a * d, b * c, b * d }) << endl;
    }
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n,a,h=1,ans;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		int t=0,f=-1;
		for(;a;a/=2,t++)if(a&1)f++;
		if(h>t)h=t;
		else{
			if(f)t++;
			ans+=t-h;
			h=t;
		}
	}
	printf("%d\n", ans);
}

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

main(){
  int N, T, E, x;
  cin >> N >> T >> E;
  vector<int> ans;

  for ( int i = 0; i < N; i++ ){
    cin >> x;
    for ( int e = -E; e <= E; e++ ){
      if ((T+e)%x == 0 ) ans.push_back(i+1);
    }
  }
  if ( ans.size() == 0 ) cout << -1 << endl;
  else {
    cout << ans[rand()%(ans.size())] << endl;
  }
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int N;
int x[101],y[101],h[101],a,b,c;
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		
		cin >>x[i] >> y[i] >> h[i];
		if(h[i]>0){a=x[i];b=y[i] ;c=h[i];}
	}

	for(int Cx=0;Cx<=100;Cx++){
		for(int Cy=0;Cy<=100;Cy++){
			int H=c+abs(Cx-a)+abs(Cy-b);
			
			bool f=true;
			for(int k=0;k<N;k++){
				
				if(h[k]!= max(H-abs(Cx-x[k])-abs(Cy-y[k]),0) ){
					f=false; 
					//cout << Cx << " " << Cy << " " << H << endl; 
					break;
				}
			}
			if(f==true){
				cout << Cx << " " << Cy << " " << H << endl;return 0;
			}
		}
	}
	
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

int main() {

	int l, r;

	cin >> l >> r;

	int ans = 2019;

	if ((r - l + 1 >= 2019) || l == 0) {
		cout << 0;
		
		return 0;
	}

	if ((int(r / 2019) != int(l / 2019)) || (l % 2019 == 0)) {
		cout << 0;
		
		return 0;
	}

	for (int i = l; i <= r; i++) {
		for (int j = l; j < i; j++) {
			if ((ans > ((i % 2019)*(j % 2019) % 2019))) ans = ((i % 2019)*(j % 2019)%2019);
		}
	}

	cout << ans;
}

Measured memory_bytes: 256
import collections
import itertools
import sys
import time

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n = getint()
xs= getints()

res = 100**2 * n

for g in range(-100,101):
    tmp = 0
    for x in xs:
        tmp += (x-g)**2
    res = min(res, tmp)

print(res)

Measured memory_bytes: 3316
import math
h, w = map(int,input().split())
hw = h * w
r = hw

for i in range(math.floor(h / 3), math.ceil(h / 3) + 1):
    r1 = w * i
    for i1 in range(math.floor((h-i) / 2), math.ceil((h-i) / 2) + 1):
        r2 = i1 * w
        r3 = hw - r1 - r2
        if r3 == 0:
            pass
        
        r = r if (max(r1,r2,r3) - min(r1,r2,r3)) > r else (max(r1,r2,r3) - min(r1,r2,r3))

    for i2 in range(math.floor(w / 2), math.ceil(w / 2) + 1):
        r2 = i2 * (h - i)
        r3 = hw - r1 - r2
        if r3 == 0:
            pass
        r = r if (max(r1, r2, r3) - min(r1, r2, r3)) > r else (max(r1, r2, r3) - min(r1, r2, r3))

for j in range(math.floor(w / 3), math.ceil(w / 3) + 1):
    r1 = h * j
    for j1 in range(math.floor((w-j) / 2), math.ceil((w-j) / 2) + 1):
        r2 = j1 * h
        r3 = hw - r1 - r2
        if r3 == 0:
            pass
        r = r if (max(r1,r2,r3) - min(r1,r2,r3)) > r else (max(r1,r2,r3) - min(r1,r2,r3))
    for j2 in range(math.floor(h / 2), math.ceil(h / 2) + 1):
        r2 = j2 * (w - j)
        r3 = hw - r1 - r2
        if r3 == 0:
            pass
        r = r if (max(r1, r2, r3) - min(r1, r2, r3)) > r else (max(r1, r2, r3) - min(r1, r2, r3))

print(r)

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

#define BR "\n"
#define SP " "

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

  vector<ll> a(N);
  ll MAX = -1e9, MIN = 1e9, SUM = 0;

  for (int i = 0; i < N; i++) {
    ll temp;
    cin >> temp;
    MAX = max(temp, MAX);
    MIN = min(temp, MIN);
    SUM += temp;
  }

  cout << MIN << SP << MAX << SP << SUM << BR;
  return 0;
}


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

int main(){
    //freopen("../input.txt","r",stdin);
    ll a, b, x;
    cin >> a >> b >> x;

    ll one_to_a_all_divisible = a/x;
    ll one_to_b_all_divisible = b/x;

    if(a%x == 0){
        one_to_a_all_divisible = one_to_a_all_divisible - 1;
    }

    cout << one_to_b_all_divisible - one_to_a_all_divisible;
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

const ll MAX_V = 200010;
ll V,E,d[MAX_V];
struct edge{ll from,to,cost;};
vector<edge> es;
bool bellmanford(ll s){
  //初期化
  rep(i,V){
    d[i] = 1e18;
  }
  d[s] = 0;
 
  rep(i,V){
    bool update = false;
    rep(j,es.size()){
      edge e = es[j];
      //cout << d[0] << " " << d[1] << " " << d[2] << endl;
      if(d[e.from]+e.cost < d[e.to]){
        d[e.to] = d[e.from] + e.cost;
        if(i==V-1 && e.to == V-1){
          return 0;
        }
        update = true;
      }
    }
    if(!update) break;
  }
  return 1;
}

int main(){
  cin >> V >> E;
  rep(i,E){
    ll a,b,c;
    cin >> a >> b >> c;
    a--;b--;c*=(-1);
    es.push_back({a,b,c});
  }
  if(bellmanford(0))cout << -d[V-1] << endl;
  else cout << "inf" << endl;
}

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

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

int main() {
  ll n, a, b, ans = 0;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0)
    ans = (b - a) / 2;
  else
    ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;

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


Measured memory_bytes: 3560
n = int(input())

a = []
for i in range(3):
    aa = list(map(int,input().split()))
    a.append(aa)

for i in range(n):
    x,y,z = a[0][i],a[1][i],a[2][i]
    x,z = x-y,z-y
    if i % 2 == 0:
        if y % 6 != 2:
            print("No")
            exit()
    else:
         if y % 6 != 5:
            print("No")
            exit()       
    y = 0
    if (x,y,z) != (-1,0,1) and (x,y,z) != (1,0,-1):
        print("No")
        exit()
        


e,o = 0,0
for i in range(n):
    if i % 2 == 0:
        if a[0][i] > a[2][i]: e += 1
    else:
        if a[0][i] > a[2][i]: o += 1

e %= 2
o %= 2

el = []
ol = []
bite = [0]
bito = [0]

for i in range(n):
    if(i % 2 == 0):
        el.append(a[1][i] // 6 + 1)
        bite.append(0)
    else:
        ol.append(a[1][i] // 6 + 1)
        bito.append(0)

def sum(i,bit):
    s = 0
    while(i > 0):
        s += bit[i]
        i = i&(i-1)
    return s
 
def add(i,x,bit):
    while(i < len(bit)):
        bit[i] += x
        i += i & (-i)

signe = 0
signo = 0

for i in range(len(el)):
    signe += (i - sum(el[i],bite))
    add(el[i],1,bite)    

for i in range(len(ol)):
    signo += (i - sum(ol[i],bito))
    add(ol[i],1,bito) 



if (signe % 2 == o) and (signo % 2 == e) :print("Yes")
else :print("No")

Measured memory_bytes: 22540
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3000000;
const int K = 100000;
const int mod = 1e9 + 7;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, q;
    cin >> n >> q;
    fenwick_tree<int> f(n);
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        f.add(i, x);
    }
    while(q--){
        int t, l, r;
        cin >> t >> l >> r;
        if (t == 0){
            f.add(l, r);
        } else{
            cout << f.sum(l, r) << endl;
        }
    }
}


Measured memory_bytes: 8240
from collections import deque
s = deque(input())
n = int(input())
now: bool = True

for i in range(n):
    q = list(input().split())
    if q[0] == '1':
        now = not now
    else:
        if (q[1] == '1' and now == True) or (q[1] == '2' and now == False):
            s.appendleft(q[2])
        elif (q[1] == '1' and now == False) or (q[1] == '2' and now == True):
            s.append(q[2])
if now == True:
    print(''.join(s))
else:
    print(''.join(reversed(s)))


Measured memory_bytes: 14192
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    print(n*800-200*(n//15))

#B
def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

def J():
    return

def K():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define outwp10(i) cout<<fixed<<setprecision(10)<<i<<"\n";

double calc(vector<double> &x, vector<double>&y, double d, int e)
{
  double sum = 0;
  rep(i,e)
  {
    sum+=pow(abs(x[i]-y[i]), d);
  }
  return pow(sum, 1/d);
}

int main()
{
  int n; cin>>n;
  vector<double> x(n), y(n);
  rep(i,n) cin>>x[i];
  rep(i,n) cin>>y[i];
  outwp10(calc(x,y,1,n));
  outwp10(calc(x,y,2,n));
  outwp10(calc(x,y,3,n));
  double m = 0;
  rep(i,n)
  {
    m = max(abs(x[i]-y[i]), m);
  }
  outwp10(m);
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

int main()
{
	ll n,k;cin>>n>>k;
	ll ans=0;
	ll i;
	vector<ll> sum(n+2,0);
	for(i=1;i<=n+1;i++)
	{
		sum[i]=(sum[i-1]+(i-1))%MOD;
	}
	for(i=k;i<=n+1;i++)
	{
		ll low=sum[i]-sum[0];
		ll high=sum[n+1]-sum[n+1-i];
		ll add=(high-low+1+MOD)%MOD;
		ans=(ans+add)%MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b,c,d=0;
  cin>>a;
  vector<pair<int,int>>N(a);
  rep(i,a){
    cin>>b>>c;
    N[i].first=c;
    N[i].second=b;
  }
  sort(N.begin(), N.end());
  rep(i,a){
    d+=N[i].second;
    if(d>N[i].first){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
	unsigned int h, w;

	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0)
			return 0;

		bool lflag = true;
		for (unsigned int i = 0; i < h; ++i) {
			bool cflag = lflag;
			for (unsigned int j = 0; j < w; ++j) {
				if (cflag)
					cout << "#";
				else
					cout << ".";
				cflag = ! cflag;
			}
			lflag = ! lflag;
			cout << endl;
		}

		cout << endl;
	}
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    map<int,int> m;
    for(int i = 0;i <= 25;i++){
        for(int j = 0;j <= 14;j++){
            m[i*4 + j*7] = 1;
        }
    }
    P(m[n] == 1 ? "Yes" : "No");
}

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int V = sc.nextInt();
		long[] x = new long[N];
		for (int i = 0; i < N; ++i) {
			x[i] = sc.nextLong();
		}

		int cnt = 0;
		int tmp = V;
		while (tmp > 0) {
			++cnt;
			tmp /= 2;
		}
		++cnt;
		int[] Vs = new int[cnt];
		Vs[0] = V;
		for (int i = 1; i < cnt; ++i) {
			Vs[i] = Vs[i - 1] / 2;
		}

		DJSet[] ds = new DJSet[cnt];
		for (int i = 0; i < ds.length; ++i) {
			ds[i] = new DJSet(N);
		}
		for (int i = 0; i < cnt; ++i) {
			for (int j = 0; j + 1 < N; ++j) {
				if (Math.abs(x[j] - x[j + 1]) <= Vs[i]) {
					ds[i].setUinon(j, j + 1);
				}
			}
		}

		int[] dpRight = new int[1 << cnt];
		int[] dpLeft = new int[1 << cnt];

		Arrays.fill(dpLeft, N);
		Arrays.fill(dpRight, -1);

		for (int i = 0; i < (1 << cnt); ++i) {
			for (int nxt = 0; nxt < cnt; ++nxt) {
				if ((i & (1 << nxt)) > 0) {
					continue;
				}
				int ni = i | (1 << nxt);
				dpRight[ni] = Math.max(dpRight[ni], dpRight[i]);
				if (dpRight[i] + 1 < N)
					dpRight[ni] = Math.max(dpRight[ni], ds[nxt].max(dpRight[i] + 1));
			}
		}
		for (int i = 0; i < (1 << cnt); ++i) {
			for (int nxt = 0; nxt < cnt; ++nxt) {
				if ((i & (1 << nxt)) > 0) {
					continue;
				}
				int ni = i | (1 << nxt);
				dpLeft[ni] = Math.min(dpLeft[ni], dpLeft[i]);
				if (dpLeft[i] - 1 >= 0)
					dpLeft[ni] = Math.min(dpLeft[ni], ds[nxt].min(dpLeft[i] - 1));
			}
		}
		int[] ans = new int[N];
		for (int i = 0; i < (1 << cnt); i += 2) {
			int co = ((1 << cnt) - 1) ^ i;
			co -= 1;
			if (dpLeft[co] - dpRight[i] <= 1) {
				Arrays.fill(ans, 1);
				break;
			}
			if (dpLeft[co] - ds[0].max(dpRight[i] + 1) <= 1) {
				++ans[ds[0].min(dpLeft[co] - 1)];
				if (ds[0].max(dpRight[i] + 1) + 1 < N) {
					--ans[ds[0].max(dpRight[i] + 1) + 1];
				}
			}
		}

		for (int i = 1; i < N; ++i) {
			ans[i] += ans[i - 1];
		}

		for (int i = 0; i < N; ++i) {
			if (ans[i] > 0) {
				System.out.println("Possible");
			} else {
				System.out.println("Impossible");
			}
		}
	}

	class DJSet {
		int n;
		int[] upper;
		int[] max;
		int[] min;

		public DJSet(int n) {
			this.n = n;
			upper = new int[n];
			min = new int[n];
			max = new int[n];
			Arrays.fill(upper, -1);
			for (int i = 0; i < n; ++i) {
				max[i] = i;
				min[i] = i;
			}

		}

		int root(int x) {
			return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		void setUinon(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (upper[x] < upper[y]) {
				int tmp = x;
				x = y;
				y = tmp;
			}
			min[y] = Math.min(min[y], min[x]);
			max[y] = Math.max(max[y], max[x]);
			upper[y] += upper[x];
			upper[x] = y;
		}

		int max(int x) {
			x = root(x);
			return max[x];
		}

		int min(int x) {
			x = root(x);
			return min[x];
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 132884
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 2e5 + 2;

int ans[A];
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<int> v;
    for (int i = n; i > 0; i--) {
        int val = 0;
        for (int j = i + i; j <= n; j += i) {
            val += ans[j];
        }
        if (val % 2 != a[i])
            ans[i] = 1, v.pb(i);
    }
    cout << v.size() << '\n';
    for (auto i : v)
        cout << i << ' ';
    return 0;
}

Measured memory_bytes: 5276
#include<stdio.h>
 
int main()
{
  
  int x;
  scanf("%d",&x);
  
  int happy=x/500;
  happy=happy*1000;
  x=x%500;
  x=x/5;
  happy+=x*5;;
  
  
  
  
  printf("%d",happy);
  
  
  
  
 
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<functional>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;

int main() {
    int n; cin >> n;
    vector<pint> senkyo(n);
    for (int  i = 0; i < n; i ++) {
        cin >> senkyo[i].first >> senkyo[i].second;
    }

    ll t = senkyo[0].first;
    ll a = senkyo[0].second;
    for (int i = 1; i < n ; i ++) {
        ll ti = senkyo[i].first;
        ll ai = senkyo[i].second;
        ll n = max((t + ti - 1)/ti, (a + ai - 1)/ai);
        t = n * ti;
        a = n * ai;
    }

    cout << t + a << endl;
}



Measured memory_bytes: 256