akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0)); 
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

vi g[100010];
int c[100010];
int bt;

void dfs(int v){
    each(u,g[v]){
        if(c[*u] == -1){
            c[*u] = c[v]^1;
            dfs(*u);
        }else{
            if((c[*u]^c[v]) != 1) bt=0;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int u,v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    fill(c,c+n,-1);

    ll x=0,y=0,z=0;
    rep(i,n){
        if(c[i] != -1) continue;
        if(g[i].size() == 0){ c[i]=0; x++; }
        else{
            bt=1; c[i]=0;
            dfs(i);
            if(bt) y++;
            else z++;
        }
    }
    printf("%lld\n", x*x+2*y*y+z*z+2ll*y*z+2ll*x*(n-x));
    return 0;
}


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

string revrs(string str, int a, int b)
{
  int m,k,j;
  string trs;

  m=str.size();
  trs = str;
  for(k = 0; k < m; k++) {
    if(k < a || b < k)
      j = k;
    else
      j = a + b -k;
    trs[j]=str[k];
  }
  return trs;
}


string trans(string str, string c, int a, int b, string p)
{
  string trs;

  trs = str;
  if(c == "reverse"){
    trs=revrs(str,a,b);
  }
  else if(c == "replace") {
    trs = str.erase(a,b-a+1);
    trs = trs.insert(a,p);
  }
  return trs;
}

int main(void)
{
  int n,k,m,j,a,b;
  string str,c,p,ans[1001];

  cin >> str;
  cin >> n;

  m=0;
  for(k = 1; k <= n; k++){
    cin >> c;
    if(c=="replace")
      cin  >> a >> b >> p;
    else
      cin >> a >> b;
    if(c!="print")
      str = trans(str,c,a,b,p);
    else if(c=="print") {
      m = m + 1;
      ans[m]=str.substr(a,b-a+1);
    }
  }

  for(j = 1; j<= m; j++){
    cout << ans[j] << endl;
  }
   
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, m, q, ans = 0;
  string s;
  cin >> n >> m;
  //vector<int> a(q), b(q), c(q), d(q);
  rep(i, m){
    cout << n / 2 - i << " " << n / 2 + i + 1 + (i * 2 >= m && n % 2 == 0) << endl;
  }
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] score = new int[n + 1];

        for (int i = 0; i < n; i++) {
            String[] input = br.readLine().split(" ");
            score[Integer.parseInt(input[0])] = Integer.parseInt(input[1]);
        }

        int maxValue = Integer.MIN_VALUE;
        int maxIndex = -1;
        for (int i = 1; i <= n; i++) {
            if (maxValue < score[i]) {
                maxValue = score[i];
                maxIndex = i;
            }
        }

        System.out.println(maxIndex + " " + maxValue);
    }
}


Measured memory_bytes: 24480
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(i+1,n):
    if l[i]==l[j]:
      continue
    for k in range(j+1,n):
      if l[k]==l[i] or l[k]==l[j]:
        continue
      a=sorted([l[i],l[j],l[k]])
      if a[0]+a[1]>a[2]:
        ans+=1
print(ans)

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

int dp[5][4001];

int main() {
    dp[0][0] = 1;
    for (int i = 1; i <= 4; i++) {
        for (int j = 0; j <= 4000; j++) {
            for (int k = 0; k <= 1000; k++) {
                if (j - k >= 0) {
                    dp[i][j] += dp[i - 1][j - k];
                }
            }
        }
    }
    int n;
    while (cin >> n) {
        cout << dp[4][n] << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
	long long int n, m = 0, a = 0, r = 0, c = 0, h = 0, ans = 0;
	cin >> n;
	string s;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		if (s[0] == 'M') m++;
		else if (s[0] == 'A') a++;
		else if (s[0] == 'R') r++;
		else if (s[0] == 'C') c++;
		else if (s[0] == 'H') h++;
	}
	ans += m * a*r + m * a*c + m * a*h + a * r*c + a * r*h + r * c*h + m * r*c + m * r*h + m * c*h + a * c*h;
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

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

    int a = min(A, K);
    int b = min(B, K-a);
    int c = K-a-b;

    cout << (a-c) << endl;

    return 0;
}


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

int main() {

  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;


  if (a1 + a2 + a3 <= 21) {
    cout << "win" << endl;
  } else {
    cout << "bust" << endl;
  }

}

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

int main() {
    int n;
    cin >> n;
    int64_t a[n];
    int64_t sum_length = 0;
    rep(i,n) {
        cin >> a[i];
        sum_length += a[i];
    }
    int64_t left_length = 0;
    int64_t ans = sum_length;
    rep(i,n-1) {
        left_length += a[i];
        ans = min(abs(left_length - (sum_length - left_length)), ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
/*
 * FileName:     binary_search_fix
 * CreatedDate:  2020-06-20 12:15:48 +0900
 * LastModified: 2020-06-20 20:35:13 +0900
 */

#include <stdio.h>
#include <stdlib.h>
int count=0;
int bi_search( int t, int *s, int left, int right){
    while(left+1<right){
        int mid = (left+right)/2;
        if(s[mid]<=t)left=mid;
        else right=mid;
    }
    return s[left]==t;
}

int main(void){
    int n;scanf("%d",&n);
    int *s = malloc(n*sizeof(int));
    for(int i=0;i<n;i++)scanf("%d",s+i);
    int q;scanf("%d",&q);

    for(int i=0;i<q;i++){
        int t;scanf("%d",&t);
        count+=bi_search(t,s,0,n);
    }
    printf("%d\n",count);
    free(s);
    return 0;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_H 10
#define MAX_W 1'000
#define INF 1152921504606846976
i64 H, W, K;
i64 G[MAX_H][MAX_W];
i64 C[MAX_H + 1][MAX_W + 1];

i64 count(i64 y1, i64 x1, i64 y2, i64 x2) {
    return C[y2][x2] - C[y2][x1] - C[y1][x2] + C[y1][x1];
}

int main() {
    cin >> H >> W >> K;
    char c;
    REP(y, H) REP(x, W) {
        cin >> c;
        G[y][x] = c - '0';
    }

    REP(y, H + 1) REP(x, W + 1) C[y][x] = 0;
    REP(y, H) REP(x, W) {
        C[y + 1][x + 1] = C[y][x + 1] + C[y + 1][x] - C[y][x] + G[y][x];
    }

    i64 min_n = 10000000000;
    REP(bit, 1 << (H - 1)) {
        vector<i64> div_y;
        div_y.reserve(H);
        REP(y, H) {
            if (bit >> y & 1) {
                div_y.pb(y + 1);
            }
        }
        div_y.pb(H);

        i64 n_col = 1;
        i64 x1, x2;
        for (x1 = 0, x2 = 1; x2 <= W; x2++) {
            bool ok = true;

            i64 y1, y2;
            y1 = 0;
            for (auto y2 : div_y) {
                if (count(y1, x1, y2, x2) > K) ok = false;
                y1 = y2;
            }

            if (!ok) {
                if (x2 - x1 == 1) {
                    n_col = INF;
                    break;
                }
                x1 = x2 - 1;
                n_col++;
            }
        }

        if (n_col < INF) {
            chmin(min_n, n_col - 1 + SIZE(div_y) - 1);
        }
    }
    cout << min_n << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    if(a==0){
        printf("1\n");
    }
    else if(b==0){
        printf("2\n");
    }
    else if(c==0){
        printf("3\n");
    }
    else if(d==0){
        printf("4\n");
    }
    else if(e==0){
        printf("5\n");
    }
    return 0;
}

Measured memory_bytes: 1568
#include <iostream>
using namespace std;
main () {
  	int a, b;
  	cin>>a>>b;
  	if (a == 1) {
  		if (b == 2) {
  			cout<<3<<endl;
		} else if (b == 3) {
			cout<<2<<endl;
		}
	} else if (a == 2) {
		if (b == 1) {
			cout<<3<<endl;
		} else if (b == 3) {
			cout<<1<<endl;
		}
	} else if (a == 3){
		if (b == 1) {
			cout<<2<<endl;
		} else if (b == 2) {
			cout<<1<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int dp[3030][3030];
int dp2[3030][3030][2];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,t; cin >> n >> t;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	int ans=0;
	dp[0][0]=0;
	for(int j=0;j<n;j++){
		for(int k=0;k+a[j]<=t;k++){
			dp[j+1][k]=max(dp[j+1][k],dp[j][k]);
			dp[j+1][k+a[j]]=max(dp[j+1][k+a[j]],dp[j][k]+b[j]);
		}
	}
	for(int j=0;j<=t;j++){
		ans=max(ans,dp[n][j]);
	}
	dp2[0][0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<t;j++){
			for(int p=0;p<2;p++){
				dp2[i+1][j][p]=max(dp2[i+1][j][p],dp2[i][j][p]);
				if(j+a[i]<t){
					dp2[i+1][j+a[i]][p]=max(dp2[i+1][j+a[i]][p],dp2[i][j][p]+b[i]);
				}
				if(p==0){
					dp2[i+1][j][1]=max(dp2[i+1][j][1],dp2[i][j][p]+b[i]);
				}
			}
		}
	}
	for(int i=0;i<t;i++){
		for(int j=0;j<2;j++){
			ans=max(ans,dp2[n][i][j]);
		}
	}
	cout << ans << endl;
} 

Measured memory_bytes: 107520
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut a: [i64; 5],
        k: i64,
    }

    // std::thread::sleep_ms(3000);

    a.sort();

    let ans = if a[4] - a[0] > k { ":(" } else { "Yay!" };
    println!("{}", ans);
}


Measured memory_bytes: 4476
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = sc.nextInt();
        int s = sc.nextInt();
        int p = sc.nextInt();
        String[] t = sc.next().split("");

        int count = 0;
        String[] history = new String[n];
        for (int i = 0; i < k; i++) {
            String enemy = t[i];
            if (enemy.equals("r")) {
                count += p;
                history[i] = "p";
            } else if (enemy.equals("s")) {
                count += r;
                history[i] = "r";
            } else if (enemy.equals("p")) {
                count += s;
                history[i] = "s";
            }
        }

        for (int i = k; i < n; i++) {
            String enemy = t[i];
            if (enemy.equals("r")) {
                if (!history[i-k].equals("p")) {
                    history[i] = "p";
                    count += p;
                } else {
                    history[i] = "*";
                }
            } else if (enemy.equals("s")) {
                if (!history[i-k].equals("r")) {
                    history[i] = "r";
                    count += r;
                } else {
                    history[i] = "*";
                }
            } else if (enemy.equals("p")) {
                if (!history[i-k].equals("s")) {
                    history[i] = "s";
                    count += s;
                } else {
                    history[i] = "*";
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 34416
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		int cost[][];
		int time[][];

		while (true) {
			n = sc.nextInt();
			m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}

			cost = new int[m][m];
			time = new int[m][m];
			for (int i = 0; i < m; i++) {
				Arrays.fill(cost[i], 1000000);
				Arrays.fill(time[i], 1000000);
			}
			for (int i = 0; i < m; i++) {
				cost[i][i] = 0;
				time[i][i] = 0;
			}
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				cost[a][b] = Math.min(cost[a][b], sc.nextInt());
				cost[b][a] = cost[a][b];
				time[a][b] = Math.min(time[a][b], sc.nextInt());
				time[b][a] = time[a][b];
			}

			for (int k = 0; k < m; k++) {
				for (int i = 0; i < m; i++) {
					for (int j = 0; j < m; j++) {
						cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);
						time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]);
					}
				}
			}

			int k = sc.nextInt();
			while (k-- != 0) {
				int p = sc.nextInt() - 1;
				int q = sc.nextInt() - 1;
				int r = sc.nextInt();
				if (r == 0) {
					System.out.println(cost[p][q]);
				} else if (r == 1) {
					System.out.println(time[p][q]);
				}
			}
		}
	}
}

Measured memory_bytes: 94772
#include<stdio.h>
#include<algorithm>
#include<iostream>

using namespace std;

int main() {
    int N;
    int hp[100000];
    cin >> N;
    for (int i = 0; i < N; ++i)
        scanf(" %d", &hp[i]);
    bool completed = false;
    int currentMin = -1;
    while (!completed) {
        sort(hp, hp+N);
        if (currentMin == hp[0])
            break;
        currentMin = hp[0];
        for (int i = 1; i < N; ++i) {
            if (hp[i] % currentMin == 0)
                hp[i] = currentMin;
            else
                hp[i] %= currentMin;
        }
    }
    cout << currentMin << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b,d) - max (a,c));
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;



int main(){
	int N, K;
	char X;
	char s[10];
	cin >> N;
	for (int i = 0; i < N; i++)		cin >>s[i];
	cin >> K;
	X = s[K - 1];
	for (int i = 0; i < N; i++) {
		if (s[i] == X) {}
		else s[i] = '*';
	}
	for (int i = 0; i < N; i++)
	{
		cout << s[i];
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	double a, b, x;
	cin >> a >> b >> x;

	double v = a * a * b;

	double start = 0;
	double end = 90;
	double e = 1e-6;
	double angl;
	while (abs(start - end) > e) {
		angl = (start + end) / 2;

		double vx;
		if (x <= v / 2) {
			double r = (angl * M_PI) / 180;
			double d = b / tan(r);
			vx = (a * b * d) / 2;
		}
		else {
			double r = ((90 - angl) * M_PI) / 180;
			double d = a / tan(r);
			vx = (2 * b - d) / 2 * a * a;
		}


		if (vx == x) {
			break;
		}

		if (vx > x) {
			start = angl;
		}
		else {
			end = angl;
		}
	}

	cout << setprecision(10) << angl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{
    arena
    string s;
    cin>>s;
    if(s=="ABC")
    cout<<"ARC";
    
    if(s=="ARC")
    cout<<"ABC";
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main(void) {
  string s, t;
  cin >> s >> t;
  ll st[26], go[26];
  ll i;
  ll f=1;
  memset(st, -1, sizeof(st));
  memset(go, -1, sizeof(go));
  for(i=0; i<s.size(); i++) {
    ll ids=s[i]-'a';
    ll idt=t[i]-'a';
    
    if(st[ids]==-1 || go[idt]==-1) {
      if(st[ids]!=-1 || go[idt]!=-1) {
        f=0;
      }else {
        st[ids]=idt;
        go[idt]=ids;
      }
    }else {
      if(st[ids]!=idt) f=0;
      if(go[idt]!=ids) f=0;
    }
    
  }
  
  if(f) pt("Yes");
  else pt("No");
  
  
}


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

int main()
{
	int n; //n??¶????????±
	int b, f, r, v;//b:?£? f:??? r:???????????¨?±? v:?¢???????????????°
	int house1[4][11] = { 0 }; //1?£?
	int house2[4][11] = { 0 }; //2?£?
	int house3[4][11] = { 0 }; //3?£?
	int house4[4][11] = { 0 }; //4?£?

	cin >> n;

	//?????±?????\???
	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;

		if (b == 1)//1?£?????????£??????
		{
			for (int j = 1; j <= 3; j++)
			{
				if (f == j)//??????????????°???
				{
					for (int k = 1; k <= 10; k++)//??????????????¨?±????
					{
						if (k == r)
						{
							house1[f][r] = house1[f][r] + v; //?????????0???????§?????????????1????????????
						}


					}
				}
			}
		}

		if (b == 2)//2?£?????????£??????
		{
			for (int j = 1; j <= 3; j++)
			{
				if (f == j)//??????????????°???
				{
					for (int k = 1; k <= 10; k++)//??????????????¨?±????
					{
						if (k == r)
						{
							house2[f][r] = house2[f][r] + v; //?????????0???????§?????????????1????????????
						}
					}
				}
			}
		}

		if (b == 3)//3?£?????????£??????
		{
			for (int j = 1; j <= 3; j++)
			{
				if (f == j)//??????????????°???
				{
					for (int k = 1; k <= 10; k++)//??????????????¨?±????
					{
						if (k == r)
						{
							house3[f][r] = house3[f][r] + v; //?????????0???????§?????????????1????????????
						}
					}
				}
			}
		}

		if (b == 4)//4?£?????????£??????
		{
			for (int j = 1; j <= 3; j++)
			{
				if (f == j)//??????????????°???
				{
					for (int k = 1; k <= 10; k++)//??????????????¨?±????
					{
						if (k == r)
						{
							house4[f][r] = house4[f][r] + v; //?????????0???????§?????????????1????????????
						}
					}
				}
			}
		}
	}

	/*??????*/
	for (int j = 1; j <= 3; j++)
	{
		for (int k = 1; k <= 10; k++)
		{
			cout << " " << house1[j][k];
		}
		cout << "\n";
	}
	cout << "####################" << "\n";

	for (int j = 1; j <= 3; j++)
	{
		for (int k = 1; k <= 10; k++)
		{
			cout << " " << house2[j][k];
		}
		cout << "\n";
	}
	cout << "####################" << "\n";

	for (int j = 1; j <= 3; j++)
	{
		for (int k = 1; k <= 10; k++)
		{
			cout << " " << house3[j][k];
		}
		cout << "\n";
	}
	cout << "####################" << "\n";

	for (int j = 1; j <= 3; j++)
	{
		for (int k = 1; k <= 10; k++)
		{
			cout << " " << house4[j][k];
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n);
	for (ll i = 0; i < n; i++) cin >> s[i];

	vector<char> ans(0);
	for (ll i = 0; i < n; i++) {
		if (s[i] == "AB") {
			if (a == 0 && b == 0) {
				No();
				return 0;
			}
			if (a > b) {
				a--;
				b++;
				ans.push_back('B');
			}
			else if (a < b) {
				a++;
				b--;
				ans.push_back('A');
			}
			else {
				if (i == n - 1) ans.push_back('A');
				else if (s[i + 1] == "AC") {
					a++;
					b--;
					ans.push_back('A');
				}
				else if (s[i + 1] == "BC") {
					a--;
					b++;
					ans.push_back('B');
				}
				else {
					a++;
					b--;
					ans.push_back('A');
				}
			}

		}
		if (s[i] == "AC") {
			if (a == 0 && c == 0) {
				No();
				return 0;
			}
			if (a > c) {
				a--;
				c++;
				ans.push_back('C');
			}
			else if (a < c) {
				a++;
				c--;
				ans.push_back('A');
			}
			else {
				if (i == n - 1) ans.push_back('A');
				else if (s[i + 1] == "AC") {
					a++;
					c--;
					ans.push_back('A');
				}
				else if (s[i + 1] == "BC") {
					a--;
					c++;
					ans.push_back('C');
				}
				else {
					a++;
					c--;
					ans.push_back('A');
				}
			}
		}
		if (s[i] == "BC") {
			if (b == 0 && c == 0) {
				No();
				return 0;
			}
			if (b > c) {
				b--;
				c++;
				ans.push_back('C');
			}
			else if (b < c) {
				b++;
				c--;
				ans.push_back('B');
			}
			else {
				if (i == n - 1) ans.push_back('B');
				else if (s[i + 1] == "AC") {
					b--;
					c++;
					ans.push_back('C');
				}
				else if (s[i + 1] == "BC") {
					b--;
					c++;
					ans.push_back('C');
				}
				else {
					b++;
					c--;
					ans.push_back('B');
				}
			}
		}
	}
	Yes();
	for (ll i = 0; i < n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 6728
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

    int MOD = 998244353;

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();

        long ans = 0;
        long col = m;

        Combi cb = new Combi(n-1, MOD);


        for (int x=n-1; 0<=x; x--) {
            long now = col % MOD;
//            System.out.println(now);
            now *= cb.nck(n-1, x);
            now %= MOD;
//            System.out.println(now);
            if (x <= k) {
                ans += now;
                ans %= MOD;
            }
            col *= (m - 1);
            col %= MOD;
        }

        System.out.println(ans);

//        System.out.println(new Combi(n, MOD).facts[n]);


    }

    public class Combi {
        int n;   //　要素数
        int MOD;
        long[] facts;

        public Combi(int n, int MOD){
            this.n = n;
            this.MOD = MOD;
            facts = new long[n+1];
            facts[0] = 1;
            for (int i=1; i<n+1; i++){
                facts[i] = facts[i-1]*i%MOD;
            }
        }

        public long modpow(long a, long b){  // 計算量はlog(MOD);
            if (b==0) return 1;
            else if (b==1) return a;
            long x = modpow(a, b/2);
            return b%2==0 ? x*x%MOD : x*(x*a%MOD)%MOD;
        }
        public long inv(long n){ // 逆元。x^(-1)≡x^(p-2) (MOD p)
            return modpow(n, MOD-2);
        }
        public long nck(int n, int k){
            return n<k ? 0: facts[n]*(inv(facts[n-k])*inv(facts[k])%MOD)%MOD;
        }
    }

}


Measured memory_bytes: 38408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int j,t,g;
  cin >> j >> t >> g;
  int f=0,s=0;
  if(j==5){
    f++;
  }
  else if(j==7){
    s++;
  }
  if(t==5){
    f++;
  }
  else if(t==7){
    s++;
  }
  if(g==5){
    f++;
  }
  else if(g==7){
    s++;
  }
  if(s==1&&f==2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
string s;
int leng;
bool func(int h)
{
	int c=h-1;
	for(int i=c;i>=0;i--)
	{
		if(i+h-1<leng)
		{
			if(s[c]!=s[i]) return 0;
			return 1;
		}
		if(s[i]!=s[c])return 0;
	}
	return 1;
}


int main()
{
	cin>>s;
	int l=1,r=s.size(),mid;
	leng=s.size();
	while(l<=r)
	{
		mid=(l+r)/2;
		if(func(mid))l=mid+1;
		else r=mid-1;
	}
	cout<<l-1<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    ll a, b, k;
    cin >> a >> b >> k;

    ll diff = a-k;
    ll res_a, res_b;
    if (diff < 0) {
        res_a = 0;
        res_b = b + diff >= 0 ? b + diff : 0;
    } else {
        res_a = diff;
        res_b = b;
    }
    cout << res_a << " " << res_b << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        bool compare(pair<int,int> a,pair<int,int> b){
            if(a.first==b.first)
                return a.second<b.second;
            return a.first<b.first;
        }

        signed main() {
 
    
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int s,w;
        cin>>s>>w;
        if(s>w)
            cout<<"safe\n";
        else
            cout<<"unsafe\n";

        return 0;
    }

Measured memory_bytes: 3668
#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 getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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 ll = long long;
using R = long double;
const R EPS = 1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max<R>(x, 0.0));}

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

// Problem Specific Parameter:
// http://codeforces.com/blog/entry/18051

template <int depth>  struct Segment_tree {
	const static int h = depth;
	const static int n = 1 << h;

	using T = long long;
	T data[2 * n], lazy[2 * n];
	const T out = (1LL << 31) - 1;

	inline T vmerge(T l, T r) {return min(l, r);}

	void init() {
		fill_n(data, 2 * n, out);
		fill_n(lazy, 2 * n, out);
	}

	// lazy_evaluation
	void apply(T v, int p, int l, int r) {
		data[p] = v;
		lazy[p] = v;
	}

	void push(int p, int l, int r) {
		const int m = (l + r) / 2;
		if (lazy[p] == out) return;
		apply(lazy[p], 2 * p + 1, l, m);
		apply(lazy[p], 2 * p + 2, m, r);
		lazy[p] = out;
	}

	void range_update(int a, int b, T x, int k = 0, int l = 0, int r = n) {
		if (r <= a or b <= l) return;
		if (a <= l and r <= b) return apply(x, k, l, r);
		push(k, l, r);
		const int m = (l + r) / 2;
		range_update(a, b, x, k * 2 + 1, l, m);
		range_update(a, b, x, k * 2 + 2, m, r);
		data[k] = vmerge(data[k * 2 + 1], data[k * 2 + 2]);
	}

	T range_query(int a, int b, int k = 0, int l = 0, int r = n) {
		if (r <= a or b <= l) return out;
		if (a <= l and r <= b) return data[k];
		push(k, l, r);
		const int m = (l + r) / 2;
		T vl = range_query(a, b, k * 2 + 1, l, m);
		T vr = range_query(a, b, k * 2 + 2, m, r);
		return vmerge(vl, vr);
	}
};

Segment_tree<17> seg;



int main(void) {
	int n, q;
	cin >> n >> q;

	seg.init();

	rep(loop, q) {
		int com, s, t, x;
		cin >> com;
		if (com) {
			cin >> s >> t;
			cout << seg.range_query(s, t + 1) << endl;
		} else {
			cin >> s >> t >> x;
			seg.range_update(s, t + 1 , x);
		}
	}
	return 0;
}

Measured memory_bytes: 7208
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	void doIt() {
		int X = sc.nextInt();
		int Y = sc.nextInt();
		for(int i = 0; i <= X; i++) {
			if(Y == i * 2 + (X - i) * 4) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 35776
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
d = {}
for i in range(m):
    a, b = list(map(int, input().split()))
    try:
        d[a-1].append(b-1)
    except KeyError:
        d[a-1] = [b-1]
    try: 
        d[b-1].append(a-1)
    except:
        d[b-1] = [a-1]
cnt = 0
for k, v in d.items():
    flag = True
    for i in set(v):
        if h[k] > h[i]:
            pass
        else:
            flag = False
    if flag is True:
        cnt += 1
print(cnt+(n-len(d.keys())))

Measured memory_bytes: 34664
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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



int main(){
    ll x;
    cin >> x;

    ll ans;

    if(x == 2){
        ans = x;
        cout << ans << endl;
        return 0;
    }

    
    for(int i = 2; i < x/2 + 2; i++){
        /*cout << i << ' ' << x << endl;*/
        if(x%i == 0){
            x += 1;
            i = 2;
        }
    }
    
    
    cout << x << endl;
}

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

using namespace std;

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

int main(void)
{
  int h, w, n;
  cin >> h >> w >> n;
  int sr, sc;
  cin >> sr >> sc;
  string s, t;
  cin >> s >> t;
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());

  int rl = 1, rr = w, cl = 1, cr = h;
  rep(i, n) {
    if (t[i] == 'L' && rr > 0 && rr <= w - 1) rr++;
    else if (t[i] == 'R' && rl > 1 && rl <= w) rl--;
    else if (t[i] == 'U' && cr > 0 && cr <= h - 1) cr++;
    else if (t[i] == 'D' && cl > 1 && cl <= h) cl--;

    if (s[i] == 'L') rl++;
    else if (s[i] == 'R') rr--;
    else if (s[i] == 'U') cl++;
    else cr--;
    if (rl > rr || cl > cr) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (rl <= sc && sc <= rr && cl <= sr && sr <= cr) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1020
N,M,K=map(int,input().split())
alist=list(map(int,input().split()))
blist=list(map(int,input().split()))

sum_alist=[0]
for a in alist:
  sum_alist.append(sum_alist[-1]+a)
sum_blist=[0]
for b in blist:
  sum_blist.append(sum_blist[-1]+b)
  
index_b=M
answer=0
for i in range(N+1):
  if sum_alist[i]>K:
    break
    
  while sum_alist[i]+sum_blist[index_b]>K:
    index_b-=1
    
  #print(i,index_b)
  answer=max(answer,i+index_b)
  
print(answer)

Measured memory_bytes: 127164
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N, M; cin>>N>>M;
  vector<int> already(N), pn(N);
  for(int i=0; i<M; i++){
    int p;
    string s;
    cin>>p>>s;
    p--;
    if(already.at(p)==0){
      if(s=="AC"){
        already.at(p)=1;
      }
      else{
        pn.at(p)++;
      }
    }
  }
  int ac=0, Pn=0;
  for(int i=0; i<N; i++){
    ac+=already.at(i);
    if(already.at(i)==1){
      Pn+=pn.at(i);
    }
  }
  cout<<ac<<" "<<Pn<<endl;
}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))

if 0 in A:
    print(0)
    exit()

temp=1
seki=0
for i in range(N):
    temp*=A[i]
    seki*=A[i]
    seki+=(temp//10**9)
    temp%=10**9
    
    if seki*10**9+temp>10**18:
        print(-1)
        exit()
    

print(seki*10**9+temp)

Measured memory_bytes: 21736
#include <iostream>
    using namespace std;
     
    int main(){
    	int N,D,a=1;
    	cin>>D>>N;
       	for(int i=0;i<D;i++)a=a*100;
       	if(N==100) cout<<N*a+a<<endl;
       	else cout<<(N*a)<<endl;
    }

Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    if((a==b&&b!=c)||(a==c&&a!=b)||(b==c&&a!=b))
    cout<<"Yes";
    else
    cout<<"No";
}



Measured memory_bytes: 3612
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

l = int(input())

tmp = l / 3

print(tmp**3)



Measured memory_bytes: 9360
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;
const int MOD=1e9+7;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(double x){
    return fabs(x) < EPS ? 0 : x>0 ? 1 : -1 ;
}
ll a[N];
ll sum[N];
map<ll,ll> mp;
int main(void){
    ll n,m;
    sf(n);sf(m);
    for(int i=1;i<=n;i++)   sf(a[i]);
    for(int i=1;i<=n;i++)   sum[i]=sum[i-1]+a[i],mp[sum[i]%m]++;
    ll ans=0;
    for(auto t : mp){
        ans+=t.S*(t.S-1)/2;
//        cout <<t.F<<" "<<t.S<<endl;
    }
    printf("%lld\n",ans+mp[0]);

    return 0;
}


Measured memory_bytes: 5760
N=int(input())
x,y = map(int,input().split())
p = list(map(int,input().split()))

a=0
b=0
c=0

for i in range(N):
  if p[i]<=x:
    a+=1
  elif p[i]>=y+1:
    c+=1
  else:
    b+=1

print(min([a,b,c]))

Measured memory_bytes: 9120
#include <iostream>
using namespace std;
int num;

int main(void) {
    cin >> num;
    int array[num] = {};
    array[0] = 1;
    array[1] = 1;
    for (int i= 2; i <= num; i++) {
        array[i] = array[i - 1] + array[i - 2];
    }
    cout << array[num] << endl;
}




Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
long long aa;bool bb;char ch;
long long scan()
{
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	ch=='-'?(bb=1,aa=0):(bb=0,aa=ch-48);
	while(ch=getchar(),(ch>='0'&&ch<='9'))
		aa=aa*10+ch-48;
	return (bb?(-aa):(aa));
}
struct P
{
	int x,y,id;
} p[100010];
struct E
{
	int from,to,w;
} e[200010];
int tot=0,N,u,v,x,y,fu,fv;
long long ans=0;
int fa[100010];
bool cmpx(P u,P v){return u.x<v.x;}
bool cmpy(P u,P v){return u.y<v.y;}
bool cmp(E u,E v){return u.w<v.w;}
int find(int u)
{
	if(u!=fa[u])
		return fa[u]=find(fa[u]);
	return u;
}
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;++i)
	{
		fa[i]=i;
		scanf("%d%d",&x,&y);
		p[i].x=x;
		p[i].y=y;
		p[i].id=i;
	}
	sort(p+1,p+N+1,cmpx);
	for(int i=1;i<N;++i)
	{
		e[++tot].from=p[i].id;
		e[tot].to=p[i+1].id;
		e[tot].w=p[i+1].x-p[i].x;
	}
	sort(p+1,p+N+1,cmpy);
	for(int i=1;i<N;++i)
	{
		e[++tot].from=p[i].id;
		e[tot].to=p[i+1].id;
		e[tot].w=p[i+1].y-p[i].y;
	}
	sort(e+1,e+tot+1,cmp);
	for(int i=1;i<=tot;++i)
	{
		u=e[i].from;
		v=e[i].to;
		fu=find(u);
		fv=find(v);
		if(fu!=fv)
		{
			fa[fu]=fv;
			ans+=e[i].w;
			//cout<<u<<" "<<v<<" "<<e[i].w<<endl;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cstdio>

int main()
{
    int dim[3];
    scanf("%d%d%d", dim, dim + 1, dim + 2);
    long long result = 1000000000000000000LL;
    for (int i = 0; i < 3; ++ i) {
        if (dim[0] & 1) {
            result = std::min(result, 1LL * dim[1] * dim[2]);
        } else {
            result = 0;
        }
        std::rotate(dim, dim + 1, dim + 3);
    }
    printf("%lld\n", result);
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N,X;
	cin >> N >> X;
		vec(L)
			fx(N) {
			vecp(L)
		}
		int D = 0;
		int ans = 1;
		fx(N) {
			D += L.at(x);
			if (D <= X) {
				ans++;
			}
		}
		ce(ans)
    return 0;
}



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

int const MAXN = 1e5;

int64_t p[MAXN+1], q[MAXN+1], r[MAXN];
int X, Y, A, B, C;

int main() {
  std::cin >> X >> Y >> A >> B >> C;
  for(int i = 0; i < A; ++i) std::cin >> p[i];
  for(int i = 0; i < B; ++i) std::cin >> q[i];
  for(int i = 0; i < C; ++i) std::cin >> r[i];
  std::sort(p, p+A); p[A] = 1e10;
  std::sort(q, q+B); q[B] = 1e10;
  std::sort(r, r+C);
  int64_t *pp = p + A-X;
  int64_t *qq = q + B-Y;
  int ia = 0, ib = 0;
  for(int ic = C-1; ic >= 0; --ic) {
    if(ia >= X || pp[ia] > qq[ib]) {
      if(ib >= Y || r[ic] < qq[ib]) break;
      qq[ib++] = r[ic];
    } else {
      if(r[ic] < pp[ia]) break;
      pp[ia++] = r[ic];
    }
  }
  int64_t ans = 0;
  for(int i = 0; i < X; ++i) ans += pp[i];
  for(int i = 0; i < Y; ++i) ans += qq[i];
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>

int n;
int a[100010];
int f1[100010],f2[100010];
int maxx(int x,int y){return x>y?x:y;}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]),i%2==1?f1[a[i]]++:f2[a[i]]++;
	int max1=0,max2=0;
	for(int i=1;i<=100000;i++)
	if(f1[i]>f1[max1])max1=i;
	for(int i=2;i<=100000;i++)
	if(f2[i]>f2[max2])max2=i;
	if(max1!=max2)printf("%d",n-f1[max1]-f2[max2]);
	else
	{
		int max3=0,max4=0;
		for(int i=1;i<=100000;i++)
		if(f1[i]>f1[max3]&&i!=max1)max3=i;
		for(int i=2;i<=100000;i++)
		if(f2[i]>f2[max4]&&i!=max2)max4=i;
		int ma=maxx(f1[max1]+f2[max4],f2[max2]+f1[max3]);
		printf("%d",n-ma);
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x;
	cin >> x;
	string s = to_string(x);
	int y = 0; 
	for (int i = 0 ; i < s.length() ; i++) y += s[i] - '0';
	if (x % y == 0) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3652