akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

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

    double s; cin >> s;
    cout << fixed << setprecision(10) << pow(s / 3, 3) << endl;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.Math;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int max = 0;

        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= k - i; j++) {
                int h = k - i - j;
                int sum = a * (int)Math.pow(2, i) + b * (int)Math.pow(2, j) + c * (int)Math.pow(2, h);
                if (sum > max) {
                    max = sum;
                }
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23892
#include<stdio.h>
int main() {
	int n, a[100];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for(int k=0;k<n-1;k++)
		printf("%d ", a[n-1-k]);
	printf("%d", a[0]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 1816
a=list(map(int,input().split()))
sum=0;
if(a[0]>a[1]):
  sum+=a[0]
  a[0]-=1
else:
  sum+=a[1]
  a[1]-=1

if(a[0]>a[1]):
  sum+=a[0]
  a[0]-=1
else:
  sum+=a[1]
  a[1]-=1

print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
int L,M,N,c,i;
int main(){
  scanf("%d",&L);
  N=floor(log2(L))+1;
  M=(N-1)*2+__builtin_popcount(L-(1<<(N-1)));
  printf("%d %d\n",N,M);
  for(i=1;i<N;i++)printf("%d %d %d\n%d %d %d\n",i,i+1,0,i,i+1,1<<(i-1));
  c=1<<(N-1);
  for(i=N-2;i>=0;i--)if(L&(1<<i))printf("%d %d %d\n",i+1,N,c),c+=1<<i;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;

int main() {
	ll n,a[100005],s2,ss,y=0;
	a[0] = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		y = a[i] - y;
	}
	for (int i = 1; i <= n; i++) {
		ll s;
		if (i == 1) {
			s = y;
			a[1] -= s / 2;
			a[n] -= s / 2;
			cout << s << endl;
		}
		else {
			s = 2 * a[i-1];
			a[i] -= s / 2;
			cout << s << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	vi v(200002, -1);
	vi c;
	int w, a, b, change = 0;
	cin >> w >> a >> b;
	for (int i = a; i < a + w; i++) {
		v[i] = 1;
	}
	for (int i = b; i < b + w; i++) {
		v[i] = 1;
	}
	for (int i = 0; i < 200001;i++) {
		if (v[i] * v[i + 1] < 0) {
			change++;
			c.eb(i);
			//cout << i << endl;
		}
	}
	if (change  <3) {
		cout << 0 << endl;
	}
	else {
		cout << c[2] - c[1] << endl;
	}
}


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

#define scl(x) scanf("%lld",&x)
#define sc(x)  scanf("%d",&x)
#define ll long long
#define lop(i,n) for(int i=0;i<n;++i)
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

const int N=18,M=1<<18;
int memo[M][N][3],n,m,arr[M],ans[M];
int solve(int v,int idx,int cnt){
	if(idx<0)return ( cnt == 1 ? arr[v]:-2e9);
	if( !(v&(1<<idx)) )return solve(v,idx-1,cnt);
	int &ret=memo[v][idx][cnt];
	if(~ret)return ret;
	ret=solve(v,idx-1,cnt);
	if(cnt == 1)ret = max(ret, solve(v^(1<<idx),idx-1,cnt));
	if(cnt == 2)ret =max(ret, solve(v,idx-1,1) + solve(v^(1<<idx),idx-1,1));

	return ret;
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("i.txt","r",stdin);
#endif
	sc(n);
	m=(1<<n);
	lop(i,m)sc(arr[i]);
	memset(memo,-1,sizeof memo);
	for(int i=1;i<m;i++){
		ans[i]=max(ans[i-1],solve(i,n-1,2));
		printf("%d\n",ans[i]);
	}

}


Measured memory_bytes: 60416
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	double ans=0;
	while(n--) {
		double x;
		string u;
		cin>>x>>u;
		if(u=="JPY")ans+=x;
		else ans+=x*380000;
	}
	//cout<<ans;
	printf("%.8lf",ans);		
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3808
#include<iostream>
using namespace std;
int main(){
	int n,m;
	int a[1000];

	while(1){
		cin>>n>>m;

		if(n==0&&m==0)
			break;

		int ans=0;

		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(m>=(a[i]+a[j])&&ans<(a[i]+a[j]))
					ans=a[i]+a[j];
			}
		}
		
		if(ans==0){
			cout<<"NONE"<<endl;
		}
		else{
			cout<<ans<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double s = x/a;
  double rad;
  if (s >= a*b/2) {
    double h = (a*b-s)*2/a;
    rad = atan2(h,a);
  } else {
    double w = s*2/b;
    rad = atan2(b,w);
  }
  double PI = acos(-1);
  double deg = rad/(2*PI)*360;
  printf("%.10f\n", deg);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     //https://www.codechef.com/viewsolution/28454497
    // https://medium.com/hackernoon/manachers-algorithm-explained-longest-palindromic-substring-22cb27a5e96f
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
vector < ll> primes;
 int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int n;
bool isvalid(int x,int y){
  return (x>=0 and x<n and y>=0 and y<n);
}
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
 const int N = 5e5 + 5;
 	int connected;
	int par[N], sz[N];
 
struct DSU
{

	void init(int n) 
	{
		for(int i=1;i<=n;i++)
		{
			par[i]=i;
			sz[i]=1;
		}
		connected=n;
	}
 
	int getPar(int k)
	{
		while(k!=par[k])
		{
			par[k]=par[par[k]];
			k=par[k];
		}
		return k;
	}
 
	int getSize(int k)
	{
		return sz[getPar(k)];
	}
 
	void unite(int u, int v)
	{
		int par1=getPar(u), par2=getPar(v);
 
		if(par1==par2)
			return;
 
		connected--;
 
		if(sz[par1]>sz[par2])
			swap(par1, par2);
 
		sz[par2]+=sz[par1];
		sz[par1]=0;
		par[par1]=par[par2];
	}
};
 
 

DSU dsu;
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}
// vector<vector<int>>dp(3500,vector<int>(3500));

 
 
int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    double ans=0.0,temp=0.0;
    
    cin>>n>>k;
    int a[n];
    for(int &i:a)cin>>i;
    
    queue<int>q;
    
    
    for(int i=0;i<k;i++)
    {
        q.push(a[i]);
        temp+=(double)(a[i]+1)/(2);
        
    }
    
    for(int i=k;i<n;i++)
    {
        
        double t;
        int p=q.front();
        q.pop();
        t=(double)(p+1)/(2);
        
        ans=max(ans,temp);
        
        temp-=t;
        
        q.push(a[i]);
        temp+=(double)(a[i]+1)/(2);
        
        
    }
    ans=max(ans,temp);
    
    cout<<fixed<<setprecision(15)<<ans;
    
    
}

Measured memory_bytes: 3456
#include <cstdio>

int N, M;
int imos[1010];
int main() {
    scanf("%d%d", &N, &M);
    for(int i=0; i<M; i++) {
        int l, r; scanf("%d%d", &l, &r);
        imos[l]++;
        imos[r]--;
    }
    for(int i=1; i<=N; i++) {
        imos[i] += imos[i-1];
    }

    int prev = -1, ans = N + 1;
    for(int i=1; i<=N+1; i++) {
        if( imos[i] && prev <  0) prev = i;
        if(!imos[i] && prev >= 0) {
            // printf("l = %d, r = %d\n", prev, i);
            ans += 2 * (i - prev);
            prev = -1;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void solve() {
    int n, d;
    cin >> n >> d;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cnt += sqrt((long )x * x + (long)y * y) <= d ? 1 : 0;
    }
    cout << cnt;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}

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

int main(){
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u.compare(s))
        b--;
    else if(u.compare(t))
        a--;
    else{
        a--;
        b--;
    }

    cout<<a<<" "<<b;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long


signed main() {
  int n, k;
  cin >> n>>k;
  vector<int> a(n);
  vector<int> f(n);  
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> f[i];
  sort(a.begin(), a.end(),greater<int>());
  sort(f.begin(), f.end());
  int l = -1, r =1e12;
  while(l+1<r) {
    int mid = (l+r)/2;
    bool ok = [&]{
      ll s = 0;
      rep(i,n) s+=max(0ll,a[i]-mid/f[i]);
      return s<=k;
    }();
    if(ok) r = mid;
    else l = mid; 
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int init = n == 1 ? 0 : 1;
  REP(i, n - 1) { init *= 10; }
  int end = n == 1 ? 10 : init * 10;

  vector<pair<int, int>> sc(m);
  REP(i, m) {
    int s, c;
    cin >> s >> c;
    sc[i] = make_pair(n - s, c);
  }

  FOR(target, init, end) {
    bool ok = true;
    REP(i, m) {
      int tmp = target;
      REP(j, sc[i].first) { tmp /= 10; }
      if ((tmp % 10) != sc[i].second) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << target << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static String s;
	static int n;
	static char[] c;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		s = sc.next();
		n = s.length();
		c = s.toCharArray();
		long ans = dfs(0, "");
		System.out.println(ans);
	}

	public static long dfs(int i, String x) {
		if(i == n) {
			x = x.replace("+", "A");
			String[] a = x.split("A");
			long temp = 0;
			for(int j = 0 ; j < a.length ; j++) {
				temp += Long.valueOf(a[j]);
			}
			return temp;
		}
		long ret = 0;
		ret += dfs(i + 1, x + c[i]);
		if(i != 0) ret += dfs(i + 1, x + "+" + c[i]);
		return ret;
	}

}


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

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 && i % 5) {
			ans += i;
		}
	}
	cout << ans << endl;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n, m, x;
  std::cin >> n >> m >> x;
  int r = 0, l = 0;
  REP(i, m) {
    int a = read();
    if (x < a)
      r++;
    else if (x > a)
      l++;
  }
  print(min(r, l));
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
char itoc(int x)
{
	char calpha = x + 48;
	return calpha;
}
int main()
{
	string s = "AB";
	int n;
	cin >> n;
	if (n > 999)
		n = n + 1;
	char c1_1;
	if (n > 999)
		c1_1 = 'D';
	else
		c1_1 = 'C';
	char c2_1 = itoc(n % 1000 / 100);
	char c2_2 = itoc(n % 100 / 10);
	char c2_3 = itoc(n % 10);
	cout << s + c1_1;

}

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

int main(){
  long long n, m;
  cin >> n >> m;
  long long result;
  if (n == 1 && m == 1) result = 1;
  else if (n == 1) result = m - 2;
  else if (m == 1) result = n - 2;
  else result = (m - 2) * (n - 2);
  cout << result << endl;
  return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

int main(void) {
    int h;
    while (cin >> h) {
        if (h == 0) {
            break; 
        }
        VII table(h, VI(5));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> table[i][j];
            }
        }

        int score = 0;
        while (1) {
            bool change = false;
            for (int i = 0; i < h; i++) {
                int j = 0;
                while (j < 3) {
                    int k;
                    for (k = j + 1; k < 5; k++) {
                        if (table[i][k] != table[i][j]) {
                            break;
                        }
                    }
                    if (k - j > 2 && table[i][j] != 0) {
                        score += (k - j) * table[i][j];
                        for (int l = j; l < k; l++) {
                            table[i][l] = 0;  
                        }
                        change = true;
                    }
                    j = k;
                }
            }

            if (! change) {
                break;
            }
            for (int k = 0; k < h; k++) {
                for (int i = h - 1; i > 0; i--) {
                    for (int j = 0; j < 5; j++) {
                        if (table[i][j] == 0) {
                            table[i][j] = table[i-1][j];
                            table[i-1][j] = 0;
                        }
                    }
                }
            }
        }
        cout << score << endl;
    }
    return 0;
}

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

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<int> S(N,1);
  rep(i,K) {
    cin >> d[i];
    rep(j,d[i]) {
      int a;
      cin >> a;
      S[a-1]=0;
    }
  }
  int ans=0;
  rep(i,N) ans+=S[i];
  cout << ans << endl;
}

Measured memory_bytes: 3632
n = int(input())
lst = list(map(int, input().split()))
i = 0 

for _ in lst:
  if _ % 2 == 0:
    if _ % 3 != 0 and _ % 5 != 0:
      i += 1
      break

if i == 0:
  print('APPROVED')
else:
  print('DENIED')
  

Measured memory_bytes: 2940
import heapq
N, M = map(int, input().split())
ab = [list(map(int,input().split())) for i in range(N)]
ab = sorted(ab, key = lambda x:x[0])
tgt = []
heapq.heapify(tgt)
count = 0
profit = 0
for m in range(M-1,-1,-1):
    for i in range(count, len(ab)):
        if ab[i][0] == M-m:
            heapq.heappush(tgt, -ab[i][1])
            count += 1
        else:
            break
    if len(tgt) != 0:
        getval = -heapq.heappop(tgt)
        profit += getval
print(profit)


Measured memory_bytes: 83288
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S,T;
  	cin >> S >> T;
    bool finddifference = false;
    for(int i=0; i < S.length(); i++){
      if(S[i] != T[i])
			  finddifference = true;
    }
    if(finddifference){
      cout << "No" << endl; 
    }
    else{
			cout << "Yes" << endl;
    }
}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}

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

int main() {
  use_cio();
  ll s;
  cin >> s;
  ll x1, x2, y1, y2;
  x1 = 1e9;
  y1 = 1;
  y2 = (s + x1 - 1) / x1;
  x2 = x1 * y2 - s;
  cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
l,r = Counter(v[0::2]).most_common(), Counter(v[1::2]).most_common()
l.append((0,0))
r.append((0,0))
if l[0][0] != r[0][0]:
  print(n-(l[0][1]+r[0][1]))
else:
  print(min(n-(l[1][1]+r[0][1]), n-(l[0][1]+r[1][1])))

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

template <typename T>
T gcd(T x, T y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

template <typename T>
T lcm(T x, T y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    string S;
    cin >> S;
    int n = S.size();

    for (int i = n - 1; i >= 0; i--)
    {
        if (S[i] == 'A' || S[i] == 'K' || S[i] == 'I')
            continue;
        if (S[i] != 'A' && S[i + 1] != 'A')
            S.insert(i + 1, "A");
    }
    if (S[0] != 'A')
        S = 'A' + S;
    cout << (S == "AKIHABARA" ? "YES" : "NO") << endl;
}

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

// それぞれマイナス方向で頑張るか、プラス方向で頑張るかの2^3=8通りのパターンを固定して考えてやるとソートが可能になり、
// 順番にいい方から選べそう

long long solve(long long N, long long M, vector<vector<long long>> values){
    long long res = 0;
    for (int s = 0; s < 8; s++) {
        vector<long long> sums;
        for (int i = 0; i < N; i++) {
            long long t = 0;
            for (int j = 0; j < 3; j++) {
                t += values[j][i] * (s & 1 << j ? 1 : -1);
            }
            sums.push_back(t);
        }
        sort(sums.begin(), sums.end());
        reverse(sums.begin(), sums.end());
        res = max(res, accumulate(sums.begin(), sums.begin() + M, 0LL));
    }
    return res;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    vector<vector<long long>> values(3, vector<long long>(N));
    for(int i = 0 ; i < N ; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%lld",&values[j][i]);
        }
    }
    cout << solve(N, M, std::move(values)) << endl;
    return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,border=-1;
    cin>>n;
    Vi a(n);
    vin(a);

    sort(ALL(a));
//    vout(a);
    REP(i,0,n){
        if(a[i]>0){
            border=i;
            break;
        }
    }
    if(border==0) border=1;
    if(border==-1) border=n-1;
    int left=a[0],right=a[n-1];
    REP(i,border,n-1){
        left -= a[i];
    }
    REP(i,1,border){
        right -= a[i];
    }
//    cout<<right<< " "<<left<<endl;
    cout<<right-left<<endl;

    int cleft=a[0],cright=a[n-1];
    REP(i,border,n-1){
        cout<<cleft<<" "<<a[i]<<endl;
        cleft -= a[i];
    }
    REP(i,1,border){
        cout<<cright<<" "<<a[i]<<endl;
        cright -=a[i];
    }
    cout<<cright<<" "<<cleft<<endl;
    return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	vector<pair<char,ll>> t;
	REP(i,(ll)s.size()) {
		if(s[i]!='x') {
			t.pb(pair<char,ll>(s[i],i));
		}
	}
	for(ll i=0; i<((ll)t.size()+1)/2; i++) {
		if(t[i].first!=t[(ll)t.size()-1-i].first) {
			cout<<-1<<endl;
			return 0;
		}
	}
	if((ll)s.size()==(ll)t.size()||(ll)t.size()==0) {
		cout<<0<<endl;
		return 0;
	}
	ll ret=0;
	ll lp,rp;
	if((ll)t.size()%2==0) {
		lp=(ll)t.size()/2-1;
		rp=(ll)t.size()/2;
	} else {
		lp=(ll)t.size()/2;
		rp=(ll)t.size()/2;
	}
	FOR(i,1,((ll)t.size()+1)/2) {
		if(t[lp].second-t[lp-1].second!=t[rp+1].second-t[rp].second) {
			ret+=abs((t[lp].second-t[lp-1].second)-(t[rp+1].second-t[rp].second));
		}
		lp--;
		rp++;
	}
	ret+=abs((t[0].second-0)-(((ll)s.size()-1)-t[(ll)t.size()-1].second));
	cout<<ret<<endl;
}


Measured memory_bytes: 2500
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, count = 1;

    cin >> N;
    vector<string> S(N);

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

    sort(S.begin(), S.end());

    for(int i = 0; i < N-1; i++)
    {
        if(S[i] != S[i+1])
        {
            count++;
        }
    }

    cout << count << endl;


    return 0;
}


Measured memory_bytes: 9604
def check(s)
  stack=[]
  s.size.times{|i|
    case s[i].chr
    when '('
      stack.push(s[i].chr)
    when '['
      stack.push(s[i].chr)
    when ')'
      prv=stack.pop
      if prv!='('
        return false
      end
    when ']'
      prv=stack.pop
      if prv!='['
        return false
      end
    end
  }
  if stack.empty?
    return true
  else
    return false
  end
end

while s=gets.chomp! do
  if s=="."
    break
  end
  if check(s)
    puts "yes"
  else
    puts "no"
  end
end

Measured memory_bytes: 2320
c = [list(map(int,input().split())) for i in range(3)]
a1 = 0
a2 = 0
a3 = 0
b1 = 0
b2 = 0
b3 = 0
m = min(c[0])
for i in range(m+1):
    a1 = i
    b1 = c[0][0]-a1
    b2 = c[0][1]-a2
    b3 = c[0][2]-a3
    if c[1][0]-b1 == c[1][1]-b2 == c[1][2]-b3:
        a2 = c[1][0]-b1
    else:
        continue
    if c[2][0]-b1 == c[2][1]-b2 == c[2][2]-b3:
        print('Yes')
        exit()
print('No')




Measured memory_bytes: 3064
#include<iostream>

int main() {
	int n,m=0,j=0;
	std::cin >>n;

	if (n < 105) {
		std::cout << 0 << std::endl;
		exit(0);
	}

	for (int p = 105; p <= n; p++) {
		m = 0;
		if (p % 2 == 1) {
			for (int i = 1; i < p / 2; i++) {
				if (p%i == 0) {
					m++;
				}
			}

			if (m == 7) {
				j++;
			}
		}
	}
	

	std::cout<<j<<std::endl;
	return 0;
}

Measured memory_bytes: 256
def func(x,y):
    global s,h,w,seen
    d = [1,-1]
    flag = False
    for i in d:
        if x+i < h and x+i >= 0:
            if s[x+i][y] == "#":
                seen[(x+i)*w+y] = 1
                seen[x*w+y] = 1
                flag = True
        if y+i < w and y+i >= 0:
            if s[x][y+i] == "#":
                seen[x*w+y+i] = 1
                seen[x*w+y] = 1
                flag = True
    return flag


h,w = map(int,input().split())
s = [input() for _ in range(h)]
seen = [0 for _ in range(h*w)]
ans = False
for i in range(h):
    for j in range(w):
        if s[i][j] == "#" and seen[j + i*w] == 0:
            if not func(i,j):
                ans = True
if ans:
    print("No")
else:
    print("Yes")

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

int main()
{
    int n , p , odd = 0 , even = 0;

    cin >> n >> p;

    for(int i = 1 ; i<=n ; i++)
    {
        int x;

        cin >> x;

        if(x%2)
            odd++;
        else
            even++;
    }
    if(p==0 && odd==0)
    {
        cout << (1ll<<even) << endl;
        return 0;
    }
    else if(p==0 && even==0)
    {
        cout << (1ll<<(odd-1));
        return 0;
    }
    else if(p==1 && odd==0)
    {
        cout << "0";
        return 0;
    }
    else if(p==1 && even==0)
    {
        cout << (1ll<<odd);
        return 0;
    }
    else
    {
        cout << (1ll<<even)*(1ll<<(odd-1));
        return 0;
    }
}


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

class D
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var k = h[1];
		var s = Console.ReadLine();

		var tl = new List<int>();
		var tc = '1';
		var tn = 0;
		foreach (var c in s)
		{
			if (c != tc)
			{
				tl.Add(tn);
				tc = c;
				tn = 0;
			}
			tn++;
		}
		tl.Add(tn);
		if (tc == '0') tl.Add(0);

		var c0 = tl.Where((x, i) => i % 2 == 1).ToArray();
		var c1 = tl.Where((x, i) => i % 2 == 0).ToArray();

		int M = c0.Take(k).Sum() + c1.Take(k + 1).Sum(), t = M;
		for (int l = 0, r = k; r < c0.Length; l++, r++)
			M = Math.Max(M, t += c0[r] + c1[r + 1] - c0[l] - c1[l]);
		Console.WriteLine(M);
	}
}


Measured memory_bytes: 14816
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultipleOf9 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String N = in.next();
            int sum = 0;
            for (int i = 0; i < N.length(); i++) {
                sum += (N.charAt(i) - '0');
            }
            if (sum % 9 == 0) out.println("Yes");
            else out.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 33932
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    if(n%2==0) {
        int m=n/2;
        if(str[m-1]!=str[m]) {
            printf("%d\n", m);
        }
        else {
            int ans=m+1;
            int i;
            for(i=1; i<m; i++) {
                if(str[m-1-i]!=str[m]) break;
                if(str[m+i]!=str[m]) break;
                ans++;
            }
            printf("%d\n", ans);
        }
    }
    else {
        int m=n/2;
        {
            int ans=m+1;
            int i;
            for(i=1; i<=m; i++) {
                if(str[m-i]!=str[m]) break;
                if(str[m+i]!=str[m]) break;
                ans++;
            }
            printf("%d\n", ans);
        }
    }

    return 0;
}

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

int main()
{
    string S;
    string T;
    int numar = 0;
    getline(cin, S);
    getline(cin, T);
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            numar += 1;
        }
    }
    cout << numar;
    return 0;
}


Measured memory_bytes: 256
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1

for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Measured memory_bytes: 6720
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 2e5;
ll n, k, A[N], F[N];
bool check(ll a){
  ll kk = k;
  FOR(i, 0, n){
    kk -= (max(0ll, A[i]-a/F[i]));
    if(kk < 0) return false;
  }
  return true;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n) cin >> A[i];
  FOR(i, 0, n) cin >> F[i];
  sort(A, A+n);
  sort(F, F+n, greater<ll>());
  ll ng = -1, ok = 1e12, mid;
  while(ok-ng>1){
    mid = (ok+ng)/2;
    (check(mid) ? ok : ng) = mid;
  }
  cout << ok << endl;
}

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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(auto& i : s) cin >> i;
    int ans = 0;
    for(int i = 0; i < 1 << h; i++){
        bitset<6> bit1 = i;
        for(int j = 0; j < 1 << w; j++){
            bitset<6> bit2 = j;
            int cnt = 0;
            for(int x = 0; x < h; x++) if(bit1[x]){
                for(int y = 0; y < w; y++) if(bit2[y]){
                    if(s[x][y] == '#') cnt++;
                }
            }
            ans += cnt == k;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int N, M; cin >> N >> M;
       vector<long long> X(M);
       for (int i = 0; i < M; ++i) cin >> X[i];
       sort(X.begin(), X.end());
           
       vector<long long> diffs;
       for (int i = 1; i < X.size(); ++i) diffs.push_back(X[i] - X[i-1]);
       sort(diffs.begin(), diffs.end(), greater<long long>());
           
       long long res = X.back() - X[0];
       for (int i = 0; i < min((int)diffs.size(), N-1); ++i) res -= diffs[i];
       cout << res << endl;
}



Measured memory_bytes: 2168
fun main(args: Array<String>) {
        val input = read()
        println(kagamiMochi(input))
    }

    data class Inputs(val count: Int, val diameters: List<Int>)

    fun read(): Inputs {
        val count = Integer.parseInt(readLine()!!)
        val diameters = mutableListOf<Int>()
        (1..count).forEach { diameters.add(Integer.parseInt(readLine()!!)) }
        return Inputs(count, diameters)
    }

    fun kagamiMochi(inputs: Inputs): Int {
        val sorted = inputs.diameters.toSortedSet()

        return sorted.size
    }

Measured memory_bytes: 33536
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int areaLengthA = sc.nextInt();
        int areaLengthB = sc.nextInt();
        int angelAForB  = sc.nextInt();
        
        //三角形の面積
        double triangleArea = 0.500000 * areaLengthA * areaLengthB * Math.sin(Math.toRadians((double) angelAForB));
        //2辺が決まっている状態で残りの辺
        double lastLength = Math.sqrt( Math.pow((double) areaLengthA, 2) + Math.pow((double)areaLengthB, 2) - 2 * areaLengthA * areaLengthB * Math.cos(Math.toRadians((double) angelAForB)));
        //3辺の長さ
        double triangleLength = lastLength + areaLengthA + areaLengthB;
        //三角形の高さ
        double triangleHeight = 2 * triangleArea / areaLengthA;
        
        System.out.println(triangleArea);
        System.out.println(triangleLength);
        System.out.println(triangleHeight);
    }
}


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

const int max_n = 17000;

string s;
int x, y;
int cnt;
int cmd[max_n];
bool dpx[max_n][max_n];
bool dpy[max_n][max_n];

int main(void){
    // Here your code !
    cin >> s;
    scanf("%d %d", &x, &y);

    int n = (1 + max_n) / 2;
    x += n;
    y += n;

    int now = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == 'T') now++;
      else cmd[now]++;
    }

    for (int i = 0; i < max_n; ++i) {
      if (i == n) dpx[0][i] = true;
      else dpx[0][i] = false;
    }

    for (int i = 0; i < max_n; ++i) {
      if (i == n) dpy[1][i] = true;
      else dpy[1][i] = false;
    }

    for (int i = 2; i <= now + 2; ++i) {
      if (i == 2) {
        dpx[i][n + cmd[i - 2]] = true;
        continue;
      }
      for (int j = 0; j < max_n; ++j) {
        if ((i % 2) == 0) {
          dpx[i][j] = dpx[i - 2][j - cmd[i - 2]] || dpx[i - 2][j + cmd[i - 2]];
        }
        else {
          dpy[i][j] = dpy[i - 2][j - cmd[i - 2]] || dpy[i - 2][j + cmd[i - 2]];
        }
      }
    }

    int lx, ly;
    if (now % 2 == 0) {
      lx = now;
      ly = now - 1;
    }
    else {
      lx = now - 1;
      ly = now;
    }

    if (dpx[lx + 2][x] && dpy[ly + 2][y]) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 267776
#include<iostream>
using namespace std;
 int main()
   {
   long int n,s=0,b,c,j=2,i;
     cin>>n;
     long int a[n];
     for(i=0;i<n;i++)
       cin>>a[i];
   long int dp[n];
   dp[0]=0;
   dp[1]=abs(a[0]-a[1]);
     for(i=2;i<n;i++)
     {
       dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
     }
     cout<<dp[n-1];
     return 0;
   }

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

sx, sy, tx, ty = map(int, raw_input().split())
dx = tx - sx
dy = ty - sy

ans = ""
ans += "R"*dx + "U"*dy
ans += "L"*dx + "D"*dy 
ans += "D" + "R"*(dx + 1) + "U"*(dy + 1) + "L"
ans += "U" + "L"*(dx + 1) + "D"*(dy + 1) + "R"
print ans


Measured memory_bytes: 2568
N, K = map(int, input().split())
li = []
for i in range(1, N+1):
    li.append(i)
for i in range(K):
    s1 = input()
    s2 = list(map(int, input().split()))
    for j in s2:
        if j in li:
            li.remove(j)
print(len(li))

Measured memory_bytes: 67600
// nikkei_procon2019_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    
    // calculation
    if (K == 0) {
        cout << A - B << "\n";
    } else if (K == 1) {
        cout << (B+C) - (A+C) << "\n";
    } else {
        if (K%2 == 0) {
            cout << A - B << "\n";
        } else {
            cout << B - A << "\n";
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

LL dp[51][51][2501];
void solve() {
    int n,a;
    cin >> n >> a;
    VI x(n);
    REP(i,0,n) cin >> x[i];

    dp[0][1][x[0]] = 1;
    dp[0][0][0] = 1;
    LL ans = 0;

    REP(i,1,n) {
        dp[i][0][0] = 1;
        REP(j,1,n+1) {
            REP(k,1,a*n+1) {
                dp[i][j][k] = dp[i-1][j][k];
                if (k - x[i] >= 0) dp[i][j][k] += dp[i-1][j-1][k-x[i]];
            }
        }
    }

    REP(i,1,n+1) {
        ans += dp[n-1][i][i*a];
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 49024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string>a(h);
    vector<int>moji(26,0);
    for(int i=0;i<h;i++)cin >> a[i];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            moji[(int)(a[i][j]-'a')]++;
        }
    }
    bool chk;
    int limitOdd = 0;
    int limitEven = 0;
    if(h%2==0 && w%2==0){
    }else if(h%2 == 0){
        limitEven = h/2;
    }else if(w%2==0){
        limitEven = w/2;
    }else{
        limitEven = h/2 + w/2;
        limitOdd = 1;
    }
    // cout << "before"<<endl;
    // cout << limitEven << " "<<limitOdd << endl;

    for(int i=0;i<26;i++){
        if(moji[i]!=0){
            if(moji[i]%2 != 0)limitOdd--;
            else if(moji[i]%4 != 0)limitEven--;
        }
    }
    if(limitOdd >=0 && limitEven >= 0 && limitEven%2==0)chk = true;
    else chk = false;


    // cout << "after"<<endl;
    // cout << limitEven << " "<<limitOdd << endl;

    if(chk)cout<<"Yes"<<endl;
    else cout << "No"<<endl;


    // for(int i=0;i<26;i++){
    //     cout << (char)('a'+i )<< ":" << moji[i]<<endl;
    // }
}


Measured memory_bytes: 256