akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define mp map<int,int>
#define pp make_pair
#define endl "\n"
#define ll long long 
#define vi vector<int>
#define clock high_resolution_clock::now()

// auto duration = duration_cast<microseconds>(stop - start);  cout<<duration.count();

const int INF = 1e9+5;
const int mod = 1e9 + 7;


using namespace std;
using namespace std::chrono;



void dfs(vector<int>&dp, vector<bool>&vis, int node, vector<int>v[]){
    vis[node] = 1;
    for(int ver : v[node]){
    	
        if(!vis[ver]){
        dfs(dp, vis, ver, v);}

        dp[node] = max(dp[node], 1 + dp[ver]);
        
    }
}


int f(vector<int>v[], int n){
    vector<int>dp(n+1, 0);
   
    vector<bool>vis(n+1, false);
    for(int i=1; i<=n; i++)vis[i] =dp[i] = 0;
    for(int i=1; i<=n; i++){
        if(!vis[i])dfs(dp, vis, i, v);
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        ans = max(ans, dp[i]);
    }
    return ans;
}
        
    

int main(){
	int n, m;
    cin>>n>>m;
    vector<int>v[n+1];
    int x, y;
    while(m--){
        cin>>x>>y;
        v[x].pb(y);
    }
    cout<<f(v, n)<<endl;

	return 0;
}
	
	

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

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

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

	int D,G; cin >> D >> G;

	int p[20],c[20];

	for (int i = 0;i < D;i++){
		cin >> p[i] >> c[i];
	}

	int ans = INT_MAX;

	for (int i = 0;i < (1<<D);i++){
		int pt = 0;
		int pro = 0;
		int M = 0;
		for (int j = 0;j < D;j++){
			if(i&(1<<j)){
				pt += (j+1)*100*p[j]+c[j];
				pro += p[j];
			}else{
				M = j;
			}
		}
		if(pt < G){
			int rem = G-pt;
			int a = (rem-1)/((M+1)*100) + 1;
			if(a > p[M]) continue;
			pro += a;
		}
		ans = min(ans,pro);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
// Your code here!
    #include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
  int a,b,c,x,y,ans,minxy,minab,maxxy,maxab;
  
  cin>>a>>b>>c>>x>>y;
  maxxy=max(x,y);
  minxy=min(x,y);
  minab=min(a,b);
  maxab=max(a,b);
  
  if(2*c<=a){
      if(2*c<=b)ans=2*c*maxxy;
      else{
          if(x<y)ans=2*c*x+(y-x)*b;
          else ans=2*c*x;
      }
  }else if(2*c<=b){
      
          if(y<x)ans=2*c*y+(x-y)*a;
          else ans=2*c*y;
     
  }else if(2*c<=a+b){
      if(x<y)ans=2*c*minxy+b*(y-minxy);
      else ans=2*c*minxy+a*(x-minxy);//cout<<minxy<<endl;
      //cout<<1<<endl;
  }else{
      ans=a*x+b*y;
  }
  
  cout<<ans<<endl;
}

   
    

   



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n;
    vector<int> V(n), W(n);
    for(int i = 0; i < n; i++) {
        cin >> V[i] >> W[i];
    }
    int M = 1 << 11;
    vector<P> rec1[M];
    for(int i = 0; i < M; i++) {
        if(i >= n) {
            break;
        }
        int now = i;
        vector<P> item;
        item.emplace_back(W[0], V[0]);
        while(now != 0) {
            item.emplace_back(W[now], V[now]);
            now = (now - 1) / 2;
        }
        int N = item.size();
        vector<P> tmp;
        for(int bit = 0; bit < (1 << N); bit++) {
            int sumw = 0, sumv = 0;
            for(int j = 0; j < N; j++) {
                if(bit & (1 << j)) {
                    sumw += item[j].first;
                    sumv += item[j].second;
                }
            }
            tmp.emplace_back(sumw, sumv);
        }
        sort(ALL(tmp));
        now = -1;
        for(auto j : tmp) {
            if(now < j.second) {
                rec1[i].emplace_back(j);
                now = j.second;
            }
        }
    }
    cin >> q;
    while(q--) {
        int v, L;
        cin >> v >> L;
        v--;
        vector<P> item;
        while(v >= M) {
            item.emplace_back(W[v], V[v]);
            v = (v - 1) / 2;
        }
        vector<P> rec2;
        int N = item.size();
        for(int bit = 0; bit < (1 << N); bit++) {
            int sumw = 0, sumv = 0;
            for(int i = 0; i < N; i++) {
                if(bit & (1 << i)) {
                    sumw += item[i].first;
                    sumv += item[i].second;
                }
            }
            rec2.emplace_back(sumw, sumv);
        }
        int ans = 0;
        for(auto j : rec2) {
            P p = P(L - j.first, INF);
            auto it = lower_bound(ALL(rec1[v]), p);
            if(it != rec1[v].begin()) {
                it--;
                chmax(ans, it->second + j.second);
            }
        }
        print(ans);
    }
}


Measured memory_bytes: 27384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int res[n];
	res[0] = 0;
	res[1] = abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		res[i] = min(res[i-1]+abs(a[i]-a[i-1]),res[i-2]+abs(a[i]-a[i-2]));
	}
	/*for(int i=0;i<n;i++){
		cout << res[i] << " ";
	}*/
	cout << res[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{

string s,ss,x;
int a,b,i,j,l,k;
vector<int>v;
map<int,int>m;

cin>>a>>b;
for(i=1;i<=b;i++)
{
cin>>l>>k;m[l]++;m[k]++;
}
for(i=1;i<=a;i++)
cout<<m[i]<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).OrderBy(i => i).ToArray();

            Console.WriteLine(Is1974(inputs) ? "YES" : "NO");
        }

        private static bool Is1974(int[] ary)
        {
            if (ary[0] != 1) return false;
            if (ary[1] != 4) return false;
            if (ary[2] != 7) return false;
            return ary[3] == 9;
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,k,d[200001],A[100][100],ans=0;
    int sunuke[200]={0};
    cin>>n>>k;
    rep(i,k){
        cin>>d[i];
        rep(j,d[i]) cin>>A[i][j],sunuke[A[i][j]]=1;
    }
    rep(i,n) if(sunuke[i+1]==0) ans++;
    cout<<ans;
}

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

int main(){

    double a,ans=0;

    for(int i=0; i<5; i++){
      cin >> a;
      if(a < 40){
        a = 40;
      }
      ans += a / 5;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3292
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()
A = LIST()

def f(N):
	left = N
	for a in A:
		left = left//a*a
	return left

l_N_max = 0
r_N_max = 10**14
while l_N_max+1 < r_N_max:
	m = (l_N_max+r_N_max)//2
	if f(m) <= 2:
		l_N_max = m
	else:
		r_N_max = m

N_max = l_N_max

l_N_min = 0
r_N_min = 10**14
while l_N_min+1 < r_N_min:
	m = (l_N_min+r_N_min)//2
	if f(m) < 2:
		l_N_min = m
	else:
		r_N_min = m
N_min = r_N_min

if N_min > N_max:
	print(-1)
else:
	print(N_min, N_max)


Measured memory_bytes: 21472
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

int main(){
  ll N;
  cin>>N;
  string S="";
  
  while(N>0){
    ll T=N%26;
    if(T==0) T=26;
    
    S+='a'+T-1;
    N=(N-T)/26;
  }
  
  REP(i,S.size()) cout<<S[S.size()-1-i];
  cout<<endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  bool f = false;
  rep(i,5) {
    if(n % 10 == 7) f = true;
    n /= 10;
  }
  cout << (f? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    unordered_set<int> s;
    while (k--) {
        int m;
        cin >> m;
        for (int i = 0; i < m; i++) {
            int a;
            cin >> a;
            s.insert(a);
        }
        
    }
    
    cout << n-s.size() << endl;
    return 0;
} 

Measured memory_bytes: 3640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BPictureFrame {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int h, w;
	    in >> h >> w;
	    for(int i=0; i<w+2; i++){
	        out << "#";
	    }
	    out << endl;
	    string c;
	    for(int i=0; i<h; i++){
	        in >> c;
	        out << "#";
	        for(int j=0; j<w; j++){
	            out << c[j];
	        }
	        out << "#" << endl;
	    }
        for(int i=0; i<w+2; i++){
            out << "#";
        }
        out << endl;
	}
};


int main() {
	BPictureFrame solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(c - a) <= d) { cout << "Yes" << endl; }
	else if (abs(c - b) <= d&&abs(b - a) <= d) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

int main() {
  int X, N;
  std::cin >> X >> N;

  std::vector<int> v(N);
  for (auto& p : v) {
    std::cin >> p;
  }

  std::sort(v.begin(), v.end());

  auto it = std::find(v.begin(), v.end(), X);

  if (it == v.end()) {
    std::cout << X << '\n';
    return 0;
  }

  int lower = X - 1;
  auto rit = std::make_reverse_iterator(it);
  for (; (rit != v.rend()) && (*rit == lower); --lower, ++rit) {
  }

  int upper = X + 1;
  ++it;
  for (; (it != v.end()) && (*it == upper); ++upper, ++it) {
  }

  int result = (std::abs(X - upper) < std::abs(X - lower) ? upper : lower);

  std::cout << result << '\n';
}


Measured memory_bytes: 3628
from collections import defaultdict

def bfs(start, end, connect, v_num, flow):
    level = [-1] * v_num
    level[start] = 0
    queue = [start]
    while queue:
        v = queue.pop()
        for next_v in connect[v]:
            if flow[v][next_v] > 0 and level[next_v] < 0:
                level[next_v] = level[v] + 1
                queue.append(next_v)
    return level

def dfs(here, end, connect, level, flow, minimum_f, visited):
    if here == end:
        return minimum_f
    for next_v in connect[here]:
        if not visited[here][next_v] and flow[here][next_v] > 0 and level[here] < level[next_v]:
            visited[here][next_v] = 1
            temp_f = dfs(next_v, end, connect, level, flow, min(flow[here][next_v], minimum_f), visited)
            if temp_f:
                flow[here][next_v] -= temp_f
                flow[next_v][here] += temp_f
                # print(flow)
                return temp_f
    return 0

v_num, e_num = (int(n) for n in input().split(" "))
connect = defaultdict(list)
flow = defaultdict(lambda: defaultdict(int))
for _ in range(e_num):
    s, t, c = map(int, input().split(" "))
    connect[s].append(t)
    connect[t].append(s)
    flow[s][t] = c
start = 0
end = v_num - 1
answer = 0
while True:
    level = bfs(start, end, connect, v_num, flow)
    if level[end] < 0:
        print(answer)
        break
    visited = defaultdict(lambda: defaultdict(int))
    temp_f = dfs(start, end, connect, level, flow, float("inf"), visited)
    while temp_f > 0:
        answer += temp_f
        temp_f = dfs(start, end, connect, level, flow, float("inf"), visited)



Measured memory_bytes: 6224
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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(){
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  vector<ll> bnum(N);
  rep(i, N) {
    auto it = lower_bound(A.begin(), A.end(), B[i]);
    bnum[i] = it-A.begin();
  }
  for(int i=1; i<bnum.size(); i++)
    bnum[i] += bnum[i-1];
  ll ans = 0;
  rep(i, N) {
    auto it = lower_bound(B.begin(), B.end(), C[i]);
    if(it == B.begin())
      continue;
    ans += bnum[it-B.begin()-1];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if ((a==b && a!=c) || (a!=b && b==c) || (a==c && a!=b))
		printf("Yes\n"); 
	else
		printf("No\n");

}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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



int main(void)
{
	int n;
	cin >> n;
	
	vector<int> s(n);

	rep(i, n) cin >> s[i];


	int sum = 0;
	for (int i = 0; i < n;i++)
	{
		if (s[i] != i + 1) sum++;
	}


	if (sum <= 2) cout << "YES" << endl;

	else cout << "NO" << endl;
}

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

int dp[100001] = {}, h[100001] = {};

int main(){
    int n, k, i, j;
    cin >> n >> k;
    for(i=0; i<n; i++){
        cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    for(i=1; i<n; i++){
        for(j=1; j<=min(i, k); j++){
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1] << "\n";
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int count_minus = 0;
  for (int i = 0; i < N; i++) if (A[i] < 0) count_minus++;
  sort(A.begin(), A.end(), [](int64_t a, int64_t b) {
      return abs(a) < abs(b);
    });

  int64_t result = 0;
  for (int i = 0; i < N; i++) {
    if ((count_minus & 1) && i == 0) {
      result -= abs(A[i]);
    } else {
      result += abs(A[i]);
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    int first, last, trgt;
    cin >> first >> last >> trgt;

    int count = 0;
    for(int i=first; i<=last && i<=trgt; ++i)
    {
        if(trgt%i==0) count++;
    }

    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<cstdlib>
using namespace std;
stack <int> s1;

int main() {
	char c[20];
	while (cin >> c) {

		if (c[0] != '+' && c[0] != '-' && c[0] != '*') s1.push(atoi(c));
		else {
			int x, y;
			x = s1.top();
			s1.pop();
			y = s1.top();
			s1.pop();
			if (c[0] == '+') s1.push(x + y);
			else if (c[0] == '-') s1.push(y - x);
			else if (c[0] == '*') s1.push(y * x);
		}		
		char a;
		cin.get(a);
		if (a == '\n') break;
	}
	cout << s1.top() << endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    string s;
    cin >> s;
    cout << s[0] + to_string(s.size() - 2) + s[s.size() - 1] << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	char s[55];
	scanf("%s", s);
	int i, ans = 0;
	for (i = 0; i < n - 2; i++)
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#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 rep(i, n)        for(int i=0; i<(int)(n); ++i)
int sub(int a,vector<char>b,int c,int d){
  if(c%2019==0&&c!=0)return 1;
  return sub(a+1,b,c+b[d]*a,d+1);
}
int main(){ 
  string a,b;
  cin>>a>>b;
  sort(a.begin(),a.end());
  sort(b.rbegin(),b.rend());
  if(a<b)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,a,b;
LL g[10050][2],allsum,sum[5005],f[5005][5005][2];
const int MOD=1e9+7,base=5010;	
int main(){
	fastio;
	cin>>n>>a>>b;
	if(a<b) swap(a,b);
	f[0][0][1]=1;
	g[0+base][1]=1;
	f[0][0][0]=1;
	sum[0]=1;
	allsum=1;
	rb(i,1,n){
		if(i>=b){
			allsum-=sum[i-b];
			allsum+=MOD;
			allsum%=MOD;
			rb(j,0,a-1){
				if(j>=b)
				g[j-i+base][0]+=f[i-b][j-b][0];
				g[j-i+base][0]%=MOD;
			}
		}
		rb(j,0,a-1){
			if(j<=i)
			rep(k,2){
				if(j==0){
					if(k==1){
						f[i][j][1]=allsum;
					}
				}
				else{
					if(!k){
						f[i][j][k]=g[j-i+base][1];
					}
					else{
						f[i][j][k]=g[j-i+base][0];
					}
				}
			}
			sum[i]+=f[i][j][0];
			sum[i]%=MOD;
			g[j-i+base][1]+=f[i][j][1];
			g[j-i+base][1]%=MOD;
		}
		allsum+=sum[i];
		allsum%=MOD;
	}
	LL res=1;
	rb(i,1,n) res<<=1,res%=MOD;
//	cout<<f[1][0][1]<<endl;
	rb(j,0,a-1){
		rep(k,2){
			res-=f[n][j][k];
//			cout<<j<<" "<<k<<" "<<f[n][j][k]<<endl;
			res+=MOD;
			res%=MOD;
		}
	}
	
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 218740
import java.util.Scanner;
import java.util.Stack;
 
public class Main {
    static Stack<Integer> stack;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        stack = new Stack<>();
        stack.push(sc.nextInt());
        while(sc.hasNext()) {
            String input = sc.next();
            switch(input.charAt(0)) {
                case '+':
                calculate('+');
                break;
                case '-':
                calculate('-');
                break;
                case '*':
                calculate('*');
                break;
                default:
                stack.push(Integer.parseInt(input));
            }
        }

        System.out.println(stack.pop());

        sc.close();
    }

    private static void calculate(char ope) {
        int y = stack.pop();
        int x = stack.pop();
        switch(ope) {
            case '+':
            stack.push(x + y);
            break;
            case '-':
            stack.push(x - y);
            break;
            case '*':
            stack.push(x * y);
        }
    }
}


Measured memory_bytes: 26452
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double

using namespace std;
ll n, t, sum, mx, mn, m, k;

void solve(){
	cin >> n >> m;
	if(m == n) cout << "Yes";
	else cout << "No";
}

int main()
{
	t = 1;
//	cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
s = input()
l = len(s)

if s[0] == "A":
    if s[2:l - 1].count("C") == 1:
        if s.count("A") == 1:
            if s.count("C") == 1:
                s = s.replace("A", "a")
                s = s.replace("C", "c")
                if s.islower() == True:
                    print("AC")
                    exit()
print("WA")

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if(n==0)
				break;
			char[] chs = Integer.toOctalString(n).toCharArray();
			for (int i = 0;i<chs.length;i++) {
				if (chs[i] >= '4') {
					chs[i]++;
				}
				if (chs[i] >= '6') {
					chs[i]++;
				}
			}
			System.out.println(chs);
		}
	}
}

Measured memory_bytes: 47992
N, M = map(int, input().split())
X = [tuple(map(int, input().split())) for _ in range(M)]
X.reverse()

# Union Find
parent = [-1 for _ in range(N)]
rank = [0 for _ in range(N)]
def find(x):
  #print(x, parent[x])
  if parent[x] < 0:
    return x
  else:
    p = find(parent[x]) 
    parent[x] = p
    return p
  
def merge(x, y):
  a = find(x)
  b = find(y)
  if a == b:
    return False
  if rank[a] < rank[b]:
    a, b = b, a
  parent[a] += parent[b]
  parent[b] = a
  rank[a] = max(rank[a], rank[b]+1)
  return True
  
def is_connected(a,b):
  return find(a) == find(b)

ans = [0 for _ in range(M+1)]
ans[0] = N*(N-1)//2
i = 1
for a, b in X:
  a -= 1
  b -= 1
  #print(i, a, b, find(a), find(b))
  if find(a) == find(b):
    ans[i] = ans[i-1]
  else:
    m = -parent[find(a)]
    n = -parent[find(b)]
    ans[i] = ans[i-1] + m*(m-1)//2 + n*(n-1)//2
    merge(a, b)
    l = -parent[find(a)]
    ans[i] -= l*(l-1)//2
    #print(i, m, n, l, a, b, parent[a], parent[b])
  i += 1

ans.pop()
ans.reverse()
print(*ans, sep = "\n")
  

Measured memory_bytes: 102276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    ll r = 0, b = 0;
    rep(i,0,N){
        if(S[i] == 'R'){
            r++;
        }else{
            b++;
        }
    }
    if(r > b){
        print("Yes");
    }else{
        print("No");
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;

int main(){
 ll n,k; cin>>n>>k;
 vector<pair<ll,ll>> p(n);
 REP(i,n){
   ll a,b; cin>>a>>b;
   p[i].first=a; p[i].second=b;
 }
 sort(ALL(p));
 ll res=p[0].first,itr=0;
 REP(i,n){
  itr+=p[i].second;

  if(k<=itr){
    res=p[i].first;
    break;
  }
 }
 cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    long weight[n], value[n];
    for (int i = 0; i < n; i++) cin >> weight[i] >> value[i];

    long long dp[n + 1][w + 1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= w; j++) dp[i][j] = 0;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= w; j++) {
            // 何も入れないとき
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            // 何かを入れるとき
            if (j + weight[i - 1] <= w) dp[i][j + weight[i - 1]] = max(dp[i][j + weight[i - 1]], dp[i - 1][j] + value[i - 1]);
        }
    }

    long long res = 0;
    for (int i = 0; i <= w; i++) res = max(res, dp[n][i]);
    cout << res << endl;
}


Measured memory_bytes: 79104
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    set<int> v = { 1,2,3 };
    v.erase(A);
    v.erase(B);
    cout << *v.begin() << endl;
    return 0;
}

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

#include <string>
void _150() {
    int n;
    string s;
    cin >> n;
    cin >> s;

    int count = 0;
    for (int i = 0; i < s.size() - 2; ++i) {
        if (s.substr(i, 3) == "ABC") {
            count++;
        }
    }
    cout << count << endl;
}

void _151() {
    int n, k, m;
    cin >> n >> k >> m;
    int a[100];
    int goal = m * n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a[i];
        goal -= a[i];
    }

    if (goal > k) {
        cout << -1 << endl;
    } else {
        cout << max(goal, 0) << endl;
    }
}

void _152() {
    int a, b;
    cin >> a >> b;

    string result("");
    if (a < b) {
        for (int i = 0; i < b; ++i) {
            result += to_string(a);
        }
    } else {
        for (int i = 0; i < a; ++i) {
            result += to_string(b);
        }
    }
    cout << result << endl;
}

void _153() {
    long long h;
    int n, a;
    cin >> h >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        h -= a;
        if (h <=0) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;
}

void _154() {
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        cout << 'x';
    }
    cout << endl;
}

void _155() {
    int n, a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a % 2 == 0) {
            if ((a % 3 != 0) && (a % 5 != 0)) {
                cout <<"DENIED" << endl;
                return;
            }
        }
    }

    cout << "APPROVED" << endl;
}

#include <cmath>
void _156() {
    int n, k;
    cin >> n >> k;

    for (int i = 0; ; ++i) {
        if (pow(k, i) > n) {
            cout << i << endl;
            return;
        }
    }
}

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



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

int main()
{
    string s;
    cin>>s;
    if(s=="SUN")
    {
        printf("7\n");
    }
    else if(s=="MON")
    {
        printf("6\n");
    }
    else if(s=="TUE")
    {
        printf("5\n");
    }

    else if(s=="WED")
    {
        printf("4\n");
    }
    else if(s=="THU")
    {
        printf("3\n");
    }
    else if(s=="FRI")
    {
        printf("2\n");
    }
    else
    {
        printf("1\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
ll n,a[N],val[N],prfx[N],bit[2*N+10];
void update(ll x){
    x+=n+2;
    for(;x<=2*n+10;x+=x&(-x))++bit[x];
}
ll query(ll x){
    x+=n+2;
    ll ans = 0;
    for(;x;x-=x&(-x))ans+=bit[x];
    return ans;
}
bool chk(ll val){
    for(ll i=0;i<=2*n+10;i++)bit[i]=0;
    for(ll i=1;i<=n;i++){
        if(a[i]<=val)prfx[i]=1;
        else prfx[i]=-1;
        prfx[i]+=prfx[i-1];
    }
    ll cur = 0 , req = (n*(n+1))/2;
    update(0);
    for(ll i=1;i<=n;i++)cur+=query(prfx[i]-1),update(prfx[i]);
    return cur>=req/2  + 1;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i],val[i]=a[i];
    sort(val+1,val+n+1);
    ll k = unique(val+1,val+n+1)-val-1;
    ll l=1,r=k,ans=0;
    while(l<=r){
        ll mid=(l+r)>>1;
        if(chk(val[mid]))ans=val[mid],r=mid-1;
        else l=mid+1;
    }
    cout<<ans;
}

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

int main() {
  int N, a[3000];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  int sum = 0;
  for (int i = 0; i < N; i++) sum += a[i];
  cout << sum - N << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
int merge(vector<int>&a, int l, int mid, int r) {
	int n1 = mid - l;
	int n2 = r - mid;
	vector<int>L(n1 + 1), R(n2 + 1);
	rep(i, 0, n1)L[i] = a[l + i];
	L[n1] = INF;
	rep(i, 0, n2)R[i] = a[mid + i];
	R[n2] = INF;
	int ret(0), i(0), j(0);
	rep(k, l, r) {
		if (L[i] <= R[j]) {
			ret += n2 - j;
			a[k] = L[i++];
		}
		else {
			a[k] = R[j++];
		}
	}
	return ret;
}
int mergeSort(vector<int>&a, int l, int r) {
	if (r - l > 1) {
		int mid = (l + r) / 2;
		return mergeSort(a, l, mid) + mergeSort(a, mid, r) + merge(a, l, mid, r);
	}
	else return 0;
}


template<typename T>
struct BinaryIndexedTree {
	// 1-indexed
	int n;
	vector<T>d;
	// d[x] が管理する区間の長さは，x の最も下の立っているビット(x&-x)
	BinaryIndexedTree(int m) : n(m) {
		// 0 以外の値で初期化をするとき
		// ・add を 𝑁 回呼び出せば 𝑂(𝑁 log 𝑁)
		// ・𝑣𝑥 = 1 で初期化するなら bit[x] = x & -x; (x&-x は区間の長さ)
		// ・一般には bit[x] を 𝑣𝑥 で初期化したのち
		//   for (int x = 1; x < N; ++x) bit[x + (x & -x)] += bit[x];
		d.assign(m + 1, 0);
	}
	T sum(int a, int b) {
		return sum(b) - sum(a - 1);
	}
	T sum(int i) {
		// iから0にiの最も下の立っているbitを使って到達する最短距離
		// 次に足すべき区間は，番号から区間の長さを引くと求まる
		T ret(0);
		for (int j = i; j > 0; j -= j&(-j))ret += d[j];
		return ret;
	}
	void add(int i, T x) {
		// iからnにiの最も下の立っているbitを使って到達する最短距離
		// 次に更新すべき区間は，番号に区間の長さを足すと求まる
		for (int j = i; j <= n; j += j&(-j))d[j] += x;
	}
	int lower_bound(T w) {
		// 二分木の分かれ方に従って二分探索する
		// 左の子に進むか右の子に進むかを知るためには，左の子の範囲の和がわかればよい (index/2)
		// ちょうど BIT がもっている情報，𝑂(1) 時間で得られる
		//
		if (w <= 0)return 0;
		int x(0), y;
		for (y = 1; 2 * y <= n; y <<= 1);
		for (int k = y; k > 0; k >>= 1) {
			if (x + k <= n&&d[x + k] < w) {
				w -= d[x + k];
				x += k;
			}
		}
		return x + 1;
	}
};

template<typename T>
vector<T> compress(vector<T>&a) {
	// 座標圧縮
	vector<T>ret;
	ret.insert(ret.end(), all(a));
	sort(all(ret));
	ret.erase(unique(all(ret)), ret.end());
	rep(i, 0, a.size())a[i] = distance(ret.begin(), lower_bound(all(ret), a[i]));
	return ret;
}

int theNunberOfNotInversion(vector<int>&a) {
	compress(a);
	BinaryIndexedTree<int> bit(a.size());
	rep(i, 0, a.size())a[i]++;
	int ans(0);
	rep(i, 0, a.size()) {
		ans += bit.sum(a[i]);
		bit.add(a[i], 1);
	}
	return ans;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	vector<int> a(N + 1); rep(i, 1, N + 1) { cin >> a[i]; }
	a[0] = 0;
	rep(i, 1, N + 1)a[i] += a[i - 1];
	rep(i, 1, N + 1) {
		a[i] -= i*K;
	}
//	cout << mergeSort(a, 0, N + 1) << endl;
	cout << theNunberOfNotInversion(a) << endl;
	return 0;
}

Measured memory_bytes: 3428
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var ans = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j += 2)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();

    let mut t = String::new();
    for c in s {
        if c == 'B' {
            t.pop();
        } else {
            t.push(c);
        }
    }
    println!("{}", t);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

            int tt = 0;
            int xx = 0;
            int yy = 0;

            for (int i = 0; i < N; i++) {
                int t = sc.nextInt();
                int x = sc.nextInt();
                int y = sc.nextInt();

                int d = Math.abs(x - xx) + Math.abs(y - yy);
                if ((d > t - tt) || (d % 2 != (t - tt) % 2)) {
                    System.out.println("No");
                    System.exit(0);
                }
            }

            System.out.println("Yes");
        }
    }

}

Measured memory_bytes: 86352
#include <iostream>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <algorithm>

int main() {
    long long n, t;
    std::cin >> n;
    std::vector<long long> x(n);
    std::vector<std::deque<long long>> c(n);
    for (auto i = 1ll; i < n; i++) {
        std::cin >> t;
        t--;
        c[t].push_back(i);
    }
    for (auto i = 0ll; i < n; i++) std::cin >> x[i];

    std::deque<long long> q, q2;
    q.push_back(0);
    q2.push_back(0);
    while (!q2.empty()) {
        auto curr = q2.front();
        for (auto el : c[curr]) {
            q.push_back(el);
            q2.push_back(el);
        }
        q2.pop_front();
    }

    /* costs[i].first >= costs[i].second */
    std::vector<std::pair<long long, long long>> costs(n);
    while (!q.empty()) {
        auto curr = q.back();
        q.pop_back();
        auto chsum = 0ll, sum = 0ll;
        if (c[curr].size() == 0) {
            costs[curr] = { x[curr], 0 };
            continue;
        }
        std::bitset<5000> bs;
        for (auto ch : c[curr]) {
            chsum += costs[ch].second;
            sum += costs[ch].first + costs[ch].second;

            auto c = costs[ch].first - costs[ch].second;
            bs |= (bs << c);
            bs[c] = true;
        }
        if (chsum > x[curr]) {
            std::cout << "IMPOSSIBLE" << std::endl;
            return 0;
        }
        for (auto i = x[curr] - chsum; i >= 0; i--) {
            if (bs[i]) {
                chsum += i;
                break;
            }
        }
        costs[curr] = { std::max(x[curr], sum - chsum), std::min(x[curr], sum - chsum) };
    }

    std::cout << "POSSIBLE" << std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if (ch=='A') return 1;
    else if (ch=='C') return 2;
    else if (ch=='G') return 3;
    else if (ch=='T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i=0; i<strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for ( i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(H[h], str) == 0) return 1;
        else if ( strlen(H[h]) == 0 ) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for ( i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if ( strcmp(H[h], str) == 0) return 1;
        else if ( strlen(H[h]) == 0 ) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    scanf("%d", &n);
    for ( i = 0; i < n; i++) {
        scanf("%s %s", com, str);

        if ( com[0] == 'i' ) {
            insert(str);
        } else {
            if ( find(str) ) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int H, W, N;
	cin >> H >> W >> N;
	int A[10001];
	rep1(i, N) {
		cin >> A[i];
	}
	int kotae[100][100];

	int ichi = 0;

	rep1(i, N) {
		rep(ii, A[i]) {
			kotae[ichi / W][ichi % W] = i;
			ichi++;
		}
	}
	for (int i = 1; i <= H; i += 2) {
		reverse(kotae[i], kotae[i] + W);
	}

	rep(i, H) {
		rep(ii, W - 1) {
			cosp(kotae[i][ii]);
		}
		co(kotae[i][W - 1]);
	}

	Would you please return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int N;
  cin >> N;
  if(N%10 == 3) cout << "bon" << endl;
  else if(N%10 == 0||N%10 == 1||N%10 == 6||N%10 == 8) cout << "pon" <<endl;
  else cout << "hon" <<endl;
  return 0;
}

Measured memory_bytes: 3636
n, k = map(int, raw_input().split(' '))
d = {}

for i in range(n):
	a, b = map(int, raw_input().split(' '))
	if d.has_key(a):
		d[a] += b
	else:
		d[a] = b

l = d.keys()
l.sort()

s = 0
for i in l:
	s += d[i]
	if s >= k:
		print i
		break



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

long int p[200000+1][3];


int main()
{
    //FASTIO
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int l=0; cin >> l;
    printf("%.12f", (double)l*l*l/27);
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn main(){
    let n: usize = read();
    let m: i64 = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut rui: Vec<i64> = vec![0;n+1];
    let mut amari: Vec<i64> = vec![0;n+1];
    for i in 0..n {
        rui[i+1] = rui[i] + a[i];
        amari[i+1] = rui[i+1] % m;
    } 
    let mut ans: i64 = 0;
    let mut map: HashMap<i64, i64> = HashMap::new();
    for i in 0..n+1 {
        let mut add = false;
        match map.get_mut(&amari[i]) {
            Some(po) => {
                ans += *po;
                *po += 1
            },
            None => { add = true; },
        }
        if add {
            map.insert(amari[i], 1);
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 14588
h, w = gets.strip.split.map(&:to_i)
a = h.times.map{ gets.strip }

x = "#"
for aa in a do
    aa.insert(0, x)
    aa.insert(aa.length, x)
end

foo = ""
(w + 2).times{ foo += x }

a.insert(0, foo)
a.push(foo)

puts a


Measured memory_bytes: 1788