akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;
const int MAX_N = 200010;

int main(int argc, const char * argv[]) {
  int N, T;
  cin >> N >> T;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  int minv = A[0];
  int maxp = 0;
  vector<int> phis(N, 0);
  for (int i = 1; i < N; i++) {
    phis[i] = max(0, A[i] - minv);
    minv = min(minv, A[i]);
    maxp = max(maxp, phis[i]);
  }
  
  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (phis[i] == maxp) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n, k;
    cin >> n >> k;
    vector<int>arr(n);
    rep(i, n)cin >> arr[i];
    sort(all(arr));
    int sum = 0;
    rep(i, k) {
        sum += arr[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define REP1(i,m,n) for(int i=m;i<=(int)(n);i++)
#define SORT(v) sort(v.begin(), v.end());
#define REVERSE(v)  reverse(v.begin(), v;.end());
typedef long long lint;
using namespace std;

int main() {
  string S; cin>>S;
  string j="AC";
  if(S.at(0)!='A') j="WA";
  int cnt1=0;
  int cnt2=0;
  REP1(i,2,S.size()-2) {
    if(S.at(i)=='C') cnt1++;
  }
  if(cnt1!=1) j="WA";
  REP(i,S.size()) {
    if(S.at(i)>='A' && S.at(i)<='Z') cnt2++;
  }
  if(cnt2!=2) j="WA";
  cout<<j<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for(;;){
			int H =  sc.nextInt();
		    int W =  sc.nextInt();
		    if(H==0 && W==0) break;
		    for(int i=0; i<H; i++){
		    	for(int j=0; j<W; j++){
		    		if(i!=0 && i!=H-1 && j!=0 && j!=W-1){
		    			System.out.print(".");
		    		}else{
		    			System.out.print("#");
		    		}
		    	}
		    	System.out.println();
		    }
	    	System.out.println();
		}
	}
}

Measured memory_bytes: 32592
#include <cassert>
#include <vector>

template <class T = long long>
class lower_convex_monotone
{
    struct line
    {
        T slop, icpt;
        T eval(const T x) const { return slop * x + icpt; }
    };

    std::vector<line> lines;
    typename std::vector<line>::iterator lp, rp;

    void realloc()
    {
        std::vector<line> cpy((rp - lp) * 2);
        cpy.swap(lines);
        rp = copy(lp, rp, lines.begin());
        lp = lines.begin();
    }

public:
    lower_convex_monotone() : lines(2), lp(lines.begin()), rp(lp) {}

    bool empty() const { return lp == rp; }

    void clear() { rp = lp = lines.begin(); }

    void add(const T a, const T b)
    {
        while(rp - lp > 1)
        {
            auto [a1, b1] = *(rp - 1);
            auto [a2, b2] = *(rp - 2);
            if((b - b1) * (a2 - a) > (b - b2) * (a1 - a)) break;
            --rp;
        }
        if(rp == lp) rp = lp = lines.begin();
        if(rp == lines.end()) realloc();
        *rp++ = {a, b};
    }

    T get(const T x)
    {
        assert(!empty());
        while(rp - lp > 1 && lp->eval(x) > (lp + 1)->eval(x)) ++lp;
        return lp->eval(x);
    }
}; // class lower_convex_monotone

#include <cstdio>

main()
{
    int n; long long c;
    scanf("%d%lld",&n,&c);

    lower_convex_monotone cht;

    for(int i=1; i<n; i++)
    {
        long long h;
        scanf("%lld",&h);
        if(i==1)
        {
            cht.add(-2*h,h*h+c);
        }
        else
        {
            cht.add(-2*h,cht.get(h)+h*h*2+c);
        }
    }
    long long hlst;
    scanf("%lld",&hlst);
    printf("%lld\n",cht.get(hlst)+hlst*hlst);
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  auto cs = [&](auto V) {
    int n = V.size() + 1;
    vector<long> R(n);
    for (int i = 1; i < n; i++) {
      R.at(i) = R.at(i - 1) + V.at(i - 1);
    }
    return R;
  };
  auto R = cs(A);
  reverse(R.begin(), R.end());
  long ans = 1;
  for (int i = 1; i < N + 1; i++) {
    if (R.at(i) * 2 >= R.at(i - 1) - R.at(i)) {
      ans++;
      continue;
    }
    break;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4776
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a, b; cin >> a >> b;
	cout << a * a - b << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main  {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        }
        if(a > b){
            if(a < c){
                System.out.printf("%d %d %d\n", b, a, c);
            }else if(b < c){
                System.out.printf("%d %d %d\n", b, c, a);
            }else{
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
    }
}


Measured memory_bytes: 26328
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
using namespace std;
template<typename V,typename Weight>
class Dijekstra {
private:
	struct edge {
		Weight dist;V node;V prev;
		bool operator<(edge const& a) const {
			return dist < a.dist;
		}
		bool operator>(edge const& a) const {
			return dist > a.dist;
		}
	};
	vector<V> trace;
	vector<vector<pair<V,Weight>>> E;
	V sz;
public:
	Weight inf = numeric_limits<Weight>::max();
	vector<Weight> D;
	Dijekstra(V v) :
		E(v),sz(v),D(v,inf),trace(v,numeric_limits<V>::max()) {}

	void addEdgeDirected(V from,V to,Weight dis){
		E[from].push_back(make_pair(to,dis));
	}
	void addEdgeUndirected(V from,V to,Weight dis){
		E[from].push_back(make_pair(to,dis));
		E[to].push_back(make_pair(from,dis));
	}

	V size() {return sz;}
	Weight & operator[] (V n) { if (0 <= n && n < sz) return D[n];} 

	void dijekstra(V start){
		priority_queue<pair<Weight,V>,vector<pair<Weight,V>>,greater<pair<Weight,V>>> que;
		D[start] = 0;
		trace[start] = 1;
		//trace[start] = start;
		que.push(make_pair(0,start));
		Weight d;V v;
		while(!que.empty()){
			pair<Weight,V> cur = que.top();que.pop();
			d = cur.first;v = cur.second;
			if (D[v] < d) continue; //既により最適が見つかっている
			for(V i = 0;i < E[v].size();i++){
				V next = E[v][i].first;
				Weight newCost = d + E[v][i].second;
				if (D[next] > newCost) {
					D[next] = newCost;
					trace[next] = v;
					que.push(make_pair(newCost,next));
				}
				else if (D[next] == newCost) {
					trace[next] = min(trace[next],v);
				}
			}
		}
	}

	vector<V> show_trace(V start,V goal){ // startからgoalの最短距離上のノード
		vector<V> ret;
		for (V node = goal;node != start;node = trace[node]) ret.push_back(node);
		ret.push_back(start);
		return ret; // 配列の先頭がgoal,末尾がstart
	}
};


int main(void){
	long V,E,R;
	long s,t,d;
	cin >> V >> E >> R;
	Dijekstra<long,long> dij(V);

	REP(i,E){
		cin >> s >> t >> d;
		dij.addEdgeDirected(s,t,d);
	}

	dij.dijekstra(R);
	REP(i,V) {
		if (dij[i] == dij.inf) cout << "INF" << endl;
		else cout << dij[i] << endl;
	}
		
	return 0;
}





Measured memory_bytes: 20088
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    Vi a(n+2),minus(n+1,0);
    a[0]=0;
    a[n+1]=0;
    repi(i,1,n+1) cin >> a[i];
    ll sum=0;
    repi(i,1,n+1){
        sum+=abs(a[i]-a[i-1]);
        if(a[i]>a[i-1]&&a[i]>a[i+1]){
            minus[i]=2*(a[i]-max(a[i-1],a[i+1]));
        }
        if(a[i]<a[i-1]&&a[i]<a[i+1]){
            minus[i]=2*(min(a[i-1],a[i+1])-a[i]);
        }
    }
    sum+=abs(a[n]);
    rp(i,n){
        print(sum-minus[i+1]);
    }


    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007
//////////////////////////////////////////

int main(){
  ini(n,a,b);
  out(min(a,b) , max(0 , a + b - n) );
}

Measured memory_bytes: 256
n, m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
  exit(0)

w = n - 2
h = m - 2
if n == 1:
  print(h)
  exit(0)
if m == 1:
  print(w)
  exit(0)
  
print(w*h)


Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i) cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	int pa = 0, pc = 0; long long ret = 0;
	for (int i = 0; i < n; i++) {
		while (pa != n && a[pa] < b[i]) ++pa;
		while (pc != n && c[pc] <= b[i]) ++pc;
		ret += 1ll * pa * (n - pc);
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long int
#define REP(i,n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)v.size()
using namespace std;
#define endl "\n"
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll MOD=1000000007;
const ll nxm=1e7+5;
void solve()
{
ll x;
cin>>x;
 for(ll i=1;;i++)
 {
   if((x*i)%360==0)
   {
  
     cout<<i;
  	return;     
   }
 }
cout<<360/x;

}
int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long f[20][20][1<<18];
int l[1<<18],r[1<<18],a[19];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	l[1]=r[1]=1;
	for(int i=2;i<(1<<n);i++){
		if(i&1)l[i]=l[i>>1]+r[i>>1],r[i]=r[i>>1];
		else l[i]=l[i>>1],r[i]=l[i>>1]+r[i>>1];
	}
	memset(f,63,sizeof(f));
	for(int i=1;i<n;i++)
		for(int j=1;j<(1<<n);j++)f[i][i+1][j]=0;
	for(int L=2;L<n;L++)
		for(int i=1;i<=n-L;i++){
			int j=i+L;
			for(int k=i+1;k<j;k++)
				for(int p=1;p<(1<<(n-L));p++)f[i][j][p]=min(f[i][j][p],f[i][k][p<<1]+f[k][j][(p<<1)|1]+1ll*(l[p]+r[p])*a[k]);
		}
	printf("%lld\n",f[1][n][1]+a[1]+a[n]);
	return 0;
}

Measured memory_bytes: 821504
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

long long MOD = 1000000007;
long long fac[200001];
long long finv[200001];
long long inv[200001];

int BIT_SIZE = 64;
long long power(long long m, long long n) {
	long long ans = 1;
	long long tmp = m;
	for (int i = 0; i < BIT_SIZE; i++) {
		//cout << ans << endl;
		if (((n >> i) & 1) == 1) {
			ans = ans * tmp % MOD;
		}
		tmp = (tmp * tmp) % MOD;
	}
	return ans;
}


void comb_init() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200000; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*
long long combination(long long M, long long N) {
	long long ans = 1;
	for (long long i = 0; i < N; i++) {
		cout << ans << endl;
		ans = (ans * (M - i)) % MOD;
	}
	for (long long i = 0; i < N; i++) {
		cout << ans << endl;
		ans = (ans / (N - i)) % MOD;
	}
	//cout << ans << endl;
	return ans;
}
*/

int main() {
	comb_init();
	int N;
	int M;
	long long K;
	cin >> N >> M >> K;

	long long ans = 0;
	for (long long dist = 1; dist < N; dist++) {
		long long tmp = N - dist;
		tmp = (((tmp * M) % MOD) * M) % MOD;
		ans = (ans + (((tmp * comb(N * M - 2, K - 2)) % MOD) * dist % MOD)) % MOD;
		//cout << tmp << endl;
		//cout << comb(N * M - 2, K - 2) << endl;
	}
	//cout << ans << endl;
	for (long long dist = 1; dist < M; dist++) {
		long long tmp = M - dist;
		tmp = (((tmp * N) % MOD) * N) % MOD;
		ans = (ans + (((tmp * comb(N * M - 2, K - 2)) % MOD) * dist % MOD)) % MOD;
	}
	cout << ans << endl;
	//cout << comb(20, 2) << endl;
	//cout << N * M - 2 << " " << K - 2 << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;

ll powl(ll n, ll m){
  ll cn=1;
  while(m>=1){
    cn*=n;
    m--;}
  return cn;
}
    

ll nikou(ll n, ll m) {
	ll qqq = 1;
	for (ll i = 1; i <= m; i++) 
		qqq = qqq * (n - i + 1) / i;
		return qqq;
	}

int main() {
ll n,p;
  cin>>n>>p;
  ll sumv=0;
  rep(i, n){
  ll p;
    cin>>p;
    ll q=p%2;
  sumv+=q;}
  
  ll cnt=powl(2, n-sumv);
  
  for(ll i=2;i<=n;i+=2){
    cnt+=powl(2, n-sumv)*nikou(sumv, i);}

  if(p==0){
    cout<<cnt<<endl;}
  else{
    cout<<powl(2, n)-cnt<<endl;}
  
  
}

Measured memory_bytes: 256
_ = int(input())
a = sorted(list(map(int, input().split())))
num0, num1, val = a[-1], 0, float('inf')

for i in a[:-1]:
    val0 = abs(i-num0/2)
    if val0 < val:
        num1 = i
        val = val0
print(num0, num1)


Measured memory_bytes: 20024
// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    long double a, b, c;
    cin >> a >> b >> c;
    cout << (a+b+2*sqrtl(a*b)<c?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>
#include <math.h>
#include <vector>
#include <bitset>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
#define PI 3.14159265
#define INF	9999999999
#define pb push_back
#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
#define FR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
typedef long long int ll; 
typedef vector<ll> vi;
typedef vector<vi> vii;



int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	cout<<"ABC"<<n<<endl;
	
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

ll gcd( ll a, ll b ){
    if( a<b ) swap(a,b);
    ll c;
    while( a%b ){
        c = b;
        b = a%b;
        a = c;
    }
    return b;
}

ll comb( ll n, ll r ){
    if( n<r ) swap(n,r);
    ll up = 1;
    ll lw = 1;
    ll di;
    Rep(i,r){
        up *= (n-i);
        lw *= (r-i);
        di = gcd(up,lw);
        up /= di;
        lw /= di;
    }
    return up/lw;
}

int main() {

    int N,A,B;
    Scd3(N,A,B);

    vl v(N);
    Rep(i,N) Scll(v[i]);

    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    double ans = 0.0;
    Rep(i,A) ans += v[i];
    ans /= A;

    ll mul = 0;
    bool uni = true;
    Rep(i,A) uni = uni && v[i] == v[0];
    ll cnt = 0;
    ll low = 0;
    Rep(i,N){
        if( v[i] == v[A-1] ){
            cnt++;
            if( i < A ) low++;
        }
    }

    mul += comb(cnt,low);
    if( uni ){
        Repe(i,B-A+1,1){
            if( v[A+i-1] != v[A-1] ) break;
            mul += comb(cnt,low+i);
        }
    }

    printf ("%.9lf\n", ans );
    printf ("%lld\n", mul );

    return 0;
}



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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 2e3 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

map<ll, ll> mp;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll s = 0;
	ll n, v;
	cin >> n;
	ll ans = 0;
	mp[0] ++;
	for(int i = 0;i < n;i++){
		cin >> v;
		s += v;
		ans += mp[-s];
		mp[-s] ++;
	}
	cout << ans;
	return 0;
}


/*
                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



Measured memory_bytes: 12800
#include <iostream>
using namespace std;
int main() {
    int x,y,t;
    cin >> x>>y;
    if((y-2*x) %2==0 && y>=2*x){
        t = (y-2*x)/2;
        if(x-t >=0) cout <<"Yes";
        else cout <<"No";
    }
    else cout <<"No";
    return 0;
}


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

int main(){
  int H, W; cin >> H >> W;
  int k=H+W-1;
  int s=H*W;
  char v;
  int count=0;
  for(int i=1;i<=s;i++){
    cin >> v;
    if(v=='#'){
      count++;
    }
  }
  if(count==k){
    cout << "Possible" << endl;
  }
  else cout << "Impossible" << endl;
}
    

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    ll x, n;
    cin>>n;
    x=7;
    for(int i=1; i<n+10; i++)
    {
        if(x%n==0)
        {
            cout<<i<<nl;
            return 0;
        }
        x=x%n;
        x=x*10+7;
    }
    cout<<-1<<nl;
    return 0;
}



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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))

using namespace std;

int n,m,q;
vector<int> a,b,c,d;
int recFunc(int dep, vector<int> v, int mx, int mxScore){
  if (dep<n){
    for (int t=mx; t<=m; t++){
      int score=0;
      vector<int> u; u=v;
      u.push_back(t);
      score = recFunc(dep+1, u, t, mxScore);
      mxScore = MAX(mxScore, score);
    }
    return mxScore;
  } else {
    int score = 0;
//    for (int i=0; i<n; i++) cout << v[i] << " ";
//    cout << endl;
    for (int i=0; i<q; i++){
      if (v[b[i]-1]-v[a[i]-1] == c[i]) score += d[i];
    }
    return MAX(mxScore, score);
  }
}

int main(void){  
  cin >> n >> m >> q;
  for (int i=0; i<q; i++){
    int ta, tb, tc, td;
    cin >> ta >> tb >> tc >> td;
    a.push_back(ta); b.push_back(tb);
    c.push_back(tc); d.push_back(td);
  }
  cout << recFunc(0, vector<int>(), 1, 0) << endl;
  return 0;
}

Measured memory_bytes: 3568
using System;

class swapping
{
    public static void Main()
    {
       


        for (int i = 0; i < 3000; i++)
        {
            String[] s = Console.ReadLine().Split();

            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);

            if (x < y)
            {
                Console.WriteLine("{0} {1}", x, y);
            } else if (x > y)
            {
                Console.WriteLine("{0} {1}", y, x);
            } else if (x == 0 && y == 0)
            {
                break;
            }
            else if (x==y)
            {
                Console.WriteLine("{0} {1}", x, y);
            }
                  
               
        }
    }
}


Measured memory_bytes: 9252
module M = Map.Make (struct type t = int let compare = compare end)

let () =
    let main () =
        let n = Scanf.sscanf (read_line ()) "%d" (fun n -> n) in
        let xy = Array.init n (fun _ -> Scanf.sscanf (read_line ()) "%d %d" (fun x y -> x, y)) in
        let xmap = Array.fold_left (fun map (x, y) ->
            M.add x (y :: (try M.find x map with _ -> [])) map) M.empty xy in
        let ymap = Array.fold_left (fun map (x, y) ->
            M.add y (x :: (try M.find y map with _ -> [])) map) M.empty xy in
        let cx = Array.make 100001 true in
        let cy = Array.make 100001 true in
        let rec dfs_x px list ax ay depth =
            cx.(px) <- false;
            List.fold_left (fun ((ax, ay) as acc) py ->
                if cy.(py) then dfs_y py (M.find py ymap) ax ay (depth + 1) else acc) (ax + 1, ay) list
        and dfs_y py list ax ay depth =
            cy.(py) <- false;
            List.fold_left (fun ((ax, ay) as acc) px ->
                if cx.(px) then dfs_x px (M.find px xmap) ax ay (depth + 1) else acc) (ax, ay + 1) list
        in
        let acc = M.fold (fun x list acc ->
            if cx.(x) then let sx, sy = dfs_x x list 0 0 0 in acc + sx * sy else acc) xmap 0 in
        let acc = M.fold (fun y list acc ->
            if cy.(y) then let sx, sy = dfs_y y list 0 0 0 in acc + sx * sy else acc) ymap acc in
        Printf.printf "%d\n" (acc - n)
    in
    main ()

Measured memory_bytes: 31360
#include <bits/stdc++.h>
using namespace std;
typedef                 long long ll;
typedef                 unsigned long long ull;
#define mkp             make_pair
#define pii             pair<int,int>
#define piii            pair<pii,int>
#define vi              vector<int>
#define PI              acos(-1)
#define all(v)          v.begin(),v.end()
#define mmset(a,val)    memset(a,val,sizeof(a))
#define sc(a)           scanf("%d",&a)
#define sc2(a,b)        scanf("%d%d",&a,&b)
#define sc3(a,b,c)      scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)    scanf("%d%d%d%d",&a,&b,&c,&d)
#define sc5(a,b,c,d,e)  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define scll(a)         scanf("%I64d",&a)
#define scll2(a,b)      scanf("%I64d%I64d",&a,&b)
#define scll3(a,b,c)    scanf("%lld%lld%lld",&a,&b,&c)
#define scll4(a,b,c,d)  scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)
#define Pr(a)           printf("%d\n",a)
#define Prll(a)         printf("%lld\n",a)
#define pb(a)           push_back(a)
#define SZ              size()
#define tcs(t)          for(int tc=1;tc<=t;tc++)
#define INF             0x3f3f3f3f
#define hash_val        347
#define popcount        __builtin_popcount
#define MOD             1000000007
#define MX              2005
//int fx[]={-1,-1,0,1,1,1,0,-1};
//int fy[]={0,1,1, 1,0,-1,-1,-1};
int Set(int n,int pos){return n=n|(1<<pos);}
int reset(int n,int pos){return n=n& ~ (1<<pos);}
bool check(int n,int pos){return (bool) (n& (1<<pos));}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);};
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);};
int mp[12][12];
int cost[12][12];
void floyd_warshall()
{
   /* for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
        {
            if(cost[i][j]==0&&i!=j)
            {
                cost[i][j]=INF;
            }

        }
    }*/

    for(int k=0;k<10;k++)
    {
        for(int i=0;i<10;i++)
        {
            for(int j=0;j<10;j++)
            {
                if(cost[i][j]>cost[i][k]+cost[k][j]){
                cost[i][j]= cost[i][k]+cost[k][j] ;

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

        for(int i=0;i<10;i++)
        {
            for(int j=0;j<10;j++)
                sc(cost[i][j]);
        }
        floyd_warshall();
        int a;
        ll ans=0;
        for(int i=0;i<row;i++)
        {
            for(int j=0;j<col;j++)
            {
                sc(a);
                if(a==-1||a==1){
                        continue;
                }
                else{

                    ans+=cost[a][1];
                }
            }
        }
        Prll(ans);
}


Measured memory_bytes: 256
using System;
using System.Linq;
 
public class Program
{
    public static void Main()
    {
        var NK = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var N = NK[0];
        var K = NK[1];
        if (N % K == 0) {
            Console.WriteLine(0);
        } else {
            Console.WriteLine(1);
        }
    }
}

Measured memory_bytes: 13268
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(void){
  ll N;
  cin >> N;
  vector<ll> L(N), R(N);
  rep(i, N){
    cin >> L[i] >> R[i];
  }
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  reverse(L.begin(), L.end());
  ll ans = 0;
  ll sum = 0;
  rep(i, N){
    ans = max(ans, sum + 2 * L[i]);
    ans = max(ans, sum - 2 * R[i]);
    ans = max(ans, sum + 2 * (L[i] - R[i]));
    sum += 2 * (L[i] - R[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
 
int n, a[9]{3, 9, 2, 4, 8, 10, 6, 12};
int main()
{
	int i;
	cin >> n;
	if (n == 3) {cout << "2 5 63"; return 0;}
	if (n % 2) n--, cout << "30000 ";
	for (i = 0; i < n; i++) printf("%d ", a[i % 8] + i / 8 * 12);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int count = 0;
  for(int i = 0; i<= 100; i++) {
    if (i >= a && i <= b && i >= c && i <= d) {
      //cout << a << "," << b << "," << c << "," << d << endl;
      //cout << i << endl;
      count++;
    }
  }
  if (count > 0) {
    count--;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
from collections import deque

def getStartPos(cmap,H,W):
    for y in range(H):
        for x in range(W):
            if cmap[y][x]=="S":
                return x,y

mv=((1,0),(-1,0),(0,1),(0,-1))
H,W,N=map(int,raw_input().split())
cmap=[list(raw_input()) for i in range(H)]
sx,sy=getStartPos(cmap,H,W)
Q=deque()
Q.append((sx,sy,0,0,1))
visited=set()
visited.add((sx,sy))
while Q:
    x,y,t,n,p=Q.popleft()
    if n==N:
        print t
        break
    for dx,dy in mv:
        mx=x+dx
        my=y+dy
        if mx<0 or mx>=W or my<0 or my>=H:
            continue
        if cmap[my][mx]=="X":
            continue
        if (mx,my) not in visited:
            visited.add((mx,my))
            Q.append((mx,my,t+1,n,p))
        if cmap[my][mx]==str(p):
            visited=set()
            visited.add((mx,my))
            Q=deque()
            Q.append((mx,my,t+1,n+1,p+1))
            break

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

const int d2o[] = {0, 1, 2, 3, 5, 7, 8, 9};

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

    vector<int> ans;
    while (n > 0) {
      ans.push_back(d2o[n%8]);
      n /= 8;
    }

    for (int i = ans.size()-1; i >= 0; --i)
      cout << ans[i];
    cout << endl;
  }
  return 0;
}

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

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    int i = 0;
    while (0 < A && 0 < C) {
        if (i % 2 == 0) C -= B;
        else A -= D;
        i++;
    }

    if (A <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string.h>
#include <algorithm>
#define N 1000
#define INF 0x3f3f3f

using namespace std;

const int MOD = 1e9+7, maxn = 2 * 1e6+5;
int t, n, ce, fir[maxn], m[maxn], l[maxn], in[maxn], lis[maxn];
long long ans;

struct graph {
	int next; 
 	int y;
} e[maxn];

void add(int x, int y) {
	e[++ce].y=y; 
	e[ce].next=fir[x]; 
	fir[x]=ce; 
}

int max(int x, int y) {	return x>y ? x:y;}
int min(int x, int y) {	return x<y ? x:y;}
void swap(int &x, int &y) { int temp = x; x = y; y = temp;}

void work() {
	queue<int> q;
	for (int i = 0; i < n; i++)
		if (in[i] == 0) q.push(i);
	while (!q.empty()) {
		int temp = q.front();
		//cout<<' '<<temp<<endl;
		int count = 0;
		for (int p = fir[temp]; p; p = e[p].next) {
			int y = e[p].y;
			lis[count ++] = m[y];
		}
		sort(lis, lis + count);
		for (int i = 0; i < count; i++)
			ans += (long long)lis[i] * (count - i - 1);
	//	cout<<ans<<endl;
		if (l[temp] != -1) {
			m[l[temp]] += m[temp];
			in[l[temp]] --;
			if (in[l[temp]] == 0) {
				q.push(l[temp]);
			}
		}
		q.pop();
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	while (scanf("%d", &n) != EOF) {
		memset(fir, 0, sizeof(fir));
		memset(in, 0, sizeof(in));
		ce = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &m[i], &l[i]);
			if (l[i] != -1) {
				in[l[i]]++;
				add(l[i], i);	
			}
		}
		ans = 0;
		work();
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 47500
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ans=0,sum=0;
	int f[100010];
	f[n+1]=1999999999;
	for(int i=1;i<=n;i++)
	cin>>f[i];
	for(int i=1;i<=n;i++)
	if(f[i]<f[i+1]) ans=max(ans,sum),sum=0;
	else sum++;
	ans=max(ans,sum);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
n, y = map(int, input().split(" "))

for i in range(n + 1):
	for j in range(n - i + 1):
		k = n - i - j
		if (i*10000 + j*5000 + k*1000) == y:
			print(i, j, k)
			exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
from sys import stdin

input = stdin.readline
import math
import heapq


def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    left = 1
    right = max(a)

    def ok(l):
        s = sum([(i-1) // l for i in a])
        return s <= k
    while left < right:
        mid = (left + right) // 2
        if ok(mid):
            right = mid
        else:
            left = mid + 1
    print(left)


if __name__ == '__main__':
    solve()


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

#define INF64 1LL << 60;
#define INF32 1 << 29;

using namespace std;

void execute()
{
	string S;
	int len, half;
	int base;
	int even_num;
	int ans;

	cin >> S;
	len = (int)S.size();
	ans = half = len / 2;
	even_num = len % 2 == 0 ? 1 : 0;
	base = S[half];

	for (int i = 0; i <= half + even_num; i++)
	{
		if (base != S[half - i - even_num] || base != S[half + i])
			break;
		ans++;
	}

	cout << ans << endl;
	return;
}

int main()
{
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n,a,b,m;

	cin >>n>>a>>b;
	if (a+b>=n){
		cout << min(a,n) << endl;
	}
	else{
		m = n/(a+b)*a+min(a,n%(a+b));
		cout << m << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);
  
int N;cin>>N;
  int a=N%10;
  int b=(N-a)/10;
  
  if(a==9||b==9){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
(function Main() {
var input = require("fs").readFileSync("/dev/stdin", "utf8");
	input = input.split("\n");
  var n=parseInt(input[0],10);
  for(var i = 1; i <= n; i++){
    var tmp=input[i].split(" ");
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
    var c = parseInt(tmp[2], 10);
    if(a*a+b*b==c*c || a*a+c*c==b*b || a*a==b*b+c*c) console.log("YES");
    else console.log("NO");
  }
})();



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

int main() {

    int n;
    cin >> n;
    int k[n];
    for(int i=0; i<n; ++i){
        cin >> k[i];
    }

    int l[n]={};
    for(int i=0; i<n; ++i){
        l[k[i]-1] = i+1;
    }
    for(int i=0; i<n; ++i){
        cout << l[i] << " ";
    }

    cout << endl;

}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 100005;
int vis[2][N];
vector <int> v[N];

int main() {
    int n, T, A;
    scanf("%d %d %d", &n, &T, &A);
    for (int i = 1; i < n; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        v[x].pb(y);
        v[y].pb(x);
    }
    queue <pair <int, pair <int, int> > > q;
    q.push({1, {A, 1}});
    vis[1][A] = 1;
    while (!q.empty()) {
        int t = q.front().fi, x = q.front().se.fi, d = q.front().se.se;
        q.pop();
        for (auto y : v[x]) {
            if (!vis[t][y]) {
                vis[t][y] = d + 1;
                q.push({t, {y, d + 1}});
            }
        }
    }
    int res = 0, mx = 0;
    q.push({0, {T, 1}});
    vis[0][T] = 1;
    while (!q.empty()) {
        int t = q.front().fi, x = q.front().se.fi, d = q.front().se.se;
        q.pop();
        if (d >= vis[1][x]) {
            res = max(res, vis[1][x]);
            continue;
        }
        if ((int)v[x].size() == 1) {
            mx = max(mx, vis[1][x]);
        }
        for (auto y : v[x]) {
            if (!vis[t][y]) {
                vis[t][y] = d + 1;
                q.push({t, {y, d + 1}});
            }
        }
    }
    printf("%d", max(res - 1, mx - 2));
    return 0;
}


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

// using ll = long long;
#define int long long
using P = pair<int, int>;
#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
bool CompareBySecond(P a, P b) {
  if(a.second != b.second) {
    return a.second > b.second;
  } else {
    return a.first > b.first;
  }
}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n_of_orig_cards = in();
  int n_of_commands = in();
  vector<int> cards(n_of_orig_cards);
  for(int i = 0; i < n_of_orig_cards; ++i) {
    cin >> cards[i];
  }
  vector<P> commands(n_of_commands);
  int total_n_of_command_card = 0;
  for(int i = 0; i < n_of_commands; ++i) {
    int n_of_cards = in();
    int card = in();
    total_n_of_command_card += n_of_cards;
    commands[i] = P(n_of_cards, card);
  }
  if(total_n_of_command_card <= n_of_orig_cards) {
    cards.reserve(n_of_orig_cards+total_n_of_command_card);
    for(int i = 0; i < n_of_commands; ++i) {
      int n_of_cards = commands[i].first;
      int card = commands[i].second;
      for(int j = 0; j < n_of_cards; ++j) {
        cards.PB(card);
      }
    }
    SORTR(cards);
    int ans = 0;
    for(int i = 0; i < n_of_orig_cards; ++i) {
      ans += cards[i];
    }
    cout << ans << endl;
    return 0;
  }
  cards.reserve(2 * n_of_orig_cards);
  sort(ALL(commands), CompareBySecond); // reversed
  for(int i = 0; i < n_of_commands; ++i) {
    int n_of_cards = commands[i].first;
    int card = commands[i].second;
    for(int j = 0; j < n_of_cards; ++j) {
      cards.PB(card);
      if(distance(ALL(cards)) >= 2*n_of_orig_cards) break;
    }
    if(distance(ALL(cards)) >= 2*n_of_orig_cards) break;
  }
  SORTR(cards);
  int ans = 0;
  for(int i = 0; i < n_of_orig_cards; ++i) {
    ans += cards[i];
  }
  cout << ans << endl;
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3328
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        List<Integer> list = new ArrayList<>();
        boolean c = false;
        for (int i = 1; i <= n; i++) {
            int p = scanner.nextInt();
            if (p == i) {
                if (c) {
                    list.set(0, list.get(0) + 1);
                } else {
                    list.add(0, 1);
                }
                c = true;
            } else {
                c = false;
            }
        }
        int ans = 0;
        for (int i : list) {
            ans += (i + 1) / 2;
        }
        System.out.println(ans);
    }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 a,b; cin >> a >> b;
    cout << max<i32>({a+b, a-b, a*b}) << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3648