akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <iomanip>
#include <cmath>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long 
//#define int long long
#define ld long double
#define vi deque<int>
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define iii pair<int,ii>
#define il pair<int,ll>
#define pll pair<ll,ll>
#define _path pair<ll,pair<ll,int> > 
#define vv deque
//#define endl '\n'
//#define mp make_pair

using namespace std;

const int MAXN = 1e5+5;


void solve(){
	int n,m;
	cin >> n >> m;

	bool hasRedball[n];
	int tot[n];
	FOR(i,n)hasRedball[i] = 0;
	FOR(i,n)tot[i] = 1;
	hasRedball[0] = 1;
	FOR(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		if(hasRedball[a])hasRedball[b] = 1;
		tot[a]--;
		tot[b]++;
		if(tot[a] == 0)hasRedball[a] = 0;
	}
	int cnt =0 ;
	FOR(i,n)cnt += hasRedball[i];
	cout << cnt << endl;
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(k,i,n) for(int i = (k); i < (int)(n); i++)

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


int main() {
    string s;ll k;cin>>s>>k;
    ll n=s.size();
    vector<ll> m(0,0),mm(0,0);
    if(n==1) {cout<<k/2; return 0;}
    rep(i,n-1){
        if(s[i]!=s[i+1]) break;
        else if(i==n-2){cout<<n*k/2;return 0;}
    }
    ll l=1;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            l++;
        }
        else{
            m.push_back(l);
            l=1;
        }
    }
    m.push_back(l);
    ll sum=0,ans=0;
    for(ll x:m){
        sum+=x/2;
    }
    s+=s;
    l=1;
    rep(i,n*2-1){
        if(s[i]==s[i+1]){
            l++;
        }
        else{
            mm.push_back(l);
            l=1;
        }
    }
    mm.push_back(l);
    for(ll x:mm){
        ans+=x/2;
    }
    cout<<sum+(ans-sum)*(k-1);
    return 0;
}

Measured memory_bytes: 256
def Dimensional(n , m , x , y , xl , yl):

    ans = "War"

    xmax = max(xl) + 1
    ymin = min(yl)

    if xmax <= ymin and x < ymin and xmax < y:
        ans = "No War"

    return ans

def main():
    n , m , x , y = map(int , input().split())
    xl = list(map(int , input().split()))
    yl = list(map(int , input().split()))
    print(Dimensional(n , m , x , y , xl , yl))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}


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

using namespace std;

#define F first
#define S second
#define MAX_N 1e5+10

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vbl;

int main() {
  int n;
  cin >> n;
  double p[n+1];
  double prod = 1;
  for (int i = 1 ; i <= n ; i++) {
    cin >> p[i];
  }

  double dp[n+1][n+1];
  dp[0][0] = 1;
  for (int i = 1 ; i <= n ; i++) {
    dp[i][0] = dp[i-1][0]*(1-p[i]);
    dp[0][i] = 0;
  }

  for (int i = 1 ; i <= n ; i++) {
    for (int k = 1 ; k <= n ; k++) {
      dp[i][k] = dp[i-1][k-1]*p[i] + dp[i-1][k]*(1-p[i]);
    }
  }

  double res = 0;

  for (int k = (n+1)/2 ; k <= n ; k++) {
    res += dp[n][k];
  }

  cout << fixed << setprecision(9) << res << endl;

  return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int A1, A2, A3; cin >> A1 >> A2 >> A3;

if (A1 + A2 + A3 >= 22) cout << "bust\n";
else cout << "win\n";



}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d){
        cout<<"Left"<<endl;
    }else if(a+b<c+d){
        cout<<"Right"<<endl;
    }else{
        cout<<"Balanced"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
T=0..59
puts 9394,a=?+,0,1,3,?<,2,3,3,[0,1].map{|x|[a,x,3,x]+T.map{[a,v=x+4,v,v,a,v,3,6,[a,6,6,6]*(59-_1),?<,6,x,u=x*99+_1+9,a,v,u,v]}},T.map{|t|[a,2,2,2]+(1..t).map{[a,39+t-_1,137+_1,5,?<,3,5,5,a,2,5,2]}}

Measured memory_bytes: 14904
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  int ans = abs(A[0]); // かかるはずだった金額
  for (int i=1; i<N; i++) ans += abs(A[i]-A[i-1]);
  ans += abs(A[N-1]);
  for (int i=0; i<N; i++) {
    if (i==0) cout << ans-abs(A[i])-abs(A[i+1]-A[i])+abs(A[i+1]) << endl;
    else if (i==N-1) cout << ans-abs(A[i]-A[i-1])-abs(A[i])+abs(A[i-1]) << endl;
    else cout << ans-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]) << endl;
  }
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a+b+c-max(a,max(b,c))<<endl;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> d(K);
    vector<vector<int>> A(K);
    rep(i, K) {
        cin >> d.at(i);
        rep(j, d.at(i)) {
            int tmp;
            cin >> tmp;
            A.at(i).push_back(tmp);
        }
    }

    set<int> S;
    rep(i, K) {
        rep(j, d.at(i)) {
            S.insert(A.at(i).at(j));
        }
    }

    int ans = N - S.size();

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=924844033;
LL n,k;
LL f[4010][2010][2];
LL vis[2010],a[4010],N=0;
void add(LL x,LL tim)
{
	LL i=x;a[N+1]=1;
	//printf("N:%d\n",N);
	while(1)
	{
		tim^=1;if(tim) vis[i]=1;N++;
		if(i+k>n) break;i+=k;
	}
}
LL fac[2010];
int main()
{
	scanf("%lld %lld",&n,&k);
	memset(vis,0,sizeof(vis));
	for(LL i=1;i<=n;i++) if(vis[i]==0) add(i,0),add(i,1);
	for(LL i=0;i<=N;i++) f[i][0][0]=1;
	for(LL i=1;i<=N;i++)
		for(LL j=1;j<=n;j++)
		{
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mod;
			if(a[i]!=1) f[i][j][1]=f[i-1][j-1][0];
		}
	//for(int i=1;i<=N;i++) printf("%lld ",a[i]);printf("\n");
	//for(LL i=0;i<=n;i++) printf("%lld:%lld\n",i,f[N][i][0]+f[N][i][1]);
	LL ans=0;
	fac[0]=1;for(LL i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	for(LL i=0;i<=n;i++)
		(ans+=(i&1?-1:1)*fac[n-i]%mod*(f[N][i][0]+f[N][i][1])%mod)%=mod;
	printf("%lld",(ans+mod)%mod);
}

Measured memory_bytes: 125952
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));

	cout << (a[a.size() - 1] - a[0]) << endl;
	
	return 0;
}


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

int main() {
    using namespace std;
    unsigned long N;
    scanf("%lu", &N);
    vector<unsigned long> perm(N);
    {
        vector<pair<long, long>> p(N);
        for(auto& i : p)scanf("%lu%lu", &i.first, &i.second);
        sort(p.begin(), p.end());
        for(unsigned long i = 0; i < N; ++i)p[i] = {p[i].second, i + 1};
        sort(p.begin(), p.end());
        transform(p.cbegin(), p.cend(), perm.begin(), [](auto i){return i.second;});
    }

    constexpr unsigned long MOD = 998244353;
    vector<unsigned long> binary(N + 1);
    unsigned long n = binary[0] = 1;
    generate(binary.begin() + 1, binary.end(), [&n](){if(n >= MOD)n -= MOD;return n <<= 1;});


    vector<unsigned long> fenwick_tree(N + 1);
    auto que = [&fenwick_tree, &N](unsigned long i){
        unsigned long s{0}, j{i};
        while (i) { s += fenwick_tree[i]; i -= i & -i; }
        while (j <= N) { ++fenwick_tree[j]; j += j & -j; }
        return s;
    };

    vector<unsigned long> coef(N + 1);
    coef[N] = N + MOD - 4;
    for(unsigned long i = 0; i != N; ++i){
        auto p = perm[i], q = que(p);
        ++coef[q];
        ++coef[i - q];
        ++coef[p - q - 1];
        ++coef[N - i - p + q];
    }

    cout << inner_product(binary.begin(), binary.end(), coef.begin(), 4 + MOD - N) % MOD << endl;
    return 0;
}

Measured memory_bytes: 6488
N = int(input())
W = list(map(int, input().split()))
ans = []
for i in range(N-1):
  ans1, ans2 = 0, 0
  for k in range(i+1):
    ans1 += W[k]
  for k in range(i+1, N):
    ans2 += W[k]
  ans.append(abs(ans1-ans2))
print(min(ans))
    

Measured memory_bytes: 8992
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef long double ld;

void faster(){
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
	cout.tie(NULL);
}

const int MAXN = 5e1 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll A, B, C;

int main(){
	faster();

	cin >> A >> B >> C;

	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
		cout << 0;
	}
	else{
		cout << min({A * B, A * C, B * C});
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;

const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	string t;
	cin>>s>>t;
	int n = s.size();
	if(t.size()!=n+1){
		cout<<"No"<<nl;
	}
	else{
		bool f = 1;
		for(int i = 0; i < n; i++){
			if(s[i] != t[i]){
				f = 0;
			}
		}
		if(f) cout<<"Yes"<<nl;
		else cout<<"No"<<nl;
	}
	return 0;
}



Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
    long int t;
    int i=1,ac=0,tle=0,re=0,wa=0;
    char e1[4]="AC",e2[4]="WA",e3[4]="TLE",e4[4]="RE",f[5];
    scanf("%ld\n",&t);
    for(i=1;i<=t;i++)
    {
        gets(f);
        if((strcmp(f,e1))==0)
        {
            ac++;
        }
        else if((strcmp(f,e2))==0)
        {
            wa++;
        }
        else if((strcmp(f,e3))==0)
        {
            tle++;
        }
        else if((strcmp(f,e4))==0)
        {
            re++;
        }
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
    return 0;
}


Measured memory_bytes: 1752
#n個の展望台
#mこの道
n,m=map(int,input().split())
#展望台の高さ
h=list(map(int,input().split()))

#print(h)
#全て良い展望台と仮定、
result=[1]*n

for _ in range(m):
    #aとbをつなぐ
    a,b=map(int,input().split())
    a=a-1
    b=b-1

    if h[a]<h[b]:
        result[a]=0
    elif h[b]<h[a]:
        result[b]=0
    else:
        result[a]=0
        result[b]=0


cnt=0
for item in result:
    if item==1:
        cnt+=1

#print(result)
print(cnt)


Measured memory_bytes: 84956
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n;
    std::cin >> n;
    std::multiset<int> s;
    rep(i,n){
        int dum;
        std::cin >> dum;
        s.insert(dum);
    }
    int m;
    std::cin >> m;
    
    rep(i,m){
        int dum;
        std::cin >> dum;
        if(s.count(dum)){
            s.erase(s.find(dum));
        }
        else{
            std::cout << "NO" << std::endl;
            exit(0);
        }
        
    }std::cout << "YES" << std::endl;
}




Measured memory_bytes: 9600
#include <iostream>

bool ishihi(std::string S)
{
	if (S.size() % 2 != 0)
	{
		return false;
	}

	bool valid = true;
	for (size_t i = 0; i < S.size() / 2; i++)
	{
		valid = valid && (S[2 * i] == 'h');
		valid = valid && (S[2 * i + 1] == 'i');
	}
	return valid;
}

void hitachi1()
{
	std::string S;
	std::cin >> S;

	if (ishihi(S))
	{
		std::cout << "Yes";
	}
	else
	{
		std::cout << "No";
	}
}

int main()
{
	hitachi1();
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        a: [String;n],
    }

    let set: HashSet<String> = a.into_iter().collect();
    println!("{}", set.len());
}


Measured memory_bytes: 21388
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
  hoge = input()
  if hoge == "AC":
    ac += 1
  elif hoge == "WA":
    wa += 1
  elif hoge == "TLE":
    tle += 1
  elif hoge == "RE":
    re += 1
    
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 9204
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    
    if(n % k == 0){
      System.out.println("0");
    }
    else{
      System.out.println("1");
    }
  }
}


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

int main(){
    int A, B, count = 0, x, x1, x2, x4, x5;
    cin >> A >> B;
    for(int i = A; i <= B; i++){
        x = i;
        x1 = x % 10;
        x /= 10;
        x2 = x % 10;
        x /= 100;
        x4 = x % 10;
        x /= 10;
        x5 = x % 10;
        if(x1 == x5 && x2 == x4) count++;
    }
    cout << count << endl;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int a, b, x;
    cin >> a >> b >> x;
    double theta;
    if (a * a * b <= 2 * x)
    {
        theta = atan(2.0 * (a * a * b - x) / (a * a * a));
    }
    else
    {
        theta = PI / 2 - atan(2.0 * x / (b * b * a));
    }
    cout << theta * 180 / PI << "\n";
    return 0;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>>  var(n, vector<int>(m, 0))
#define vecb2(var, n, m)   vector<vector<bool>> var(n, vector<bool>(m, false))
#define vecll2(var, n, m)  vector<vector<ll>>   var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n);
  sortall(a);

  ll ans=0;
  if(n%2==0){
    rep(i,n){
      if(i<n/2) ans -= 2*a[i];
      else ans += 2*a[i];
      if(i==n/2-1) ans += a[i];
      if(i==n/2) ans -= a[i];
    }
  } else {
    ll ans1=0, ans2=0;
    rep(i,n){
      if(i<=n/2) ans1 -= 2*a[i];
      else ans1 += 2*a[i];
      if(i==n/2 || i==n/2-1) ans1 += a[i];
    }
    rep(i,n){
      if(i<n/2) ans2 -= 2*a[i];
      else ans2 += 2*a[i];
      if(i==n/2 || i==n/2+1) ans2 -= a[i];
    }
    ans = max(ans1, ans2);
  }

  prt(ans);
}


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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    int n, k; cin >> n >> k;
    string s; cin >> s;

    int x = 0;
    rep(i,n-1) {
        if (s[i] == s[i+1]) x++;
    }
    int ans = min(x + 2 * k, n-1);
    cout << ans << endl;
    return 0;
}


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

#define ll long long

int main() {
    int N, M;
    cin >> N >> M;
    int L[M];
    int R[M];

    int maxL = -1;
    int minR = 114514;

    for(int i = 0;i < M;i++) {
        cin >> L[i] >> R[i];
        maxL = max(L[i], maxL);
        minR = min(R[i], minR);
    }

    int res = 0 <= minR - maxL ? minR - maxL + 1 : 0;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
import numpy as np
 
def main():
  
  row, col = map(int, input().split())
  ls2 = [['.']*(col+2)]
  for i in range(row):
    ls2.append(['.'] + list(input().rstrip()) + ['.'])
  ls2.append(['.']*(col+2))
  nda = np.array(ls2)
  
  rslt = 'Yes'
  for i in range(row):
    for j in range(col):
      if nda[i,j] == '#':
        if nda[i-1,j] != '#':
          if nda[i+1,j] != '#':
            if nda[i,j-1] != '#':
              if nda[i,j+1] != '#':
                rslt = 'No'
  print(rslt)
  
if __name__ == "__main__":
  main()
  

Measured memory_bytes: 12408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,x,cnt=0,sum=0;
	cin >> n >> x;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	for (ll i = 0; i < n-1; i++) {
		x -= a[i];
		if (x < 0)return cout << cnt << endl,0;
		cnt++;
	}
	cout << (a[a.size() - 1] == x ? cnt + 1 : cnt) << endl;
}

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


int main(void){

int a,b,v,w,t;

scanf("%d %d %d %d %d",&a,&v,&b,&w,&t);

int kyori,run;

kyori=abs(b-a);
//run=abs(v*t-w*t);
int flag=0;


if(v>w){
int x;
x=v-w;
for(int i=1;i<=t;i++){
        long int y;
        y=x*i;
        if(y >= kyori){
                flag=1;
                printf("YES\n");
                break;
        }   
}
}

if(flag==0){
        printf("NO\n");
}


return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;


int main(){
	int n,k;

	cin >> n>>k;
	
	int count = 0;
	
	vector<int> arr(n);

	for (int i = 0; i < n; i++) cin >> arr[i];

	sort(arr.begin(), arr.end(), greater<int>());

	for (int i = 0; i < k; i++) count = count + arr[i];

	cout << count << endl;

	return 0;

}

Measured memory_bytes: 3608
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    a <- getLine
    -- 出力
    putStrLn $ if (head a) `elem` "aiueo" then "vowel" else "consonant"


Measured memory_bytes: 380
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*
多倍長整数, cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s;
	scans(s);
	int len = s.length();
	rep(i, len) {
		if (s[i] == '?') {
			s[i] = 'D';
		}
	}
	prints(s);

	Please AC;
}

Measured memory_bytes: 3880
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>

 
int c()
{
    int k, n;
    std::cin >> k >> n;
    std::vector<int> dist(n);
    
    for(int i = 0; i < n; i++)
    {
        std::cin >> dist[i];
    }
    
    std::sort(dist.begin(), dist.end());
    
    int maxLen = 0;
    for(int i = 0; i < n-1; i++)
    {
        int myLen = dist[i+1] - dist[i];
        if(maxLen < myLen)
        {
            maxLen = myLen;
        }
    }
    
    int lastLen = dist[0] + (k - dist[n-1]);
    if(maxLen < lastLen)
    {
        maxLen = lastLen;
    }
    
    std::cout << k - maxLen;
    
    return 0;
}
 
int main(int argc, const char * argv[])
{
    c();
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
p = list(map(int, input().split()))
s = [0]*(n+1)
l =0
s[0] = 100000000000
for i in range(n):
  s[i+1]=min(s[i],p[i])
for j in range(n):
  if(s[j]>=p[j]):
    l+=1
print(l)
    

Measured memory_bytes: 32380
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const inputs = input.trim().split('\n');
const n = Number(inputs.shift());
const adj = inputs.map((s) => s.split(' ').map(Number));

class Node {
  constructor(id, list) {
    this.id = id;
    this.list = list || [];
  }
  toString() {
    return [this.id, this.depth !== undefined ? this.depth : -1].join(' ');
  }
}

class Graph {
  constructor() {
    this.queue = [];
    this.map = new Map();
  }
  get(id) {
    return this.map.get(id);
  }
  set(id, list) {
    this.map.set(id, new Node(id, list));
  }
  bfs() {
    const root = this.map.get(1);
    root.depth = 0;
    this.queue.push(root);
    while(this.queue.length) {
      const node = this.queue.shift();
      node.list.forEach(id => {
        const child = graph.map.get(id);
        if (child.depth !== undefined) {
          return;
        }
        child.depth = node.depth + 1;
        this.queue.push(child);
      })
    }
  }
  print() {
    for (let i = 1; i <= this.map.size; i++) {
      const node = this.map.get(i);
      console.log(node.toString());
    }
  }
}

const graph = new Graph();
adj.forEach(([id, k, ...ck]) => {
  graph.set(id, ck);
});
graph.bfs();
graph.print();



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

int main()
{
    int N, M;
    cin >> N >> M;
    int num = 1 << N;
    int max = 99999999;
    vector<int>opened = vector<int>(num, max);
    
    int a, b, c, flag;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        flag = 0;
        for (int j = 0; j < b; j++) {
            cin >> c;
            flag = flag | (1 << (c-1));
        }
//        cout << "key " << i << "'s flag is " << flag << endl;
        for (int j = 0; j < num; j++) {
            int k = j | flag;
            if (opened[flag] > a) {
                opened[flag] = a;
//                cout << "updating " << flag << " with " << a << endl;
            }
            if (opened[j] >= 0 && opened[j] + a < opened[k]) {
//                cout << "updating " << k << " with " << opened[j] + a << endl;
                opened[k] = opened[j] + a;
            }
        }
    }
    
    if (opened[num - 1] == max) {
        opened[num - 1] = -1;
    }
    cout << opened[num - 1] << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int a, b;
	cin >> a >> b;
	if (a == b)cout << "Draw" << endl;
	else if (a == 1)cout << "Alice" << endl;
	else if (b == 1) cout << "Bob" << endl;
	else if(a > b)cout << "Alice" << endl;
	else if (b > a) cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









const int N=3e5+10;
int n,w[N],res;
char s[N];



void solve()
{
	cin>>n>>(s+1);
	w[0]=0;
	for(int i=1;i<=n;i++)
	{
		w[i]=w[i-1];
		if(s[i]=='W')w[i]++;
	}
	res=n+1;
	for(int i=1;i<=n;i++)
	{
		res=min(res,w[i-1]+n-i-w[n]+w[i]);
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 1792
#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) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	ll n, m, s = 0;
	cin >> n >> m;
	rep(i, 0, m) { int t; cin >> t; s += t; }
	cout << (s <= n ? n - s : -1) << endl;
}



Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<math.h>
using namespace std;
int main(){
    char s[31]="SUNMONTUEWEDTHUFRISAT";
	char t[10]; 
	scanf("%s",t);
	int i;
	for(i=0;i<7;i++)
	{
		if(t[0]==s[3*i]&&t[1]==s[3*i+1])
		{
			printf("%d\n",7-i);
			break;
		}
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n;
int a[110000];
int r[110000],l[110000];


int main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }

  r[0]=a[0];
  l[n-1]=a[n-1];
  FOR(i,1,n+1){
    r[i]=__gcd(r[i-1],a[i]);
  }
  rrep(i,n-2){
    l[i]=__gcd(l[i+1],a[i]);
  }

  int ans=max(r[n-2],l[1]);
/*
  rep(i,n){
    cout<<l[i]<<' '<<r[i]<<endl;
  }
*/

  FOR(i,1,n-1){
    ans=max(ans,__gcd(r[i-1],l[i+1]));
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 1408
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10),
          cards = args[1].split(' ').map(n => parseInt(n, 10));

    var aSum = 0,
        bSum = 0;

    cards.sort((a, b) => (a < b ? 1 : -1)).forEach((n, i) => {
        (i % 2 === 0)? aSum += n : bSum += n;
    });

    console.log(aSum - bSum);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int h,w;
  cin>>h>>w;
  char s[25][25];
  rep(i,h) rep(j,w) cin>>s[i][j];
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  int ans=0;
  rep(si,h) rep(sj,w){
    if(s[si][sj]=='#') continue;
    int d[25][25];
    rep(i,h) rep(j,w) d[i][j]=-1;
    d[si][sj]=0;
    queue<P> q;
    q.push({si,sj});
    while(q.size()){
      int x,y;
      tie(x,y)=q.front();
      q.pop();
      rep(i,4){
	int nx=x+dx[i],ny=y+dy[i];
	if(nx>=h||ny>=w||nx<0||ny<0) continue;
	if(s[nx][ny]=='.'&&d[nx][ny]==-1){
	  d[nx][ny]=d[x][y]+1;
	  ans=max(ans,d[nx][ny]);
	  q.push({nx,ny});
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   ll X; cin >> X;
   bool done = false;

   for (ll A = 1; A <= 201; A++) {
     for (ll B = -201; B <= A - 1; B++) {
       if (A * A * A * A * A - B * B * B * B * B == X) {
         cout << A << " " << B << endl;
         done = true;
         break;
       }
     }
     if (done) break;
   }
 }


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int ct[nax];
long long s;
int n;

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

    for (int i = 1 ; i <= n;  ++ i) {
        int x;
        scanf("%d", &x);
        ++ ct[x];
        s += x;
    }

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

    for (; q -- ; ) {
        int b, c;
        scanf("%d %d", &b, &c);
        int d = ct[b];
        s -= 1LL * b * ct[b];
        s += 1LL * ct[b] * c;
        ct[c] += ct[b];
        ct[b] = 0;
        printf("%lld\n", s);
    }
}


Measured memory_bytes: 4104
# -*- coding:utf-8 -*-

"""
bit全探索の考え方

for div in range(2**3):
    print(div)
    # divの値を2進数で考えると、
    # 0000
    # 0001
    # 0010
    # 0011
    # 0100
    # 0101
    # ...
    # となるので、全探索を考えやすい

"""


def solve():
    """
    最初に横に切る方法を全探索し、
    次に、ギリギリのラインを縦に切っていく
    O(2**H W)

    Note1:
        1 << K  =>  2**k

    Note2:
        div>>i&1
        => divのi桁目が1であるかどうか
    """
    H, W, K = list(map(int, input().split()))
    S = ["" for _ in range(H)]
    for i in range(H):
        s = input()
        S[i] += s
    ans = float("inf")

    # 横に切るのを全部試す
    # divのbitが1のところで切る
    # gはグループ数
    for div in range(0, 1<<(H-1)):  # 2**(H-1)を全探索するとき、bitで考えたほうがラク
        g = 0
        ids = [0 for _ in range(H)]
        for i in range(H):
            ids[i] = g
            if div>>i&1:
                g += 1
        g += 1

        c = [[0 for _ in range(1005)] for __ in range(10)]

        for i in range(H):
            for j in range(W):
                c[ids[i]][j] += int(S[i][j])

        num = g-1  # g-1回、横に切る
        now = [0 for _ in range(g)]  # 今、各グループに何個のホワイトチョコレートがあるか
        def add(j, now, c):
            for i in range(g):
                now[i] += c[i][j]
            for i in range(g):
                if now[i] > K: return False
            return True

        for j in range(W):
            if not add(j, now, c):
                num += 1
                now = [0 for _ in range(g)]
                if not add(j, now, c):
                    num = float("inf")
                    break
        ans = min(ans, num)
    print(ans)


if __name__ == "__main__":
    solve()


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

int main(){
  while(true){
    int m, nmin, nmax;
    cin >> m >> nmin >> nmax;

    if(m == 0)
      break;

    vector<int> p(m);
    for(int i=0; i<m; i++)
      cin >> p[i];

    int amax = 0, ans;
    for(int i=nmin; i<=nmax; i++){
      if(p[i-1] - p[i] >= amax){
	amax = p[i-1] - p[i];
	ans = i;
      }
    }

    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int ans;

int n, k;
int R, S, P;
char a[N];

int m;
int b[N];

int arz(int x)
{
    if (x == 0)
        return R;
    if (x == 1)
        return S;
    return P;
}
bool stg(int x, char y)
{
    if (x == 0 && y == 's')
        return true;
    if (x == 1 && y == 'p')
        return true;
    if (x == 2 && y == 'r')
        return true;
    return false;
}

int dp[N][3];
void solv()
{
    for (int i = 1; i <= m; ++i)
    {
        for (int j = 0; j < 3; ++j)
            dp[i][j] = 0;
    }
    if (b[1] == 'r')
    {
        dp[1][2] = P;
    }
    else if (b[1] == 's')
    {
        dp[1][0] = R;
    }
    else
    {
        dp[1][1] = S;
    }
    for (int i = 2; i <= m; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 3; ++k)
            {
                if (j == k)
                    continue;
                if (stg(k, b[i]))
                    dp[i][k] = max(dp[i][k], dp[i - 1][j] + arz(k));
                else
                    dp[i][k] = max(dp[i][k], dp[i - 1][j]);
            }
        }
    }
    ans += max(dp[m][0], max(dp[m][1], dp[m][2]));
}

int main()
{
    scanf("%d%d", &n, &k);
    scanf("%d%d%d", &R, &S, &P);
    scanf(" %s", a);
    for (int i = 0; i < k; ++i)
    {
        m = 0;
        for (int j = i; j < n; j += k)
        {
            b[++m] = a[j];
        }
        solv();
    }
    printf("%d\n", ans);
    return 0;
}


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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX/2+2],R[MAX/2+2];

llong merge(int A[], int n, int left, int mid, int right){
	int i,j,k;
	llong cnt = 0;
	int lenL = mid-left;
	int lenR = right-mid;
	for(i = 0; i < lenL; i++) L[i] = A[left+i];
	for(i = 0; i < lenR; i++) R[i] = A[mid+i];
	L[lenL] = R[lenR] = SENTINEL;
	i = j = 0;
	for(k = left; k < right; k++){
		if( L[i] <= R[j] ) A[k] = L[i++];
		else { A[k] = R[j++]; cnt += lenL-i;}
	}
	return cnt;
}

llong mergeSort(int A[], int n, int left, int right){
	int mid;
	llong cnt = 0;
	if(left+1 < right){
		mid = (left+right)/2;
		cnt += mergeSort(A,n,left,mid);
		cnt += mergeSort(A,n,mid,right);
		cnt += merge(A,n,left,mid,right);
	}
	return cnt;
}

int main(){
	int A[MAX],n;
	llong cnt = 0;
	
	cin >> n;
	for(int i = 0; i < n; i++) cin >> A[i];
	cnt = mergeSort(A,n,0,n);
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4656
(function(input) {
    var lines = input.split('\n');
    for (var i = 0; i < lines.length; i++) {
        var items = lines[i].split(' ').map(Number);
        var h = items[0];
        var w = items[1];
        if (!h && !w) {
            break;
        }
        console.log(Array(h + 1).join(Array(w + 1).join('#') + '\n'));
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7644
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int abs(int x)
{
	if (x < 0) return -x;
	else return x;
}

int main()
{
	int n, k;
	cin >> n >> k;
	int min = INF;

	int x[n];
	REP(i, n) cin >> x[i];

	REP(i, n - k + 1){
		int far = 0;
		far += abs(x[i + k - 1] - x[i]);
		if (x[i] < 0 and x[i + k - 1] > 0){
			if (abs(x[i]) < x[i + k - 1]) far += abs(x[i]);
			else far += x[i + k - 1];
		}
		if (x[0] > 0) far += x[i];
		else if (x[n - 1] < 0) far += abs(x[i + k - 1]);
		if (far < min) min = far;
	}

	cout << min << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

signed main() {
  int N;
  cin >> N;
  
  vector<int> num(1001);
  for( int i = 2; i <= N; i++ ){
    int A = i;
    int B = 2;
    int now = 0;
    while( A > 0 && B <= i ){
      if( A%B == 0 ){
        A /= B;
        num.at(B)++;
      }else{
        B++;
      }
    }
  }
  
  int ans = 1;
  for( int i = 0; i <= 1000; i++ ){
    if( num.at(i) > 0 ) ans = (ans*(num.at(i)+1))%MOD;
  }
  cout << ans << endl;

    
  
  
}


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

int main(){
    int n,m,k;
    cout<<fixed;
    cout.precision(8);
    while(cin>>n>>m>>k,n){
        double dp[2][n*m+1];
        fill(dp[0],dp[2],0.0);
        dp[0][0]=1;
        for(int i=0;i<n;i++){
            for(int j=0;j<=n*m;j++) dp[i&1^1][j]=0;
            for(int j=0;j<=n*m;j++){
                for(int d=1;d<=m&&j+d<=n*m;d++){
                    dp[i&1^1][j+d]+=dp[i&1][j]/m;                
                }
            }
        }
        double ans = 0;
        for(int i=0;i<=n*m;i++){
            ans+=dp[n&1][i]*(max(1,i-k));
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3244
class Flood:
    """
    begin : int
        水たまりの始まる場所
    area : int
        水たまりの面積
    """
    def __init__(self, begin, area):
        self.begin = begin
        self.area = area

down_index_stack = []  # \の場所
flood_stack = []  # (水たまりの始まる場所, 面積)


for i, c in enumerate(input()):
    if c == '\\':
        down_index_stack.append(i)
    if c == '/':
        if len(down_index_stack) >= 1:  # 現在の/に対応する\が存在したら

            l = down_index_stack.pop()  # 現在の水たまりの始まる場所
            area = i - l  # 現在の水たまりの現在の高さの部分の面積はi-l

            # 現在の水たまりが最後の水たまりを内包している間は
            # (現在の水たまりの始まる場所が最後の水たまりの始まる場所より前にある間は)
            while len(flood_stack) >= 1 and l < flood_stack[-1].begin:
                # 最後の水たまりを現在の水たまりに取り込む
                last_flood = flood_stack.pop()
                area += last_flood.area

            flood_stack.append(Flood(l, area))  # 現在の水たまりを最後の水たまりにして終了


area_list = [flood.area for flood in flood_stack]
print(sum(area_list))
print(' '.join(list(map(str, [len(area_list)] + area_list))))



Measured memory_bytes: 6484
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    int a4 = 0,a2 = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a%4 == 0) a4++;
        else if(a%2 == 0) a2++;
    }

    cout << (n/2-a2/2-a4 <= 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256