akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int partition(int A[], int p, int r){

	int x = A[r];
	int i = p-1;
	int j, temp;
	for (j=p; j<r; j++){
		if(A[j] <= x){
			i++;
			temp = A[i];
			A[i] = A[j];
			A[j] = temp;
		}
	}
	temp = A[i+1];
	A[i+1] = A[r];
	A[r] = temp;

	return i+1;

}

int main(){

	int n, i, base;
	int A[100000];

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

	base = partition(A, 0, n-1);

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

	return 0;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,k,i,ans=0;
  string s;
  cin>>n>>k>>s;
  for(i=0;i<n;i++){
    if(i>0 && s.at(i-1)==s.at(i) && s.at(i)=='L') ans++;
    else if(i<n-1 && s.at(i+1)==s.at(i) && s.at(i)=='R') ans++;
  }
  ans=min(ans+2*k,n-1);
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

int main(void){
	int n,p[123456],i,ans=0;
	cin >> n;
	for(i=1; i<=n; ++i){
		cin >> p[i];
	}
	for(i=1; i<n; ++i){
		if(p[i] == i){
			ans++;
			swap(p[i],p[i+1]);
		}
	}
	if(p[n] == n){
		ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
fn main(){
  loop {
    let n: usize = read();

    if n == 0 { break; }

    let mut vsc: Vec<Vec<usize>> = vec![vec![];31];

    for i in 0 .. n {
      let vt: Vec<usize> = read_vec();

      for j in 1 .. vt.len() {
        vsc[vt[j]].push(i);
      }
    }

    let ans: i32 = solve(n, &vsc);
    println!("{}", ans);
  }
}

fn solve(n: usize, vsc: &Vec<Vec<usize>>) -> i32 {
  let mut vst: Vec<u64> = (0 .. n).map(|i| 1 << i).collect();
  let gat: u64 = 2u64.pow(n as u32) - 1;

  let mut d: usize = 1;
  let ret: i32;
  
  loop {
    if d == 31 { ret = -1; break; }

    let mut t: u64 = 0;
    
    for s in &vsc[d] {
      t |= vst[*s];
    }

    for s in &vsc[d] {
      vst[*s] = t;
    }
    
    if (0..n).any(|i| vst[i] == gat) { ret = d as i32; break; }
    
    d += 1;
  }
  
  ret
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int p,q,r;
string s;
signed main() {
    cin >> p >> q >> r;
    int a[3];
    a[0] = p;
    a[1] = q;
    a[2] = r;
    sort(a,a+3);
    int ans = a[0] + a[1];
    cout << ans << endl;
}

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


int main(){
  int n,x,a=0,an=0,ans=0;
  cin >>n>>x;
  for(int i=1;i<=n;i++){
    int mi;
    cin >> mi;
    an +=mi;
    if(i==1){
      a = mi;
    }
    if(mi<a){
      a=mi;
    }
  }

  ans = n+(x-an)/a;

  cout << ans <<endl;

}

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

struct card
{
	card(const card&a) {
		mark = a.mark;
		num = a.num;
	}
	card(const char* str)
	{
		*this = str;
	}
	card() {}

	char mark;
	int	num;

	void operator = (const char * str) {
		mark = str[0];
		num = str[1] - 0x30;
	}
	bool operator < ( const card & right)const {
		return num < right.num;
	}


};

template<typename T>
int bubbleSort(list<T>&arr, int n) {
	int cunt = 0;
	bool cont = true;
	while (cont)
	{
		typename	list<T>::iterator it1 = arr.begin(), it2 = arr.begin();
		advance(it2, 1);
		cont = false;
		for (int i = 1; i < n; ++i, advance(it1, 1), advance(it2, 1))
		{
			if ( *it2 < *it1 ) {
				swap(*it1, *it2);
				cont = true;
				cunt++;
			}
		}
	}
	return cunt;
}
//template int bubbleSort(list<int>&arr, int n);

template <typename T>
int selectionSort(list<T>& arr, int n) {
	int cunt = 0;
	typename list<T>::iterator it1, it2, min, itend = arr.end();
	for (it1 = arr.begin(); it1 != itend; advance(it1, 1))
	{
		min = it1;
		for (it2 = next(it1); it2 != itend; advance(it2, 1))
		{
			if (*it2 < *min)
				min = it2;
		}
		if (it1 != min) {
			cunt++;
			swap(*it1, *min);
		}
	}
	return cunt;	
}

void listPrint(list<int>& arr) {
	list<int>::iterator it = arr.begin(),itend = arr.end();
	cout << *it;
	advance(it, 1);
	for (; it != itend; advance(it, 1))
		cout << " " << *it;
	cout << endl;
}

#ifdef D
int main(void)
{
	int n;
	cin >> n;
	list<card> arr1, arr2;
	char str[3];
	for (int i = 0 ; i< n; ++i)
	{
		cin >> str;
		card c(str);
		arr1.push_back(c);
		arr2.push_back(c);
	}

	return 0;
}
#endif // D

#ifdef B
int main(void)
{
	int n;
	cin >> n;
	list<int> arr(n);
	for (auto &a : arr)
		cin >> a;
	int cunt = selectionSort(arr,n);
	listPrint(arr);
	cout <<  cunt << endl;
	return 0;
}
#endif // B

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define si set<int>
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define sq(x) ((x) * (x))
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    str s;
    cin >> s;
    int sum = 0;
    for (char c : s)
        sum += c - '0';
    if (sum % 9)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    GAME_OVER;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	fastio();
	int n, m; cin >> n >> m;
	vector<bool> ac(n, 0);
	vector<int> was(n, 0);
	int p; string v;
	int score = 0, pen = 0;
	for(int i = 0; i<m; i++){
		cin >> p >> v; p--;
		if (ac[p]) continue;
		if (v == "WA") was[p]++;
		else if (v == "AC") ac[p] = true;
	}
	for(int i = 0; i<n; i++) if (ac[i]) score++, pen+= was[i];
	cout << score << " " << pen << "\n";
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long int A[100010],B[100010],IC[100010],n,m,p,judge[100010],ans,ss;

int main(){
    cin >> n >> m;
    cin >> ss;
    for(int i=1;i<m;i++){
        cin >> p;
        judge[min(ss,p)]++;
        judge[max(ss,p)]--;
        ss=p;
    }
      //for(int i=1;i<m;i++)cout << judge[i] << endl;

    ss=0;
    for(int i=1;i<n;i++)cin >> A[i] >> B[i] >> IC[i];

    for(int i=1;i<n;i++){
        ss+=judge[i];
        ans+=min(ss*A[i],IC[i]+B[i]*ss);
      //  printf("ans=%d\n",ans);
    }
    cout << ans << endl;

return 0;
}

Measured memory_bytes: 6216
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

#if __has_include(<string_view>)
#include <string_view>
#endif
#if __has_include(<optional>)
#include <optional>

template <class T>
constexpr const T& max(const T& a, const std::optional<T>& b)
{
    return b ? max(a, *b) : a;
}

template <class T>
constexpr const T& max(const std::optional<T>& a, const T& b)
{
    return a ? max(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& max(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a > *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

template <class T>
constexpr const T& min(const T& a, const std::optional<T>& b)
{
    return b ? min(a, *b) : a;
}

template <class T>
constexpr const T& min(const std::optional<T>& a, const T& b)
{
    return a ? min(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& min(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a < *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

#endif
#if __has_include(<any>)
#include <any>
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template <class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
istream& operator>>(istream& is, valarray<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

void solution()
{
    int x,n;
    cin >> x >> n;
    if(n == 0){
        cout << x << '\n';
        return;
    }
    unordered_set<int> ps;
    rep(i,n){
        int p;
        cin >> p;
        ps.insert(p);
    }
    rep(d,100){
        if(ps.find(x - d) == ps.end()){
            cout << x - d << '\n';
            break;
        }
        if(ps.find(x + d) == ps.end()){
            cout << x + d << '\n';
            break;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 3656
import java.util.*;
import java.math.BigInteger;

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

        String S = sc.next();
        BigInteger N = new BigInteger(S);
        S = sc.next();
        BigInteger K = new BigInteger(S);
        sc.close();

        BigInteger min = N;
        BigInteger MONE = new BigInteger("-1");
        boolean f = true;
        N = N.remainder(K);
        min = N;
        while(f){
            N = N.subtract(K);
            if(N.compareTo(BigInteger.ZERO) == -1)
                N = N.multiply(MONE);
            if(N.compareTo(min) == -1){
                min = N;
            }else{
                break;
            }
            if(min.compareTo(BigInteger.ZERO) == 0)
                break;
        }
        System.out.println(min.toString());
    }
}

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

int main(){
 long long int N=0,M=0,ans,amari,sec;
 cin>>N>>M;
 
 if(N>M/2){
 	ans=M/2;
 }else{
 	ans=N;
 }
 
 amari=M-(ans*2);
 sec=amari/4;
 
 cout<<ans+sec<<endl;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<array>
using namespace std;
int main(){
int A[3],ans=0,N=3;
for (int i = 0; i < 3; i++) {
  cin>>A[i];
}
sort(A,A+N);
for (int i = 1; i <3; i++) {
  ans=ans+A[i]-A[i-1];
}
cout<<ans<<endl;












}


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

int main(){
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= K; y++){
      int z = S - (x + y);
      if(not(0 <= z and z <= K)) continue;
      else ans++;      
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long n, m, ans = 0;
    cin >> n >> m;
    for(long long i = 1; i * i <= m; i++)
    {
        if(m % i == 0)
        {
            if(m >= n * i)
            {
                ans = max(ans, i);
            }
            if(m >= n * (m / i))
            {
                ans = max(ans, m / i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
    int a,b,c,i,x=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
	    if(c%i==0){
		    x=x+1; 
		}    
    }
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long a = sc.nextLong();
		String b = sc.next();
		BigDecimal x = new BigDecimal(a);
		BigDecimal y = new BigDecimal(b);
		BigDecimal q = x.multiply(y);
		BigDecimal ans = q.setScale(0, BigDecimal.ROUND_DOWN);
		System.out.println(ans);
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 33288
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string s, t;
    cin >> s >> t;

    int N = (int) s.size();
    int M = (int) t.size();

    int dp[N + 1][M + 1];
    fill(dp[0], dp[N+1], 0);

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    string revret = "";
    int i = N;
    int j = M;
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j-1] + 1 && s[i-1] == t[j-1]) {
            revret += s[i-1];
            i--; j--;
        } else {
            if (dp[i][j] == dp[i][j-1]) {
                j--;
            } else {
                i--;
            }
        }
    }

    reverse(revret.begin(), revret.end());
    cout << revret << endl;

    return 0;
}

Measured memory_bytes: 70656
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll k, x;
    cin >> k >> x;
    for (ll i = max(-N, x - k + 1); i < min(x + k, N + 1); i++)
        cout << i << " ";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b;

signed main() {
	cin >> a >> b;
	cout << max({ a + b,a - b,a*b }) << endl;
}

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

const int maxn=200010;
LL a[maxn],sum[maxn];
int n;
LL ans=0x3f3f3f3f;
LL minn1=0x3f3f3f3f;
LL maxe1=0;
LL minn2=0x3f3f3f3f;
LL maxe2=0;
LL Max(LL a,LL b,LL c,LL d)
{
    return max(max(a,b),max(c,d));
}
LL Min(LL a,LL b,LL c,LL d)
{
    return min(min(a,b),min(c,d));
}
void solve(int L,int R,int v)
{
    int l=L,r=R;
    if(l>r)return ;
    while(l+1<r){
        int mid=(l+r)>>1;
        if(sum[mid]-sum[L-1]>(sum[R]-sum[mid]))r=mid;
        else l=mid;
    }
    if(v==1){
        if(abs(sum[l]-sum[L-1]-(sum[R]-sum[l]))<abs(sum[r]-sum[L-1]-(sum[R]-sum[r]))){
            minn1=min(sum[l]-sum[L-1],sum[R]-sum[l]);
            maxe1=max(sum[l]-sum[L-1],sum[R]-sum[l]);
        }
        else{
            minn1=min(sum[r]-sum[L-1],sum[R]-sum[r]);
            maxe1=max(sum[r]-sum[L-1],sum[R]-sum[r]);
        }
    }
    else{
        if(abs(sum[l]-sum[L-1]-(sum[R]-sum[l]))<abs(sum[r]-sum[L-1]-(sum[R]-sum[r]))){
            minn2=min(sum[l]-sum[L-1],sum[R]-sum[l]);
            maxe2=max(sum[l]-sum[L-1],sum[R]-sum[l]);
        }
        else{
            minn2=min(sum[r]-sum[L-1],sum[R]-sum[r]);
            maxe2=max(sum[r]-sum[L-1],sum[R]-sum[r]);
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    for(int i=1;i<=n;i++){
        if(i<2||n-i<2)continue;
        minn1=0x3f3f3f3f;
        maxe1=0;
        minn2=0x3f3f3f3f;
        maxe2=0;
        solve(1,i,1);
        solve(i+1,n,0);
        ans=min(ans,Max(maxe1,maxe2,minn1,minn2)-Min(maxe1,maxe2,minn1,minn2));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <ctime>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=400010, Mod=998244353;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int n;
signed main()
{
	int res; n=read(); res=0;
	for(ri int i=2;i*i<=n;i++)
	{
		if(n%i) continue;
		int p=0, q=1;
		while(!(n%i))
		{
			n/=i; p++;
			if(p==q) res++, q++, p=0;
		}
	}
	printf("%lld\n",res+(n>1));
	return 0;
}

Measured memory_bytes: 3764
number = gets.chomp.split('')
count = 0
number.each_with_index do |n, i|
  if n ==  "0" && n == number[i + 1]
    number[i+1] = "1"
    count += 1
  elsif n ==  "1" && n == number[i + 1]
    number[i+1] = "0"
    count += 1
  end
end
p count

Measured memory_bytes: 11900
N = int(input())
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))
 
ans = sum(B)
tmp = A[0]
for i in range(1, len(A)):
  if A[i] == tmp + 1:
    ans += C[A[i]-2]
  tmp = A[i]
print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {

    static int n;
    static int[] a = new int[20];

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int[] m = new int[q];
        for (int i = 0; i < q; i++) {
            m[i] = sc.nextInt();
        }

        for (int i : m) {
            System.out.println(solve(0, i) ? "yes" : "no");
        }
    }

    static boolean solve(int i, int m) {
        if (m == 0) return true;
        if (i >= n) return false;
        return solve(i + 1, m) || solve(i + 1, m - a[i]);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

set<string> data;
char *ans[1000000];
int num = 0;

int main() {
    int n;
    string a,b;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (a == "insert") {
            data.insert(b);
        }
        else if (a == "find") {
            if (data.find(b) == data.end())
                ans[num] = "no";
            else
                ans[num] = "yes";
            num++;
        }
    }
    for (int i = 0; i < num; i++)
        cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 34708
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
ll ans1,ans2,ans;
const int sz=1e5+10;
char s[sz];
void solve()
{
    const ll n=strlen(s+1);
    ans1=ans2=n;
    for(ll i=1;i<=n;i++)
    {
        if(s[i]=='1')ans1=min(ans1,max(n-i,i-1));
        if(s[i]=='0')ans2=min(ans2,max(n-i,i-1));
    }
    ans=max(ans1,ans2);
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    scanf("%s",s+1);
    solve();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
N,M = map(int,input().split())

def dist(ab,cd):
  return abs(ab[0]-cd[0]) + abs(ab[1]-cd[1])

AB = [[int(x) for x in input().split()] for _ in range(N)]
CD = [[int(x) for x in input().split()] for _ in range(M)]

answer = []
for ab in AB:
  min_dist = 10**15
  target = 0
  for j,cd in enumerate(CD,1):
    x = dist(ab,cd)
    if min_dist > x:
      min_dist = x
      target = j
  answer.append(target)

print(*answer, sep='\n')

Measured memory_bytes: 3064
x1, y1, x2, y2 = map(int, input().split())

a = x2 - x1
b = y2 - y1

# print(- (y1 - y2) + x1 x1 - x2 + y2, y2 - y1 + x1, -(x2 - x1) + y1)
print(- y2 + y1 + x2, x2 - x1 + y2, - (y2 - y1) + x1, -x1 + x2 + y1)

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

int main(){
	long long int n,ans=LLONG_MAX;
  	cin >> n;
  	for (int i=1;i<=pow(n,0.5);i++){
      if(n%i==0){
        long long int k=n/i,l=i,kc=0,lc=0;
        while(k>0){
          k/=10;
          kc++;
        }
        while(l>0){
          l/=10;
          lc++;
        }
       ans=min(ans,max(kc,lc));
      }
    }
  cout <<ans<<endl;
  	
}

Measured memory_bytes: 256
B[]={18680908,19120730,19261225,19890108};char*F=" %d %d %d\n\0pre-meiji\0 taisho\0showa\0 heisei";y,m,d,e;main(){for(;~scanf(F,&y,&m,&d);e?printf(F,y-B[e-1]/10000+1,m,d,printf(F+e*7+8)):puts(F+11))for(e=0;e<4&&y*10000+m*100+d>=B[e];e++);}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
using namespace std;

#define DEBUG_MSG_off

static int N;
static queue<int> st;
static priority_queue<double,vector<double>,greater<double>> pque;

int main() {
  cin >> N;
  for(int i=0;i<N;++i) {
    double tmp; cin >> tmp;
    pque.push(tmp);
  }

  while(pque.size()>1) {
    double tmp1 = pque.top();
    pque.pop();
    double tmp2 = pque.top();
    pque.pop();
    double tmp3 = (tmp1+tmp2)/2;
    //cerr << "tmp3=" << tmp3 << "\n";
    pque.push(tmp3);
  }
  cout << pque.top() << "\n";

#ifdef DEBUG_MSG
  cerr << N << "\n";
  //for(auto s: st) cerr << s << "\n"; 
#endif
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
	}
	ll ans=0,pre=0;
	rep(i,n){
		if(a[i]==pre+1){
			pre++;
		}else if(a[i]>pre+1){
			ans+=a[i]/(pre+1);
			if(a[i]%(pre+1)==0){
				ans--;
			}
		}
		if(i==0) pre=1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
/*
/ ATcoder /
ID : lalit kumar
TASK : A
LANG : c++14
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{

ll a,b,k;
cin>>a>>b>>k;
if(k>(b-a)+1)
{
    for(int i = a;i<=b;i++)
    {
        cout<<i<<endl;
    }
   return 0 ;
}
set<ll> s;
for(int i =a;i<a+k;i++) s.insert(i);
for(int i = b;i>b-k;i--) s.insert(i);
for(auto x:s) if(x>0) cout<<x<<endl;

 return 0;

}

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

int main(){
    string s;
    int a,b,c;
    cin >> s;
    string str[] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    for(int i = 0; i < 9; i++){
        if(s == str[i]){
            cout << i+1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
	char c;
	int sum{};
	while (std::cin >> c)
		if (c >= '0' && c <= '9') sum += c - '0';
	if (sum % 9 == 0) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

	return 0;
}

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

int main()
{
    int n, d;
    std::cin >> n >> d;
    int x, y, cnt = 0;
    for (register int i = 0; i < n; ++i)
    {
        std::cin >> x >> y;
        cnt += 1ll * x * x + 1ll * y * y <= 1ll * d * d;
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 3620
main=do
 n<-readLn :: IO Int
 s<-map read.words<$>getLine :: IO [Int]
 let p=replicate n s
 let q=zip [1..n] s
 print$length$filter (==0) (zipWith (\x y->if fst y==1 then 0 else if maximum (take (fst y-1) x) <= snd y then 0 else 1) p q)

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

//Longest path in DAG
vector<vector<int>> adj(100010);
int id[100010], dp[100010];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--,v--;
        adj[u].push_back(v);
        id[v]++;
    }
    queue<int> Q;
    for(int i = 0; i < n; i++) if (!id[i]) Q.push(i);
    while(!Q.empty()) {
        int u = Q.front(); Q.pop();
        for(auto v : adj[u]) {
            id[v]--;
            dp[v] = max(dp[v], dp[u] + 1);
            if (!id[v]) Q.push(v);
        }
    }
    cout << *max_element(dp, dp + n) << "\n";
    return 0;
}


Measured memory_bytes: 6528
N,K =map(int,input().split())
R,S,P = map(int,input().split())
T = input()

def score(T):
    sa = 0
    x = 0
    for i in range(len(T)):
        if x == 1 and T[i] == T[i-1] :
            if T[i] == "r":
                sa += P
                x = 0
            elif T[i] == "s":
                sa += R
                x = 0
            elif T[i] == "p":
                sa += S
                x = 0
            
        elif i > 0 and T[i] == T[i-1] :
            x = 1
        elif T[i] == "r":
            sa += P
            x = 0
        elif T[i] == "s":
            sa += R
            x = 0
        elif T[i] == "p":
            sa += S
            x = 0
    return sa
ans = 0
for k in range(K):
    ans += score(T[k::K])

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, C; cin >> A >> B >> C;

    cout << min(C, B / A) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
using namespace std;

int n,k;
int a[111111];
signed main(){
    cin>>n;
	bool flag=1;
  	rep(i,n){
		int b;
      	cin>>b;
      	if(b%2==1)flag=0;
    }
  	if(flag)cout<<"second"<<endl;
  	else cout<<"first"<<endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

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

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

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

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

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

struct Shop {
    int money;
    int stock;
    Shop(int m, int s) : money(m), stock(s) {}
    bool operator<(const Shop& os) const {
        return (money < os.money);
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vector<Shop> sl;
    rep(i, n) sl.pb(Shop(a[i], b[i]));
    VSORT(sl);
    ll ans = 0;
    rep(i, n) {
        int buy = min(m, sl[i].stock);
        ans += (ll)buy * sl[i].money;
        m -= buy;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
#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 <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 MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

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

int main(){
	int a;
	string s;
	char c;
	cin>>a;
	//cin>>c;
	FOR(j,0,a){
		cin>>c;
		//cout<<j<<" "<<c<<endl;
		if(c=='Y'){
			cout<<"Four"<<endl;
			return 0;
		}
		//if(j!=a-1)cin>>c;
	}
	cout<<"Three"<<endl;

    return 0;
}


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

int main()
{
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(b-a <= k && c-a <= k && d-a <= k && e-a <= k && c-b <= k && d-b <= k && e-b <= k && d-c <= k && e-c <= k && e-d <= k){
        cout << "Yay!" << endl;
    }else{
        cout<< ":(" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long t,n,x,y,k;
    cin >> x >> n;
    if(n==0)
    {   cout << x <<endl;
        return 0;
    }
    int a[n];
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
    }
    sort(a,a+n);
    int d,c;
    for(int j=x;j<103;j++)
    {
        if(m[j]==0)
        {
            d=j;
            break;
        }
    }
    for(int j=x;j>=-1;j--)
    {
        if(m[j]==0)
        {
            c=j;
            break;
        }
    }
    if(abs(c-x)>abs(d-x))
    {
        c=d;
    }
    cout << c <<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int a[100020];
int main ()
{
	long long  n,m;
	while(scanf("%lld%lld",&n,&m)!=EOF)
	{
		if(m-n<-1||m-n>1)
		{
			printf("0\n");
		}
		else
		{
			long long c=1,t=1000000007,k=1,i;
			if(m==n)
				c++;
			for(i=1;i<=m;i++)
				k=k*i%t;
			for(i=1;i<=n;i++)
				k=k*i%t;
			printf("%lld\n",k*c%t);
		}
	}
} 

Measured memory_bytes: 128
// AOJ 2589: North North West
// 2017.10.5 bal4u@uu

#include <stdio.h>
#include <string.h>

char buf[205];

long long gcd(long long a, long long b)
{
	long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

void add(long long *si, long long *bo, int a, int b)
{
	long long m, n, g;
	m = *si, n = *bo;
	*si = m*b + n*a;
	*bo = b*n;
	g = gcd(*si, *bo);
	if (g > 1) *si /= g, *bo /= g;
}

int main()
{
	int k;
	long long bo, si;
	char *p;

	while (scanf("%s", buf) && *buf != '#') {
		p = buf + strlen(buf) - 1, k = 1; si = 0, bo = 1;
		while (p >= buf) {
			if (*p == 'n') {
				if (k == 1) k++;
				else add(&si, &bo, -90, k), k <<= 1;
			} else if (*p == 'w') {
				if (k == 1) si = 90, k++;
				else add(&si, &bo, 90, k), k <<= 1;
			}
			p--;
		}
		if (bo == 1) printf("%lld\n", si);
		else printf("%lld/%lld\n", si, bo);
	}
	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D){
   cout << "Left" << endl; 
  }
  else if(A + B < C + D){
    cout << "Right" << endl;
  }
  else{
  cout << "Balanced" << endl;
  }
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  double a, b, x;
  cin >> a >> b >> x;

  // atan2(h, x)
  // h = 2 * x / (a * b);
  double h = (double)x * 2 / a / b;

  // For Debug
  // cout << "h: " << h << endl;
  // cout << "b: " << b << endl;

  // double theta = atan2(h, b);
  // theta = theta * 180 / M_PI;
  // double ans = (double)90.0 - theta;
  if (h <= a) {
    double ans = atan2(b, h) * 180 / M_PI;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
  } else {
    double K = (double)x * 2 / a / a - b;
    double ans = atan2(b-K, a) * 180 / M_PI;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin>>k;
  int ans = 0;
  for(int i=1; i<=k; i++)
    for(int j=1; j<=k; j++)
      for(int l=1; l<=k; l++)
        ans += __gcd(i, __gcd(j, l));
  cout<<ans<<"\n";
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  pair<int, int> mx{0, 0};
  int n; cin >> n;
  vector<int> ar(n);
  for(int &x: ar) {
    cin >> x;
    if(x > mx.first) {
      mx = {x, mx.first};
    } else if(x > mx.second) {
      mx.second = x;
    }
  }
  for(int x: ar) {
    if(mx.first == x) {
      cout << mx.second << '\n';
    } else {
      cout << mx.first << '\n';
    } 
  }
  cout << '\n';
  return 0;
}


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

struct edge {
  int to;
  int cost;
};

int main() {
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> town(R);
  rep(i,R) {
    int r;
    cin >> r;
    --r;
    town[i] = r;
  }
  sort(town.begin(), town.end());
  
  vector<vector<edge>> G(N);
  rep(i,M) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;  // 0-indexed
    G[a].push_back(edge{b,c});
    G[b].push_back(edge{a,c});
  }

  /* dijkstra */
  Graph d(N, vector<int>(N, INFTY));
  rep(i,N) {
    d[i][i] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0,i));
    while (!que.empty()) {
      auto p = que.top();
      que.pop();
      int &v = p.second;
      if (d[i][v] < p.first) continue;
      for (auto e : G[v]) {
        if (d[i][v] + e.cost < d[i][e.to]) {
          d[i][e.to] = d[i][v] + e.cost;
          que.push(P(d[i][e.to], e.to));
        }
      }
    }
  }

  int ans = INFTY;
  do {
    int sum = 0;
    rep(i,R-1) {
      sum += d[town[i]][town[i+1]];
    }
    if (sum < ans) ans = sum;
  } while (next_permutation(town.begin(), town.end()));

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define endl "\n"
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int main() {
    io;

    ll n;
    cin>>n;
    ll arr[n+1]={0};
    rep(i,1,n+1) cin>>arr[i];
    ll dp[n+1]={0};
    dp[2] = abs(arr[2] - arr[1]);

    rep(i,3,n+1){
        dp[i] = min(abs(arr[i]-arr[i-2])+dp[i-2],dp[i-1]+abs(arr[i]-arr[i-1]));
    }
    // rep(i,1,n+1)
    cout<<dp[n]<<endl;

 
 
 
    
 
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        String postnumber = sc.next();
        
        
        Pattern pattern = Pattern.compile("^[0-9]{"+x+"}-[0-9]{"+y+"}$");
        Matcher matcher = pattern.matcher(postnumber);
        
        if(matcher.find()){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
    }
}


Measured memory_bytes: 39192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int n,m;
struct data{
	int c,t;
	friend bool operator < (const data &a,const data &b){
		return a.t<b.t;
	}
}dp[N][11];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=y<x?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace G{
	int cnt,fir[N];
	struct edge{
		int to,nx;
	}eg[N<<1];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	void solve(){
		for(int d=10; d; --d){
			for(int i=1; i<=n; ++i){
				for(int j=fir[i]; j; j=eg[j].nx){
					const int y=eg[j].to;
					apx(dp[y][d-1],dp[i][d]);
				}
			}
		}
	}
}

int main(){
#ifdef LOCAL
	freopen("paint.in","r",stdin);
	freopen("paint.out","w",stdout);
#endif
	n=nxi(),m=nxi();
	for(int i=1; i<=m; ++i){
		const int a=nxi(),b=nxi();
		G::add(a,b);
		G::add(b,a);
	}
	for(int q=nxi(),i=1; i<=q; ++i){
		const int x=nxi(),d=nxi(),c=nxi();
		apx(dp[x][d],(data){c,i});
	}
	G::solve();
	for(int i=1; i<=n; ++i){
		data res=(data){0,0};
		for(int j=0; j<=10; ++j){
			apx(res,dp[i][j]);
		}
		printf("%d\n",res.c);
	}
	return 0;
}


Measured memory_bytes: 11136
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

            System.out.println(IntStream.range(1, N + 1).filter(i -> String.valueOf(i).length() % 2 == 1).count());
        }
    }

}


Measured memory_bytes: 31188
#include <stdio.h>

#define N 10000
#define NIL -1

int linearSearch(int *, int, int);

int main() {

  int s[N];
  int t[N];
  int n, q;
  int cnt = 0;
  int i;

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

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }

  for (i = 0; i < q; i++) {
    if(linearSearch(s, n, t[i]) != NIL){
      cnt++;
    }
  }
  printf("%d\n", cnt);
  
  return 0;
}


int linearSearch(int s[], int n, int k) {
  int i;
  for (i = 0; i < n; i++) {
    if(s[i] == k) {
      return i;
    }
  }
  return NIL;
}



Measured memory_bytes: 2108