akhauriyash/Code-Regression huggingface dataset:
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

solve :: [Int64] -> [Int64] -> Int64
solve [x0,x1] [y0] = min (x0 + x1) y0
solve (x0:x1:xs) (y0:ys) = let !c = min (x0 + x1) y0
                               !d = if c <= x0
                                    then x1
                                    else x1 + x0 - c
                           in c + solve (d:xs) ys

main = do
  n <- readLn :: IO Int
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  ys <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ solve (map fromIntegral xs) (map fromIntegral ys)


Measured memory_bytes: 5884
#include<iostream>
using namespace std;
int main(){
  int A,B,C,out1,out2,out3;
  cin>>A>>B>>C;
  out1=abs(A-B)+abs(A-C);
  out2=abs(A-B)+abs(B-C);
  out3=abs(A-C)+abs(B-C);
  if(out1<=out2&&out1<=out3)cout<<out1<<endl;
  else if(out2<=out1&&out2<=out3)cout<<out2<<endl;
  else cout<<out3<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] dataline = Console.ReadLine().Split(' ');
            int n = int.Parse(dataline[0]);
            int t = int.Parse(dataline[1]);

            dataline = Console.ReadLine().Split(' ');
            int[] timedata = new int[n];
            for (int i = 0; i < n; i++)
            {
                timedata[i] = int.Parse(dataline[i]);
            }

            int ans = 0;
            for (int i = 0; i < timedata.Length-1; i++)
            {
                if (timedata[i+1]-timedata[i] < t)
                {
                    ans += timedata[i + 1] - timedata[i];
                }
                else
                {
                    ans += t;
                }
            }
            ans += t;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 26464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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 (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

const string YES = "Yes";
const string NO = "No";

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> BA(N);
    for(int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        BA[i] = make_pair(b, a);
    }
    sort(BA.begin(), BA.end());
    long long cur = 0;
    bool ans = true;
    for (auto ba : BA) {
        cur += ba.second;
        if (cur > ba.first) {
            ans = false;
            break;
        }
    }
    if (ans) cout << YES << endl;
    else cout << NO << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

ll x;
ll odds[40],evens[40];
ll nums[40];
int digs[40];

void cals(){
	nums[0] = 1;
	nums[1] = 2;
	evens[0]=1;
	odds[0]=0;
	evens[1]=1;
	odds[1]=2;
	for(int i=2;i<35;i++){
		nums[i] = nums[i-1]*2;
		if(i%2==0){
			evens[i] = evens[i-1]+nums[i];
			odds[i] = odds[i-1];
		}else{
			evens[i] = evens[i-1];
			odds[i] = odds[i-1]+nums[i];
		}
		//printf("(%d,%lld,%lld)",i,evens[i],odds[i]);
	}
	//printf("\n");
}

int main()
{
	scanf("%lld",&x);
	cals();
	if(x==0){
		puts("0");
		return 0;
	}
	while(x!=0){
		int n=0;
		if(x>0){
			for(int i=0;i<34;i+=2){
				if(nums[i] - odds[i] <= x && x <= evens[i]){
					n = i;
					break;
				}
			}
			x -= nums[n];
		}else{
			for(int i=1;i<34;i+=2){
				if((-1) * odds[i] <= x && x <= evens[i] - nums[i]){
					n = i;
					break;
				}
			}
			x += nums[n];
		}
		//printf("%d,",n);
		digs[n]=1;
	}
	int k = 35;
	while(digs[--k]==0);
	for(;k>=0;k--){
		printf("%d",digs[k]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
  char s[6];
  char *x1="Sunny";
  char *x2="Cloudy";
  char *x3="Rainy";
  scanf("%s",s);
  if(strcmp(s,x2)==0){
    printf("Rainy\n");
  }
  if(strcmp(s,x3)==0){
    printf("Sunny\n");
  }
  if(strcmp(s,x1)==0){
    printf("Cloudy\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

vector<ll> vec[55];
ll par[55], dep[55], X[21], Y[21], lca[21], n, m, dp[1<<21];

void  dfs(ll u, ll p){
    par[u] = p;
    dep[u] = dep[p]+1;
    for(auto x: vec[u]){
        if(p != x){
            dfs(x, u);
        }
    }
}

void solve(){
    ll  n; string s;
    cin >>n;
    vector<ll> v(n), v1(n), v2(n);
    for(ll i = 0; i < n; i++){
        cin >> v1[i]; v[i] = i+1;
    }
    for(ll i = 0; i < n; i++){
        cin >> v2[i];
    }

    ll x, y, c = 0;
    do{
        c++;
        if(v1 == v) x = c;
        if(v2 == v) y = c;
    }
    while(next_permutation(v.begin(), v.end()));
    cout << abs(y-x);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
long long counter=0;
long long n;
cin>>n;
long long a[n]={};
long long f=0;
for(long long i=0; i<n; i++){
cin>>a[i];}
for(long long i=0; i<n-1; i++){
if(a[i]==a[i+1]){
continue;}
else if(a[i]<a[i+1]){
if(f==0){
f++;
continue;}
else if(f==1){
continue;}
else{
counter++;
f=0;
continue;}}
else{
if(f==0){
f+=2;
continue;}
else if(f==2){
continue;}
else{
counter++;
f=0;
continue;}}}
cout<<counter+1<<endl;}



Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n,m,c ;
  cin >> n >> m >> c  ;
  

  vector <int> B(m);
  for (int i = 0; i < m; ++i) {
    cin >> B[i];
  }
  vector <vector <int>> A(n, vector <int >(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> A[i][j];
    }
  }

  int ans = 0 ;
  
  for(int i=0;i<n;i++){
    int cnt  = 0 ;
    for(int j=0;j<m;j++){
      cnt += A[i][j]*B[j]  ;
    }
    if((cnt+c)>0){
      ans++ ;
    }
  }
  
  cout << ans << endl;
  return 0 ;
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N, K;
	static int[] s;
	static int[][] b;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		N = sc.nextInt(); K = sc.nextInt();
		if( N == 0 && K == 0 )return false;
		s = new int[K];
		b = new int[N][K];
		for(int i = 0; i < s.length; i++){
			s[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++){
			for(int j = 0; j < K; j++){
				b[i][j] = sc.nextInt();
			}
		}
		return true;
	}
	
	static void solve(){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < K; j++){
				s[j] -= b[i][j];
			}
		}
		boolean flag = true;
		for(int i = 0; i < s.length; i++){
			if( s[i] < 0 )flag = false;
		}
		if(flag){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

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

int main() {
  int l;
  cin >> l;
  double L;
  L = l * 1.0;
  double len, ans;
  len = L / 3.0;
  ans = len * len * len;
  cout << fixed << setprecision(15) << ans << endl;
}


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

const int MAX_N = 8000 + 3;
int n, ans, x, y;
int Arr[2][MAX_N];
int ind[2] = {1, 1};
int dp[2][MAX_N][2 * MAX_N];
int BASE = 8000 + 3;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s >> x >> y;
	n = s.size();

	int type = 0;
	int len = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'F')
			len++;
		else {
			Arr[type][ind[type]++] = len;
			type ^= 1;
			len = 0;
		}
	}

	Arr[type][ind[type]++] = len;
	type ^= 1;
	len = 0;

	for (int t = 0; t < 2; t++) {
		dp[t][0][BASE] = 1;
		for (int i = 1; i < ind[t]; i++)
			for (int j = 0; j < 2 * MAX_N; j++) {
				if (Arr[t][i] <= j)
					dp[t][i][j] |= dp[t][i - 1][j - Arr[t][i]]; 
				if ((t || 1 < i) && j + Arr[t][i] < 2 * MAX_N)
					dp[t][i][j] |= dp[t][i - 1][j + Arr[t][i]]; 
			}
	}

	if (dp[0][ind[0] - 1][BASE + x] && dp[1][ind[1] - 1][BASE + y]) {
		cout << "Yes\n";
		return 0;
	}
		
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 499968
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll r; cin >> r;
    cout << r*r << endstr;
    return 0;
}


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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

// 最小公倍数lcm=m*n/gcd
uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// nCm
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

signed main() {
  char s, sprev;
  sprev = 0;
  for(int i=0; i<3; i++){
    cin >> s;
    if(sprev!=0 && sprev != s){
      cout << "Yes" << endl;
      return 0;
    }
    sprev = s;
  }
  cout << "No" << endl;
  return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll next(ll n) {
  for (;;) {
    if (n % 10 == 0) {
      break;
    }
    n++;
  }
  return n;
}

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  vector<pair<ll, ll>> list(5);

  for (ll i = 0; i < 5; i++) {
    ll v;
    scanf("%lld", &v);
    ll ha = v % 10;
    if (ha == 0) {
      ha = 10;
    }
    list[i] = make_pair(ha, v);
  }

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

  ll tm = 0;
  for (ll i = 0; i < list.size() - 1; i++) {
    ll s = list[i].second;
    tm += s;
    tm = next(tm);
  }
  tm += list[list.size() - 1].second;
  cout << tm << endl;
}


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


int main(){
    int a,b;
    cin >> a >> b;
    if(a>=13) cout << b << endl;
    else if(a<=5) cout << 0 << endl;
    else cout << b/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 169, task a, 2020/05/31
//ms,
/*
*/

int main(void){
  int a, b;
  cin >>a >>b;
  cout <<a*b <<endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3636
def cal(a,b):
    return a-b
while True:
    n = int(input())
    if n == 0:
        break
    data = list(map(int,input().split()))
    avg = sum(data)/len(data)
    temp = list(map(lambda x:(x-avg)**2,data))
    mean = (sum(temp)/len(temp))**0.5
    print(mean)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int w,h;
string s[22];
bool vis[22][22];

int d[]={-1,0,1,0,-1};

int dfs(int y,int x){
	int res=1;
	vis[y][x]=true;
	rep(i,4){
		int nx=x+d[i],ny=y+d[i+1];
		if(nx<0||nx>=w||ny<0||ny>=h||s[ny][nx]=='#')continue;
		if(!vis[ny][nx])res+=dfs(ny,nx);
	}
	return res;
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>w>>h;
		if(w==0)break;
		int sw,sh;
		rep(i,h){
			cin>>s[i];
			rep(j,w){
				if(s[i][j]=='@'){
					sw=j; sh=i;
				}
			}
		}
		memset(vis,0,sizeof(vis));
		cout<<dfs(sh,sw)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
  int main(){      
      string s;
      lint k,n;
      cin>>s>>k;
       n=s.size();
     
      set<string> st;
      rep(i,n){
            string an="";
            repp(j,i,min(n,i+7)){
                an+=s[j];
             st.emplace(an);
            }
      }
      lint count=0;
     for(auto x:st){
         count++;
        if(count==k){ cout<<x<<endl;
        return 0;
        }
     }
  }
          
  

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=998244353;
const long long int INF=99999999999999999;

long long int n,m,sum,res=0;

int main() {
	cout << fixed << setprecision(10);
    cin>>n>>m;
    cout<<max(0LL,n-2*m);
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

signed main() {
    long long x;
    cin >> x;
    vector<long long> a(200);
    vector<long long> b(200);
    for (int i = 0; i < 200; i++) {
        a[i] = modpow(i, 5);
    }
    long long A, B;
    for (int i = 0; i < 200; i++) {
        b[i] = -a[i];
    }
    REP(i, 200) {
        REP(j, 200) {
            if (a[i] - b[j] == x) {
                A = i;
                B = j;
                break;
            }
            if (a[i] + b[j] == x) {
                A = i;
                B = -j;
                break;
            }
        }
    }
    cout << A << " " << -B << endl;
    // cout << a[101] << " " << a[99] << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<ext/pb_ds/priority_queue.hpp>
 
#define int long long
 
using namespace std;
 
const int N = 1e5 + 10;
 
__gnu_pbds::priority_queue<int, greater<int>, __gnu_pbds::pairing_heap_tag> val[N];
int n, m, fa[N], ans, cnt;
 
int find(int x) {
	return fa[x] = x == fa[x] ? x : find(fa[x]);
}	
 
signed main() {
	//freopen("apc001d.in", "r", stdin);
	//freopen("apc001d.out", "w", stdout);
	int x, y, now = 1;
	scanf("%lld%lld", &n, &m);
	for(int i = 1; i <= n; ++ i) 
		scanf("%lld", &x), val[fa[i] = i].push(x);
	for(int i = 1; i <= m; ++ i) {
		scanf("%lld%lld", &x, &y);
		++ x, ++ y;
		x = find(x), y = find(y);
		if(x != y) ++ cnt, fa[y] = x, val[x].join(val[y]);
	}
	for(int i = 1; i <= n; ++ i)
		if(val[find(i)].size() > val[now].size())
			now = find(i);
	if(cnt + n / 2 < n - 1) return puts("Impossible"), 0;
	for(int i = 1; i <= n; ++ i) {
		int u = find(now), v = find(i);
		if(u == v || val[v].empty()) continue;
		ans += val[u].top() + val[v].top();
		val[u].pop(), val[v].pop();
		val[u].join(val[v]), fa[v] = u;
		++ cnt;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 10112
#define r return
i,j,n,max[6];
dx[8]={1,1,0,-1,-1,-1,0,1};
dy[8]={0,1,1,1,0,-1,-1,-1};
char t[10][10],mark[2]={'o','x'};
 
int l(int dx,int dy,int x,int y,char m,int c){
  if(t[x][y]=='.'||t[x][y]=='0')r 0;
  if(t[x][y]==m)r c;
  r l(dx,dy,x+dx,y+dy,m,c+1);
}
int s(int x,int y,char m){
  int k,c;
  c = 0;
  if(t[x][y]!='.')r 0;
  for(k=0;k<8;k++){
    c += l(dx[k],dy[k],x+dx[k],y+dy[k],m,0);
  }
  r c;
}
int okikae2(int dx,int dy,int x,int y,char m){
  if(t[x][y]=='0'||t[x][y]=='.')r 0;
  else if(t[x][y]==m)r 1;
  else if(okikae2(dx,dy,x+dx,y+dy,m)){
    t[x][y]=m;
    r 1;
  }
  else r 0;
}
int okikae(int x,int y,char m){
  int k;
  t[x][y]=m;
  for(k=0;k<8;k++){
    okikae2(dx[k],dy[k],x+dx[k],y+dy[k],m);
  }
  r 0;
}
 
int main(){
  for(i=0;i<10;i++)t[0][i]=t[9][i]='0';
  for(i=1;i<9;i++){
    scanf("%s",&t[i][1]);
    t[i][0]='0';
    t[i][9]='0';
  }
  max[1]=-1;
  for(n=0;;n=(n+1)%2){
    max[n]=-1;
    for(i=n?8:1;n?i>-1:i<9;n?i--:i++){
      for(j=n?8:1;n?j>-1:j<9;n?j--:j++){
        if(max[n]<s(i,j,mark[n])){
          max[2+n]=i;
          max[4+n]=j;
          max[n]=s(i,j,mark[n]);
        }
      }
    }
    if(max[n]!=0)okikae(max[2+n],max[4+n],mark[n]);
    if(max[0]==0&&max[1]==0)break;
  }
  for(i=1;i<9;i++){
    for(j=1;j<9;j++){
      printf("%c",t[i][j]);
    }
    puts("");
  }
  r 0;
}

Measured memory_bytes: 524
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(s=>parseInt(s));
  buildMaxHeap(arr);
  console.log(' ' + arr.join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[largest]) largest = left;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };
  for (let i = Math.floor(n / 2 - 1); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 110744
import java.util.*;

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();
		String answer = (A-C)*(B-C) <= 0 ? "Yes": "No";
		System.out.println(answer);
	}
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
	int n;
	cin >> n;
	double a[n];
	REP(i,n){
		cin >> a[i];
	}
	double ans=0;
	REP(i,n){
		ans +=1/a[i];
	}
	cout << 1/ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP std::make_pair
#define FI first
#define SE second
#define M 1000005
#define INF 1000000000
int n,m,S[1024][1024];
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(int x){
	if (x<10) putchar(x+'0');
	else Write(x/10),putchar(x%10+'0');
	return;
}
int max(int x,int y){return x>y?x:y;}
void calc(int X1,int Y1,int X2,int Y2){
	if (X1==X2) return S[X1][Y1]=1,void();
	int midX=(X1+X2)/2,midY=(Y1+Y2)/2;
	calc(X1,Y1,midX-1,midY-1);
	calc(X1,midY+1,midX-1,Y2);
	calc(midX+1,Y1,X2,midY-1);
	calc(midX+1,midY+1,X2,Y2);
	return S[midX][midY]=1,void();
}
int main(){
	n=(1<<read())-1,m=(1<<read())-1,calc(1,1,max(n,m),max(n,m));
	for (int i=1;i<=n;i++,putchar('\n'))
		for (int j=1;j<=m;j++) putchar(S[i][j]+'0');
	return 0;
}


Measured memory_bytes: 7580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h1,m1,h2,m2,k,s=0;
    cin>>h1>>m1>>h2>>m2>>k;
    s=((h2*60+m2)-(h1*60+m1)-k);
    cout<<s<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define abs(x) (x < 0 ? -x : x) 
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, T;
    cin >> A >> B >> T;
    cout << B * (T / A) << endl;
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N,W=map(int,input().split())

l=[10**10]*(10**5+1)
l[0]=0
dp=l[:]

#indexが価値　itemが重さ
for i in range(N):
    w,v=map(int,input().split())
    for index,item in enumerate(l):
        if item!=10**10 and item+w<=W:
            dp[index+v]=min(l[index+v],item+w)
    l=dp[:]

ans=0
for index, item in enumerate(l):
    if item!=10**10:
        ans=index
    else:
        continue
print(ans)



Measured memory_bytes: 80844
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
    s <- C.getLine
    print $ snd $ C.foldl (\(c,ac) w -> f c ac w) (0,0) s

f 0 ac 'g' = (1,    ac)
f c ac 'g' = (c-1,  ac+1)
f 0 ac 'p' = (1,    ac-1)
f c ac 'p' = (c-1,  ac)

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

int main(){
    char s;
   cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

   return 0;

}


Measured memory_bytes: 3636
import sys
input=sys.stdin.readline
mod=998244353

class BIT():
    def __init__(self,n):
        self.size=n
        self.bit=[0]*(n+1)
    def add(self,i,x):
        while i<=self.size:
            self.bit[i]+=x
            i+=i&-i
    def sum_to_i(self,i):
        s=0
        while i>0:
            s+=self.bit[i]
            i-=i&-i
        return s

n=int(input())
XY=[]
Y=[]
for _ in range(n):
    x,y=map(int,input().split())
    XY.append((x,y))
    Y.append(y)
Y.sort()
y_dict={y:i+1 for i,y in enumerate(Y)}
XY=[(x,y_dict[y]) for x,y in XY]
XY.sort()
bit=BIT(n)
pow_2=[1]
for _ in range(n):
    pow_2.append(pow_2[-1]*2%mod)
ans=0
for i,(x,y) in enumerate(XY):
    a=bit.sum_to_i(y)
    b=i-a
    c=y-a-1
    d=(n-i-1)-c
    bit.add(y,1)
    pa,pb,pc,pd=pow_2[a],pow_2[b],pow_2[c],pow_2[d]
    tmp=pow_2[n-1]
    tmp+=(pa-1)*(pd-1)*pb*pc%mod
    tmp+=(pb-1)*(pc-1)*pa*pd%mod
    tmp-=(pa-1)*(pb-1)*(pc-1)*(pd-1)%mod
    ans+=tmp
    ans%=mod
print(ans)

Measured memory_bytes: 110548
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int x[100000];
int y[100000];

int main(){
	int n,k;
	cin>>n;
	while(scanf("%d %d",&n,&k)!=EOF){
		REP(i,n)scanf("%d",&x[i]);
		int ans = 0;
		REP(i,n-1){
			ans += (y[i] = x[i+1]-x[i]);
		}
		sort(y,y+n-1);
		//debug(y,y+n-1);
		int bnd = min(k-1,n-1);
		for(int i = 0; i < bnd; i++){
			ans -= y[n-2-i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
H, W = map(int, input().split())
G = []
for i in range(H):
    G.append(list(input()))
fd = [[-1, 0], [1, 0], [0, 1], [0, -1]]
for i in range(H-1):
    for j in range(W-1):
        if G[i][j] == '#':
            boo = False
            for x, y in fd:
                if i+y < 0 or i+y >= H or j+x < 0 or j+y >= W:
                    continue
                if G[i+y][j+x] == '#':
                    boo = True
            if not boo:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int change(int *); 
int main(void)
{
	int w,n,i;
	int amida[100];

	scanf("%d %d",&w,&n);//縦棒と横棒の数

 	for(i = 0;i <= w;i ++){
		amida[i] = (i + 1);
	}

	for(i = 0;i < n;i ++){
		change(amida);
	}
	for(i = 0;i < w;i ++){
		printf("%d\n",amida[i]);

	}
	return 0;
}

int change(int *amida){
	char skip;
	int a,b,temp;

	scanf("%d",&a);
	scanf("%c ",&skip);
	scanf("%d", &b);	
	
	temp = *(amida + a - 1);
	*(amida + a - 1) = *(amida + b - 1);
	*(amida + b - 1) = temp;
	return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for( int i=0;i<n; i++)
	cin>>arr[i];
	
	char ans[k+1];
	ans[0]='S';
	int flag;
	for( int i=1;i<=k;i++)
	{
	    flag=0;
	    for( int j=0;j<n ;j++)
	    {
	        if(arr[j]<=i)
	        {
	            if(ans[i-arr[j]]=='S')
	            {flag=1; break;}
	        }
	        else
	        break;
	    }
	    if(flag==1)
	    ans[i]='F';
	    else ans[i]='S';
	}
// 	for( int i=0;i<=k;i++)
// 	cout<<ans[i]<<" ";
	if(ans[k]=='F')
	cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int pow(int x, int p) {
    if (p == 0) { return 1; }
    if (p == 1) { return x; }
    if (p % 2) { return (x * pow(x, p - 1)); }
    int sub = pow(x, p / 2);
    return (sub * sub);
}

int ctoi(char c) { return int(c - '0'); }

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;
    string n_string = to_string(n);

    vvi c(10, vi(10, 0));

    rep(i, 0, n + 1) {
        string i_string = to_string(i);
        int front = ctoi(i_string.front()), back = ctoi(i_string.back());
        ++c[front][back];
    }

    ll sum = 0;
    rep(i, 1, 10) {
        rep(j, 1, 10) {
            sum += c[i][j] * c[j][i];
        }
    }

    cout << sum << endl;

    return 0;
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,k,t,i;
	cin>>a>>b>>k;
	while (a!=0&&b!=0){
		if (a>b){a%=b;}else{b%=a;}
	}
	t=a|b;
	for (i=t;i>=1;i--){
		if (t%i==0){
			k--;
		}
		if (k==0){
			cout<<i;
			break;
		}
	}
	return 0;
}

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

int main(){
  int ans=0;
  vector<int> a(5,0),b(5,0);
  r(i,5){
    cin >> a.at(i);
    b[i]=(a.at(i)-1)%10;
    ans+=(a.at(i)+9)/10*10;
  }
  ans+=*min_element(b.begin(),b.end())-9;
  cout << ans << endl;
}

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

int main() {
  // c が母音であるとき、vowel と、そうでないとき consonant と出力せよ。
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }

  else {
    cout << "consonant" << endl;
  }

}

Measured memory_bytes: 256
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

tmp = [0 for _ in range(N)]

for i in range(N):
    tmp[i] = V[i] - C[i]
  
res = 0
for i in range(N):
    if tmp[i] > 0:
        res += tmp[i]
            
        
print(res)
    

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

int main(){
    using namespace std;

    unsigned long N, X;
    cin >> N >> X;

    vector<long> x(N);
    for(auto& i : x)cin >> i;
    reverse(x.begin(), x.end());
    partial_sum(x.begin(), x.end(), x.begin());

    unsigned long ans(numeric_limits<long>::max());
    for(unsigned long i = 1; i <= N; ++i)
        [&]{
            unsigned long na((N + i) * X + 5 * x[N - 1]);
            for(unsigned long j = 2 * i - 1; j < N; j += i)
                if(ans < (na += 2 * (x[N - 1] - x[j])))return;
            if(na < ans)ans = na;
        }();
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#define fo(x,a,b) for(int x=(a),e_=(b);x<=e_;x++)

using namespace std;
typedef long long ll;
const int N=100005;
ll q[N],x[N],a[N],ans=0,s;
int n;

int main(){
	scanf("%d %lld",&n,&s);
	fo(i,1,n) scanf("%lld %lld",&x[i],&a[i]);

	int L=1, R=n;q[0]=0;
	while(L<=R) {
		if(x[L]>s) {
			ans+=x[R]-s, s=x[R]; break;
		}
		if(x[R]<s) {
			ans+=s-x[L], s=x[L]; break;
		}
		if(a[L]>=a[R]) a[L]+=a[R], q[++q[0]]=R, R--;
		else a[R]+=a[L], q[++q[0]]=L, L++;
	}
	for(; q[0]; q[0]--) ans+=abs(s-x[q[q[0]]]), s=x[q[q[0]]];
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3860
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)

mo=10**9+7
#n=int(input()) 
n,a,b=map(int,input().split())
#a=[int(i) for i in input().split()]
ans=min(n*a,b)

print(ans)



Measured memory_bytes: 3444
#include <iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define cle(a) memset(a,0,sizeof(a))
#define maxn 1000005

using namespace std;
typedef long long ll;
//n个人  每辆车 c个人  超过k分钟生气
int n,c,k;
int a[100005];
int main()
{
  while(cin>>n>>c>>k)
  {
      memset(a,0,sizeof(a));
      for(int i=0;i<n;i++)
        cin>>a[i];
      sort(a,a+n);
      int flag=0;  //表示车

      for(int i=0;i<n;i++)
      {
          //cout<<"adjfklasjdf"<<i<<endl;
          int temp=1;
          int j;
          for( j=i+1;;)
          {
             if(a[j]>a[i]+k){j--;break;}
             else temp++;
             if(temp>c){j-- ;break;}
             if(j>=n)break;
             j++;
          }
          i=j;
          flag++;
      }
      cout<<flag<<endl;

  }



    return 0;
}


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

using namespace std;

int main()
{
    int map[101][101] = {0};
    int w, h, i, j, x, y, a = 1, n; // w, i=x, h, j=y;
    cin >> w >> h >> n;
    for (i=1; i<=w; i++)
        for (j=1; j<=h; j++)
            map[i][j] = 1;
    for (int k=1; k<=n; k++)
    {
        cin >> x >> y >> a;
        if (a == 1)
        {
            for (i=1; i<=x; i++)
                for (j=1; j<=h; j++)
                    map[i][j] = 0;
        }
        else if (a == 2)
        {
            for (i=x+1; i<=w; i++)
                for (j=1; j<=h; j++)
                    map[i][j] = 0;
        }
        else if (a == 3)
        {
            for (i=1; i<=w; i++)
                for (j=1; j<=y; j++)
                    map[i][j] = 0;
        }
        else if (a == 4)
        {
            for (i=1; i<=w; i++)
                for (j=y+1; j<=h; j++)
                    map[i][j] = 0;
        }
    }
    int sum = 0;
    for (i=1; i<=w; i++)
        for (j=1; j<=h; j++)
            sum += map[i][j];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
vector<int>g[maxn];
int vis[maxn];
int cnt[maxn];
int facnt[maxn];
int n;
int dfs(int x, int dep, vector<int>& fa){
    if(vis[x] == 1){
        return 0;
    }
    vis[x] = 1;
    int flag = 0;
    for(int i = 0; i < g[x].size(); ++i){
        if(vis[g[x][i]] == 0) flag = 1;
    }
    if(flag == 0){
        cnt[x] = 1;
        if(x == n){
            fa.push_back(x);
            return 1;
        }
        else return 0;
    }
    cnt[x] = 1;
    int ok = 0;
    for(int i = 0; i < g[x].size(); ++i){
        if(vis[g[x][i]] == 0){
            ok |= dfs(g[x][i], dep + 1, fa);
            cnt[x] += cnt[g[x][i]];
        }
    }
    if(x == n){
        fa.push_back(x);
        return 1;
    }
    else{
        if(ok != 0){
            fa.push_back(x);
            return 1;
        }
        else return 0;
    }
}
int main(){
    cin>>n;
    int a, b;
    for(int i = 1; i < n; ++i){
        scanf("%d %d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    memset(vis, 0, sizeof(vis));
    vector<int> fa;
    dfs(1, 1, fa);
    int f1 = n - cnt[n] - 1;
    int f2 = cnt[n] - 1;
    int tot = fa.size() - 1;
    for(int i = 1; i < tot; ++i){
        if(i != tot - 1){
            f2 = cnt[fa[i]] - 1;
            f1 = n - cnt[fa[i]] - 1;
            tot--;
        }
    }

    if(f1 > f2){
        cout<<"Fennec"<<endl;
    }
    else{
        cout<<"Snuke"<<endl;
    }
}


Measured memory_bytes: 13436
def main():
    N = int(input())
    H = list(map(int, input().split())) + [10**9 + 1]
    ans = t = c = 0
    for h in H:
        if h <= t:
            c += 1
        else:
            ans = max(ans, c)
            c = 0
        t = h
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20632
n, m = map(int, input().split())
counts = [1] * n
cands = [False] * n
cands[0] = True
for _ in range(m):
  x, y = map(lambda t: int(t) - 1, input().split())
  counts[x] -= 1
  counts[y] += 1
  if cands[x]:
    cands[y] = True
    if counts[x] == 0:
      cands[x] = False
print(sum(cands))

Measured memory_bytes: 4596
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] i = line.split(" ");
        int n = Integer.parseInt(i[0]);
        int m = Integer.parseInt(i[1]);
        int r = (n - 1) * (m - 1);
        System.out.println(r);
    }
}

Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef pair<int, int> pa;
constexpr int INF = 1145141919;

struct SparseTable {
    vector<vector<pa>> st;
    vector<int> lookup;

    void init(vector<int> &v) {
        int b = 0;
        while ((1 << b) <= v.size()) ++b;
        st.assign(b, vector<pa>(1 << b));
        for (int i = 0; i < v.size(); i++) st[0][i] = {v[i], i};
        for (int i = 1; i < b; i++) {
            for (int j = 0; j + (1 << i) <= (1 << b); j++) {
                st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
            }
        }

        lookup.resize(v.size() + 1);
        for (int i = 2; i < lookup.size(); i++) {
            lookup[i] = lookup[i >> 1] + 1;
        }
    }

    inline pa rmq(int l, int r) {
        int b = lookup[r - l];
        return min(st[b][l], st[b][r - (1 << b)]);
    }
};

int n;
vector<int> p;
vector<SparseTable> tables;
vector<vector<int>> ret;

void solve(int x, int y) {
    auto fi = tables[x % 2].rmq(x, y);
    auto se = tables[(x + 1) % 2].rmq(fi.second + 1, y);
    pa minValue = {fi.first, se.first}, minIndex{fi.second, se.second};

    int here = ret.size();
    ret.push_back({minValue.first, minValue.second});
    if (x != minIndex.first) {
        ret[here].push_back(ret.size());
        solve(x, minIndex.first);
    }
    if (minIndex.first + 1 != minIndex.second) {
        ret[here].push_back(ret.size());
        solve(minIndex.first + 1, minIndex.second);
    }
    if (minIndex.second + 1 != y) {
        ret[here].push_back(ret.size());
        solve(minIndex.second + 1, y);
    }
}

int main() {
    cin >> n;
    p.resize(n);
    vector<vector<int>> v(2, vector<int>(n, INF));
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        v[i % 2][i] = p[i];
    }
    tables.resize(2);
    tables[0].init(v[0]), tables[1].init(v[1]);

    solve(0, n);

    priority_queue<vector<int>, vector<vector<int>>, greater<>> que;
    que.push(ret.front());
    bool first = true;
    while (!que.empty()) {
        if (first)first = false;
        else cout << " ";

        auto now = que.top();
        que.pop();
        cout << now[0] << " " << now[1];
        for (int i = 2; i < now.size(); i++)que.push(ret[now[i]]);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 96108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

int main() {
	int n,k;
	cin >> n >> k;
	vector<int64_t> hs;
	for (int i = 0; i < n; ++i) {
		int64_t h;
		cin >> h;
		hs.push_back(h);
	}
	sort(hs.begin(), hs.end());
	int64_t mindif = 10000000000L;
	for (int i = 0; i + k-1 < n; ++i) {
		int64_t dif = hs[i + k-1] - hs[i];
		mindif = min(mindif, dif);
	}
	cout << mindif << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  int a,b; cin>>a>>b; int ans=max(a,b); if(a>b) --a; else --b; Cout(ans+max(a,b));
}












Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>

const int MAX_N = 2e3 + 5;

int n, x, y, dis[MAX_N], ans[MAX_N];
std::vector<int> adj[MAX_N];
bool vis[MAX_N];

int main()
{
	scanf("%d%d%d", &n, &x, &y);
	adj[x].push_back(y);
	adj[y].push_back(x);
	for (int i = 2; i < n; ++i)
	{
		adj[i].push_back(i + 1);
		adj[i].push_back(i - 1);
	}
	if (n > 1) adj[1].push_back(2);
	if (n > 1) adj[n].push_back(n - 1);
	for (int i = 1; i < n; ++i)
	{
		memset(vis, 0x00, sizeof(vis));
		std::queue<int> q; vis[i] = true; dis[i] = 0;
		for (q.push(i); !q.empty(); q.pop())
		{
			for (int j : adj[q.front()])
				if (!vis[j])
				{
					dis[j] = dis[q.front()] + 1;
					vis[j] = true;
					q.push(j);
				}
		}
		for (int j = i + 1; j <= n; ++j)
			++ans[dis[j]];
	}
	for (int i = 1; i < n; ++i)
		printf("%d\n", ans[i]);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	
    ll n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << "\n";
    return 0;
}



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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int A = cin.nextInt();
        int B = cin.nextInt();
        int ret = 0;

        if (A > B)
        {
            ret += A;
            A--;
        }
        else
        {
            ret += B;
            B--;
        }

        if (A > B)
        {
            ret += A;
            A--;
        }
        else
        {
            ret += B;
            B--;
        }

        Console.WriteLine(ret);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13140