akhauriyash/Code-Regression huggingface dataset:
iN ,iX  = [int(x) for x in input().split()]
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[iN]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost

#枝刈り
iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,fCeil(iN,2) + 1):
    iThisCost = fCalcCost(iN,iX,aCum,iK)
    if iThisCost > iTotalCost:
        break
    else:
        iTotalCost = iThisCost
print(iTotalCost)


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

res = [0]*20000

for x in range(1, int(N**0.5)):
    for y in range(1, int(N**0.5)):
        for z in range(1, int(N**0.5)):
            idx = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if idx < 20000:
                res[idx] += 1

for r in res[1:N+1]:
    print(r)

Measured memory_bytes: 9444
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
typedef unsigned int uint;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}

int main(){
	int n,S;
	while(n=in(),S=in(),(n||S)){
		int w[102]={},a[102]={};
		int ans = 0;
		for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
		for(int i = 99 ; i >= 0 ; i--) w[i] += w[i+1];
		for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
		for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[max(i+1,S-i+1)];
		printf("%d%c",ans,10);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int n,m,k;
long long int used[100005]={};
queue<long long int> qu[100005];

int main() {
    const long long int mod = 1000000007,INF=99999999999999;
	map<long long int, long long int>mp;
    string str[2005],tmp;
	cout << fixed << setprecision(10);
    cin>>n>>m>>k;
    cout<<min(k,n*m);
    
} 


Measured memory_bytes: 67840
import java.util.Scanner;

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

        int H = scanner.nextInt();
        int W = scanner.nextInt();
        char[][] map = new char[H][W];
        for (int i = 0; i < H; i++) map[i] = scanner.next().toCharArray();
        int[][] dd = new int[][]{{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (map[i][j] == '#') continue;
                int cnt = 0;
                for (int[] d : dd) {
                    int x = i + d[0];
                    int y = j + d[1];
                    if (x >= 0 && x < H && y >= 0 && y< W && map[x][y] == '#') cnt++;
                }
                map[i][j] = (char)('0' + cnt);
            }
        }
        for (int i = 0; i < H; i++) System.out.println(new String(map[i]));
    }
}

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

int main() {
	int n; cin >> n;
	int x[n], c[n];
	for(int i = 0; i < n; i++) {
		cin >> x[i];
		c[i] = x[i];
	}
	sort(c, c + n);
	for (int i = 0; i < n; i++)
	{
		int p = lower_bound(c, c + n, x[i]) - c;
		if(p < n / 2) cout << c[n/2] << endl;
		else cout << c[n/2-1] << endl;
	}

	return 0;
}


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

bool kai(string S){
	string T=S;
	reverse(T.begin(),T.end());
	return T==S;
}

signed main(){
	string S; cin>>S;
	int N=S.size();
	bool ans=true;
	ans=kai(S);
	if(ans)ans=kai(S.substr(0,(N-1)/2));
	if(ans)ans=kai(S.substr((N+1)/2,N));
	cout<<(ans ? "Yes" : "No")<<endl;

	return 0;

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int x = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();

            int c = Math.abs(x - a);
            int d = Math.abs(b - x);

            if (c < d) {
                out.print("A");
            } else {
                out.print("B");
            }
        }

    }
}



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

int N, K, A[100005];
long long p[100005], s[100005];

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		sum += max(0, A[i]);
		p[i] = sum;
	}
	sum = 0;
	for (int i = N - 1; i >= 0; i--) {
		sum += max(0, A[i]);
		s[i] = sum;
	}
	sum = 0;
	for (int i = 0; i < K; i++) {
		sum += A[i];
	}
	long long ans = max(sum, 0ll) + s[K];
	for (int i = K; i < N; i++) {
		sum += A[i];
		sum -= A[i - K];
		ans = max(ans, max(sum, 0ll) + p[i - K] + s[i + 1]);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int K,X;cin>>K>>X;
    bool ok=false;
    
    for(int i=-1000000;i<=1000000;i++){
        if(ok&&abs(i-X)<=K-1) cout<<" ";
        if(abs(i-X)<=K-1){
            ok=true;
            cout<<i;
        }
    }
    cout<<endl;
    
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)2e5 + 77;
const int A    = 26;

int dp[MAXN], a[MAXN], n;
map<int, int> mn;

void relax(int& x, int y) {
	x = (y < x ? y : x);
}

int get_mn(int x) {
	return (mn.count(x) ? mn[x] : INT_INF);
}

void solve() {
	auto line = fetch<string>();
	n = len(line);

	for(int i = 1; i <= n; ++i) {
		int code = line[i - 1] - 'a';
		a[i] = 1 << code;
		a[i] ^= a[i - 1];
	}

	dp[0] = 0;
	mn[a[0]] = 0;

	for(int i = 1; i <= n; ++i) {
		dp[i] = INT_INF;
		relax(dp[i], get_mn(a[i]) + 1);
		DBG(i); DBG(get_mn(a[i]));

		for(int code = 0; code < A; ++code) {
			int b = a[i] ^ (1 << code);
			relax(dp[i], get_mn(b) + 1);

			DBG(b); DBG(get_mn(b));
		}

		int temp = get_mn(a[i]);
		mn[a[i]] = min(temp, dp[i]);
	}

#ifdef __LOCAL
	cout << "@a: ";

	for(int i = 0; i <= n; ++i) {
		cout << a[i] << ' ';
	}

	cout << '\n';
	cout << "@dp: ";

	for(int i = 0; i <= n; ++i) {
		cout << dp[i] << ' ';
	}

	cout << '\n';
#endif

	cout << dp[n] << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

using namespace std;
   
void primeCal()
{
    const int N = 1000000;
    
    vector<bool> prime(N, true);
    prime[0] = prime[1] = false;
    
    vector<int> count(N);
    
    int n;
    
    for (int i = 2; i*i < N; ++i) 
    {
        if (!prime[i]) 
        { 
            continue; 
        }
        
        for (int j = i*i; j < N; j += i) 
        {
            prime[j] = false;
        }
    }
    
    for (int i = 1; i < N; ++i) 
    {
        count[i] = count[i-1] + prime[i];
    }
    
    while (cin>>n)
    {
        cout << count[n] << endl;
    }
    
    return;
}
     
int main()
{     
    primeCal();
    return 0;
}

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

int main()
{
	char arr[55][55];
	int i,j,h,w,ans;
	
	cin>>h>>w;
	for(i=0;i<h;i++)
		cin>>arr[i];
	
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(arr[i][j]=='.')
			{
				ans=0;
				
				if((i-1)>=0&&arr[i-1][j]=='#')
				{
					ans++;
				}
				
				if((i+1)<h&&arr[i+1][j]=='#')
				{
					ans++;
				}
				
				if((j-1)>=0&&arr[i][j-1]=='#')
				{
					ans++;
				}
				
				if((j+1)<w&&arr[i][j+1]=='#')
				{
					ans++;
				}
				
				if((i-1)>=0&&(j-1)>=0&&arr[i-1][j-1]=='#')
				{
					ans++;
				}
				
				if((i-1)>=0&&(j+1)<w&&arr[i-1][j+1]=='#')
				{
					ans++;
				}
				
				if((i+1)<h&&(j-1)>=0&&arr[i+1][j-1]=='#')
				{
					ans++;
				}
				
				if((i+1)<h&&(j+1)<w&&arr[i+1][j+1]=='#')
				{
					ans++;
				}
				arr[i][j]='0'+ans;
			}
		}
	}
	for(i=0;i<h;i++)
		cout<<arr[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> pii;
const int NSIZ=1000010;
const int MSIZ=1000010;
const int mxint=-1u/2;
int n, m, o, re=0;
int a[NSIZ], b[NSIZ];
bool chk[NSIZ];
int main(){
	int i, j, k, l;
	scanf("%d %d", &n, &m);
	if(n<=0 && m>=0){printf("Zero");return 0;}
	else if(n>0){printf("Positive"); return 0;}
	else if(m<0){
		if((m-n+1)%2==0)printf("Positive");
		else printf("Negative");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
using namespace std;
 
int main() {
 
	long long n, MAX=-1000000000;
	cin >> n;
	vector<int> R(n);

	/* 株価の値を入力 */
	for(int i = 0; i < n; i++){
		cin >> R[i];
	}

	/* 株価の最大値を探す */
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(MAX < R[j]-R[i]) MAX = R[j]-R[i];
			if(R[i]>=R[j])break;
		}
	}

	cout << MAX << endl;
 
	return 0;
}
 


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

using namespace std;

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

int N;

int main() {
  cin >> N;
  rep(i, N) {
    int t[3];
    rep(i, 3) cin >> t[i];
    sort(t, t+3);
    int a = t[0], b = t[1], c = t[2];
    if (a*a + b*b == c*c) cout << "YES" << "\n";
    else                  cout << "NO"  << "\n";
  }
  return 0;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;

int f(int n) {
    if (n & 1) {
        return 3 * n + 1;
    } else {
        return n / 2;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> heights(n);
    for (int i = 0; i < n; ++i) {
        cin >> heights[i];
    }
    int ans = 0;
    for (int i = 1; i <= 100; ++i) {
        int curr = 0;
        bool found = false;
        for (int j = 0; j < n; ++j) {
            if (heights[j] >= 1) {
                heights[j]--;
                if (!found) {
                    ++curr;
                    found = true;
                }
            } else {
                found = false;
            }
        }
        ans += curr;
    }
    cout << ans << endl;
    return 0;
}


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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;
constexpr i64 MAX_N = 1e5 + 1;

vector<i64> fact(MAX_N), fact_inv(MAX_N);

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 multi_inv(i64 a, i64 md) {
    i64 x, y;
    extgcd(md, a, x, y);
    return (y > 0 ? y : md + y);
}

void set_fact(i64 n){
    fact[0] = 1; fact_inv[0] = 1;
    for(i64 i=1;i<=n;++i){
        fact[i] = i * fact[i-1] % MOD;
        fact_inv[i] = multi_inv(fact[i], MOD);
    }
}

i64 ncr(i64 n, i64 r){
    if(n < r)return 0;
    if(n < 0 || r < 0)return 0;
    return fact[n] * (fact_inv[r] * fact_inv[n-r] % MOD) % MOD;
}

int main(){
    i64 n, k;
    cin >> n >> k;
    set_fact(n);
    vector<i64> a;
    for(int i=0;i<n;++i){
        i64 tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    vector<pair<i64, i64>> v;
    v.emplace_back(a[0], 1);
    for(int i=1;i<n;++i){
        if(a[i] == v.back().first)v.back().second++;
        else{
            v.emplace_back(a[i], 1);
        }
    }

    i64 cum = 0, ans = 0;
    for(auto e: v){
        cum += e.second;
        if(cum >= k){
            i64 num = ncr(cum, k) - ncr(cum-e.second, k);
            if(num < 0)num += MOD;
            i64 tmp = num * e.first;
            if(tmp < 0)tmp += (abs(tmp)+MOD-1)/MOD * MOD;
            ans = (ans + tmp) % MOD;
        }
        if(n - (cum - e.second) >= k){
            i64 num = ncr(n-(cum-e.second), k) - ncr(n-cum, k);
            if(num < 0)num += MOD;
            i64 tmp = num * e.first;
            if(tmp < 0)tmp += (abs(tmp)+MOD-1)/MOD * MOD;
            ans -= tmp;
            if(ans < 0)ans += (abs(ans)+MOD-1)/MOD * MOD;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <set>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    int n,a;

    cin >> n;
    cin >> a;

    int res = n % 500;

    if(res > a) cout << "No" << "\n";
    else cout << "Yes" << "\n";

    return 0;
}

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

ll solve() {
    int N, M, x, y;
    cin >> N >> M;
    vector<int> b(N, 1), r(N);
    r[0] = 1;
    for ( int i = 0; i < M; i++ ) {
        cin >> x >> y;
        x--, y--;
        if ( r[x] == 1 ) r[y] = 1;
        b[x]--;
        b[y]++;
        if ( b[x] == 0 ) r[x] = 0;
    }
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( r[i] == 1 ) ans++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;
 
map<ll,ll> mcount;
ll a,b,c,d;
ll rec(ll n){
  if(n == 0) return 0;
  if(n == 1) return d;
  if(mcount.count(n)) return mcount[n];
 
  ll u2 = (n+1)/2*2;
  ll l2 = n/2*2;
  ll u3 = (n+2)/3*3;
  ll l3 = n/3*3;
  ll u5 = (n+4)/5*5;
  ll l5 = n/5*5;
 
  ll ret = 1e18;
  if(n < 1e18/d) ret = n*d;
  ret = min(ret, llabs(l2-n)*d + a + rec(l2/2));
  ret = min(ret, llabs(u2-n)*d + a + rec(u2/2));
 
  ret = min(ret, llabs(l3-n)*d + b + rec(l3/3));
  ret = min(ret, llabs(u3-n)*d + b + rec(u3/3));
 
  ret = min(ret, llabs(l5-n)*d + c + rec(l5/5));
  ret = min(ret, llabs(u5-n)*d + c + rec(u5/5));
 
 
  mcount[n] = ret;
  return ret; 
}
 
int main(){
  int t;cin >> t;
  rep(i,t){
    ll n;cin >> n >> a >> b >> c >> d;
    mcount.clear();
    cout << rec(n) << endl;
  }
}

Measured memory_bytes: 4532
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>
#include <chrono>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back


using namespace std;
using namespace std::chrono;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[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' };
const int MOD = 1000000007;
char alphs[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' };

int visited[200001];
int sizy = 0;
vector<vector<int>> adj(200005);

void dfs(int a) {
    if (visited[a] == 1) return;
    visited[a] = 1;
    sizy++;
    for (auto x : adj[a]) {
        if (visited[x] == 0) dfs(x);
    }

}



void solve() {

    int n, m;
    cin >> n >> m;

    
    vector<set<int>> present(n+1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        if (present[a].count(b) == 0) {
            adj[a].pb(b);
            adj[b].pb(a);
            present[a].insert(b);
            present[b].insert(a);
        }
    }
    int maxy = 0;
    for (int i = 1; i <= n; i++) {
        if (visited[i] == 1) {
            continue;
        }
        if (visited[i] == 0) {
            sizy = 0;
            dfs(i);
            maxy = max(sizy, maxy);
        }
    }

    cout << maxy << endl;
    

}


int main() {

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

        
        solve();


    return 0;
}

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

using namespace std;
typedef long long ll;

// #define DEBUG

void shave(vector<int> &v, int n)
{
    vector<int> x, y;
    int n_sq = sqrt(n) + 1;
    for (int i = 3; i < n + 1; i += 2)
    {
        x.push_back(i);
    }
    for (int i = 3; i < n_sq; i += 2)
    {
        for (auto itr = x.begin(); itr != x.end(); itr++)
        {
            if (*itr == i || *itr % i != 0)
                y.push_back(*itr);
        }
        x.clear();
        x = y;
        y.clear();
    }
    if (n >= 2)
        x.insert(x.begin(), 2);

    for (auto itr = x.begin(); itr != x.end(); itr++)
    {
        v.push_back(*itr);
    }
}

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    const int Maxshave = 1e4;
    int n, s, ans;
    cin >> n;
    ans = 0;
    bool isprime;
    vector<int> v;
    shave(v, Maxshave);
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        isprime = true;
        for (auto itr = v.begin(); itr != v.end(); itr++)
        {
            if (*itr == s)
                break;
            else if (s % *itr == 0)
            {
                isprime = false;
                break;
            }
        }
        if (isprime == true)
            ans += 1;
    }
    cout << ans << endl;
}


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

int main() {

  const int size = 50022;
  int seq[size] = {};

  for (int i = 2; i < size; ++i)
    for (int j = i * 2; j < size; j += i)
      seq[j] = 1;

  int n;
  while (cin >> n) {
    int v1, v2;

    for (int i = n-1; 0 < i; --i) {
      if (seq[i] == 0) {
        v1 = i;
        break;
      }
    }

    for (int i = n+1; 0 < size; ++i) {
      if (seq[i] == 0) {
        v2 = i;
        break;
      }
    }

    cout << v1 << " " << v2 << endl;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double rad = (double)(H*30 + M*0.5 - M*6)*M_PI/180.0;
    double ans = sqrt(A*A + B*B -2.0*A*B*cos(rad));
    printf("%10.10f\n", ans);

    return 0;
}

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

signed main() {
	ios_base::sync_with_stdio(false);

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

	// sort(a.begin(), a.end());
	// sort(b.begin(), b.end());
	int d = accumulate(b.begin(), b.end(), 0ll) - accumulate(a.begin(), a.end(), 0ll);
	int num = 0;
	for (int i = 0; i < n; i++) {
		num += max(0ll, b[i] - a[i] + 1ll) / 2;
	}
	if (d >= 0 && num <= d) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve(){
  int ans=0;

  bool V[MAX];
  for(int i=0;i<n;i++){
    B[i]=A[i];
    V[i]=false;
  }

  sort(B,B+n);
  for(int i=0;i<n;i++) T[B[i]]=i;
   for(int i=0;i<n;i++){
     if(V[i]) continue;
     int cur =i;
     int S=0;
     int m=VMAX;
     int an=0;
     while(1){
       V[cur]=true;
       an++;
       int v=A[cur];
       m=min(m,v);
       S += v;
       cur=T[v];
       if(V[cur]) break;
     }
     ans+= min(S+(an-2)*m,m+S+(an+1)*s);
   }
   return ans;
}



int main(){
  cin >> n;
  s=VMAX;
   for(int i=0;i<n;i++){
     cin >> A[i];
     s=min(s,A[i]);
   }
   int ans=solve();
   cout << ans << endl;

   return 0;
}




Measured memory_bytes: 3164
def main():
    N , M = map(int,input().split())
    val = [map(int,input().split()) for _ in range(M)]
    ans = [-1 for _ in range(N)]
    flag = True
    for i in range(M):
        p,q = val[i]
        if ans[p-1] != -1 and ans[p - 1] != q :
            flag = False
        if ans[p -1] == -1 :
            ans[p-1] = q
    ans_val = 0
    if ans[0] == -1 and N >= 2:
        ans[0] = 1
    for i in range(N):
        if ans[i] != -1 :
            ans_val += ans[i] * (10 ** (N - 1 -i))

    if (ans[0] == 0 and N != 1):
        print(-1)
    elif  (not flag) :
        print(-1)
    else:
        print(ans_val)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


long int merge(long int a1[], long int a2[], long int b1[], long int b2[], long int a1_size, long int a2_size, long int b1_size, long int b2_size, long int a[], long int b[]);
long int mergeSort(long int a[], long int a_size, long int b[], long int b_size);

int main(void)
{
	long int n;
	long int i, j;
	long int work;
	long int a[200000];
	long int b[200000];
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
		b[i] = i + 1;
	}
	/*
	if(n <= 20) {
		for(i = 0; i < n - 1; i++) {
			for(j = 0; j < n - 1 - i; j++) {
				if(a[j] > a[j + 1]) {
					work = a[j];
					a[j] = a[j + 1];
					a[j + 1] = work;
					
					work = b[j];
					b[j] = b[j + 1];
					b[j + 1] = work;
				}
			}
		}
		
		for(i = 0; i < n; i++) {
			printf("%ld ", b[i]);
		}
		return 0;
	}
	*/
	mergeSort(a, n, b, n);
	
	for(i = 0; i < n; i++) {
		printf("%ld ", b[i]);
	}
	//printf("%ld", b[n - 1]);
	
	return 0;
}

long int merge(long int a1[], long int a2[], long int b1[], long int b2[], long int a1_size, long int a2_size, long int b1_size, long int b2_size, long int a[], long int b[])
{
	long int i = 0, j = 0;
	
	while( (i < a1_size ) || (j < a2_size) ) {
		if( (j >= a2_size ) || ( (i < a1_size) && (a1[i] < a2[j]) ) ) {
			a[i + j] = a1[i];
			b[i + j] = b1[i];
			i++;
		} else {
			a[i + j] = a2[j];
			b[i + j] = b2[j];
			j++;
		}
	}
	
	return 0;
}

long int mergeSort(long int a[], long int a_size, long int b[], long int b_size)
{
	long int m = a_size / 2, n = a_size - m;
	long int a1[m];
	long int a2[n];
	long int b1[m];
	long int b2[n];
	long int i, j;
	
	if(a_size > 1) {
		for(i = 0; i < m; i++) {
			a1[i] = a[i];
			b1[i] = b[i];
		}
		for(i = 0; i < n; i++) {
			a2[i] = a[m + i];
			b2[i] = b[m + i];
		}
		mergeSort(a1, m, b1, m);
		mergeSort(a2, n, b2, n);
		merge(a1, a2, b1, b2, m, n, m, n, a, b);
	}
	
	return 0;
}


Measured memory_bytes: 6656
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    A2IN(ll, l, ll, r, N);
    ll ans = 0;
    REP(i, N)
    {
        ans += r[i] - l[i] + 1;
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+7;
const ll mod = 1e9+7;

int n,m;
int ar[maxn];
vector<int> g[maxn];
ll ans=1;
ll dp[maxn];
void dfs(int u,int pre){
    int ins = (u!=1)+1;
    for(auto v:g[u]){
        if(v!=pre){
            if(m<=ins)ans=0;
            ans = ans*(m-ins)%mod;
            //cout<<v<<" "<<m-ins<<"\n";
            ins++;
            dfs(v, u);
        }
    }
}
int main()
{
    scanf("%d%d", &n, &m);
    for(int i=1;i<n; i++){
        int a,b;scanf("%d%d", &a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans=m;
    dfs(1, 0);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 34688
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int THP = scanner.nextInt();
		int TAP = scanner.nextInt();
		int AHP = scanner.nextInt();
		int AAP = scanner.nextInt();
		
		scanner.close();
		
		int TC = AHP/TAP;
		int TCP = AHP%TAP;
		if (TCP != 0) {
			TC = TC + 1;
		}
		
		int AC = THP/AAP;
		int ACP = THP%AAP;
		
		if (ACP != 0) {
			AC = AC + 1;
		}
		
		if (TC == AC) {
			System.out.println("Yes");
		} else if (TC < AC) {
			System.out.println("Yes");
		} else if (TC + 1 == AC) {
			System.out.println("Yes"); 
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 27024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        S: String,
        T: String
    }
    
    let s_l = S.len();
    let t_l = T.len();
    if (S == S.to_lowercase()) && (T == T.to_lowercase()) && (t_l - s_l) == 1 {
        let S_STR: &str = &S[0..s_l];
        let T_STR: &str = &T[0..s_l];
        if S_STR == T_STR {
            println!("Yes");
        } else {
            println!("No");
        }
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2128
m,d = map(int, input().split())

count = 0

for month in range(1,m+1):
    for day in range(1,d+1):
        d_1  = day%10
        d_10 = day//10
        if (d_1>=2 and d_10>=2):
            if d_1 * d_10 == month:
                count = count + 1
        else:
            pass
        
print(count)    

Measured memory_bytes: 3060
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<(n-1);i++){
        if(v[i]>v[i-1]){
            v[i]--;
        }
    }
    vector<int> temp;
    temp = v;
    sort(all(temp));
    for(int i=0;i<n;i++){
        if(temp[i]!=v[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}
//.........

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

using ll = long long;

using namespace std;

int main() {
    int n;
    set<int> s;
    cin >> n;
    for (int i=0, ai; i<n; i++) {
        cin >> ai;
        s.insert(ai);
    }
    cout << (s.size() == n ? "YES" : "NO") << '\n';
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int n , t = 0;
    cin >> n;
	int a;
	for(int i = 0; i < n; i++){ 
        cin >> a;
        t+=a;
    }
	t-=n;
    cout << t << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a, b;
  REP(i, n)
  {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  REP(i, n)
  {
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }

  int ans = 0;
  REP(k, 29)
  {
    vector<int> c;
    REP(i, n)
    {
      c.push_back(b[i] % (1 << (k + 1)));
    }
    sort(c.begin(), c.end());

    int count = 0;
    REP(i, n)
    {
      int t = (1 << k);
      int moda = a[i] % (1 << (k + 1));
      REP(j, 2)
      {
        auto init = distance(c.begin(), lower_bound(c.begin(), c.end(), (t + 2 * j * t) - moda));
        auto end = distance(c.begin(), lower_bound(c.begin(), c.end(), (2 * (j + 1) * t) - moda));
        count += end - init;
        count %= 2;
      }
    }

    if (count % 2 == 1)
    {
      ans += (1 << k);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3680
dist = lambda b, e, k: (k+(e-m))%(e-b)

n = int(input())
a = list(map(int, input().split(' ')))
q = int(input())
for i in range(q):
    b, m, e = list(map(int, input().split(' ')))

    tmp = [None for i in range(e-b)]
    for k in range(e-b):
        tmp[dist(b, e, k)] = a[b+k]
    a[b:e] = tmp

print(' '.join(list(map(str, a))))


Measured memory_bytes: 5720
n = int(input())
a = list(map(int, input().split()))
sorted_a = sorted(a, reverse=True)
alice_sum = 0
bob_sum = 0
for i in range(len(sorted_a)):
    if i % 2 == 0:
        alice_sum += sorted_a[i]
    else:
        bob_sum += sorted_a[i]
print(alice_sum - bob_sum)

Measured memory_bytes: 3060
(require '[clojure.string :as str])


(def mn (map #(Integer. %) (str/split (read-line) #" ")))

(defn flip-flip [n m]
  (cond
    (and (= m 1) (= n 1))
      1
    (= m 1)
      (let [t1 2
            t2 (- n 2)]
        t2)
    (= n 1)
      (let [t1 2
            t2 (- m 2)]
        t2)
    (and (>= m 2) (>= n 2))
      (let [t3 4
            t5 (+ (* 2 (- n 2)) (* 2 (- m 2)))
            t8 (- (* n m) (* 2 (- m 1)) (* 2 (- n 1)))]
        t8)))

(println (flip-flip (first mn) (last mn)))


Measured memory_bytes: 67976
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func gcd(m, n int) int {
	if m < n {
		m, n = n, m
	}
	if n == 0 {
		return m
	}
	mod := m % n
	ans := n
	for mod > 0 {
		ans = mod
		m, n = n, mod
		if m < n {
			m, n = n, m
		}
		mod = m % n
	}
	return ans
}
func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	aa := getIntList(scanner)
	dp := make([]int, n)
	dp2 := make([]int, n)
	dp[0] = aa[0]
	dp2[0] = aa[n-1]
	for i := 1; i < n; i++ {
		dp[i] = gcd(dp[i-1], aa[i])
		dp2[i] = gcd(dp2[i-1], aa[n-1-i])
	}
	max := 0
	var ans int
	for i := 0; i < n; i++ {
		if i == 0 {
			ans = dp2[n-2-i]
		} else {
			if i == n-1 {
				ans = dp[i-1]
			} else {
				ans = gcd(dp[i-1], dp2[n-2-i])
			}
		}
		if max < ans {
			max = ans
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 16256
N = 100
n = input()
p = [0 for i in xrange(N+1)]
m = [[0 for i in xrange(N+1)] for j in xrange(N+1)]
for i in xrange (1,n+1):
    p[i-1],p[i] = map(int,raw_input().split())
    m[i][i] = 0
for l in xrange (2,n+1):
    for i in xrange(1,n-l+2):
        j = i + l - 1
        m[i][j] = 10**10
        for k in xrange(i,j):
            m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j])
print max(max(m))

Measured memory_bytes: 6568
#include <cstdio>
#include <map>

typedef long long LL;
const int Mod[4] = {999988679, 999988609, 999988589, 999988571};
const int B[4] = {370728, 370732, 370729, 370728};
const int iB[4] = {396903752, 462741403, 834141573, 238331041};
const int MN = 250005;

inline void Add(int &x, int y, int i) { x -= (x += y) >= Mod[i] ? Mod[i] : 0; }

typedef std::tuple<int, int, int, int> i4;

int N;
char S[MN];
int A[4][MN], D[4][MN];
std::map<i4, int> Buk;
LL Ans;

int main() {
	scanf("%d%s", &N, S + 1);
	for (int j = 0; j < 4; ++j) A[j][0] = 0, D[j][0] = 1;
	for (int i = 1, V[4] = {1, 1, 1, 1}; i <= N; ++i) {
		for (int j = 0; j < 4; ++j) {
			A[j][i] = A[j][i - 1];
			if (S[i] == '+') Add(A[j][i], V[j], j);
			if (S[i] == '-') Add(A[j][i], Mod[j] - V[j], j);
			if (S[i] == '>') V[j] = (LL)V[j] * B[j] % Mod[j];
			if (S[i] == '<') V[j] = (LL)V[j] * iB[j] % Mod[j];
			D[j][i] = V[j];
		}
	}
	for (int i = N; i >= 0; --i) {
		Ans += Buk[std::make_tuple(
			(A[0][i] + (LL)A[0][N] * D[0][i]) % Mod[0],
			(A[1][i] + (LL)A[1][N] * D[1][i]) % Mod[1],
			(A[2][i] + (LL)A[2][N] * D[2][i]) % Mod[2],
			(A[3][i] + (LL)A[3][N] * D[3][i]) % Mod[3]
		)];
		++Buk[std::make_tuple(A[0][i], A[1][i], A[2][i], A[3][i])];
	}
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 39552
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
int main(){
    int n,m,k;
    bool ans=false;
    cin >>n>>m>>k;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i*j+(n-i)*(m-j)==k){
                ans=true;
            }
        }
    }
    cout<<solve(ans)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push (int);
int pop ();


int top,stack[100];
int main(){
  int a,b;
  char c[100];

  while( scanf("%s",c)!=EOF){

    if(c[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(c[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(c[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      push(atoi(c));
    }
  }

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

  return 0;
}

void push (int n){

  stack[++top]=n;
}

int pop (){

  if(top<=0){
  top--;
  return 0;
  }
  
  else{
    top--;
    return stack[top+1];
  }
  
}



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

ll modpow(ll a, ll n){
  ll ans = 1;
  while(n > 0){
    if(n & 1) ans = ans * a % mod;
    n >>= 1;
    a = a * a % mod;
  }
  return ans;
}

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

int main(){
	ll n;
	cin >> n;
	map<pll, pll> slope;
	ll all0 = 0;
	rep(i, 0, n){
		ll a, b;
		cin >> a >> b;
		if(a == 0 && b == 0){
			all0++;
			continue;
		}
		if(mkp(a, b) < mkp(0ll, 0ll)) a = -a, b = -b;
		ll g = gcd(abs(a), abs(b));
		a /= g, b /= g;
		if(b <= 0) slope[mkp(-b, a)].second++;
		else slope[mkp(a, b)].first++;
	}

	ll ans = 1;
	vrep(i, slope){
		ll num1 = i.second.first, num2 = i.second.second;
		ans = ans * (modpow(2, num1) + modpow(2, num2) - 1) % mod;
	}
	cout << (ans + all0 - 1 + mod) % mod << endl;
}

Measured memory_bytes: 19228
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll INF = 1e15;
typedef pair<ll, ll> P;
struct edge
{
  ll to; 
  ll cost;
};
ll V;
vector<edge> G1[100000], G2[100000];
ll D1[100000], D2[100000];
void dijkstra1(ll s)
{
  priority_queue<P, vector<P>, greater<P>>que;
  fill(D1, D1 + V, INF);
  D1 [s] = 0;
  que.push(P(0,s));
  while (!que.empty())
  {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (D1[v] < p.first)
      continue;
    for (int i = 0; i < G1[v].size(); i++)
    {
      edge e = G1[v][i];
      if (D1[e.to] > D1[v] + e.cost)
      {
        D1[e.to] = D1[v] + e.cost;
        que.push(P(D1[e.to], e.to));
      }
    }
  }
}
void dijkstra2(ll s)
{
  priority_queue < P, vector<P>, greater<P>>que;
  fill(D2, D2 + V, INF);
  D2[s] = 0;
  que.push(P(0,s));
  while (!que.empty())
  {
    P p = que.top();
    que.pop();
    ll v = p.second;
    if (D2[v] < p.first)
      continue;
    for (int i = 0; i < G2[v].size(); i++)
    {
      edge e = G2[v][i];
      if (D2[e.to] > D2[v] + e.cost)
      {
        D2[e.to] = D2[v] + e.cost;
        que.push(P(D2[e.to], e.to));
      }
    }
  }
}

int main()
{
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;
  V = n;
  for (int i = 0; i < m; i++)
  {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; 
    v--;
    G1[u].push_back({v,a});
    G1[v].push_back({u,a});
    G2[u].push_back({v,b});
    G2[v].push_back({u,b});
  }
  //startからの最短とgoalからの最短
  dijkstra1(s);
  dijkstra2(t);
  ll res[100000];
  //i年後について
  for (int i = 0; i < n; i++)
  {
    res[i] = D1[i] + D2[i];
  }
  for (int i = n - 2; i >= 0; i--)
  {
    res[i] = min(res[i], res[i + 1]);
  }
  for (int i = 0; i < n; i++)
  {
    cout << INF - res[i] << endl;
  }
}

Measured memory_bytes: 19140
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a;
    cin >>a;
    if(a<1200) cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int count = 0;
		int x = 0;
		for (int i = b; i >= a; i --) {
			x = c % i;
			if (x == 0) {
				count = count + 1;
			}
		}
		System.out.println (count);
	}
}


Measured memory_bytes: 26316
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

struct UnionFind {
	vector<int> par;
	vector<int> rank;

	UnionFind(int n) : par(n), rank(n) { 
		for(int i = 0; i < n; i++) {par[i] = i; rank[i] = 1;}
	}

	int find(int x) {if (par[x]==x) return x; else return par[x] = find(par[x]);}
	void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x==y) return;
 
        if (rank[x]>rank[y]) {par[y] = x; rank[x] += rank[y];}
        else {par[x] = y; rank[y] += rank[x];}
  }
	bool same(int x, int y) {return find(x)==find(y);}
};

int ans[100005];
int N, M, K;

int main(void) {
    scanf("%d %d %d", &N, &M, &K);
    UnionFind fr(100005);

    rep(i, 0, M) {
        int a, b;
        scanf("%d %d", &a, &b);
        fr.unite(a, b);
        ans[a]++;
        ans[b]++;
    }

    rep(i, 1, N+1) ans[i] = fr.rank[fr.find(i)] - ans[i];

    rep(i, 0, K) {
        int c, d;
        scanf("%d %d", &c, &d);
        if (fr.same(c, d)) {
            ans[c]--;
            ans[d]--;
        }
    }

    rep(i, 1, N+1) {
        if (i>1) printf(" ");
        printf("%d", ans[i]-1);
    }
    printf("\n");



	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int V, E;
int g[20][20];
int dp[50000][20];

int rec(int S, int v) {  
    if (S == 0) {
        if (v == 0) {
            return 0;
        } else {
            return INF;
        }
    }
    if ((S & (1 << v)) == 0) { 
        return INF;
    }
 
    int &ret = dp[S][v];
    if (ret != 0) return ret;
 
    ret = INF;
    rep(u, V) { chmin(ret, rec(S ^ (1 << v), u) + g[u][v]); }
    return ret;
}

int main(){
    cin >> V >> E;

    rep(i, 20) {
        rep(j, 20) { g[i][j] = INF; }
    }
    rep(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s][t] = d;
    }

    int ans = rec((1 << V) - 1, 0);
 
    if (ans != INF) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}



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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int MAX = 1e5 + 5;
vector<int> adj[MAX];
int a[MAX];
int n, root;

ll dfs(int source, int father, bool &good) {
	int maxx = 0;
	ll sum = 0;
	for(auto &each : adj[source]) {
		if(each != father) {
			int cur = dfs(each, source, good);
			sum += cur;
			maxx = max(maxx, cur);
		}
	}
	ll ret;
	bool leaf = adj[source].size() == 1;
	if(leaf) {
		ret = a[source];
	}
	else {
		ll deduced = 2 * a[source] - sum;
		if(deduced < 0 || (source == root && deduced)) {
			good = false;
		}
		sum += deduced;
		maxx = max(1LL * maxx, deduced);
		if(maxx > sum - maxx) {
			good = false;
		}
		ret = deduced;
	}
	return ret;
}

int main() {
	scanf("%d", &n);
	fori(i, 1, n + 1) {
		scanf("%d", a + i);
	}
	if(n == 2) {
		puts(a[1] == a[2] ? "YES" : "NO");
		return 0;
	}

	root = -1;
	fori(i, 0, n - 1) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
		if(adj[u].size() > 1) {
			root = u;
		}
		else if(adj[v].size() > 1) {
			root = v;
		}
	}

	bool good = true;
	dfs(root, -1, good);
	puts(good ? "YES" : "NO");

	return 0;
}



Measured memory_bytes: 13952
#include<bits/stdc++.h>
typedef long long i64;
const int P = 1e9 + 7;
int N, M;
int dp[1 << 15];
int ouset[1 << 15];

int main() {
  if(fopen("input.txt","r")) {
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  }
  
  scanf("%d%d", &N, &M);
  while(M--) {
    int u, v; scanf("%d%d", &u, &v);
    --u, --v; ouset[u] |= 1 << v;
  }

  dp[0] = 1;
  for(int S = 0;S < 1<<N; ++S) {
    if(!dp[S]) continue;
    int T = ((1 << N) - 1) ^ S;
    for(int S0 = T; S0; (--S0) &= T) {
      if((S0 & 3) == 3) continue;
      int w = dp[S];
      for(int k = 0;k < N; ++k) {
	if(S >> k & 1) continue;
	if(S0 >> k & 1) w = (i64) w * (1ll << __builtin_popcount(ouset[k] & ~(S | S0))) % P;
	else w = (i64) w * ((1 << __builtin_popcount(ouset[k] & S0)) - 1) % P;
      }
      (dp[S | S0] += w) %= P;
    }
  }

  printf("%d\n", dp[(1 << N) - 1]);
  
  return 0;
}


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

int main(void){

    int N,i,m,n;
    char *hut;

    scanf("%d",&N);
    
    hut=malloc(sizeof(char)*N);

    scanf("%s",hut);

    m=0;

    for(i=0;i<N;i++){
        if(hut[i]=='R'){
            m++;
        }
    }


    n=N-m;

    if(m>n){
        printf("Yes");
    }
    else{
        printf("No");
    }


    return 0;
}

Measured memory_bytes: 128