akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; n>i; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);
    int cnt = n-1;
    int ans = 0;
    int id = n-1;
    while(cnt){
        if(id == n-1){
            ans += arr[id];
            id--;
            cnt--;
        }else{
            if(cnt >= 2){
                ans += 2*arr[id];
                id--;
                cnt -= 2;
            }else{
                ans += arr[id];
                id--;
                cnt--;
            }
        }
    }
    cout << ans << endl;
}






Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(int i=0;i<(int)n;++i)
#define _rep1(i,k,n) for(int i=k;i<(int)n;++i)
#define _rep2(i,k,n,d) for(int i=k;d>0?i<(int)n:i>(int)n;i+=d)
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

template<class T>
class SegmentTree{
private:
    ll n = 1;
    function<T(T, T)> dot;
    T unit;
    vector<T> tree;
public:
    constexpr SegmentTree(const vector<T> &A, function<T(T, T)> dot, T unit) : dot(dot), unit(unit) {
        while(n < (ll)A.size()) n <<= 1;
        tree.resize(2 * n, unit);
        copy(A.begin(), A.end(), tree.begin() + n);
        rep(i, n - 1, 0, -1) tree[i] = dot(tree[i << 1], tree[i << 1 | 1]);
    }
    constexpr void update(ll i, T v){
        i += n;
        tree[i] = v;
        while(i >>= 1) tree[i] = dot(tree[i << 1], tree[i << 1 | 1]);
    }
    constexpr void add(ll i, T v){update(i, tree[i + n] + v);}
    constexpr T sum(ll l, ll r) const {
        l += n; r += n;
        T l_val = unit, r_val = unit;
        while(l < r){
            if(l & 1) l_val = dot(l_val, tree[l++]);
            if(r & 1) r_val = dot(tree[--r], r_val);
            l >>= 1; r >>= 1;
        }
        return dot(l_val, r_val);
    }
};

void solve(){
    ll n, q; cin >> n >> q;
    vector<ll> C(n);
    rep(i, n){
        cin >> C[i];
        C[i]--;
    }

    vector<ll> A(n), next(n, -1), used(n, -1);
    rep(i, n - 1, -1, -1){
        ll c = C[i];
        A[i] = 1;
        if(used[c] != -1){
            next[i] = used[c];
            A[used[c]] = 0;
        }
        used[c] = i;
    }
    SegmentTree<ll> tree(A, [](ll a, ll b){return a + b;}, (ll)0);

    vector<vector<pair<ll, ll>>> queries(n);
    rep(i, q){
        ll l, r; cin >> l >> r;
        queries[l - 1].emplace_back(r, i);
    }

    vector<ll> ans(q);
    rep(l, n){
        for(auto [r, i] : queries[l]){
            ans[i] = tree.sum(l, r);
        }
        if(next[l] != -1){
            tree.add(next[l], 1);
        }
    }
    for(auto a : ans) cout << a << '\n';
}

Measured memory_bytes: 56352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var abx = ReadLine().Split().Select(double.Parse).ToArray();
        var a = abx[0];
        var b = abx[1];
        var x = abx[2];

        var d = a * b / 2 * a;
        var ans = 0.0;
        if (d < x)
        {
            var c = 2 * x / (a * a) - b;
            var an = Atan((b - c) / a);
            ans = an;
        }
        else
        {
            var c = 2 * x / (a * b);
            ans = Atan(b / c);
        }
        WriteLine(ans / PI * 180);
    }
}



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

int main()
{
    long long X;
    cin >> X;
    long long target = 100;
    int count = 0;
    while (target < X) {
        target += target / 100;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int a[20];
int x[20][20];
int y[20][20];
int main(){
	cin>>n;
	REP(i,n){
		cin>>a[i];
		REP(j,a[i]){
			cin>>x[i][j]>>y[i][j];
			x[i][j]--;
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
			int co=0;
			int flag=1;
		for(int j=0;j<n;j++){
			if((i>>j)&1){
				co++;
				for(int k=0;k<a[j];k++){
					if(((i>>x[j][k])&1)!=y[j][k]){
						flag=0;
						goto A;
					}
				}
			}
		}
		A:
		if(flag){
			ans=max(ans,co);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, m, c;
    int b[20];
    int a[20][20];

    int i, j;
    int count, sum;

    scanf("%d %d %d", &n, &m, &c);

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

    count = 0;
    for(i=0;i<n;i++){
        sum = 0;
        for(j=0;j<m;j++){
            sum += a[j][i] * b[j];
        }
        sum += c;
        if(sum > 0){
            count++;
        }
    }

    printf("%d", count);

    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > 0 && b > 0)
        cout << "Positive" << endl;
    else if (a <= 0 && b >= 0)
        cout << "Zero" << endl;
    else if (abs(a - b) % 2 == 0)
        cout << "Negative" << endl;
    else
        cout << "Positive" << endl;
    return 0;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<vector<int>> g(n+1);
    set<pair<int, int>> odd;
    for (int i = 1; i < n; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
        if (w & 1) {
            odd.emplace(u, v);
            odd.emplace(v, u);
        }
    }
    vector<int> c(n+1, -1);
    auto bfs = [&](){
        queue<int> q;
        q.push(1);
        c[1] = 1;
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (int v: g[u]) {
                if (!~c[v]) {
                    if (odd.find(make_pair(u, v)) != odd.end()) {
                        c[v] = c[u] ^ 1;
                    }else{
                        c[v] = c[u];
                    }
                    q.push(v);
                }
            }
        }
    };
    bfs();
    for (int i = 1; i <= n; i++) {
        cout << c[i] << "\n";
    }
}

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


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int ct=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]!=i+1) ct++;  
    }
    if(ct<=2) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 3628
n,m = map(int, input().split())
ab = []
cd = []
for _ in range(n):
    ab.append(list(map(int, input().split())))
for _ in range(m):
    cd.append(list(map(int, input().split())))
    
dis = [[-1]*m for _ in range(n)]
for nn in range(n):
    a, b = ab[nn]
    for mm in range(m):
        c, d = cd[mm]
        dis[nn][mm] = abs(a-c) + abs(b-d)
        
# print(dis)
  
for nn in range(n):
    min_d = min(dis[nn])
    for mm in range(m):
        if dis[nn][mm]==min_d:
            print(mm+1)
            break
            
        
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int A[N];
int dp[N];

int dfs(int id){
    if(dp[id]!=-1) return dp[id];
    dp[id] = 0;
    for(int i=1; i<=n; i++) if(id>=A[i])
        dp[id] = max(dp[id], 1-dfs(id-A[i]));
    return dp[id];
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>k;
    rep(i, 1, n+1) cin>>A[i];
    memset(dp, -1, sizeof dp);
    if(dfs(k)) cout<<"First";
    else cout<<"Second";
}

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

using namespace std;

int main() {
  int N, ans = 0;
  
  cin >> N;
  
  for (int c = 1; c < N; c++) {
    for (int a = 1; a * a <= N - c; a++) {
      if ((N - c) % a == 0) {
        if (a * a + c == N) {
          ans++;
        } else {
          ans += 2;
        }
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
	int n, flag = 0;
	scanf("%d", &n);
	for(int i = 0; i <= 100; i++){
		for(int j = 0; j <= 100; j++){
			if(4*i+7*j == n){
				printf("Yes\n");
				flag = 1;
				break;
			}
		}
		if(flag)
			break;
	}
	if(!flag)
		printf("No\n");
return 0;
}

Measured memory_bytes: 256
def hanntei(s):
    return s==s[::-1]
s=input()
if hanntei(s):
    a=s[0:(len(s)-1)//2]
    b=s[(len(s)+1)//2:]
    if hanntei(a) and hanntei(b):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int a,b,c,d,k;
    cin >> a >> b >> c >> d >> k;
    int ans = c * 60 + d - (a * 60 + b) - k;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	deque<pair<int, int>>bw;
	int cnt = 1;
	rep(i, n - 1) {
		if (s[i] == s[i + 1]) {
			cnt++;
		}
		else {
			if (s[i] == '#') {
				bw.push_back(make_pair(cnt, 1));
			}
			else {
				bw.push_back(make_pair(cnt, 0));
			}
			cnt = 1;
		}
	}

	if (s[n - 1] == '#') {
		bw.push_back(make_pair(cnt, 1));

	}
	else {
		bw.push_back(make_pair(cnt, 0));
	}
	int wmax = 0;
	rep(i, bw.size()) {
		if (bw[i].second == 0) {
			wmax += bw[i].F;
		}
	}
	int bsum = 0, wsum = 0;
	int ans = wmax;
	rep(i, bw.size()) {
		if (bw[i].second == 1) {
			bsum += bw[i].first;
		}
		else {
			wsum += bw[i].first;
		}
		ans=min(ans,bsum + wmax - wsum);
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 2052
import collections

n=int(input())
num_str=input().split()
list=list(map(int, num_str))

list_e = [list[i] for i in range(0,n-1,2)]
list_o = [list[i] for i in range(1,n,2)]
e = collections.Counter(list_e)
o = collections.Counter(list_o)
mode_e=e.most_common(2)
mode_o=o.most_common(2)
mode_e.append((-1,0))
mode_o.append((-1,0))
if mode_e[0][0]==mode_o[0][0]:
    print(n-max(mode_e[0][1]+mode_o[1][1],mode_e[1][1]+mode_o[0][1]))
    # if mode_e[0][1]>mode_o[0][1]:
    #     mode_e_value=mode_e[0][1]
    #     mode_o_value=mode_o[1][1]
    # else:
    #     mode_e_value=mode_e[1][1]
    #     mode_o_value=mode_o[0][1]
else:
    mode_e_value = mode_e[0][1]
    mode_o_value = mode_o[0][1]
    print(n-mode_e_value-mode_o_value)


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5, mod = 1e9 + 7;;
bool p[2 * nsz + 5];
int n, c0, c1, del[2 * nsz + 5];
num dp[2 * nsz + 5], ans = 1;
string s;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> s;
    s = ' ' + s;
    int cur = 0;
    cont (i, 2 * n) {
        if (s[i] == 'B') {
            if ((cur + 1) & 1) {
                ++cur;
                ++c0;
                p[i] = 0;
            } else if (i == 2 * n || cur - 1 >= 0) {
                --cur;
                ++c1;
                p[i] = 1;
            } else {
                ans = 0;
                break;
            }
        } else if (s[i] == 'W') {
            if (((cur + 1) & 1) == 0) {
                ++cur;
                ++c0;
                p[i] = 0;
            } else if (i == 2 * n || cur - 1 >= 0) {
                --cur;
                ++c1;
                p[i] = 1;
            } else {
                ans = 0;
                break;
            }
        }
    }
    ans = (c0 == n && c1 == n);
    c0 = 0, c1 = 0;
    cont (i, 2 * n) {
        if (p[i]) {
            ++c1;
            ans *= c0;
            ans %= mod;
            --c0;
        } else {
            ++c0;
        }
    }
    cont (i, n) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << ln;
}


Measured memory_bytes: 788
#include <iostream>
#include <utility>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;


//---- Reversing Numbers
int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(int i=0; i<n; i++){
        if(n-i-1==0){
            printf("%d", a[n-i-1]);
        }
        else{
            printf("%d ", a[n-i-1]);
        }
    }
    printf("\n");
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c - a, y = d - b;
    printf("%d %d %d %d\n", c - y, d + x, a - y, b + x);
}

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

int d[50];
int n, r;

int main() {
  while (1) {
    scanf("%d%d", &n, &r);
    if (n == 0) break;
    for (int i = 0; i < n; i++) d[i] = n - i;
    int p, c;
    int temp[50];
    for (int i = 0; i < r; i++) {
      scanf("%d%d", &p, &c);
      p--;
      for (int j = 0; j < c; j++) temp[j] = d[j + p];
      for (int j = 0; j < p; j++) temp[j + c] = d[j];
      for (int j = 0; j < p + c; j++) d[j] = temp[j];
    }
    printf("%d\n", d[0]);
  }
}



Measured memory_bytes: 2572
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    ll a[n];
    map<ll,ll>m;
    ll A=0,B=0;
    vector<pair<ll,ll> > stick;
    REP(i,n){
        cin >> a[i];
        m[a[i]]++;
    }
    for(auto itr = m.begin(); itr != m.end(); ++itr) {
       stick.push_back(*itr);
    }
    sort(ALL(stick));
    reverse(ALL(stick));
    REP(i,stick.size()){
        //cout << stick[i].first << " " << stick[i].second << endl;
        if(stick[i].second >= 2){
            if(A == 0){
                A = stick[i].first;
            }
            else{
                B = stick[i].first;
                cout << A*B << endl;
                return 0;
            }
            if(stick[i].second >= 4){
                cout << stick[i].first * stick[i].first;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 9464
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    ll N, K;
    cin >> N >> K;
    ll H[N];
    rep(i, N){
        cin >> H[i];
    }
    sort(H, H+N);
    reverse(H, H+N);
    ll ans = 0;
    REP(i, K, N) {
        ans += H[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
  
S = input()
T = input()

if len(S) != len(T):
  print('No')
  exit()

N = len(S)
for i in range(N):
  if S == T:
    print('Yes')
    exit()
  S = S[1:] + S[0]

print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N, X; cin >> N >> X;
	ll m[100] = {};
	ll minV = 1 << 30;
	ll ans = 0;
	rep(i, 0, N) {
		cin >> m[i];
		X -= m[i];
		ans++;
		minV = min(m[i], minV);
	}

	ans += X / minV;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  ll ans = 0;
  for (ll i = 0; i < s.size(); i++) {
    if (s[i] != 'A' && s[i] != 'G' && s[i] != 'C' && s[i] != 'T') {
      continue;
    }

    ll length = 1;
    for (ll j = i + 1; j < s.size(); j++) {
      if (s[j] != 'A' && s[j] != 'G' && s[j] != 'C' && s[j] != 'T') {
        break;
      }
      length++;
    }
    cout << endl;
    ans = max(length, ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
struct UnionFind {
	vector<int> rank, parent;
	UnionFind() {};
	UnionFind(int size) :rank(size, 0), parent(size, 0) {
		for (int i = 0; i < size; i++)makeset(i);
	}

	void makeset(int x) {
		parent[x] = x;
		rank[x] = 0;
	}

	bool same(int x, int y) {
		return findset(x) == findset(y);
	}

	int findset(int x) {
		if (x != parent[x]) {
			parent[x] = findset(parent[x]);
		}
		return parent[x];
	}

	void unite(int x, int y) {
		link(findset(x), findset(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y])parent[y] = x;
		else {
			parent[x] = y;
			if (rank[x] == rank[y])rank[y]++;
		}
	}
};
int main() {
	cin >> N >> M;
	vector<int> p(N+1),x(M+1),y(M+1);
	UnionFind uf(N + 1); //UFの下準備
	for (int i = 1; i <= N; i++)cin >> p[i];
	for (int i = 1; i <= M; i++) {
		cin >> x[i] >> y[i];
		uf.unite(x[i], y[i]);
	}
	for (int i = 1; i <= N; i++) {
		if (uf.same(p[i],i))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main() {
  int k, n;
  cin >> n >> k;
  int l[51];
  REP(i, n) { cin >> l[i]; }

  sort(l, l + n);

  int ans = 0;
  int count = 0;
  REP(i, k) { ans += l[n - 1 - i]; }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ab= []

cnt = [0 for i in range(N)]
for i in range(M):
  x,y = map(int,input().split())
  ab.append(x)
  ab.append(y)

for i in range(N):
  cnt[i] = ab.count(i+1)

for i in range(N):
  print(cnt[i])



Measured memory_bytes: 3060
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

w, h, x, y = na()
s = h * w
if w / 2 == x and h / 2 == y:
    print(s/2, 1)
else:
    print(s/2, 0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline int max(int x,int y) {return x>y?x:y;}
const int N=200009;
ll a[N],ps[N],px[N];
bool used[N];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		ps[i]=ps[i-1]+a[i];
		px[i]=px[i-1]^a[i];
	}
	ll ans=0;
	int maxl=-1;
	for(int i=1;i<=n;i++)
	{
		int l=i,r=n,pos;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			ll xor_sum=px[i-1]^px[mid],sum=ps[mid]-ps[i-1];
			if(xor_sum==sum) pos=mid,l=mid+1;
			else r=mid-1;
		}
		if(maxl>=pos) continue;
		ans+=(pos-i+2)*1ll*(pos-i+1)/2;
		if(maxl>=i) ans-=(maxl-i+2)*1ll*(maxl-i+1)/2;
		maxl=pos;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(){
    int n;scanf("%d",&n);
    int l[n];
    int sum=0,max=0;
    for(int i=0;i<n;i++){
        scanf("%d",&l[i]);
        sum+=l[i];
        max=(max<l[i])?l[i]:max;
    }   
    if(sum-max>max)printf("Yes\n");
    else printf("No\n");
    return 0;
}   

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

int main()
{
    char a;
    int counta=0,countb=0;
  for(int i=1;i<=3;i++)
    {
        cin>>a;
        if(a=='A')
            counta++;
        else
            countb++;
    }
    if(counta<3&&countb<3)
        cout<<"Yes"<<endl;
    if(counta==3||countb==3)
        cout<<"No"<<endl;


    return 0;
}







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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  preprocess();
  int m, d; cin>>m>>d;
  map<int, int> mm;
  rep(i,1,d+1) {
    int x = i;
    vi ar;
    rep(j,0,2) {
      ar.pb(x%10);
      x /= 10;
    }
    if(ar[0]>=2 && ar[1] >= 2) {
      mm[ar[0] * ar[1]]++;
    }
  }
  int ans = 0;
  rep(i,1,m+1) ans += mm[i];
  cout<<ans<<endl;
}



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

using namespace std;

typedef long long llint;

int main() {
  llint n, a, b;
  cin >> n >> a >> b;

  if (a % 2 == b % 2) {
    cout << (b - a) / 2 << endl;
  } else {
    cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
P = list(map(int, input().split()))
P_sum = 0
for i in range(K):
    P_sum += P[i]
P_max = P_sum
for i in range(N-K):
    P_sum = P_sum + P[K+i]-P[i]
    if P_sum > P_max:
        P_max = P_sum
print(P_max/2+0.5*K)

Measured memory_bytes: 25060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >>a[2];
  sort(a.begin(),a.end());
  
  
  cout << a[0]+a[1] << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int max(int A[3]) {
  int m = A[0] > A[1] ? 0 : 1;
  return A[m] > A[2] ? m : 2;
}

int main(int argc, char const *argv[]) {
  int A[3];
  int K;
  scanf("%d", &A[0]);
  scanf("%d", &A[1]);
  scanf("%d", &A[2]);
  scanf("%d", &K);
  for (int i = 0; i < K; i++) {
    int index = max(A);
    A[index] = A[index] * 2;
  }
  printf("%d\n", A[0] + A[1] + A[2]);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>


#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _Ty> _Ty tp_abs(const _Ty& a) {
	return ((a < 0) ? (a * -1) : a);
}
static const int EduDp_INF = 1111000000;
static void B_task();

int main()
{
	B_task();
	
	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N, K;
	scanf(" %d %d", &N, &K);

	auto height = new int[N];
	for (int i = 0; i < N; i++) {
		scanf(" %d", &height[i]);
	}

	auto dp = new int[N + 1];
	std::fill(dp, dp + N, EduDp_INF);
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		for (int j = 1; j <= std::min(i, K); j++) {
			dp[i] = std::min(dp[i], dp[i - j] + tp_abs<int>(height[i] - height[i - j]));
		}
	}
	printf("%d\n", dp[N - 1]);

	delete[] height;
	delete[] dp;
}


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

using namespace std;
char a[105];
int ans,p;
int main()
{
	scanf("%s",a);
	int l=strlen(a);
	for(int i=0;i<l-1;i++)
		if(a[i]=='A'&&a[i+1]=='C')
		{
			cout<<"Yes\n";
			return 0;
		}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int c=0,n,p[25],k[3];
	cin>>n;
	for(int i=0;i<(n);i++)cin>>p[i];
	for(int i=1;i<(n-1);i++){
		k[0]=p[(i-1)];
		k[1]=p[i];
		k[2]=p[(i+1)];
		sort(k,k+3);
		if(k[1]==p[i])c++;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const ll INF = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2e5 + 7;
const int maxm = 1e5 + 7;
const int mod = 192600817;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main()
{
    IO;
    int n,m;
	cin>>n>>m;
	for(int i=1;i<=(m+1)/2;++i)
		cout<<i<<" "<<m+2-i<<endl;
	for(int i=1;i<=m/2;++i)
		cout<<m+1+i<<" "<<2*m+2-i<<endl;
    return 0;
}

Measured memory_bytes: 3668
n = int(input())
l = list(map(int, input().split()))
l.sort()
i = len(l)-1
j = len(l) -2
k = len(l) -3
ans = 0
while i >= 2:
  j = i-1
  while j >= 1:
    k = j -1
    while k >= 0:
      if l[i] > l[j] > l[k] and l[i] - l[k] < l[j]:
        ans += 1
      else:
        pass
      k -= 1
    j -= 1
  i -= 1

print(ans)

Measured memory_bytes: 9100
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;


int main(void) {
  vector<int> a = {1,0,0};
  string b = "ABC";
  char x, y;
  int p, q;
  while( scanf("%c,%c",&x, &y) != EOF ){
    p = x-'A';
    q = y-'A';
    swap(a[p], a[q]);
  }
  for(int i=0; i<3; i++) if( a[i] == 1 ) cout << b[i] << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3220
import sys
input = sys.stdin.readlines()

line1 = input[0].split()
x = input[1].split()
y = input[2].split()

x = [int(n) for n in x]
y = [int(n) for n in y]

N = int(line1[0])
M = int(line1[1])
X = int(line1[2])
Y = int(line1[3])

x_max = max(x)
y_min = min(y)

if x_max > X:
    x_border = x_max
else:
    x_border = X
if y_min < Y:
    y_border = y_min
else:
    y_border = Y

if x_border < y_border:
    print('No War')
else:
    print('War')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll e;

int main(){
    while(cin >> e&& e){
        ll ans = INF;
        for(ll z = 0;z*z*z <= e;z++){
            for(ll y = 0;z*z*z + y*y <= e;y++){
                ll x = e - y*y - z*z*z;
                ans = min(ans,x+y+z);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3004
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += 1000 * (int) (x / 500);
  ll tmp = x % 500;
  x /= 500;
  ans += 5 * (int)(tmp / 5);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
h,w = map(int, input().split())
s = [[''] * w] * h
for i in range(h):
    s[i] = list(str(input()))

# '#'が縦横にあったらfalse
def sirokuro(i,j):
    result = True
    if i + 1  < h :
        if s[i + 1][j] == '#':
            result = False
    if i - 1 >= 0:
        if s[i - 1][j] == '#':
            result = False
    if j + 1 < w:

        if s[i][j + 1] == '#':

            result = False
    if j - 1 >= 0:
        if s[i][j - 1] == '#':
            result = False
    return result

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            if sirokuro(i,j):
                print('No')
                sys.exit()
print('Yes')

Measured memory_bytes: 9244
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int a[110];
int n,m;
ll ans;
int cnt;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i],ans+=a[i];
	m*=4;
	int mod=ans%m;
	ans/=m;
	if(mod)ans++;
	for(int i=0;i<n;i++)if(a[i]>=ans)cnt++;
	if(cnt>=(m/4))cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#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 n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  int low = 1, high = 1e9;
  while (low != high) {
    int mid = (low + high) / 2;
    int64 cnt = 0;
    for (int i = 0; i < n; ++i) {
      cnt += (a[i] + mid - 1) / mid - 1;
    }
    // trace(mid, cnt);
    if (cnt > m) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  printf("%d\n", high);
  return 0;
}


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

bool searchBinaryTree(int begin, int end, int S[], int t) {
    int mid = ( begin+ end) / 2;
    // 無かった場合
    if(begin == end) {
        return false;
    }

    // 見つかった場合
    else if(S[mid] == t) {
        return true;
    }
    // 左半分にある場合
    else if(S[mid] > t) {
        return searchBinaryTree(begin, mid, S, t);
    }
    // 右半分にある場合
    else {
       return searchBinaryTree(mid+1, end, S , t);
    }

}


int main() {
    
    int n, q;
    cin >> n;
    int S[n];
    rep(i,n) cin >> S[i];
    cin >> q;
    int T[q];
    rep(i,n) cin >> T[i];

    int cnt = 0;

    rep(i,q) {
        if(i != 0 && T[i-1] == T[i]) continue;

        if(searchBinaryTree(0,n,S ,T[i])) {
            ++cnt;
        }
    }
    cout << cnt << endl;
    
   
}


Measured memory_bytes: 3660
package main

import (
	"fmt"
)

func main() {
	var weather string
	var k int
	fmt.Scan(&weather)
	for i := 0; i < 3; i++ {
		if weather[i] == 'R' {
			k++
		}
	}
	if k == 0 || k == 1 || k == 3 {
		fmt.Printf("%d", k)
	} else if weather[1] == 'S' {
		fmt.Printf("1")
	} else {
		fmt.Printf("2")
	}
}


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

int main(){
  int cnt,ans,m,n,i,j,k,info[101][101],hantei[101];
  while(1){
    for(i = 1; i < 101; i++){
      hantei[i] = 0;
      for(j = 1; j < 101; j++){
      info[i][j] = 0;
      }
    }
    cin >> n;
    if(n==0)break;
    for(i = 1; i <= n; i++){
      cin >> m;
      for(j = 1; j <= m; j++){
	int num;
	cin >> num;
	info[i][num] = 1;
      }
    }
    cin >> k;
    for(i = 1; i <= k; i++){
      int num2;
      cin >> num2;
      hantei[num2] = 1;
    }
    int total = 0;
    for(i = 1; i < 101; i++){
      cnt = 0;
      for(j = 1; j < 101; j++){
	if(hantei[j]==info[i][j] && hantei[j]==1)cnt++;
      }
      if(cnt==k){
	ans = i;
	total++;
      }
    }
    
  if(total==1)cout << ans << endl;
  else cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<bool> f(N+1);//素数かどうか
	//素数判定
	for (int i = 2; i <= N; ++i){
		bool flag = true;
		for (int j = 2; j < i; ++j){
			if(i%j==0)flag = false;
		}
		if(flag)f[i] = true;
	}

	vector<int> s(N+1);
	for (int i = 0; i <= N; ++i){
		s[i] = 1;
	}

	for (int i = 2; i <= N; ++i){
		int a = i;
		for (int j = 2; j <= i; ++j){
			if(f[j]){
				while(a%j==0){
					s[j]++;
					a/=j;
				}
			}
		}
	}
	ll ans = 1;
	rep(i,N+1){
		ans*=s[i];
		ans%=MOD;
	}
	cout<<ans<<endl;
}

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

int main(void){
   int N;
   cin>>N;
   vector<long long> A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   long double result=0.0;
   for(int i=0;i<N;i++){
      result+=log10(A[i]);
   }
   if(result>18.1){
      cout<<-1<<endl;
      return 0;
   }
   long long ans=1;
   for(int i=0;i<N;i++){
      ans*=A[i];
   }
   if(ans>1000000000000000000){
      cout<<-1<<endl;
      return 0;
   }
   cout<<ans<<endl;
   return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

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

    int a[1005];
    FOR(i,0,n)
    {
        cin>>a[i];
    }

    bool ans = true;
    FOR(i,0,n)
    {
        if (a[i]%2 == 0 && (a[i]%3 !=0 && a[i]%5 != 0))
        {
            ans = false;
            break;
        }
    }

    if (ans)
    {
        cout<<"APPROVED"<<endl;
    }
    else
    {
        cout<<"DENIED"<<endl;
    }
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  16:30-
//A 16:36
//B 16:46
int solve(void){
	llint b,i=0,ki;cin>>b;
	if(b==0){return 0;}
	while(i*(i+1)/2<b){i++;}
	while(-1){
		ki=i*(i+1)/2;
		if((b-ki)%i==0){cout<<(b-ki)/i+1<<" "<<i<<endl;return 1;}
		i--;
	}
	return 1;
}
int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3104
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int t;

int main()
{
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    int n;
    map<string, int> mmap;
    cin>>n;
    string s;
    int maxt = 0;
    for(int i=0;i<n;++i) {
        cin>>s;
        if(mmap.count(s)==0) mmap[s] = 1;
        else mmap[s]++;
        if(mmap[s]>maxt) maxt = mmap[s];
    }
    vector<string> ans;
    for(auto it=mmap.begin();it!=mmap.end();++it) {
        if(it->second==maxt) ans.push_back(it->first);
    }
    sort(ans.begin(), ans.end());
    for(int i=0;i<ans.size();++i) 
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 26224
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

D = lines[0][0]
Inf = 10 ** 10

last_date = []
for i in 1..26 do
  last_date.push(0)
end

satis = 0
for i in 1..D do
  max_satis = - Inf
  best_contest = 0
  for k in 1..26 do
    now_satis = 0
    now_satis += lines[i+1][k-1]
    for j in 1..26 do
      if j != k then
        now_satis -= (i - last_date[k-1]) * lines[1][j-1]
      end
    end
    if now_satis > max_satis then
      max_satis = now_satis
      best_contest = k
    end
  end
  satis += lines[i+1][best_contest-1]
  last_date[best_contest-1] = i
  if i < D then
    puts i % 26 + 1
  else
    print i % 26 + 1
  end
end

Measured memory_bytes: 14388