akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        char[] s=fsc.next().toCharArray();
        int ans=0;
        for(int i=0;i<s.length-1;i++){
            if(s[i]!=s[i+1]) ans++;
        }
        System.out.println(ans);
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21588
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int N;
string S;

int main(){
    cin>>N>>S;

    int l=0, r=0;
    rep(i,N){
        if(S[i]=='(') l++;
        else if(l>0) l--;
        else r++;
    }

    string ans;
    rep(i,r) ans+='(';
    ans+=S;
    rep(i,l) ans+=')';

    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

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

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


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int Q;
    cin >> Q;
    bool era[100005] = {};
    rep(i,0,100005) era[i] = true;
    era[0] = era[1] = false;
    rep(i,2,100005){
        if(era[i]){
            for(int j = i * 2; j < 100005; j+= i){
                era[j] = false;
            }
        }
    }
    int nite[100005] = {};
    rep(i,3,100005){
        if(era[i] && era[(i+1)/2]) nite[i]++;
    }
    rep(i,0,100004){
        nite[i+1] += nite[i];
    }

    rep(i,0,Q){
        int l,r;
        cin >> l >> r;
        cout << nite[r] - nite[l-1] << endl;
    }



    return 0;
}


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

using namespace std;

int n, q;
int st[2000010];

void update(int l, int r, int pt, int val, int i){
    if(r < pt || pt < l) return;

    if(l == r && l == pt){
        st[i] = 1 << val;
        return;
    }

    int m = (l + r) >> 1;

    update(l, m, pt, val, i << 1);
    update(m + 1, r, pt, val, 1 + (i << 1));

    st[i] = st[i << 1] | st[1 + (i << 1)];
}

int query(int l, int r, int ls, int rs, int i){
    if(r < ls || rs < l) return 0;

    if(ls <= l && r <= rs) return st[i];

    int m = (l + r) >> 1;
    return query(l, m, ls, rs, i << 1) | query(m + 1, r, ls, rs, 1 + (i << 1));
}

int main(){
    scanf("%d", &n);

    for(int i = 1; i <= n; i++){
        char c; scanf(" %c", &c);

        update(1, n, i, c - int('a'), 1);
    }

    scanf("%d", &q);

    while(q--){
        int type;

        scanf("%d", &type);

        if(type == 1){
            int i; char c;

            scanf("%d %c", &i, &c);

            update(1, n, i, c - int('a'), 1);
        } else {
            int l, r;
            scanf("%d%d", &l, &r);

            printf("%d\n", __builtin_popcount(query(1, n, l, r, 1)));
        }
    }
    
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  vector<ll> cnt(5,0);

  int N;
  cin >> N;
  ll ans=0;
  REP(i,N){
    string s;
    cin >> s;
    switch(s[0]){
      case 'M':
        cnt[0]++;
        break;

      case 'A':
        cnt[1]++;
        break;

      case 'R':
        cnt[2]++;
        break;

      case 'C':
        cnt[3]++;
        break;

      case 'H':
        cnt[4]++;
        break;
    }
  }
  REP(i,5)FOR(j,i+1,5)FOR(k,j+1,5){
    ans += cnt[i]*cnt[j]*cnt[k];
//    cout << ans << endl;
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;

bool prime(int n){
  bool ret = true;
  if(n==1){
    return false;
  }
  for (int i=2; i*i<=n; i++){
    if(n%i==0){
      ret = false;
      break;
    }
  }
  return ret;
}


int main(){
	int q;
	cin>>q;
	//vector<P>l(q);
//	vector<int>r(q);

	vector<int>p(100005,0);
	vector<int>s(100005);
	rep(i,100005){
		if (prime(i) and prime((i+1)/2)) p[i]=1;
	}
	int cnt=0;
	rep(i,100001){
		if (p[i]==1)cnt++;
		s[i+1]=cnt;
	}


	rep(i,q){
		int l1,r1;
		cin>>l1>>r1;
		int ans=s[r1+1]-s[l1];
		cout<<ans<<endl;
	}
}


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

int main()
{
    int m; cin >> m;
int n;
n= m%10;

    if (n == 2|| n == 4 || n == 5 || n == 7 || n == 9)
    {
        cout << "hon" << endl;
    }else if(n == 3)
    {
        cout << "bon" << endl;
    }else
    {
        cout << "pon"<<endl;
    }
    
    
}

Measured memory_bytes: 3616
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

score = sum(b)
for i, j in zip(a[:-1], a[1:]):
    if j == i + 1:
        score += c[i-1]
print(score)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> Vlist = new ArrayList<Integer>();
		List<Integer> Wlist = new ArrayList<Integer>();
		int dp[][] = new int[101][10001];
		
		for (int i = 0; i < 101; i++) {
			Arrays.fill(dp[i], 0);
		}
		
		int N = in.nextInt();
		int W = in.nextInt();
		for (int i = 0; i < N; i++) {
			int vval = in.nextInt();
			int wval = in.nextInt();
			Vlist.add(vval);
			Wlist.add(wval);
		}
		
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j <= W; j++) {
				if (Wlist.get(i-1) > j) {
					dp[i][j] = dp[i-1][j];
				} else {
					dp[i][j] = Math.max(dp[i-1][j-Wlist.get(i-1)]+Vlist.get(i-1), dp[i-1][j]);
				}
			}
		}
		System.out.println(dp[N][W]);
	}
}



Measured memory_bytes: 31644
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    use std::cmp::min;

    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut pv = vec![0u32; n];
    for i in 0..n - 1 {
        pv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    pv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut rv = vec![0u32; n];
    let mut minp = pv[0];
    for i in 0..pv.len() {
        minp = min(minp, pv[i]);
        rv[i] = minp;
    }

    let mut ans = 0;
    for i in 0..pv.len() {
        if pv[i] <= rv[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int n,k;

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c>'9'||c<'0')&&c!='-')c=getchar();
   	if(c=='-')t=-1,c=getchar();
   	while(c>='0'&&c<='9')s=s*10+c-'0',c=getchar();
   	return s*t;
}

int main(void){
	scanf("%d %d",&n,&k);
	for(int i=k-n+1;i<=k+n-1;i++)
	printf("%d ",i);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
bool cmp(P a, P b)
{
	if(a.second == b.second) return a.second - a.first < b.second - b.first; 
	else                     return a.second < b.second;
}
int main()
{
	ios_base::sync_with_stdio(false);
	int a;
	cin >> a;
	P arr[a];
	for(int i=0; i<a; i++)
		cin >> arr[i].first >> arr[i].second;
	sort(arr, arr+a, cmp);
	int cur = 0, yes = 1;
	for(int i=0; i<a; i++)
	{
		cur += arr[i].first;
//		printf("%d %d %d\n",arr[i].first, arr[i].second, cur);
		if(cur > arr[i].second)
		{
			yes = 0;
			break;
		}
	}
	if(yes) printf("Yes");
	else    printf("No");
	printf("\n");
	return 0;
}

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

using namespace std;

int main()
{
	int N,ans=1,t=0;
	
	cin >> N;
	
	vector<pair<int,int>> v(N);
	
	for(int i=0;i<N;i++){
		cin >> v[i].second >> v[i].first;
	}
	
	sort(v.begin(),v.end());
	
	for(int i=0;i<N;i++){
		if((t + v[i].second) > v[i].first)ans = 0;
		else t += v[i].second;
	}
	
	if(ans == 0)cout << "No" << endl;
	else cout << "Yes" << endl;
	
	
	
	return 0;
}

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

using namespace std;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int k,a,b;cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3572
def main():
    n, k = tuple([int(e) for e in input().split()])
    arr = [int(e) for e in input().split()]
    t = [float('inf')] * (n + 1)
    t[0] = 0
    t[1] = 0 
    for i in range(2, n + 1):
        for j in range(1, k + 1):
            if i - j <= 0:
                break
            l1 = t[i - j] + abs(arr[i - j - 1] - arr[i - 1])
            t[i] = min(t[i], l1)
    print(t[n])
    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 54880
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int Q = in.nextInt();

        int[][] map = new int[n][n + 1];
        for (int i = 0; i < m; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt();
            map[l][r]++;
        }

        for (int i = 0; i < n; i++) {
            int tmp = 0;
            for (int j = 0; j <= n; j++) {
                map[i][j] += tmp;
                tmp = map[i][j];
            }
        }

        for (int i = 0; i < Q; i++) {
            int p = in.nextInt() - 1;
            int q = in.nextInt();
            int ans = 0;
            for (int j = p; j < q; j++) {
                ans += map[j][q] - map[j][p];
            }
            out.println(ans);
        }
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

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

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

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

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 89348
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 1e5+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[maxn];
int main(){
	n=read();k=read();m=read();
	for(register int i=1;i<=m;i++){
		int x=read();
		a[x]++;
	}
	for(register int i=1;i<=n;i++){
		if(k>m-a[i])puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
  int x, a, b;
  scanf("%d %d %d", &x, &a, &b);

  if (a >= b) printf("delicious\n");
  else if (a < b && b - a <= x) printf("safe\n");
  else printf("dangerous\n");

  return 0;
}

Measured memory_bytes: 128
# include "bits/stdc++.h"
using namespace std;
int n, h[101010], m[101010];
const int INF = INT_MAX;
int dp(int cur){
    if(m[cur] != -1)return m[cur];
    if(cur == 1)return m[cur] = 0;
    int ret = INF;
    if(cur - 1 >= 1)ret = min(ret, dp(cur - 1) + abs(h[cur] - h[cur - 1]));
    if(cur - 2 >= 1)ret = min(ret, dp(cur - 2) + abs(h[cur] - h[cur - 2]));
    return m[cur] = ret;
}
int main(){
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> h[i];
    for(int i = 1;i <= n;i++)m[i] = -1;
    cout << dp(n) << endl;
}




Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];

    if (N % 3 == 0)
    {
        int xorSum = 0;
        rep(i, 0, N)
        {
            xorSum ^= a[i];
        }

        cout << (xorSum == 0 ? "Yes" : "No") << endl;
    }
    else
    {
        const bool yes = [&]()
        {
            rep(i, 0, N)
            {
                if (a[i] != 0)
                {
                    return false;
                }
            }
            return true;
        }();

        cout << (yes ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 640
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int a, b, c, m;
  cin >> a >> b >> c >> m;
  int used = min(a, m);
  int64 ret = used;
  m -= used;
  used = min(b, m);
  m -= used;
  used = min(c, m);
  ret -= used;
  cout << ret << endl;
  return 0;
}


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

int main()
{
int n,an=INT_MAX,s;cin>>n;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
for(int k=-100;k<=100;k++)
{s=0;
	for(int i=0;i<n;i++)
	s+=(a[i]-k)*(a[i]-k);
	an=min(an,s);
}
cout<<an<<endl;


}



Measured memory_bytes: 3612
import sys
def inpl(): return [int(i) for i in input().split()]
N, A, B = inpl()
rev = (A < B)
B ,A = sorted([B, A])
if B < -(-N//A) or A+B-1 > N:
    print(-1)
    sys.exit()
st = list(range(1,N+1))
if B == 1:
    ans = st
elif 2*A > N:
    ans = st[A:N-B+1] + st[N-1:N-B:-1] + st[0:A]
else:
    n = N//A
    x = B+(-N//A)+1
    ans = st[n*A:N] + st[(n-1)*A:n*A-x] + st[n*A-1:n*A-x-1:-1]
    for i in range(2,n+1):
        ans += st[(n-i)*A:(n-i+1)*A]
if rev:
    ans = [N+1-i for i in ans]
print(*ans)

Measured memory_bytes: 33700
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 10;
int n, m, k[N], s[N][N], p[N], ans;
inline bool check(int x){
	for(Rint i = 0;i < m;i ++){
		int tmp = 0;
		for(Rint j = 0;j < k[i];j ++)
			tmp ^= ((x >> s[i][j]) & 1);
		if(tmp != p[i]) return false;
	}
	return true;
}
int main(){
	scanf("%d%d", &n, &m);
	for(Rint i = 0;i < m;i ++){
		scanf("%d", k + i);
		for(Rint j = 0;j < k[i];j ++)
			scanf("%d", s[i] + j), -- s[i][j];
	}
	for(Rint i = 0;i < m;i ++) scanf("%d", p + i);
	for(Rint i = 0;i < (1 << n);i ++)
		if(check(i)) ++ ans;
	printf("%d", ans);
}

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

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

  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  bool ok = true;
  for (int i = 0; i < n; ++i) {
    if (a[i] % 2 != 0)
      continue;
    if (a[i] % 3 != 0 && a[i] % 5 != 0)
      ok = false;
  }

  if (ok)
    puts("APPROVED");
  else
    puts("DENIED");
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    lint N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    sort(A,A+N);
    lint ans=N;
    lint cnt[100001]={};
    lint rem=0;
    rep(i,N) cnt[A[i]]++;
    rep(i,100001){
        if(cnt[i]>1){
            if(cnt[i]%2){
                ans-=cnt[i]-1;
            }
            else rem+=cnt[i]-1;
        }
    }
    if(rem%2) ans-=rem+1;
    else ans-=rem;
    cout << ans << endl;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1; i<n; i++){
        int tmp=ceil(n/i);
        if(tmp*i>=n) tmp--;
        ans+=tmp;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main(void){
    char s[105],t[105];
    cin>>s>>t;
    int N,M;
    N=strlen(s);
    M=strlen(t);
    sort(s,s+N);
    sort(t,t+M,greater<int>());
    int ans;
    ans=strcmp(s,t);
    if(ans<0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
int main(){
double a,b,c,d,e,f,x,y;
while(std::cin>>a>>b>>c>>d>>e>>f){
	x = (double)(b*f-c*e)/(b*d-a*e);
	y = (double)(f*a-d*c)/(a*e-b*d);
	printf("%.3f %.3f\n",x==-0.000?0.000:x, y==-0.000?0.000:y);
}
}

Measured memory_bytes: 1236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.sql.Array;
import java.util.*;

public class Main {

    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    static long lcm (long a, long b) {return a*b/gcd(a,b);}

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(),y=sc.nextLong();
        System.out.println(gcd(x,y));
    }
}



Measured memory_bytes: 26392
#include <stdio.h>
int main(){
	int r,c,sum,total_sum = 0;
	scanf("%d %d",&r,&c);
	int table[r+1][c+1];

	for(int i = 0; i < r+1; i++)
		for(int j = 0; j < c+1; j++) table[i][j] = 0;

	for(int i = 0; i < r; i++){
		sum = 0;
		for(int j = 0; j < c; j++){
			scanf("%d",&table[i][j]);
			sum += table[i][j];
			table[r][j] += table[i][j];
		}
		table[i][c] = sum;
		total_sum += sum;
	}
	table[r][c] = total_sum;

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c; j++){
			printf("%d ",table[i][j]);
		}
		printf("%d\n",table[i][c]);
	}
}




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

int main(){
  string sk[30][30];
  int H,W;
  cin >> H >> W ;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> sk[i][j];
      if(sk[i][j] == "snuke")
        printf("%c%d",j+'A',i+1);
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	int x[105];
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	sort(x,x+n);
	reverse(x,x+n);
	int alice = 0, bob = 0;
	for(int i = 0; i < n; i++){
		if(i % 2 == 0) alice += x[i];
		else bob += x[i];
	}
	cout << alice - bob;
}

Measured memory_bytes: 256
import math
result = 0
inp = []
N,D = map(int,input().split())
for i in range(N):
    inp.append(input().split())
for i in range(len(inp)):
    n = pow(int(inp[i][0]),2)+pow(int(inp[i][1]),2)
    cal = math.sqrt(n)
    if cal <= D:
        result +=1
print(result)

Measured memory_bytes: 67512
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}


void solve()
{
     string s1,s2;
     cin>>s1>>s2;
     int n=sz(s1),m=sz(s2);
     int mx=1e9;
     rep(i,0,n-m+1)
     {
        string str="";
        rep(j,i,i+m)
        {
            str+=s1[j];
        }
        int cnt=0;
        rep(j,0,sz(str))
        {
            if(s2[j]!=str[j])
                ++cnt;
        }
        mx=min(mx,cnt);
        
     }
     cout<<mx;

}

signed main()
{
        FIO
         
        
        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

Measured memory_bytes: 3792
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int kaidan[31];
	kaidan[0] = 1;
	kaidan[1] = 1;
	kaidan[2] = 2;
	for (int i = 3; i <= 30; i++) {
		kaidan[i] = kaidan[i - 1] + kaidan[i - 2] + kaidan[i - 3];
	}
	int n;
	while(cin >> n&&n)
	cout << (int)ceil(kaidan[n] / 3650.0) << endl;
	
	return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int dp[50] = {};
    dp[0] = dp[1] = 1;
    REP(i, 2, 50) dp[i] = dp[i-1] + dp[i-2];

    int N;
    cin >> N;
    cout << dp[N] << endl;

}

Measured memory_bytes: 3232
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
P pos[90000];
vector<ll> sum[90000];
 int main() {
	int H, W, D;
	cin >> H >> W >> D;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int A;
			cin >> A;
			A--;
			pos[A] = P(j, i);
		}
	}
	for (int i = 0; i < D; i++) {
		ll s = 0;
		sum[i].push_back(0);
		for (int j = i + D; j < H*W; j += D) {
			s += abs(pos[j - D].first - pos[j].first) + abs(pos[j - D].second - pos[j].second);
			sum[i].push_back(s);
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int L, R;
		cin >> L >> R;
		L--; R--;
		int m = L % D;
		cout << sum[m][R / D] - sum[m][L / D] << endl;
	}
}

Measured memory_bytes: 6016
N = int(input())

if N < 1000:
    num = str(N)
    if num[-1] == "3":
        print("bon")
    elif num[-1] in ["0", "1", "6", "8"]:
        print("pon")
    else:
        print("hon")
else:
    print("Please enter an interger between not exceeding 999")  

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int mx = 0, ans = 0;
    forn(i, 0, n) {
        int h;
        cin >> h;
        if (mx <= h) {
            mx = h;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto a = readln.chomp.split.to!(int[]);
  auto x = a[0] + a[1];
  auto y = a[0] * a[1];
  if (x == 15) writeln("+");
  else if (y == 15) writeln("*");
  else  writeln("x");
}


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

void solve()
{
	int r,g,b,k;
	cin>>r>>g>>b>>k;
	int q = 0;
	while(g<=r)
	{
		g *= 2;
		q++;
	}
	while(b<=g)
	{
		b *= 2;
		q++;
	}
	if(q<=k)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var primeFactors = Prime.PrimeFactors(N);
            if (primeFactors.Count() == 0)
                Console.Write(0);
            else
            {
                long res = 0;
                foreach(var p in primeFactors.Distinct())
                {
                    var num = primeFactors.Count(x => x == p) - 1;
                    var p_operationNum = 1;
                    for (int i = 2; num >= i; i++)
                    {
                        num -= i;
                        p_operationNum++;
                    }
                    res += p_operationNum;
                }
                Console.WriteLine(res);
            }
        }
    }

    public class Prime
    {
        //public static void Main()
        //{
        //    int n = int.Parse(Console.ReadLine());
        //    Console.WriteLine("{0} = {1}", n, string.Join(" x ", PrimeFactors(n)));
        //}

        public static IEnumerable<long> PrimeFactors(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }
    }

}



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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    int N = a[n-1];
    int i = lower_bound(a.begin(), a.end(), a[n-1]/2) - a.begin();
    if (i==n-1) i--;
    int K = a[i];
    if (i && N-a[i-1]<K)
        K = a[i-1];
    cout << N << ' ' << K;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int W, H;
int P[100111], Q[100111];

int main() {
    scanf("%d%d", &W, &H);
    REP (i, W) scanf("%d", P+i);
    REP (i, H) scanf("%d", Q+i);

    sort(P, P+W); sort(Q, Q+H);
    int pi = 0, qi = 0;
    
    LL ans =0;
    
    while (pi < W || qi < H) {
	if (pi == W || (qi < H && Q[qi] < P[pi])) {
	    ans += (LL)Q[qi] * (W - pi + 1);
	    qi++;
	} else {
	    ans += (LL)P[pi] * (H - qi + 1);
	    pi++;
	}
    }

    printf("%lld\n", ans);


    return 0;
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////


int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    ll n;cin>>n;
    set<ll>s;
    while(n--){
        ll k;cin>>k;s.insert(k);
    }
    
    cout<<s.size()<<endl;
    
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int n = 0; n < N; n++) {
		cin >> a.at(n);
	}
	for (int n = 0; n < N; n++) {
		for (int m = n + 1; m < N; m++) {
			if (a.at(n) < a.at(m)) {
				int t = a.at(n);
				a.at(n) = a.at(m);
				a.at(m) = t;
			}
		}
	}
	int answer = 0;
	for (int n = 0; n < N; n++) {
		if (n % 2 == 0) {
			answer += a.at(n);
		}
		else {
			answer -= a.at(n);
		}
	}
	cout << answer << endl;
}

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

const int maxN = 100010;
typedef long long ll;

ll A[maxN], L[maxN], R[maxN], B[maxN];

int main (){
	int n, i;
	ll ans = 1;
	scanf("%d", &n);
	for(i = 0; i <= n; ++i) scanf("%lld", A + i);
	for(i = n, L[n] = R[n] = 0; i; --i){
		L[i - 1] = (A[i] + L[i] + 1) / 2;
		R[i - 1] = A[i] + R[i];
	}
	if(L[0] + A[0] <= 1 && 1 <= R[0] + A[0]){
		R[0] = B[0] = 1;
		for(i = 1; i <= n; ++i){
			B[i] = B[i - 1] * 2;
			if(R[i] > R[i - 1] * 2 - A[i])
				R[i] = R[i - 1] * 2 - A[i];
			if(B[i] > R[i]) B[i] = R[i];
			ans += A[i] + B[i];
			//printf("%d : %lld\n", i, ans);
		}
		printf("%lld\n", ans);
	}
	else puts("-1");
	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
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)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

  vector<ll> a(n),b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];

  ll ans=0;
  for(int d = 32; d >= 0; --d){
    REP(i,n) a[i] %= (1LL << (d + 1));
    REP(i,n) b[i] %= (1LL << (d + 1));
    sort(all(a));
    sort(all(b));

    ll cnt = 0;
    ll cur = 1LL << d;
    REP(i,n){
      if(a[i] >= cur) cnt += lower_bound(all(b), 2*cur-a[i]) - b.begin() + n - (lower_bound(all(b), 3*cur-a[i]) - b.begin());
      else cnt += lower_bound(all(b), 2*cur-a[i])-lower_bound(all(b), cur-a[i]);
    }
    if(cnt % 2 == 1) ans += cur;
  }

  pl(ans)
  return 0;

}

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

int main()
{
	long long N, A, B, i, j, a1, a2, a3, a4, a5, t, ans;

	cin >> N >> A >> B;

	ans = 0;

	for ( i = 0; i <=N; i++)
	{
		a1 = i / 10000;
		a2 = (i - 10000 * a1) / 1000;
		a3 = (i - 10000 * a1 - 1000*a2) / 100;
		a4 = (i - 10000 * a1 - 1000 * a2 - 100 * a3) / 10;
		a5 = i - 10000 * a1 - 1000 * a2 - 100 * a3 - 10 * a4;
		t = a1 + a2 + a3 + a4 + a5;

		if (t >= A&&t <= B)
		{
			ans = ans + i;
		}
		
	}

	cout << ans;

			return 0;
	
}

Measured memory_bytes: 256
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
#include <string> 
#include <sstream>
#include <cstring> 
#include<cmath>
using namespace std;
int main() {
	int x, y,z=0;
	int a[51];
	cin >> x >> y;
	for (int i = 0; i < x; i++) {
		cin >>a[i];
			
	}
	for (int i = 0; i < x; i++) {
		for (int j = i + 1; j < x; j++) {
			
			if (a[i] < a[j]) {
				int q = a[i];
				a[i] = a[j];
				a[j] = q;
			}


		}

	}
	for (int i = 0; i < y; i++) {
		z += a[i];

	}cout << z;
	
	return 0;

}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
const int maxn=110;
int map[maxn][maxn];
int h,w,n;
int a[maxn*maxn];
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
void dfs(int x,int y,int k){
	if(a[k]==0)k++;
	map[x][y]=k;
	a[k]--;
	for(int i=0;i<4;i++){
		int lx=x+dir[i][0],ly=y+dir[i][1];
		if(lx<0||lx>=h||ly<0||ly>=w)continue;
		if(map[lx][ly])continue;
		dfs(lx,ly,k);
	}
}

int main(){
	cin>>h>>w;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	dfs(0,0,1);
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++){
		if(j==0)cout<<map[i][j];
		else cout<<' '<<map[i][j];
		if(j==w-1)cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    double a, b, x;
    cin >> a >> b >> x;
    if ( a * a * b < x * (double)2 ) {
        double tmp_a = x * (double) 2 / a / a - b;
        printf("%.7lf\n", atan2((b-tmp_a), a) * (double)360 / (double)2 / M_PI );
    }
    else {
        double tmp_h = x * 2 / b / a;
        printf("%.7lf\n", (double)90 - atan2(tmp_h, b) * (double)360 / (double)2 / M_PI);
    }
    return 0;
}

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

typedef long long LL;

const int N=1e5+10,Mod=1e9+7;

int n,m,x[N];

struct Matrix {
	int x,y,a[3][3];
	
	void Clear() { for (int i=0;i<x;++i) for (int j=0;j<y;++j) a[i][j]=0; }
	
	Matrix operator * (const Matrix &A) const {
		Matrix ret; ret.x=x; ret.y=A.y; ret.Clear();
		for (int i=0;i<ret.x;++i)
			for (int j=0;j<ret.y;++j) {
				ret.a[i][j]=0;
				for (int k=0;k<y;++k)
					ret.a[i][j]=(ret.a[i][j]+1ll*a[i][k]*1ll*A.a[k][j])%Mod;
			}
		return ret;
	}
	
}a,b,p,ans;

void Init() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i) scanf("%d",&x[i]);
}

void power(const Matrix &a,int t,Matrix &ret) {
	Matrix p=a;
	ret.x=3; ret.y=3; ret.Clear();
	for (int i=0;i<3;++i) ret.a[i][i]=1;
	while (t) {
		if (t&1) ret=ret*p;
		p=p*p;
		t>>=1;
	}
}

void Solve() {
	a.x=3; a.y=3;
	a.a[0][0]=1; a.a[0][1]=2; a.a[0][2]=1;
	a.a[1][0]=0; a.a[1][1]=1; a.a[1][2]=1; 
	a.a[2][0]=1; a.a[2][1]=2; a.a[2][2]=2;
	
	b.x=3; b.y=3;
	b.a[0][0]=1; b.a[0][1]=2; b.a[0][2]=1;
	b.a[1][0]=0; b.a[1][1]=1; b.a[1][2]=1;
	b.a[2][0]=0; b.a[2][1]=0; b.a[2][2]=1;
	
	ans.x=1; ans.y=3;
	ans.a[0][0]=1; ans.a[0][1]=0; ans.a[0][2]=0; 
	
	int now=0;
	for (int i=1;i<=m;++i) {
		power(a,x[i]-now,p);
		ans=ans*p*b;
		now=x[i]+1;
	}
	power(a,n-now,p);
	ans=ans*p;
	printf("%d\n",(ans.a[0][2]%Mod+Mod)%Mod);
}

int main() {
	Init();
	Solve();
	return 0;	
}

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

// https://qiita.com/drken/items/cce6fc5c579051e64fab
struct WeightedUnionFind{
    vector<int> par;
    vector<int> rank;
    vector<int> diff;

    WeightedUnionFind(int n){
        init(n);
    }

    void init(int n){
        par.resize(n); rank.resize(n, 0); diff.resize(n, 0);
        for(int i = 0; i < n; i++)  par[i] = i;
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            int r = root(par[x]);
            diff[x] += diff[par[x]];
            return par[x] = r;
        }
    }

    // 単ノードの重み取得
    int weight(int x){
        root(x);
        return diff[x];
    }

    int dif(int x, int y){
        return weight(y) - weight(x);
    }

    bool isSame(int x, int y){
        return root(x) == root(y);
    }

    // weight(y) - weight(x) = w となるように merge
    bool merge(int x, int y, int w){
        // x が y の親になることを考えると、更新の起点はdiff[y]で、
        // diff[y] を w + weight(x) - weight(y) にすればよい
        w += weight(x); w -= weight(y);

        x = root(x); y = root(y);
        if(x == y)  return false;
        if(rank[x] < rank[y])   swap(x, y), w = -w;
        if(rank[x] == rank[y])  rank[x]++;
        par[y] = x;
        diff[y] = w;
        return true;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    WeightedUnionFind uf(n);
    while(q-- > 0){
        int a, b, c, d;
        cin >> a >> b >> c;
        if(a == 0){
            cin >> d;
            uf.merge(b, c, d);
        }else{
            if(uf.isSame(b, c)) cout << uf.dif(b, c) << endl;
            else                cout << "?" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3884
from sys import stdin,stdout

if __name__=="__main__":
    n=int(stdin.readline())

    a=[int(x) for x in stdin.readline().split()]
    b=[int(x) for x in stdin.readline().split()]

    cnt=0

    for i in range(n):
        if(a[i]>=b[i]):
            cnt+=b[i]
        else:
            cnt+=a[i]
            d=b[i]-a[i]
            cnt+=min(a[i+1],d)
            if(d>a[i+1]):
                a[i+1]=0
            else: a[i+1]-=d
            
    stdout.write(str(cnt)+"\n")


Measured memory_bytes: 24244
mod = 10 ** 9 + 7

N, K = map(int, input().split())
A = list(map(int, input().split()))

neg = []
zero = 0
pos = []
for a in A:
    if a < 0:
        neg.append(a)
    else:
        pos.append(a)

pos.sort()
neg.sort(reverse=True)

if len(pos) == 0:
    res = 1
    if K % 2 == 0:
        neg.reverse()
    for a in neg[:K]:
        res *= a
        res %= mod
else:
    res = 1
    if K % 2 == 1:
        res = pos.pop()
        K -= 1
    while K > 1 and len(pos) > 1 and len(neg) > 1:
        if pos[-1] * pos[-2] > neg[-1] * neg[-2]:
            res *= pos.pop()
            res %= mod
            res *= pos.pop()
            res %= mod
        else:
            res *= neg.pop()
            res %= mod
            res *= neg.pop()
            res %= mod
        K -= 2
    while K > 1 and len(pos) > 1:
        res *= pos.pop()
        res %= mod
        res *= pos.pop()
        res %= mod
        K -= 2
    while K > 1 and len(neg) > 1:
        res *= neg.pop()
        res %= mod
        res *= neg.pop()
        res %= mod
        K -= 2
    while K and pos:
        res *= pos.pop()
        res %= mod
        K -= 1
    while K and neg:
        res *= neg.pop()
        res %= mod
        K -= 1


print(res)

Measured memory_bytes: 31656
#include<stdio.h>
int main()
{
long long int a,b,c,i;
  c=0;
  scanf("%lld %lld",&a,&b);
int d[b];
  for(i=0;i<b;++i)
  {
  scanf("%lld",&d[i]);
  c=c+d[i];
  }
  if(c<a) printf("No");
  else printf("Yes");
return 0;
}

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

using namespace std;

string s;
int N, sol;
vector < int > a;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;

    char c;
    for (int i = 1; i <= N; ++i) {
        cin >> c;
        
        if (c == 'Y') {
            cout << "Four" << '\n';
            return 0;
        }
    }
    
    
    cout << "Three" << '\n';
    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll a, b, c, d;

    cin >> a >> b >> c >>d;

    ll ansa = (a - 1) - ((a - 1) / c) - ((a - 1) / d) + ((a - 1) / lcm(c, d));
    ll ansb = b - (b / c) - (b / d) + (b / lcm(c, d));

    cout << ansb - ansa << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=1005;
int n;
int a[maxn];
int b[maxn];
int tot;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    int ans=-1;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int cnt=a[i]*a[j];
            bool f=1;
            while(cnt!=0){
                int kk=cnt%10;
                cnt/=10;
                if(cnt==0)break;
                if(kk!=cnt%10+1){f=0;break;}
            }
            if(f)ans=max(ans,a[i]*a[j]);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3236