akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	int h, w;
	int n;
	vi a;
public:
	D()
	{
		cin >> h >> w >> n;

		a.reserve(h * w);

		REP1C(col, n)
		{
			int tmp;
			cin >> tmp;

			REP(i, tmp)
				a.PB(col);
		}
	}
	void solve()
	{
		vvi res(h, vi(w));

		REP(i, h)
		{
			if (!(i & 1))
			{
				REP(j, w)
				{
					res[i][j] = a.back();
					a.pop_back();
				}

			}

			else
			{
				RREP(j, w)
				{
					res[i][j] = a.back();
					a.pop_back();
				}
			}
		}

		REP(i, h)
		{
			REP(j, w)
				cout << res[i][j] << " ";
			cout << endl;
		}

	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

#define DO(x, y) ((x) / (y))
long long  gcd(long long  a, long long b);

int main(){
        long long a, b, c, d;
        cin >> a >> b >> c >> d;
        long long anc_c = DO(b, c) - DO(a-1, c);
        long long anc_d = DO(b, d) - DO(a-1, d);
        long long gcd_v = gcd(c, d);
        long long anc_cd = DO(b, c*d/gcd_v) - DO(a-1, c*d/gcd_v);

        //cout << anc_c << " " << anc_d << " " << anc_cd << endl;
        cout << b - a + 1 - anc_c - anc_d + anc_cd << endl;
}

long long  gcd(long long  a, long long b)
{
        if ( a < b) return gcd(b, a);
        if(a % b == 0) return b;
        return gcd(b, a%b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct T
{
    int x,y;
}a[100010];
typedef long long ll;
bool cmp(T a,T b)
{
    return a.x<b.x;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>a[i].x>>a[i].y;
    sort(a,a+n,cmp);
    ll sum=0,num=0,flag=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<a[i].y;j++)
        {
            num++;
            sum+=a[i].x;
            if(num==m)
            {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char a[110],b[110];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();
	scanf("%s%s",a+1,b+1);
	for(int i=1;i<=n;i++)printf("%c",a[i]),printf("%c",b[i]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    vector<int> vec(n);
    bitset<32> bit;
    rep(i,n){
        in(vec[i]);
        bitset<32> a(vec[i]);
        bit=(bit^a);
    }
    bitset<32> bit2;
    vector<int> vec2(n);
    rep(i,n){
        bitset<32> a(vec[i]);
        bit2=(bit^a);
        vec2[i]=bit2.to_ullong();
    }
    out(vec2);
}

Measured memory_bytes: 4872
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230781640628
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double w1=1.0/120,w2=1.0/10;
    int t=h*60*60+m*60;
    double x=w1*t,y=w2*t;
    double ang=abs(x-y);
    double ans=sqrt(a*a+b*b-2*a*b*cos(pi*ang/180));
    printf("%0.10lf",ans);
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 2e5 + 10;

int n;

VI A[N], B[N];

int fa[N], in[N], out[N], dep[N], dfs_clock;

void dfsB(int u)
{
	in[u] = ++dfs_clock;
	for (auto v : B[u])
	{
		if (v == fa[u]) continue;
		fa[v] = u;
		dep[v] = dep[u] + 1;
		dfsB(v);
	}
	out[u] = dfs_clock;
}

bool check(int u, int v)
{
	if (in[u] <= in[v] && in[v] <= out[u])
	{
		if (fa[v] == u) return 1;
		if (fa[fa[v]] == u) return 1;
		return 0;
 	}
 	if (in[v] <= in[u] && in[u] <= out[v])
	{
		if (fa[u] == v) return 1;
		if (fa[fa[u]] == v) return 1;
		return 0;
 	}
 	if (fa[u] == fa[v]) return 1;
 	return 0;
}

bool vis[N];

int d[N];

void bfsA(int s)
{
	static int q[N]; int l = 0, r = 0;
	q[r++] = s; vis[s] = 1;
	while (l < r)
	{
		int u = q[l++];
		for (auto v : A[u])
		{
			if (vis[v]) continue;
			d[v] = d[u] + 1;
			if (d[v] < dep[v] && !vis[v])
			{
				vis[v] = 1;
				q[r++] = v;
			}
		}
	}
}

int rootA, rootB;

bool win[N];

int main()
{
	giii(n, rootA, rootB);
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		A[u].pb(v);
		A[v].pb(u);
	}
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		B[u].pb(v);
		B[v].pb(u);
	}
	dfsB(rootB);
	for (int i = 1; i <= n; ++i)
	{
		for (auto j : A[i])
			if (!check(i, j)) win[i] = win[j] = 1;
	}
	bfsA(rootA);
	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (vis[i] && win[i]) 
		{
			puts("-1");
			return 0;
		}
		if (vis[i]) ans = max(ans, dep[i] * 2);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 35708
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100001],b[100001],d[100001],num[100001],ans[100001],ori=-1;
vector<int> g[100001];
int visit(int p)
{
	if(d[p]!=-1) return d[p];
	d[p]=0;
	for(int i=0;i<g[p].size();i++)
	 d[p]=max(d[p],visit(g[p][i])+1);
	return d[p];
}
void visit2(int p,int rt)
{
	if(ans[p]!=-1) return;
	ans[p]=rt+1;
	vector<pair<int,int> > ch;
	for(int i=0;i<g[p].size();i++)
	 ch.push_back({d[g[p][i]],g[p][i]});
	sort(ch.begin(),ch.end());
	reverse(ch.begin(),ch.end());
	for(int i=0;i<ch.size();i++)
	 visit2(ch[i].second,p);
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n-1+m;i++)
	{
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
	}
	for(int i=0;i<n-1+m;i++)
	{
		g[a[i]].push_back(b[i]);
		num[b[i]]++;
	}
	for(int i=0;i<n;i++)
	 if(num[i]==0) ori=i;
	for(int i=0;i<n;i++)
	d[i]=ans[i]=-1;
	visit(ori);
	visit2(ori,-1);
	for(int i=0;i<n;i++)
	 cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
using M = map<ll, ll>;
ll INF = 100100100100100;
ll MONEY = 1e15;

vector<ll> dijkstra(ll start, vector<P> *G, ll n) {
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(P(0, start));

  vector<ll> dist(n);
  rep(i, n) dist[i] = INF;
  dist[start] =  0;

  while (! pq.empty()) {
    ll pos = pq.top().second;
    pq.pop();

    rep(i, int(G[pos].size())) {
      ll cost = G[pos][i].second;
      ll to = G[pos][i].first;

      if (dist[to] > dist[pos] + cost) {
        dist[to] = dist[pos] + cost;
        pq.push(P(dist[to], to));
      }
    }
  }

  return dist;
}

int main() {
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  s--; t--;

  vector<P> G_s[n];
  vector<P> G_t[n];

  rep(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    G_s[u].push_back(P(v, a));
    G_s[v].push_back(P(u, a));
    G_t[u].push_back(P(v, b));
    G_t[v].push_back(P(u, b));
  }

  vector <ll> dist_s = dijkstra(s, G_s, n);
  vector <ll> dist_t = dijkstra(t, G_t, n);

  vector<ll> dist(n);
  rep(i, n) {
    dist[i] = dist_s[i] + dist_t[i];
  }

  vector<ll> ans(n);
  ans[n-1] = dist[n-1];

  rep(i, n-1) {
    ans[n-2-i] = min(dist[n-2-i], ans[n-1-i]);
  }

  rep(i, n) {
    cout << MONEY - ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 19780
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn=55;
int n,m,vis[maxn];
bool g[maxn][maxn];
struct nod{
	int x,y;
}node[1300];
void dfs(int star){
	vis[star]=1;
	int i;
	for(i=1;i<=n;i++){
		if(vis[i]==0&&g[star][i]==1){
			dfs(i);
		}
	}
	return ;
}
int main(){
	int i,j;
	while(scanf("%d%d",&n,&m)!=EOF){
		int ans=0;
		memset(g,0,sizeof(g));
		for(i=0;i<m;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			node[i].x=x;
			node[i].y=y;
			g[x][y]=g[y][x]=1;
		}
		for(i=0;i<m;i++){
			memset(vis,0,sizeof(vis));
			g[node[i].x][node[i].y]=g[node[i].y][node[i].x]=0;
			dfs(1);
			g[node[i].x][node[i].y]=g[node[i].y][node[i].x]=1;
			bool bridge=false;
			for(j=1;j<=n;j++){
				if(!vis[j])
					bridge=true;
			}
			if(bridge)
				ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int d[5][16] = {0};


int main(){
    int n;
    scanf("%d", &n);
    int i;
    getchar();
    for(i = 0; i < n; i++){
        char c, c1;
        int a;
        scanf("%c", &c);
        getchar();
        scanf("%d", &a);
        getchar();
        // printf("%c %d\n", c, a);
        if(c == 'S') d[0][a - 1] = 1;
        else if(c == 'H') d[1][a - 1] = 1;
        else if(c == 'C') d[2][a - 1] = 1;
        else d[3][a - 1] = 1;
    }
    int j;
    char m;
    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
            if(d[i][j] == 0){
                if(i == 0){
                    m = 'S';
                }else if(i == 1){
                    m = 'H';
                }else if(i == 2){
                    m = 'C';
                }else{
                    m = 'D';
                }
                printf("%c %d\n", m, j + 1);          
            }
        }
    }
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
bool vis[100005];
int col[100005];
vector<pair<int, int>> adj[100005];

void dfs(int u) {
  vis[u] = true;
  for (auto it: adj[u]) {
    int v = it.first, dis = it.second;
    if (vis[v]) continue;
    col[v] = (col[u] + dis)%2;
    dfs(v);
  }
}
int main() {
  int n;
  cin >> n;
  int sz = n;
  n--;
  while (n--) {
    int u, v, w;
    cin >> u >> v >> w;
    w %= 2;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  col[1] = 0;
  dfs(1);
  for (int i = 1; i <= sz; i++) {
    cout << col[i] << el;
  }
  return 0;
}

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

using namespace std;

#define int long long

int p(int i){
    int ans = 1;
    for(int n = 1; n <= i; ++n){
        ans *= n;
    }
    return ans;
}

int P(int n){
    if(n <= 2){
        return 0;
    }
    int num = p(n);
    
    int ans = 0;
    for(int i = 1; i <= n - 2; ++i){
        for(int j = 1; j <= n - i - 1; ++j){
            int k = n - i - j;
            ans += num / (p(i) * p(j) * p(k));
        }
    }
    return ans;
}
signed main(){
    int N; cin >> N;
    
    int NN = N;
    int num = 0;
    while(NN >= 10){
        NN /= 10;
        ++num;
    }
    
    int ans = 0;
    
    for(int i = 0; i <= num; ++i){
        ans += P(i);
    }
    
    for(int i = 1; i < num; ++i){
        for(int j = 1; j < num; ++j){
            int k = num - i - j + 1;
            if(k <= 0){
                break;
            }
            vector<int> s;
            int ii = i; int jj = j; int kk = k;
            while(ii > 0){
                s.push_back(3);
                --ii;
            }
            while(jj > 0){
                s.push_back(5);
                --jj;
            }
            while(kk > 0){
                s.push_back(7);
                --kk;
            }
            do{
                int temp = 0;
                for(int m = 0; m < s.size(); ++m){
                    temp += pow(10, num - m) * s[m];
                }
                if(temp <= N){
                    ++ans;
                }
            }while(next_permutation(s.begin(), s.end()));
        }
    }
    
    cout << ans << endl;
}


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

int main(){
	int n,c,k;
  	cin >> n >> c >> k;
  	vector<int> a(n);
  	int count=1;
  	for(int i = 0; i <n; i++) {
      	cin >> a[i];
	}
  	int tmp,now=0;
  	sort(a.begin(),a.end());
  	tmp = a[0];
  	for(int i = 1; i<n;i++) {
      	if(i-now<c && k + tmp >= a[i]) {
        	continue;
        } else {
        	count++;
          	now = i;
          	tmp = a[i];
        }
    }
  	
  	cout << count <<endl;
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

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

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

ll res=1,n,m,mod=1e9+7;
bool pri[1001];
long long f(int x){
	m=n;
	int cnt=0;
	while(m)
		cnt+=(m/x),m/=x;
	return cnt;
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	memset(pri,1,sizeof pri);
	pri[0]=pri[1]=0;
	for(int i=2;i<=n;i++)
		if(pri[i])
			for(int j=2;j*i<=n;j++)
				pri[j*i]=0;
	for(int i=1;i<=n;i++) {
		if(pri[i]) {
			res=(res*(f(i)+1))%mod; 
		}
	}
	cout<<res<<endl;
	return 0;
}
/******************************************************************************
10
972926972

972926972
******************************************************************************/


Measured memory_bytes: 256
x,n = gets.chomp.split.map(&:to_i)
q = gets.chomp.split.map(&:to_i)

i = 0
check = true
while(check)
    if !q.find_index(x-i)
        print x-i 
        check = false
    elsif !q.find_index(x+i)
        print x+i 
        check = false
    end
    i = i + 1
end

Measured memory_bytes: 14356
#include <iostream>
#include <cmath>
#include <math.h> 
#include <iomanip>
using namespace std;

int main(){
  double a, b, r;
  double s, l, h;
  cin >> a >> b >> r;
  r = r * (M_PI/180.0);
  s = (a * b * sin(r)) / 2;
  l = a + b + pow(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(r), 0.5);
  h = b * sin(r);
  cout << fixed;
  cout << setprecision(9) << s << endl;
  cout << setprecision(9) << l << endl;
  cout << setprecision(9) << h << endl;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{

            long long int n,j,k,r=0;
            cin>>n;
            int a[n];
            for(j=0;j<n;j++)
            {
                cin>>a[j];
            }
            sort(a,a+n);
             for(j=0;j<n-1;j++)
            {
                r = r+a[j];
            }

              if(r>a[n-1])
            {
                cout<<"Yes"<<endl;
            }
            else
            cout<<"No"<<endl;

       return 0;



       }


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)

int main() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    int sum = 0;
    sum = min(a, k);
    sum -= max(0, min(c, k - a - b));
    cout << sum << endl;
}


Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double ha = h / 12.0 * 2 * M_PI;
	if (m % 60 != 0) {
		ha += m / 12.0 / 60.0 * 2 * M_PI;
	}
	double ma = m / 60.0 * 2 * M_PI;
	double hx = a * cos(ha);
	double hy = a * sin(ha);
	double mx = b * cos(ma);
	double my = b * sin(ma);
	double lx = hx - mx;
	double ly = hy - my;
	double l = sqrt(lx * lx + ly * ly);
	//double l = sqrt(pow(hx - mx, 2) + pow(hy - my, 2));
	//cout << hx <<","<< hy <<","<< mx << "," << my << endl;
	cout << fixed << std::setprecision(10);
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 4100
from fractions import gcd


def lcm(a, b):
    return (a*b)//gcd(a, b)


A, B, C, D = map(int, input().split())
sc = B//C - (A-1)//C
sd = B//D - (A-1)//D
scd = B//lcm(C, D) - (A-1)//lcm(C, D)
#print(B//lcm(C, D), (A-1)//lcm(C, D))
#print(sc, sd, scd, B-A+1)
print(B-A+1 - sc - sd + scd)


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

constexpr auto PI = 3.14159265359;

using namespace std;


int make_partition(vector<pair<int, char>>& A, int p, int r) {
	int x = A[r].first;
	int i = p - 1;
	for (int j = p; j < r; ++j) {
		if (A[j].first <= x) {
			++i;
			swap(A[j], A[i]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

void quickSort(vector<pair<int, char>>& A, int p, int r) {
	if (p < r) {
		int q = make_partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

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

	int N;
	cin >> N;
	vector<pair<int, char>> A(N);
	vector<tuple<int, int, char>> stable_A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i].second >> A[i].first;
		stable_A[i] = make_tuple(A[i].first, i, A[i].second);
	}

	quickSort(A, 0, A.size() - 1);
	stable_sort(stable_A.begin(), stable_A.end());

	string stable = "Stable";
	for (int i = 0; i < A.size(); ++i) {
		if (A[i].second != get<2>(stable_A[i])) {
			stable = "Not stable";
		}
	}
	cout << stable << endl;

	for (int i = 0; i < N; ++i) {
		cout << A[i].second << " " << A[i].first << endl;
	}

	return 0;
}


Measured memory_bytes: 6008
#include<stdio.h>

int main(){
int a,b;
char op;

        while(1){
    scanf("%d %c %d", &a, &op, &b);
    if ( op == '+' ){
        printf("%d\n",a+b);
}
    else if ( op == '-' ){
        printf("%d\n",a-b);
}
    else if ( op == '*' ){
        printf("%d\n",a*b);
}
    else if ( op == '/' ){
        printf("%d\n",a/b);
}
    else if( op == '?')break;

                    else {
    exit(1);
    }
    }



    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    int N;
    cin >> N;
    FOR (i, 1, 10) FOR (j, 1, 10) {
        if (i * j == N) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
S=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(S[int(input())-1])

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, m;
  cin >> n >> m;
  vll v(3,vl(n));
  rep(j,n)rep(i,3) cin >> v[i][j];
  ll ans = 0;
  for(int i = 0; i < (1<<3); i++) {
    bitset<3> b(i);
    vl p(n);
    rep(j,n) {
      rep(k,3) {
        if(b[k]) p[j] += v[k][j];
        else p[j] -= v[k][j];
      }
    }
    sort(rall(p));
    ll tmp = 0;
    rep(j,m) tmp += p[j];
    chmax(ans, tmp);
  }
  cout << ans << endl;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s = in();
    string o = "+-";
    rep(i, 2) rep(j, 2) rep(k, 2)
    {
        int a = s[0] - '0';
        int b = s[1] - '0';
        int c = s[2] - '0';
        int d = s[3] - '0';
        int tmp = a;
        if (i % 2 == 0)
            tmp += b;
        else
            tmp -= b;
        if (j % 2 == 0)
            tmp += c;
        else
            tmp -= c;
        if (k % 2 == 0)
            tmp += d;
        else
            tmp -= d;
        if (tmp == 7)
        {
            cout << a << o[i] << b << o[j] << c << o[k] << d << "=7" << endl;
            return;
        }
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int t;
	cin >> t;
	REP(hoge,t){
		int n, d;
		cin >> n >> d;
		int ans = 0;
		n--;
		REP(i,7){
			if(((d>>i)&1)){
				if((n)%2 == 0) ans += (1<<i)*(n+1);
				else ans += (1<<i)*(n);
			}else{
				if(n%2 == 0) ans += (1<<i)*(n);
				else  ans += (1<<i)*(n+1);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#define DEBUG

using namespace std;
int n, a[150010];
struct node {
    int id, point;
} node[1<<21];

void add(int id, int x)
{
    id=n-1+id;
    node[id].point+=x;

    while (id>0) {
        id=(id-1)/2;
        int c1=2*id+1, c2=2*id+2;
        if (node[c1].point>=node[c2].point)
            node[id]=node[c1];
        else
            node[id]=node[c2];
    }
}

void print()
{
#ifdef DEBUG
    int k=1;
    int x=0;
    while (true) {
        for(int i=0;i<k;++i) printf("(%d %d)", node[x+i].id, node[x+i].point);
        puts("");
        x+=k;
        k<<=1;
        if (x>=n) break;
    }
    puts("");
#endif
}

int main()
{
    int m, r, l;
    scanf("%d%d%d", &m, &r, &l);
    n=1;
    while (n<m) n<<=1;
    for(int i=0;i<m;++i) node[n-1+i].id=i;

    int pt=0;
    for(int i=0;i<r;++i) {
        int d, t, x;
        scanf("%d%d%d", &d, &t, &x);

        if (pt<t) {
            int id=node[0].id;
            a[id]+=t-pt;
        }
        add(d-1, x);
        print();
        pt=t;
    }
    print();
    a[node[0].id]+=l-pt;
#ifdef DEBUG
    for(int i=0;i<n;++i) printf("%d ", a[i]); puts("");
#endif
    printf("%d\n", 1+(max_element(a, a+n)-a));
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    ll N, K; cin >> N >> K;
    vll h(N); cin >> h;

    vll dp(N, LLONG_MAX);
    dp[0] = 0;

    rep(i, N) {
        rep1(k, K+1) {
            int j = i + k;
            if (j < N) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    cout << dp.back() << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>

int main()
{

    int A, B, a, b;
    std::cin >> A >> B;
    a = 12.5 * A + 0.5;
    b = 10 * B;
    if (std::abs(a - b + 0.5) <= 10)
    {
        std::cout << std::max(a, b) << std::endl;
    }
    else
    {
        std::cout << -1 << std::endl;
    }
    return 0;
}

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

int main() {
  while (true) {
    int t; cin >> t;
    if (t == 0) break;

    int x = 1000 - t;
    int cnt = 0;
    while (x > 0) {
      if (x / 500 > 0) {
        cnt += x / 500;
        x %= 500;
      } else if (x / 100 > 0) {
        cnt += x / 100;
        x %= 100;
      } else if (x / 50 > 0) {
        cnt += x / 50;
        x %= 50;
      } else if (x / 10 > 0) {
        cnt += x / 10;
        x %= 10;
      } else if (x / 5 > 0) {
        cnt += x / 5;
        x %= 5;
      } else if (x / 1 > 0) {
        cnt += x / 1;
        x %= 1;
      }
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 3012
//前回の提出で対応してなかったのはループじゃなく閉路でした
//PDF解説に倣って
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,k;
  cin>> n >> k;
  
  k=(n-1)*(n-2)/2-k;
  if (k<0){ cout<<-1<<endl; return 0;}

  vector<unordered_set<int>> G(n);
  int m=n+k-1, l=1, r=2;
  for (int i=1; i<n; i++) G[0].insert(i);
  while (k>0){
    if (r==n){ l++; r=l+1;}
    G[l].insert(r);
    r++; k--;
  }
  
  cout<<m<<endl;
  for (int i=0; i<n; i++)
    for (auto j: G[i])
      cout<< i+1 <<" "<< j+1 <<endl;
}
//実装は難しくないが思いつけない。

Measured memory_bytes: 512
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T b,T a){if(a<b){a^=b;b^=a;a^=b;return 1;}return 0;}

ll n,d;
void input(){
    cin>>n>>d;
}
void src(){
    ll dd=2*d+1;
    cout<<(n%dd==0? n/dd:n/dd+1);
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL - 1

int n;
struct Node {
	int p, l, r;
};
struct Node T[MAX];

void Preorder (int u) {
	if (u == NIL) {
		return;
	}
	printf(" %d", u);
	Preorder(T[u].l);
	Preorder(T[u].r);
}

void Inorder (int u) {
	if (u == NIL) {
		return;
	}
	Inorder(T[u].l);
	printf(" %d", u);
	Inorder(T[u].r);
}

void Postorder (int u) {
	if (u == NIL) {
		return;
	}
	Postorder(T[u].l);
	Postorder(T[u].r);
	printf(" %d", u);
}

int main () {
	int i, v, l, r, root;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		T[i].p = NIL;
	}

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL) {
			T[l].p = v;
		}
		if (r != NIL) {
			T[r].p = v;
		}
	}

	for (i = 0; i < n; i++) {
		if (T[i].p == NIL) {
			root = i;
		}
	}

	printf("Preorder\n");
	Preorder(root);
	putchar('\n');
	printf("Inorder\n");
	Inorder(root);
	putchar('\n');
	printf("Postorder\n");
	Postorder(root);
	putchar('\n');
	
	return 0;
}


Measured memory_bytes: 2116
#include <cstdio>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Vector { double x, y; };

bool isOrthogonal(Vector a, Vector b) {
    return equals(a.x * b.x + a.y * b.y, 0.0);
}

bool isParallel(Vector a, Vector b) {
    return equals(a.x * b.y - a.y * b.x, 0.0);
}

int main(void) {
    int n, x1, x2, y1, y2;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        Vector v1, v2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        v1.x = x2 - x1; v1.y = y2 - y1;

        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        v2.x = x2 - x1; v2.y = y2 - y1;

        if (isOrthogonal(v1, v2)) printf("%d\n", 1);
        else if (isParallel(v1, v2)) printf("%d\n", 2);
        else printf("%d\n", 0);
    }

    return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  
  priority_queue<int, vector<int>, greater<int>> p;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    p.push(a);
  }
  
  int sum = 0;
  
  for(int i = 0; i < K; i++){
    sum += p.top();
    p.pop();
  }
  cout << sum << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(((b-a)*(b-a) <= d*d && (c-b)*(c-b) <= d*d) || (c-a)*(c-a) <= d*d){
    cout << "Yes" << endl;
  }
    else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int main() {
    ull n, x[1000], y[1000], c[2];
    cin >> n;
    for (ull i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        c[(x[i] + y[i]) % 2]++;
    }
    if (c[0] && c[1]) {
        cout << -1 << endl;
        return 0;
    }
    cout << (c[0] ? 33 : 32) << endl;
    if (c[0]) cout << "1 ";
    ull s = 0;
    for (ull i = 0; i < 32; i++) {
        cout << ((ull)1 << i) << ' ';
        s |= ((ull)1 << i);
    }
    cout << endl;
    char t[2][2] = {
            {'L', 'D'},
            {'U', 'R'}
    };
    for (ull i = 0; i < n; i++) {
        if (c[0]) {
            cout << 'L';
            x[i]++;
        }
        ull u = x[i] + y[i], v = x[i] - y[i];
        ull u2 = (s - u) / 2, v2 = (s - v) / 2;
        for (ull j = 0; j < 32; j++) {
            ull d1 = u2 & ((ull)1 << j) ? 0 : 1;
            ull d2 = v2 & ((ull)1 << j) ? 0 : 1;
            cout << t[d1][d2];
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;
int d[110];
int k[110];

int main(){
   int n;
   cin>>n;
   for(int i=0;i<n;i++){
      cin>>d[i];
      k[d[i]]++;
   }
   int ans=0;
   for(int i=0;i<102;i++){
      if(k[i]>0)ans++;
   }


   cout<<ans<<endl;

}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    if (N )
    _PR((N + 1) / 2);

    return 0;
}

/*



*/

Measured memory_bytes: 256
/*
Author: Snickeen 
Email : ff@snickeen.com
If you find any bug, please tell me.
*/

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

typedef long long LL;

const LL INF = 1e18+7;
const LL MOD = 1e9+7;
const LL MAXN = 3e5+7;

/////**********************************************/////

LL n,a,b;
vector<LL> f[MAXN];

signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	LL i,j,k,l,r,d;
	
	cin>>n>>a>>b;
	l=(n+a-1)/a;
	r=n+1-a;
	if(b<l||b>r)return cout<<"-1\n",0;
	for(i=1;i<=l;i++){
		j=i+(n-i*a)-b;
		if(j<a)break;
	}
	k=i+1;d=j;
	for(i=1;i<k;i++){
		LL tmp=n-i*a+1;
		for(j=1;j<=a;j++)cout<<tmp++<<" ";
	}
//	cout<<"\n---"<<k<<" "<<d<<"---\n";
	r=n-a*k+a;l=max(r-a+1,1ll);
	for(i=1;i<=d&&l>0;i++)cout<<l++<<" ";
	for(i=1;i+d<=a&&r>=l;i++)cout<<r--<<" ";
	for(i=n-k*a;i>0;i--)cout<<i<<" ";
	cout<<endl; 
	
	return 0;
}

Measured memory_bytes: 9216
def valid(s):
    if s[0] != 'A':
        return False
    if s[2:-1].count('C') != 1:
        return False

    num_upper = 0
    for c in list(s):
        if c.isupper():
            num_upper += 1

    if num_upper > 2:
        return False

    return True


s = input().strip()
print('AC') if valid(s) else print('WA')

Measured memory_bytes: 3064
// Problem : F - Silver Fox vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_f
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
#define int ll
const int MOD = 1000000007;

int bit[200005]; int N;

void upd(int x, int v) { x++; while(x <= N) { bit[x] += v; x += (-x&(x)); } }
int get(int x) { x++; int ans = 0; while(x) { ans += bit[x]; x -= (-x&(x)); } return ans; }

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
	int dia, A; cin >> N >> dia >> A;
	vector<pii> v;
	rep(i, N) {
		int loc, ne; cin >> loc >> ne;
		ne = (ne + A - 1) / A;
		v.pb({loc, ne});
	}
	sort(all(v));
	int ans = 0;
	rep(i, N) {
		if(get(i) >= v[i].se) continue;
		// bin search for last index <= than v[i].fi+2*dia
		int targ = v[i].fi+2*dia;
		int lef = i, rig = N-1, ban = i;
		while(lef <= rig) {
			int mid = (lef+rig)/2;
			if(v[mid].fi > targ) rig = mid-1;
			else { lef = mid+1; ban = mid; }
		}
		int dt = v[i].se-get(i);
		ans += dt;
		upd(i, dt); upd(ban+1, -dt);
	}
	cout << ans << endl;	
}



Measured memory_bytes: 3568
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Debug.Trace
import Data.List

getEachNumberCount :: [Int] -> [Int]
getEachNumberCount = map length . group . sort

countDuplicated :: [Int] -> Int
countDuplicated [] = 0
countDuplicated (x:xs) = (x - 1) + (countDuplicated xs)

solve:: [Int] -> Int
solve arr = ans
    where
        countArr = getEachNumberCount arr
        dup = countDuplicated countArr
        cardNum = length countArr
        ans = if dup `mod` 2 == 0 then cardNum else cardNum - 1

main :: IO ()
main = do
    n <- (fst . fromJust . BS.readInt) <$> BS.getLine
    a <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    print $ solve a


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

int main() {
	char b, c;
	cin >> b;

	switch (b) {
	case 'A':
		c = 'T';
		break;
	case 'T':
		c = 'A';
		break;
	case 'C':
		c = 'G';
		break;
		case 'G':
		c = 'C';
		break;
	}

	cout << c;
	return 0;
}


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

int main(void){
	int W,H;
	string l = "";
	for(int i = 0; i < 301; i++){
		if(i%2 == 0)l += "#";
		else l += ".";
	}
	cin >> H >> W;
	string line;
	while(H != 0 || W != 0){
		for(int i = 0; i < H; i++){
			if(i %2 == 0)line = l.substr(0,W);
			else line = l.substr(1,W);
				cout << line << "\n";
		}
		cout << "\n";
		cin >> H >> W;
	}
	return 0;

}


Measured memory_bytes: 3104
def main():
    n, k = map(int, input().split())
    mod = 10 ** 9 + 7
    ans = [0] * (k + 1)
    x = n - k + 1
    ans[1] = x
    a, b = n - k, k - 1
    for i in range(2, k + 1):
        x = x * a * b // (i * (i - 1))
        ans[i] = x % mod
        a -= 1
        b -= 1

    print('\n'.join(map(str, ans[1:])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int r0, int w0, int c, int r) {
    for (int cnt = 0;;cnt++) {
        if ((r0 + cnt * r) / w0 >= c) {
            cout << cnt << endl;
            return;
        }
    }
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    while (cin >> n >> m >> a >> b, n) {
        solve(n, m, a, b);
        //return 0;
    }
}

Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  rep1(i, n) {
    vector< pair<int, int> > v;
    v.assign(26, mp(0, 0));
    string s1 = s.substr(0, i), s2 = s.substr(i, n-i);

    rep(j, s1.length()) {
      v[s1[j] - 'a'].first++;
    }
    rep(j, s2.length()) {
      v[s2[j] - 'a'].second++;
    }

    int cnt = 0;
    rep(j, 26) {
      if(v[j].first > 0 && v[j].second > 0) cnt++;
    }

    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 100005
#define ll long long
#define db double
#define dbg1(x) cout<<#x<<"="<<x<<" "
#define dbg2(x) cout<<#x<<"="<<x<<"\n"
int n,A[N],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=1;i<=n;i++) ans+=abs(A[i]-A[i-1]);
	ans+=abs(A[n]);
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",ans-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]));
	}
	return 0;
}


Measured memory_bytes: 1664
import math

def main():
    A, B, C = map(int, input().split())

    c = math.radians(C)
    s = A * B * math.sin(c) / 2
    l = A + B + math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(c))
    h = B * math.sin(c)

    print(s)
    print(l)
    print(h)

main()

Measured memory_bytes: 8024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		List<Integer> p = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		int ans = 101;
		int minres = 101;
		List<Integer> p_ = new ArrayList<>();
		for (int i = 0; i <= 101; i++) {
			if (!p.contains(i)) {
				p_.add(i);
			}
		}
		for (int i : p_) {
			if (Math.abs(x - i) < minres) {
				minres = Math.abs(x - i);
				ans = i;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35932