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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAX = 2e5 + 10 ;

int n ;
long long sz[MAX] , mul[MAX] , ans[MAX] ;
long long fact = 1ll ;
vector< vector<int> >adj(MAX) ;

long long powlog(long long base , long long power)
{
	if(power == 0)
		return 1ll ;
	long long x = powlog(base , power / 2ll) ;
	x = (x * x) % mod ;
	if(power & 1)
		x = (x * base) % mod ;
	return x ;
}

long long ModInv(long long a , long long b)
{
	long long x = powlog(b , mod-2ll) % mod ;
	x = (x * a) % mod ;
	return x ;
}

void dfs(int node , int par)
{
	sz[node] = 1 ;
	mul[node] = 1ll ;
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		dfs(child , node) ;
		sz[node] += sz[child] ;
		mul[node] = (mul[node] * mul[child]) % mod ;
	}
	mul[node] = (mul[node] * sz[node]) % mod ;
}

void dfs2(int node , int par , long long val)
{
	//calculate answer of children
	long long x = 1ll , y , a ;
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		x = (x * mul[child]) % mod ;
	}
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		y = ModInv(x , mul[child]) ;
		y = (y * val) % mod ;
		a = (n - sz[child]) ;
		y = (y * a) % mod ;
		dfs2(child , node , y) ;
	}
	//calculting answer of current node
	x = val ;
	x = (x * n) % mod ;
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		x = (x * mul[child]) % mod ;
	}
	ans[node] = ModInv(fact , x) % mod ;
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
	}
	for(long long i = 1 ; i <= n ; ++i)
		fact = (fact * i) % mod ;
	dfs(1 , -1) ;
	dfs2(1 , -1 , 1) ;
	for(int i = 1 ; i <= n ; ++i)
		cout<<ans[i]<<"\n" ;
	return 0 ; 
}		

Measured memory_bytes: 18676
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 705
#define maxm 500005
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define ff first
#define ss second

int n,m,tot;
int now[maxn],pre[maxm*2],son[maxm*2];
bool f[maxn][maxn];

inline int read(){
    int x=0,f=1; char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

void add(int a,int b){son[++tot]=b,pre[tot]=now[a],now[a]=tot;}
void link(int a,int b){add(a,b),add(b,a);}

int cnt,cc[2];
pii pps[maxn];
int col[maxn];
bool can=1,g[maxn][maxn];

void dfs(int x,int pp){
	col[x]=pp; ++cc[pp];
	for (int p=now[x];p;p=pre[p]){
		if (~col[son[p]]){if (col[son[p]]==col[x]) can=0; continue;}
		dfs(son[p],pp^1);
	}
}

int calc(int n){return n*(n-1)>>1;}

int main(){
	n=read(),m=read();
	for (int i=1,a,b;i<=m;i++){
		a=read(),b=read();
		f[a][b]=f[b][a]=1;
	}
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			if (!f[i][j]) link(i,j);
	memset(col,-1,sizeof(col));
	for (int i=1;i<=n;i++)
		if (!~col[i]){
			cc[0]=cc[1]=0;
			dfs(i,0); pps[++cnt]=mp(cc[0],cc[1]);
		}
	if (!can){puts("-1"); return 0;}
	g[0][0]=1;
	for (int i=1;i<=cnt;i++)
		for (int j=n;~j;j--){
			if (j>=pps[i].ff) g[i][j]|=g[i-1][j-pps[i].ff];
			if (j>=pps[i].ss) g[i][j]|=g[i-1][j-pps[i].ss];
		}
	int ans=1e9;
	for (int i=1;i<=n;i++)
		if (g[cnt][i]) ans=min(ans,calc(i)+calc(n-i));
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

int main() {
  ll Q; cin >> Q;
  ll sum_b = 0;
  priority_queue<ll> former;
  priority_queue<ll,vector<ll>,greater<ll>> latter;
  ll sum_former = 0;
  ll sum_latter = 0;
  REP(i,Q){
    ll type; cin >> type;
    if(type==1){
      ll a,b; cin >> a >> b;
      sum_b += b;
      if(i==0){
        former.push(a);
        sum_former += a;
      }else if(former.size() > latter.size()){
        //latterに追加
        ll t = former.top();
        if(a>=t){
          latter.push(a);
          sum_latter += a;
        }else{
          former.pop();
          former.push(a);
          latter.push(t);
          sum_former += a-t;
          sum_latter += t;
        }
      }else{//former.size() == latter.size()
        //formerに追加
        ll t = latter.top();
        if(a<=t){
          former.push(a);
          sum_former += a;
        }else{
          latter.pop();
          latter.push(a);
          former.push(t);
          sum_former += t;
          sum_latter += a-t;
        }
      }
    }else{
      ll x = former.top();
      ll val = x*(former.size()-latter.size()) - sum_former + sum_latter + sum_b;
      cout << x << " " << val << endl;
    }
  }
}
 

Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0)return 0;
        bool odd = true;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (odd) {
                    cout << '#';
                    odd = false;
                }
                else {
                    cout << '.';
                    odd = true;
                }
            }
            cout << endl;
            if (W % 2 == 0) {
                if (odd)odd = false;
                else odd = true;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
long long n,a,b;
int main(){
	std::cin>>n>>a>>b;
	if(a>b)std::swap(a,b);
	long long ans=LLONG_MAX;
	if((b-a)%2==0)ans=std::min(ans,b-a>>1);
	ans=std::min(ans,b-1);
	ans=std::min(ans,n-a);
	if((b-a)%2==1){
		ans=std::min(ans,a+(b-a-1>>1));
		ans=std::min(ans,n-b+1+(-a+b-1>>1));
	}
	std::cout<<ans<<std::endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

signed main(){
  int n;cin >> n;
  vector<P> ans;
  rep(i,n)rep(j,n){
    if(i >= j)continue;
    if(n%2 == 0 and j == n-1-i)continue;
    if(n%2 == 1 and j == n-1-i-1)continue;
    ans.pb(P(i+1, j+1));
  }
  cout << ans.size() << endl;
  rep(i,ans.size())cout << ans[i].fi << " " << ans[i].se << endl;
  return 0;
}





Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,ans = "YES";cin >> s;vector<int> a(3);
    for(int i=0; i<s.size(); i++) a[s[i]-'a']++; 
    sort(a.begin(), a.end());
    if(1<a[2]-a[0]) ans = "NO";
    cout << ans << endl;
}

Measured memory_bytes: 512
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();
      	if(a==1)
          if(b==2)
            System.out.println("3");
      	  else
            System.out.println("2");
      	else if(a==2)
          if (b==1)
          	System.out.println("3");
      	  else
            System.out.println("1");
      	else
          if (b==1)
            System.out.println("2");
      	  else
            System.out.println("1");
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <random>

int main() {
	int t; std::cin >> t;
	for (auto _i = 0; _i < t; ++_i) {
		int n; std::cin >> n;
		std::string state; std::cin >> state;
		std::vector<bool> shelves{ state[0] == 'Y', state[2 * n] == 'Y' };
		for (auto i = 1; i < n; ++i) {
			shelves.push_back(state[i * 2 - 1] == 'Y' || state[i * 2] == 'Y');
			shelves.push_back(state[2 * n + i * 2 - 1] == 'Y' || state[2 * n + i * 2] == 'Y');
		}
		shelves.push_back(state[2 * n - 1] == 'Y');
		shelves.push_back(state[4 * n - 1] == 'Y');
		int upper = -1, mid = 6 * n, lower = 6 * n;
		for (auto i = 0; i <= n; ++i) {
			int new_upper, new_mid, new_lower;
			if (!shelves[2 * i] && !shelves[2 * i + 1]) {
				new_upper = std::min({ upper + 1, mid + 2, lower + 3 });
				new_mid = std::min({ upper + 2, mid + 1, lower + 2 });
				new_lower = std::min({ upper + 3, mid + 2, lower + 1 });
			}
			else if (shelves[2 * i] && shelves[2 * i + 1]) {
				new_upper = std::min({ upper + 4, mid + 3, lower + 3 });
				new_mid = std::min({ upper + 3, mid + 3, lower + 3 });
				new_lower = std::min({ upper + 3, mid + 3, lower + 4 });
			}
			else if (shelves[2 * i]) {
				new_upper = std::min({ upper + 2, mid + 2, lower + 3 });
				new_mid = std::min({ upper + 2, mid + 2, lower + 3 });
				new_lower = std::min({ upper + 3, mid + 3, lower + 4 });
			}
			else {
				new_upper = std::min({ upper + 4, mid + 3, lower + 3 });
				new_mid = std::min({ upper + 3, mid + 2, lower + 2 });
				new_lower = std::min({ upper + 3, mid + 2, lower + 2 });
			}
			upper = new_upper;
			mid = new_mid;
			lower = new_lower;
		}
		std::cout << upper << std::endl;
	}
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==1||b==1){
    if(a==b)
      cout << "Draw" << endl;
    else if(a==1)
      cout << "Alice" << endl;
    else
      cout << "Bob" << endl;
  }
  else{
    if(a==b)
      cout << "Draw" << endl;
    else if(a>b)
      cout << "Alice" << endl;
    else
      cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s,t,u;cin>>s>>t;
    int a,b;cin>>a>>b;
    cin>>u;
    if(s==u){
        cout << a-1 << " " << b;
    }else{
        cout << a << " " << b-1;
    }
    return 0;
}

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


int A[26];
int main(){
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		A[s[i]-'a']++;
	}
	
	
	for(int i=0;i<26;i++){
		if(A[i]%2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
for i in sys.stdin:
	a,b,c,d,e,f=list(map(float,i.split()))
	y=(d*c-a*f)/(d*b-a*e)+0
	x=(e*c-b*f)/(e*a-d*b)+0
	print("{:.3f} {:.3f}".format(x,y))

Measured memory_bytes: 7380
n = int(input())
v = list(map(int, input().split()))
v.sort()
i=0
while not(len(v)==1):
    v_new = (v[0] + v[1]) / 2
    v.pop(0)
    v.pop(0)
    v.append(v_new)
    v.sort()
print(v[0])


Measured memory_bytes: 2940
parseInt(x) = parse(Int,x)

function main()
  N = parseInt(readline())
  A = map(parseInt,split(readline()))
  B = map(parseInt,split(readline()))
  C = map(parseInt,split(readline()))
  m = B[A[1]]
  for i = 2:N
    m += B[A[i]]
    if A[i] - A[i-1] == 1
      m += C[A[i-1]]
    end
  end
  println(m)
end

main()

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll,ll> vll;
typedef pair<ll,ll> pll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n, k;
	cin >> n >> k;
	vi h(n);
	M00(i, n) cin >> h[i];
	vi DP(n);
	DP[0] = 0;
	for(int i = 1; i < n; i++) {
		for(int j = 1; j <= k; j++) {
			if(j == 1) 
				DP[i] = DP[i-1] + abs(h[i] - h[i-1]);
			else if(i - j >= 0) 
				DP[i] = min(DP[i-j] + abs(h[i-j] - h[i]), DP[i]);
		}
	}
	finish(DP[n-1]);
}


Measured memory_bytes: 1024
def resolve():
    import sys
    import itertools
    import numpy as np

    readline = sys.stdin.readline

    N = int(readline())
    lst = [list(map(int, readline().split())) for _ in [0] * N]

    dp = np.full((N, 3), -1, np.int32)
    for i in range(N):
        for a, b in itertools.permutations([0, 1, 2], 2):
            if a == b:
                continue
            if i == 0:
                dp[i][a] = lst[i][a]
            else:
                dp[i][a] = max(dp[i][a], dp[i - 1][b] + lst[i][a])
    print(max(dp[-1]))

resolve()


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

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    ans += (ll) (N / K) * (N / K) * (N / K);
    if (K % 2 == 0) ans += (ll) ((N + K / 2) / K) * ((N + K / 2) / K) * ((N + K / 2) / K);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-9
#define endl "\n"
/*ll gcd(ll a,ll b)
{
    if(a==0){return b;}
    return gcd(b%a,a);
}
ll modexp(ll x,ll y,ll p)
{
    ll res=1;x%=p;
    while(y>0)
    {   if(y%2==1){res=(res*x)%p;}
        y=y>>1;x=(x*x)%p;
    }return res;
}*/
ll n,k;
const int maxn=1e5+10;
vi g[maxn];
ll ans=1;
void dfs(ll v,ll p)
{
    ll curr=k-1;
    if(p!=-1){curr--;}
    rep(i,1,g[v].size())
    {
        ll nxt=g[v][i-1];
        if(nxt==p)
        {
            continue;
        }
        if(curr<=0)
        {
            ans=0;
            return;
        }
        ans=ans*curr;
        curr--;
        ans=ans%MOD;
        dfs(nxt,v);

    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    rep(i,1,n-1)
    {
        int x,y;cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    ans=k;
    dfs(1,-1);
    cout<<ans<<"\n";



    return 0;

    /*check for long long or int*/
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
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,k;
    cin >> n >> k;
    vector<int> a(n);
    vector<bool> dp(k+1,-1);
    rep(i,n) cin >> a.at(i);

    rep(i,a.at(0)) dp.at(i) = false;

    for(int i = a.at(0); i <= k; i++){
        int res = -1;
        for(auto go : a){
            if(i - go >= 0){
                if(res != -1 && dp.at(i - go) == res){
                    res = 1;
                    break;
                }
                else res = !dp.at(i - go);
            }
        }
        dp.at(i) = res;
    }

    dp.at(k)? cout << "First"  : cout << "Second" ;
    cout << endl;
    return 0;   

}


Measured memory_bytes: 256
while gets
	n,m = $_.split(" ").map(&:to_i)
	break if n==0 and m==0
	arr = (1..n).to_a
	x = m-1
	while arr.length > 1
		arr.delete_at x
		x = (x+m-1)%arr.length
	end
	p arr[0]
end 

Measured memory_bytes: 6136
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string s;
    cin >> s;
    cout << s.substr(0,4)+ " " + s.substr(4) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i;
  char s[110];

  scanf("%s", s);

  printf("%c", s[0]);
  for (i = 0; s[i] != '\0'; i++) continue;
  printf("%d", i - 2);
  printf("%c", s[i - 1]);
  return 0;
}

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

#define int long long
signed main() {
	string s;cin >> s;
	if(s.size() == 1 || s == "><") {cout << 1 <<endl;return 0;}

	vector<long long> vec;
	s += '0';
	long long dub = 1;
	for(int i = 1; i < s.size();i++) {
		if(s[i] == s[i-1]) dub++;
		else {
			vec.push_back(dub);dub = 1;
		}
	}
	//for(int i = 0; i< vec.size();i++) cout << vec[i] <<" " ;cout <<endl;
	int sum = 0;
	if(s[0] == '<') {
		if(vec.size() == 1) {cout << vec[0]*(vec[0]+1)/2;return 0;}
		for(int i = 0; i < vec.size();i++) {
				sum += (vec[i]-1)*vec[i]/2;
		}
		for(int i = 0; i < vec.size();i+=2) {
			if(i+1 >= vec.size()) {sum += vec[i]; break;}
			sum += max(vec[i], vec[i+1]);
		}
	}
	else {
		for(int i = 1; i < vec.size();i++) {
				sum += (vec[i]-1)*vec[i]/2;
		}
		for(int i = 1; i < vec.size();i+=2) {
			if(i+1 >= vec.size()) {sum += vec[i]; break;}
			sum += max(vec[i], vec[i+1]);
		}
		sum += vec[0]*(vec[0]+1)/2;
	}

	cout << sum << endl;

}


Measured memory_bytes: 3068
while True:
    a, b = input().split()
    if b == 'X':
        break

    if '_' in a:
        ans = a.split('_')
    else:
        ans = []
        j = 0
        for i in range(1, len(a)):
            if a[i].isupper():
                ans.append(a[j:i])
                j = i
        ans.append(a[j:])
        
    if b == 'D':
        ans = '_'.join(map(str.lower, ans))
    else:
        ans = ''.join(map(str.capitalize, ans))
        
        if b == 'L':
            ans = ans[0].lower() + ans[1:]

    print(ans)




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

int main(){
	#ifdef LOCAL_DEFINE
		freopen("../a.in","r",stdin);
		freopen("../a.out", "w",stdout);
	#endif
	
	float t,x;
	cin >> t >> x;
	cout << t/x << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <sstream>

using namespace std;

typedef string::const_iterator Cursor;
class ParseError{};

// <四則演算の式> ::= <乗算除算の式> (+ or -) <乗算除算の式> (+ or -) ...
// <乗算除算の式> ::= <括弧か数> (* or /) <括弧か数> (* or /) ...
// <括弧か数>     ::= '(' <四則演算の式> ')' or <数>
// <数>           ::= (0|1|2|3|4|5|6|7|8|9)+

int expression(Cursor&);
int term(Cursor&);
int factor(Cursor&);
int number(Cursor&);

// <四則演算の式> ::= <乗算除算の式> (+ or -) <乗算除算の式> (+ or -) ...
int expression(Cursor &c){
    int ret = term(c);
    while(*c == '+' or *c == '-'){
        if(*c == '+'){
            c++;
            ret += term(c);
        }else{
            c++;
            ret -= term(c);
        }
    }
    return ret;
}

// <乗算除算の式> ::= <括弧か数> (* or /) <括弧か数> (* or /) ...
int term(Cursor &c){
    int ret = factor(c);
    while(*c == '*' or *c == '/'){
        if(*c == '*'){
            c++;
            ret *= factor(c);
        }else{
            c++;
            ret /= factor(c);
        }
    }
    return ret;
}

// <括弧か数>     ::= '(' <四則演算の式> ')' or <数>
int factor(Cursor &c){
    if(*c == '('){
        c++;
        int ret = expression(c);
        // ')'
        c++;
        return ret;
    }else{
        return number(c);
    }
}

// <数>           ::= (0|1|2|3|4|5|6|7|8|9)+
int number(Cursor &c){
    stringstream ss;
    while(isdigit(*c)){
        ss << *c;
        c++;
    }
    int ret;
    ss >> ret;
    return ret;
}

int main(){
    int test_case;
    cin >> test_case;
    cin.ignore();
    for(int i=0;i<test_case;i++){
        string s;
        getline(cin,s);
        Cursor c = s.begin();
        cout << expression(c) << endl;
        if(*c != '='){
            cerr  << 'n' << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
 
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}
 
const ll INF = 1LL << 60;
//ll MOD = 1000000007;
//ll _MOD = 1000000009;
double EPS = 1e-10;
 
ll MOD = 998244353;
 
 
//拡張ユークリッドの互除法
//ax+by=gcd(a, b)の特殊解を計算
//返り値はgcd(a, b)
ll extgcd(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = (a >= 0) ? 1 : -1;
		y = 0;
		return abs(a);
	}
	else {
		ll res = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
		return res;
	}
}
 
 
//xとmは互いに素であるとする
//法mにおけるaの逆元とはab%m=1なる唯一のb<m
//逆元（拡張ユークリッド）
//ax+my=1なる(x, y)が求まればax%m=(1-my)%m=1よりb=x
ll mod_inverse(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}
 
 
//順列
//nPk mod MODを返す
//f[i]はi!（階乗）mod MODを指す
const ll N = 3 * 100000;
vector<ll> f(N + 1);
 
ll P(ll n, ll k) {
	if (n < k) return 0;
	return (f[n] * mod_inverse(f[n - k], MOD)) % MOD;
}
 
 
//組合せ
//nCk mod MODを返す
ll C(ll n, ll k) {
	if (n < 0) return 0;
	return (P(n, k) * mod_inverse(f[k], MOD)) % MOD;
}
 
int main() {
	ll n, a, b, k;
	vector<pair<ll, ll>> v;
	ll ans = 0;
 
	cin >> n >> a >> b >> k;
 
	f[0] = 1;
	FOR(i, 1, N + 1) {
		f[i] = (f[i - 1] * i) % MOD;
	}
 
	REP(i, n + 1) {
		ll red = a * i;
		if (k >= red && (k - red) % b == 0) {
			ll blue = (k - red) / b;
			if (blue < n + 1 && blue >= 0) {
				v.push_back(make_pair(i, blue));
			}
		}
	}
 
	REP(i, v.size()) {
		ans += (C(n, v[i].first) * C(n, v[i].second)) % MOD;
                ans %= MOD;
	}
 
	cout << ans << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

ll inv=500000004;

ll dp[5010][5010];//dp(n,x);
int main(){
    int n;cin >>n;
    string s;cin >>s;
    dp[1][1]=2;dp[1][0]=1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (j > 0)dp[i + 1][j - 1] += dp[i][j];
            dp[i + 1][j - 1] %= mod;
            dp[i + 1][j + 1] += dp[i][j] * 2 % mod;
            dp[i + 1][j + 1] %= mod;
        }
        dp[i+1][0]+=dp[i][0];
        dp[i+1][0]%=mod;
    }
   // for (int l = 0; l < 5; ++l) {
     //   for (int i = 0; i < 5; ++i) {
       //     cout <<dp[l][i]<<" ";
        //}
        //cout <<endl;
    //}
    for (int k = 0; k < s.size(); ++k) {
        dp[n][s.size()]*=inv;
        dp[n][s.size()]%=mod;
    }
    cout <<dp[n][s.size()]<< endl;
    return 0;
}

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

int n, m;
int board[1000];
int main()
{
    while(cin >> n >> m)
    {
        int temp;
        int where=0;
        int ans;
        if(!n && !m) break;
        for(int i=0;i<n;i++)
        {
            cin >> temp;
            board[i] = temp;
        }
        for(int i=0;i<m;i++)
        {
            cin >> temp;
            where += temp;
            where += board[where];
            if(where >= n-1)
            {
                ans = i+1;
                break;
            }
        }
        for(int i=ans;i<m;i++) cin >> temp;
        cout << ans << endl;
    }
}

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

using namespace std;

int t;
int x[100000];
vector<int> dx;

void solve() {
    dx.clear();
    int n, k;
    int ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> x[i];
        if(i > 0) {
            dx.push_back(x[i] - x[i - 1]);
            ans += x[i] - x[i - 1];
        }
    }

    sort(dx.rbegin(), dx.rend());

    for(int i = 0; i < min(k - 1, int(dx.size())); i++)
        ans -= dx[i];

    cout << ans << endl;
}

int main() {
    cin >> t;
    for(int i = 0; i < t; i++)
        solve();
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class Pair {
	int first;
	int second;

	Pair(int first, int second) {
		this.first = first;
		this.second = second;
	}
}

class TaskB {

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		int X = in.nextInt();
		int Y = in.nextInt();
		for (int i = 0; i <= X; i++) {
			if ((Y - 2 * i) % 4 == 0) {
				int temp = (Y - 2 * i) / 4;
				if (temp + i == X) {
					pw.println("Yes");
					return;
				}
			}
		}
		pw.println("No");
	}

	long __gcd(long a, long b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 32868
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)
#define ll long long
const ll mod=1e9+7;


bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

  vector<ll> a(n),b(n);
  vector<pair<ll,ll> > p(n);
  int f,s;
  r(i,n){
    cin>>f>>s;
    p[i]=make_pair(f,s);
  }

  sort(p.begin(),p.end());
  //r(i,n){
//    cout<<p[i].first<<" "<<p[i].second<<endl;
//  }

  ll sum=0;
  r(i,n){
    if(m>=p[i].second){
      m=m-p[i].second;
      //cout<<m<<endl;
      sum+=p[i].second*p[i].first;
    }
    else{
      sum+=m*p[i].first;
      break;
    }
  }

  cout<<sum<<endl;







return 0;

}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
struct edge{int from,to,cost;};
vector<edge> es;
int par[1000];
void init(int n){
	rep(i,n) par[i]=i;
}
int find(int x){
	if(x==par[x]) return x;
	return par[x]=find(par[x]);
}
bool same(int x,int y){
	return find(x)==find(y);
}
void unite(int x,int y){
	x=find(x),y=find(y);
	if(x!=y) par[x]=y;
}
bool comp(const edge &x,const edge &y){
	if(x.cost!=y.cost) return x.cost<y.cost;
	if(x.from!=y.from) return x.from<y.from;
	return x.to<y.to;
}
int main(){
	while(true){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		init(n);
		es.clear();
		rep(i,m){
			int a,b,c;
			cin>>a>>b>>c;
			es.pb(edge{a-1,b-1,c});
		}
		sort(all(es),comp);
		int cnt=0;
		for(auto e:es){
			if(same(e.from,e.to)) continue;
			unite(e.from,e.to);
			cnt++;
			if(cnt==n/2){
				cout<<e.cost<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1440
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	Map<String, Map<Integer, Integer>> shop = new HashMap<>();
    	for (int i = 1; i < N+1; i++) {
    		String city = sc.next();
    		int point = sc.nextInt();
    		if (shop.containsKey(city)) {
    			shop.get(city).put(point, i);
    		} else {
    			Map<Integer, Integer> order = new HashMap<>();
    			order.put(point, i);
    			shop.put(city, order);
    		}
    	}
    	StringBuilder sb = new StringBuilder();
    	List<String> key = new ArrayList<>(shop.keySet());
    	Collections.sort(key);
    	for (int i = 0; i < key.size(); i++) {
    		Map<Integer, Integer> cityShop = shop.get(key.get(i));
        	List<Integer> pointKey = new ArrayList<>(cityShop.keySet());
        	Collections.sort(pointKey, Collections.reverseOrder());
        	for (int point : pointKey) {
        		sb.append(cityShop.get(point)).append("\n");
        	}
    	}
    	System.out.println(sb);
    }
}

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

int main(){
	int h, w, n;
  	cin >> h >> w >> n;
  	vector<int> hs(h), ws(w);
  	set<P> s;
  	rep(i, n){
    	int r, c;
      	cin >> r >> c;
      	r--; c--;
      	hs[r]++;
      	ws[c]++;
      	s.emplace(r, c);
    }
  
  	int mh = 0, mw = 0;
  	rep(i, h) mh = max(mh, hs[i]);
   	rep(j, w) mw = max(mw, ws[j]);
  	vector<int> is, js;
  	rep(i, h) if(mh == hs[i]) is.push_back(i);
  	rep(j, w) if(mw == ws[j]) js.push_back(j);
  	
  	int ans = mh+mw;
  	for(int i : is){
    	for(int j : js){
        	if(s.count(P(i, j))) continue;
          	cout << ans << endl;
          	return 0;
        }
    }
  	ans--;
  	cout << ans << endl;
}

Measured memory_bytes: 23796
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>

#define IO std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);

#define MOD 1000000007
#define ull unsigned long long int
#define ll  long long int
#define MAX 100005

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;


int main() {

    //IO
    //freopen("entrada.txt", "r", stdin);

    string x;

    cin >> x;

    bool s=false;

    for(int i=0; i<x.size(); i++) {
        if(x[i]=='7') {
            s=true;
            break;
        }
    }
    !s? puts("No") : puts("Yes");



    return 0;
}


Measured memory_bytes: 3628
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <numeric>
#include <cmath>
#include <map>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int INF = (1<<12);

int main() {
  int X, N;
  int minV = INF;
  int ans = INF;
  cin >> X >> N;
  if(!N) {
    cout << X << endl;
    return 0; 
  }
  vector<bool> p(100 + 2, 0);
  rep(i,N){
    int n; 
    cin >> n;
    p[n] = true;
  }
  for(int i = 0; i <= 101; i++){
    if(!p[i] && (abs(X - i) < minV)){
      minV = abs(X - i);
      ans = i;
    }
  }

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

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll k, x;

    cin >> k >> x;

    (500 * k >= x) ? (cout << "Yes" << endl) : (cout << "No" << endl);
    
    return 0;
}

Measured memory_bytes: 256
ansList = list()

while True:
    s = input()
    if s == "-":
        for ans in ansList:
            print(ans)
        break
    
    hList = list()
    co = int(input())
    for _ in range(co):
        h = int(input())
        hList.append(h)
        
    for h in hList:
        s = s[h - len(s):] + s[:h]
    ansList.append(s)


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

using namespace std;

#define MAX 11
 
int main()
{
    int n, mat[MAX][MAX];
     
    while (cin >> n, n) {
        for (int i = 0; i < MAX; i++) {
            for (int j = 0; j < MAX; j++) {
                mat[i][j] = 0;
	    }
	}
         
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cin >> mat[i][j];
	    }
	}
         
        int sum = 0;
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                sum += mat[i][j];
                if (j == n) {
                    mat[i][j] = sum;
                    sum = 0;
                }
                 
            }
        }
         
        for (int j = 0; j <= n; j++) {
            for (int i = 0; i <= n; i++) {
                sum += mat[i][j];
                if (i == n) {
                    mat[i][j] = sum;
                    sum = 0;
                }
            }
        }
         
        int e = 0;
        for (int i = 0; i < n; i++) {
            e += mat[n][i];
            if (i == n-1) mat[n][n] = e;
        }
         
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
		printf("%5d", mat[i][j]);
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3192
s=input()
S=[]
count=0
for i in range(len(s)):
    S.append(s[i])
for x in range(26):
    if chr(x+ord("a")) in S:
        count=count+1
    else:
        print(chr(x+ord("a")))
        break
if count==26:
    print(None)
else:
    pass

Measured memory_bytes: 9732
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
int main(){
	fast;
	ll n;
	cin>>n;
	ll arr[n],cnt4=0,cnt2=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		if(arr[i]%4==0)
			cnt4++;
		if(arr[i]%2==0)
			cnt2++;
	}
	if(cnt4>=n/2||(cnt4>=(n-cnt2)))
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}



Measured memory_bytes: 4376
# -*- coding:utf-8 -*-
A_Bingo = []
for i in range(3):
    A_Bingo.append(list(map(int,input().split())))

card =[]
n = int(input())
for k in range(n):
    card.append(int(input()))

r_cnt =[0,0,0]
c_cnt =[0,0,0]
rc_result = [[0,0,0],[0,0,0],[0,0,0]]

for row in range(3):
    for column in range(3):
        if A_Bingo[row][column] in card:
            r_cnt[row] += 1
            c_cnt[column] += 1
            rc_result[row][column] = 1

if 3 in r_cnt:
    print("Yes")
elif 3 in c_cnt:
    print("Yes")
elif rc_result[0][0]*rc_result[1][1]*rc_result[2][2] == 1:
    print("Yes")
elif rc_result[0][2]*rc_result[1][1]*rc_result[2][0] == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9252
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int a = ir.nextInt();
		int b = ir.nextInt();
		out.println(Math.max(a + b, Math.max(a - b, a * b)));
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 21332
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

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

func scanInts(n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = nextInt()
	}
	return is
}

var ANS int

func main() {
	N := nextInt()
	M := nextInt()
	if N >= M {
		fmt.Println(0)
		return
	}
	NS := scanInts(M)
	sort.Ints(NS)
	DS := make([]int, M-1)
	for i := 0; i < M-1; i++ {
		DS[i] = NS[i+1] - NS[i]
	}
	sort.Ints(DS)
	ANS = NS[M-1] - NS[0]
	for i := 1; i < N; i++ {
		ANS -= DS[M-1-i]
	}
	fmt.Println(ANS)
}

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

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


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	double L;
	cin >> L;
	double hen = L/3.0;
	double ans = hen*hen*hen;
	cout << std::fixed << std::setprecision(15) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;

int A[MAX];
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n) cin >> A[i];

	int t = 0;
	int ans = 0;
	FOR(i, 1, n)
	{
		if (t == 0)
		{
			if (A[i] == A[i - 1]) continue;
			if (A[i] > A[i - 1])
			{
				t = 1;
				continue;
			}

			t = -1;
			continue;
		}

		if (t == -1 && A[i] > A[i - 1])
		{
			ans++;
			t = 0;
			continue;
		}

		if (t == 1 && A[i] < A[i - 1])
		{
			ans++;
			t = 0;
		}
	}

	ans++;
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <map>
#include <functional>
#include <algorithm>

#define SIZE 100000

using namespace std;

int main(void){
    int N;
    int cnt[SIZE] = {0};
    cin >> N;
    int a;
    for(int i=0; i<N; i++){
        cin >> a;
        if(a == 0){
            cnt[a] += 1;
            cnt[a+1] += 1;
        }else if(a == SIZE-1){
            cnt[a-1] += 1;
            cnt[a] += 1;
        }else {
            cnt[a-1] += 1;
            cnt[a] += 1;
            cnt[a+1] += 1;
        } 
    }
    int max_cnt = cnt[0];
    int max_idx = 0;
    for(int i=1; i<SIZE; i++){
        if(max_cnt < cnt[i]){
            max_cnt = cnt[i];
            max_idx = i;
        }
    }
    cout << max_cnt;
    return EXIT_SUCCESS;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int N, M;
vector<int> s, c;

bool ok(string str)
{
  if (str.size() != N)
    return false;
  for (int i = 0; i < M; i++) {
    if (str[s[i]] != (char)(c[i] + '0'))
      return false;
  }
  return true;
}

string solve()
{
  for (int i = 0; i <= 999; i++)
  {
    string tmp = to_string(i);
    if (ok(tmp))
      return tmp;
  }
  return "-1";
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M;
  s.resize(M), c.resize(M);
  for (int i = 0; i < M; i++)
  {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  cout << solve() << endl;
  return 0;
}


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

using namespace std;

int Sum10(int n);

int main()
{
    // 入力
    int h,w;
    cin >> h >> w;
    cout << (h-1)*(w-1) <<endl;
    return 0;
}

int Sum10(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    long count = 0;
 
    public static void main(String[] args) {
        new Main().run();
    }
    private void run() {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        StringBuilder builder = new StringBuilder();
        int[] A = new int[n];
        int[] B = new int[n];
        int K = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            A[i] = scanner.nextInt();
            K = Math.max(K, A[i]);
        }
        CountingSort(A, B, K);
        builder.append(B[0]);
        for (int i = 1; i < n; i++) {
            builder.append(' ').append(B[i]);
        }
        System.out.println(builder);
    }
 
    private void CountingSort(int[] a, int[] b, int k) {
        int[] C = new int[k + 1];
        for (int i = 0; i < a.length; i++)
            C[a[i]]++;
 
        for (int i = 1; i <= k; i++)
            C[i] += C[i - 1];
 
        for (int i = a.length - 1; i >= 0; i--) {
            C[a[i]]--;
            b[C[a[i]]] = a[i];
 
        }
    }
}


Measured memory_bytes: 515668