akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;
 
typedef long long ll;
 
struct PAIR{
    int a;
    int b;
    int c;
    int d;
};
 
int main() {
    int H,W;
    cin >> H >> W;
    vector< vector<int> > coins(H, vector<int>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> coins[i][j];
        }
    }
    
    vector<PAIR> ans;
    for(int h=0; h<H-1; h++){
        for(int w=0; w<W; w++){
            if(coins[h][w]%2==1){
                coins[h+1][w]++;
                PAIR p={h+1, w+1, h+2, w+1};
                ans.push_back(p);
            }
        }
    }
    for(int w=0; w<W-1; w++){
        if(coins[H-1][w]%2==1){
            coins[H-1][w+1]++;
            PAIR p={H, w+1, H, w+2};
            ans.push_back(p);
        }
    }
    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); i++){
        cout << ans[i].a << ' ' << ans[i].b << ' ' << ans[i].c << ' ' << ans[i].d << endl;
    }
 
    return 0;
}

Measured memory_bytes: 5232
import numpy as np
N = 50
K = int(input())

skip_div = K // N
skip_mod = K % N

a = np.array(range(skip_div, skip_div + N))

for i in range(skip_mod):
	max_index = np.argmin(a)
	add = np.ones(N, dtype = np.int) * -1
	add[max_index] = N
	a += add

print(len(a.tolist()))
print(' '.join(map(str, a.tolist())))

Measured memory_bytes: 21940
n = int(raw_input())
G = [[0 for i in xrange(n)] for j in xrange(n)]

for i in xrange(n):
    data = map(int, raw_input().split())
    u = data[0]-1
    k = data[1]
    for j in xrange(k):
        v = data[j+2]-1
        G[u][v] = 1

for i in xrange(n):
    print " ".join([str(x) for x in G[i]])

Measured memory_bytes: 6464
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, K, X, Y;
    cin >> N >> K >> X >> Y;
    print(min(N, K) * X + max(N - K, 0LL) * Y);

    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
"""考え方
(x, y)と長方形の中心を両方通るような直線で分割すると、大きくない方の面積は全体の半分の面積。

・与えられた(x, y)が長方形の中心の場合、区切り方は無限にある。
・与えられた(x, y)が長方形の中心でない場合、一通りに求まる。
"""
def solve():
    W, H, x, y = list(map(int, input().split()))

    ans_area = W*H/2

    if x == W/2 and y == H/2:
        is_multi = 1
    else:
        is_multi = 0
    
    print(ans_area, is_multi)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
package main

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

func solve() {
	n := getInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		a := getInt()
		m[a]++
	}

	ans := "Yes"
	switch len(m) {
	case 3:
		xor := 0
		cnt := make([]int, 0, 3)
		for a, c := range m {
			xor ^= a
			cnt = append(cnt, c)
		}

		if xor != 0 {
			ans = "No"
			break
		}
		if !(cnt[0] == cnt[1] && cnt[0] == cnt[2]) {
			ans = "No"
			break
		}
	case 2:
		cnt0, cntElse := -1, -1
		for a, c := range m {
			if a == 0 {
				cnt0 = c
			} else {
				cntElse = c
			}
		}

		if cnt0 == -1 {
			ans = "No"
			break
		}
		if cnt0*2 != cntElse {
			ans = "No"
			break
		}
	case 1:
		if _, ok := m[0]; !ok {
			ans = "No"
		}
	default:
		ans = "No"
	}

	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 6912
n, m = map(int, input().split())
A_list = list(map(int, input().split()))
BC_list = []
for _ in range(m):
    BC_list.append(list(map(int, input().split())))
A_list.sort()
BC_list.sort(key=lambda x: x[1], reverse=True)
C_list = []
for i in range(m):
    for _ in range(BC_list[i][0]):
        if len(C_list) < n:
            C_list.append(BC_list[i][1])
        else:
            break
    else:
      continue
    break

for i in range(min(n, len(C_list))):
    if A_list[i] < C_list[i]:
        A_list[i] = C_list[i]
    else:
        break

ans = sum(A_list)
print(ans)

Measured memory_bytes: 87448
#include<bits/stdc++.h>
using namespace std;
string s[105]; 
int n;
int main(){
cin>>n;
for(int i=1;i<=n;i++)cin>>s[i];
for(int i=2;i<=n;i++){
if(s[i][0]!=s[i-1][s[i-1].size()-1])
{ cout<<"No"<<endl;return 0;}
}
for(int i=1;i<n;i++)
for(int j=i+1;j<=n;j++)
{
if(s[i]==s[j]){ cout<<"No"<<endl;return 0;}
}
cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s,t;
cin >> s >> t;
sort(all(s));
sort(rall(t));
cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3640
#%%
x, y = map(int, input().split())
flag = True
a, b = 0, 0
if x > y:
    tmp = x - y
    a += x - y
    x -= tmp * 2
    y -= tmp
elif y > x:
    tmp = y - x
    a += y - x
    y -= tmp * 2
    x -= tmp
else:
    pass
#print(x, y)

if x % 3 != 0:
    flag = False
if x < 0 :
    flag = False
#print(a, b)
a += (x) //3
b += (x) //3

inf = 10 ** 9 + 7

c = 1
d = 1
for i in range(1, a+b+1):
    c *= i
    c %= inf
for i in range(1, a+1):
    d *= i
    d %= inf
for i in range(1, b+1):
    d *= i
    d %= inf

#print(a, b)
#print(c, d)
ans = c * pow(d, inf-2, inf)
ans %= inf

if flag:
    print(ans)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a!=1 and b!=1)
	{
		cout<<1<<endl;
		}	
		else if(a!=2 and b!=2)
			cout<<2<<endl;
			else cout<<3<<endl;
			return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, n;
	int sum;
	double f;
	int i;

	while (scanf("%d %d %d", &a, &b, &n) != EOF){
		a %= b;
		sum = 0;
		for (i = 1; i <= n; i++){
			a *= 10;
			sum += (a / b);
			a %= b;
		}

		printf("%d\n", sum);
	}

	return (0);
}

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

int main()
{
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < S.length(); ++i)
    {
        if (S[i] == T[i])
        {
            continue;
        }

        char c1 = S[i];
        char c2 = T[i];

        for (int j = 0; j < S.length(); ++j)
        {
            bool trans = false;
            if (S[j] == c1)
            {
                S[j] = c2;
                trans = true;
            }
            else if (S[j] == c2)
            {
                S[j] = c1;
                trans = true;
            }

            if (trans && j < i)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 776
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>

//abc158E
int main(void) {


  long long p,n, tmp;
  scanf(" %lld %lld", &n, &p);
  char str[n];
  long long s[n], s10[n]; //剰余がiになる数値の個数、10のi乗の剰余
  long long cou=0, sur[p], i;

  scanf(" %s", str); //scanして1桁ごとに配列へ

  //printf("n=%d p=%d\n", n, p);
  for(i=0; i < n; i++){
    s[i]=((int) str[i]) - 48;
    //printf("%d\n", s[i]);
  }

  if(p == 2 || p == 5){ //2か5の倍数なら最終桁で判断
    for(i=0; i < n; i++)
      if(s[i] % p == 0) cou+=i + 1;
    printf("%lld", cou);
    return 0;
  }

  for(i=0; i < p; i++)
    sur[i]=0;
  //それ以外
  sur[0]++;
  s10[n - 1]=1;
  tmp=s[n - 1] % p;
  sur[tmp]++;

  for(i=n - 2; i >= 0; i--){
    s10[i]=(s10[i + 1] * 10) % p;
    tmp=(s10[i] * s[i] + tmp) % p;
    sur[tmp]++;
  }

  for(i=0; i < p; i++){
    cou+=sur[i] * (sur[i] - 1) / 2;
    //printf("sur[%d]=%d\n", i, sur[i]);
  }
  printf("%lld", cou);
  return 0;

}


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

using namespace std;

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

	if (a == b && b == c && a==c) {
		cout << 1 << endl;
	}
	else if (a != b && b != c && a != c) {
		cout << 3 << endl;
	}
	else {
		cout << 2 << endl;
	}

	return 0;
}

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

using namespace std;

const int maxn=1e5+5;

typedef long long ll;

const ll mod=1e9+7;

ll a[maxn];
ll inv[maxn];

ll qPow(ll a,int b){
	ll ans=1;
	while(b){
		if(b&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",a+i);
	}
	sort(a+1,a+1+n);
	
	for(int i=1;i<=n;i++){
		inv[i]=qPow(i,mod-2);
	}
	
	ll ans=a[k];ll p=1;
	for(int i=k+1;i<=n;i++){
		p=(p*(i-1))%mod;
		p=(p*inv[i-k])%mod;
		ans=(ans+a[i]*p%mod)%mod;
	}
	ans=(ans+mod-a[n-k+1])%mod;
	p=1;
	for(int i=k+1;i<=n;i++){
		p=(p*(i-1))%mod;
		p=(p*inv[i-k])%mod;
		ans=(ans+mod-a[n-i+1]*p%mod)%mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
# Here your code !

line = input().strip().split(" ")

if int(line[0]) <= int(line[1]):
    if int(line[1]) <= int(line[2]):
        print(line[0] + " " + line[1] + " " + line[2])
    elif int(line[2]) < int(line[1]):
        if int(line[0]) <= int(line[2]):
            print(line[0] + " " + line[2] + " " + line[1])
        else:
            print(line[2] + " " + line[0] + " " + line[1])

elif int(line[1]) < int(line[0]):
    if int(line[0]) <= int(line[2]):
        print(line[1] + " " + line[0] + " " + line[2])
    else:
        if int(line[2]) <= int(line[1]):
            print(line[2] + " " + line[1] + " " + line[0])
        else:
            print(line[1] + " " + line[2] + " " + line[0])

Measured memory_bytes: 7740
#include <bits/stdc++.h>
using namespace std;
int main() {
    char ch;
    while(1){
        scanf("%c", &ch);
        if( ch == '\n' ) {
            cout << endl;
            break;
        }
        else if( 'a' <= ch && ch <= 'z' ) {
            ch -= 32;
        }
        else if( 'A' <= ch && ch <= 'Z' ) {
            ch += 32;
        }
        printf("%c", ch);
    }
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll N, C;
ll left1[110000], right1[110000];
ll left2[110000], right2[110000];
ll x[110000], v[110000];

int main(){
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        cin >> v[i] >> x[i];
    }
    ll ma = 0LL, x_sum = 0LL, ma2 = 0LL;
    for(int i = 0; i < N; i++){
        x_sum += x[i];
        ma = max(x_sum - v[i], ma);
        ma2 = max(x_sum - 2*v[i], ma2);
        left1[i] = ma;
        left2[i] = ma2;
    }

    ma = 0LL;
    ma2 = 0LL;
    x_sum = 0LL;
    for(int i = N-1; i >= 0; i--){
        x_sum += x[i];
        ma = max(x_sum - (C - v[i]), ma);
        ma2 = max(x_sum - 2*(C - v[i]), ma2);
        right1[i] = ma;
        right2[i] = ma2;
    }

    ll res = 0;
    for(int i = 0; i < N; i++){
        res = max(left1[i], res);
        res = max(right1[i], res);
    }
    for(int i = 0; i < N-1; i++){
        res = max(left1[i] + right2[i+1], res);
        res = max(left2[i] + right1[i+1], res);
    }

    cout << res << endl;


    return 0;

}



Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int mod= 998244353;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int sa=0;
  rep(i,n)sa+=a[i];
  int l=sa/2;
  vector<int>dp(l+1,0),dp2;
  dp[0]=1;
  dp2=dp;
  rep(i,n)
  {
    for(int j=l-a[i];j>=0;j--)
    {
      dp[j+a[i]]+=(ll)dp[j]*2%mod;
      dp[j+a[i]]%=mod;
      dp2[j+a[i]]+=dp2[j];
      dp2[j+a[i]]%=mod;
    }
  }
  ll res=modpow(3,n,mod);
  rep(i,l+1)dp[i]=(ll)dp[i]*3%mod;
  for(auto i:dp){res+=mod-i;res%=mod;}
  if(!(sa&1))res+=(ll)dp2.back()*3;
  cout<<res%mod<<endl;


  return 0;

}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
    int N, M;
    int result = 0;

    cin >> N >> M;
    if(N != 0){
        result += (N * (N - 1) /2);
    }
    if (M != 0)
    {
        result += (M * (M - 1) / 2);
    }

    cout << result << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)if(i%2==0)cout<<s[i];
  cout<<endl;
  return 0;
}


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

int main() {
    string s;
    int n;
    cin >> s;
    n      = s.size();
    ll ans = 0;
    rep(i, 1 << (n - 1)) {
        ll sum = 0;
        ll a   = s[0] - '0';
        rep(j, n - 1) {
            if(i & (1 << j)) {
                sum += a;
                a = 0;
            }
            a = a * 10 + s[j + 1] - '0';
        }
        sum += a;
        ans += sum;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn = 2010;
int n, a[maxn], degree[maxn];
bool mp[maxn][maxn], vis[maxn];
vector <int> edge[maxn];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

void dfs(int u) {
    vis[u] = 1;
    for(int i = 1; i <= n; i++) 
        if(mp[u][i] && !vis[i]) dfs(i), edge[u].push_back(i), degree[i]++;
}

void toposort() {
    priority_queue <int> pq;
    for(int i = 1; i <= n; i++)
        if(degree[i] == 0) pq.push(i);
    while(!pq.empty()) {
        int u = pq.top();
        pq.pop();
        printf("%d ", a[u]);
        for(int i = 0; i < (int)edge[u].size(); i++) pq.push(edge[u][i]);
    }
}

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    for(int i = 1; i < n; i++)
        for(int j = i + 1; j <= n; j++)
            if(gcd(a[i], a[j]) != 1) mp[i][j] = mp[j][i] = 1;
    for(int i = 1; i <= n; i++)
        if(!vis[i]) dfs(i);
    toposort();
    return 0;
}

Measured memory_bytes: 4480
import java.util.Scanner

fun main(args : Array<String>) {
        val scn = Scanner(System.`in`)
        val N = scn.nextInt()
        val M = scn.nextInt()

        var L = Int.MIN_VALUE
        var R = Int.MAX_VALUE

        for (i in 1..M) {
                val lm = scn.nextInt()
                val rm = scn.nextInt()
                L = if (L < lm) lm else L
                R = if (rm < R) rm else R
        }
        val ans = R - L + 1
        if (ans > 0) {
                println(ans)
        }
        else {
                println(0)
        }
}


Measured memory_bytes: 71056
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    s[3] = '8';

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;


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


    if( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ) cout << "vowel" << endl;
    else cout << "consonant" << endl;


    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()
print(sum(bisect_left(A, i) * (N - bisect_right(C, i)) for i in B))


Measured memory_bytes: 23360
n, k, q = gets.split.map(&:to_i)
a_arr = q.times.map{gets.to_i}

answers = Array.new(n){0}

a_arr.each do |a|
  answers[a-1] += 1
end

answers.each do |ans|
  if k - q + ans >=1
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 6196
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;

namespace ABC126B
{
    static class Program
    {
        static void Main(string[] args)
        {
            var s = Regex.Split(ReadLine(), @"(?<=\G.{2})(?!$)").Select(x => int.Parse(x)).ToList();
            var a = "";


            if (s[0] <= 0 && s[1] <= 0)
            {
                a = "NA";
            }
            else
            {
                if ((s[0] <= 12 && s[1] != 0 && s[0] > 0) && (s[1] <= 12 && s[0] != 0 && s[1] > 0))
                {
                    a = "AMBIGUOUS";
                }
                else if(s[0] <= 12 && s[0] > 0)
                {
                    a = "MMYY";
                }
                else if(s[1] <= 12 && s[1] > 0)
                {
                    a = "YYMM";
                }
                else
                {
                    a = "NA";
                }
            }
            WriteLine(a);

        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


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

int main()
{
  int n;
  cin>>n;
  int x=n;
  if(n%2==0)
    x--;
  
  int term=((x-1)/2)+1;
  double prob=(double)term/(double)n;
  cout<<fixed<<setprecision(10)<<prob<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int q = Integer.parseInt(scan.next());

        SegTree st = new SegTree(n);

        for (int i = 0; i < q; i++) {
            int com = Integer.parseInt(scan.next());
            int x = Integer.parseInt(scan.next());
            int y = Integer.parseInt(scan.next());
            if (com == 0) {
                st.update(x, y);
            } else {
                System.out.println(st.find(x, y + 1));
            }
        }
        scan.close();
    }

    static class SegTree {
        int size = 1;
        int[] node;

        public SegTree(int n) {
            while (size < n) {
                size *= 2;
            }
            node = new int[2 * size];
            for (int i = 0; i < 2 * size; i++) {
                node[i] = Integer.MAX_VALUE;
            }
        }

        public void update(int i, int x) {
            int index = i + size - 1;
            node[index] = x;
            while (index > 0) {
                index = (index - 1) / 2;
                node[index] = Math.min(node[2 * index + 1], node[2 * index + 2]);
            }
        }

        public int find(int s, int t) {
            return find(s, t, 0, 0, size);
        }

        private int find(int s, int t, int i, int left, int right) {
            if (t <= left || right <= s) {
                return Integer.MAX_VALUE;
            }
            if (s <= left && right <= t) {
                return node[i];
            }

            int l = find(s, t, 2 * i + 1, left, (left + right) / 2);
            int r = find(s, t, 2 * i + 2, (left + right) / 2, right);
            return Math.min(l, r);
        }
    }

}



Measured memory_bytes: 72352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	
    	int N = sc.nextInt(), ans = 0;
    	
    	for(int i = 1; i <= N; i++)	ans += i;
    	
    	System.out.println(ans);
    }
}

Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    rep(i,n+1){
        rep(j,m+1){
            if((n-i)*j+(m-j)*i==k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    int c = scanner.nextInt();
		    
		    if( a == b ) 
		    {
		    	System.out.println(c);
		    }
		    else 
		    {
		    	if( b == c ) 
		    	{
		    		System.out.println(a);
		    	}
		    	else 
		    	{
		    		System.out.println(b);
		    	}
		    }
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long

using namespace std;



int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    ll x, y;
    ios::sync_with_stdio(false);
    cin >> x >> y;
    ll cnt = 0, val = x;
    while(val <= y) {
        cnt++;
        val *= 2;
    }
    cout << cnt;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s.substr(i, 3) == "ABC") {
            res++;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

template <typename T> void max_self(T& a, T b) {
    a = max(a, b);
}

// dp[n][m]

bool first_row_or_column(pair<int,int> p) {
    return p.first == 0 || p.second == 0;
}

const int INF = 1e9 + 5;

int main() {
    string a, b;
    cin >> a >> b;
    vector<vector<pair<int,pair<int,int>>>> dp(a.length() + 1,
        vector<pair<int,pair<int,int>>>(b.length() + 1, {-INF,{0,0}}));
    dp[0][0] = {0, {0,0}};
    // dp[i][j] - the max total length so far
    for(int i = 0; i < (int) a.length(); ++i) {
        for(int j = 0; j < (int) b.length(); ++j) {
            if(a[i] == b[j]) {
                max_self(dp[i+1][j+1], make_pair(dp[i][j].first + 1, make_pair(i,j)));
            }
            max_self(dp[i+1][j], make_pair(dp[i][j].first, make_pair(i,j)));
            max_self(dp[i][j+1], make_pair(dp[i][j].first, make_pair(i,j)));
        }
    }
    pair<int,pair<int,int>> answer = {0,{0,0}};
    for(int i = 0; i <= (int) a.length(); ++i) {
        for(int j = 0; j <= (int) b.length(); ++j) {
            max_self(answer, make_pair(dp[i][j].first, make_pair(i, j)));
        }
    }
    string s;
    pair<int,int> cur = answer.second;
    while(!first_row_or_column(cur)) {
        int i = cur.first;
        int j = cur.second;
        pair<int,int> previous = dp[i][j].second; // a cell from which we came to (i,j)
        debug() << imie(cur) imie(previous);
        if(previous == make_pair(i - 1, j - 1)) {
            assert(a[i-1] == b[j-1]);
            s += a[i-1];
        }
        cur = previous;
    }
    //~ debug() << answer;
    reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 105984
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;


int main() {
    ll N;
    cin >> N;

    ll minDigit=100;
    for(ll A=1; A*A<=N; A++) {
        if(N%A) continue;
        ll B=N/A;
        ll maxDigit = (log10(A)>log10(B))?log10(A)+1:log10(B)+1;
        minDigit = (maxDigit>minDigit) ?minDigit : maxDigit;
    }
    cout << minDigit << endl;

    return 0;
}



Measured memory_bytes: 256
h, w, k = gets.split.map(&:to_i)
ary = []
h.times{
  ary << gets.chomp.split(//)
}

h_ary = []
w_ary = []
[0,1].repeated_permutation(h) do |i|
  h_ary << i
end
[0,1].repeated_permutation(w) do |i|
  w_ary << i
end

tmp = Marshal.load(Marshal.dump(ary))

ans = 0
h_ary.length.times do |i|
  w_ary.length.times do |j|
    h_ary[i].length.times do |k|
      if h_ary[i][k] == 1
        tmp[k].fill("*")
      end
    end
    w_ary[j].length.times do |l|
      if w_ary[j][l] == 1
        tmp.length.times do |m|
          tmp[m][l] = "*"
        end
      end
    end
    if tmp.flatten.count("#") == k
      ans += 1
    end
    tmp = Marshal.load(Marshal.dump(ary))
  end
end
p ans

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

using namespace std;

#define ll long long
#define sf scanf
#define pf printf 
#define nl printf("\n")
#define pi acos(-1)

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif

    double r;
    sf("%lf",&r);
    pf("%lf\n",(2*pi*r));
    return 0;
}

Measured memory_bytes: 3824
N, K = map(int, input().split())
N = N + K
mod = 10 ** 9 + 7
P = [[0] * (K + 1) for i in range(N + 1)]
for i in range(1, N + 1):
	P[i][1] = 1
for i in range(1, min(N, K) + 1):
	P[i][i] = 1
for n in range(1, N + 1):
	for k in range(2, min(n - 1, K) + 1):
		P[n][k] = (P[n - k][k] + P[n - 1][k - 1]) % mod
print(P[N][K])


Measured memory_bytes: 68440
#include <bits/stdc++.h>
using namespace std;
typedef string str;
int main(){
  //definition
  int N,K,Q,i,j; cin >> N >> K >> Q;
  vector<int> A(N), B(Q);
  //input 
  for(i=0;i<Q;++i){
    cin >> B[i];
  }
  for(i=0;i<N;++i){
    A[i] = K-Q;
  }
  //calc
  for(i=0;i<Q;++i){
    A[B[i]-1] = A[B[i]-1]+1;
  }
  //output answer
  for(i=0;i<N;++i){
    if(A[i]<=0){
      cout << "No" << '\n';
    }
    else{
      cout << "Yes" << '\n';
    }
  }
  return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    int high_max = 0;
    rep(i, n) high_max = max(high_max, h[i]);
    bool cont;
    int cnt = 0;
    rep(i, high_max)
    {
        int top = high_max - i;
        cont = false;
        rep(j, n)
        {
            if(h[j]==top){
                if(!cont){
                    cnt++;
                    cont = true;
                }
                h[j]--;
            }else{
                cont = false;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define ll long long
#define ld long double
using namespace std;

int main() {
    ll w,a,b;
    cin >> w >> a >> b;
    ll answ = 0;
    if (a + w < b) answ = b - (a+w);
    else
        answ = a - (b+w);
    cout << (answ < 0 ? 0 : answ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int L, R, d;
  cin >> L >> R >> d;
  L--;
  cout << R / d - L / d << endl;
  return 0;
}


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

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int INF = 1e9;

using namespace std;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int K; cin >> K;
    string ACL = "ACL";
    string s = "";
    for(int i = 0; i < K; i++) s+=ACL;    
    cout << s; 

    return 0;

}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        sum+=i;

    }
    cout<<sum;
    return 0;
}


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

int main() {
    int N,K; cin >> N >> K;
    int ans = 1;
    int temp = K;
    while(true){
        if(N < temp){
            cout << ans << endl;
            return 0;
        }
        else{
            temp *= K;
            ans++;
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int a, b, c, d;
	a = N % 10;
	b = (N % 100 - a) / 10;
	c = (N % 1000 - (a + b)) / 100;
	d = N / 1000;
	//cout << d << c << b << a << endl;

	if (((a == b) && (a == c) && (b == c)) ||
		((b == c) && (b == d) && (c == d))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
from itertools import accumulate

n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]

num = [0] * (n + 1)
for l, r in lr:
    num[l - 1] += 1
    num[r] -= 1
num = list(accumulate(num))
print(num.count(m))


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

using namespace std;
int main ()
{
    int N,T;
    int c[1010];
    int t[1010];
    cin >> N >> T;
    for(int i=0;i<N;i++){
        cin >> c[i] >> t[i];
    }
    int cost=10000;
    for(int i=0;i<N;i++){
        if(t[i]<=T)cost=min(cost,c[i]);
    }
    if(cost==10000)cout << "TLE" << endl;
    else cout << cost << endl;
    return 0;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
llong k,s;
int main(){ _;
  cin>>k>>s;
  llong ans=0;
  REP(x,k+1)
    REP(y,k+1)
    if(s-(x+y)>=0 && s-(x+y)<=k)
      ++ans;
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 55 + 3;
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	int n, m, cur = 1, res = 0;
	scanf("%d %d", &n, &m);
	while (cur < m) {
		cur += n - 1;
		++res;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		
		int[][] table = new int[r+1][c+1];
		for(int i=0; i<r+1; i++) {
			int sum_c = 0;
			for(int j=0; j<c+1; j++) {
				if(i != r && j != c) {
					table[i][j] = sc.nextInt();
					sum_c += table[i][j];
					System.out.print(table[i][j] + " ");
				} else if(j == c) {
					table[i][j] = sum_c;
					System.out.println(table[i][j]);
				} else {
					int sum_r = 0;
					for(int k=0; k<r; k++){
						sum_r += table[k][j];
					}
					table[i][j] = sum_r;
					sum_c += table[i][j];
					System.out.print(table[i][j] + " ");
				}
			}
		}
	}

}

Measured memory_bytes: 41004
import itertools 
n = int(input())
a = []
shogen =[]
for i in range(n):
    a.append(int(input()))
    temp = []
    for j in range(a[i]):
        x,y = map(int,input().split())
        temp.append([x,y])
        
    shogen.append(temp)

pattern = list(itertools.product([0,1], repeat = n))
result = 0

#print('a',a)
#print('shogen',shogen)
for i in range(len(pattern)):
    flg = True
    check = [-1 for _ in range(n)]
    #j人目について考える
    for j in range(n):
        #正直者のとき
        if pattern[i][j] == 1:
            #全ての証言について考える
            for k in range(a[j]):
                #checkが更新されていないとき
                if check[shogen[j][k][0]-1] == -1:
                    check[shogen[j][k][0]-1] = shogen[j][k][1]
                else:
                    if check[shogen[j][k][0]-1] != shogen[j][k][1]:
                        flg = False
                        #print('break') 
                        break


    for l in range(n):
        if (pattern[i][l] == 1 and check[l] == 0) or (pattern[i][l] == 0 and check[l] == 1):
            flg = False
            break

    if flg:
        #print('pattern',pattern[i])
        result = max(result, sum(pattern[i]))

print(result)





Measured memory_bytes: 14452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
    ll n,i,x,y,s=1e9+5;
    cin>>n;
    ll a[n+1],b[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>x>>y;
        a[i]=x+y;b[i]=(s-x)+y;
    }
    sort(a+1,a+n+1);sort(b+1,b+n+1);
    ll ans=max(a[n]-a[1],b[n]-b[1]);
    cout<<ans<<endl;
}


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
//ll chose(ll n,ll k){ll r=fact[n]%md;r=(r+md)%md;r=r*inv[k]%md;r=(r+md)%md;r=r*inv[n-k]%md;r=(r+md)%md;return r;}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	//ll x;cin>>x;
	vl v;
	//cout<<pow(150,5)-pow(149,5);
	rep(i,0,151) v.pb(binpow(i,5));
	
	//cout<<"hi\n";
	//cout<<v.size();
	map<ll,pll> m;
	///*
	rep(i,0,149){
		for (ll j = i+1; j < 151; j += 1)
		{
			//db2(i,j);
			m[v[j]+v[i]]={j,-i};
			m[v[j]-v[i]]={j,i};
		}
	}
	//*/
	ll x;cin>>x;
	cout<<m[x].fi<<" "<<m[x].se<<endl;
	//cout<<v.size();
return 0;
}
/*

(a-b)(a4+a3b+a2b2+
*/


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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

struct r {
	ll num;
	ll index;
};

bool f(r a, r b) {
	return a.num < b.num;
}

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;
	vector<r> a(n);

	rep(i, n) {
		a.at(i).index = i + 1;
		cin >> a.at(i).num;
	}

	sort(a.begin(), a.end(), f);

	cout << a.at(0).index;
	repd(i, 1, n) {
		cout << " " << a.at(i).index;
	}

	return 0;
}


Measured memory_bytes: 2432
n, m = map(int, input().split())
X = [int(i) for i in input().split()]
X = sorted(X)
L = []
for i in range(1, m):
    L.append(X[i] - X[i - 1])
L = sorted(L)
if n >= m:
    print(0)
else:
    print(sum(L[0:m-n]))

Measured memory_bytes: 13832
import bisect
A, B, Q = map(int, input().split())
INF = float("inf")
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]

for q in range(Q):
    x = int(input())
    ans = INF
    a_i = bisect.bisect_right(s, x)
    b_i = bisect.bisect_right(t, x)
    for a in [s[a_i], s[a_i - 1]]:
        for b in [t[b_i], t[b_i - 1]]:
            ans = min(ans, abs(x - a) + abs(b - a), abs(x - b) + abs(b - a))
    print(ans)


Measured memory_bytes: 14612
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,m; cin>>n>>m;
	map <int, bool> mymap;
	for (int i = 0; i < m; ++i)
	{
		int a,b; cin>>a>>b;
		if(a == 1 || a == n){
			if(mymap.count(b))
			{
				cout<<"POSSIBLE\n"; return 0;
			}
			mymap[b] = true;
		}
		else if(b == 1 || b == n){
			if(mymap.count(a))
			{
				cout<<"POSSIBLE\n"; return 0;
			}
			mymap[a] = true;
		}
	}
	cout<<"IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
 
 int a,b,c;
  cin >> a >> b >> c;
 if(a==b&&b==c||a!=b&&b!=c&&c!=a){
 	cout << "No" << endl;
 }else{
 	cout << "Yes" << endl;
 }
}

Measured memory_bytes: 256
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <queue>  
#include <iostream>  
#include <string>  
#include <cmath>  
#include <vector>  
#include <set>  
#include <map>  
#include <bitset>  
#include <stack>  
using namespace std;  
  
#define REP(i,n) for ( int i=1; i<=int(n); i++ )    
#define MP make_pair  
#define PB push_back  
#define SZ(x) (int((x).size()))  
#define ALL(x) (x).begin(), (x).end()  
#define X first  
#define Y second  
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }  
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }  
  
typedef long long LL;  
typedef long double LD;  
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;

const int N = 2e4 + 10;
int a[N], b[N];
int main() {
	int n;
	cin >> n;
	int lst = 0;
	for(int i = 1; i <= n; i ++) a[i] = a[i - 1] + N;
	for(int i = 1; i <= n; i ++) b[i] = a[n - i + 1];
	for(int i = 1; i <= n; i ++) {
		int x;
		scanf("%d", &x);
		a[x] += i;
	}
	for(int i = 1; i <= n; i ++) printf("%d%c", a[i], i == n ? '\n' :' ' );
	for(int i = 1; i <= n; i ++) printf("%d%c", b[i], i == n ? '\n' : ' ');
}



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

vector<ll> prime_factorize(ll N) {
  vector<ll> res;
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    ll ex = 0; // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    // その結果をpush
    res.push_back(a);
  }

  // 最後に残った数について
  if (N != 1) res.push_back(N);
  return res;
}


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

  vector<ll> ret = prime_factorize(n);

  ll cnt = 0;
  for(auto v : ret) {
    ll _v = v;
    while(n % _v == 0) {
      n /= _v;
      _v *= v;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
typedef int _int;
#define int long long
int n,q,k,ans,cntd,cntm,cnts;char a[N];
_int main(){
    cin>>n>>a+1>>q;
    while(q--){
        ans=0;cin>>k;cntd=cntm=cnts=0;
        for(int i=1;i<=n;++i){
            if(a[i]=='D'){
                ++cntd;
            }if(a[i]=='M'){
                ++cntm;
                cnts+=cntd;
            }if(a[i]=='C')ans+=cnts;
            int j=i-k+1;
            if(j>0){
                if(a[j]=='D'){
                    --cntd;
                    cnts-=cntm;
                }if(a[j]=='M'){
                    --cntm;
                }
            }
        }cout<<ans<<"\n";
    }return 0;
}

Measured memory_bytes: 1280