akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		
		PrimeNumberGenerator pg = new PrimeNumberGenerator();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			int n = Integer.parseInt(str);
			
			int smallPrime = 2;
			int bigPrime = Integer.MAX_VALUE;
			
			//?°??????????
			for(int i = n - 1; i >= 2 ; i--){
				if(pg.isPrime(i)){
					smallPrime = i;
					break;
				}
			}
			
			//??§?????????
			for(int i = n + 1; i <= Integer.MAX_VALUE ; i++){
				if(pg.isPrime(i)){
					bigPrime = i;
					break;
				}
			}
			
			System.out.println(smallPrime+" "+bigPrime);
		}
	}

}

class PrimeNumberGenerator {
    private boolean[] isPrime= new boolean[100000001];
 
    public PrimeNumberGenerator() {
        //Date from = new Date();
        Arrays.fill(isPrime, true);
 
        isPrime[0] = false;
        isPrime[1] = false;
        isPrime[2] = true;
 
        for(int i = 3; i <= Math.sqrt( isPrime.length ); i+=2){
            /*
            if(i % 2 == 0){
                isPrime[i] = false;
                continue;
            }
            */
 
            if(isPrime[i] == false){
                continue;
            }
 
            for(int j = i * 2; j <= isPrime.length - 1; j += i){
                isPrime[j] = false;
            }
        }
        //Date to = new Date();
        //System.out.println("init takes "+ (to.getTime() - from.getTime())+ "milli sec");
    }
 
    public boolean isPrime(int index){
        if(index % 2 == 0 && index != 2){
            return false;
        }
        return isPrime[index];
    }
}

Measured memory_bytes: 122880
#include<iostream>
using namespace std;
int main()
{
    int n1,n2,ans=-1,a,b;
    cin>>n1>>n2;
    for(int i =0;i<1001;i++)
    {
        a=i*0.08;
        b=i*0.1;
        if(n1==a&&n2==b)
        {
            ans=i;
            break;
        }

    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    vector<vector<ll>> c(3, vector<ll>(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    for (int a1 = 0; a1 <= 100; a1++) {
        ll b1 = c[0][0] - a1;
        ll b2 = c[0][1] - a1;
        ll b3 = c[0][2] - a1;
        ll a2 = c[1][0] - b1;
        ll a3 = c[2][0] - b1;

        if (a2 + b2 == c[1][1] && a2 + b3 == c[1][2] && a3 + b2 == c[2][1] &&
            a3 + b3 == c[2][2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int min_value = INT_MAX;
    for (int i = v[0]; i <= v[n - 1]; ++i) {
        int temp = 0;
        for (int j = 0; j < n; ++j) {
            temp += ((v[j] - i) * (v[j] - i));
        }
        min_value = min(temp, min_value);
    }
    cout << min_value << endl;

    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <queue>

uint32_t makeV(int l, int r)
{
    if (l > r)
        std::swap(l, r);
    return uint32_t(l) | (uint32_t(r) << 12);
}

std::unordered_map<uint32_t, std::vector<uint32_t>> G;
int n;
void addEdge(uint32_t a, uint32_t b)
{
    G[b];
    G[a].push_back(b);
}

int BFS()
{
    int t = 0;
    std::unordered_map<uint32_t, int> L;
    std::queue<uint32_t> q[2];
    std::unordered_set<uint32_t> V;
    for (const auto& it : G)
    {
        L[it.first] += 0;
        for (uint32_t w : it.second) ++L[w];
    }
    for (const auto& it : L)
    {
        if (it.second == 0)
        {
            V.insert(it.first);
            q[1].push(it.first);
        }
    }
    while (!q[1].empty() || !q[0].empty())
    {
        if (q[0].empty() && !q[1].empty())
        {
            ++t;
            std::swap(q[0], q[1]);
            continue;
        }
        uint32_t v = q[0].front();
        q[0].pop();
        for (uint32_t w : G[v])
        {
            --L[w];
            if (L[w] == 0 && V.count(w) == 0)
            {
                V.insert(w);
                q[1].push(w);
            }
        }
    }
    if (V.size() == G.size()) return t;
    else return -1;
}

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        uint32_t prev = 0;
        for (int j = 1; j < n; ++j)
        {
            int k;
            std::cin >> k;
            uint32_t next = makeV(i, k);
            if (prev) addEdge(prev, next);
            prev = next;
        }
    }
    std::cout << BFS() << std::endl;
    return 0;
}


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

public class Solution
{
    public static void Main()
    {
        var x = int.Parse(Console.ReadLine());
        var set = new SortedSet<int>();
        set.Add(0);
        while (set.Count > 0)
        {
            var cur = set.First();
            set.Remove(cur);
            for (int next = cur + 100; next <= cur + 105; next++)
            {
                if (next < x)
                {
                    set.Add(next);
                }
                else if (next == x)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
        }

        Console.WriteLine("0");
    }
}

Measured memory_bytes: 15560
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int h[N], f[N];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> h[i];
	f[0] = 0;
	f[1] = abs(h[0] - h[1]);
	for(int i = 2; i < n; i++){
		f[i] = min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	}
	cout << f[n-1];
}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define MOD 1000000007
vector<int> memo(100001, -1);





int main()
{

	ll n, m;
	cin >> n >> m;

	char input[n][m];

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> input[i][j];
		}
	}

	ll dp[n][m];
	dp[0][0] = 1;
	for (int i = 1; i < m; i++)
	{
		if (input[0][i] == '#')
			dp[0][i] = 0;
		else
			dp[0][i] = dp[0][i - 1];
	}

	for (int i = 1; i < n; i++)
	{
		if (input[i][0] == '#')
			dp[i][0] = 0;
		else
			dp[i][0] = dp[i - 1][0];
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j < m; j++)
		{
			if (input[i][j] == '#')
			{
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] = ((dp[i - 1][j] % MOD) + (dp[i][j - 1] % MOD)) % MOD;
		}
	}

	cout << dp[n - 1][m - 1] << endl;
}













Measured memory_bytes: 9472
#include <stdio.h>

int main(void) {
	int a, b, c, i, r, count = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(i = a; i <= b; i++){
		r = c % i;
		if(r == 0){
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}



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

int main(){
  int n;
  int a=1;
  cin >> n;
  if(n==1){
    cout << 1 << endl;
  }else if(n<4){
    cout << 2 << endl;
  }else if(n<8){
    cout << 4 << endl;
  }else if(n<16){
    cout << 8 << endl;
  }else if(n<32){
    cout << 16 << endl;
  }else if(n<64){
    cout << 32 << endl;
  }else if(n<101){
    cout << 64 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
struct edge{int t,ne;}e[N];
int head[N],cnt,n,bad;
void adde(int a,int b){
	e[++cnt]=(edge){b,head[a]};head[a]=cnt;
}
int dfs(int x,int f){
	int c=0;
	run(x)if(v!=f)if(!dfs(v,x))c++;
	if(c<=1)return c;
	bad=1;
}
int main(){
	read(n);
	re(i,1,n){
		int a,b;read(a,b);
		adde(a,b);adde(b,a);
	}
	if(!dfs(1,0))bad=1;
	if(bad)printf("First");else printf("Second");
}

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    
    if(A+B==C+D){
        cout << "Balanced" << endl;
    }else if(A+B>C+D){
        cout << "Left" << endl;
    }else{
        cout << "Right" << endl;
    }
    
    return 0;
}




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

int main(){
    ll n,k;
    cin>>n>>k;
    V h(n);
    rep(i,n)cin>>h[i];
    V ans(n,1e9);
    ans[0]=0;
    rep(i,n){
        rep(j,k){
            if(i+j+1<n)ans[i+j+1]=min(ans[i+j+1],ans[i]+abs(h[i]-h[i+j+1]));
        }
    }
    cout<<ans[n-1]<<endl;
}


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

#define   ll     long long int

const int N = 200005;
ll ara[N];

int main( )
{
    ll s = 0, i, j, k, t, n;
    cin >> n >> t;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
    }
    s += t;
    for (i = 2; i <= n; i++) {
        if (ara[i - 1] + t < ara[i]) {
            s += t;
        }
        else {
            s += (ara[i] - ara[i - 1]);
        }
    }
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int s;
    cin >> s;

    map<int, int> mp;
    mp[s] = 1;

    FOR(i, 0, inf){
        if(s%2==0){
            s /= 2;
        }else{
            s = 3*s + 1;
        }
        if(mp[s]==1){
            // hit
            p(i+2);
            return 0;
        }else{
            mp[s] = 1;
        }
    }

    return 0;
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define SUM(a) accumulate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n; cin >> n;
  int a;
  int c1 = 0,c2 = 0,c4 = 0;
  rep(i,n){
    cin >> a;
    if(a%2 == 0){
      if(a%4 == 0) c4++;
      else c2++;
    }else c1++;
  }
  bool ans;
  if(c2 == 0){
    if(c1 <= c4 + 1) ans = true;
    else ans = false;
  }else{
    if(c1 <= c4) ans = true;
    else ans = false;
  }
  if(ans) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		String ns = s.nextLine();	
		
		String str = s.nextLine();
		
//		int n = Integer.parseInt(ns);
		
		char arr[] = str.toCharArray();

		int count = 1;
		for(int i = 0; i < arr.length; i++) {
			if(i == 0) {
				continue;
			}
			if(arr[i] != arr[i-1]) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 27860
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

int main()
{
  long long n, a, b;
  cin >> n >> a >> b;
  long long q = n / (a + b);
  long long r = n % (a + b);
  cout << q * a + min(r, a) << endl;
  return 0;
}


Measured memory_bytes: 256
x=require('fs').readFileSync('/dev/stdin','utf8').split(/\s/);
i=0;
for(;i<x.length-2;){
if(x[i++]<x[i++]){
    tmp = x[i-2];
    x[i-2] = x[i-1];
    x[i-1] = tmp;
  }
l=x[i-2]*x[i-1];
r = x[i-2] % x[i-1];
  while(r!==0){
    x[i-2] = x[i-1];
    x[i-1] = r;
    r = x[i-2] % x[i-1];
  }
console.log(x[i-1], l/x[i-1]);
}

Measured memory_bytes: 15448
#include<bits/stdc++.h>
using namespace std;
string a,b;
int n;
int at()
{
	if(a.size()>b.size())
	{
		return 0;
	}
	if(a.size()<b.size())
	{
		return 1;
	}
	for(int s=0;s<a.size();s++)
	{
		if(a[s]>b[s])
		{
			return 0;
		}
		if(a[s]<b[s])
		{
			return 1;
		}
	}
	return 2;
}
int main()
{
	cin>>a>>b;
	n=at();
	if(n==0)
	 cout<<"GREATER"<<endl;
	  else
	   if(n==1)
	    cout<<"LESS"<<endl;
	     else
	      cout<<"EQUAL"<<endl;
	   
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

void solve() {
    vector<int> a(5);
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int minval = 643+1;
    do{
        int current = 0;
        for(int i = 0; i < 4; i++){
            current += a[i] + (a[i]%10 == 0?0:10 - (a[i] % 10));
        }
        current += a[4];
        minval = min(minval, current);
    } while(next_permutation(a.begin(), a.end()));
    cout << minval << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z>>w;
int a[x][y];
  rep(i,x){
    Rep(j,y){
            a[i][j]=0;
       if (i<w ^ j<z) a[i][j]=1;
    }
  }

rep(i,x){
  Rep(j,y){
    std::cout << a[i][j];
  }
  std::cout  << '\n';
}
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=200000;
const int inf=1e9;
const ll mod=1e9+7;

int a[3][3];

int main()
{
    FasterIO;

    int tc, cs=1;

    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++) cin>>a[i][j];
    }
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        int x; cin>>x;
        for(int j=0; j<3; j++)
        {
            for(int k=0; k<3; k++)
            {
                if(a[j][k]==x) a[j][k]=-1;
            }
        }
    }
    bool flg=0;
    for(int i=0; i<3; i++)
    {
        int c=0, c1=0;
        for(int j=0; j<3; j++)
        {
            c+=a[i][j]; c1+=a[j][i];
        }
        if(c==-3 || c1==-3 || a[0][0]+a[1][1]+a[2][2]==-3 || a[2][0]+a[1][1]+a[0][2]==-3)
        {
            cout<<"Yes"<<endl; return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    for(int i = 0; i<n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);
    sum += a[n-1];
    int x = n-2;
    int times = 0;
    int curr = n-2;
    for(int i = 1; i<=x; i++) {
        sum += a[curr];
        times ++;
        if(times == 2) {
            times = 0;
            curr --;
        }
    }
    cout << sum << '\n';
}

int main() {_
    int t = 1;
    //cin >> t;
    //Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Set;
import java.util.HashMap;

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

    static class GoodSequence {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<Long, Long> map = new HashMap<>();
            for (int i = 0; i < n; i++) {
                long a = Long.parseLong(in.next());
                map.put(a, map.getOrDefault(a, 0L) + 1);
            }

            long result = 0;
            Set<Long> keys = map.keySet();
            for (Long key : keys) {
                Long v = map.get(key);
                if (key < v) {
                    result += Math.min(v, v - key);
                } else if (v < key) {
                    result += v;
                }
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 63972
#include <iostream>
#include <vector>

using namespace std;

vector<int> ans;
int a[55];
int b[55];
int c[55];
int d[55];
int n, m, q;
int aa;

void so(int num, int nn)
{
    if (nn == n)
    {

               int res = 0;
        for (int i = 0; i < q; i++)
        {
            if (b[i] >= n)
                continue;
            if (ans[b[i]] - ans[a[i]] == c[i])
                res += d[i];
        }
        aa = max(aa, res);
        return;
    }

    for (int i = num; i <= m; i++)
    {
        ans.push_back(i);
        so(i, nn + 1);
        ans.pop_back();
    }
    return;
}

int main()
{

    cin >> n >> m >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    so(1, 0);

    cout << aa << endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int a, b, c;

int main()
{
	while(~scanf("%d%d", &a, &b))
	{
		c = b + ( b - a);
		printf("%d", c);
	}
	return 0;
}	

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

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    double max = W * H / 2;

    if (x == W / 2 && y == H / 2) {
        printf("%f 1\n", max);
    } else {
        printf("%f 0\n", max);
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

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

vector<bool> eratosthenes(int n) {
	vector<bool> prime(n + 1);
	for (int i = 2; i <= n; i++) {
		prime[i] = true; // 初期化
	}
	prime[0] = prime[1] = false;
	for (int i = 2; i*i <= n;i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= n; j += i) {
				prime[j] = false;
			}
		}
	}
	return prime;
}
int n, m,p[10], ans = 0,a[29], b[29];
const int nmax = 8;
bool graph[nmax][nmax];
/**
 * pos個は決定済み
 * mask 残に置く数の集合を表すビット配列
 */
void dfs(int pos, int mask) {
//	cout << "pos=" << pos << ",mask=" << mask << endl;
	if (pos == n) { // posが最後までいった
//		cout << p[0] << p[1] << p[2] << endl;
		return;
	}
	REP(i, n) {
		if (mask  & (1 << i)) { // 残の中にiが残っている場合
//			cout << "mask=" << mask << ",1<<" << i << "="  << (1 << i) << "=true" << endl;
			p[pos] = i; // 配列のPOS位置を0～nまでループ
			if (p[0] != 0)continue;
			if (pos > 0 && graph[p[pos - 1]][p[pos]] == false) {
				//				cout << "pos=" << pos << "," << p[0] << p[1] << p[2] << ",graph[" << p[pos - 1] << "][" << p[pos] << "]=false" << endl;
				continue;
			}
			dfs(pos + 1, (mask ^ (1 << i))); // 配列のPOS位置を進める,排他的論理和でフラグを下ろす
		}
		else {
//			cout << "mask=" << mask << ",1<<" << i << "=" << (1 << i) << "=false" << endl;
		}
	}
}
/*int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	scanf("%d %d", &n ,&m);

	REP(i, m) {
		scanf("%d %d",&a[i], &b[i]);
		p[i] = i;
		graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = true;
	}

	dfs(0, (1 << n) - 1);
	cout << ans << endl;
	return 0;
}*/
/**
 * v 現在の頂点
 */
int dfs(int v, int n, bool visited[]) {
	bool all_visited = true; // 全頂点を訪問済
	REP(i, n) {
		if(!visited[i])all_visited = false;
	}
	if (all_visited)return 1; //答を1増やす
	int ret = 0;
	REP(i, n) { //頂点i:頂点vに隣接、且つ、未訪問
		if (!graph[v][i])continue;
		if(visited[i])continue;

		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}
int main() {
	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; ++i) {
		int A, B;
		cin >> A >> B;
		graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
	}
	
	bool visited[nmax];
	for (int i = 0; i < n; ++i) {
		visited[i] = false;
	}
	
	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const long long llinf=1e18;
const int A=100005,B=200005,C=305,D=105,E=1005,F=3005;
long long n,a[F],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],ans+=a[i]-1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

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

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string s;
    cin >> s;
    string bk = "";
    int n = int(s.size());
    int ans = 0;
    int l = 0;
    while (l < n) {
        string nx;
        nx += s[l];
        l++;
        while (l < n && bk == nx) {
            nx += s[l];
            l++;
        }
        if (nx == bk) break;
        ans++;
        bk = nx;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;
 
int main(){
    i64 n, sum = 0; cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    if(sum % (n * (n + 1) / 2)) {
        cout << "NO" << endl;
        return 0;
    }
    sum /= n * (n + 1) / 2;

    for(int i = 0; i < n; i++) {
        i64 d = a[(i + 1) % n] - a[i] - sum;
        if(d % n or d > 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define Chkmin(a,b) a=a<b?a:b
using namespace std;
template<typename T>inline void read(T &x)
{
    T s=0,f=1;char k=getchar();
    while(!isdigit(k)&&(k^'-'))k=getchar();
    if(!isdigit(k)){f=-1;k=getchar();}
    while(isdigit(k)){s=s*10+(k^48);k=getchar();}
    x=s*f;
}
const int MAXN=2e5+7;

static int n,a[MAXN];

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]);
}

static long long ans; 

static int got[MAXN],bit[23];

inline void solve()
{
	Rep(i,0,20)bit[i]=n+1;
	got[n+1]=n+1;
	Repe(i,n,1)
	{
		got[i]=n;
		Rep(j,0,19)if(a[i]&(1<<j))
		{
			Chkmin(got[i],bit[j]-1);
			bit[j]=i;
		}
		Chkmin(got[i],got[i+1]);
		ans+=got[i]-i+1;
	}
	printf("%lld\n",ans);
}
int main()
{
    init();
    solve();
    return 0;
}


Measured memory_bytes: 1792
import sys
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]

for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1

ans = 'Yes'
for j in range(n-1):
    if h[j] < h[j+1]:
        print('No')
        sys.exit()

print(ans)

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> b(n+1);
    rep(i, m) {
        int a;
        cin >> a;
        b[a] = true;
    }
    vi c(n+2);
    const int mod = 1e9 + 7;
    c[n+1] = 0, c[n] = 1;
    repr(i, n) {
        if (b[i]) continue;
        c[i] = (c[i+1] + c[i+2]) % mod;
    }
    cout << c[0] << endl;
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}



ll h[334],dp[334][334];

int main(void){
	int n,k,i,j,t;
	ll ans = INFLL;
	fill(dp[0],dp[334],INFLL);
	cin >> n >> k; k = n-k;
	for(i=1; i<=n; ++i){
		cin >> h[i];
	}
	dp[0][0] = 0ll;
	for(i=0; i<n; ++i){
		for(j=0; j<=i; ++j){
			for(t=0; t<n; ++t){
				dp[i+1][t+1] = min(dp[i+1][t+1],dp[j][t]+max(h[i+1]-h[j],0ll));
			}
		}
	}
	for(i=0; i<=n; ++i){
		for(t=k; t<=n; ++t){
			ans = min(ans,dp[i][t]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1152
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

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

typedef long long ll;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define PR(x) cout<<#x<<" : "<<x<<"\n";
#define PR1(x,y) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"  |  "<<#z<<" : "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              emplace_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001

const int N=5e6+99;



int main() 
{
    
    // #ifndef ONLINE_JUDGE
    // FILEIO
    // #endif


    int n;
    cin>>n;
    cout<<pow(n,3)<<endl;



   




}
    

    





 
    
     

Measured memory_bytes: 256
def resolve():
    import math
    a,b,h,m=map(int,input().split())
    A=30*(h+m/60)
    B=m*6
    dif=abs(A-B)
    if dif>=180:
        dif=360-dif
    print((((b-a*math.cos(math.radians(dif))))**2+(a*math.sin(math.radians(dif)))**2)**(1/2))

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9584
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

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

	int a, b, c;
	cin >> a >> b >> c;
	if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>

#define MN 200000

using namespace std;

int main(){
  int N;
  long sunuke = 0, arai = 0;
  int l[MN];
  long mind = 1e+15;
  cin >> N;
  for( int i = 0; i < N; i++ ){
	cin >> l[i];
	arai += l[i];
  }
  for( int i = 0; i < N-1; i++ ){
	sunuke += l[i];
	arai -= l[i];
	long tmp = labs(sunuke-arai);
	//cout << sunuke << "," << arai << "," << tmp << endl;
	if( tmp < mind ){
	  mind = tmp;
	}
  }
  cout << mind << endl;
  return 0;
}

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

int main() {
	int q;
	cin >> q;
	deque<int> v;

	for (int i = 0; i < q; i++) {
		int c; cin >> c;
		if (c == 0) {
			int d,x;
			cin >> d >> x;
			if(d==0) v.push_front(x);
			else v.push_back(x);
		}
		else if (c == 1) {
			int p;
			cin >> p;
			cout << v[p] << endl;
		}
		else {
			int d; cin >> d;
			if(d==0) v.pop_front();
			else v.pop_back();
		}
	}

}
	



Measured memory_bytes: 4648
N,T = map(int,input().split())
m = 9999
d = 0
for i in range(N):
    c,t = map(int,input().split())
    if t <= T:
        m = min(m,c)
    elif t > T:
        d += 1

if d == N:
    print("TLE")
else:
    print(m)



Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> p(a),q(b),r(c);
    REP(i, a) cin >> p[i];
    REP(i, b) cin >> q[i];
    REP(i, c) cin >> r[i];

    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());
    sort(r.begin(),r.end(),greater<int>());

    p.erase(p.begin() + x, p.end());
    q.erase(q.begin() + y, q.end());

    vector<int> ans;
    for(int i=0;i<p.size();i++) ans.push_back(p[i]);
    for(int i=0;i<q.size();i++) ans.push_back(q[i]);
    for(int i=0;i<r.size();i++) ans.push_back(r[i]);
    sort(ans.begin(),ans.end(),greater<int>());

    ll sum = 0;
    for(int i=0;i<x+y;i++) sum += ans[i];

    cout<<sum<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n,k;
cin >> n >> k;
vi h(n);
vi dp(n,P);
rep(i,n)cin >> h[i];
dp[0] = 0;
for(int i=1;i<n;++i){
    for(int j=1;j<=k&&i-j>=0;++j){
        chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
}
fin(dp[n-1]);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cstring>

using namespace std;

int main()
{
	int a[6] = { 0, };

	for (int i = 0; i < 5; i++)
	{
		int input;

		scanf("%d", &input);

		a[input] = 1;
	}

	for (int i = 1; i <= 5; i++)
	{
		if (!a[i])
		{
			printf("%d\n", i);

			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
const ll MOD=998244353;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

struct UnionFindTree{
    vector<int> par,rank;
    UnionFindTree(int n):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res*=a;
        a*=a;
        x>>=1;
    }
    return res;
}

int popcount(int x){
    int res=0;
    while(x>0){
        if(x&1) res++;
        x>>=1;
    }
    return res;
}

ll f(ll x){
    ll res=0;
    while(x>0){
        res+=x%10;
        x/=10;
    }
    return res;
}

int main(){
    int A,B,C,D;cin>>A>>B>>C>>D;
    ll DP[C+1][D+1][2];
    for(int i=0;i<=C;i++){
        for(int j=0;j<=D;j++){
            for(int k=0;k<2;k++){
                DP[i][j][k]=0;
            }
        }
    }
    DP[A][B][0]=1;
    for(int i=A+1;i<=C;i++){
        DP[i][B][0]=DP[i-1][B][0]*B%MOD;
    }
    for(int j=B+1;j<=D;j++){
        DP[A][j][0]=DP[A][j-1][0]*A%MOD;
    }
    for(int i=A+1;i<=C;i++){
        for(int j=B+1;j<=D;j++){
            DP[i][j][0]=(DP[i-1][j][0]+DP[i-1][j][1])*j%MOD;
            DP[i][j][1]=(DP[i][j-1][0]+DP[i][j-1][1]*i)%MOD;
        }
    }
    ll ans=(DP[C][D][0]+DP[C][D][1])%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 144236
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define PI 3.14159265
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 300000000000000001
#define infx 9223372036854775806
#define all(c) c.begin(),c.end()
#define mk(x,yy) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
// #define endl "\n"
#define max2(x,y)           (x>y)?x:y
#define min2(x,y)           (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define ene cout<<"\n";

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll power(ll x,  ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
bool compr(std::vector<ll> a, std::vector<ll> b)
{
    if(a[0]==b[0])
        return a[1]<b[1];
    else
        return a[0]<b[0];
}

bool comp(std::vector<ll> a, std::vector<ll> b)
{
    if(a[1]==b[1]&&a[2]==b[2])
        return a[0]<b[0];
    else if(a[1]==b[1])
        return a[2]>b[2];
    else
        return a[1]<b[1];
}

int main()
{
    #ifdef SHIVANSH 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n][3];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    ll dp[n][3];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(ll i=1;i<n;i++)
    {
        dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][1],dp[i-1][0]); 
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

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

int main() {

	int N;
	cin >> N;

	vector<int>cards;

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

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

	int score = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 1) {
			score -= cards[i];
		}
		else {
			score += cards[i];
		}
	}

	cout << score << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=11e2+10;
char s[N];
const double pi=acos(-1);
void solve()
{
   double a,b;
   int h,m;
   cin>>a>>b>>h>>m;
   double jiao1=m*6,jiao2=h*30+m*0.5;

   double jiao3=abs(jiao1-jiao2);
   jiao3=jiao3*pi/180;
   double c=sqrt(a*a+b*b-a*b*2*cos(jiao3));
   printf("%.9f\n",c);

}
int main()
{
	//ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//int _;cin>>_;while(_--)
	solve();
}


Measured memory_bytes: 4224
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$Q = intval(fgets(STDIN));

$seg = new SegTree($n);
function op($a, $b){return $a | $b;}

for($i = 0; $i < $n; $i++){
  $seg->set($i, 1<<(ord($str[$i])-97));
}
while($Q--){
  list($q, $a, $b) = explode(" ", trim(fgets(STDIN)));
  if($q == "1"){
    $seg->set($a-1, 1<<(ord($b)-97));
  }else{
    $ret[] = popcount($seg->get($a-1, $b));
  }
}
echo implode("\n", $ret);


class SegTree{
  public $tree;
  public $bits;
  function __construct($n){
    $this->bits = max(1, ceil(log($n)/log(2)));
    for($i = 0; $i < $this->bits; ++$i){
      $this->tree[$i] = array_fill(0, 2**($this->bits-$i), 0);
    }
  }
  function set($i, $amount){
    $this->tree[0][$i] = $amount;
    for($j = 1, $J = $this->bits; $j < $J; ++$j){
      $this->tree[$j][$i>>$j] = $this->tree[$j-1][$i>>$j<<1] | $this->tree[$j-1][($i>>$j<<1) + 1];
    }
  }
  function get($f, $t){
    $sum = 0;
    $tree = $this->tree;
    for($i = 0; $i < $this->bits ; ++$i){
      $treei = $tree[$i];
      if(($f >> $i) & 1){
        $sum |= $treei[$f>>$i];
        $f+=1<<$i;
      }
      if(($t >> $i) & 1){
        $sum |= $treei[($t>>$i)-1];
        $t-=1<<$i;
      }
      if($f==$t)break;
    }
    return $sum;
  }
}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 39544
using System;

namespace AtcoderProblem
{
    class Program
    {

        static void Main(string[] args)
        {
            var Str = Console.ReadLine();
            /*var line = Console.ReadLine();
            var stArrayData = line.Split(' ');
            var S1 = long.Parse(stArrayData[0]);
            var S2 = long.Parse(stArrayData[1]);
            var S3 = long.Parse(stArrayData[2]);*/

            if (Str == "RSS" || Str == "SRS" || Str == "SSR" || Str == "RSR") Console.WriteLine("1");
            else if (Str == "RRS" || Str == "SRR") Console.WriteLine("2");
            else if (Str == "RRR") Console.WriteLine(3);
            else Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 25840