akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        a: [usize; 2],
    }
    let mut mul = a[1];
    for i in 1..a[0]{
        mul *= (a[1]-1);
    }
    println!("{}", mul );
}


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

int main() {
	int n, k, sum = 0;
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {cin >> v.at(i);}
	sort(v.begin(), v.end(), greater<int>());
	for (int i = 0; i < k; i++) {sum += v.at(i);}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A+1); rep(i,A) cin >> p[i];
  vector<ll> q(B+1); rep(i,B) cin >> q[i];
  vector<ll> r(C); rep(i,C) cin >> r[i];
  p[A]=1e9+100;
  q[B]=1e9+100;
  sort(rall(p));
  sort(rall(q));
  sort(rall(r));
  int idp,idq;
  idp=X;
  idq=Y;
  ll ans = 0;
  rep(idr, C){
    if(p[idp]>r[idr] && q[idq]>r[idr]){
      break;
    }
    if(p[idp]>q[idq]){
      if(q[idq]<r[idr]){
        idq--;
        ans += r[idr];
      }
    }
    else{
      if(p[idp]<r[idr]){
        idp--;
        ans += r[idr];
      }
    }
  }
  rep(i,idp+1){
    if(i==0) continue;
    ans += p[i];
  }
  rep(i,idq+1){
    if(i==0) continue;
    ans += q[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

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

	    int a=gi();
	    int b=gi();
	    int c=gi();
	    int d=gi();

        System.out.println(Math.min(a, b)+Math.min(c, d));
//        if (a+b>=c) {
//        	System.out.print("Yes");
//        }else {
//        	System.out.print("No");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35660
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int l = 0;
  while(s[l] != 'A')l++;
  int r = s.size() - 1;
  while(s[r] != 'Z')r--;
  cout << r - l + 1 << endl;
	return 0;
}


Measured memory_bytes: 640
N = int(input())
L = list(map(int,input().split()))
L.sort()
def Ju(x,y,z):
    if x + y > z:
        if x != y and y != z and z != x :
            return 0
        else:
            return 1
    else:
        return 1
A = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1, N):
            if Ju(L[i],L[j],L[k]) == 0:
                A += 1
print(A)
               

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

int main()
{
  int n;
  cin >> n;
  int max_combo = 0;
  int combo = 0;
  
  int prev;
  cin >> prev;
  int tmp;
  for (int i = 1; i < n; i ++)
  {
    cin >> tmp;
    if (prev >= tmp)
    {
      combo ++;
      if (combo > max_combo) max_combo = combo;
    }
    else combo = 0;
    prev = tmp;
  }
  
  cout << max_combo;
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define int ll
#define INF (ll)1e18
#define maxn 100001

ll A,B,C,D;

int32_t main()
{
	cin>>A>>B>>C>>D;
	
	cout<<max({A*C,A*D,B*C,B*D});
}


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

#define min(a,b) ((a)<(b)?(a):(b))

map<string, int> item;
map<string, vector<string> > recipe;

int get_lowest_price(string name) {
    if (recipe.find(name) == recipe.end()) {
        return item[name];
    }
    vector<string> m = recipe[name];
    int mat_price = 0;
    for (vector<string>::iterator e = m.begin(); e != m.end(); e++) {
        mat_price += get_lowest_price(*e);
    }
    return min(item[name], mat_price);
}

int main() {
    string name;
    int price, i, n, m;

    while ((cin >> n) && n) {
        item.clear();
        for (i = 0; i < n; i++) {
            cin >> name >> price;
            item[name] = price;
        }

        cin >> m;
        recipe.clear();
        for (i = 0; i < m; i++) {
            vector<string> material;
            int k;
            cin >> name >> k;
            while (k--) {
                string itm;
                cin >> itm;
                material.push_back(itm);
            }
            recipe[name] = material;
        }
        cin >> name;
        cout << get_lowest_price(name) << endl;

    }
    return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		Long A = scan.nextLong();
		Long V = scan.nextLong();
		Long B = scan.nextLong();
		Long W = scan.nextLong();
		Long T = scan.nextLong();

		Long x = B-A;
		if(x<0) {
			x = x*(-1L);
		}

		if(V>W) {
			if(x <= (V-W)*T) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 35216
#include<bits/stdc++.h>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define f(i,a,b) for(int i=a;i<=b;i++)

using namespace std;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef set<int> si;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int k;
	cin >> k;
	double kk = (double)k/2;
	int a = ceil(kk);
	int b = floor(kk);
	cout << a * b << endl;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
	long long int n;
	long long int a[200005];
	long long f(long long b)
	{
		long long int s=0;
		for(int i=0;i<n;i++)
		{
			s+= abs(a[i]-(b+i+1));
		}
		return s;
	}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
 
	cin>>n;
 
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	//cout<<abs(*max_element(a,a+n)-*min_element(a,a+n))<<endl;
	long long l=-1000000000,r=1000000000,m,res,v1,v2,v3;
	while(l<=r)
	{
		m= (l+r)/2;
		v1 = f(m-1);
		v2= f(m);
		v3 = f(m+1);
		if(v2<=v1 && v2<=v3)
            {
                res = m;
                break;
            }
            if(v2<=v1 && v3<=v2)
            {
                l=m+1;
            }
            else
            if(v1<=v2 && v2<=v3)
            {
                r=m-1;
            }
	}
	/*
	for(int b=-100;b<=100;b++)
	{
		cout<<b<<" ";
		int s=0;
		for(int i=0;i<n;i++)
		{
			s+= abs(a[i]-(b+i+1));
		}
		cout<<s<<endl;
	}
	*/
	cout<<f(res)<<endl;
    return 0;
}

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

using namespace::std;

int main(void){
  string input;
  string target;
  string res;

  int cnt=0;

  cin >> input;
  cin >> target;

  while(true){
    if(input == target){
      res = "Yes";
      break;
    }

    if(cnt > input.size()){
      res = "No";
      break;
    }

    rotate(input.rbegin(),input.rbegin()+1,input.rend());
    cnt++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first.first
#define y first.second
#define z second.first
#define v second.second
using namespace std;
int n,m,a[3000][3000],ans;
vector <int> g[3000],h[3000];
int ss[3000][3000];
main(){
cin>>n>>m;
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++){
    char ch;
    cin>>ch;
    if(ch=='.')
        a[k][i]=1;
}
for(int k=1;k<=n;k++)
    g[k].push_back(0);
for(int k=1;k<=m;k++)
    h[k].push_back(0);
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++){
    if(a[k][i]==0)
    {
        g[k].push_back(i);
        h[i].push_back(k);
    }
}
for(int k=1;k<=n;k++)
    g[k].push_back(m+1);
for(int k=1;k<=m;k++)
    h[k].push_back(n+1);
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++){
        if(a[k][i]!=0){
vector<int>::iterator it1,it2;
int a1=0,b1=0,c1=0,d1=0;
it1=lower_bound(g[k].begin(),g[k].end(),i);
it2=lower_bound(h[i].begin(),h[i].end(),k);
a1=*it1;
b1=*it2;
it1--;
it2--;
c1=*it1;
d1=*it2;
ss[k][i]=(a1-c1)+(b1-d1)-3;

}
}
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++)
ans=max(ans,ss[k][i]);
cout<<ans;
return 0;
}


Measured memory_bytes: 162560
#include <stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==1){a=14;}
    if(b==1){b=14;}
  if(a>b){printf("Alice\n");}
  else if(a<b){printf("Bob\n");}
  else {printf("Draw\n");}
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("C.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,d = 0;
    cin >> a >> b;
    while(a<=b){       
        a *= 2;
        d++;     
    }
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 384
# https://atcoder.jp/contests/abc088/tasks/abc088_c
# C - Takahashi's Information

c_matrix = []
for _ in range(3):
    c_list = list(map(int, input().split()))
    c_matrix.append(c_list)

a_matrix = []
a_list = []
b_list = []
a_list.append(0) # a1
b_list.append(c_matrix[0][0])
b_list.append(c_matrix[0][1])
b_list.append(c_matrix[0][2])
a_list.append(c_matrix[1][0] - b_list[0])
a_list.append(c_matrix[2][0] - b_list[0])

is_ok = True

for i in range(3):
    for j in range(3):
        if a_list[i] + b_list[j] != c_matrix[i][j]:
            is_ok = False
            break

    if not is_ok:
        break

ans = 'Yes' if is_ok else 'No'
print(ans)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int height = Integer.parseInt(sc.next());
    int width = Integer.parseInt(sc.next());
    System.out.println((height * width) + " " + (2 * height + 2 * width));
  }
}


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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;
const int modulo = 1e9 + 7;
template<typename T>
inline T sum(const T& a, const T& b) { return T((a % modulo + b % modulo) % modulo); }
template<typename T>
inline T mul(const T& a, const T& b) { return T((1LL * (a % (1LL * modulo)) * (b % (1LL * modulo))) % (1LL * modulo)); }
string to_string(string a) { return "\"" + a + "\""; }
#ifdef __LOCAL_DEBUG
#define debug(args...) { string __out = #args; replace(__out.begin(), __out.end(), ',', ' '); stringstream __out_ss(__out);\
istream_iterator<string> __it(__out_ss); _debug(__it, args); }
void _debug(istream_iterator<string> it) { }
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T a, Args... args){ cerr << *it << " = " << to_string(a) << '\n'; _debug(++it, args...); }
#else
#define debug(...)
#endif

const int N = 1e5 + 5;
char s[N];
int n, k;
struct elm {
  int l, r, t;
  elm(int _l = 0, int _r = 0, int _t = 0) { l = _l; r = _r; t = _t; }
};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> s + 1;
  vector<elm> f;
  for (int i = 1; i <= n;) {
    int j = i;
    while (j <= n && s[j] == s[i]) ++j;
    f.push_back(elm(i, j - 1, s[i] - '0'));
    i = j;
  }
  int ans = 0, a = 0, b = 0, tmp = 0;
  while (b < int(f.size())) {
    if (f[b].t == 0) tmp++;
    while (tmp > k) { if (f[a].t == 0) tmp--; a++; }
    ans = max(ans, f[b].r - f[a].l + 1);
    b++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 2040
#include<iostream>
using namespace std;
int main() {
    int n, m, l;
    cin >> n >> m >> l;
    int A[n][m], B[m][l];
    long long int C[n][l];
    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            cin >> A[i][j];
        }
    }
    for (int i=0; i<m; i++){
        for (int j=0; j<l; j++){
            cin >> B[i][j];
        }
    }
    for (int i=0; i<n; i++){
        for (int j=0; j<l; j++){
            C[i][j] = 0;
        }
    }
    for (int i=0; i<n; i++){
        for (int j=0; j<l; j++){
            for (int k=0; k<m; k++){
                C[i][j] += A[i][k]*B[k][j];
            }
            if (j == l-1) cout << C[i][j] << endl;
            else cout << C[i][j] << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 3216
import sys
def input(): return sys.stdin.readline().strip()
offset = 2500

def main():
    N, A = map(int, input().split())
    X = list(map(int, input().split()))
    for i in range(N): X[i] -= A
    dp = [0] * 5010
    dp[offset] += 1
    dp[X[0] + offset] += 1
    for i, x in enumerate(X):
        if i == 0: continue
        dp2 = [0] * 5010
        for j in range(5010):
            if j < x or j - x >= 5010:
                dp2[j] = dp[j]
            else:
                dp2[j] = dp[j] + dp[j - x]
        dp = dp2
        #print(dp[offset - 3: offset + 4])
    print(dp[offset] - 1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 66136
local mod = 1000000007
local function badd(x, y) return (x + y) % mod end
local function bmul(x, y) return (x * y) % mod end
local s = io.read()
local max, normal = 1, 0
for i = 1, #s do
  local v = s:byte(i) - 48
  if v == 1 then
    max, normal = bmul(max, 2), badd(max, bmul(normal, 3))
  else
    max, normal = max, bmul(normal, 3)
  end
end
print(badd(max, normal))


Measured memory_bytes: 2648
#include<bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
using namespace std;
int main()
{
    FLASH
    ll n,k,d;
    cin >> n >> k;
    map<ll,ll> mp;
    ll m,x;
    for(int i = 0; i < k ;i++)
    {
        cin >> m;
        while(m--)
        {
            cin >> x;
            mp[x]++;
        }
    }
    ll cnt =0;
    for(int i = 1;i <=  n;i++)
    {
        if(mp[i] == 0)
            cnt++;
    }
    cout << cnt;
    return 0;
}



Measured memory_bytes: 3648
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

#define MAX 3000000
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	COMinit();
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	long long X, Y;
	cin >> X >> Y;
	//3m = 2X - Y  //  m = (2X - Y) / 3
	//3n = -X + 2Y //  n = (2Y - X) / 3
	long long ans;
	if ((2 * X - Y) % 3 != 0) {
		ans = 0;
	}
	else {
		long long m = (2 * X - Y) / 3;
		long long n = (2 * Y - X) / 3;
		ans = COM(n + m, n);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 70656
#include <cstdio>
#include <iostream>

using namespace std;

#define limit int(1e4)
#define mod int(1e9 + 7)

#define EMP 0
#define VAR 1
int arr[ limit ][ limit ];
int answer[ limit ][ limit ];

int found_answer(int h, int w) {
	answer[ 0 ][ 0 ] = 1;
	/*
	for(int i = 0; i < h; i++) {
		if(!arr[ i ][ 0 ]) {
			answer[ i ][ 0 ] = 1;
		}
	}

	for(int i = 0; i < w; i++) {
		if(!arr[ 0 ][ i ]) {
			answer[ 0 ][ i ] = 1;
		}
	}*/

	/*
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			printf("%i ", answer[ i ][ j ]);
		}	printf("\n");
	}
	printf("\n\n\n");
	*/

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(arr[ i ][ j ]) {
				answer[ i ][ j ] = -1;
				continue;
			}
			if(!arr[ i ][ j ] && i - 1 >= 0 && !arr[ i - 1 ][ j ]) answer[ i ][ j ] = (answer[ i ][ j ] + answer[ i - 1 ][ j ]) % mod;
			if(!arr[ i ][ j ] && j - 1 >= 0 && !arr[ i ][ j - 1 ]) answer[ i ][ j ] = (answer[ i ][ j ] + answer[ i ][ j - 1 ]) % mod;			
		}
	}

	/*
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			printf("%i ", answer[ i ][ j ]);
		}	printf("\n");
	}*/

	return arr[ h - 1 ][ w - 1 ] ? 0 : answer[ h - 1 ][ w - 1 ];
}

int main() {
	int h, w;
	char t[1010];
	scanf("%i%i", &h, &w);

	for(int i = 0; i < h; i++) {
		scanf("%s", t);
		for(int j = 0; j < w; j++) {
			char s = t[j];


			if(s == '.') {
				arr[ i ][ j ] = EMP;
			} else if(s == '#') {
				arr[ i ][ j ] = VAR;
				//printf("i = %i, j = %i\n", i, j);
			}
		}
	}

	/*
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			printf("%i ", arr[ i ][ j ]);
		}	printf("\n");
	}
	printf("\n\n");
	*/

	printf("%i", found_answer(h, w));
}

Measured memory_bytes: 80512
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int X; cin >> X;
    
    for (int A = 0; A < 120; A++) {
        for (int B = -120; B < A; B++) {
            if ((pow(A, 5) - pow(B, 5)) == X) {
                cout << A << " " << B << endl;
                return;
            }
        }
    }
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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



int main() {

  int r;
  cin >> r;

  cout << r*r << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// ÉÏ ×ó ÏÂ ÓÒ
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k,a;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a;
	cout<<(n-k)/(k-1)+((n-k)%(k-1)==0?0:1)+1; 
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();  	
}

void solve() {
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << 0.5 << endl;
    }
    else if (n == 1) {
        cout << 1 << endl;
    }
    else {
        // dbg((doublen / 2 + 1);
        cout << (double)(n / 2 + 1) / n << endl;
    }
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll A,B,C; cin >> A >> B >> C;
  ll K; cin >> K;

  ll num = 0;
  while(B <= A){
    num++;
    B*=2;
  }
  while(C<=B){
    num++;
    C*=2;
  }
  if(num<=K){
    cout << "Yes" << endl;
  } else { 
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
n = int(input())
a = [(_a, i) for i, _a in enumerate(map(int, input().split()))]
a.sort(reverse=True)

dp = [[0]*(n+1) for _ in range(n+1)]
for i, (v, p) in enumerate(a):
    # 前にj人いる
    dp[i+1][0] = dp[i][0] + v*abs((n-1 - i) - p)
    for j in range(1, i+1):
        dp[i+1][j] = max(dp[i][j] + v*abs((n-1 - (i-j)) - p),
                         dp[i][j-1] + v*abs((j-1) - p))
    dp[i+1][i+1] = dp[i][i] + v*abs(i - p)
print(max(dp[n]))


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M, H, K;
  while(cin>>N>>M>>H>>K,N){
	VI xs(N);
	REP(i,N) cin >> xs[i];
	VVI es(H);
	REP(i,M){
	  int x, y;
	  cin >> x >> y;
	  --x, --y;
	  es[y].EB(x);
	}

	VI f(N), fi(N), g(N), gi(N);
	iota(ALL(f), 0);
	iota(ALL(fi), 0);
	iota(ALL(g), 0);
	iota(ALL(gi), 0);
	REP(y,H){
	  for(int x: es[y]){
		swap(g[gi[x]], g[gi[x+1]]);
		swap(gi[x], gi[x+1]);
	  }
	}

	int ans = 0;
	REP(i,K) ans += xs[g[i]];
	REP(y,H){
	  for(int x: es[y]){
		swap(f[fi[x]], f[fi[x+1]]);
		swap(fi[x], fi[x+1]);
		swap(g[x], g[x+1]);
	  }
	  for(int x: es[y]){
		int sum = 0;
		swap(fi[x], fi[x+1]);
		swap(f[fi[x]], f[fi[x+1]]);
		REP(i,K){
		  sum += xs[g[f[i]]];
		}
		mini(ans, sum);
		swap(f[fi[x]], f[fi[x+1]]);
		swap(fi[x], fi[x+1]);
	  }
	}
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3576
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] x = new int[n];
        for(int i = 0; i < n; i++) x[i] = scan.nextInt();
        int out = 0;
        for(int i = 0; i < n; i++){
            out += (int)(Math.min(Math.abs(k - x[i]), x[i])) * 2;
        }
        System.out.println(out);
        scan.close();
    }
}

Measured memory_bytes: 27084
import java.util.Scanner;

class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		int []N = new int[str.length()];
		int sum=0;
		for(int i=0; i<str.length(); i++) {
			if (i!=0){
				String n = str.substring(i,i+1);
				N[i] = Integer.parseInt(n);
				if(N[i] == N[i-1]){
					if(N[i]==1) {
						N[i]=0;
						sum++;
					}
					else if(N[i]==0){
						N[i]=1;
						sum++;
					}
				}
			}
			else if(i==0) {
				N[0]=Integer.parseInt(str.substring(0,1));
			}
		}
		System.out.print(sum);
	}
}


Measured memory_bytes: 32592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s;
	t="CODEFESTIVAL2016";
	int ans=0;
	rep(i,s.size()) if(s[i]!=t[i]) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		String text,b;
		StringBuffer sb = new StringBuffer();
		Scanner sc = new Scanner(System.in);
		text=sc.nextLine();

		for (int i = 0; i < text.length(); i++) {
			if(Character.isLowerCase(text.charAt(i))) {
				sb.append(Character.toUpperCase(text.charAt(i)));
			} else if (Character.isUpperCase(text.charAt(i))) {
				sb.append(Character.toLowerCase(text.charAt(i)));
			} else {
				sb.append(text.charAt(i));
			}
		}
		System.out.println(sb);
	}
}



Measured memory_bytes: 26244
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
ll read()
{
    char s;
    ll k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
void write(int x)
{
    if(x<0){putchar('-');write(-x);}
    else{if(x/10)write(x/10);putchar(x%10+'0');}
}
int n,k,ans; 
int x,y,xx,yy,x2,y2;
char ch;
int w[2333][2333];
int b[2333][2333];
int main()
{
	n=read();k=read();
	for (int i=1;i<=n;i++)
	{
		x=read();y=read();
		ch=getchar();
		while (ch!='W'&&ch!='B') ch=getchar();
		if (ch=='B')
		{
			b[x%(2*k)+1][y%(2*k)+1]++; 
		} else
		{
			w[x%(2*k)+1][y%(2*k)+1]++;
		} 
	}
	for (int i=1;i<=2*k;i++)
		for (int j=1;j<=2*k;j++)
		{
			w[i][j]+=w[i][j-1]+w[i-1][j]-w[i-1][j-1];
			b[i][j]+=b[i][j-1]+b[i-1][j]-b[i-1][j-1];
		}
	for (int i=1;i<=k;i++)
		for (int j=1;j<=k;j++)
		{
			xx=w[k*2][2*k]-w[i+k-1][2*k]-w[2*k][j+k-1]+w[i+k-1][j+k-1]*2+w[i-1][2*k]+w[2*k][j-1]-w[i+k-1][j-1]*2-w[i-1][j+k-1]*2+w[i-1][j-1]*2;
			x2=w[2*k][2*k]-xx;
			yy=b[2*k][2*k]-b[i+k-1][2*k]-b[2*k][j+k-1]+b[i+k-1][j+k-1]*2+b[i-1][2*k]+b[2*k][j-1]-b[i+k-1][j-1]*2-b[i-1][j+k-1]*2+b[i-1][j-1]*2;
			y2=b[2*k][2*k]-yy;
			qmax(ans,max(xx+y2,yy+x2));
		}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 39168
N = int(input())
#A = [sorted(list(map(int,input().split()))) for i in range(N-1)]
#連結成分＝頂点の個数-辺の本数
#結局、頂点、辺の個数の和はその頂点、辺を含むSの個数で求められる
vertex = 0
edge = 0
for i in range(1,N+1): #数字上で、頂点の両端の頂点をいくつ含めるか
    vertex += (N-i+1)*i
for i in range(N-1):
    A = sorted(list(map(int,input().split())))
    edge += (N-A[1]+1)*A[0] #数字上で、辺の両端の頂点をいくつ含めるか
print(vertex-edge)

Measured memory_bytes: 70064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
constexpr int MOD = 998244353;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}
int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> d(n);

    bool onedzero = false;
    REP(i,n) {
        int x;
        cin >> x;
        if (i == 0) {
            if (x == 0) {
                onedzero = true;
            }
        } else {
            d[x]++;
        }
    }

    int ans = 0;
    if (onedzero && d[0] == 0) {
        ans = 1;
        int cnt = d[1] + 1;
        FOR(i,2,n) {
            ans = modm(ans,modpow(d[i-1],d[i]));
            cnt += d[i];
            //cerr << ans << " " << cnt << endl;
            if (cnt == n) break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
S = list(input())[: -1]
ls = []
rs = []
N = len(S)
for i in range(N):
  if S[i] == "L": ls.append(i)
  else: rs.append(i)
#print(ls, rs)

res = [0] * N
for i in range(N):
  if S[i] == "R":
    j = bl(ls, i)
    x = N - 1
    if len(ls) > j: x = ls[j]
    x -= abs(x - i) % 2
    res[x] += 1
  if S[i] == "L":
    j = bl(rs, i) - 1
    x = 0
    if j >= 0: x = rs[j]
    x += abs(x - i) % 2
    res[x] += 1
print(*res)

Measured memory_bytes: 57340
N = int(input())
minval = N

for a in range(1,N):
  sum = 0
  A = a
  B = N-a
  while A > 0:
    sum += A%10
    A = int(A/10)
  while B > 0:
    sum += B%10
    B = int(B/10)
  if minval > sum:
    minval = sum

print(minval)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define pb push_back

using namespace std;

const int N=1e5+5;

string s;
int a[N];
vector< pii > v;
int main()
{
	cin >> s;
	int n = s.length();
	for(int i = 1; i <= n; i++) a[i]=s[i-1]-'0';
	if(a[1]==0 || a[n]==1)
	{
		cout << -1;
		return 0;
	}
	for(int i = 1; i < n; i++)
	{
		if(a[i]!=a[n-i])
		{
			cout << -1;
			return 0;
		}
	}
	v.pb(mp(1, 2));
	int curr0=2, curr1=2, ptr=2;
	bool flag=false;
	for(int i = 2; i < n; i++)
	{
		ptr++;
		if(a[i])
		{
			v.pb(mp(ptr, curr1));
			curr1 = ptr;
		}
		else
		{
			v.pb(mp(curr1, ptr));
		}
		/*if(2*i==n && flag==false)
		{
			flag=true;
			i--;
		}*/
	}
	for(auto pp: v)
	{
		cout << pp.first << " " << pp.second << endl;
	}
}	

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

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

	vector<pair<int, int>> v;
	v.push_back(make_pair(0, 0));
	rep(i, n+1){
		int w = v[i].first;
		int e = v[i].second;
		if (s[i] == 'W')
			w++;
		else e++;
		v.push_back(make_pair(w, e));
	}
	// rep(i, n+1){
	// 	cout << v[i].first << " " << v[i].second << endl;
	// }
	int min = INF;
	rep(i, n){
		int t;
		t = v[i].first;
		t += v.back().second - v[i+1].second;
		min = min < t ? min : t;
	}
	cout << min-1 << endl;
}


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

#define reg register

using namespace std;

typedef long long ll;

const int MAXN=1250;

int a,b;
bool ans=0;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0); 
	cin>>a>>b;
	for(int i=0; i<=MAXN; ++i)
		if(static_cast<int>(i*0.08)==a && static_cast<int>(i*0.1)==b) {//round down 
			cout<<i<<endl;
			ans=1;
			break;
		}
	if(!ans) puts("-1");
	return 0;
}

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

int main()
{
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	
	if (u == s)
	{
		a--;
	}
	else
	{
		b--;
	}
	
	cout << a << " " << b << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin>>str;
  if(str=="RRR")
  {
    cout<<"3";
    return 0;
  }
  else if(str=="RRS" || str=="SRR")
  {
    cout<<"2";
    return 0;
  }
  else if(str=="SSS")
  {
    cout<<"0";
    return 0;
  }
  else
  {
    cout<<"1";
    return 0;
  }
}

Measured memory_bytes: 3620
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, m, d= MAP()

if d != 0:
	print(2*(n-d)*(m-1)/n**2)
else:
	print((m-1)/n)

Measured memory_bytes: 9936
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

int main(){
	char s[5];
	cin>>s;
	if((s[0]==s[1] && s[1]==s[2]) || ( s[1]==s[2] && s[2]==s[3])){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#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;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::string S; std::cin >> S;

  ll ans = 0;
  ll x = 0;
  rep(i,N) {
    if ( S[i] == 'I' ) x++;
    else if ( S[i] == 'D' ) x--;
    ans = std::max(ans, x);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const int N=1e5+3; 
int n,a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	std::sort(a+1,a+1+n);
	for(int i=0;i<n;i++)if(a[n-i]==i){
	  int f;
	  for(f=i+1;a[n-f]>=i;f++);
	  return 0*puts((f-i+1&1)&&(a[n-i+1]-i+1&1)?"Second":"First");
	}
	for(int i=0;i<n;i++)if(a[n-i-1]<i+1&&a[n-i]>i)return 0*puts(a[n-i]-i&1?"Second":"First");
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root=NIL;
Node treeMinimum(Node x){
  if(x->left == NIL) return x;
  else treeMinimum(x->left);
}

Node treeMaximum(Node x){
  if(x->right == NIL) return x;
  else treeMaximum(x->right);
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;
  else if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x->key == y->right->key){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left!=NIL) x = y->left;
  else x = y->right;

  if(x!=NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y!=z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;
    
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u==NIL) return ;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20476
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main() {
    int A, B, C;

    scanf("%d %d %d", &A, &B, &C);

    if(A + B >= C) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
int POW[20];

int main(){

	POW[0] = 1;
	for(int i = 1; i < 20; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d",&N);

	int num;
	scanf("%d",&num);

	int tmp;
	vector<int> V;

	for(int i = 0; i < num; i++){

		scanf("%d",&tmp);
		V.push_back(tmp);
	}

	vector<int> ans;

	for(int state = 0; state < POW[N]; state++){
		bool FLG = true;
		for(int i = 0; i < V.size(); i++){
			if((state & POW[V[i]]) == 0){
				FLG = false;
				break;
			}
		}
		if(FLG){

			ans.push_back(state);
		}
	}

	for(int i = 0; i < ans.size(); i++){

		printf("%d:",ans[i]);
		for(int k = 0; k < N; k++){
			if((ans[i]&POW[k])){
				printf(" %d",k);
			}
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 3832
list_a = []
n = int(input())
for i in range(n):
    list_a.append(int(input()))
dict_ans = {}
for i in range(n):
    try:
        del dict_ans[list_a[i]]
    except KeyError:
        dict_ans[list_a[i]] = 1
print(len(dict_ans))


Measured memory_bytes: 16272
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#define INF 100000000
using namespace std;
typedef pair<int ,int >P; 
int W,H;
char grid[50][50];
int dx[] = {1,-1,0,0},dy[] = {0,0,1,-1};
int ansB,ansW; 

void bfs(int sx,int sy){
  queue<P>que;
  bool flagB = true,flagW = true;
  int res = 0;
  while(!que.empty())que.pop();

  que.push(P(sx,sy)); 

  while(!que.empty()){
    P p = que.front();
    que.pop();
    int x = p.first,y = p.second;
    if(grid[x][y] == '.'){
      res++;
      grid[x][y] = '#';
	if(flagB == true
	   &&((x+1 < W && grid[x+1][y] == 'B' )||
	      (x-1 >= 0 && grid[x-1][y] == 'B')||
	      (y+1 < H && grid[x][y+1] == 'B')||
	      (y-1 >= 0 && grid[x][y-1] == 'B'))){
	  flagB = false;
	}
	if(flagW == true &&
	   ((x+1 < W && grid[x+1][y] == 'W' )||
	    (x-1 >= 0 && grid[x-1][y] == 'W')||
	    (y+1 < H && grid[x][y+1] == 'W')||
	    (y-1 >= 0 && grid[x][y-1] == 'W'))){
	  flagW = false;
	}
    }else continue;
    for(int i = 0 ; i < 4 ; i++ ){
      int nx = x + dx[i],ny = y + dy[i];

      if(0 <= nx && nx < W && 0 <= ny && ny < H && grid[nx][ny] == '.'){
	que.push(P(nx,ny));
      }
    }
  }
  if(flagB == false && flagW == true)ansB+=res;
  else if(flagB == true && flagW == false)ansW+=res;
 N:;
}

int main(){

  while( cin >> W >> H,W + H ){
    ansB = 0,ansW = 0;

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

    for(int i = 0 ; i < H ; i++ ){
      for(int j = 0 ; j < W ; j++ ){
	if(grid[j][i] == '.'){
	  bfs(j,i);
	}
      }
    }
    cout << ansB << " " << ansW << endl;
  } 
  return 0;
}

Measured memory_bytes: 1216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, n;

    cin >> N;

    n = N % 10;

    if(n==2 || n==4 || n==5 || n==7 || n==9) {
        cout << "hon" << endl;
    } else if (n==0 || n==1 || n==6 || n==8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = numeric_limits<int>::infinity();
const int E = numeric_limits<int>::min();

int main(void)
{
    int N;
    cin >> N;
    bool flag = false;
    vector<unsigned long long> A(N);
    unsigned long long num = 1;
    unsigned long long ans = 1000000000000000000;
    rep(i, N)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    rep(i, N){
        if (A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
        ans /= A[i];
        if (ans <= 0){
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i, N){
        num *= A[i];
    }
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

struct E {
  int L, R;
  bool operator<(E const& r) const { return L > r.L; }
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<E> LR(N);
  int ma = 0, maL=0, miR=1e9+1, iL, iR;
  auto len = [](int l, int r)->int64_t { return std::max(0, r-l+1); };
  for(int i = 0; i < N; ++i) {
    std::cin >>  LR[i].L >> LR[i].R;
    ma = std::max(ma, LR[i].R-LR[i].L+1);
    if(LR[i].L > maL) { maL = LR[i].L; iL = i; }
    if(LR[i].R < miR) { miR = LR[i].R; iR = i; }
  }
  int64_t ans = ma + len(maL, miR);
  if(iL == iR) fin(ans);
  int miL = LR[iR].L, maR = LR[iL].R;
  LR.erase(LR.begin() + std::max(iL, iR));
  LR.erase(LR.begin() + std::min(iL, iR));
  std::sort(LR.begin(), LR.end());
  // initial: [all LR.L, miR] + [maL, maR]
  // final:   [miL, miR] + [maL, all LR.R]
  for(int i = 0; i < LR.size(); ++i) {
    int64_t cur = len(std::max(LR[i].L, miL), miR)
                + len(maL, maR);
    ans = std::max(ans, cur);
    maR = std::min(maR, LR[i].R);
  }
  int64_t cur = len(miL, miR) + len(maL, maR);
  ans = std::max(ans, cur);
  fin(ans);
  return 0;
}


Measured memory_bytes: 1024