akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define vll         vector<pll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
    ll n; cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    ll ans=0;
    rep(i,0,n){
        if(a[i]==b[i] && b[i]==c[i]);
        else if(a[i]==b[i]) ans++;
        else if(a[i]==c[i]) ans++;
        else if(b[i]==c[i]) ans++;
        else ans+=2;
    }
    cout<<ans;
}

int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int dp[111111];

signed main(){
    int L,K;
    cin>>L>>K;
    dp[1]=1;
    dp[K]=1;
    for(int i=1;i<L;i++){
        dp[i+2]+=dp[i];
        dp[i+1+K]+=dp[i];
    }

    cout<<accumulate(dp,dp+L+1,0ll)<<endl;
    return 0;
}

Measured memory_bytes: 3088
# C 白昼夢

s = input()[::-1]

cnt = 0
while cnt < len(s):
  if not s[cnt:cnt+7] == "remaerd":
    if not s[cnt:cnt+6] == "resare":
      if not s[cnt:cnt+5] in ["maerd", "esare"]:
        print("NO")
        exit()
      else:
        cnt += 5
    else:
      cnt += 6
  else:
    cnt += 7
print("YES")

Measured memory_bytes: 9080
#include<stdio.h>


int sum[100000],i;

int num(int r,int l)
{
    int x,y,z,w;
    x=sum[l];
    y=r-1;
    for(z=r;z<l;z++)
    {
        if(sum[z]<=x)
        {
            y++;
            w=sum[y];sum[y]=sum[z];sum[z]=w;
        }
    }
    w=sum[y+1];sum[y+1]=sum[l];sum[l]=w;
    return y+1;
}
int main()
{
    int a,b;
    scanf("%d",&i);
    for(a=0;a<i;a++)
    {
        scanf("%d",&sum[a]);
        
    }
    b=num(0,i-1);
    for(a=0;a<i;a++)
    {
        if(a)printf(" ");
        if(a==b)printf("[");
        printf("%d",sum[a]);
        if(a==b)printf("]");
    
    }
    printf("\n");
    return 0;
    
}



Measured memory_bytes: 2084
#include <iostream>
#include <string>

using namespace std;

int main(){
	string str;

	getline(cin, str);

	for (int i = 0; str[i] != '\0'; i++){
		if (str[i] >= 'a' && str[i] <= 'z'){
			str[i] -= 0x20;
		}
	}

	cout << str << endl;
}

Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<vector>


using namespace std;
int dp [200002][2]={};
int n;
int c[200002];
int par[200002];
int sosen[200002];
int sison[200002];
int mod(int a){
	return a%1000000007;
}

int main(){
	cin>>n;
	int a;
	for (int i = 1; i <= n; i++)
	{
		cin>>a;
		if(i-1)if(a==c[i-1]){n--;i--;continue;}
		c[i]=a;
		if(sosen[a]==0)
		{sosen[a]=i;sison[a]=i;par[i]=-1;}
		else{
			par[i]=sison[a];
			sison[a]=i;
		}
	}
	dp[1][0]=1;
	for (int i = 2; i <= n; i++)
	{
			for (int k = 0; k < 2; k++)
			{
				dp[i][0]=mod(dp[i][0]+=dp[i-1][k]);
			}	
			if(sosen[a]!=i)dp[i][1]=(dp[par[i]+1][0]);
	}
	int ans=0;
	for (int i = 0; i < 2; i++)
	{
		ans=mod(ans+=dp[n][i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
import sys
N, M = map(int, input().split())
A = list(map(int, input().split()))
card = [ list(map(int, i.rstrip().split())) for i in sys.stdin.readlines()]
card = sorted(card, key=lambda x:x[1], reverse=True)
A = sorted(A)
i = 0
for b, c in card:
  for _ in range(b):
    if i >= N:
      break
    elif A[i] >= c:
      break
    else:
      A[i] = c
      i += 1
print(sum(A))

Measured memory_bytes: 40248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    // 6の累乗数で引き出す金額をi円とする
    for(int i=0; i<=N; i++){
        int tmp = 0;
        int a = i, b = N-i;
        for(int j=7; a>0; j--){
            tmp += a/pow(6,j);
            a %= (int)pow(6,j);
        }
        for(int j=6; b>0; j--){
            tmp += b/pow(9,j);
            b %= (int)pow(9,j);
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
const ll mxans = 1e18;
 
int main()
{
	ll n, ans=1, zeros=0; cin >> n;
	vector<ll> arr(n);
	for (ll i=0; i<n; i++)
	{
		cin >> arr[i];
		if (arr[i] == 0)
			zeros++;
	}

	if (zeros > 0)
	{
		cout<<"0\n";
		return 0;
	}

	for (ll i=0; i<n; i++)
	{
		if (arr[i]<=1000000000000000000/ans)
			ans *= arr[i];
		else
		{
			cout<<"-1\n";
			return 0;
		}
	}
	cout<<ans<<"\n";
 
	return 0;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int n, i, tab[N], c[N];
LL sum, res[N], r;

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) {
	scanf("%d", &tab[i]);
	c[tab[i]]++;
}
sum = 0;
for (i=1;i<=n;i++) {
	res[i] = c[i] * 1LL * (c[i] - 1) / 2;
	sum += res[i];
}
for (i=0;i<n;i++) {
	c[tab[i]]--;
	r = c[tab[i]] * 1LL * (c[tab[i]] - 1) / 2;
	printf("%lld\n", sum - res[tab[i]] + r);
	c[tab[i]]++;
}
return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 100000+10;
vector<int> L,A;

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

    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A.push_back(a);
    }

    L.push_back(-A[0]);

    for(int i = 1;i < N;i++) {
        int a = A[i];
        a *= -1;
        auto it = upper_bound(L.begin(),L.end(),a);
        if(it == L.end())
            L.push_back(a);
        else
            *it = a;
    }

    cout<<L.size()<<endl;


    return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    auto check = [&](char out0, char out1) {
        auto a = out0;
        char out2;
        auto v = vector<char>();
        v.push_back(out0);
        v.push_back(out1);
        auto f = [](char in1, char out0, char out1) {
            char out2;
            if (in1 == 'o') {
                if (out0 == 'S' && out1 == 'S') out2 = 'S';
                if (out0 == 'S' && out1 == 'W') out2 = 'W';
                if (out0 == 'W' && out1 == 'S') out2 = 'W';
                if (out0 == 'W' && out1 == 'W') out2 = 'S';
            } else {
                if (out0 == 'S' && out1 == 'S') out2 = 'W';
                if (out0 == 'S' && out1 == 'W') out2 = 'S';
                if (out0 == 'W' && out1 == 'S') out2 = 'S';
                if (out0 == 'W' && out1 == 'W') out2 = 'W';
            }
            return out2;
        };
        for (int i = 1; i < n; i++) {
            char in1 = s[i];
            out2 = f(in1, out0, out1);
            v.push_back(out2);
            out0 = out1;
            out1 = out2;
        }

        if (out2 == a) {
            v.erase(v.end() - 1);
            if (f(s[0], v[n - 1], v[0]) == v[1]) {
                return v;
            }
        }
        return vector<char>();
    };

    auto intToC = [](int a) {
        return a == 0 ? 'S' : 'W';
    };

    for (int i = 0; i < 4; i++) {
        char out0 = intToC(i % 2);
        char out1 = intToC(i / 2 % 2);
        auto v = check(out0, out1);
        if (v.size() > 0) {
            for (auto c : v) {
                putchar(c);
            }
            puts("");
            return 0;
        }
    }

    puts("-1");
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int lower = max(A,C);
  int upper = min(B,D);
  if (lower<upper) cout << upper-lower<<endl;
  if (upper<=lower) cout << 0 <<endl;
}


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

using namespace std;

typedef pair<int,int> P;

int in[3][3],mod;
vector<int> V;
vector<P> empty;
bool used[11];
int ans;

void init(){
  V.clear();
  empty.clear();
  fill(used,used+11,false);
  ans = 0;
}

int check_row(){
  int sum[3];
  
  for(int i = 0; i < 3; i++){
    int tmp = 0;
    for(int j = 0; j < 3; j++)
      tmp += in[i][j];
    sum[i] = tmp;
  }

 for(int i = 0; i < 3; i++)
   sum[i] %= mod;


 if((sum[0] == sum[1])&&(sum[0] == sum[2])) return sum[0];
 return -1;
}

int check_column(){
  int sum[3];
  
  for(int i = 0; i < 3; i++){
    int tmp = 0;
    for(int j = 0; j < 3; j++)
      tmp += in[j][i];
    sum[i] = tmp;
  }

  for(int i = 0; i < 3; i++)
    sum[i] %= mod;

  if((sum[0] == sum[1])&&(sum[0] == sum[2])) return sum[0];
  return -1;
}

int check_dia(){
  int sum[2] = {0,0};

  for(int i = 0; i < 3; i++){
    sum[0]+=in[i][i];
    sum[1]+=in[i][2-i];
  }

  sum[0] %= mod;
  sum[1] %= mod;
  
  if(sum[0] == sum[1]) return sum[0];
  return -1;
}

bool check(){

  int ansmod[3];

  if((ansmod[0] = check_row()) == -1) return false;
  
  if((ansmod[1] = check_column()) == -1) return false;
  if((ansmod[2] = check_dia()) == -1) return false;

  
  return (ansmod[0] == ansmod[1] && ansmod[0] == ansmod[2]);
}

void print(){
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++)
      cout << in[i][j] << " ";
    cout << endl;
  }
  cout << "mod " << mod << endl << endl;

}

void solve(){

  bool modchange = false;

  if(mod == 0) modchange = true;


  do{
    
    
    if(modchange){
      for(int i = 0; i < V.size()-1; i++)
	in[empty[i].first][empty[i].second] = V[i];
      
      mod = V[V.size()-1];

     

    }else{
      for(int i = 0; i < V.size(); i++)
	in[empty[i].first][empty[i].second] = V[i]; 
    }

    //print();

    if(check()) ans++;

  }while(next_permutation(V.begin(),V.end()));

  cout << ans << endl;
}

bool input(){
  init();
  
  bool flg = false;

  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++){
      cin  >> in[i][j];
      if(in[i][j] == 0) empty.push_back(P(i,j));
      if(in[i][j] != -1) flg = used[in[i][j]] = true;
    }

  cin >> mod;

  if(mod >= 0) used[mod] = true;

  for(int i = 1; i < 11; i++)
    if(!used[i]) V.push_back(i);

  return flg;
}

int main(){
  
  while(input()) solve();

  return 0;
}

Measured memory_bytes: 1220
class UnionFind():
    #https://note.nkmk.me/python-union-find/ 
    #note.nkmk.me  2019-08-18 
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない

N,M = map(int, input().split())
bridge =[]
for i in range(M):
    a,b = map(int, input().split())
    bridge.append((a,b))

all =N*(N-1)//2 #行き来できる島の組み合わせ
ans =[0]*(M-1) +[all]
#print(ans)

#i 番目の橋が崩落した直後の不便さ＝i+1番目がまだ残っているときの不便さ
#   ⇒最後の橋から順番に作り、できた時の不便さ
uf =UnionFind(N)

for i in range(M-1,0,-1):

    a,b =bridge[i]
    #事前につながっているかどうかで場合分け
    if uf.same(a-1,b-1):
        ans[i-1] =ans[i]
    #くっつけてから変化分を引く
    else:
        x_a =uf.size(a-1)
        x_b =uf.size(b-1)
        connection_bfo =x_a*(x_a -1)//2 +x_b*(x_b -1)//2
        connection_aft =(x_a +x_b) *(x_a +x_b -1)//2 
        ans[i-1] =ans[i] -connection_aft +connection_bfo
        uf.union(a-1,b-1)
[print(i) for i in ans]


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

Measured memory_bytes: 14980
function Main(input) {
  const lines = input.split("\n");
  const as = lines[1].split(' ').map(v => +v);
  let result = 'APPROVED';
  
  as.some(v => {
    if (v % 2 == 0 && v % 3 != 0 && v % 5 != 0) {
        result = 'DENIED';
        return true;
    }
  });

  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
	int a, b;
	cin >> a >> b;
	if ( a + b == 15 ) {
		cout << "+" << endl;
	} else if ( a * b == 15 ) {
		cout << "*" << endl;
	} else {
		cout << "x" << endl;
	}
	return ( 0 );
}


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

int main()
{
    int N;
    scanf("%d", &N);
    pair<int, int> P[N];
    for(int i = 0; i < N; ++i) { scanf("%d", &P[i].second); }
    {
        int cur = 0;
        for(int i = 0; i < N; ++i) {
            if(i%2) { //put left 
                P[i].first = -cur;
            } else 
            {
                P[i].first = cur; ++cur;
            }
        }
    }

    sort(P, P + N);
    for(int i = 0; i < N; ++i) {
        if(N%2 == 0) printf("%d ", P[i].second);
        else printf("%d ", P[N-1-i].second);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3840
#include<stdio.h>
#include<math.h>
int myabs(int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	int a[502];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int sum = 0;
	for (i = 0; i < n; i++)
		sum += a[i];
	int x, j, l;
	int count;
	int b[502];
	int p, q;
	for (i = 1; i <= sqrt(sum); i++)
	{
		if (sum % i == 0)
		{
			x = sum / i;
			for (j = 0; j < n; j++)
				b[j] = a[j] % x;
			for (j = 0; j < n - 1; j++)
			{
				if (b[j] > b[j + 1])
				{
					b[j] ^= b[j + 1];
					b[j + 1] ^= b[j];
					b[j] ^= b[j + 1];
					if (j > 0)
						j -= 2;
				}
			}
			count = 0;
			l = n - 1;
			for (j = 0; j < n; j++)
			{
				if (b[j] % x != 0)
				{
					count += b[j];
					b[j] %= x;
					while (b[j] > 0)
					{
						if (b[l] + b[j] < x)
						{
							b[l] += b[j];
							b[j] = 0;
						}
						else
						{
							b[j] -= x - b[l];
							b[l] = x;
							l--;
						}
					}
				}
			}
			if (count <= k)
			{
				printf("%d\n", x);
				return 0;
			}
		}
	}
	for (i = (int)sqrt(sum); i > 0; i--)
	{
		if (sum % i == 0)
		{
			x = i;
			for (j = 0; j < n; j++)
				b[j] = a[j] % x;
			for (j = 0; j < n - 1; j++)
			{
				if (b[j] > b[j + 1])
				{
					b[j] ^= b[j + 1];
					b[j + 1] ^= b[j];
					b[j] ^= b[j + 1];
					if (j > 0)
						j -= 2;
				}
			}
			count = 0;
			l = n - 1;
			for (j = 0; j < n; j++)
			{
				if (b[j] % x != 0)
				{
					count += b[j];
					b[j] %= x;
					while (b[j] > 0)
					{
						if (b[l] + b[j] < x)
						{
							b[l] += b[j];
							b[j] = 0;
						}
						else
						{
							b[j] -= x - b[l];
							b[l] = x;
							l--;
						}
					}
				}
			}
			if (count <= k)
			{
				printf("%d\n", x);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 128
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int a=gInt(),b=gInt();
		System.out.println(a<=b?a:a-1);
	}
	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}


Measured memory_bytes: 21460
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using ll = long long;
using namespace std;
int x, y, z, l, m, n, r, q, k, s;

void solve() {
    vector<int> c(10000,0);
    int count = 1;
    cin>>s;
    c[s]++;
    auto f = [&](int x){
        return x&1?3*x+1:x/2;
    };
    while(c[f(s)]<1){
        s = f(s);
        c[s]++;
        count++;
    }
    cout<<count+1<<'\n';


}

int main() 
{
    std::ios::sync_with_stdio(false); \
        std::cin.tie(NULL);
    int test;
    test  = 1;
    while (test--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
a,b,x = map(int,input().split())

import math
if (x/a < 0.5*a*b):
  print(90-math.degrees(math.atan((2*x)/(a*b**2))))
elif (x/a == a*b):
  print(0)
else:
  print(90-math.degrees(math.atan(0.5*a**3/((b*a**2)-x))))

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

//ABC109A
int main(void) {
  int a, b, n, k, i, cou=0, tmp;
  scanf("%d %d", &a, &b);
  if(a*b%2==0) printf("No");
  else printf("Yes");
}

Measured memory_bytes: 128
#include<algorithm>
#include<cstring>
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

double caver(int N,double num[]) {
	double sum = 0;
	for(int i=0;i<N;i++) sum += num[i];
	double ans = sum/(N*1.);
	return ans;
}

double cstan(int N,double num[]) {
	double aver = caver(N,num);
	double ans = 0;
	for(int i=0;i<N;i++) {
		double tmp = num[i] - aver;
		ans = ans + tmp*tmp;
	}
	ans = sqrt(ans/N);
	return ans;
}

double cstana(int N,double num[]) {
	double stana = cstan(N,num);
	double ans = stana/sqrt(N);
	return ans;
}

double cstanb(double delta) { 
	return delta/sqrt(3);
	return delta;
}

int main() {
	//freopen("in","r",stdin);
	bool type = 1;//type = 0;
	while(1) {
		
			int N;
			double num[10000], delta;
			cin>>N;
			if(N==0) break;
			for(int i=0;i<N;i++) {
				cin>>num[i];
			}

			//double aver = caver(N,num);
			double stan = cstan(N,num);
		
			cout<<fixed<<setprecision(6)<<stan<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 3280
#include<stdio.h>

int main(void){
    char S[10]={};
    scanf("%s",S);
    if(S[0]!='A'){
        printf("WA");
        return 0;
    }
    S[0] = 'a';
    int len=0;
    while(S[len]!='\0'){
        len++;
    }
    int count = 0;
    for(int i=2;i<=len-2;i++){
        if(S[i]=='C'){
            count++;
            S[i] = 'c';
        }
    }
    if(count!=1){
        printf("WA");
        return 0;
    }
    for(int i=0;i<len;i++){
        if(S[i]<='Z'){
            printf("WA");
            return 0;
        }
    }
    printf("AC");    

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
using namespace std;
int k;
long long s;
int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}
int main(void)
{
	scanf("%d",&k);
	for(int i=1;i<=k;i++)
		for(int j=1;j<=k;j++)
			for(int l=1;l<=k;l++)
				s+=gcd(gcd(i,j),l);
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll h, w, a, b;
    cin >> h >> w >> a >> b;

    init();

    ll ans = 0;
    exrep(j, b, w-1) {
        ans += Comb(h-a-1+j, j)*Comb(w+a-2-j, a-1);
        ans %= mod;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int visit[101];
int main(){
	int N, K;
	cin >> N >> K;
	for(int i=1; i<=K; i++){
		int d1, v;
		cin >> d1;
		for(int j=1; j<=d1; j++){
			cin >> v;
			visit[v] = 1;
		}
	}
	int ans = 0;
	for(int i=1; i<=N; i++){
		if(!visit[i]) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
//#include<ctype.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
//#define MAX(a,b) a>b?a:b
//#define MIN(a,b) a<b?a:b

int main() {
	unsigned n;
	S(d, n);
	P(g, ceil(log(n)/log(3)));
	return 0;
}

Measured memory_bytes: 672
import java.util.*;

public class Main {
    public static void main(String[] args)  {

        Scanner sc = new Scanner(System.in);
        boolean result = check(sc);

        toPrint(result);

    }

    public static void toPrint(boolean result) {
        if(result){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static boolean check(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        String code = sc.next();
        if(code.charAt(a) != '-' )
            return false;
        for(int i = 0; i < code.length(); i++){
            if(i == a) continue;
            if(!Character.isDigit(code.charAt(i))) return false;
        }

        return true;
    }
}


Measured memory_bytes: 25044
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define vl vector<long long>
#define pll pair<long long,long long>
#define sl set<long long>
#define uset unordered_set<long long>
#define umap unordered_map
#define hell 1000000007
#define mod 998244353
#define pb push_back
#define mp make_pair
#define N 10001
#define inf 1e16
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<endl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
using namespace std;
ll power(ll x, ll y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return (power(x, y / 2) * power(x, y / 2)) % mod;
  else
    return ((x * power(x, y / 2)) % mod * power(x, y / 2)) % mod;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;  
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little theorem. 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p; 
}
ll log26(ll n){
  ll i=0;
  ll x=1;
  if(n==0)
    return 0;
  while(true){
    if(x<=n&&x*26>n){
      return i;
    }
    x*=26;
    i++;
  }
}
ll sum(ll n){
  ll s=0,i;
  for(i=1;i<=n;i++){
    s+=pow(26,i);
  }
  //cout<<s<<endl;
  return s;
}
int main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt.txt","r",stdin);
  freopen("output.txt.txt","w",stdout);
  freopen("error.txt","w",stderr);
  #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    ll n,i,j,x,y;
    map<ll,ll> m;
    cin>>n;
    ll a[n];
    ll s=0;
    for(i=0;i<n;i++){
      cin>>a[i];
      m[a[i]]++;
      s+=a[i];
    }
    ll q;
    cin>>q;
    while(q--){
      cin>>x>>y;
      if(x!=y){
        s=s-m[x]*x+m[x]*y;
        m[y]+=m[x];
        m[x]=0;
      }
      cout<<s<<endl;

    }
    cerr<<(1000*clock())/CLOCKS_PER_SEC<<"ms";
    return 0;
}


Measured memory_bytes: 10304
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, h, w, res;
	cin>>n>>h>>w;
	res = 0;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(i + w <= n && j + h <= n)res++;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=3e5+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int n;
string s;
int f[26];
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  cin>>s;
  int cnt=1;
  for(int i=0;i<n;i++)f[s[i]-'a']++;
  for(int i=0;i<26;i++)cnt=cnt*1LL*(f[i]+1)%mod;
  cnt--;
  cnt+=mod;
  cnt%=mod;
  cout<<cnt;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int N;
bool e[51][51];

void dfs(int i, int *d)
{
	if (d[i]) return;
	d[0]++;
	d[i] = 1;
	for (int j = 1; j <= N; j++)
		if (e[i][j]) dfs(j, d);
}

int main()
{
	int M;
	cin >> N >> M;
	int a[50], b[50];
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		e[a[i]][b[i]] = e[b[i]][a[i]] = true;
	}
	int c = 0;
	for (int i = 0; i < M; i++) {
		e[a[i]][b[i]] = e[b[i]][a[i]] = false;
		int d[51] = {};
		dfs(*a, d);
		c += *d < N;
		e[a[i]][b[i]] = e[b[i]][a[i]] = true;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()


def check(s):
    if not s[0] == "A":
        return False
    if not s[2:-1].count("C") == 1:
        return False
    count = 0
    for c in s[1:]:
        if not c.lower() == c:
            count += 1
            if count > 1:
                return False
    return True


print("AC" if check(S) else "WA")


Measured memory_bytes: 3060
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef unsigned long long  ULL;

constexpr ULL _MOD = 1000000007;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ULL powOf2(int k) {
    if(k == 0) return 1;
    return 2 * powOf2(k-1);
}

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<ULL> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    ULL odd = 0;
    ULL even = 0;
    ULL ans = 0;
    ULL temp = 0;

    for(int i=0; i<60; i++){
        for(int j=0; j<N; j++){
            if((A[j] >> i) & 1) {
                odd++;
            }
            else {
                even++;
            }
        }

        temp = (ULL)1 << i;
        temp %= _MOD;
        temp *= (odd * even) % _MOD;

        ans += temp;
        ans %= _MOD;

        odd = 0;
        even = 0;
    }

    cout << ans % 1000000007<< endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////

int main() {
	int N, K; cin >> N >> K;
	int V[51];
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
	}
	ll ans = 0;
	for (int i = 0; i <= min(N, K); ++i) {
		for (int j = 0; i+j <= min(N, K); ++j) {
			vector<int>G;
			for (int k = 0; k < i; ++k) {
				G.push_back(V[k]);
			}
			for (int k = 0; k < j; ++k) {
				G.push_back(V[N - 1 - k]);
			}
			sort(G.begin(), G.end());
			int cnt = 0;
			ll sum = 0;
			for (int k = 0; k < G.size(); ++k) {
				if (cnt < (K - i - j) && G[k] < 0) {
					++cnt;
				}
				else {
					sum += G[k];
				}
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i=0; i<N; ++i) {
    cin >> vec.at(i);
  }
  int a = 0;
  for (int j=0; j<N; ++j) {
    if (vec.at(j) >= K) {
      ++a;
    }
  }
  cout << a << endl;
}
  

Measured memory_bytes: 640
N, K=map(int, input().split())
MOD=10**9+7

EXA=[1]*(N+1)
for i in range(2, N+1):
  EXA[i]=EXA[i-1]*i%MOD
  
EXB=[1]*N+[pow(EXA[N], MOD-2, MOD)]
for i in range(N-1, 1, -1):
  EXB[i]=EXB[i+1]*(i+1)%MOD
  
def combmod(n, r):
  return EXA[n]*EXB[r]*EXB[n-r]

def f(I):
  z=N-K-(I-1)
  if z==0:
    print(combmod(K-1, I-1)%MOD)
  elif z<0:
    print(0)
  else:
    tmp=combmod(K-1, I-1)
    tmp=tmp*EXA[N-K+1]%MOD
    tmp=tmp*EXB[N-K-I+1]%MOD
    tmp=tmp*EXB[I]%MOD
    print(tmp)

for i in range(1, K+1):
  f(i)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int f[610],s[610],R[610],lnk[610],F[610][610];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi()*2,k=gi(),A,B;
	for(int i=1;i<=n;++i)s[i]=1;
	while(k--){
		A=gi(),B=gi();if(A>B)std::swap(A,B);
		s[A]=s[B]=0;R[A]=B;lnk[A]=B,lnk[B]=A;
	}
	for(int i=1;i<=n;++i)s[i]+=s[i-1];
	int ans=0;
	f[0]=1;for(int i=2;i<=n;i+=2)f[i]=1ll*f[i-2]*(i-1)%mod;
	for(int sz=2;sz<=n;++sz){
		for(int l=1,r=sz;r<=n;++l,++r){
			if(R[l]&&R[l]>r)continue;
			bool flg=0;
			for(int i=l;i<=r;++i)if(lnk[i]&&(lnk[i]<l||lnk[i]>r)){flg=1;break;}
			if(flg)continue;
			F[l][r]=f[s[r]-s[l-1]];
			for(int i=R[l];i<r;++i)F[l][r]=(F[l][r]-1ll*F[l][i]*f[s[r]-s[i]]%mod+mod)%mod;
			ans=(ans+1ll*F[l][r]*f[s[n]-s[r]+s[l-1]])%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1664
'use strict'

const main = (input) => {
    input = input.split('\n')
    const H = parseInt(input[0].split(' ')[0])
    const W = parseInt(input[0].split(' ')[1])
    const grid = input.slice(1, H + 1).map(w =>  w.split(''))
    const g1 = grid.filter(g => g.some(h => h === '#'))
    let buffer = []
    g1.forEach(g => {
        g.forEach((h, i) => {
            if(h === '#'){
                buffer.push(i)
            }
        })
    })
    buffer = [...new Set(buffer)]
    g1.forEach(g => {
        let str = ''
        g.forEach((h, i) => {
            if(buffer.some((v) => i === v)){
                str += h
            }
            if(i === g.length -1){
                console.log(str)
            }
        })
    })
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 9744
a, b = map(int, input().split())

ans = -1
#a,bの最大値が100円までなので、消費税100円になる10000円まで実行すればOK
for i in range(1, 10001):
  if int(i * 0.08) == a and int(i * 0.10) == b:
    ans = i
    break

print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int N;
	cin >> N;
	vector<int> S(N), T;
	int sum = 0;
	rep(i,N) {
		cin >> S[i];
		sum += S[i];
		if(S[i] % 10 != 0) T.pb(S[i]);
	}
	if(sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	
	if(T.size() != 0) {
		sort(T.begin(), T.end());
		cout << sum - T[0] << endl;
		return 0;
	}
	else {
		cout << 0 << endl;
		return 0;
	}

  return 0;
}


Measured memory_bytes: 256
n,*a=$<.map &:to_i
mod=10**9+7
res=1
c=d=0
a.map.with_index{|x,i|[x,i<n]}.sort.each do |x,pc|
    if pc
        d>0 ? (res=res*d%mod; d-=1) : c+=1
    else
        c>0 ? (res=res*c%mod; c-=1) : d+=1
    end
end
p res


Measured memory_bytes: 18680
import math
import itertools
import statistics
#n = int(input())
#n, T = list(map(int, input().split()))

def check(n):
    for i in range(n-1):
        if w[n]==w[i]:
            return True
    return False

n = int(input())
w = []
for i in range(n):
    w.append(input())

for i in range(1,n):
    if w[i-1][-1]!=w[i][0] or check(i):
        print("No")
        exit()

print("Yes")

    

Measured memory_bytes: 5144
#include <cstdio>
#include <algorithm>
using namespace std;

int n;

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=9;i++)
	for(int j=1;j<=9;j++)
	if(i*j==n){
		printf("Yes");
		return 0;
	}
	printf("No");
}

Measured memory_bytes: 128
def inverse(a, p):
    a_, p_ = a, p
    x, y = 1, 0
    while p_:
        t = a_ // p_
        a_ -= t * p_
        a_, p_ = p_, a_
        x -= t * y
        x, y = y, x
    x %= p
    return x


def solve():
    N, M, K = map(int, input().split())
    mod = 998244353

    nCi = [1]
    for i in range(1, N):
        nCi.append(nCi[i - 1] * (N - i) * inverse(i, mod) % mod)
    ans = 0
    for k in range(K + 1):
        n = N - k
        ans += M * int(pow((M - 1), n - 1, mod)) * nCi[k]
        ans %= mod
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16888
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n;
    cin >> n;
    ll a[n];
    unordered_map < ll , ll > mpp;
    rep(i, n){
        cin >> a[i];
        mpp[a[i]]++;
    }
    sort(a, a+n);
    if(a[n/2] == a[(n/2) - 1]){
        cout << 0 << endl;
        return 0;
    }
    ll c = 1;
    fo(i, a[(n/2) - 1]+1, a[n-1]){
        if(mpp[i])   break;
        else{
            c++;
        }
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 5156
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, A: int, B: int, C: int, p: "List[int]", q: "List[int]", r: "List[int]"):
    pqr = [(0,p[i]) for i in range(A)] + [(1,q[i]) for i in range(B)] + [(2,r[i]) for i in range(C)]
    pqr.sort(key= lambda x: -x[1])

    answer = 0
    count = [0,0,0]
    for i in range(len(pqr)):
        if sum(count) == X+Y:
            break
        key,value = pqr[i]
        if key == 0:
            if count[key] >= X:
                continue
            count[key] += 1
        elif key == 1:
            if count[key] >= Y:
                continue
            count[key] += 1
        else:
            count[key] += 1
        answer += value
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    q = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    r = [int(next(tokens)) for _ in range(C)]  # type: "List[int]"
    solve(X, Y, A, B, C, p, q, r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 60724
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	a = risort(a)

	if n == 2 {
		fmt.Println(a[0])
		return
	}

	var ret int
	var tmp []int
	var tc int
	for k, v := range a {
		if k == 0 {
			ret += v
			continue
		}
		if k == 1 {
			tmp = append(tmp, v)
			tc = 2
			continue
		}
		tmp = append(tmp, v)
		tc--
		ret += tmp[0]
		if tc == 0 {
			tmp = tmp[1:]
			tc = 2
		}
	}
	fmt.Println(ret)
}

func risort(s []int) []int {
	sort.Slice(s, func(i, j int) bool { return s[i] > s[j] })
	return s
}

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


Measured memory_bytes: 8592
#include <iostream>
using namespace	std;
int main()
{
  int n;
  cin >> n;
  for(int j=0;j<n;j++){
    int y,m,d,c=0;
    cin >> y >> m >> d;
    for(int i=y; i<1000 ;i++){
      if (i%3==0)
        c+=200;
      else
        c+=195;
    }
    c-=d;
    c++;
    for (int i=1;i<m;i++){
      if(y%3==0)
        c-=20;
      else{
        if(i%2==0)
          c-=19;
        else
          c-=20;
      }
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3064
s=input()
S=list(s)

le=len(S)
counter=0

for i in range(0,le-1):
    if S[i]==S[i+1]:
        if S[i+1] =='0':
            S[i+1] ='1'
        else:
            S[i+1] ='0'
        counter=counter+1
print(counter)

Measured memory_bytes: 3956
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int X; cin >> X;
	cout << (X >= 30 ? "Yes" : "No") << endl;
}

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

int main() {
    int N, sum = 0;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < N - i; j++){
            sum += d.at(i) * d.at(i + j);
        }
    }
    cout << sum << endl;
}

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

int main() {
  int N,K,X,Y;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;

  if(N<=K){
    cout << X*N;return 0;
  }
  else{
      cout << X*K+(N-K)*Y; return 0;
  }
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, m, q;
    cin >> n >> m >> q;

    list<int> x;
    for(int i=0; i<n; ++i)
        x.push_back(i);

    auto it = x.begin();
    while(--m >= 0){
        int a;
        cin >> a;

        if(a % 2 == 0){
            while(--a >= 0){
                ++ it;
                if(it == x.end())
                    it = x.begin();
            }
        }
        else{
            while(--a >= 0){
                if(it == x.begin())
                    it = x.end();
                -- it;
            }
        }

        it = x.erase(it);
        if(it == x.end())
            it = x.begin();
    }

    vector<bool> ans(n, false);
    for(int i : x)
        ans[i] = true;

    while(--q >= 0){
        int a;
        cin >> a;
        if(ans[a])
            cout << 1 << endl;
        else
            cout << 0 << endl;
    }

    return 0;
}

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

using namespace std;
const long long MOD = 1e9 + 7;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<long long  > v(26);
  for(int i=0 ; i<n ; i++)
    v[s[i]-'a']++;
  long long res=1;
  for(int i=0 ; i<26 ;i++)
   if(v[i]>0) res=(res*(v[i]+1))%MOD;
  cout<<res-1;
 return 0; 
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

ll digit[200010];

int main(void){
    string s;
    cin>>s;
    ll n = s.length();
    ll power = 1;
    ll ans = 0;
    ll p = 2019;
    for(ll i=n-1;i>=0;i--){
        ll d =s[i]-'0';
        if(i!=n-1){
            power =(power*10)%p;
        }
        digit[(n-1)-i]=(d*power)%p;
    }
    for(ll i=0;i<n-1;i++)digit[i+1] = (digit[i+1]+digit[i])%p;
    map<ll,ll>m;
    for(ll i=0;i<n;i++)m[digit[i]]++;
    for(auto itr = m.begin();itr!=m.end();++itr){
        ll r = itr->first;
        ll cnt = itr->second;
        if(r == 0)ans+=(cnt+1)*cnt/2;
        else ans += (cnt-1)*cnt/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5236
from collections import defaultdict
n,m = list(map(int, input().split()))
wa = defaultdict(int)
ac = set()
for _ in range(m):
  p, s = input().split()
  if(s == "AC"):
    ac.add(p)
  if (p not in ac and s=="WA"): 
    wa[p] += 1
print(len(ac), sum([wa[i] for i in ac]))

Measured memory_bytes: 25172