akhauriyash/Code-Regression huggingface dataset:
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      k: usize,
      x: [i64; n]
   }
   let mut p = 0;
   while p != n && x[p] < 0 {
      p += 1;
   }
   let mut ans = 1e18 as i64;
   for l in 0..k + 1 {
      let r = k - l;
      if l > p || p + r > n {
         continue;
      }
      if l == 0 {
         ans = std::cmp::min(ans, x[p + k - 1]);
      } else if r == 0 {
         ans = std::cmp::min(ans, -x[p - k]);
      } else {
         let mn = std::cmp::min(2 * x[p + r - 1] - x[p - l], x[p + r - 1] - 2 * x[p - l]);
         ans = std::cmp::min(ans, mn);
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pb push_back
# define PI  3.14159265358979323846  /* pi */
using namespace std;
typedef long long ll;
double a, b, h, m;
double res, s;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> a >> b >> h >> m;
    s = abs((h/12.0*360+m/60.0*30)-(m/60.0*360));
    s = min(s,360.0-s);
    res = sqrt(a*a+b*b-2.0*a*b*(cos(s*PI/180.0)));

    printf("%.20f", res);
}


Measured memory_bytes: 4296
#include <bits/stdc++.h>
using namespace std;
long double getProbability(int currIndex, int n, int numHeads, int numTails, vector<long double> &prob, vector<vector<long double> > &memo) {
    if (currIndex == n) {
        if (numHeads)
            return prob[currIndex];
        return (1 - prob[currIndex]);
    }
    if (memo[currIndex][numTails] != -1)
        return memo[currIndex][numTails];
    long double probHead = 0, probTail = 0;
    if (numHeads > 0) {
        probHead = prob[currIndex] * getProbability(currIndex+1, n, numHeads-1, numTails, prob, memo);
    }
    if (numTails > 0) {
        probTail = (1-prob[currIndex]) * getProbability(currIndex+1, n, numHeads, numTails-1, prob, memo);
    }
    return memo[currIndex][numTails] = probHead + probTail;
}
int main() {
    int n;
    cin>>n;
    vector<long double> prob(n+1);
    for (int i = 1; i <= n; i++) {
        cin>>prob[i];
    }
    long double ans = 0;
    vector<vector<long double> > memo(n+1, vector<long double>(n/2+1, -1) );
    int startIndex = 1;
    for (int heads = n/2+1; heads <= n;heads++) {
        int tails = n - heads;
        ans += getProbability (startIndex, n, heads, tails, prob, memo);
    }
    cout<<std::setprecision(9)<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 74032
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int wi = Integer.parseInt(line[0]);
		int hi = Integer.parseInt(line[1]);
		int n = Integer.parseInt(line[2]);
		int xrg[] = {0, wi};
		int yrg[] = {0, hi};
		int dir;
		while (n > 0) {
			line = br.readLine().split(" ");
			dir = Integer.parseInt(line[2]);
			if (dir == 1) {
				xrg[0] = Math.max(xrg[0], Integer.parseInt(line[0]));
			} else if (dir == 2) {
				xrg[1] = Math.min(xrg[1], Integer.parseInt(line[0]));
			} else if (dir == 3) {
				yrg[0] = Math.max(yrg[0], Integer.parseInt(line[1]));
			} else if (dir == 4) {
				yrg[1] = Math.min(yrg[1], Integer.parseInt(line[1]));
			}
			n--;
		}
		System.out.println(Math.max((xrg[1] - xrg[0]), 0)*Math.max((yrg[1] - yrg[0]), 0));
	}
}

Measured memory_bytes: 8276
#include <iostream>
#include <vector>
#define llint long long

using namespace std;

struct BIT{
	int size;
	vector<int> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	int query(int i){
		int ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, int x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};

int n;
int a[3][100005];
vector<int> evec, ovec;
int ecnt, ocnt;
BIT bit(100005);

int calc(vector<int> &vec)
{
	bit.init();
	llint ret = 0;
	for(int i = 0; i < vec.size(); i++){
		ret += i - bit.query(vec[i]);
		bit.add(vec[i], 1);
	}
	return ret%2;
}

int main(void)
{
	cin >> n;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	for(int j = 0; j < n; j++){
		for(int i = 0; i < 3; i++){
			if(a[i][j]/3 != a[0][j]/3){
				cout << "No" << endl;
				return 0;
			}
		}
		if(a[0][j]%2 != j%2){
			cout << "No" << endl;
			return 0;
		}
		if(a[1][j]%3 != 1){
			cout << "No" << endl;
			return 0;
		}
	}
	
	for(int j = 0; j < n; j++){
		if(a[0][j]%3 != 0){
			if(j%2) ocnt++;
			else ecnt++;
		}
		if(j%2) ovec.push_back(a[0][j]/3+1);
		else evec.push_back(a[0][j]/3+1);
	}
	
	int eres = calc(evec), ores = calc(ovec);
	if(eres%2 == ocnt%2 && ores%2 == ecnt%2) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 2556
from collections import Counter
s = input()
if len(s) == 1:
  print("YES")
  exit()
t = sorted(Counter(s).values())
if len(s) == 2:
  if t == [1,1]:
    print("YES")
  else:
    print("NO")
elif len(t) == 3 and t[-1]-t[0]<2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}


int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n, sum = 0;
  cin >> n;
  vector<int>l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int k=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
      sum += max(0,k-(j+1));
    }
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int matrix[20][20];
signed main() {
  int N, D;
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> matrix[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int a = 0;
      for (int k = 0; k < D; k++) {
        a += pow(matrix[i][k]-matrix[j][k], 2);
      }
      double b = sqrt(a);
      if ( (double)((int)b) == b) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}



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

using namespace std;

#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)

template<typename T>
void err(T a){
    cerr<<a<<'\n';
    cerr<<"END OF DEBUG"<<'\n'<<'\n';
}

const long double PI=acos(-1.0);  
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;

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

/*head------[@cordercorder]*/

const int maxn=(int)3e3+10;

char s[maxn],t[maxn];
int lens,lent;
int dp[maxn][maxn];
char ans[maxn];

void solve(){
    int cnt=0;
    lens=strlen(s+1);
    lent=strlen(t+1);
    for(int i=1;i<=lens;i++){
        for(int j=1;j<=lent;j++){
            if(s[i]==t[j]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    int i=lens,j=lent;
    while(i>=1&&j>=1){
        if(dp[i][j]==dp[i-1][j-1]+1&&s[i]==t[j]){
            ans[cnt++]=s[i];
            i--;
            j--;
        }
        else if(dp[i][j]==dp[i][j-1]){
            j--;
        }
        else{
            i--;
        }
    }
    ans[cnt]='\0'; 
    reverse(ans,ans+cnt);
    puts(ans);
}

int main(void){
    scanf("%s %s",s+1,t+1);
    solve();
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int MOD = 1e9 + 7;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int a = (A+D-1) / D;
  int b = (C+B-1) / B;

  cout << ((a >= b)?"Yes":"No") << "\n";
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <cassert>
#include <complex>
#include <tuple>
#include <utility>
using namespace std;
  
typedef complex<double> vec;
typedef pair<vec, vec> line;
double ip(vec u, vec v) {
    return real(u * conj(v));
}
double cross(vec u, vec v) {
    return imag(conj(u) * v);
}
vec projection(line l, vec p) {
    vec s = l.first, t = l.second;
    double k = ip(t - s, p - s) / ip(t - s, t - s);
    return (1.0 - k) * s + k * t;
}
  
vec reflection(line l, vec p) {
    return 2.0 * projection(l, p) - p;
}
  
vec intersection(line l0, line l1) {
    vec s0, t0, s1, t1;
    s0 = l0.first, t0 = l0.second;
    s1 = l1.first, t1 = l1.second;
    double k = cross(t1 - s1, s1 - s0) / cross(t1 - s1, t0 - s0);
    return s0 + (t0 - s0) * k;
}
  
string s;
int c, N;
  
struct V {
    vector<vec> ps;
    V() {
    }
};
  
V f(V v1, V v2) {
    if (v1.ps.size() + v2.ps.size() == 2) {
        V ret;
        ret.ps.push_back(v1.ps[0]);
        ret.ps.push_back(v2.ps[0]);
        return ret;
    }
    if (v1.ps.size() + v2.ps.size() == 3) {
        if (v1.ps.size() == 2)
            swap(v1, v2);
        vec v = v1.ps[0];
        line l = make_pair(v2.ps[0], v2.ps[1]);
        v = reflection(l, v);
        V ret;
        ret.ps.push_back(v);
        return ret;
    }
    if (v1.ps.size() + v2.ps.size() == 4) {
        line l1 = make_pair(v1.ps[0], v1.ps[1]);
        line l2 = make_pair(v2.ps[0], v2.ps[1]);
        vec v = intersection(l1, l2);
        V ret;
        ret.ps.push_back(v);
        return ret;
    }
}
  
V expr();
double num();
  
V expr() {
    if (s[c] == '(') {
        c++;
        if (isdigit(s[c]) || s[c] == '-') {
            double x = num();
            assert(s[c] == ',');
            c++;
            double y = num();
            assert(s[c] == ')');
            c++;
            V v;
            v.ps.push_back(vec(x, y));
            return v;
        }
        V v1 = expr();
        while (c < N && s[c] == '@') {
            c++;
            V v2 = expr();
            //assert(s[c] == ')');
            v1 = f(v1, v2);
        }
        assert(s[c] == ')');
        c++;
        return v1;
    }
}
  
double num() {
    double ret = 0;
    bool m = false;
    if (s[c] == '-') {
        m = true;
        c++;
    }
    while (isdigit(s[c])) {
        ret = ret * 10 + s[c] - '0';
        c++;
    }
    if (m) {
        ret *= -1;
    }
    return ret;
}
  
int main() {
    while (cin >> s, s != "#") {
        c = 0;
        N = s.size();
        V v1 = expr();
        while (c < N && s[c] == '@') {
            c++;
            V v2 = expr();
            v1 = f(v1, v2);
        }
        vec p = v1.ps[0];
        cout << fixed << setprecision(15) << p.real() << " " << p.imag()
                << endl;
    }
}

Measured memory_bytes: 3148
#include<iostream>
using namespace std;
int main()
  {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    bool a[26]={false};
    int nb=0;
    for(int i = 0; i < 4; i++)
    {
      if(!a[s[i]-'A'])
      {
        a[s[i]-'A']=true;
        nb++;
      }
    }
    if(nb==2)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
                                              

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
	int n[4]={0,0,0,0},i;
	std::string s;
	while (std::cin>>s){
		s=s.substr(s.find(",")+1);
		n[(s=="A")?0:(s=="B")?1:(s=="O")?3:2]++;
	}
	for (i=0;i<4;i++) std::cout<<n[i]<<"\n";
}

Measured memory_bytes: 1192
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef pair<long long int, int> P;

long long int INF = 100000000000000000LL;

int main(){
	
	long long int N, Q, v, w;
	cin >> N >> Q;
	
	if(N == 1){
		for(int i = 0; i < Q; i++){
			cin >> v >> w;
			cout << min(v, w) << endl;
		}
		return 0;
	}
	
	for(int i = 0; i < Q; i++){
		cin >> v >> w;
		vector<long long int> v1, v2;
		while(v > 0){
			v1.push_back(v);
			v += N - 2;
			v /= N;
		}
		while(w > 0){
			v2.push_back(w);
			w += N - 2;
			w /= N;
		}
		sort(v1.begin(), v1.end());
		sort(v2.begin(), v2.end());
		long long int ans = 1;
		for(int j = 0; j < v1.size(); j++){
			if(v1[j] == v2[j]){
				ans = v1[j];
			}else{
				break;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

int main() {
    string N;
    bool TorF = false;
    cin >> N;
    REP(i, 3){
        if(N[i] == '7'){
            TorF = true;
        }
    }
    if(TorF == true){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
from collections import Counter
n,*a = map(int,open(0).read().split())
dbl = Counter(a).most_common()[0][0]
l,r = [i for i,j in enumerate(a) if j==dbl]
const = n+l-r
m = n + 1
mod = 10**9+7
fac = [1]*(m+1)
inv = [1]*(m+1)
for i in range(1,m+1):
	fac[i] = fac[i-1] * i % mod
inv[-1] = pow(fac[-1], mod - 2, mod)
for i in range(m-1, -1, -1):
	inv[i] = inv[i+1] * (i+1) % mod
def cmb(n,r):
	if n<r:return 0
	return fac[n] * inv[n-r] * inv[r] % mod
for k in range(1,n+2):
	print((cmb(n+1,k)-cmb(const,k-1)) % mod)

Measured memory_bytes: 21468
#include <cassert>
#include <tuple>
#include <utility>
#include <iostream>
using namespace std;

using ll = long long;

string expr;
ll a_ans;

ll calc1() {
    ll ans = expr[0] - '0';
    int idx = 1;
    while (idx < expr.size()) {
        char op = expr[idx];
        ll v = expr[idx+1] - '0';

        if (op == '+') ans += v;
        if (op == '*') ans *= v;

        idx += 2;
    }

    return ans;
}

pair<ll, int> term(int idx) {
    ll ret = expr[idx] - '0';
    idx+=1;

    while (idx < expr.size()) {
        char op = expr[idx];
        if (op == '+') break;
        assert(op == '*');
        ll v = expr[idx+1] - '0';
        ret *= v;

        idx += 2;
    }

    return make_pair(ret, idx);
}

ll calc2() {
    ll ans = 0, val;
    int idx = 0, nidx;
    while (idx < expr.size()) {
        tie(val, nidx) = term(idx);
        ans += val; idx = nidx;
        idx += 1;
    }
    return ans;
}

int main() {
    cin >> expr >> a_ans;
    ll ans1 = calc1(), ans2 = calc2();

    if (ans1 == a_ans && ans2 == a_ans) {
        cout << "U";
    } else if (ans1 == a_ans && ans2 != a_ans) {
        cout << "L";
    } else if (ans1 != a_ans && ans2 == a_ans) {
        cout << "M";
    } else {
        cout << "I";
    }
    cout << endl;

    return 0;
}

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

const int MN = 100010;

int N;
vector<int> adj[MN];
int dist[MN], par[MN];

void dfs0(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dist[v] = dist[u] + 1;
        par[v] = u;
        dfs0(v, u);
    }
}

vector<int> V;
int del[MN], sz[MN];

void dfs1(int u, int p) {
    sz[u] = 1;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        if(del[v]) continue;
        dist[v] = dist[u] + 1;
        dfs1(v, u);
        sz[u] += sz[v];
    }
}

bool cmp(vector<int> &a, vector<int> &b) {
    for(int i = 0; i < a.size(); i++) {
        if(a[i] != b[i]) return a[i] < b[i];
    }
    return false;
}

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

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs0(0, -1);

    int p = 0;
    for(int i = 0; i < N; i++) if(dist[i] > dist[p]) p = i;

    dist[p] = 0;
    par[p] = -1;
    dfs0(p, -1);

    int q = 0;
    for(int i = 0; i < N; i++) if(dist[i] > dist[q]) q = i;

    int u = q;
    while(u != -1) {
        V.push_back(u);
        del[u] = 1;
        u = par[u];
    }

    for(int i = 0; i < V.size(); i++) {
        dist[ V[i] ] = 0;
        dfs1(V[i], -1);
    }

    for(int i = 0; i < N; i++) if(dist[i] > 1) {
        printf("-1");
        return 0;
    }

    vector<int> A, B;
    for(int i = 0; i < V.size(); i++) A.push_back(sz[ V[i] ] - 1);
    for(int i = (int)V.size() - 1; i >= 0; i--) B.push_back(sz[ V[i] ] - 1);
    if(!cmp(A, B)) swap(A, B);

    vector<int> ans;
    int pos = 1;
    for(int i = 0; i < A.size(); i++) {
        for(int j = pos + 1; j <= pos + A[i]; j++) {
            ans.push_back(j);
        }
        ans.push_back(pos);
        pos += A[i] + 1;
    }

    for(int i = 0; i < N; i++) {
        printf("%d ", ans[i]);
    }
}


Measured memory_bytes: 15736
#include<stdio.h>
int main(){

  int G[100][100],n,i,j,s,u,k;




  scanf("%d",&n);

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      G[i][j] = 0;

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    if(k!=0)for(j=0;j<k;j++){
	scanf("%d",&s);
	G[u-1][s-1] = 1;
      }
  }

  for(i=0;i<n;i++)
    for(j=0;j<n;j++){
      if(j!=n-1)printf("%d ",G[i][j]);
      else printf("%d\n",G[i][j]);
    }
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 5;
vector<ll> G[maxn];
ll ans = 1;
const ll mod = 1e9 + 7;
ll n,k;
void dfs(ll cur,ll pre,ll col)
{
	ans = ans * col % mod;
	col = k - 1;
	if(pre != -1)
	{
		col--;
	}
	for(int i = 0;i < G[cur].size(); ++i)
	{
		int u = G[cur][i];
		if(u != pre)
		{
			dfs(u,cur,col);
			col--;
		}
	}
}
int main()
{
	cin>>n>>k;
	for(ll i = 0;i < n - 1; ++i)
	{
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(0,-1,k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10368
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        double N = sc.nextDouble();
        double sum = 0;
        double ans = 0;
        for(int i=1;i<=N;i++)
        {
            if(i%2==1)
            {
               sum++; 
            }
        }
        ans = sum / N;
        System.out.println(ans);
    }
}


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

namespace ABC109
{
    class Program
    {
        static long GCD(long a, long b)
        {
            return (a < b)? GCD(b, a):
                   (a % b == 0)? b:
                                 GCD(b, a % b);
        }
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            long X = long.Parse(s[1]);
            s = Console.ReadLine().Split(' ');
            long res = Math.Abs(long.Parse(s[0]) - X);
            for (int i = 1; i < N; i++)
            {
                long temp = Math.Abs(long.Parse(s[i]) - X);
                res = GCD(res, temp);
            }
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 18016
n,m = gets.split.map!(&:to_i)

bin = Array.new(n+2)
bin[1] = 1
2.upto(n+1) {|i| bin[i] = bin[i-1] * 2}

dp = Array.new(bin[n+1],-1)

m.times do 
    a,_ = gets.split.map!(&:to_i)
    c = 0
    gets.split.each {|e| c += bin[e.to_i]}

    x = dp.dup
    x.each_with_index do |e,i|
        next if e == -1
        z = i | c
        dp[z] = e + a if (dp[z] == -1 || dp[z] > e + a)
    end

    dp[c] = a if dp[c] == -1 || dp[c] > a
    #p dp
end

puts dp.last

Measured memory_bytes: 8988
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>

using namespace std;



int main()
{
	int ar[] = { 2, 31,61,151,181,211,241,271,331,421,541,571,601,631,691,751,811,991,1021,1051,1171,1201,1231,1291,1321,1381,1471,1531,1621,1741,1801,
				1831,1861,1951,2011,2131,2161,2221,2251,2281,2311,2341,2371,2521,2551,2671,2731,2791,2851,2971,3001,3061,3121,3181,3271 };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		printf("%d ", ar[i]);

	return 0;
}


Measured memory_bytes: 888
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder.XXX.B
{ 
    public class Program
    {
        public static void Main(string[] args)
        {

            var a = int.Parse(r());
            var b = int.Parse(r());
            var c = int.Parse(r());
            var x = int.Parse(r());
            var cnt = 0;
            for(var i = 0; i < a+1;i++)
			{
                for(var j = 0; j < b+1;j++)
				{
                    for( var k = 0; k < c+1;k++)
					{
                        if (i * 500 + j * 100 + k * 50 == x)
                        {
                            cnt++;
			            }
					}
				}
			}
            P(cnt);

        }

        private static StreamReader sr;
        public static int[] Ecr()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static string Er()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine();
        }
        public static string r()
        {
            return Console.ReadLine();
        }
        public static  int[] cr()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static int cri()
        {
            return int.Parse(Console.ReadLine());
        }
        public static void P(string str)
        {
            Console.WriteLine(str);
        }
        public static void P(int num)
        {
            P(num.ToString());
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
R = [[int(x) for x in input().split()] for _ in range(N)]
B = [[int(x) for x in input().split()] for _ in range(N)]

import operator
R.sort(key=operator.itemgetter(1), reverse=True)
B.sort()

ans = 0
for b in B:
    xb, yb = b
    for r in R:
        xr, yr = r
        if xr < xb and yr < yb:
            ans += 1
            R.remove(r)
            break
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main{

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

        int n = scan.nextInt();

        int x = 0, y = 0;
        int it = 0;
        boolean res = true;
        for(int i=0; i<n; i++){
            int t = scan.nextInt();
            int tx = scan.nextInt();
            int ty = scan.nextInt();
            if(!res) continue;
            for(int j=it; j<t; j++){
                if(Math.abs(tx-x) > Math.abs(ty-y)){
                    if((tx-x) > 0) x++;
                    else x--;
                }else{
                    if((ty-y) > 0) y++;
                    else y--;
                }
            }
            it = t;
            if(x == tx && y == ty) res = true;
            else res =false;
        }

        if(res){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        scan.close();
        
    }

}

Measured memory_bytes: 87844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication10
{
    //ONLINE JUDGE (ITP1_8_A)

    class Program
    {
        static void Main(string[] args)
        {

                string str = Console.ReadLine();

            for (int i = 0; i < str.Length; ++i)
            {
                if ((str[i] >= 'A') && (str[i] <= 'Z'))
                {
                    char ch = char.ToLower(str[i]);
                    Console.Write(ch);
                }
                else if ((str[i] >= 'a')  && (str[i] <= 'z'))
                {
                    char ch = char.ToUpper(str[i]);
                    Console.Write(ch);
                }
                else
                {
                    Console.Write(str[i]);
                }
            }
            Console.WriteLine();
                
            
        }
    }
}

Measured memory_bytes: 11700
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1e9 + 7;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int n, m;
VI k(20), p(20);
int s[20][20];
int sj[20] = { 0 };
int ans = 0;
void dps(int i) {
	if (i == n) {
		int flag = 1;
		REP(j, m) {
			int os = 0;
			REP(l, k[j]) {
				os += sj[s[j][l] - 1];
			}
			if (os % 2 != p[j])
				flag = 0;
		}
		if (flag)
			ans++;
		return;
	}
	sj[i] = 0;
	dps(i + 1);
	sj[i] = 1;
	dps(i + 1);
	return;
}
int main() {
	cin >> n >> m;
	REP(i, m) {
		cin >> k[i];
		REP(j, k[i])
			cin >> s[i][j];
	}
	REP(i, m)
		cin >> p[i];
	dps(0);
	cout << ans;
}

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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF = static_cast<ll>(1ll << 60);
const auto MOD = static_cast<ll>(1e9 + 7);
const auto NIL = nullptr;

/************* Utils *************/

/*********** Variables ***********/
ll N;
vector<bool> prime;
vector<ll> ANS;

/*********** Functions ***********/
bool init() {
    cin >> N;
    prime.resize(55555, true);
    return true;
}

void solve() {
    prime[0] = prime[1] = false;
    for (ll i = 2; i * i < 55555; i++) {
        if (prime[i]) {
            for (ll j = i * 2; j < 55555; j += i) {
                prime[j] = false;
            }
        }
    }
    for (ll i = 0; i < 55555; i++) {
        if (prime[i] && i % 5 == 2) {
            ANS.push_back(i);
        }
    }
}

void output() {
    for (ll i = 0; i < N; i++) {
        cout << (i ? " " : "") << ANS[i];
    }
    cout << endl;
}

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    for(ll i = 0; i < s.size() - 1; ++i){
        if(s.substr(i, 2) == "AC"){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#define INF 10e10

using namespace std;

//  void y(void){cout << "yes"<< endl;}
  void Y(void){cout << "YES" << endl;}
  void y(void){cout << "Yes" << endl;}
//  void n(void){cout << "no"<< endl;}
  void N(void){cout << "NO" << endl;}
  void n(void){cout << "No" << endl;}
  
 void say(string r){cout << r << endl;}
 void sayn(string r){cout << r ;}
  
	int a,b,c,d,e,f,g,h,ans,res;
//	char a,b,c,d,e,f,g,h,ans,res;
//	string a,b,c,d,e,f,g,h,ans,res;
//	double a,b,c,d,e,f,g,h,ans,res;
	
void take(int x){
	if(x==1)
		cin >> a;
	else if(x==2)
		cin >> a >> b;
	else if(x==3)
		cin >> a >> b >> c;
	else if(x==4)
		cin >> a >> b >> c >> d;
	else if(x==5)
		cin >> a >> b >> c >> d >> e;
	else if(x==6)
		cin >> a >> b >> c >> d >> e >> f;
	else if(x==7)
		cin >> a >> b >> c >> d >> e >> f >> g;
	else if(x==8)
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
	return ;
}
  
int main(void){
	take(1);//数
	
	sayn("Christmas");
	
	if(a==22){
		say(" Eve Eve Eve");
	//	y();	//Yes
	//	Y();	//YES
	//	n();	//No
	//	N();	//NO
	}
	
	else if(a==23){
		
		say(" Eve Eve");
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}
	else if(a==24){
		
		say(" Eve");
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}/*
	else if(){
		
		
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}*/
	
	else{
		say("");
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}
//	cout << ans << endl;
	
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n;
ll a[55];
vector<P> res;

int main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  ll idx=0;
  rep(i,n){
    if(abs(a[idx])<abs(a[i])){
      idx=i;
    }
  }
  rep(i,n){
    res.push_back(P(idx,i));
  }
  if(a[idx]>=0){
    rep(i,n-1)res.push_back(P(i,i+1));
  }else{
    for(ll i=n-1;i>=1;i--)res.push_back(P(i,i-1));
  }
  cout<<res.size()<<endl;
  rep(i,res.size())cout<<res[i].fi+1<<" "<<res[i].se+1<<endl;
	return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())
A = list(map(int,input().split()))
Q = int(input())

c=collections.Counter(A)
S = sum(A)

for i in range(Q):
    B,C = map(int,input().split())
    S += (C-B) * c[B]
    c[C] = c[C] + c[B]
    c[B] = 0
    print(S)

Measured memory_bytes: 24196
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

typedef long long ll;
const ll maxn=2e3+10,maxnn=maxn*maxn,mod=1e9+7;
ll n,k,fac[maxnn],inv[maxnn];
ll f[maxn][maxn],ans;

ll qpow(ll a,ll n){
	ll res=1;
	while(n){
		if(n&1ll)
			res=res*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res;
}

int main(){
	fac[0]=1;
	for(int i=1;i<maxnn;++i)
		fac[i]=fac[i-1]*i%mod;
	inv[maxnn-1]=qpow(fac[maxnn-1],mod-2);
	for(int i=maxnn-1;i;--i)
		inv[i-1]=inv[i]*i%mod;
	scanf("%lld%lld",&n,&k);
	if(k==1){
		puts("1");
		return 0;
	}
	f[1][1]=1;
	for(int i=2;i<=n;++i){
		ll sum=0;
		for(int j=i;j;--j){
			(sum+=f[i-1][j-1])%=mod;
			f[i][j]=sum*fac[i*k-j-1]%mod*inv[k-2]%mod*inv[(i-1)*k-j+1]%mod;
		}
	}
	for(int i=1;i<=n;++i)
		ans+=f[n][i];
	ans=ans%mod*fac[n]%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 93440
#include <bits/stdc++.h>
using namespace std;
#define  ft   ios_base::sync_with_stdio(false);cin.tie(NULL);
#define  ll   long long
#define  pb   push_back
#define  ll   long long
#define  mk   make_pair
#define  msi  map<string,int>
#define  mii  map<int,int>
#define  pii  pair<int,int>
const int N=2e5+3;
const ll M=1e9+7;
ll BM(ll a,ll b)
{
    a%=M;
    ll k=1;
    while(b!=0)
    {
        if(b%2==1)
        {
            k=(k*a)%M;
        }
        a=(a*a)%M;
        b/=2;
    }
    return k;
}
ll MI(ll a)
{
    ll MM=1e9+5;
    return BM(a,MM);
}
ll ncr(ll n,ll r)
{
    ll i,j,k,m,s=1,p=1,mn;
    m=max(r,(n-r));
    mn=min(r,(n-r));
    for(i=m+1;i<=n;i++)
    {
        s=(s*i)%M;
    }
    for(i=1;i<=mn;i++)
    {
        p=p*MI(i);
        p%=M;
    }
    return (s*p);
}
int main()
{
    ft
    ll t,i,j,k,n,a,b,ans;
    cin>>n>>a>>b;
    ans=BM(2,n)-1;
    ans%=M;
    if(ans<0)
    {
        ans+=M;
    }
    ans-=(ncr(n,a)%M);
    if(ans<0)
    {
        ans+=M;
    }
    ans-=(ncr(n,b)%M);
    if(ans<0)
    {
        ans+=M;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
import bisect

def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = list(map(int, input().split()))
    C = sorted(list(map(int, input().split())))
    ans = 0
    for b in B:
        indexa = bisect.bisect_left(A, b)
        indexc = bisect.bisect_right(C, b)
        ans += indexa * (N - indexc)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 23744
from random import sample

N = int(input())

if N == 3:
    print("2 5 63")
    exit()

# 2の倍数か3の倍数 [6, 30000]
L = [n for n in range(6, 30001) if (n % 2 == 0) or (n % 3 == 0)]

while True:
    ans = [2, 3, 4]
    ans += sample(L, N - 3)
    if sum(ans) % 6 == 0:
        break

print(*ans)

Measured memory_bytes: 5228
//include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <cassert>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pf push_front
#define pof push_front
#define pb push_back
#define pob pob_back
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOR_(i, n) for (int i = n; i >= 0; i--)
#define FOR1(i, n) for(int i = 1; i <= n; i++)
#define FOR2(i, a, b) for (int i = a; a <= b; i++)
#define FOR2_(i, b, a) for (int i = b; i >= a; i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#ifdef momo
#define  debug(...) do{\
fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
_do(__VA_ARGS__);\
}while(0)
template<typename t> void _do(t &&_x){cerr<<_x<<endl;}
template<typename t,typename ...T> void _do(t &&_x,T &&...tail){cerr<<_x<<", ";_do(tail...);}
#else
#define debug(...)
#endif

int N, M;
string A[200], B[200];

bool check(int x1, int y1, int n1, int n2)
{
    FOR(i, n1) {
        FOR(j, n2) {
            if (A[x1+i][y1+j] != B[i][j]) return false;
        }
    }
    return true;
}



int main(void)
{
    IOS;
    
    cin >> N >> M;
    FOR(i, N) cin >> A[i];
    FOR(j, M) cin >> B[j];
    
    bool ans = false;
    FOR(i, N)
        FOR(j, N)
            if (check(i, j, M, M)) {
                ans = true; break;
            }
    if (ans) puts("Yes");
    else puts("No");
    return 0;
}

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

typedef struct {
    int n;
    int *arr;
} vector;

vector A;

void pushBack(int x)
{
    A.arr = realloc(A.arr, sizeof(int) * (++A.n));
    A.arr[A.n - 1] = x;
    return;
}

void randomAccess(int p)
{
    if ( A.n != 0 ) {
        printf("%d\n", A.arr[p]);
    }
    return;
}

void popBack(void)
{
    if ( (A.n != 0) && (A.arr != NULL) ) {
        if ( A.n == 1 ) {
            free(A.arr);
            A.n = 0;
            A.arr = NULL;
        } else {
            A.arr = realloc(A.arr, sizeof(int) * (--A.n));
        }
    }
    return;
}

int main(void)
{
    int q;
    char line[16];
    int i;

    A.n = 0;
    A.arr = NULL;

    scanf("%d\n", &q);

    for ( i = 0; i < q; i++ ) {
        fgets(line, sizeof(line), stdin);
        if ( line[0] == '0' ) {
            pushBack(atoi(line + 2));
        } else if ( line[0] == '1' ) {
            randomAccess(atoi(line + 2));
        } else {
            popBack();
        }
    }

    return 0;
}



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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int n;
int a[22][22];
int memo[22][3000005];

int dp(int i, int mask) {
	if (i == n) return 1;
	if (memo[i][mask] != -1) return memo[i][mask];
	int sol = 0;
	for (int j=0 ; j<n ; j++) {
		if ((1<<j)&mask) continue;
		if (a[i][j]) sol = (sol + dp(i+1, mask|(1<<j))) % MOD;
	}
	return memo[i][mask] = sol;
}

int main() {
	memset(memo, -1, sizeof memo);
	scanf("%d", &n);
	for (int i=0 ; i<n ; i++) {
		for (int j=0 ; j<n ; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	printf("%d\n", dp(0, 0));
	return 0;
}

Measured memory_bytes: 261604
#include<iostream>
#include<cinttypes>
#include<vector>
#include<algorithm>

using si32 = std::int32_t;
using ui32 = std::uint32_t;

int main() {
	
	ui32 n, m;
	std::cin >> n >> m;

	std::vector<std::vector<si32>> vertices(n);

	for (ui32 i{}; i < m; ++i) {
		ui32 x, y;
		std::cin >> x >> y;
		vertices[x - 1].emplace_back(y - 1);
	}

	auto p = [&] {
		std::cout << "print vertices--start\n\n";
		for (const auto&e : vertices) {
			for (const auto&ee : e)
				std::cout << ee << " ";
			std::cout << "\n";
		}
		std::cout << "print vertices--end\n";
	};
	//p();


	std::vector<ui32> tab(n, -1);

	auto count = 0;
	auto dfs = 
		[&](auto f, auto i)->ui32 {

		//std::cout << i << "\n";
//		++count;
//		std::cout << "c:" << count << "\n";
		if (i == -1)
			return 0;

		if (tab[i] != -1)
			return tab[i];

		ui32 acc{};
		for (auto e : vertices[i])
			acc = std::max(acc, 1 + f(f, e));

//		std::cout << i << ", " << acc << "\n";
		return tab[i] = acc;
	};

//	std::cout << dfs(dfs, 0) << "\n";

	for (ui32 i{}; i < n; ++i)
		auto v = dfs(dfs, i);
	
	/*/
	for (const auto&e : tab)
		std::cout << e << " ";
	std::cout << "\n";
	*/

	std::sort(std::begin(tab), std::end(tab), std::greater<>{});
	std::cout << tab[0] << "\n";
	return 0;
}

Measured memory_bytes: 10240
def pow_k(x, n, M):

    if n == 0:
        return 1

    K = 1
    while n:
        if n & 1:
            K *= x
            K %= M
        x *= x
        x %= M
        n >>= 1

    return K

M = 1000000007
m, n = map(int, input().split())
print(pow_k(m, n, M))



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  if( A + B > C + D )
    cout << "Left";
  if( A + B == C + D )
    cout << "Balanced";
  if( A + B < C + D )
    cout << "Right";
  }

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

struct Edge{
	int to, cost;
};

int color[100005];

bool dfs(int v, int c, vector<vector<Edge>> & g){
	color[v] = c;
	for(auto e: g[v]){
		int cost = e.cost;
		int u = e.to;
		if (color[u] == c && cost%2) return false;
		if(color[u]==-1){
			if(cost%2) dfs(u, !c, g);
			else dfs(u, c, g);
		}
	}
	return true;
}

int main(){
	int n; cin >> n;
	vector<vector<Edge>> g(n, vector<Edge>());
	memset(&color[0], -1, sizeof(color));
	rep(i, n-1){
		int u, v, w; cin >> u >> v >>w;
		u--; v--;
		g[u].push_back(Edge{v,w});
		g[v].push_back(Edge{u,w});
	}
	dfs(0, 1, g);
	rep(i, n) cout << color[i] << endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main(){
  pair< int, int > Q[6];
  for(int i = 0; i < 6; i++) {
    cin >> Q[i].first >> Q[i].second;
    if(Q[i].first > Q[i].second) swap(Q[i].first, Q[i].second);
  }sort(Q, Q + 6);
  if(Q[0] == Q[1] && Q[2] == Q[3] && Q[4] == Q[5] && Q[0].first == Q[2].first && Q[2].second == Q[4].second && Q[0].second == Q[4].first) {
    cout << "yes" << endl;
  } else cout << "no" << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
using namespace std;
int main()
{
  const double pi=3.1415926535;
  int a,b,x;
  double theta;
  cin>>a>>b>>x;
  if(a*a*b/2.0>x)
  {
    theta=pi/2.0-atan(2*x/((double)a*b*b));
  }
  else
  {
    theta=atan(2*(a*a*b-x)/((double)a*a*a));
  }
  cout<<fixed<<setprecision(10)<<theta*360/(2*pi)<<endl;
}

Measured memory_bytes: 384
N = int(input())
s = [input().split() for i in range(N)]
for i in range(N):
    s[i] = list(s[i][0])
    s[i].sort()
    s[i] = ''.join(map(str, s[i]))
s.sort()
count = 0
ren = 0
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1+ren
        ren += 1
    else:
        ren = 0
print(count)

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

  
int main() {
 int a,b;
  cin >> a >> b;
  if(a <= b){
	for(int i=0;i<b;i++){
     cout << a; 
    }
  }
    else {
     for(int i=0;i<a ;i++){
      cout << b; 
     }
    }
  
}

Measured memory_bytes: 256
#include<stdio.h>

int binarySearch(int *,int,int);

int main(){
  int i;
  int key;
  int S_num[1000000];
  int T_num;
  int num_in_1;
  int num_in_2;
  int count=0;

  scanf("%d",&num_in_1);

  for(i=0;i<num_in_1;i++){
    scanf("%d",&S_num[i]);
  }

  scanf("%d",&num_in_2);

  for(i=0;i<num_in_2;i++){
    scanf("%d",&key);
    if(binarySearch(S_num,key,num_in_1)==1){
      count++;
    }
  }
  
  printf("%d\n",count);
  
  return 0;
}

int binarySearch(int S_num[],int key,int n){
  int left=0;
  int right=n;
  int mid;
  
  while(left<right){
    mid=(left+right)/2;
    if(S_num[mid]==key){
      return 1;
    }else if(key<S_num[mid]){
      right=mid;
    }else{
      left=mid+1;
    }
  }
  
  return -1;
}

Measured memory_bytes: 992
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

ll mod = 1000000007LL;

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

    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll dp[n+1][k+1];
    fill(dp[0], dp[n]+k+1, 0LL);
    dp[0][0] = 1LL;

    for (int i = 1; i <= n; i++) {
        dp[i][0] = 1LL;
        for (int j = 1; j <= k; j++) {
            if (j <= a[i-1]) {
                dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % mod;
            } else {
                dp[i][j] = ((dp[i][j-1] + dp[i-1][j]) % mod + mod - dp[i-1][j - a[i-1] - 1]) % mod;
            }
        }
    }

    cout << dp[n][k] << "\n";
    return 0;
}


Measured memory_bytes: 79104
s=input()
n=len(s)
 
flag=True
 
for i in range(n):
  if(s[i]!=s[n-1-i]):
    flag=False
 
for i in range((n-1)//2):
  if(s[i]!=s[(n-1)//2-1-i]):
    flag=False
  if(s[(n-1)//2+1+i]!=s[n-1-i]):
    flag=False
    
if(flag):
  print("Yes")
else:
  print("No")

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

namespace AtCoder0621
{
	class Program
	{
		static void Main(string[] args)
		{
			D();
		}

		static void D()
		{
			var n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
			var q = int.Parse(Console.ReadLine());
			var bc = Enumerable.Range(0, q).Select(i => new IntPair(Console.ReadLine())).ToArray();
			long s0 = a.Sum();

			var m1 = a.Max();
			var m2 = bc.Max(x => Math.Max(x.First, x.Second));
			var m = Math.Max(m1, m2);

			var valueCounts = new long[m + 1];
			foreach (var val in a)
				valueCounts[val]++;

			for (int i = 0; i < q; i++)
			{
				var b = bc[i].First;
				var c = bc[i].Second;

				s0 = s0 + valueCounts[b] * (c - b);

				valueCounts[c] += valueCounts[b];
				valueCounts[b] = 0;

				Console.WriteLine(s0);
			}
		}

		static void C()
		{
			var n = long.Parse(Console.ReadLine());
			var cur = 26L;
			int chars = 1;
			while (n > cur)
			{
				n -= cur;
				cur *= 26L;
				chars++;
			}
			n -= 1;
			var l = new char[chars];
			chars--;
			while (chars >= 0)
			{
				l[chars--] = (char)('a' + n % 26);
				n /= 26;
			}

			Console.WriteLine(new string(l));
		}

		static void B()
		{
			var ints = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
			var k = ints[1];
			var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
			Array.Sort(a);

			Console.WriteLine(a.Take(k).Sum());
		}

		static void A()
		{
			var s = Console.ReadLine();
			if (s == s.ToLower())
				Console.WriteLine('a');
			else
				Console.WriteLine('A');
		}
	}

	public struct IntPair
	{
		public int First;
		public int Second;

		public IntPair(string s)
		{
			var split = s.Split();
			First = int.Parse(split[0]);
			Second = int.Parse(split[1]);
		}

		public IntPair(int first, int second)
		{
			First = first;
			Second = second;
		}

		public static bool operator ==(IntPair p1, IntPair p2) => p1.First == p2.First && p1.Second == p2.Second;
		public static bool operator !=(IntPair p1, IntPair p2) => p1.First != p2.First || p1.Second != p2.Second;
		public override string ToString() => $"{First} {Second}";
		public override bool Equals(object obj)
		{
			var p = obj as IntPair?;
			return p.HasValue && p.Value.First == First && p.Value.Second == Second;
		}

		public override int GetHashCode()
		{
			uint rol5 = ((uint)First << 5) | ((uint)First >> 27);
			return ((int)rol5 + First) ^ Second;
		}

		public static long UpperBound(long min, long max, Predicate<long> test)
		{
			long ans = min;
			long s = min;
			long e = max;
			while (s <= e)
			{
				long mid = (s + e) / 2;
				if (test(mid))
				{
					ans = mid;
					s = mid + 1;
				}
				else
					e = mid - 1;
			}

			return ans;
		}

		public static long LowerBound(long min, long max, Predicate<long> test)
		{
			long ans = max;
			long e = max;
			long s = min;

			while (s <= e)
			{
				long mid = (s + e) / 2;

				if (test(mid))
				{
					ans = mid;
					e = mid - 1;
				}
				else
					s = mid + 1;
			}

			return ans;
		}

	}

}


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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    string s,t;
    cin >> s >> t;
    vector<vector <int> > dp(s.size()+1);
    for(int i=0;i<s.size()+1;i++)
    {
        dp[i].resize(t.size()+1);
        dp[i][0]=0;
    }
    for(int i=0;i<t.size()+1;i++)
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=s.size();i++)
    {
        for(int j=1;j<=t.size();j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string lcs="";
    int i=s.size();
    int j=t.size();
    while(i!=0 && j!=0)

    {
        if(s[i-1]==t[j-1])
        {
            lcs=s[i-1]+lcs;
            i--;
            j--;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
            {
                i--;
            }
            else
            j--;
        }
    }
    cout << lcs << endl;
	
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 35584