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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

  const double EPS = 1e-8;
  const double INF = 1e12;
  typedef complex<double> P;//????´???°????????¢?????????????????¨?§£???
  namespace std {
    bool operator < (const P& a, const P& b) {//x????????????
      return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
    bool sorty(const P& a, const P& b) {//y????????????
      return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
    }
  }
  double cross(const P& a, const P& b) {//??????
    return imag(conj(a)*b);
  }
  double dot(const P& a, const P& b) {//??????
    return real(conj(a)*b);
  }

  struct L : public vector<P> {//??´???
    L(){};
    L(const P &a, const P &b) {
      push_back(a); push_back(b);
    }
  };

  typedef vector<P> G;

  struct C {//???
    P p; double r;
    C(){};
    C(const P &p, double r) : p(p), r(r) { }
  };
  int ccw(P a, P b, P c) {//3????????????????????§????????§??????????????????
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
  }
  bool is_convex(const G &g){
    if(g.size() == 3) return true;
    rep(i,g.size()){
      if(ccw(g[i],g[(i+1) % g.size()],g[(i+2) % g.size()]) != 1 && ccw(g[i],g[(i+1) % g.size()],g[(i+2) % g.size()]) != -2){
        return false;
      }
    }
    return true;
  }

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  double x,y;
  cin >> n;
  G g;
  rep(i,n){
    cin >> x >> y;
    g.push_back({x,y});
  }
  cout << is_convex(g) << endl;
  return 0;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define ll   long long
int main(){
	ll n;
	cin>>n;
	vector<ll>v;
	for(ll i=1;i<=n;i++){
		if(i%3LL!=0 && i%5LL!=0){
			v.push_back(i);
		}
	}
	cout<<accumulate(v.begin(),v.end(),0LL);
}

Measured memory_bytes: 11656
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  string s,t;
  cin>>s>>t;
  vector<ll> p[27];
  
  ll N=s.size();
  ll M=t.size();
  rep(i,N){
    ll q=s[i]-'a';
    p[q].push_back(i);
  }
  rep(i,N){
    ll q=s[i]-'a';
    p[q].push_back(i+N);
  }
  
  bool ok=true;
  ll position=0;
  ll ans=0;
  rep(i,M){
    ll q=t[i]-'a';
    if(p[q].empty()) {
      ok=false;
      break;
    }
    position=*lower_bound(all(p[q]),position)+1;
    if(position>=N){
      position-=N;
      ans+=N;
    }
  }
  ans+=position;
  if(!ok) cout<<-1<<endl;
  else cout<<ans<<endl;
}
      

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

int main(){
 int w,h,x,y,r;
 cin >> w >> h >> x >> y >> r;

 if( x-r>=0 && y+r<=h && x+r<=w && y-r>=0 ){
  cout << "Yes" << endl;
 }else{
  cout << "No" << endl;
 }

 return 0;
}


Measured memory_bytes: 3104
/*---> 01 November 2019 <--- > 00:44:03 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//boot#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<n;i++){
		if(i+1<n && s[i]==s[i+1] && s[i]=='R')
			ans++;
		if(i-1>=0 && s[i]==s[i-1] && s[i]=='L')
			ans++;
	}
	cout<<min(n-1,ans+k*2)<<"\n";
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

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

    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    rep(i, n) v[i]--;


    CumulativeSum cs(n);
    rep(i, n) cs.set(i, v[i]);
    cs.build();

    vector<ll> u(n);
    rep(i, n) u[i] = cs.getSum(i) % k;

    map<int, int> m;
    m[0] = 1;
    ll ans = 0;
    rep(i, n) {
        if (i == k - 1)m[0]--;
        if (i >= k) m[u[i - k]]--;

        ll t = u[i]; //(u[i] % k);
        ll now = m[t];

        ans += now;

        m[u[i]]++;

    }

//    rep(i, n) if (v[i] % k == 0) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 18776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;

int main(){
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<ll> sum(n+1);
    for(int i = 0; i < n; i++) sum[i+1] = sum[i] + a[i];
    unordered_map<ll, ll> mp;
    for(int i = 0; i <= n; i++){
        mp[sum[i]%m]++;
    }
    ll ans = 0;
    for(auto p : mp){
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8156
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B==C+D){cout<<"Balanced"<<endl;}
  else if(A+B<C+D){cout<<"Right"<<endl;}
  else{cout<<"Left"<<endl;}
  return 0;  
}


Measured memory_bytes: 3608
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <fstream>
#define rep(i,a,b) for (long long i = a; i < b; i++)
using namespace std;
long long n;

// long long bf(long long p, long long pp , long long sum, vector <long long>& fec){
    
//     if(dp[p]!=-1){
//         return dp[p];
//     }
//     if (pp==n-1){
//         //cout << sum  << endl;
//         return sum;
//     } else if(pp>=n){
//         return 1000000000;
//     }
//     //cout << abs(fec[pp]-fec[p]) << "  " << p << "   " << pp << endl;
//     return dp[p]= min(bf(p+1, p, sum + abs(fec[pp]-fec[p]), fec) , bf(p+2, p, sum + abs(fec[pp]-fec[p]), fec));
// }

int main(){
    
    cin >> n;
    int dp[n][3];
    //dp.assign(n+k+k,10000000000000);
    memset(dp,-1, sizeof (dp));
    int fector[n][3];
    memset(fector,-1, sizeof (fector));
    rep(i,0,n){
        rep(j,0,3){
            cin >> fector[i][j];
        }
    }
    dp[0][0] = fector[0][0];
    dp[0][1] = fector[0][1];
    dp[0][2] = fector[0][2];
    rep(i,0,n-1){
        dp[i+1][0] = fector[i+1][0] + max(dp[i][1], dp[i][2]);
        dp[i+1][1] = fector[i+1][1] + max(dp[i][0], dp[i][2]);
        dp[i+1][2] = fector[i+1][2] + max(dp[i][1], dp[i][0]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";
    //cout << bf(0, 0, 0, fector) << endl;

}

Measured memory_bytes: 2560
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

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

	//何度繰り返しても偶数ならa-b. 奇数ならb-aになる
	if (k % 2 == 0) cout << a - b << endl;
	else            cout << b - a << endl;

}

Measured memory_bytes: 3588
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll ans=0;
    ll cnt=0;
    string s;
    cin>>s;
    set<char> S;
    S.insert('A');
    S.insert('T');
    S.insert('G');
    S.insert('C');
    for(auto &I:s){
        if(S.count(I)){cnt++; ans=max(ans,cnt);}
        else{cnt=0;}
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
def fab(x):
    if x == 1:
        return x

    ans = 0
    for i in range(1 , x + 1):
        if -(-x // i) < i:
            return ans
        if x % i == 0:
            ans = len(str(int(x / i)))

def main():
    n = int(input())
    print(fab(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 39408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

namespace std {
	#define u(x, a, b) for(ll x = a; x < b; x++)
	#define d(x, a, b) for(ll x = a; x > b; x--)
}

typedef long long ll;
typedef long double ld;

#define MAXI 100010
#define MOD 1000000007

int main(){
	
	ll l, r, d;
	cin >> l >> r >> d;
	
	ll cnt = 0;
	u(one, l, r+1){
		if(one%d==0){cnt++;}
	}
	
	cout << cnt;
	
}


Measured memory_bytes: 3612
from collections import Counter

M = 998244353
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if a[0] == 0 and c[0] == 1:
    r = i = 1
    while c[i]:
        r = r * pow(c[i - 1], c[i], M) % M
        n -= c[i]
        i += 1
print(r if n == 1 else 0)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 1000010
#define INF int(2e9 + 9)
#define BIG_INF ll(1e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

//#pragma GCC optimize("Ofast")


ll n, a[SIZE];

bool used[SIZE];

int cnt[SIZE];

ll A, B, C, K  ;

ll pref[SIZE];


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);


    cin >> A >> B >> C >> K;


    ll ans = min(A, K);

    K -= A + B;
    if(K <= 0)
    {
        cout << ans;
        return 0;
    }

    K = min(K, C);

    ans -= K;

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
    int m, f, r;
    while (1){
        scanf(" %d %d %d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1){
            break;
        }

        if (m == -1 || f == -1){
            printf("F\n");
        }
        else if (m + f >= 80){
            printf("A\n");
        }
        else if (m + f >= 65 && m + f < 80){
            printf("B\n");
        }
        else if (m + f >= 50 && m + f < 65){
            printf("C\n");
        }
        else if (m + f >= 30 && m + f < 50){
            if (r >= 50){
                printf("C\n");
            }
            else {
                printf("D\n");
            }
        }
        else if (m + f < 30){
            printf("F\n");
        }
    }

    return 0;
}
        

Measured memory_bytes: 580
#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)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
ll A[112345];
ll ans[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%lld", A + i);
	
	REP(i, N) ans[0] += A[i] * (i & 1 ? -1 : 1);
	REP(i, N - 1) ans[i + 1] = 2 * A[i] - ans[i];
	
	REP(i, N) printf("%lld%c", ans[i], i == N - 1 ? '\n' : ' ');
	
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int p[N];
main() {
    int n = readInt();
    for (int i = 1; i <= n; i++) {
        p[i] = readInt();
    }
    int ans = 0;
    for (int i = 2; i < n; i++) {
        if ((p[i] < p[i + 1] && p[i + 1] > p[i - 1] && p[i] > p[i - 1]) || (p[i] < p[i - 1] && p[i - 1] > p[i + 1] && p[i] > p[i + 1])) {
            ++ans;
        }
    }
    cout << ans;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJ0046().doIt();
	}
	
	class AOJ0046{
		void doIt(){
			ArrayList<Double> list = new ArrayList<Double>();
			while(in.hasNext())list.add(in.nextDouble());
			Collections.sort(list);
			System.out.println(Math.abs(list.get(0)-list.get(list.size()-1)));
		}
	}
	
}

Measured memory_bytes: 18676
# -*- coding: utf-8 -*-

N = int(input())
aN = list(map(str, input().split()))

for i in range(N):
    tmp = aN[i]
    j = i - 1
    while j >= 0 and int(aN[j]) > int(tmp):
        aN[j+1] = aN[j]
        j -= 1
    aN[j+1] = tmp

    print(' '.join(aN))



Measured memory_bytes: 5600
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    # test = []
    X, Y = 0, 0
    for j in range(n):
        if (i >> j) & 1 == 1:
            X += v[j]
            Y += c[j]
            # test.append([v[j], c[j]])
    if ans < X - Y:
        ans = X - Y
    # print(test)

print(ans)

Measured memory_bytes: 42684
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int, int> pint;

signed main()
{
	string s; cin >> s;
	int ans = (s[0] - '0') + 9 * (SZ(s) - 1);
	bool all9 = 1;
	for (int i = 1; i<SZ(s); i++) {
		if (s[i] != '9') all9 = 0;
	}
	if (!all9) ans--;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

bool besarDulu(const int &a, const int &b)
{
    return a > b;
}

bool tupleSort(tuple<int, int, int> &a, tuple<int, int, int> &b)
{
    return get<2>(a) > get<2>(b);
}

using ll = long long int;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c;
    cin >> a >> b >> c;
    //cout << setprecision(10) << pow(a, 0.5) + pow(b, 0.5) << ' ' << pow(c, 0.5) << '\n';
    //cout << setprecision(10) << sqrt(a) + sqrt(b) << ' ' << sqrt(c) << '\n';
    //cout << sqrt(a) + sqrt(b) << ' ' << sqrt(c) << endl;
    //cout << a + b + sqrt(a * b) << ' ' << c << endl;
    //a + b + 2 * sqrt(a * b) < c ? cout << "Yes" : cout << "No";
    //2 * sqrt(a * b) < c - a - b
    (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) ? cout << "Yes" : cout << "No";
    return 0;
}
//3774506968

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

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e5+5;
const ll   mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

int test = 1, n, ans = 0, p[N], sz[N];
vpll X, Y;
vector <pair<ll,pll>> edges;

void make(ll n){
	for(int i = 1; i <= n; i++){
		p[i] = i;
		sz[i] = 1;
	}
}

int find(ll x){
	return (p[x] == x)? x: p[x] = find(p[x]);
}

void merge(ll x, ll y){
	ll a = find(x);
	ll b = find(y);
	if(a != b){
		if(sz[a] >= sz[b]) swap(a,b);
		p[a] = b;
		sz[b] += sz[a];
	}
}

void solve(){
	cin>>n;
	for(int i = 1; i <= n; i++){
		int x, y; cin>>x>>y;
		X.pb({x,i});
		Y.pb({y,i});
	}
	sort(all(X)); sort(all(Y));
	for(int i = 1; i < n; i++){
		edges.pb({X[i].f-X[i-1].f,{X[i].s,X[i-1].s}});
		edges.pb({Y[i].f-Y[i-1].f,{Y[i].s,Y[i-1].s}});
	}
	sort(all(edges));
	make(n);
	for(auto it : edges){
		int x = it.s.f, y = it.s.s;
		if(find(x) != find(y)){
			ans += it.f;
			merge(x,y);
		}
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
}

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=333,mod=1000000007;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,f[maxn*2][maxn][maxn],cnt1,cnt2,ans;
bool vis[maxn*2],ind[maxn*2];
int main(){
	n=read();
	FOR(i,1,n){
		int x=read(),y=read();
		if(~x && ~y) vis[x]=vis[y]=true;
		else if(~x) ind[x]=true,cnt2++;
		else if(~y) ind[y]=true,cnt2++;
		else cnt1++;
	}
	f[2*n+1][0][0]=1;
	ROF(i,2*n,1) FOR(j,0,cnt1+cnt2) FOR(k,0,cnt2){
		if(vis[i]) f[i][j][k]=f[i+1][j][k];
		else if(ind[i]){
			if(k) f[i][j][k]=(f[i][j][k]+f[i+1][j][k-1])%mod;
			if(j!=cnt1+cnt2) f[i][j][k]=(f[i][j][k]+f[i+1][j+1][k])%mod;
		}
		else{
			if(j) f[i][j][k]=(f[i][j][k]+f[i+1][j-1][k])%mod;
			if(j!=cnt1+cnt2) f[i][j][k]=(f[i][j][k]+f[i+1][j+1][k])%mod;
			if(k!=cnt2) f[i][j][k]=(f[i][j][k]+1ll*(k+1)*f[i+1][j][k+1])%mod;
		}
	}
	ans=f[1][0][0];
	FOR(i,1,cnt1) ans=1ll*ans*i%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 261888
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
      //入力値を取り込む
      Scanner sc = new Scanner(System.in);
      //0を消去して1だけ残し、その長さを出力すれば1の個数になる
      //replaceよりもreplaceAllの方が早い、なぜ？
      int i = sc.next().replaceAll("0","").length();
      //出力する
      System.out.println(i);
    }
}



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

struct Cube {
  string label[6];
  void swap(int a, int b, int c, int d) {
    string temp = label[a];
    label[a] = label[b];
    label[b] = label[c];
    label[c] = label[d];
    label[d] = temp;
  }
  void roll(char dir) {
    switch (dir) {
    case 'N': swap(0, 1, 5, 4); break;
    case 'E': swap(0, 3, 5, 2); break;
    case 'R': swap(1, 2, 4, 3); break;
    }
  }
  bool is_same(Cube& c) {
    for (auto& dir : "RRRRNRRRRERRRRNRRRRERRRRNRRRR") {
      if (sequence_equal(c)) return true;
      roll(dir);
    }
    return false;
  }
  bool sequence_equal(Cube& c) {
    for (int i = 0; i < 6; i++) {
      if (label[i] != c.label[i]) return false;
    }
    return true;
  }
};

int main() {
  int n;
  while (cin >> n, n) {
    vector<Cube> c(n);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 6; j++) {
        cin >> c[i].label[j];
      }
    }
    vector<int> m(n, 1);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (!m[i]) continue;
      for (int j = i + 1; j < n; j++) {
        if (m[j] && c[i].is_same(c[j])) {
          m[j] = 0;
          cnt++;
        }
      }
    }
    cout << cnt << "\n";
  }
}


Measured memory_bytes: 3172
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    n,d = map(int, input().split())
    ans = 0
    for i in range(n):
        x,y = map(int, input().split())
        z = sqrt(x**2 + y**2)
        #print(z)
        if z <= d:
            ans += 1

    print(ans) 

if __name__ == '__main__':
	main()


Measured memory_bytes: 9628
#include <iostream>

using namespace std;

int H, W;
char board[52][52] = {{'.'}};

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

  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> board[i][j];
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int a,b;cin>>a>>b;
    if(a>8||b>8)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	int A,B,C,D,N;
	scanf("%d",&N);
	A=N/1000;
	B=(N-A*1000)/100;
	C=(N-A*1000-B*100)/10;
	D=N-A*1000-B*100-C*10;
	if(A+B+C+D==7) printf("%d+%d+%d+%d=7\n",A,B,C,D);
	else if(A-B+C+D==7) printf("%d-%d+%d+%d=7\n",A,B,C,D);
	else if(A+B-C+D==7) printf("%d+%d-%d+%d=7\n",A,B,C,D);
	else if(A+B+C-D==7) printf("%d+%d+%d-%d=7\n",A,B,C,D);
	else if(A+B-C-D==7) printf("%d+%d-%d-%d=7\n",A,B,C,D);
	else if(A-B-C+D==7) printf("%d-%d-%d+%d=7\n",A,B,C,D);
	else if(A-B+C-D==7) printf("%d-%d+%d-%d=7\n",A,B,C,D);
	else if(A-B-C-D==7) printf("%d-%d-%d-%d=7\n",A,B,C,D);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAX_V 2500
#define MAX_A 5000
#define INF LLONG_MAX

using namespace std;

int grau[MAX_V];	
long long int d[MAX_V];		
int p[MAX_V];	
int visitado[MAX_V];	

typedef struct{
	int v;	
	long long int w;	
} TAdj;
TAdj adj[MAX_V][MAX_A];

void aresta(int a, int b, long long int w){
	adj[a][ grau[a] ].v = b;
	adj[a][ grau[a] ].w = w;
	grau[a]++;
}

void initGrafo(int vertices){
	memset(grau, 0, sizeof(int)*vertices);
	memset(p,-1, sizeof(int)*vertices);
}

void dfs(int v){
    visitado[v] = 1;
    for(int i = 0; i < grau[v]; i++){
        if (!visitado[adj[v][i].v])
            dfs(adj[v][i].v);
    }
}

bool interfere(int v, int n){
    memset(visitado, 0, sizeof(int)*n);
    dfs(v);
    if (visitado[0] || visitado[n-1])
        return true;
    return false;
}

bool bellmanFord(int inicial, int n){
    memset(p, -1, sizeof(p));
    for(int i=0; i<n; i++)
        d[i] = INF;
    d[inicial] = 0;
    for(int i=0; i<n; i++){ // todos vertices
        for(int j=0; j<n; j++){ /* todas */
            if (d[j] == INF)
                continue;
            for(int k=0; k<grau[j]; k++){/* arestas */
                if(d[j] + adj[j][k].w < d[adj[j][k].v])
                {
                    d[adj[j][k].v] = d[j] + adj[j][k].w;
                    p[adj[j][k].v] = j;
                }
            }
        }
    }

    for(int i=0; i<n; i++){
        if (d[i] == INF)
            continue;
        for(int j=0; j<grau[i]; j++){
            if(d[adj[i][j].v] > d[i] + adj[i][j].w && interfere(adj[i][j].v, n)) 
                return false;
        }
    }
    return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n, m, a, b, i;
    long long int c, pv, resp = 0;
	cin >> n >> m >> pv;
    initGrafo(n);
    for(i = 0; i < m; i++){
        cin >> a >> b >> c;
        aresta(a-1,b-1,pv-c);
    }
    if (bellmanFord(0, n))
    {
        cout << max(resp, -d[n-1]) << endl;
    } 
    else
    {
        cout << "-1" << endl;
    }
}


Measured memory_bytes: 13768
#include <stdio.h>

static 
void printfig(int h, int w, int y, int x)
{
  if ((x+y)%2 == 0)
    printf("#");
  else
    printf(".");
}

int main(int argc, char *argv[])
{
  int w[300], h[300];
  int i, j;

  for (i = 0; i < 300; i++) {
    scanf("%d %d", &h[i], &w[i]);
    if (w[i] == 0 && h[i] == 0)
      break;
  }

  for (j = 0; j < i; j++) {
    int k, n;
    for (k = 0; k < h[j]; k++) {
      for (n = 0; n < w[j]; n++) {
	printfig(h[j], w[j], k, n);
      }
      
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
program abc167a
      implicit none
      character(10)::s,t
      integer::i

         read *, s
         read *, t

         i=len_trim(s)
         if (s(1:i)==t(1:i)) then
            print *, 'Yes'
         else
            print *, 'No'
         end if

   end program abc167a

Measured memory_bytes: 2856
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll mod=1e9+7;

int main()
{
    ll n,k;
    cin >> n >> k;
    ll m=(n-2)*(n-1)/2;
    if(k>m){
        cout << -1 << endl;
        return 0;
    }
    ll diff=m-k;
    vector<vector<ll>> g(n,vector<ll>(n)),used(n,vector<ll>(n));
    rep(i,n){
        if(i==0) continue;
        g[i][0]=g[0][i]=1;
    }
    rep(i,n){
        bool fin=false;
        rep(j,n){
            if(diff==0){
                fin=true;
                break;
            }
            
            if(i==j) continue;
            if(i==0 || j==0) continue;
            if(g[i][j]!=1 && g[j][i]!=1){
                g[i][j]=g[j][i]=1;
                diff--;
            }
        }
        if(fin) break;
    }
    vector<pll> ans;
    rep(i,n){
        rep(j,n){
            if(g[i][j]==1 && g[j][i]==1 && used[j][i]==0 && used[i][j]==0){
                ans.push_back(make_pair(i+1,j+1));
                used[i][j]=used[j][i]=1;
            }
        }
    }
    ll v=ans.size();
    cout << v << endl;
    rep(i,v){
        cout << ans[i].fi << " " << ans[i].se << endl;
    }
    return 0;
} 

Measured memory_bytes: 640
mod union_find {

///素集合データ構造
pub struct UnionFind {
    v: Vec<usize>,
    h: Vec<usize>,
}

impl UnionFind {
    ///要素数nの素集合データ構造を構築する。
    pub fn new(n: usize) -> UnionFind {
        let mut v = Vec::new();
        for i in 0..n {
            v.push(i);
        }
        let h = vec![1; n];
        UnionFind { v: v, h: h }
    }

    ///親を探索する。
    pub fn find(&mut self, a: usize) -> usize {
        if a == self.v[a] {
            return a;
        }

        let buf = self.v[a];
        let parent = self.find(buf);
        self.v[a] = parent;
        parent
    }

    ///親が同じか判定する。
    pub fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }

    ///結合する。
    pub fn union(&mut self, a: usize, b: usize) {
        let parent_a = self.find(a);
        let parent_b = self.find(b);
        if self.h[parent_a] < self.h[parent_b] {
            self.v[parent_a] = parent_b;
        } else {
            self.v[parent_b] = parent_a;

            if self.h[parent_a] == self.h[parent_b] {
                self.h[parent_a] += 1;
            }
        }
    }
}
}
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

use std::collections::HashMap;
use union_find::*;

fn main() {
    input! {
        n:usize,m:usize,
    }
    let mut uf = UnionFind::new(n);
    for _ in 0..m {
        input! {
            a:Usize1,
            b:Usize1,
        }
        uf.union(a, b);
    }
    let mut map = HashMap::new();
    for i in 0..n {
        let q = uf.find(i);
        *map.entry(q).or_insert(0) += 1;
    }
    let mut ans = 0;
    for (i, x) in map {
        ans = std::cmp::max(ans, x);
    }
    println!("{}", ans);
}


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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a[3];
	for(ll i=0;i<3;i++)cin>>a[i];
	sort(a,a+3);
	if((a[0]==a[1] or a[1]==a[2]) and a[0]!=a[2])cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long int 
using namespace std;


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(int i=0;i<100;i++)
	{
		c-=b;
		if(c<=0)
		{
			cout<<"Yes";
			break;
		}
		a-=d;
		if(a<=0)
		{
			cout<<"No";
			break;
		}
	}
	
	return 0; 
}

Measured memory_bytes: 3632
sx,sy,tx,ty=map(int,input().split())
xdiff=tx-sx
ydiff=ty-sy
move=[]
move.append("D")
move+="R"*(xdiff+1)
move+="U"*(ydiff+1)
move+="L"#ここでt到着
move+="U"
move+="L"*(xdiff+1)
move+="D"*(ydiff+1)
move+="R"#ここでs到着
move+="R"*xdiff
move+="U"*ydiff#ここでt到着
move+="L"*xdiff
move+="D"*ydiff#ここでs到着
print(*move,sep="")

Measured memory_bytes: 9348
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

fn main() {
    input! {
        n: usize, k: u64,
        a: [[u64; n]; n]
    }

    let init = vec![1u64;n];
    let a_k = matrix_pow(&a, k);
    let mut ret = 0u64;
    for i in 0..n {
        let row = &a_k[i];
        ret += dot(row, &init);
        ret %= M;
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn dot(a: &[u64], b: &[u64]) -> u64 {
    let mut c = 0;
    for i in 0..a.len() {
        c += a[i] * b[i];
        c %= M;
    }
    c
}

#[allow(dead_code)]
fn matrix_mul(a: &[Vec<u64>], b: &[Vec<u64>]) -> Vec<Vec<u64>> {
    let mut c = vec![vec![0; b[0].len()]; a.len()];
    for i in 0..a.len() {
        for k in 0..b.len() {
            for j in 0..b[0].len() {
                c[i][j] = c[i][j] + a[i][k] * b[k][j] % M;
                c[i][j] %= M;
            }
        }
    }
    c
}
#[allow(dead_code)]
fn matrix_pow(a_: &[Vec<u64>], mut n: u64) -> Vec<Vec<u64>> {
    let mut a: Vec<Vec<u64>> = a_.to_vec();
    let mut b = vec![vec![0; a.len()]; a.len()];
    for i in 0..a.len() {
        b[i][i] = 1;
    }
    while n > 0 {
        if n & 1 == 1 {
            b = matrix_mul(&b, &a);
        }
        a = matrix_mul(&a, &a);
        n >>= 1;
    }
    b
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int H, W; cin >> H >> W;
   V<string> A(H);
   map<char,int> cnt;
   for (int i = 0; i < H; i++) {
      cin >> A[i];
      for (int j = 0; j < W; j++) {
         cnt[A[i][j]]++;
      }
   }

   if (cnt['#'] != H+W-1) {
      cout << "Impossible" << endl;
      return 0;
   }

   for(int i = 0, j = 0; i != H-1 || j != W-1;) {
      if (i != H-1 && A[i+1][j]) {
         i++; continue;
      }
      if (j != W-1 && A[i][j+1]) {
         j++; continue;
      }
      cout << "Impossible" << endl;
      return 0;
   }
   cout << "Possible" << endl;

   return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 1e5+10;

ll N, M;
ll A[MAX];

ll solve() {
    vi s(M), t(M+1);
    REP (i, N-1) s[A[i+1]] += (A[i+1] - A[i] + M) % M - 1;
    REP (i, N-1) {
        t[A[i]+1] += 1;
        if (A[i+1] < A[i]) t[0] += 1;
        t[A[i+1]] -= 1;
    }
    REP (m, M-1) t[m+1] += t[m];

    // f0
    ll f = 0;
    REP (i, N-1) {
        if (A[i+1] > A[i]) f += A[i+1] - A[i];
        else f += A[i+1] + 1;
    }

    ll ret = f;
    // f1, f2, ...
    REP (x, M-1) {
        f += s[x] - t[x];
        CHMIN(ret, f);
    }
    return ret;
}

int main() {
    cin >> N >> M;
    REP (i, N) {
        cin >> A[i];
        A[i]--;
    }
    cout << solve() << endl;
}

Measured memory_bytes: 2560
#!/usr/bin/env python
# coding: utf-8

# In[1]:


N = int(input())
A = list(map(int, input().split()))


# In[3]:


ans = 1
p = 0
m = 0
pre = A[0]
for a in A[1:]:
    if a > pre:
        p = 1
    elif a < pre:
        m = 1
    if p == 1 and m == 1:
        ans += 1
        p = 0
        m = 0
    pre = a
print(ans)


# In[ ]:






Measured memory_bytes: 20040
import java.util.Scanner;


public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		final long time = sc.nextLong();
		
		System.out.println(time / (60 * 60) + ":" + (time / 60 % 60) + ":" + (time % 60));
		
	}
	
}

Measured memory_bytes: 17228
eval'H,W='+gets.split*?,
B=$<.map(&:chop)*?#+?#*W+=1
*Q=i=0
d=B.count ?.
p loop{(d-=1
i+=Q.size)if-1==i-=1
break d if H*W==2+k=Q.shift
[-W,-1,W,1].map{|l|B[l+=k][B[l]=?#]||Q<<l}}rescue p~0

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

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

  int n; cin >> n;
  vector<int> aup(n);
  vector<int> adown(n);
  rep(i, n) cin >> aup[i];
  rep(i, n) cin >> adown[i];

  vector<int> upCumul(n);
  vector<int> downCumul(n);
  upCumul[0] = aup[0];
  downCumul[0] = adown[0];
  for(int i = 1; i < n; ++i) {
    upCumul[i] = upCumul[i-1]+aup[i];
    downCumul[i] = downCumul[i-1]+adown[i];
  }

  int ans = -1e9;
  rep(i, n) {
    int down = (i == 0 ? downCumul[n-1] : downCumul[n-1]-downCumul[i-1]);
    ans = max(ans, upCumul[i]+down);
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

int main(){

    string s;
    cin >> s;
    int N = s.length();
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            string tmp = s.substr(0,i) + s.substr(j+1, N-1-j);
            if(tmp == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#!python3

from time import perf_counter
tick = perf_counter() + 1.92

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from random import randrange
from bisect import bisect

def resolve():
    G = 26
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(G)]
    S = [[next(it) for i in range(G)] for i in range(D)]
    L = [[-1] for i in range(G)]
    T = [0] * D

    def update(di, qi):

        score = 0
        t0 = T[di]
        score += S[di][qi]-S[di][t0]

        a1 = li = L[t0][:]
        ii = li.index(di)
        la = D if len(li)-1 == ii else li[ii+1]
        score -= C[t0] * (di-li[ii-1])*(la-di)
        li.pop(ii)

        a2 = li = L[qi][:]
        ii = bisect(li, di)
        li.insert(ii, di)
        la = D if len(li)-1 == ii else li[ii+1]
        score += C[qi] * (di-li[ii-1])*(la-di)

        return score, (a1, a2)

    def calc(i, j):
        score = S[i][j]
        for k in range(j):
            score -= C[k] * (k - L[k][-1])
        for k in range(j+1, G):
            score -= C[k] * (k - L[k][-1])
        return score

    for di in range(D):
        i, score = 0, calc(di, 0)
        for qi in range(1, G):
            x = calc(di, qi)
            if x > score:
                i, score = qi, x
        T[di] = i
        L[i].append(di)

    while perf_counter() < tick:
        di, qi = randrange(0, D), randrange(0, G)
        diff, swap = update(di, qi)
        if diff > 0:
            score += diff
            q0, T[di] = T[di], qi
            L[q0], L[qi] = swap

    print(*(i+1 for i in T), sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 89660
using System;
using System.Linq;

class ITP1
{
    static void Main()
    {
        while (true)
        {
            var str = Console.ReadLine();
            int a = int.Parse(str.Split(' ')[0]);
            int b = int.Parse(str.Split(' ')[1]);
            int count=0;
            if (a == 0 && b == 0) break;
            else
            {
                for (int i = 1; i <= a; i++)
                {
                    for (int j = i + 1; j <= a; j++)
                    {
                        for (int k = j + 1; k <= a; k++)
                        {
                            if (i + j + k == b)
                                count++;
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	long ans=0,i,N,j=1;
	string temp;
	vector<string> s;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>temp;
		sort(temp.begin(),temp.end());
		s.push_back(temp);
	}
	sort(s.begin(),s.end());
	for(i=0;i<N-1;i++){
		if(s.at(i)==s.at(i+1)){
			j++;
		}else{
			ans+=j*(j-1)/2;
			j=1;
		}
	}
	ans+=j*(j-1)/2;
	cout<<ans;
	return 0;
}



Measured memory_bytes: 5748
package main

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

func main() {
	n := getInt()

	as := make([]int, n)
	for i := range as {
		as[i] = getInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(as)))

	candidate := make([]int, 0, n/2)
	for i := 0; i < n-1 && len(candidate) < 2; i++ {
		if as[i] == as[i+1] {
			candidate = append(candidate, as[i])
			i++
		}
	}

	if len(candidate) < 2 {
		fmt.Println(0)
	} else {
		fmt.Println(candidate[len(candidate)-1] * candidate[len(candidate)-2])
	}
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 3072