akhauriyash/Code-Regression huggingface dataset:
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;
    int sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 || i % 5 == 0) sum += i;
    }

    cout << (N+1) * N / 2 - sum << endl;

    return 0;
}

Measured memory_bytes: 3652
#pragma comment(linker, "/STACK:64777216")
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <stdio.h>
#include <cctype>
#include <algorithm>
#include <utility>
#include <cassert>
#include <complex>
#include <time.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back

typedef long long Int;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;

const int MAX = 1000007;
const int CNT = 17;



int main()
{
	//freopen("in.txt", "r", stdin);


	int n, p;
	int c0 = 0, c1 = 0;
	cin >> n >> p;
	FOR (i,0,n)
	{
		int x;
		cin >> x;
		if (x % 2 == 0)
			++ c0;
		else
			++ c1;
	}

	Int res = 1;
	FOR (i,0,n)
	res = res * 2;

	if (p == 0)
	{
		if (c1)
			res /= 2;
	}
	else
	{
		if (c1 == 0)
			res = 0;
		else
			res /= 2;
	}

	cout << res << endl;




	return 0;
}


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

typedef long long ll;
typedef long double ld;

int graf[505][505];

void solve(vector <int> vec, int lvl){
    int n = vec.size();
    if(n == 1) return;
    vector <int> a;
    vector <int> b;
    for(int i=0; i<n; i++){
        if(i%2) a.push_back(vec[i]);
        else b.push_back(vec[i]);
        for(int j=0; j<n; j++){
            if((i-j)%2) graf[vec[i]][vec[j]] = lvl;
        }
    }
    solve(a, lvl+1);
    solve(b, lvl+1);
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    vector <int> vec;
    for(int i=1; i<=n; i++) vec.push_back(i);
    solve(vec, 1);
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            cout << graf[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	vector<int>c(n);
	for (int i = 0;i < 3;i++) {
		for (int j = 0;j < n;j++) {
			if (i == 0) {
				cin >> a[j];
			}
			if (i == 1) {
				cin >> b[j];
			}
			if (i == 2) {
				cin >> c[j];
			}
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	vector<llint>bb(n);
	vector<llint>cc(n);
	int x = 0;
	for (int i = 0;i < n;i++) {
		if (0 < i) {
			bb[i] = bb[i - 1];
		}
		for (int j = x;j < n;j++) {
			if (a[j] < b[i]) {
				bb[i]++;
			}
			else {
				x = j;
				break;
			}
			x = -1;
		}
		if (x == -1) {
			x = n;
		}
	}
	x = 0;
	for (int i = 0;i < n;i++) {
		if (0 < i) {
			cc[i] = cc[i - 1];
		}
		for (int j = x;j < n;j++) {
			if (b[j] < c[i]) {
				cc[i] += bb[j];
			}
			else {
				x = j;
				break;
			}
			x = -1;
		}
		if (x == -1) {
			x = n;
		}
	}
	llint ans = 0;
	for (int i = 0;i < n;i++) {
		ans += cc[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2944
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    let mut s = 0;
    let mut m = 1_000_i64;
    for i in 0..n {
        if i == n - 1 {
            m += a[i] * s;
        }
        for j in i + 1..n {
            if a[i] == a[j] {
                continue;
            } else if a[i] < a[j] {
                if s == 0 {
                    s = m / a[i];
                    m -= a[i] * s;
                }
                break;
            } else if a[i] > a[j] {
                m += a[i] * s;
                s = 0;
                break;
            }
        }
    }
    let ans = m;
    println!("{}", ans);
}


Measured memory_bytes: 2164
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

struct UnionFind{
    vector<int> data;
    /* constructor */
    UnionFind(int sz){ data.assign(sz,-1); }
    /* merge the set to which x belongs and the set to which y belongs */
    bool unite(int x,int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    /* find the root of k */
    int find(int k){
        if (data[k] < 0) return k;
        return data[k] = find(data[k]);
    }
    /* calculate the size of the set to which k belongs */
    int size(int k){ return -data[find(k)]; }
};

int main(void){
	int N, M;
	cin >> N >> M;
	UnionFind uf(N);
	for (int i = 0; i < M; ++i){
		int a, b; cin >> a >> b;
		--a, --b;
		uf.unite(a, b);
	}
	int res = 0;
	for (int i = 0; i < N; ++i)
		res = max(res, uf.size(i));
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    long K;
    cin >> N >> M >> K;
    bool yes = false;
    for(int i = 0; i <= N; i++){
    	for(int j = 0; j <= M; j++){
    		if(M*i+N*j-i*j*2 == K){
    			yes = true;
    			break;
    		}
    	}
    }
    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

x = input()
X = int(x)

div = make_divisors(X)

for item in div:
    for A in range(-1000,1000):
        B = A - item

        if A**5 - B**5 == X:
            print(str(A) + " " + str(B))
            break
        else:
            continue
        break


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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF =1LL << 60;

int N;
long long h[1000010];

long long dp[1000010];

long long rec(int i) {
  if (dp[i] < INF) return dp[i];
  
  if (i == 0) return 0;
  
  long long res = INF;
  chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));
  if (i > 1) chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));
  
  return dp[i] = res;
}

int main() {

  int N; cin >> N;
  for(int i = 0; i < N; i++) cin >> h[i];
  
  for (int i = 0; i < N; i++) dp[i] = INF;
  
  cout << rec(N - 1) << endl;
}

    

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

int main(){
    int N;
    cin >> N;
    vector<int64_t> l(87);
    l.at(0) = 2;
    l.at(1) = 1;
    for (int i = 2; i < 87; i++){
        l.at(i) = l.at(i-1) + l.at(i-2);
    }
    cout << l.at(N) << endl;
}

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

int main() {
  ll X;
  cin >> X;
  ll y = 100;
  ll year = 0;
  while (y < X) {
    y += (double) y * 0.01;
    year++;
  }
  cout << year << endl;
}

Measured memory_bytes: 3620
import numpy as np
def enum753():
    table = str.maketrans({
        '0': '3',
        '1': '5',
        '2': '7'
    })
    ret = []
    for d in range(3, 10):
        for n in range(3 ** d):
            s = np.base_repr(n, 3).zfill(d).translate(table)
            if all(c in s for c in "357"):
                ret.append(int(s))
    return ret

print(np.searchsorted(enum753(), int(input()), side="right"))


Measured memory_bytes: 13436
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);


using ll = long long;
using namespace std;
using ld = long double;
struct stu
{
    int id,val;
};

bool cmp(stu &a, stu &b)
{
    return (a.val<b.val);
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    int n;
    cin >> n;
    vector<stu> a(n);
    for(int i=0; i<n; ++i)
    {
        int v;
        cin >> v;
        stu k;
        k.id=i+1;
        k.val = v;
        a[i]= k;
    }
    sort(a.begin(), a.end(), cmp);
    for(int i=0; i<n; ++i) cout << a[i].id << ' ';
    return 0;
}



Measured memory_bytes: 1664
/*
"اله السماء يعطينا النجاح ونحن عبيده نقوم ونبني" 
"تكفيك نعمتي لان قوتي في الضعف تكمل"
created by shady rafet 
my face book : https://www.facebook.com/profile.php?id=100019579575853
never give up
one day i will do it ':(

*/
#include <bits/stdc++.h>
using namespace std;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ul;
const ll oo = 1e18;
const ll N = 1e6;
const ll mod = 1e9 + 7;
#define point complex<double>
const double pi = acos(-1);
double dot(point a, point b)
{
    return (conj(a) * b).real();
}
double cross(point a, point b)
{
    return (conj(a) * b).imag();
}
ll inv[N],fact[N];
ll fb(ll x, ll y)
{
    if(y == 0)
    return 1;
   ll ans = fb(x,y/2);
   ans = (ans * ans)%mod;
   if(y % 2 !=0)
   {
       ans = (ans*(x%mod))%mod;
   }
   return ans ;
}
void pre(ll n)
{
    fact[0] = 1;
    inv[0] = 1;
    for ( int i = 1;i<=n;i++)
    {
        fact[i] = (i * fact[i-1])% mod;
        inv[i] = fb(fact[i], mod-2);
    }
}
ll ncr (ll n , ll r)
{
      return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
ll npr (ll n,ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}
vector<int> adj[N];
bool visted[N];
int main()
{
   int n,m,sum = 0;
   cin>>n>>m;
   int a[n];
 for(int i = 0;i<n;i++)
cin>>a[i];
sort(a,a+n);
for(int j = 0;j<m;j++)
sum+=a[j];
cout<<sum;
    return 0;
}

Measured memory_bytes: 27000
#include <iostream>
#include<vector>
#include <algorithm>

using namespace std;
typedef pair<int, int > P;
vector<vector<int> > ita(32, vector<int>(32, 0));
vector<vector<int> > itasum(33, vector<int>(33, 0));
vector<vector<vector<vector<P > > > > dp(33, vector<vector<vector<P > > >(33, vector<vector<P > >(33, vector<P >(33, P(-1, -1)))));
P cut(int, int, int, int);
int over;

int main() {
	while (true) {
		for (int i = 0; i < 33; i++) {
			for (int j = 0; j < 33; j++) {
				for (int k = 0; k < 33; k++) {
					for (int l = 0; l < 33; l++) {
						dp[i][j][k][l] = P(-1, -1);
					}
				}
			}
		}
		int h, w, s;
		cin >> h >> w >> s;
		if (h == 0)return 0;
		int sum = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> ita[i][j];
				sum += ita[i][j];
			}
		}
		for (int i = 0; i < 33; i++) {
			itasum[i][0] = 0;
			itasum[0][i] = 0;
		}
		for (int i = 0; i < h; i++) {
			int r = 0;
			for (int j = 0; j < w; j++) {
				for (int k = 0; k <= i; k++) {
					r += ita[k][j];
				}
				itasum[i+1][j+1] = r;
				//cout << r << " ";
			}
			//cout << endl;
		}

		over = sum - s;
		//cout << over << endl;
		P cutnum = cut(0, 0, h, w);
		cout << cutnum.first <<" "<< cutnum.second << endl;
	}
}


P cut(int sx, int sy, int ex, int ey) {
	P empty = make_pair(-1, -1);
	if (dp[sx][sy][ex][ey] != empty)return dp[sx][sy][ex][ey];
	if (itasum[ex][ey] - itasum[sx][ey] - itasum[ex][sy] + itasum[sx][sy] < over)return P(0,0);
	vector<P> sol;
	sol.push_back(P(0, 0));
	for (int i = sx + 1; i < ex; i++) {
		P P1 = cut(sx, sy, i, ey);
		P P2 = cut(i, sy, ex, ey);
		if (P1.first == 0 || P2.first == 0) { 
			sol.push_back(P(0, 0)); 
		}else {
			P p = make_pair(P1.first + P2.first, min(P1.second, P2.second));
			sol.push_back(p);
		}
	}
	for (int i = sy + 1; i < ey; i++) {
		P P1 = cut(sx, sy,ex, i);
		P P2 = cut(sx, i, ex, ey);
		if (P1.first == 0 || P2.first == 0) { 
			sol.push_back(P(0, 0)); 
		}else {
			P p = make_pair(P1.first + P2.first, min(P1.second, P2.second));
			sol.push_back(p);
		}
	}
	sort(sol.begin(), sol.end());
	if (sol.back().first == 0) {
		dp[sx][sy][ex][ey] = P(1, itasum[ex][ey] - itasum[sx][ey] - itasum[ex][sy] + itasum[sx][sy]-over);
		return P(1, itasum[ex][ey] - itasum[sx][ey] - itasum[ex][sy] + itasum[sx][sy]-over);
	}
	dp[sx][sy][ex][ey] = sol.back();
	//cout << sx << " " ;
	return sol.back();
}

Measured memory_bytes: 13512
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
toTuple (x : y : _) = (x, y)

main = do
    [n, m] <- getIntList
    lrs <- map toTuple <$> replicateM m getIntList
    let (x, y) = foldl solve (1, n) lrs
    print $ max 0 (y - x + 1)

solve (l, r) (l', r') = (max l l', min r r')

Measured memory_bytes: 53628
import java.util.Scanner;
public class Main{
  public static long gcd(long a, long b){
    if(a < b) {
      long tmp = a;
      a = b;
      b = tmp;
    }
    if(b==0) return a;
    return gcd(b,a%b);
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    a -= 1;
    
    long lcm = c * d / gcd(c,d);
    long n = b - (b/c) - (b/d) + (b/lcm);
    long m = a - (a/c) - (a/d) + (a/lcm);
    
    System.out.println(n-m);
  }
}


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

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


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

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s;  cin >> s;
    int n = s.size();
    bool ans = true;
    for (int i = 0; i < n; ++i) {
        if (s[i] != s[n - 1 - i])  ans = false;
    }
    string s1 = s.substr(0, (n - 1) / 2);
    string s2 = s.substr((n + 3) / 2 - 1);
    for (int i = 0; i < s1.size(); ++i) {
        if (s1[i] != s1[s1.size() - 1 - i])  ans = false;
    }
    for (int i = 0; i < s2.size(); ++i) {
        if (s2[i] != s2[s2.size() - 1 - i])  ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(System.in);

	public void syori(){
		int ue = sc.nextInt();
		int si = sc.nextInt();
		System.out.println(ue-si);
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Main m = new Main();
		for(int i=0;i<7;i++){
			m.syori();
		}
	}

}

Measured memory_bytes: 17312
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    LLI q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    LLI per1=min(min(4*q,2*h),s);
    LLI per2=min(2*per1,d);
    cout<<(n/2)*per2+(n%2)*per1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k;
	cin>>k;
	queue<ll> q;
	rep(i,9)q.push(i+1);
	rep(i,k-1){
		ll t=q.front();
		q.pop();
		ll end=t%10;
		for(ll j=end-1;j<=end+1;j++){
			if(j<0||9<j)continue;
			q.push(t*10+j);
		}
	}
	puta(q.front());
}


Measured memory_bytes: 4704
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long s = n % (a + b), t = n / (a + b), sum = 0;
        sum += a * t;
        sum += (s > a)? a:s;
        System.out.println(sum);
    }
}


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

namespace Algorithm
{
    class Program
    {
        static bool[] color = new bool[6];
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var ans = new int[n][];

            for (var i = 0; i < n; i++)
            {
                var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ans[i] = new int[n];
                for (var j = 2; j < 2 + t[1]; j++)
                {
                    ans[t[0] - 1][t[j] - 1] = 1;
                }
            }

            for (var i = 0; i < n; i++)
                Console.WriteLine(string.Join(" ", ans[i]));
        }
    }
}



Measured memory_bytes: 16324
from collections import *
n = int(input())
v = list(map(int,input().split()))
if len(set(v))==1:
    print(len(v)//2)
    exit()
n_even = v[0::2]
n_odd = v[1::2]
a = Counter(n_even).most_common()+[(0,0)]
b = Counter(n_odd).most_common()+[(0,0)]
#print(a)
#print(b)
if a[0][0] == b[0][0]:
    ans = min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1])
else:
    ans = n - a[0][1] - b[0][1]
print(ans)

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

int main()
{
    string s;
    string a;
    cin >> s;
    for( int i = 0; i < s.size(); ++i ){
        a.push_back('x');
    }
    
    cout << a << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define M 1005
#define N 51
using namespace std;
int r,c,m,gy,gx,T,ans;
int C[3][N][N];
bool used[N][N];
string s[N];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
int d[N][N];

void update(int y,int x,int t){
  if(d[y][x]==-1)ans+=C[1][y][x]+C[2][y][x];
  else ans+=min((t-d[y][x])*C[0][y][x],
		C[1][y][x]+C[2][y][x]);
  d[y][x]=t;
}

bool dfs(int y,int x,int t){
  
  if(used[y][x])return false;
  used[y][x]=true;
  
  if(y==gy&&x==gx){
    update(y,x,t);
    T=t;
    return true;
  }
  
  bool res=false;
  rep(i,4){
    int ny=y+dy[i],nx=x+dx[i];
    if(ny<0||nx<0||r<=ny||c<=nx)continue;
    if(s[ny][nx]=='#')continue;
    res|=dfs(ny,nx,t+1);
  }
  if(res)update(y,x,t);
  
  return res;
}

int y[M],x[M];

int main(){
  cin>>r>>c>>m;
  rep(i,r)cin>>s[i];
  
  rep(i,3)
    rep(j,r)
      rep(k,c)cin>>C[i][j][k];
  
  rep(i,m)cin>>y[i]>>x[i];
  
  memset(d,-1,sizeof(d));
  
  rep(i,m-1){
    gy=y[i+1],gx=x[i+1];
    memset(used,0,sizeof(used));
    dfs(y[i],x[i],T);
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3392
#include <stdio.h>

int main(void)
{
	int a[100];
	int n;
	int i;

	scanf("%d", &n);
	i = 0;
	while(i < n)
	{
		scanf("%d", &a[i]);
		i++;
	}

	i = 0;
	while(i < n)
	{
		printf("%d", a[n - i - 1]);
		if(i != n - 1)
			printf(" ");
		i++;
	}
	printf("\n");

	return (0);
}



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

int n;
vector<long long> t, a;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
long long ans = 1;
long long mod = 1e9+7;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, t);
	readVector(n, a);
	bool f[n] = {}, g[n] = {};
	for(int i=0; i<n; ++i)
		if(i == 0 || t[i] != t[i-1])
			f[i] = true;
	for(int i=n-1; i>=0; --i)
		if(i == n-1 || a[i] != a[i+1])
			g[i] = true;
//	for(int i=0; i<n; ++i)
//		cout << (f[i]?1:0) << " " << (g[i]?1:0) << "\n";
	for(int i=0; i<n; ++i){
		if(f[i] && g[i]){
			if(t[i] != a[i])
				ans *= 0;
		}else if(!f[i] && !g[i]){
			ans *= min(t[i], a[i]);
			ans %= mod;
		}else if(f[i]){
			if(t[i] > a[i])
				ans *= 0;
		}else if(g[i]){
			if(a[i] > t[i])
				ans *= 0;
		}
//		cout << ans << "\n";
	}
	cout << ans << "\n";
}

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

int main(){
	int n;
	cin >> n;
	map<string,int> cnt;
	rep(i,n){
		string s;
		cin >> s;
		cnt[s]++;
	}
	int m;
	cin >> m;
	rep(i,m){
		string t;
		cin >> t;
		cnt[t]--;
	}
	int maxim = 0;
	for(auto p : cnt){
		auto k = p.first;
		auto v = p.second;
		maxim = max(maxim,v);
	}
	cout << maxim << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
	int H,W;
	
	int i,j;
	
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}printf("\n");
		}printf("\n");
	}
	
	
	return 0;}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
vector<int> adj[100005];
ll mod = 1e9+7;
int dp[100005][2];
ll dfs(int node, int color, int parent){
    //cout << node << " " << color << parent << endl;
    if(dp[node][color] != -1)return dp[node][color];
    ll ways = 1;
    for(int v : adj[node]){
        ll curr = 0;
        if(v != parent){
            if(color == 0){
                curr += dfs(v,1,node);
                curr %= mod;
            }
            curr += dfs(v,0,node);
            curr %= mod;
            ways *= curr;
            ways %= mod;
        }
        //ways *= curr;
    }
    //cput << node << " " << culor << " " << ways << endl;
    return dp[node][color] = ways;


}
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int N;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for(int i = 0; i < N; i++){
        dp[i][0] = -1;
        dp[i][1] = -1;
    }
    cout << (dfs(0, 0, -1) + dfs(0,1,-1))%mod<< endl; 

}



Measured memory_bytes: 16772
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();

        int count10000 = -1;
        int count5000 = -1;
        int count1000 = -1;

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n-i; j++) {
                int tmpCount10000yen = i*10000;// 10000: i枚
                int tmpCount5000yen = j*5000;// 5000: j枚数
                int tmpCount1000yen = 0;// 1000: n-i-j枚数
                if ((n-i-j) > 0) {
                    tmpCount1000yen = (n-i-j)*1000;// 1000: n-i-j枚数
                }

                int tmpAns = tmpCount10000yen + tmpCount5000yen + tmpCount1000yen;
                if (y == tmpAns) {
                    count10000 = i;
                    count5000 = j;
                    count1000 = n-i-j;
                    break;
                }
            }
        }

        System.out.println(count10000 + " " + count5000 + " " + count1000);
    }
}


Measured memory_bytes: 22868
import sys

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n, k = read_ints()
    x = read_int_list()
    ans = INF

    for i in range(n - k + 1):
        left = x[i]
        right = x[i + k - 1]
        if left < 0 and right > 0:
            ans = min(ans, min(abs(left), abs(right)) * 2 + max(abs(left), abs(right)))
        else:
            ans = min(ans, max(abs(left), abs(right)))
    
    print(ans)
    
if __name__ == '__main__':
    Main()

Measured memory_bytes: 20372
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cini(n);
    cinai(a,n);

    int allxor=0;
    for(int i=0; i<n; i++) 
        allxor^=a[i];

    for(int i=0; i<n; i++)
        cout<<(allxor^a[i])<<" ";
    cout<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 4764
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main binarySearch = new Main();
		Scanner input = new Scanner(System.in);
		int[] integers = new int[input.nextInt()];
		input.nextLine();
		integers = binarySearch.nextLineToIntArray(input.nextLine(), integers);
		int[] queries = new int[input.nextInt()];
		input.nextLine();
		queries = binarySearch.nextLineToIntArray(input.nextLine(), queries);
		ArrayList<int[]> unsortedArrays = new ArrayList<int[]>();
		unsortedArrays.add(integers);
		unsortedArrays.add(queries);
		ArrayList<int[]> sortedArrays = binarySearch.selectionSortData(unsortedArrays);
		System.out.println(binarySearch.binarySearch(sortedArrays.get(0), sortedArrays.get(1)));
	}
	
	public int[] nextLineToIntArray(String nextLine, int[] array) {
		String integerString = "";
		int arrayIndex = 0;
		int integerValue = 0;
		for (int i = 0; i < nextLine.length(); i++) {
			if (i == nextLine.length() - 1) {
				integerString = integerString + nextLine.substring(i);
			} else {
				integerString = integerString + nextLine.substring(i, i + 1);
			}
			try {
				integerValue = Integer.parseInt(integerString);
			} catch (NumberFormatException e) {
				array[arrayIndex] = integerValue;
				arrayIndex++;
				integerString = "";
			}
		}
		if (integerString != "") {
			array[array.length - 1] = integerValue; 
		}
		
		return array;
	}
	
	public int binarySearch(int[] integers, int[] queries) {
		int count = 0;
		int midpoint;
		for (int i = 0; i < queries.length; i++) {
			int high = integers.length;
			int low = 0;
			for (int j = 1; j < integers.length; j*=2) {
				midpoint = (high + low) / 2;
				if (integers[midpoint] > queries[i]) {
					high = midpoint;
				} else if (integers[midpoint] < queries[i]) {
					low = midpoint;
				} else {
					count++;
					break;
				}
			}
			
		}
		return count;
	}
	
	public ArrayList<int[]> selectionSortData(ArrayList<int[]> setData) {
		for (int i = 0; i < setData.size(); i++) {
			int[] set = setData.remove(i);
			int largestNumberIndex = -1;
			int largestNumber = -1;
			int reverseSetIndex = set.length - 1;
			for (int j = 0; j >= 0; j++) {
				int arrayValue = set[j];
				if (arrayValue > largestNumber) {
					largestNumber = arrayValue;
					largestNumberIndex = j;
				}
				if (j == reverseSetIndex) {
					set[largestNumberIndex] = set[reverseSetIndex];
					set[reverseSetIndex] = largestNumber;
					reverseSetIndex--;
					largestNumber = 0;
					j = (reverseSetIndex <= 0)? -2 : -1;
				}
			}
			setData.add(i, set);
		}
		return setData;
	}
	
}



Measured memory_bytes: 43244
#include <iostream>
#include <queue>

using namespace std;

int main()
{
	int N;
	cin >> N;
	priority_queue<double, vector<double>, greater<double>> q;
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		int v;
		cin >> v;
		q.push(v);
	}
	while (q.size() != 1)
	{
		double v1, v2, new_v;
		v1 = q.top();
		q.pop();
		v2 = q.top();
		q.pop();
		new_v = (v1 + v2) / 2.0;
		q.push(new_v);
	}
	cout << q.top() << endl;
	return 0;
}

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

void init() {
//#if __GLIBCXX__ == 20160609
#ifdef KEK
    freopen("a.in", "r", stdin);
    ///freopen("a.out", "w", stdout);
#else
    ///freopen(TASKNAME".in", "r", stdin);
    ///freopen(TASKNAME".out", "w", stdout);
#endif
}
#define pb push_back
#define fi first
#define se second

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

const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = (int)1e6 + 34;

int a[200200], q[200200], w[200200], p[200200], s[200200];

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i & 1)
            q[a[i]]++;
        else
            w[a[i]]++;
    }
    for (int i = 1; i <= 100000; i++)
        p[i] = (q[i] > q[p[i - 1]] ? i : p[i - 1]);
    for (int i = 100000; i > 0; i--)
        s[i] = (q[i] > q[s[i + 1]] ? i : s[i + 1]);
    int ans = 1000000000;
    for (int i = 1; i <= 100000; i++) {
        //cerr << n - w[i] - max(q[p[i - 1]], q[s[i + 1]]) << ' ' << q[p[i - 1]] << ' ' << s[p[i + 1]] << "\n";
        ans = min(ans, n - w[i] - max(q[p[i - 1]], q[s[i + 1]]));

    }
    cout << ans << "\n";
}

int main() {
    init();
    solve();

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define PI 3.14159265358979
	#define EPS 1e-8
	#define mod 
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define endl "\n"
		 
	const ll INF=1e15;	
	const int N=1e5+5;
	 

	 
	long long binpow(long long a, long long b, long long m) {
		a %= m;
		long long res = 1;
		while (b > 0) {
			if (b & 1)
				res = res * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return res;
	}
	
	
	int main()
	{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);cout.tie(0);
		
		ll n;
		cin>>n;
		
		vector<int> v(n);
		ll val=0;
		for(int i=0;i<n;i++)
		{
			cin>>v[i];
			val^=v[i];
		}
		
		for(int i=0;i<n;i++)
		{
			cout<<(val^v[i])<<" ";
		}
		
		
	
	}
		
		
	


Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
int main(){
    int Answer =0;
    int left, right;
    int N;
    int Q;
    scanf("%d%d",&N,&Q);
    int Place[N];
    int number=0;
    char Str[N+1];
    int flag=0;
    scanf("%s",Str);
    for(int i=0; i<N; i++){
        if(flag && Str[i]=='C'){
            number++;
        }
        if(Str[i]=='A'){
            flag=1;
        }else{
            flag=0;
        }
        Place[i]=number;
    }
    for(int i=0; i<Q; i++){
        scanf("%d%d",&left, &right);
        printf("%d\n",Place[right-1]-Place[left-1]);
    }
    return 0;
}

Measured memory_bytes: 1280
// ABC 159-B
// 2020.3.24 bal4u

#include <stdio.h>
#include <string.h>

int isPalin(char *s, int n) {
	int i = 0, j = n - 1;
	while (i < j) {
		if (s[i] != s[j]) return 0;
		i++, j--;
	}
	return 1;
}

char S[105]; int N;

int main()
{
	int t;
	scanf("%s", S);
	N = strlen(S);
	t = (N+3)/2-1;
	puts((isPalin(S, N) && isPalin(S, (N-1)/2)
	    && isPalin(S+t, N-t))? "Yes": "No");
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		for (int i = 0; i < H; i++) {
			String C = sc.next();
			System.out.println(C);
			System.out.println(C);
		}
		
  }
}

Measured memory_bytes: 37264
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=10000;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    string s;
    cin>>s;
    int c[26]={};
    for(int i=0;i<s.length();i++){
        int a=s[i]-'a';
        c[a]++;
    }
    bool f=true;
    for(int i=0;i<26;i++){
        if(c[i]%2!=0){
            f=false;
        }
    }
    if(f){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import itertools
a=[i for i in input()]
b=[i for i in input()]
l=list(itertools.zip_longest(a,b,fillvalue=0))
ll=[]
for i in l:
  if i[0]!=0:
    ll.append(i[0])
  if i[1]!=0:
    ll.append(i[1])  
print("".join(ll))    
              
              

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll d[50010],x[50010],y[50010],z[50010],ans,n,m;
    
int main() {
  cin >> n >> m;
  for(ll i=1; i<=n; i++) d[i]=d[i-1]+i;
  for(int i=0,a,b; i<m; i++) {
    cin >> a >> b;
    if(!a) b=lower_bound(d,d+n+1,b)-d;
    if(b>n) continue;
    if(!a) x[b]++;
    else if(a==1) y[b]++;
    else z[b]++;
  }
  for(ll i=1; i<=n; i++) {
    y[i]+=y[i-1];
    z[i]+=z[i-1];
    ans+=(i-x[i])*(i-y[i])*(i-z[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4572
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#define inf pow(10, 9)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int N;
  ci(N);
  ve<int> a(N);
  rep(i, N){
    ci(a.at(i));
  }
  int c = 0;
  rep(i, N){
    if(a.at(a.at(i) - 1) == i + 1){
      c++;
    }
  }
  co(c / 2);
}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

using namespace std;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    REP(_, M) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        g[A].push_back(B);
        g[B].push_back(A);
    }

    vector<bool> used(N, false);
    vector<vector<int>> path(2); 
    path[0].push_back(0);
    path[1].push_back(g[0][0]);
    used[0] = true;
    used[g[0][0]] = true;

    function<void(int, int)> f = [&](int u, int path_id) {
        bool updated = true;
        while (updated) {
            updated = false;
            for (int v: g[u]) {
                if (!used[v]) {
                    used[v] = true;
                    path[path_id].push_back(v);
                    u = v;
                    updated = true;
                    break;
                }
            }
        }
    };
    
    f(0, 0);
    f(g[0][0], 1);

    cout << (path[0].size() + path[1].size()) << endl;
    RREP(i, path[0].size()) cout << (path[0][i] + 1) << " "; // 1-based indexing
    REP(i, path[1].size()) cout << (path[1][i] + 1) << " "; // 1-based indexing
    cout << endl;

    return 0;
}


Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
int n,a[25],b[25],sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<=n;i++) sum+=max(a[i]-b[i],0);
	cout<<sum<<'\n';
	return 0;
}


Measured memory_bytes: 256
import math
a, b, x = [int(i) for i in input().split()]

if x >= 0.5 * (a ** 2) * b:
    print(math.degrees(math.atan2(2*((a**2) * b - x), a**3)))
else:
    print(90 - math.degrees(math.atan2(2*x, a*(b**2))))

Measured memory_bytes: 3060
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import sys


def solve(values, _nb):
    ca, cb, cc = 0, 0, 0
    for a, b, c in values:
        ca, cb, cc = max(cb + b, cc + c), max(ca + a, cc + c), max(ca + a, cb + b)
    return max(ca, cb, cc)


def do_job():
    "Do the work"
    # first line is number of test cases
    N = int(input().strip())
    values = []
    for _ in range(N):
        values.append(map(int, input().split()))
    result = solve(values, N)
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


Measured memory_bytes: 58388
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val Array(t, a) = in.readLine.split(" ").map(_.toInt)
  val h = in.readLine.split(" ").map(_.toInt)
  val ans = h./:((Int.MaxValue, 0, 1)) { case((v, idx, i), hi) =>
      val vi = (a * 1000 - (t * 1000 - hi * 6)).abs
      if(vi < v) (vi, i, i + 1)
      else (v, idx, i + 1)
    }._2
  println(ans)
}

Measured memory_bytes: 25544
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C

int gkey(char input[]) {
	int len = strlen(input);
	int sum = 0, p = 1;
	for (int i = 0; i < len; i++) {
		int res = 0;
		switch (input[i]) {
			case 'A':
				res = 1;
				break;
			case 'T':
				res = 2;
				break;
			case 'G':
				res = 3;
				break;
			case 'C':
				res = 4;
		}
		sum += p * res;
		p *= 5;
	}
	return sum;
}

int main() {
	int n;
	cin >> n;
	vector<bool> arr(20000000);

	for (int i = 0; i < 20000000; i++) arr[i] = false;
	for (int i = 0; i < n; i++) {
		char op[10], param[12];
		cin >> op >> param;
		switch (op[0]) {
			case 'i':
				arr[gkey(param)] = true;
				break;
				
			case 'f':
				int key = gkey(param);
				cout << (arr[key] == true ? "yes" : "no") << endl;
				break;
		}
	}
	return 0;
}

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

int main(){

    int64_t X;
    cin >> X;

    int64_t A,B;

    for(int a=-118;a<120;a++){
        bool flg = false;
        for(int b=-118;b<120;b++){
            int64_t num = pow(a,5)-pow(b,5);
            if(num ==X){
                A=a;
                B=b;
                flg =true;
                break;
            }
        }
        if(flg){
            break;
        }
    }


    cout << A << " " << B << endl;

}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
int n;
vector <string> str;
string mem[15][15];
typedef pair <string,int> P;

string con(string a,string b){
  int K=0;
  for(int i=0;i<a.size();i++){
    int j=i,k=0;
    while(a[j]&&b[k]&&a[j]==b[k]) j++,k++;
    if(!a[j]||!b[k])K=max(K,k);
  }
  return b.substr(K,b.size());
}

string solve(){
  string dp[1<<14][14];
  for(int i=0;i<n;i++) dp[1<<i][i]=str[i];
  
  for(int i=0;i<(1<<n);i++)
    for(int k=0;k<n;k++){
      if(dp[i][k]=="")continue;
      for(int j=0;j<n;j++){
	if((i&(1<<j)))continue;
	string nx=dp[i][k]+mem[k][j];
	int ni=i|1<<j;
	string &ndp=dp[ni][j];
	if(!ndp.size()||
	   nx.size()<ndp.size()||
	   (nx.size()==ndp.size()&&ndp>nx))ndp=nx;
      }
    }

  string res=dp[(1<<n)-1][0];
  for(int i=1;i<n;i++) {
    string a=dp[(1<<n)-1][i];
    if(res.size()>a.size()||(a.size()==res.size()&&res>a)) res=a;
  }
  return res;
}

int main(){
  
  while(cin>>n,n){
    str.resize(n);
    for(int i=0;i<n;i++)cin>>str[i];

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	if(i!=j&&con(str[i],str[j])==""){
	  str.erase(str.begin()+j);
	  n--;
	  i=-1;
	  break;
	}
    
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)mem[i][j]=con(str[i],str[j]);

    cout<<solve().size()<<endl;
  }

  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  if(n==2){
    int m=2*n*n-2*n;
    vector<vector<int>> e(n*n);
    int u,v;
    rep(i,m){
      cin >> u >> v;
      e[u-1].push_back(v-1);
      e[v-1].push_back(u-1);
    }
    vector<int> dist(n*n,-1);
    queue<int> q;
    q.push(0);
    dist[0]=0;
    while(!q.empty()){
      int now=q.front();
      q.pop();
      for(auto nx:e[now]){
        if(dist[nx]!=-1) continue;
        dist[nx]=dist[now]+1;
        q.push(nx);
      }
    }
    vector<vector<int>> ans(n,vector<int>(n,-1));
    rep(i,4){
      if(dist[i]==0) ans[0][0]=i;
      else if(dist[i]==2) ans[1][1]=i;
      else{
        if(ans[0][1]==-1) ans[0][1]=i;
        else ans[1][0]=i;
      }
    }
    rep(i,n){
      rep(j,n){
        cout << ans[i][j]+1;
        if(j<n-1) cout << " ";
        else cout << endl;
      }
    }
    return 0;
  }
  vector<vector<int>> e(n*n);
  int m=2*n*n-2*n;
  int u,v;
  rep(i,m){
    cin >> u >> v;
    e[u-1].push_back(v-1);
    e[v-1].push_back(u-1);
  }
  int s;
  rep(i,n*n){
    if(e[i].size()==2){
      s=i;
      break;
    }
  }
  vector<int> par(n*n,-1);
  vector<int> dist(n*n,-1);
  queue<int> q;
  q.push(s);
  dist[s]=0;
  par[s]=s;
  int t;
  while(!q.empty()){
    int now=q.front();
    q.pop();
    for(auto nx:e[now]){
      if(dist[nx]!=-1) continue;
      dist[nx]=dist[now]+1;
      par[nx]=now;
      if(dist[nx]==n-1&&e[nx].size()==2){
        t=nx;
        goto next;
      }
      q.push(nx);
    }
  }
  next:;
  vector<bool> usd(n*n,false);
  vector<vector<int>> ans(n,vector<int>(n,-1));
  per(i,n){
    ans[0][i]=t;
    usd[t]=true;
    t=par[t];
  }
  rep(i,n-1){
    rep(j,n){
      for(auto nx:e[ans[i][j]]){
        if(!usd[nx]){
          ans[i+1][j]=nx;
          usd[nx]=true;
          break;
        }
      }
    }
  }
  rep(i,n){
    rep(j,n){
      cout << ans[i][j]+1;
      if(j<n-1) cout << " ";
      else cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3696
import numpy as np


N,M=map(int,input().split())
# A=np.array(list(map(int,input().split())))
A=np.array(list(map(int,input().split())),dtype=np.int32)
A=np.sort(A)

EXC=[]

for i in range(M):
    exc=list(map(int,input().split()))
    EXC.append(exc)
excArry=np.array(EXC,dtype=np.int32)

col_num=1
Arr=excArry[np.argsort(excArry[:,col_num])[::-1]]
# print(A)
# print(Arr)

point=0


for j in range (M):
    change_Num=Arr[j][1]
    count=np.count_nonzero(A<change_Num)
    if count > 0:
        m=min(count,Arr[j][0])
        A[point:point+m]=change_Num
        point+=m
        # A=np.sort(A)
    else:
        break

print(np.sum(A))
    
#     for j in range (B):
#         count=np.count_nonzero(A<C)
#         if count>0:
#             m=min(B,count)
#             A[:m]=C
#         else:
#             continue
    
#     A=np.sort(A)

# print(np.sum(A))

Measured memory_bytes: 48340