akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define otc ll t=1;while(t--)
#define ll long long int
#define ld long double
#define pb push_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
#define ull unsigned long long int
#define memset(arr) memset(arr, 0, sizeof(arr));
bool sortinrev(const pair<ll, ll> &a, const pair<ll, ll> &b)
{return (a.fi > b.fi);}//sort by first in descending order
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{ return (a.se < b.se); }//sort by second in ascending order
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
#define PI 3.141592653589793238
vector<int> adj[200005];
bool vist[200005];
int parent[200005];

int main()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    queue<pair<int,int>> q;
    q.push({1,-1});
    vist[1]=1;
    while(!q.empty())
    {
        int node=q.front().fi;
        int p=q.front().se;
        
        if(parent[node]==0)
        parent[node]=p;
        q.pop();
        
        for(auto child: adj[node])
        if(vist[child]==0 && child!=p)
        {
            vist[child]=1;
            q.push({child,node});
        }
    }

    bool f=0;
    for(int i=1;i<=n;i++)
    {
        if(vist[i]!=1)
        {f=1;
        break;}
    }
    if(f)
    cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
        for(int i=2;i<=n;i++)
        cout<<parent[i]<<endl;
    }
    
    return 0;
}


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

int main() {
    int N ;
    cin >> N ;
    int ans;
    ans = 0;
    for( int i = 1 ; i <= N ; ++i ){
        int p ;
        cin >> p ;
        if( p == i){
            ans += 0;
        }
        else{
            ans += 1;
        }
    }
    if( ans == 0 || ans == 2 ){
        cout << "YES" << endl ;
    }
    else{
        cout << "NO" << endl ;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#define fi first
#define se second
#define mp make_pair
using namespace std;
int main(){
    short u;
    scanf("%hd",&u);
    printf("%hd",3*u*u);
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
n=int(input())
B=[int(input()) for j in  range(n)]
 
if (a in B and b in B  and c in B) or (d in B and e in B  and f in B) or (g in B and h in B and i in B) or (a in B and d in B and g in B) or (b in B and e in B and h in B) or (c in B and f in B and i in B) or (a in B and e in B and i in B) or (c in B and e in B and g in B):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=505;
int n,P;
int l[N],r[N];
pair<int,int>a[N];
long long dp[N][N];
long long calc(int k)
{
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	int c1=0,c2=0;
	for(int i=0;i<n+n;i++)
		if(a[i].second==0)
		{
			for(int j=0;j<=c2;j++)
				dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(a[i].first+1-(c1+j))%P)%P;
			c1++;
		}
		else
		{
			for(int j=0;j<=c2;j++)
				dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*(a[i].first+1-(c1+j))%P)%P;
			for(int j=0;j<=c2;j++)
				dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(a[i].second+1-(n+k+(c2-j)))%P)%P;
			c2++;
		}
	return dp[n+n][k];
}
int main()
{
	scanf("%d%d",&n,&P);
	for(int i=0;i<n;i++)
		l[i]=max((int)ceil(sqrt(n*n-i*i)),0),r[i]=min((int)floor(sqrt(4*n*n-i*i)),n+n-1),a[i]=make_pair(l[i]-1,r[i]);
	for(int i=n;i<n+n;i++)
		l[i]=0,r[i]=sqrt(4*n*n-i*i),a[i]=make_pair(r[i],0);
	sort(a,a+n+n);
	long long ans=0;
	for(int i=n;i>=0;i--)
		if(i&1) ans=(ans-calc(i)+P)%P;
		else ans=(ans+calc(i))%P;
	printf("%lld",ans);
	return 0;
}

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

int main()
{
    int n;
    vector<int>vec;

    cin>> n;
    int input;

    for(int i = 0; i < n; i++)
    {
        cin>> input;
        vec.push_back(input);
    }

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

    long int sum, ans;
    //cout<< n;
    int l = 0;

    for(int i= vec[0]; i <= vec[n-1]; i++)
    {
        //cout<< 'x';
        long int temp = 0;
        for(int j = 0; j < n; j++)
        {
            temp =temp + pow((vec[j] - i),2);
        }
        //cout<< temp << "\n";

        if(l == 0)
            ans = temp;
        else
        {

        if(temp < ans)
           ans = temp;

        }

        l++;


    }

    cout<< ans;

}


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

using namespace std;

typedef long long ll;

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

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

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

    string S;
    cin >> S;

    if (N % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    string T = S.substr(0, N / 2);
    string U = S.substr(N / 2, N / 2);

    if (T == U) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> ds(n);
    rep(i,n) {
        int t, d;
        cin >> t >> d;
        --t;
        ds[t].push_back(d);
    }
    vector<int> y0, y1;
    rep(i,n) {
        if (ds[i].size() == 0) continue;
        sort(ds[i].begin(), ds[i].end());
        y1.push_back(ds[i].back());
        ds[i].pop_back();
        y0.insert(y0.end(), ds[i].begin(), ds[i].end());
    }
    sort(y0.rbegin(), y0.rend());
    sort(y1.rbegin(), y1.rend());
    long long ans = 0;
    int Y = max(0, k-int(y0.size()));
    long long X = 0;
    rep(i,Y) X += y1[i];
    rep(i,k-Y) X += y0[i];
    while (1) {
        ans = max(ans, X + (long long)Y*Y);
        if (Y >= k || Y >= y1.size()) break;
        X += y1[Y];
        X -= y0[k-Y-1];
        ++Y;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int N,K,coin,test;
    double ans=0,count;

    scanf("%d %d",&N,&K);

    srand((unsigned int)time(NULL));

    for(int i=1;i<=N;i++){
        test=i;
        count=1;
        while(test<K){
            test*=2;
            count*=0.5;
        }
        ans+=count/N;
    }
    printf("%.12f",ans);
    return 0;
}

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

char c[55][55];
int H, W;

int main() {
    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  int res = 1000;
  for (int i = 0; i < n - 2; ++i) {
    res = min(res, abs(stoi(s.substr(i, 3)) - 753));
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll ans=0,n;
  cin >> n;
  if(n%2){
    cout << ans << endl;
    return 0;
  }
  n/=2;
  while(1){
    n/=5;
    ans+=n;
    if(n==0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
C,S,F = [0],[0],[0]
for i in range(1,N):
    c,s,f = (int(j) for j in input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(1,N):
    x = S[i] + C[i]
    for j in range(i+1,N):
        if S[j]<=x and x%F[j]==0:
            pass
        elif S[j]<=x:
            x = (x//F[j]+1)*F[j]
        else:
            x = S[j]
        x+=C[j]
    print(x)
print(0)

Measured memory_bytes: 42476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n= in.nextInt();
		int [] a= new int[n];
		int [] b= new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i]= in.nextInt();
			if(a[i]==i+1) b[i]=1;
		}
		int res=0;
		boolean used= false;
		for (int i = 0; i < b.length-1; i++) {
			if(b[i]==1&&b[i+1]==1){
				res++;
				i++;
				if(i==b.length-1) used= true;
			}
			else if(b[i]==1){
				res++;
			}
		}
		if(!used && b[n-1]==1) res++;
		
		System.out.println(res);

	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}



Measured memory_bytes: 34652
n,k=map(int,input().split())
a=list(map(int,input().split()))
usiro=0
for i in range(n):
    for j in range(i,n-1):
        if a[i]>a[j+1]:
            usiro+=1            
mae=0
for i in range(n):
    for j in range(0,i):
        if a[i]>a[j]:
            mae+=1
#print(mae)
#print(usiro)
def f(x):
  return x*(x+1)//2
ans=mae*f(k-1)+usiro*f(k)
print(ans%(10**9+7))

Measured memory_bytes: 3188
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

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

typedef vector<int> Edges;
typedef vector<Edges> Graph;

vector<vector<int> > g;
vector<int> order;
vector<bool> color;

void visit(int v) {
  color[v] = true;
  for (vector<int>::iterator e = g[v].begin(); e != g[v].end(); ++e) if (!color[*e]) visit(*e);
  order.push_back(v);
}
void topologicalSort() {rep (u, g.size()) if (!color[u]) visit(u);}

int main() {
  int m, n;
  cin >> m >> n;
  g.resize(m);
  color.resize(m);
  rep (i, n) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[y].push_back(x);
  }
  topologicalSort();
  rep (i, m) cout << order[i] + 1 << endl;
  return 0;
}

Measured memory_bytes: 1224
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def bs(f, mi, ma):
    mm = -1
    while ma > mi:
        mm = (ma+mi) // 2
        if f(mm):
            mi = mm + 1
        else:
            ma = mm
    if f(mm):
        return mm + 1
    return mm

def main():
    n,k = LI()
    a = sorted(LI())
    b = sorted(LI(), reverse=True)
    if sum(a) <= k:
        return 0

    def f(i):
        t = 0
        for ai,bi in zip(a,b):
            u = i // bi
            if ai > u:
                t += ai - u
        return t > k

    r = bs(f,0,10**12)

    return r


print(main())





Measured memory_bytes: 37072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

void cominit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i=2; i<MAX; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll com(ll n, ll k)
{
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main()
{
  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  cominit();

  ll p=0, m=0;
  for (int i=0; i<N; i++) {
    m += (A[i]*com(N-i-1, K-1))%mod;
    m %= mod;
    p += (A[i]*com(i, K-1))%mod;
    p %= mod;
  }
  cout << (p+mod-m)%mod << endl;

  return 0;
}


Measured memory_bytes: 12928
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <list>
#include <climits>

using namespace std;

#define CL(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define pc __builtin_popcount
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, b) FOR(i, 0, b)

typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int step = 0;
    while (true) {
        if ((a & 1) || (b & 1) || (c & 1)) break;

        if (a == b && b == c) {
            step = -1;
            break;
        }

        int next_a = (b + c) / 2;
        int next_b = (a + c) / 2;
        int next_c = (a + b) / 2;

        a = next_a;
        b = next_b;
        c = next_c;

        ++step;
    }

    printf("%d\n", step);
    return 0;
}

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i,N){
   cin >> A[i]; 
  }
  int out = 1;
  REP(i,N){
    if((A[i] % 2 ) == 0 ){
     if((A[i] % 3) == 0 || (A[i] % 5 ) == 0){
       out = 1;
     }
     else{
      out = 0;
       break;
     }
    }
  }
  if(out == 1) cout << "APPROVED";
  else cout << "DENIED";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> v(n, 0);
	unordered_map<int, int> mp;
	for (int i = 0; i < n; i++) {
		cin>>v[i];
		mp[v[i]]++;
	}
	long res = 0;
	for (auto &i : mp) {
		if (i.second > 1) {
			res += (long)i.second * (long)(i.second-1) / 2L;
		}
	}

	for (auto &i : v) {
		long rd = mp[i]-1;
		cout<<res-rd<<endl;
	}

	return 0;
}

Measured memory_bytes: 8392
import java.util.Scanner;

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

		for (int i=0; i<n; i++){
			if ((n-7*i) < 0){
				break;
			}

			if ((n-7*i) % 4 == 0){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
		return;
	}
}

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

int main() {
  int n,y;
  cin>>n>>y;
  int a=-1;
  int b=-1;
  int c=-1;
  for(int i=0;i<=n;i++){
    for(int j=0; j<=n-i;j++){
      if(10000*i+5000*j+1000*(n-i-j)==y){
        a=i;
        b=j;
        c=n-i-j;
      }
    }
  }
  cout<<a<<' '<<b<<' '<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<map>
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)

using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    int r;
    cin >> r;
    fin(3*r*r);
    return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 1100000

int N, M;
int s[MAX];
int temp[MAX];

int check(int X){
	int L = 1, count = 1;
	
	if(s[0] >= L+X) return INF;
	
	for(int i = 0;;){
		if(s[N-1] < L+X) break;
		while(L >= s[i])i++;
		if(!i)  L += max(1ll,X-abs(L-s[i]));
		else if(s[i] < L+X) L += max(1ll,max(X-abs(L-s[i]),X-abs(L-s[i-1])));
		else L += max(1ll,X-abs(L-s[i-1]));
		count++;
	}
	return count;
}


int solve(){
	int l = 1, h = s[N-1]+10, m;
	if(check(1) < M) return -1;
	while(l < h){
		m = (l+h)/2;
		if(check(m) >= M) l = m+1;
		else h = m;
	}
	if(check(h-1) == INF) return -1;
	return h-1;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	while(true){
		
		cin>>N>>M;
		
		if(!N&&!M) break;
		
		for(int i = 0; i < N; i++){
			cin>>s[i];
		}
		
		cout<<solve()<<endl;
	}
	
	return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = a.back() - a.front();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()

x = []
ss = ["A","T","G","C"]

for i in range(len(s)):
  if(i != len(s)):
    for j in range(i+1,len(s)+1):
      x.append(s[i:j])
  else:
    x.append(s[-1])
ans = []
ans.append(0)
for i in range(len(x)):
  tmp = 0
  for j in range(len(x[i])):
    if(x[i][j] in ss):
      tmp += 1
  if(tmp == len(x[i])):
    ans.append(tmp)
print(max(ans))

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 200200;
const ll INF = (ll)1e17;
ll a[N];
int n;
ll b[N], c[N];
ll ans = INF;

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

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		ll x;
		scanf("%lld", &x);
		a[i + 1] = a[i] + x;
	}
	set<ll> setik;
	for (int i = 1; i < n; i++) {
		if (i >= 2) {
			ll val = INF;
			ll x = (a[i] + a[0]) / 2;
			auto it = setik.upper_bound(x);
			if (it != setik.end()) {
				ll y = *it;
				ll z = max(abs(y - a[0]), abs(y - a[i]));
				if (z < val) {
					val = z;
					b[i] = y;
				}
			}
			if (it != setik.begin()) {
				it--;
				ll y = *it;
				ll z = max(abs(y - a[0]), abs(y - a[i]));
				if (z < val) {
					val = z;
					b[i] = y;
				}
			}
		}
		setik.insert(a[i]);
	}
	setik.clear();
	for (int i = n - 1; i > 0; i--) {
		if (i <= n - 2) {
			ll val = INF;
			ll x = (a[i] + a[n]) / 2;
			auto it = setik.upper_bound(x);
			if (it != setik.end()) {
				ll y = *it;
				ll z = max(abs(y - a[i]), abs(y - a[n]));
				if (z < val) {
					val = z;
					c[i] = y;
				}
			}
			if (it != setik.begin()) {
				it--;
				ll y = *it;
				ll z = max(abs(y - a[i]), abs(y - a[n]));
				if (z < val) {
					val = z;
					c[i] = y;
				}
			}
		}
		setik.insert(a[i]);
	}

	for (int i = 2; i <= n - 2; i++) {
		ll mx = -INF, mn = INF;
		ll x = b[i] - a[0];
		mx = max(mx, x);
		mn = min(mn, x);
		x = a[i] - b[i];
		mx = max(mx, x);
		mn = min(mn, x);
		x = c[i] - a[i];
		mx = max(mx, x);
		mn = min(mn, x);
		x = a[n] - c[i];
		mx = max(mx, x);
		mn = min(mn, x);
		ans = min(ans, mx - mn);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 14336
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <map>
const int maxn = 100005;
using ll = long long;
std::vector<int> G[maxn];
inline void ins_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

ll d_n;
ll calc_dis(int x, int fa = 0) {
  ll ans = 1;
  for(int v : G[x]) {
    if(v != fa) ans += calc_dis(v, x);
  }
  d_n += ans;
  return ans;
}

ll d[maxn];
inline int cmp(const int &i, const int &j) {
  return d[i] > d[j];
}

using pii = std::pair<int, int>;
std::map<ll, int> ma;
int id[maxn], siz[maxn];
int main() {
  int n; scanf("%d", &n); d_n = -n;
  for(int i = 1; i <= n; i ++) {
    scanf("%lld", &d[i]);
    ma[d[i]] = i;
  }
  for(int i = 1; i <= n; i ++) id[i] = i;
  std::sort(id + 1, id + 1 + n, cmp);
  std::vector<pii> E;
  for(int i = 1; i < n; i ++) {
    int th = id[i]; siz[th] ++;
    ll p_d = d[th] - (n - siz[th]) + siz[th];
    if(!ma.count(p_d) || p_d > d[th]) {
      puts("-1"); return 0;
    }
    int fa = ma[p_d]; siz[fa] += siz[th];
    ins_edge(th, fa); E.push_back({th, fa});
  }
  calc_dis(id[n]);
  if(d_n != d[id[n]]) {
    puts("-1"); return 0;
  }
  for(auto e : E) {
    printf("%d %d\n", e.first, e.second);
  }
  return 0;
}

Measured memory_bytes: 17780
#include <bits/stdc++.h>
using namespace std; 
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define ld long double
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reprev(i,a,b) for(int i=b-1;i>=a;i--)
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vin(a,n) vi a(n); rep(i,0,n) cin>>a[i];
#define vout(a) rep(i,0,sz(a)) cout<<a[i]<<" "; cout<<endl;
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define inf LLONG_MAX
#define pi 3.1415926535897932384626
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

signed main()
{
    IOS
    int n;
    cin>>n;
    vin(a,n);
    int total=0;
    rep(i,0,n)
    {
        total^=a[i];
    }
    rep(i,0,n)
    {
        int x=total^a[i];
        cout<<x<<" ";
    }
    return 0;
}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    int n;cin>>n;
    int count=0;
    vector<int>p(n);
    rep(i,n)cin>>p[i];
    vector<int>cop=p;
    sort(all(cop));
    rep(i,n){
        if(p[i]!=cop[i])count++;
    }
    cout<<(count<=2?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

string s[30];
string str[2000];
int n;
bool bo[30][30];

int main() {
    while (1) {
        int h, w;
        cin >> h >> w;
        if (h == 0) {
            break;
        }
        for (int i = 0; i < h; i++) {
            cin >> s[i];
        }
        int num = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                for (int k = 0; k < 8; k++) {
                    for (int l = 0; l < h; l++) {
                        fill(bo[l], bo[l] + w, false);
                    }
                    string ss = "";
                    int x = i;
                    int y = j;
                    while (!bo[x][y]) {
                        ss.push_back(s[x][y]);
                        bo[x][y] = true;
                        x = (x + h + dx[k]) % h;
                        y = (y + w + dy[k]) % w;
                    }
                    str[num] = ss;
                    num++;
                }
            }
        }
        n = h * w * 8;
        // for (int i = 0; i < n; i++) {
        //     cout << str[i] << endl;
        // }
        string ans = "";
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                string sa = str[i];
                string sb = str[j];
                int lena = sa.size();
                int lenb = sb.size();
                int numb = -1;
                int len = min(lena, lenb);
                for (int k = 0; k < len; k++) {
                    if (sa[k] != sb[k]) {
                        numb = k;
                        break;
                    }
                }
                if (numb == -1) {
                    numb = len;
                }
                int anslen = ans.size();
                if (numb > anslen) {
                    ans = sa.substr(0, numb);
                } else if (numb == anslen) {
                    if (sa.substr(0, numb) < ans) {
                        ans = sa.substr(0, numb);
                    }
                }
            }
        }
        int anslenb = ans.size();
        if (anslenb >= 2) {
            cout << ans << endl;
        } else {
            cout << 0 << endl;
        }
    }
}



Measured memory_bytes: 3516
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	string s;
	cin>>s;

	lli cnt=0;
	lli ans=s.size();
	REP(i,0,s.size()){
		if(s.at(i)=='T'){
			if(cnt>0){
				cnt--;
				ans-=2;
			}
		}
		else{
			cnt++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n;
  cin >> n;

  auto p = prime_factorize(n);
  ll ans = 0;
  for(auto i : p){
    ll e = i.second;
    ll tmp = 0, cnt = 1;
    while(e >= cnt) ++tmp, e -= cnt++;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3680
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a + b < c) {
            System.out.println(a + (2 * b) + 1);
        } else {
            System.out.println(b + c);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, a = 0, b = 0;
	scanf("%d", &n);
	for (int i =0; i < n; ++ i) {
		int x;
		scanf("%d", &x);
		if (x & 1) a ++; else b ++;
	}
	if (a & 1) puts("NO"); else puts("YES");
}



Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long now;
long long nn;
long long n;
long long ni;
long long dp[40];
int main()
{
	cin>>n;
	now=1;
	ni=2;
	for(long long i=0;i<40;i++)
	{
		if(n%ni==0)
		{
			dp[i]=0;
		}
		else
		{
			dp[i]=1;
			n-=now;
			nn+=now;
		}
		now*=(-2);
		ni*=2;
		if(n==0)
		{
			for(long long j=i;j>=0;j--)
			{
				cout<<dp[j];
			}
			break;
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v) (int)v.size()
#define debug(var) cout << #var << ": " << var << endl;
using namespace std;
using ll = long long;
using pii = pair<int, int>;

template<class T>
struct bi_t : vector<T> {
    bi_t(int n) : vector<T>(n + 1) {};
    int lowbit(int i) { return i & (-i); }
    T sum(T i) {
        int s = 0;
        for (; i > 0; i -= lowbit(i)) s += (*this)[i];
        return s;
    }
    void add(int i, T x) {
        for (i++; i < (int)this->size(); i += lowbit(i)) (*this)[i] += x;
    }
};

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n, m;
    cin >> n >> m;
    vector<pii> segs(n);
    for (auto &e : segs) cin >> e.first >> e.second, e.second++;
    auto cmp = [](pii a, pii b){ return a.second - a.first < b.second - b.first; };
    sort(segs.begin(), segs.end(), cmp);

    bi_t<int> d(m);

    auto now = segs.begin();
    for (int i = 1; i <= m; i++) {
        ll ans = 0;
        auto up = lower_bound(segs.begin(), segs.end(), (pii){0, i}, cmp);
        ans += segs.end() - up;
        for (; now != up; now++)
             d.add(now->first - 1, 1), d.add(now->second - 1, -1);

        for (int j = 0; j < m + 1; j += i)
            ans += d.sum(j);
        cout << ans << endl;
    }    
}

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
//a^n modをO(logN)で計算
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    int64_t n;
    cin>>n;
    map<int64_t,int64_t> p;
    vector<int64_t> d(n);
    int max=0;
    rep(i,n){
        cin>>d[i];
        if(d[i]>max){
            max=d[i];
        }
        p[d[i]]++;
    }
    rep(i,max+1){
        
        if(p[d[i]]==0 || p[0]!=1 || d[0]!=0){
            cout<<0<<endl;
            return 0;
        }
    }
    int64_t ans=1;
    int MOD=998244353;
    for(int i=0;i<max;i++){
        ans = ((ans%MOD)*modpow(p[i],p[i+1],MOD))%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 1e5+7;
const ll INF = 1e18;

ll n,k,dp[nax],a[nax];

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin>>n>>k;
	for (ll i=1;i<=n;++i) cin>>a[i];
	for (ll i=2;i<=n;++i) dp[i]=INF;
	
	for (ll i=1;i<=n;++i) {
		
		for (ll j=1;j<=k;++j){
			dp[i]=min(dp[i],((i-j>0)? dp[i-j]+abs(a[i]-a[i-j]) : INF));
		}
		
	}
	
	cout<<dp[n]<<"\n";
}

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

int N, M, C;
vector<int> B;

int
main()
{
  cin >> N >> M >> C;
  for (int j = 0; j < M; j++) {
    int b; cin >> b;
    B.emplace_back(b);
  }

  int num = 0;
  for (int i = 0; i < N; i++) {
    int score = C;
    for (int j = 0; j < M; j++) {
      int a; cin >> a;
      score += a * B.at(j);
    }
    if (0 < score) num++;
  }
  
  cout << num << endl;
}
/*
2 3 -10
1 2 3
3 2 1
1 2 2
 */


Measured memory_bytes: 256
import math
from functools import reduce

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,k = get_nums_l()
k -= 1
s = input()

ans = ""
for i in range(n):
    c = s[i]
    if i == k:
        ans += c.lower()
    else:
        ans += c

print(ans)

Measured memory_bytes: 3828
#include<iostream>
using namespace std;
#define N 100003
int dp[N][3],happy[N][3];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>happy[i][0]>>happy[i][1]>>happy[i][2];
    dp[0][0]=happy[0][0];
    dp[0][1]=happy[0][1];
    dp[0][2]=happy[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=happy[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=happy[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=happy[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}


Measured memory_bytes: 2560
def main():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    B = [list(map(int, input().split())) for _ in range(H)]
    C = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            C[h][w] = abs(A[h][w] - B[h][w])

    dp = [[0 for _ in range(6400)] for _ in range(H*W)]
    dp[0][C[0][0]] = 1

    for d in range(H*W):
        h, w = divmod(d, W)
        for k in range(6400):
            if not dp[h*W+w][k]:
                continue
            nh, nw = h+1, w+1
            if nh < H:
                if k + C[nh][w] < 6400:
                    dp[nh*W+w][k+C[nh][w]] = 1
                dp[nh*W+w][abs(k-C[nh][w])] = 1
            if nw < W:
                if k + C[h][nw] < 6400:
                    dp[h*W+nw][k+C[h][nw]] = 1
                dp[h*W+nw][abs(k-C[h][nw])] = 1

    for k in range(6400):
        if dp[-1][k]:
            print(k)
            exit()

if __name__ == "__main__":
    main()

Measured memory_bytes: 380680
N,M = map(int,input().split())
count = 0
for i in range(M):
    a,b = map(int,input().split())
    if count == 0:
        L = a
        R = b
        count = 1
    else:
        if L < a:
            L =a
            if L>R:
                break
        if R > b:
            R = b
            if R < L:
                break
if M == i+1:
    print(R-L+1)
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;


int main(){
    int n,k; cin >> n >> k;
    vector<int> vec(n);
    for(int i=0;i<n;i++) cin >> vec[i];
    sort(vec.begin(),vec.end());
    int ans=0;
    for(int i=0;i<k;i++) ans+=vec[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
def resolve():
  n = int(input())
  a = []
  for i in range(n):
    a.append(int(input()) - 1)

  ans = 0
  idx = 0
  while True:
    if a[idx] == -1:
      print("-1")
      return
    if idx == 1:
      break
    ans += 1
    tmp = a[idx]
    a[idx] = -1
    idx = tmp
  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 7084
import math
import collections
import sys

#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

k=I()
ans=(k//2)*(k-k//2)
print(ans)


Measured memory_bytes: 3316
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(b%2==0&&a*2<=b&&b<=a*4)printf("Yes\n");else printf("No\n");
}

Measured memory_bytes: 1660
// 2011/08/24 Tazoe

#include <iostream>
#include <climits>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++)
			for(int j=0; j<10; j++)
				if(i==j)
					T[i][j] = 0;
				else
					T[i][j] = INT_MAX;

		int m = -1;	// ¬Ì
		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;
			T[a][b] = T[b][a] = c;
			if(m<a)
				m = a;
			if(m<b)
				m = b;
		}
		m = m+1;

		// tChÌASY
		for(int k=0; k<m; k++){
			for(int i=0; i<m; i++){
				for(int j=0; j<m; j++){
					if(T[i][k]==INT_MAX||T[k][j]==INT_MAX)	// «·ÆI[ot[·éÌÅ
						continue;
					if(T[i][j]>T[i][k]+T[k][j])
						T[i][j] = T[i][k]+T[k][j];
				}
			}
		}

		int m_min = INT_MAX;
		int s_min = INT_MAX;
		for(int i=0; i<m; i++){
			int sum = 0;
			for(int j=0; j<m; j++)
				sum += T[i][j];
			if(sum<s_min){
				m_min = i;
				s_min = sum;
			}
		}

		cout << m_min << ' ' << s_min << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	
	public static void main(String [] args) throws IOException{
		
		ArrayDeque<Integer> list = new ArrayDeque<Integer>();
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		String  str;
		StringBuilder builder = new StringBuilder();
		
		for(int i=0; i<n; i++){
			str = reader.readLine();
			if(str.charAt(0) == 'i'){
				list.push(Integer.parseInt(str.substring(7)));
			}else if(str.charAt(6) == ' '){
				list.remove((Integer) Integer.parseInt(str.substring(7)));
			}else if(str.charAt(6) == 'F'){
				list.removeFirst();
			}else{
				list.removeLast();
			}	
		}
		
		builder.append(list.poll());
		for(int num: list){
			builder.append(" ").append(num);
		}
		System.out.println(builder);
	}
  
}

Measured memory_bytes: 125344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication46
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int a = int.Parse(Console.ReadLine()), s = 0,b;
                if (a == 0) break;
                for( b=5;; b *= 5)
                {
                    s += (a / b);
                    if (b>a) break;
                }
                Console.WriteLine(s);
            }
        }
    }
}

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

int main() {
  string b;
  cin >> b;
  if (b == "A") {
    cout << "T" << endl;
  } else if (b == "T") {
    cout << "A" << endl;
  } else if ( b == "G") {
    cout << "C" << endl;
  } else {
    cout << "G" <<endl;
  }

  return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def mod_comb_count(n, r, mod):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

mod=10**9+7
print((2*mod+(pow(2,n,mod)-1)-mod_comb_count(n,a,mod)-mod_comb_count(n,b,mod))%mod)


Measured memory_bytes: 3064