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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

ll ans = 0;
int n;
ll a;

int main(){
  cin >> n;
  REP(i,n){
    cin >> a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  cout << ans <<endl;
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
template<class T>
void print_array(T a[],size_t n){
  cerr<<"array:";
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

ll N,P;

int main(){
  cin>>N>>P;
  ll ans=1;
  if(N==1){
    cout<<P<<endl;
    return 0;
  }
  for (ll i = 2; i*i <= P; i++) {
    ll cnt=0;
    while(P%i==0){
      cnt++;
      P/=i;
    }
    For(j,cnt/N){
      ans*=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    int diff = b - a;
    int ans = 0;
    REP(i,diff) ans += i;
    cout << ans - a << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import math
import heapq
def input():
    return sys.stdin.readline()[:-1]

N, M = map(int, input().split())
A = list(map(lambda a: int(a)*(-1), input().split()))
heapq.heapify(A)

for _ in range(M):
    heapq.heappush(A, math.trunc(heapq.heappop(A) / 2))

print(sum(A)*(-1))

Measured memory_bytes: 23228
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 998244353;

ll pow_ans(ll x, int n) {
  ll res=1;
  while (n>0) {
    if (n & 1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

int main(){
  ll n,ans=1;
  cin>>n;
  vector<ll>d(n,0);
  for(ll i=0;i<n;i++){
    cin>>d[i];
  }
  if(d[0]!=0){
    cout<<0<<endl;
    return 0;
  }
  sort(d.begin(),d.end());
  ll t=0;
  ll num=0;
  ll f=1;
  vector<ll>v;
  for(ll i=0;i<n;i++){
    if(d[i]==t)num++;
    else if(d[i]==t+1){
      v.push_back(num);
      num=1;
      t++;
    }
    else f=0;
  }
  v.push_back(num);
  if(f==0||v[0]!=1){
    cout<<0<<endl;
    return 0;
  }
  for(ll i=1;i<v.size();i++){
    ans=ans*pow_ans(v[i-1],v[i])%MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2800
A,B,C = map(int,input().split())

#print(A,B,C)

if A==B and B==C and A%2==1:
  print(0)
  
elif A==B and B==C:
  print(-1)
else:
  count=0
  while A%2==0 and B%2==0 and C%2==0:
    Ax=A/2
    Bx=B/2
    Cx=C/2
    #print(Ax,Bx,Cx)
    A = int(Bx+Cx)
    B = int(Cx+Ax)
    C = int(Ax+Bx)
    count +=1
    #print(A,B,C)
  print(count)    
    

Measured memory_bytes: 3060
import Control.Monad
f :: [Int]->[[Int]]->[Int]
f l a= if null a then [] else[sum l+(last.head) a-(l!!((head.head)a-1))]++f l (tail a)
main=do
 n<-getLine
 l<-map read.words<$>getLine
 m<-readLn
 a<-map (map read).map words<$>replicateM m getLine
 putStrLn.init.unlines.map show.f l$a

Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define Yes(a) if(a)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
int aaa(int a, int b) {
	for (int i = 1;; i++) {
		if (i * a > b)return i-1;
	}
}

int main(){
	int a, b, c;
	string s, t,u;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (u == s)a--;
	else b--;

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

}

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

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int d1[4] = {0,1,0,-1};
int d2[4] = {1,0,-1,0};

const int inf = 1<<29;
int h, w;
vector<vector<char>> fi(55, vector<char>(55, '#'));
vector<vector<int>> d(55, vector<int>(55, inf));

void bfs(){
    queue<pair<int,int>> q;
    q.push(make_pair(1, 1));
    d[1][1] = 0;

    while(!q.empty()){
        pair<int, int> p=q.front(); q.pop();
        int i=p.first, j=p.second;
        for(int k=0; k<4; ++k){
            int ni=i+d1[k], nj=j+d2[k];
            if(fi[ni][nj]=='.' &&  d[ni][nj] > d[i][j]+1){
                d[ni][nj] = d[i][j]+1;
                q.push(make_pair(ni, nj));
            }
        }
    }
}

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

    cin >> h >> w;
    int white=0;

    for(int i=1; i<=h; ++i) for(int j=1; j<=w; ++j){
        cin >> fi[i][j];
        if(fi[i][j] == '.') ++white;
    }

    bfs();

    if(d[h][w] == inf) cout << -1 << '\n';
    else cout << white - d[h][w] - 1 << '\n';

	return 0;
}


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, S: str):
    if N % 2 == 1:
        print(NO)
        return
    elif S[: N // 2] != S[N // 2:]:
        print(NO)
        return
    print(YES)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    long K = sc.nextLong();
    if (S.length() == 1) {
      System.out.println(S);
      return;
    }
    int i =0;
    while (i < S.length() && S.charAt(i) == '1') {
      i++;
    }
    if (K <= i) {
      System.out.println(1);
      return;
    }
    System.out.print(S.charAt(i));
  }
}

Measured memory_bytes: 35788
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int L=128,C=62;
int pw[C*2+2][L];int diff,edit[C+1]={0},sz[2*C+2]={0};
static inline int decode(int x){return x<=26?64+x:(x<=52?96-26+x:48+x-52-1);}
static inline int ask(int u,int i,int j)
{
  int len=diff;
  printf("? ");rep(k,sz[u]){len--;putchar(decode(pw[u][k]));}len--;putchar(decode(pw[u<<1][i]));
  rep(k,sz[u<<1|1]-j){len--;putchar(decode(pw[u<<1|1][k+j]));}puts("");fflush(stdout);
  int res;if(scanf("%d",&res)!=0)return res==len;else return -1;
}
static inline void solve(int u,int le,int ri)
{
  if(le==ri){sz[u]=edit[le];rep(i,edit[le]){pw[u][i]=le;}return;}
  int mid=(le+ri)>>1;
  solve(u<<1,le,mid);solve(u<<1|1,mid+1,ri);
  for(int i=0,j=0;i<sz[u<<1]||j<sz[u<<1|1];)
  {
    if(i<sz[u<<1]&&(j==sz[u<<1|1]||ask(u,i,j))){pw[u][sz[u]++]=pw[u<<1][i];i++;}
    else{pw[u][sz[u]++]=pw[u<<1|1][j];j++;}
  }
}
int main(void)
{
  rep(i,C)
  {
    printf("? ");rep(j,L){putchar(decode(i+1));}puts("");fflush(stdout);
    int res;if(!scanf("%d",&res))return -1;
    edit[i+1]=L-res;diff+=L-res;
  }
  solve(1,1,C);
  printf("! ");rep(i,sz[1])putchar(decode(pw[1][i]));puts("");fflush(stdout);
  return 0;
}

Measured memory_bytes: 3800
/*author : Yashvardhan
Sunday, May 10, 2020
5:39 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

int n,m,x;
vi arr(20);
int tmp[20][20];

int dp[15][(1 << 13)];
int curr[15];

int solve(int i, int mask){
	if(dp[i][mask] != -1) return dp[i][mask];
	if(i == n){
		initialise(curr,0);
		for(int it = 0; it < n; it++){
			if(!((1 << it) & mask)) continue;
			for(int j = 0; j < m; j++){
				curr[j] += tmp[it][j];
			}
		}
		bool flag = true;
		for(int j = 0; j < m; j++) flag &= (curr[j] >= x);
		if(flag) return 0;
		return inf;
	}
	int ans = solve(i + 1, mask);
	for(int it = 0; it < n; it++){
		if((1 << it) & mask) continue;
		ans = min(ans, solve(i + 1, mask | (1 << it)) + arr[it]);
	}
	return dp[i][mask] = ans;	
}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

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

	time_t t1, t2;
	t1 = clock();
	
	cin >> n >> m >> x;

	for(int i = 0; i < n; i++){
		cin >> arr[i];
		for(int j = 0; j < m; j++){
			cin >> tmp[i][j];
		}
	}
	initialise(dp, -1);

	int ans = solve(0,0);
	if(ans == inf){
		cout << -1 << endl;
	}
	else cout << ans << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 4624
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}


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

int main()
{
	char str[10000];
	int count[26] = { 0 };

	int i;
	
	while (scanf("%s", str) != EOF)
	{
		for (i = 0; str[i] != '\0'; i++)
		{
			if (str[i] >= 'a' && str[i] <= 'z')
				count[str[i] - 'a']++;
			else if (str[i] >= 'A' && str[i] <= 'Z')
				count[str[i] - 'A']++;
		}

	}

	for (i = 0; i < 26; i++)
		printf("%c : %d\n", 'a' + i, count[i]);

	return 0;
}


Measured memory_bytes: 2056
#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<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 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,M,V,P; cin >>N>>M>>V>>P;
    vector<ll> A(N); cin >> A;
    sort(all(A));
    vector<ll> s(N);
    rep(i, N) {
        s[i] = A[i] + (i==0 ? 0 : s[i-1]);
    }

    ll l = -1, r = N-P;
    while (r - l > 1) {
        ll c = l + (r - l)/2;
        bool ok = false;

        if (A[c] + M >= A[N-P]) {
            ll k = V-(c+1)-(P-1);
            if (k <= 0) {
                ok = true;
            } else {
                ll w = N-P-c;
                ll h = A[c] + M;
                if (w*h - (s[N-P]-s[c]) >= k*M /*&& w >= k*/) {
                    ok = true;
                }
            }
        }
        if (ok) {
            r = c;
        } else {
            l = c;
        }
    }

    cout << N-r << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int N;
    cin >> N;
    int a = 1;
    while(a <= N){
        a = a * 2;
    }
    cout << a / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const long double EPS = 1e-9;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<char> &o) {
    string a;
    in >> a;
    for (char c : a) o.insert(c);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


int main() {
    int a, b;
    cin >> a>>b;
    
    cout << a*b<< endl;
}


Measured memory_bytes: 3632
def gcm(a, b) :
  while(b) :
    a, b = b, a%b
  return a
def lcm(a, b) :
  return int(a*b/gcm(a, b))

n, m = map(int, input().split())
s = list(str(input()))
t = list(str(input()))
s_out = []
t_out = []
for i in range(int(gcm(n, m))) :
  s_out.append(s[i*int(n/gcm(n, m))])
for i in range(int(gcm(n, m))) :
  t_out.append(t[i*int(m/gcm(n, m))])
  
if(s_out == t_out) : print(lcm(n, m))
else : print(-1)

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

int main() {
  string s,ans="No";
  cin>>s;
  if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
    ans="Yes";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;
 
int main() {
	string s;
	cin >> s;
 
	bool h = true;
	for (auto& it : s)
	{
		if (h && it == 'h')
		{
			h = false;
		}
		else if( !h && it == 'i')
		{
			h = true;
		}
		else
		{
			cout << "No";
			return 0;
		}
	}
 
	if( h )
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	cout << (A*N < B ? A*N : B) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<map>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,s[110000],A,B,vis[110000],clo;
long long ans,sum;
//map<int,bool> vis;
int main(){
	scanf("%d",&n);
	fo(i,0,n-1) scanf("%d",&s[i]);
	fo(C,1,n-2){
//		vis.clear();
		clo++;
		sum=0;//!!!! 
		for(int kC=C;kC<n-1;kC+=C){
			A=n-1-kC;
			B=A-C;
			if (A<=B||B<=0) break;
			if (A==kC||vis[A]==clo||vis[kC]==clo) break;
			sum+=s[A]+s[kC];
			vis[A]=clo;vis[kC]=clo;
			if (sum>ans) ans=sum;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}


int main(){

    int K;

    cin >> K;

    int sum = 0;

    int a, b, c;
    int d;

    for(a = 1; a <= K; a++){
        for(b = 1; b <= K; b++){
            for(c = 1; c <= K; c++){
                d = gcd(b, c);
                sum = sum + gcd(a, d);
            }
        }
    }

    printf("%d\n", sum);

    return 0;
    
}

Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
int main(void)
{
    int N,C,K;
    int ans1 = 0, ans2 = 0;
    int num=0;
    unsigned long long int last,first;
 
    cin >> N >> C >> K;
 
    vector<int> T(N);
 
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
 
    sort(T.begin(), T.end());
 
ans1 = 10000000;
 
    for (int i = 0; i < N; i++) {
        first = T[i];
        num = 1;
        ans2++;
        for (int j = i+1; j < N; j++) {
            if (first+K >= T[j] && num < C) {
                num++;
            } else {
                break;
            }
        }
        i += num-1;
    }
 
    cout << min(ans1,ans2) << endl;
 
    return 0;
}

Measured memory_bytes: 640
# AOJ 1209: Square Coins
#Python3 2018.7.19 bal4u

N = 18
tbl = [i**2 for i in range(0, N)]
dp = [[0 for j in range(600)] for i in range(N)]
dp[0][0] = 1
for i in range(1, N):
    for n in range(300):
        dp[i][n] += dp[i-1][n]
        for j in range(tbl[i], 300, tbl[i]):
            dp[i][n+j] += dp[i-1][n]

while True:
    n = int(input())
    if n == 0: break
    print(dp[N-1][n])




Measured memory_bytes: 5716
S = gets.strip.chars
j = 'g'
puts  S.inject(0) {|tot, x|
        if j == 'p' && x == 'g'
          tot += 1 
        elsif j == 'g' && x == 'p'
          tot -= 1 
        end
        j = (j == 'g' ? 'p' : 'g')
        tot 
      }

Measured memory_bytes: 9468
import math
a,b,x=map(int,input().split())
l = a**2*b
rx = l-x
rl = rx / a**2
if 2*rl <= b:
    print(math.degrees(math.atan(2*rl/a)))
else:
    print(math.degrees(math.atan(b**2*a/(x*2))))

Measured memory_bytes: 3060
L,R = map(int, input().split())

if ((R - L) >= 2019):
  print(0)
  exit()

ans = 2019
for j in range(L,R+1):
  for i in range(L,j):
    tmp = (i * j) % 2019

    if (ans > tmp):
      ans = tmp
print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <bitset>
#include <cctype>
#include <algorithm>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e3+5, M = 4e6+5;
int n, s; bitset<M> f;
int main()
{
    n = read(), f[0] = 1;
    for(int i = 1, w; i <= n; ++i) w = read(), s += w, f |= f<<w;
    s = (s-1)/2+1;
    for(int i = s; i < M; ++i) if(f[i]) return printf("%d\n", i), 0;
    return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    int f=0,c=0;
    FOR(i,0,n){
        int a,s;
        cin>>a>>s;
        if(a==s){
            c++;
            if(c>=3){
                f=1;
            }
        }else{
            c=0;
        }
    }

    if(f){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 3640
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def largestRectangInHistgram(heights):
    stack = [-1]
    maxArea = 0

    for i in range(len(heights)):
        # we are saving indexes in stack that is why we comparing last element in stack
        # with current height to check if last element in stack not bigger then
        # current element
        while stack[-1] != -1 and heights[stack[-1]] > heights[i]:
            lastElementIndex = stack.pop()
            maxArea = max(maxArea, heights[lastElementIndex] * (i - stack[-1] - 1))
        stack.append(i)

    # we went through all elements of heights array
    # let's check if we have something left in stack
    while stack[-1] != -1:
        lastElementIndex = stack.pop()
        maxArea = max(maxArea, heights[lastElementIndex] * (len(heights) - stack[-1] - 1))

    return maxArea


def main():
    n=ni()
    a = na()
    
    ans = largestRectangInHistgram(a)

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 19100
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;
typedef vector<int> V;

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

int main() {
	llong N,Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    int ans=N;
    // vector<int> p(N,1);
    vector<char> t(Q),d(Q);
    REP(i,Q){
        cin >> t[i] >> d[i];
    }
    int tar_l,tar_r,tar,ret_l,ret_r;
    //left
    tar_l=-1,tar_r=N;
    REP(i,N){
        tar =(tar_l+tar_r)/2;
        if(tar_l+1>=tar_r){
            ret_l=tar_l;break;
        }
        int now = tar;
        int reach=0;
        REP(j,Q){
            if(t[j]==s[now]){
                if(d[j]=='L'){
                    now--;
                    if(now<0){
                        reach=1;
                        break;
                    }
                }else{
                    now++;
                }
            }
        }
        if(reach){
            tar_l=tar;
        }else{
            tar_r=tar;
        }
    }


    //right
    tar_l=-1,tar_r=N;
    REP(i,N){
        tar =(tar_l+tar_r)/2;
        if(tar_l+1>=tar_r){
            ret_r=tar_r;break;
        }
        int now = tar;
        int reach=0;
        REP(j,Q){
            if(t[j]==s[now]){
                if(d[j]=='L'){
                    now--;
                }else{
                    now++;
                    if(now>N-1){
                        reach=1;
                        break;
                    }
                }
            }
        }
        if(reach){
            tar_r=tar;
        }else{
            tar_l=tar;
        }
    }
    // cout <<ret_l <<" ,"<< ret_r <<endl;
    ans = N-min(N,(ret_l+1)+N-(ret_r));
    

    cout << ans << endl;





}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int n,k,a[101010];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cout<<(n-1+k-2)/(k-1)<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define maxn 510
#define ll long long
#define lim 1000000000
int a[maxn][maxn];
int n,m,h,w;
int main()
{
    scanf("%d%d%d%d",&n,&m,&h,&w);
    for(int i=1;i<=n;i+=h)
        for(int j=1;j<=m;j+=w)
            a[i][j]=lim-1;
    for(int i=h;i<=n;i+=h)
        for(int j=w;j<=m;j+=w)
            a[i][j]=-lim;

    ll sum=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            sum+=a[i][j];

    if(sum<=0) puts("No");
    else
    {
        puts("Yes");
        for(int i=1;i<=n;++i)
            for(int j=1;j<=m;++j)
                printf("%d%c",a[i][j],j==m?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 3968
import java.util.Scanner;
public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			String s = sc.next();
			long ans = dfs(0,0,0,s);
			System.out.println(ans);
		}
		
		static long dfs(int id,int preid, long sum, String s) {
			if(id == s.length()) {
				if(id != preid)
				sum += Long.parseLong(s.substring(preid, id));
				return sum;
			}
			long ret = dfs(id+1, preid, sum, s);
			if(id != preid) {
				ret += dfs(id+1,id,sum + Long.parseLong(s.substring(preid,id)),s);
			}
			
			return ret;
		}

		

}


Measured memory_bytes: 10068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int N = 100005;
const int MOD = 1e9 + 7;

int n, k, a[N];

int modinv(int a) {
  int b = MOD, u = 1, v = 0;
  while (b) {
    int t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}

vector<int> mf(N, -1), mif(N, -1);

int modfact(int n) {
  if (mf[n] != -1) return mf[n];
  if (n == 0) return mf[0] = 1;
  return mf[n] = (ll)n * modfact(n-1) % MOD;
}

int modinvfact(int n) {
  if (mif[n] != -1) return mif[n];
  if (n == 0) return mif[0] = 1;
  return mif[n] = (ll)modinv(n) * modinvfact(n-1) % MOD;
}

int modcomb(int n, int k) {
  return (ll)modfact(n) * modinvfact(k) % MOD * modinvfact(n-k) % MOD;
}

int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  rep(i, n) {
    if (n-i-1 >= k-1) ans = (ans - (ll)a[i] * modcomb(n-i-1, k-1)) % MOD;
    if (i >= k-1) ans = (ans + (ll)a[i] * modcomb(i, k-1)) % MOD;
  }
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6028
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 


//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}
void reverse(string& str) 
{ 
    int n = str.length(); 
  
    // Swap character starting from two 
    // corners 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
} 
int fun(string s,char c)
{
    int n=s.length();
    if(n==1)
    {
        if(s[0]!=c)
        {
         return 1;
        }
        else {
        return 0;
        }
    }
    else {
    int l=0,k=0;
   int r=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=c)
        {
           l++;
        }
    }
    for(int i=n/2;i<n;i++)
    {
        if(s[i]!=c)
        {
            k++;
        }
    }
   // cout<<l<<" "<<k<<endl;
   string p=s.substr(0,n/2);
        string o=s.substr(n/2,n/2);
        r+=min(k+fun(p,char(c+1)),l+fun(o,char(c+1)));
        return r;
    }
}



  
int main() {
       ll int n;
       cin>>n;
      ll int a[n];
      ll int b[n];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
          b[i]=a[i];
      }
      sort(b,b+n);
      for(int i=0;i<n;i++)
      {
          if(a[i]!=b[n-1])
          {
              cout<<b[n-1]<<" ";
          }
          else {
          cout<<b[n-2]<<" ";
          }
      }
}


Measured memory_bytes: 6748
#include <iostream>

using namespace std;

int main(void){
    int S;
    cin >> S;
    int h, m, s;
    h = S / 3600;
    m = (S / 60) % 60;
    s = S % 60;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int number[n+1];
    int sum[105]={0};
    for(int i=1; i<=n; i++){
        cin >> number[i];
        sum[number[i]]++;
    }
    int max=0;
    for(int i=101; i>=0; i--){
        sum[i-1]+=sum[i];
        if(sum[i]>=i){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>
int main()
{
	int sum,a,b,count;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		sum=a+b;
		count=(int)log10(sum)+1;
		printf("%d\n",count);
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int res=0;
    int now=0;
    for(char c:s)
    {
        if(c=='R') now++;
        else now=0;
        res=max(res,now);
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

ll rec(ll n, ll x){
  if(n==0) return 1;
  ll len = pow(2,n+2) - 3;
  ll pty = pow(2,n+1) - 1;
  if(x==1) return 0;
  else if(x<=(len+1)/2-1) return rec(n-1,x-1);
  else if(x==(len+1)/2) return (pty-1)/2 + 1;
  else return (pty-1)/2 + 1 + rec(n-1, x-(pow(2,n+1)-3)-2);
}

int main() {
  ll n,x; cin >> n >> x;
  cout << rec(n,x) << endl;
}



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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define foi(i,a,n) for(i = (a); i <= (n); i++)
#define pd(x) cout<<x
#define sd(x) cin>>x
#define nl cout<<endl
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//ll fibonacci[2][2] = {{0,1},{1,1}};
//ll identity[2][2] = {{1,0},{0,1}};

int main() {
	ll i,j,k;
	ll n,m;
	cin>>n>>m;
	vector<vll> graph(n);
	fo(i,0,m) {
		ll a,b;
		cin>>a>>b;
		graph[a-1].pb(b-1);
		graph[b-1].pb(a-1);
	}
	ll c6 = 0, c4 = 0, oc = 0;
	fo(i,0,n) {
		if (sz(graph[i])%2 == 1) {
			oc++;
			break;
		}
		if (sz(graph[i]) == 6) c6++;
		else if (sz(graph[i]) == 4) c4++;
	}
	if (oc) {
		cout << "No" << endl;
	} else if (c6 > 0) {
		cout << "Yes" << endl;
	} else if (c4 > 2) {
		cout << "Yes" << endl;
	} else if (c4 == 2) {
		vll c4s;
		fo(i,0,n) if (sz(graph[i]) == 4) c4s.pb(i);
		queue<ll> q;
		q.push(c4s[0]);
		vector<bool> visited(n,false);
		visited[c4s[0]] = true;
		ll count = 0;
		while (!q.empty()) {
			ll top = q.front();
			q.pop();
			for(auto it : graph[top]) {
				if (it == c4s[1]) {
					count++;
					continue;
				}
				if (!visited[it]) {
					q.push(it);
					visited[it] = true;
				}
			}
		}
		if (count == 2) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl; 
		}
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 5760
#include<iostream>
using namespace std;
#define MAX 2000000
int H,i,A[MAX+1];
void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest])largest=r;
  if(largest != i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}
int main(){
  cin>>H;
  for(int i=1;i<=H;i++)cin>>A[i];
  for(int i=H/2;i>=1;i--)maxHeapify(i);
  for(int i=1;i<=H;i++){
    cout<<" "<<A[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 5044
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int H = scan.nextInt();
        int M = scan.nextInt();

        double ax = A*Math.cos(Math.toRadians(30*H+M/2.0));
        double ay = A*Math.sin(Math.toRadians(30*H+M/2.0));
        double bx = B*Math.cos(Math.toRadians(6*M));
        double by = B*Math.sin(Math.toRadians(6*M));

        double ans = Math.sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));

        os.println(ans);
    }


}

Measured memory_bytes: 27188
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX
#define NUM 26

#define p1 first
#define p2 second
#define y1 first.first
#define y2 second.first
#define x1 first.second
#define x2 second.second

bool check(vector<string> &C, pair<pair<int,int>,pair<int,int>> &p){
	if(p.p1 == p.p2) return false;
	else if(p.x1 == p.x2) {
		if(p.y2-p.y1 <= 1) return false;
		for(int i = p.y1+1; i < p.y2; i++) if(C[i][p.x1] != '.') return false;
		return true;
	} else if(p.y1 == p.y2){
		if(p.x2-p.x1 <= 1) return false;
		for(int i = p.x1+1; i < p.x2; i++) if(C[p.y1][i] != '.') return false;
		return true;
	} else if(p.x1 < p.x2){
		bool flag = true;
		for(int i = p.y1+1; i <= p.y2; i++) if(C[i][p.x1] != '.') flag = false;
		for(int i = p.x1+1; i <  p.x2; i++) if(C[p.y2][i] != '.') flag = false;
		if(flag) return true;
		
		for(int i = p.x1+1; i <=  p.x2; i++) if(C[p.y1][i] != '.') return false;
		for(int i = p.y1+1; i < p.y2; i++) if(C[i][p.x2] != '.')   return false;
		
		return true;
	} else {
		bool flag = true;
		for(int i = p.y1+1; i <= p.y2; i++) if(C[i][p.x1] != '.') flag = false;
		for(int i = p.x2+1; i <  p.x1; i++) if(C[p.y2][i] != '.') flag = false;
		if(flag) return true;
		
		for(int i = p.x2; i <  p.x1; i++) if(C[p.y1][i] != '.') return false;
		for(int i = p.y1+1; i < p.y2; i++) if(C[i][p.x2] != '.')   return false;
		
		return true;
	}
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	int ans = 0;
	int M, N;
	bool hoge[NUM] = {};
	vector<string> C;
	pair<pair<int,int>,pair<int,int>> point[NUM];
	
	cin>>M>>N;
	
	C.resize(M);
	
	for(int i = 0; i < M; i++){
		cin>>C[i];
		for(int j = 0; j < N; j++){
			if(C[i][j] != '.'){
				// cout<<i<<" "<<j<<" "<<C[i][j]<<endl;
				hoge[C[i][j] - 'A'] = true;
				if(point[C[i][j] - 'A'].second.first == -1){
					point[C[i][j] - 'A'].second.first  = i;
					point[C[i][j] - 'A'].second.second = j;
				} else {
					point[C[i][j] - 'A'].first.first  = i;
					point[C[i][j] - 'A'].first.second = j;
					point[C[i][j] - 'A'].second.first = -1;
				}
			}
		}
	}
	
	for(int i = 0; i < NUM; i++){
		if(!hoge[i]) continue;
		if(point[i].p1 > point[i].p2) swap(point[i].p1, point[i].p2);
		// cout<<i<<" "<<point[i].y1<<" "<<point[i].x1<<"  "<<point[i].y2<<" "<<point[i].x2<<endl;
	}
	
	while(true){
		bool flag = false;
		for(int i = 0; i < NUM; i++){
			if(!hoge[i]) continue;
			if(check(C,point[i])){
				flag = true;
				hoge[i] = false;
				C[point[i].y1][point[i].x1] = '.';
				C[point[i].y2][point[i].x2] = '.';
				ans += 2;
			}
		}
		if(!flag) break;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

  int n,c1,c2,a1,a2,result,i,j,k;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    scanf("%d %d %d %d",&c1,&c2,&a1,&a2);

    if(a1 >= 5 && a2 >= 2){

      printf("%d\n",(c1*a1+c2*a2)*4/5);

    } else if(a1 < 5 && a2 < 2 && c1*a1+c2*a2 > (c1*5+c2*2)*4/5){

        printf("%d\n",(c1*5+c2*2)*4/5);

    } else if(a1 < 5 && a2 >= 2 && c1*a1+c2*a2 > (c1*5+c2*a2)*4/5){

        printf("%d\n",(c1*5+c2*a2)*4/5);

    } else if(a1 >= 5 && a2 < 2 && c1*a1+c2*a2 > (c1*a1+c2*2)*4/5){

        printf("%d\n",(c1*a1+c2*2)*4/5);

    } else {

    printf("%d\n",c1*a1+c2*a2);

    }

  }

  return 0;

}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
LL lcm(LL a, LL b) {
	return a / gcd(a, b) * b;
}

void solve() {
	LL N, M;
	cin >> N >> M;

	int SF = -1;
	vector<LL> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		int cnt = 0;
		while (A[i] % 2 == 0) {
			++cnt;
			A[i] /= 2;
		}

		if (SF == -1) {
			SF = cnt;
		}
		else if(SF != cnt){
			cout << 0 << endl;
			return;
		}
	}
	
	
	LL res = A[0];
	for (int i = 1; i < N; ++i) {
		res = lcm(res, A[i]);
		if (res > M || res < 0) {
			cout << 0 << endl;//関係ない
			return;
		}
	}
	res <<= (SF-1);
	LL ter = (M / res) - (M / (res * 2));
	cout << ter << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 1024
n,w=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]

dp=[[0]*(w+1) for _ in range(n+1)]
#dp:=i番目以降の商品から重さの総和がj以下となるように選んだ時の価値の総和の最大

#初期条件 dpｗｐ0で作ってるのでいらない
for j in range(w):dp[n][j] = 0

#漸化式
#dp[i][j] = dp[i+1][j] (j < w[i])
#           max(dp[i+1][j] , dp[i+1][j-w[i]]+v[i]) (otherwise)
for i in reversed(range(n)):
    for  j in range(w+1):
        if j < l[i][0]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j] , dp[i+1][j - l[i][0]] + l[i][1] )

print(dp[0][w])

Measured memory_bytes: 120300
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int sum = 0;
		int l = 0;
		for(i=0;i<n;i++) {
			l = parseInt(sc.next());
			sum += parseInt(sc.next()) - l + 1;
		}
		sc.close();
		out.println(sum);
	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='o')cnt++;
    }
    int rem = 15-s.size();
    if(cnt+rem>=8)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
ll N;
ll arr[10000];
int main(){
    cin>>N;
    for(int i = 0;i<N;i++) scanf("%lld",&arr[i]);
    ll res = 2e9;
    for(int i = 1;i<=100;i++){
        ll cur = 0;
        for(int j = 0;j<N;j++){
            cur += (arr[j]-i)*(arr[j]-i);
        }
        res = min(cur,res);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 888
from collections import defaultdict

def gets():
  return list(map(int, input().split()))

N, K = gets()
A = gets()

S = [0] * (N + 1)
for i in range(N):
  S[i + 1] = (S[i] + A[i] - 1) % K

cnt = defaultdict(int)
ans = 0
cnt[0] += 1
for i in range(1, N+1):
  if i - K >= 0:
    cnt[S[i - K]] -= 1
  ans += cnt[S[i]]
  cnt[S[i]] += 1

print(ans)


Measured memory_bytes: 111564
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    t = 0
    for k in range(d): t += abs(x[i][k] - x[j][k])**2
    t **= 0.5
    if t.is_integer(): ans += 1
print(ans)

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N, ans=0;
	int p[100005];

	cin >> N;
	rep(i,N) cin >> p[i];
	rep(i,N) p[i]--;

	rep(i,N) if( p[i] == i ){
		swap(p[i], p[i+1]);
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640