akhauriyash/Code-Regression huggingface dataset:
n,c = map(int,input().split())

cp = [0]*n
cp_rev = [0]*n
d = [0]*n

for i in range(n):
    x,v = map(int,input().split())
    d[i] = x
    cp[i] = v
    cp_rev[n-1-i] = v

sm = [0]*n
sm_rev = [0]*n
max_sm = [0]*n
max_sm_rev = [0]*n

sm[0] = cp[0] - d[0]
sm_rev[0] = cp_rev[0] - (c - d[n-1])
max_sm[0] = sm[0]
max_sm_rev[0] = sm_rev[0]

for i in range(1,n):
    sm[i] = sm[i-1] + cp[i] - d[i] + d[i-1]
    sm_rev[i] = sm_rev[i-1] + cp_rev[i] - (c - d[n-1-i]) + c - d[n-i]
    max_sm[i] = max(max_sm[i-1],sm[i])
    max_sm_rev[i] = max(max_sm_rev[i-1],sm_rev[i])

ret_ind = sm.index(max(sm))
ret_ind_rev = sm_rev.index(max(sm_rev)) 

ans = 0

for i in range(ret_ind + 1):
    ans = max(ans, sm[i])
    if n-i-2 >= 0:
        ans = max(ans, sm[i] - d[i] + max_sm_rev[n-i-2])

for i in range(ret_ind_rev + 1):
    ans = max(ans, sm_rev[i])
    if n-i-2 >= 0:
        ans = max(ans,sm_rev[i] - (c - d[n-1-i]) + max_sm[n-i-2])

print(ans)

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

#define INF 100000000

using namespace std;

int main()
{
    int n ;
    cin >> n;
    char s[n];
    bool flag = false;
    for(int i = 0;i<n;i++)
    {
        cin >> s[i];
        if(s[i] == 'Y')
        {
            flag = true;
        }
    }
    cout << ((flag == true) ? "Four\n" : "Three\n");

    return 0;
}


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

int main() {
    ll n, W, w, v;
    cin >> n >> W;
    vector<pair<ll, ll>> a;
    a.push_back({0, 0});
    for (ll i = 0; i < n; i++) {
        cin >> w >> v;
        a.push_back({w, v});
    }
    ll dp[W+1][n+1];
    memset(dp, 0, sizeof(dp));
    for (ll w = 1; w <= W; w++) {
        for (ll i = 1; i <= n; i++) {
            if (a[i].first <= w) {
                dp[w][i] = max(dp[w][i], dp[w-a[i].first][i-1] + a[i].second);
            }
            dp[w][i] = max(dp[w][i], dp[w][i-1]);
        }
    }
    cout << dp[W][n];
    return 0;
}


Measured memory_bytes: 79104
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N + 1 - x):
        if x * 10000 + y * 5000 + (N - x - y) * 1000 == Y:
            print(x, y, N - x - y)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")


Measured memory_bytes: 40772
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

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

long long lcm(long long a,long long b){
	long long g=gcd(a,b);
	return a/g*b;
}

int main(){
	LL n,m;
    cin>>n>>m;
    vi a(n);
    FOR(i,0,n){
        cin>>a[i];
        a[i]/=2;
    }
    if(n==1){
        cout<<(m/a[0]+1)/2<<endl;
        return 0;
    }
    LL lcm2=1;
    FOR(t,0,50){
        int f=a[0]&1;
        FOR(i,0,n){
            if((a[i]&1)!=f){
                cout<<0<<endl;
                return 0;
            }
        }
        if(f==0){
            lcm2*=2;
            FOR(i,0,n){
                a[i]/=2;
            }
        }
    }
    LL lc=a[0];
    FOR(i,1,n){
        lc=lcm(lc,a[i]);
    }
    lcm2*=lc;
    cout<<(m/lcm2+1)/2<<endl;

}


Measured memory_bytes: 640
def add_list(l1,l2):
    res = []
    for v1,v2 in zip(l1,l2):
        res.append(v1+v2)
    return res

def sub_list(l1,l2):
    res = []
    for v1,v2 in zip(l1,l2):
        res.append(v1-v2)
    return res

n = int(input())
al = list(map(int, input().split()))
al2 = []
for a in al:
    a2 = list( map(int,format(a,'020b')) )
    al2.append(a2)

# print(al2)

left = -1
right = -1
next_i = 0
each_keta = [0]*20
ans = 0
while True:
    if right == n-1:
        break
    next_2 = add_list(al2[right+1], each_keta)
    if 2 in next_2:
        left += 1
        each_keta = sub_list(each_keta, al2[left])
    else:
        right += 1
        each_keta = next_2[:]
        ans += (right-left)

print(ans)

Measured memory_bytes: 154520
def c():
    import numpy as np

    N = int(input() )
    A = np.array([int(a) for a in input().split()])

    A_cum = np.cumsum(A)
    A_rev = A_cum[-1] - A_cum
    res = np.abs(A_rev - A_cum)[:-1]
    print(int(np.min(res)))


c()

Measured memory_bytes: 32748
X, Y = map(int, input().split())

ans = 0
if X == 3 :
    ans += 100000
elif X == 2 :
    ans += 200000
elif X == 1 :
    ans += 300000

if Y == 3 :
    ans += 100000
elif Y == 2 :
    ans += 200000
elif Y == 1 :
    ans += 300000

if max(X,Y) == 1 :
    ans += 400000

print(ans)


Measured memory_bytes: 3060
// Vicfred
// https://atcoder.jp/contests/abc165/tasks/abc165_d
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    long long a, b, n;
    cin >> a >> b >> n;

    cout << (a*min(b-1LL, n))/b << endl;

    return 0;
}



Measured memory_bytes: 3176
def main():
	from math import log,ceil
	n=int(input())
	a=list(map(int,input().split()))
	num={}
	for x in a:
		if x in num:
			num[x]+=1
		else:
			num[x]=1
	ans=0
	cnt=ceil(log(max(a),2)+1e-7)
	for i in range(cnt,0,-1):
		b=set(2**i-x for x in num)
		for x in num:
			if x in b and num[x]>0:
				if x*2==2**i:
					ans+=num[x]//2
					num[x]%=2
				else:
					small=min(num[x],num[2**i-x])
					ans+=small
					num[x]-=small
					num[2**i-x]-=small
	print(ans)
if __name__ == '__main__':
	main()

Measured memory_bytes: 243280
#include<iostream>
using namespace std;
int main(){
	long long n,i,l[100001];
	cin>>n;
	l[0]=2;
	l[1]=1;
	for(int i=2;i<=n;i++){
		l[i]=l[i-1]+l[i-2];
	}
	cout<<l[n]<<endl;
	return 0;
}

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

 using namespace std;

 int main() {
   int N, i, input, count, ans;

   cin >> N;

   vector<int> a(N + 1);

   for (i = 1; i <= N; i++) cin >> a.at(i);

   input = 1;
   count = 1;
   ans = -1;
   for (i = 0; i < N; i++) {
     if (a.at(input) == 2) {
       ans = count;
       break;
     }
     else {
       input = a.at(input);
       count++;
     }
   }

   cout << ans << endl;
 }


Measured memory_bytes: 640
N,Y = map(int,input().split())

res10000,res5000,res1000 = -1,-1,-1
for a in range(N+1):
    for b in range(N-a+1):
        c = N - a - b
        total = 10000*a + 5000*b + 1000*c
        if total == Y:
            res10000 = a
            res5000 = b
            res1000 = c
print(res10000,res5000,res1000)

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

#define ls (p<<1)
#define rs ((p<<1)|1)
#define mid ((l+r)>>1)
#define ULL unsigned long long

using namespace std;

int n,k,a[300009];

int tree[300009<<2];

void build(int p,int l,int r)
{
    if(l==r)
    {
        //printf("p:%d l:%d\n",p,l);
        tree[p]=1;
        return;
    }
    build(ls,l,mid);
    build(rs,mid+1,r);
    tree[p]=max(tree[ls],tree[rs]);
    //printf("p:%d ls:%d rs:%d lsw:%d rsw:%d maxn:%d\n",p,ls,rs,tree[ls],tree[rs],tree[p]);
}

void update(int p,int l,int r,int pp,int w)
{
    if(pp<l || r<pp)return;
    if(l==r)
    {
        tree[p]=w;
        return;
    }
    update(ls,l,mid,pp,w);
    update(rs,mid+1,r,pp,w);
    tree[p]=max(tree[ls],tree[rs]);
}

int getmax(int p,int l,int r,int ll,int rr)
{
    if(rr<l || r<ll)return -1;
    if(ll<=l && r<=rr)return tree[p];
    return max(getmax(ls,l,mid,ll,rr),getmax(rs,mid+1,r,ll,rr));
}

int main()
{
    scanf("%d%d",&n,&k);
    int limit=0,tmp;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        a[i]++;
        limit=max(limit,a[i]);
    }
    update(1,1,limit,a[1],1);
    for(int i=2;i<=n;i++)
    {
        tmp=getmax(1,1,limit,max(a[i]-k,1),min(a[i]+k,limit))+1;
        //printf(" %d\n",tmp);
        update(1,1,limit,a[i],tmp);
    }
    printf("%d",tree[1]);
    return 0;
}


Measured memory_bytes: 9052
#include <iostream>

using namespace std;
int N;

int main() {
  cin >> N;
  switch (N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    default:
      cout << "bon" << endl;
  }
}

Measured memory_bytes: 3648
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

int main(){
	int NNN;
	cin >> NNN;
	int c[NNN],s[NNN],f[NNN];
	rep(i,NNN-1){
		cin >> c[i] >> s[i] >> f[i];
	}
	int ans=0;
	int temp=0;
	rep(i,NNN){
		ans=0;
		Rep(j,i,NNN-1){
			if(ans<s[j]){
				ans = s[j] + c[j];
			}
			else if((f[j]+ans)%f[j]==0){
				ans  = ans + c[j];
			}
			else{
				temp = (f[j]+ans) % f[j];
				temp = f[j]- temp;
				ans  = ans + temp;
				ans  = ans + c[j];
			}		
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    int W,a,b; cin >> W >> a >> b;
    if((a <= b and b <= a+W) or (a <= b+W and b <= a)) cout << 0 << endl;
    else if(a+W < b) cout << b-a-W << endl;
    else cout << a-b-W << endl;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -fexcess-precision -fvia-C -optc-O3 #-}

import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M
import Data.List
import Data.Char

main :: IO ()
main = do
    [_, m] <- readInts
    as <- readInts
    print $ solve m as

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

solve :: Int -> [Int] -> Int
solve m =  M.foldl' (+) 0
     . fmap (\x -> x * (x - 1) `div` 2)
     . foldr (M.alter $ return . maybe 1 succ)  M.empty
     . map (`mod` m)
     . scanl' (+) 0


Measured memory_bytes: 20860
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
		int n = sc.nextInt();
		int x = sc.nextInt();
			if(n == 0 && x == 0) break;
		int s = 0;
		for(int i = 1; i <= n; i++) {
			for(int j = i + 1; j <= n; j++) {
				for(int k = j + 1; k <= n; k++) {
					if(i + j + k == x) s++;
				}
			}
		}
		System.out.println(s);
		}
	}
}

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

int main(){
  long long int a, b, c, n;
  cin >> a >> b >> c >> n;
  map<vector<int>,int> M;
  int dx[] = {1,0,0,-1,0,0}, dy[] = {0,1,0,0,-1,0}, dz[] = {0,0,1,0,0,-1};
  long long int ans = 2*(a*b + b*c + c*a);
  for(int i = 0; i < n; ++i){
    vector<int> t(3);
    cin >> t[0] >> t[1] >> t[2];
    ++M[t];
    int d = 0;
    for(int j = 0; j < 6; ++j){
      vector<int> t_ = t;
      t_[0] += dx[j];
      t_[1] += dy[j];
      t_[2] += dz[j];
      if(t_[0] >= a || t_[1] >= b || t_[2] >= c ||
         t_[0] < 0 || t_[1] < 0 || t_[2] < 0 || M[t_] == 1){
        --d;
      }else{
        ++d;
      }
    }
    ans += d;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3920
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0,k,x;
    cin >> n >> m ;
    ll h[n+1];
    rep(i,n) cin >> h[i+1] ;
    ll go[n+1];
    for(i=1;i<=n;++i) go[i]=1;
    rep(i,m)
    {
        cin >> k >> x ;
        if(h[k]>h[x])
        {
            go[x]=0;
        }
        else if(h[x]>h[k])
        {
            go[k]=0;
        }
        else 
        {
            go[k]=0;
            go[x]=0;
        }
    }
    for(i=1;i<=n;++i) 
    {
        if(go[i]==1) 
        {
            //cout << i << endl ;
            ans++;
        }
        
    }
    cout << ans ;
    return 0;
}

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

int n;
double a[20];
double dp[20][200001];

int main(){
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,20) rep(j,200001) dp[i][j] = DINF;
    for(int i = 1; i <= 200000; i++){
        dp[0][i] = abs(i-a[0])/a[0];
    }
    for(int i = 1; i < n; i++){
        for(int j = 1; j <= 200000; j++){
            for(int k = 1;;k++){
                if(k*k > j) break;
                if(j%k) continue;
                dp[i][j] = min(dp[i][j],max(dp[i-1][j/k],abs(j-a[i])/a[i]));
                dp[i][j] = min(dp[i][j],max(dp[i-1][k],abs(j-a[i])/a[i]));
            }
        }
    }
    double ans = DINF;
    for(int i = 1; i <= 200000; i++) ans = min(ans,dp[n-1][i]);
    printf("%.11f\n",ans);
}

Measured memory_bytes: 34540
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n >> m;
  rep(i, n) {
    cin >> k;
    rep(j, k) {
      cin >> a;
      mp[a]++;
      if (mp[a] == n) ans++;
    }
  }
  Cout(ans);
  return 0;
}

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

int main(){
//srandom((unsigned long)time(NULL));

int n,k;
cin>>n>>k;

int cnt[n];
for(int i=0;i<n;i++) cnt[i]=0;

for(int i=0;i<k;i++){
    int d;
    cin>>d;
for(int j=0;j<d;j++){
    int a;
    cin>>a;
    cnt[a-1]++;
}
}

int ans=0;
for(int i=0;i<n;i++){
    if(cnt[i]==0) ans++;
}
cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>

int main()
{
    std::ios_base::sync_with_stdio(0);
    int n;
    std::string s;
    std::cin >> n >> s;
    for (char& c : s) c = (c-'A'+n)%26+'A';
    std::cout << s;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
#define M 1000000007
using namespace std;
ll t;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll power(ll x,ul y,ll p){ll res = 1;x = x % p;if(x == 0)return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
void solve(){
	ll n,k,count=0;
	cin>>n>>k;
	ll a[n],ans[n]={0};
	for(ll i=0;i<n;i++){ cin>>a[i]; ans[i]=a[i];}
	for(ll i=0;i<k;i++){
		ll c,b;
		cin>>c>>b;
		if(a[c-1]<a[b-1]){
			ans[c-1]=0;
			if(ans[b-1]>0) ans[b-1]++;
		}
		else if(a[c-1]==a[b-1]){ans[c-1]=0;ans[b-1]=0;}
		else{
			ans[b-1]=0;
			if(ans[c-1]>0) ans[c-1]++;
		}
		
	}
	for(ll i=0;i<n;i++) if(ans[i]>0) count++;
	cout<<count<<"\n";
 }
int main(){
	fast();
	solve();
	return 0;
}



Measured memory_bytes: 5220
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000

char hoge[BUFSIZE] = {0};

int main(void){
  scanf("%s",hoge);
  for(int i = 0;i < 3;i++){
    printf("%c",hoge[i]);

}




}


Measured memory_bytes: 1660
def judge(N,Y):
    if(Y%1000!=0):
        return print('-1 -1 -1')
    for x in range(N+1):
        for y in range(N+1-x):
            if(9*x+4*y+N == Y/1000):
                return print(x, y, N-x-y)
    return print('-1 -1 -1')

if __name__ == '__main__':
    N, Y = map(int, input().split())
    judge(N,Y)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
char a[120];
int main()
{  int flag=1;
	scanf("%s",a);
	int k=strlen(a);
	for(int i=0;i<k;i++)
	if(a[i]!=a[k-i-1])flag=0;
//	printf("  %d  ",flag);
	for(int i=0;i<(k-1)/2;i++)
	{
	   if(a[i]!=a[(k-1)/2-i-1])flag=0;
	  // printf("%d %d",i,(k-1)/2-i+1);
	   
}
	  // printf("%c %c",a[1],a[2]);
	  // 	printf("  %d  ",flag);
	   int l=0;
	   for(int i=(k+3)/2-1;i<k;i++)
	   {
	if(a[i]!=a[k-l-1])flag=0;
	l++;}
		//printf("  %d  ",flag);
	if(flag)printf("Yes\n");
	 else printf("No\n");
	// printf("%c",a[0]);
}

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

int main(void)
{
  int n, x;
  cin >> n;
  int data[n];
  for (int i = 0; i < n; i++)
  {
    cin >> x;
    data[i] = x;
  }

  int max = data[n - 1] - data[n - 2];
  int min = data[0];
  for (int i = 1; i < n; i++)
  {
    if (max < data[i] - min)
    {
      max = data[i] - min;
    }
    if (min > data[i])
    {
      min = data[i];
    }
    //cout << "min" << min << endl;
  }

  cout << max << endl;
  return 0;
}


Measured memory_bytes: 3896
#include <stdio.h>
#include<string.h>
int main()
{
    int a,b,c;
    char x[10];
    scanf("%s",x);
    if(0==strcmp(x,"Sunny"))
    {
        printf("Cloudy\n");
    }
    else if(0==strcmp(x,"Cloudy"))
    {
        printf("Rainy\n");
    }
    else if(0==strcmp(x,"Rainy"))
    {
        printf("Sunny\n");
    }



    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef    pair<int,int> pii;
typedef    pair<int,pii> ppi;
typedef    pair<pii,int> pip;
typedef    long long int ll;
typedef    unsigned long long int ull;
typedef    pair<ll,ll> pll;
typedef    vector<int> VI;
typedef    vector<pii> Vii;
typedef    vector<VI> VVI;// 2D
//typedef    priority_queue<int> PQ;// MaxHeap
typedef    priority_queue<int,VI,greater<int> > PQ;// MinHeap
//int Dx[] ={-1,0, 0,1};
//int Dy[] ={ 0,1,-1,0};
//int Dx8[]={-1,-1,-1,0,1,1, 1, 0};
//int Dy8[]={-1, 0, 1,1,1,0,-1,-1};
//int Kx[] ={2,1,-1,-2,-2,-1, 1, 2};
//int Ky[] ={1,2, 2, 1,-1,-2,-2,-1};

// code starts from here
#define pi acos(-1.0)
const int MAX=1e6+10,MOD=1e9+7;
void solve(){
    int n;cin >> n;
    int r = n%10;
    if(r==3)cout<<"bon";
    else if(r==0||r==1||r==6||r==8)cout<<"pon";
    else cout<<"hon";
}
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    while(t--)solve();
    return 0;
}



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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=INF, tmp=0, tmpi;
vector<ll> A, S1, S2;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    S1.resize(N);
    S1[0] = A[0];
    for(int i=0;i<N-1;i++) {
        S1[i+1] = S1[i] + A[i+1];
    }
    S2.resize(N);
    S2[N-1] = A[N-1];
    for(int i=N-2;i>=0;i--) {
        S2[i] = S2[i+1] + A[i];
    }
    reverse(S2.begin(), S2.end());
    for(int i=1;i<N-2;i++) {
        ll id1 = lower_bound(S1.begin(), S1.end(), S1[i]/2)-S1.begin();
        tmp = INF;
        if(id1<i) {
            tmp = abs(S1[i]-2*S1[id1]);
            tmpi = id1;
        }
        if(id1>0) {
            if(tmp>abs(S1[i]-2*S1[id1-1LL])) {
                tmp = abs(S1[i]-2*S1[id1-1LL]);   
                tmpi = id1-1;
            }
        }
        ll P = S1[tmpi];
        ll Q = S1[i] - S1[tmpi];
        ll id2 = lower_bound(S2.begin(), S2.end(), S2[N-i-2]/2)-S2.begin();
        tmp = INF;
        if(id2<N-i-2) {
            tmp = abs(S2[N-i-2]-2*S2[id2]);
            tmpi = id2;
        }
        if(id2>0) {
            if(tmp>abs(S2[N-i-2]-2*S2[id2-1LL])) {
                tmp = abs(S2[N-i-2]-2*S2[id2-1LL]);   
                tmpi = id2-1;
            }
        }
        ll R = S2[tmpi];
        ll S = S2[N-i-2] - S2[tmpi];
        ll minv, maxv;
        minv = min(R, S);
        minv = min(minv, P);
        minv = min(minv, Q);
        maxv = max(R, S);
        maxv = max(maxv, P);
        maxv = max(maxv, Q);
        ans = min(ans, maxv-minv);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7864
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    string s,t;
    cin>>n>>s>>t;
    string ans="";
    for(int i=0;i<s.size();i++){
        ans+=s[i];
        ans+=t[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n, m, a;
	scanf("%d %d", &n, &m);
	while(m){
		scanf("%d", &a);
		n-=a;
		m--;
	}
	if(n<0)printf("-1\n");
	else	printf("%d\n", n);
	
	return 0;
}

Measured memory_bytes: 1732
def comb(n,r,m):
    if 2*r > n:
        r = n - r
    nume,deno = 1,1
    for i in range(1,r+1):
        nume *= (n-i+1)
        nume %= m
        deno *= i
        deno %= m

    return (nume * pow(deno,m-2,m)) % m

def main():
    N,M,K = map(int,input().split())
    mod = 998244353

    ans,comb_r = pow(M-1,N-1,mod),1
    for r in range(1,K+1):
        comb_r = (comb_r * (N-r) * pow(r,mod-2,mod)) % mod
        ans = (ans + comb_r * pow(M-1,N-r-1,mod)) % mod
    ans = (ans * M) % mod

    print(ans)

if __name__ == "__main__":
    main()


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

#define REP(i,n) for(ll i=0;i<ll(n);i++)

int main(){
    int n,c = 0;
    ll d;
    cin >> n >> d;
    REP(i,n) {
        ll a,b;
        cin >> a >> b;
        if(a*a+b*b <= d*d) c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 3636
import collections
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))
c = collections.Counter(A)
buka_num = []

for i in range(1,N):
    buka_num.append(c[i])
    
buka_num.append(0)
for ele in buka_num:
    print(ele)

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

int main(){
  int N,M,t,J,a;
  cin >> N >> M;
  vector<int> score(M);
  for(int i=0;i<N;i++){
    cin >> J;
    for(int j=0;j<J;j++){
      cin >> a;
      score.at(a-1)++;
    }
  }
  for(int k=0;k<M;k++){
    if(score.at(k)==N)
      t++;
  }
  cout << t;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 100000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int main() {
	long long n, k;
	cin >> n >> k;
	cout << max(0LL, n - k + 1LL) << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}
template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
double dist(pair<int,int> p1, pair<int,int> p2){
    double ans = (p1.first - p2.first) * ( p1.first - p2.first) + (p1.second -p2.second) * (p1.second - p2.second);
    return sqrt(ans);
}
void solve(){
    int n;
    read(n);
    vector<pair<int,int>> p(n);
    REP(i,n){
        int x, y;
        read(x,y);
        p[i] = make_pair(x,y);
    }
    double ans = 0;
    for(int i = 0; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            if ( j != i)
                ans += dist(p[i], p[j]); 
        }
    }
    ans = ans / n;
    printf("%.9f \n", ans);
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3812
def modinv2(a,m):
    return pow(a,m-2,m)

def f(n,m):
    a = 1
    for i in range(2,n+1):
        a = a*i%m
    return a

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

ans = 0
P = 10**9+7

b = f(N-1,P)

invlist = [1]

for i in range(1,N-1):
    inv = (invlist[-1]+modinv2(i+1,P))%P
    invlist.append(inv)
#print(invlist)

for i in range(N-1):
    l = x[i+1]-x[i]
    ans += (l*invlist[i]%P)*b%P

print(ans%P)


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

int main() {
  int a,b, c;
  cin >> a >> b >> c;
  if(a==b) cout << c << endl;
  else if(a==c) cout << b << endl;
  else cout << a << endl;
}

Measured memory_bytes: 256
import math

N, M, K = (int(x) for x in input().split())

def comb(n,k,p):
    if k < 0 or k > n:
        return 0
    if n == 0 or k == 0:
        return 1
    a=math.factorial(n) % p
    b=math.factorial(k) % p
    c=math.factorial(n-k) % p
    return (a*mypow(b,p-2,p)*mypow(c,p-2,p)) % p

def mypow(a,b,p):
    if b == 0: return 1
    if b % 2 == 0:
        d=mypow(a,b//2,p)
        return d*d % p
    if b % 2 == 1:
        return (a*mypow(a,b-1,p )) % p

c_sum = (M*(N-1)*N*(N+1)*M+N*(M-1)*M*(M+1)*N)//3
c_sum = c_sum//2
c_sum *= comb(N*M-2, K-2, 1000000007)
c_sum = c_sum % 1000000007

print(c_sum)


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

int lcs(string x, string y) {
    x = ' ' + x;
    y = ' ' + y;
    int m = x.size();
    int n = y.size();
    vector<vector<int>> c(m, vector<int>(n, 0));
    rep(i, m) {
        rep(j, n) {
            if (i == 0 || j == 0) continue;
            if (x[i] == y[j]) c[i][j] = c[i-1][j-1] + 1;
            else c[i][j] = max(c[i][j-1], c[i-1][j]);
        }
    }
    return c[m-1][n-1];
}

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        string s1, s2;
        cin >> s1;
        cin >> s2;
        cout << lcs(s1, s2) << endl;
    }
}


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

int main(){
  int n,t;
  cin >> n >> t;
  int ans = 0;
  int crt = 0;
  int next = 0;
  for(int i = 0;i < n;i++)
  {
    cin >> crt;
    if (next <= crt) {
      ans += t;
    } else {
      ans += -(next - crt) + t;
    }
    next = crt + t;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

#print(N, K)
#print(A)
if N == K:
    print(1)
elif K == 2:
    print(N-1)
else:
    a = N // (K-1)
    if N - a*(K-1) >= 2:
        print(a+1)
    else:
        print(a)

Measured memory_bytes: 13880
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var h = o.a();
  var n = o.a();
  var a = o.m(n);
  var dp = xArray(1e9,2e4+1);
  dp[0] = 0;
  for(var i = 0; i < n; i++){
    for(var j = 0; j < h; j++){
      if(dp[j]+a[i][1] < dp[j+a[i][0]])dp[j+a[i][0]] = dp[j]+a[i][1];
    }
  }
  var ans = 1e9;
  for(var i = h; i <= h+1e4; i++)if(dp[i] < ans)ans = dp[i];
  return ans;
}

Measured memory_bytes: 8120
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n;
	cin >> n;
	set<string> v;
	rep(i, n) {
		string s;
		cin >> s;
		v.insert(s);
	}
	cout << v.size();
	return 0;
}

Measured memory_bytes: 19252
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L[] = new int[N];
    int max = 0;
    int sum = 0;
    for(int i=0; i<N; i++){
      L[i]=sc.nextInt();
      max = Math.max(max, L[i]);
      sum += L[i];  
    }
    if(max<sum-max){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

int main(){
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  unordered_map<long long, long long> mp;
  long long m=0;
  for (int i=0; i<N; i++){
    m += A[i];
    m %= M;
    if (mp.find(m) == mp.end()) mp[m] = 1;
    else mp[m] += 1;
  }
  long long ans = 0;
  for (auto m: mp){
    if (m.first==0){
      ans += m.second*(m.second+1)/2;
    } else {
      ans += m.second*(m.second-1)/2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4492
#!/usr/bin/env python3
import sys


def solve(s: str, K: int):
    # 解候補
    ans_ls = []
    for i in range(1, K + 1):
        for j in range(0, len(s) - i + 1):
            ans_ls.append(s[j : j + i])
    ans_set = list(set(ans_ls))
    print(sorted(ans_set)[K-1])
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()


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

using namespace std;

struct I{
    I(){
	ios::sync_with_stdio(false);cin.tie(0);
    }
}cww;
typedef long long  LL;
typedef vector<LL> V;
#define cnt(l,r) (__builtin_popcountll(l)+__builtin_popcountll(r))
typedef tuple<LL,LL> P;
typedef map<P,int> Map;
int dfs(LL rest1,LL rest2,V &v1,V &v2,Map &memo){
    // cout<<rest1<<" "<<rest2<<endl;
    if(cnt(rest1,rest2)==1)return 0;
    if(memo.count(P(rest1,rest2)))
	return memo[P(rest1,rest2)];
    int res=114514;
    int n=v1.size();
    for(int i=0;i<n;i++){
	int ans=0;
	LL nxt1,nxt2;
	nxt1=rest1&v1[i];
	nxt2=rest2&v2[i];
	if(nxt1==rest1&&nxt2==rest2)continue;
	if(nxt1==0&&nxt2==0)continue;
	ans=max(ans,1+dfs(nxt1,nxt2,v1,v2,memo));
	nxt1=rest1-nxt1;
	nxt2=rest2-nxt2;
	ans=max(ans,1+dfs(nxt1,nxt2,v1,v2,memo));
	res=min(res,ans);
    }    
    return memo[P(rest1,rest2)]=res;
}
int main(){
    for(int n,m;cin>>n>>m,n+m;){
	V v1(n,0),v2(n,0);
	for(int i=0;i<m;i++){
	    string s;
	    cin>>s;
	    for(int j=0;j<n;j++){
		if(s[j]=='1'){
		    if(i<64)
			v1[j]|=(1ll<<i);
		    else
			v2[j]|=(1ll<<(i-64));
		}
	    }
	}
	Map memo;
	LL r1=1,r2=1;
	if(m<=63){
	    r1=(r1<<m)-1;
	    r2=0;
	}
	else if(m==64){
	    r1=-1;
	    r2=0;
	}
	else if(m==128){
	    r1=-1;
	    r2=-1;
	}
	else{
	    r1=-1;
	    r2=(r2<<(m-64))-1;
	}
	cout<<dfs(r1,r2,v1,v2,memo)<<endl;
    }
    return 0;
}
    

Measured memory_bytes: 4384
#include<bits/stdc++.h>
#define I64 "%I64d"
#define RAN(v)v.begin(),v.end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
template<class T>
inline void upd1(T&a,T b){a>b?a=b:0;}
template<class T>
inline void upd2(T&a,T b){a<b?a=b:0;}
struct ano{
	operator ll(){
		ll x=0,y=0,c=getchar();
		while(c<48)
			y=c==45,c=getchar();
		while(c>47)
			x=x*10+c-48,c=getchar();
		return y?-x:x;
	}
}buf;
int main(){
	int n=buf,m=buf,k=buf;
	if(k%m==0)
		return!~puts("Yes");
	for(int i=1;i<=n;++i){
		int x=n-i*2;
		k-=m;
		if(k*x>0&&k%x==0&&k/x<=m)
			return!~puts("Yes");
	}
	puts("No");
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    S = input()
    ans = 1
    flg = False
    for i in range(N-1):
        if S[i] == S[i+1] and not flg:
            flg = True
        elif S[i] != S[i+1]:
            flg = False
            ans += 1
    print(ans)


if __name__ == '__main__': main()

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int32_t main(){
	IOS;
	int tt = 1; 
	//cin >> tt;
	while(tt--){
	int n, m, q; cin >> n >> m >> q;
  int row[n] = {}, col[m] = {};
  map < pair < int, int >, int > mp;
  while(q--){
    int a, b; cin >> a >> b;
    a--, b--;
    row[a]++, col[b]++;
    mp[{a, b}] = 1;
  }
  int max1 = *max_element(row, row + n);
  int max2 = *max_element(col, col + m);
  vector < int > a, b;
  for(int i = 0; i < n; i++){
    if(row[i] == max1){
      a.EB(i);
    }
  }
  
  for(int i = 0; i < m; i++){
    if(col[i] == max2){
      b.EB(i);
    }
  }
  
  bool ok = true;
  int cnt = 0;;
  for(auto x : a){
    for(auto y : b){
      if(!mp[{x, y}]){
        ok = false;
        break;
      }
      cnt++;
      if(cnt == (int)5e7) break;
    }
  }
	cout << max1 + max2 - ok;
	}
	return 0;
}


Measured memory_bytes: 50052
ARG_N, ARG_M = gets.split.map(&:to_i)
ARG_a = gets.split.map(&:to_i)

lcm = ARG_a[0] / 2
d = 1
while ARG_a[0] % (2**(d+1)) == 0 do
  d+=1
end
div = 2**d
1.upto(ARG_N-1) do |i|
  if ARG_a[i] % div != 0 || (ARG_a[i] / div).even?
    puts 0
    exit
  end
  lcm = (ARG_a[i]/2).lcm(lcm)
end
res = (ARG_M / lcm)
if res.even?
  puts res / 2
else
  puts res /2 + 1
end

Measured memory_bytes: 12556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()



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

    for(ll i=-1000;i<=1000;i++){
        for(ll j=-1000;j<=1000;j++){
            if(i*i*i*i*i-j*j*j*j*j==n){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}



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

int main()
{
	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
	#endif*/
	
	string s;
	cin >> s;
	bool a = false;

	for(int i = 1;i < s.length();i++)
	{
		if(s[i-1] == s[i])
		{	
			cout << "Bad";
			a = true;
			break;
		}
	}
	if(!a)
		cout << "Good";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        ArrayList<Integer> work = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
            work.add(nums[i]);
        }

        sc.close();
        Collections.sort(work);

        for (int i = 0; i < n; i++) {
            if (nums[i] <= work.get((n - 1) / 2)) {
                System.out.println(work.get((n + 1) / 2));
            } else {
                System.out.println(work.get((n - 1) / 2));
            }
        }
    }
}

Measured memory_bytes: 96416
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int N, l, r,ans;
    ans = 0;
    cin >> N;
    for (int i = 0; i < N;i++){
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static string s;

    static void input()
    {
        cin = new Scanner();
        s = cin.next();
    }
    static void solve()
    {
        input();
      
      WriteLine(s.Contains("AC") ? "Yes" : "No");
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

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

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

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

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

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

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
ll S;

int main() {

  cin >> S;

  ll x2 = 1;
  ll y2 = 1e9;

  ll x3 = S/y2 + 1;
  ll y3 = y2 - S%y2;
  if (x3==1e9+1 && y3==1e9) {
    x3 = 1e9;
    y3 = 0;
  }

  cout << 0 << ' ' << 0  << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;
 }

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

int main()
{
    int stu[28];
    int stusum = 0;
    int sum = 0;
    int Nostu[2];

    for (int i = 0; i < 28; i++){
        cin >> stu[i];
        stusum += stu[i];
    }

    for (int i = 1; i <= 30; i++){
        sum += i;
    }

    sort(stu, stu + 28);
    
    for (int j = 0; j < 30; j++){
        if (stu[j] != j + 1){
            Nostu[0] = j + 1;
            break;
        }
    }
    
    Nostu[1] = (sum - stusum) - Nostu[0];

    for (int i = 0; i < 2; i++){
        cout << Nostu[i] << endl;
    }

    return (0);
}

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

int main(){
  int N;
  long long s=0;
  cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v.at(i);
  }
  int t=v.at(0);
  for (int i=1;i<N;i++){
    if (t < v.at(i)){
      t = v.at(i);
    } else {
      s = s + t - v.at(i);
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
#define dim 100001
long long n,m,x,z,a[dim],s1,s2;
int main()
{
    cin>>n>>m>>x;
    for(int i=1;i<=m;i++){
        cin>>z;
        a[z]=1;
    }
    for(int i=x;i<=n;i++)
        s1+=a[i];
    for(int i=x;i>=1;i--)
        s2+=a[i];
    cout<<min(s1,s2)<<endl;
}


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

typedef vector<int> vi;

int main(){
    int N,T,A;
    double tmp,ans_temp=10000000;
    int ans=0;
    vi H;
    cin >> N >> T >> A;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        if(ans_temp > abs(A - (T - tmp * 0.006)) ){
            ans_temp = abs(A - (T - tmp * 0.006));
            ans = i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char a[105],b[105];
	scanf("%s%s",a,b);
	int i,j;
	int flag=0;
	for(i=0;i<strlen(a);i++)
	{
		int f=0;
		for(j=i;j<i+strlen(b);j++)
		{
			if(j<strlen(b))
			{
				if(b[j]!=a[j-i])
					{f=1;break;}
			}
			else
			{
				if(b[j-strlen(b)]!=a[j-i])
					{f=1;break;}
			}
		}
		if(f==0)
			{printf("Yes");return 0;}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {

  int N;

  cin >> N;

  int divide = N;
  int sum = 0;
  bool flag = false;

  while (divide > 0) {

    if (divide % 10 == 0) {
      divide /= 10;
      if (divide == 1)
        flag = true;
    }

    else {
      sum += divide % 10;
      divide /= 10;
    }
  }

  if (flag == true)
    cout << 10 << endl;
  else
    cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    sc.close();

    char[] ans = new char[S.length()];
    for (int i = 0; i < S.length(); i++) {
      int c = (int) S.charAt(i) - 'A';
      c = (c + N)  % 26;
      ans[i] = (char) ('A' + c);
    }
    System.out.println(new String(ans));
  }
}

Measured memory_bytes: 24404
#!/usr/bin/env python3
def main():
    h = int(input())
    w = int(input())
    n = int(input())
    if h > w:
        h, w = w, h
    for y in range(h):
        n -= w
        if n <= 0:
            break
    print(y + 1)
if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    long long int A,B,N;
    cin >> N >> A >> B;
    if(B<A || N == 1 && A != B){
        cout << "0" << endl;
    }else if(A==B || N==2){
        cout << "1" << endl;
    }else{
        cout << (N-2)*(B-A) +1 << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    int now=1;
    int ans=0;
    rep(i,n){
        int a;
        cin >> a;
        if(a==now){
            now++;
            continue;
        }
        else ans++;
    }

    if(now==1) ans=-1;

    cout << ans << endl;
}

Measured memory_bytes: 256
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

struct req {
    int a;
    int b;
    int c;
    int d;
};

int n, m, q, ans = 0;
vector<req> reqs;
vi cur;

void brute(int at)
{
    if (at == n) {
        int curAns = 0;
        for (auto u : reqs) {
            if (cur[u.b - 1] - cur[u.a - 1] == u.c) {
                curAns += u.d;
            }
        }
        ans = max(ans, curAns);
        return;
    }
    for (int i = cur[at - 1]; i <= m; i++) {
        cur.PB(i);
        brute(at + 1);
        cur.pop_back();
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        req newReq;
        newReq.a = a;
        newReq.b = b;
        newReq.c = c;
        newReq.d = d;
        reqs.PB(newReq);
    }
    for (int i = 1; i <= m; i++) {
        cur.clear();
        cur.PB(i);
        brute(1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3668