akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>

typedef unsigned long long ULL;
using namespace std;
typedef struct{
    int *x;
}POS;
bool check(POS x1, POS x2, int D);
int main(){
    int N,D;
    int i,j;
    int count;
    POS *X;
    
    cin >> N >> D;
    X = new POS[N];
    for(i=0;i<N;i++){
        X[i].x = new int[D];
        for(j=0;j<D;j++){
            cin >> X[i].x[j];
        }
    }
    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            if(check(X[i],X[j],D))
                count++;
        }
    }
    cout << count << endl;
    
    return 0;
}
bool check(POS x1, POS x2, int D){
    int dis;
    int ans;
    int i;
    
    dis = 0;
    for(i=0;i<D;i++){
        dis += (x1.x[i] - x2.x[i]) * (x1.x[i] - x2.x[i]);
    }
    ans = sqrt(dis);
    if( ans * ans == dis){
        return true;
    }else{
        return false;
    }
}


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

using namespace std;

int main() {
    long long n;
    cin >> n;
    
    long long ans = 0;
    
    for (long long i = 1; i * i <= n; ++i) if (n % i == 0) {\
        if (i < n / i - 1) {
            ans += n / i - 1;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

#define long long long int

#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(6);

    string s, t;
    cin >> s >> t;
    string str1 = s + t;
    string str2 = t + s;

    long a = stol(str1);
    long b = stol(str2);

    for (long i = 0; i * i <= a; ++i) {
        if (i * i == a) {
            cout << "Yes";
            return 0;
        }
    }
    for (long i = 0; i * i <= b; ++i) {
        if (i * i == b) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,a,b;cin>>x>>a>>b;
    string s[3] ={"delicious","safe","dangerous"};
    if((b-a)<=0){
        cout<<s[0]<<endl;
    }
    else if((b-a)<=x){
        cout<<s[1]<<endl;
    }
    else if((b-a)>x){
        cout<<s[2]<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string S;
  cin >> S;
  int N = len(S);

  vector<int> A(N);
  rep(i, N) {
    A[i] = S[i] - '0';
  }

  reverse(all(A));
  A.pb(0);

  ll ans = 0;
  rep(i, N) {
    ll temp = A[i];
    if (temp <= 4)
      ans += temp;
    else if (temp >= 6) {
      ans += 10 - temp;
      A[i + 1]++;
    } else {
      if (A[i + 1] <= 4)
        ans += temp;
      else {
        ans += 10 - temp;
        A[i + 1]++;
      }
    }
  }
  if (A[N] == 1)
    ans++;
  cout << ans << endl;
}

Measured memory_bytes: 11164
#include<bits/stdc++.h>
using namespace std;
//min(x,y)が0以下の場合はmax(x,y)が返される
//ユークリッドの互除法を元に実装
long long gcd(long long x,long long y){
    if(x<y) swap(x,y);
    //xの方が常に大きい
    long long r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}

//オーバフローしないようにかける順番を気を付ける
long long lcm(long long x,long long y){
    return (x/gcd(x,y))*y;
}
int main(){
  int N;
  cin>>N;
  long long T[N],ans=1;
  for(int i=0;i<N;i++){
    cin>>T[i];
    ans=lcm(ans,T[i]);
  }
  cout<<ans<<endl;
}


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

int n, a[200000];

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

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

using namespace std; 

long long int cnt_digits(long long int N) {
	 int digits = 0;
	
		 while (N>0) {
		 N /= 10;
		 digits++;
		
	}
	
		 return digits;
	
}
int main()
{

	long long int n;
	cin >> n;
	long long int ans = 10000000000;
	
	for (long long int i = 1; i*i <=n ; i++)
	{
		long long int w = 0;
		if (n%i != 0)
		{
			continue;
		}
			w =cnt_digits(n/i);
			if (ans > w)
			{
				ans = w;
			}
		
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
h, w, a, b = map(int, input().split())
if b > h / 2:
  if a > w / 2:
    print('No')
    
for i in range(h):
  if i < b:
    print('0'*a + '1'*(w-a))
  else:
    print('1'*a + '0'*(w-a))

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main()
{
    int n, p;
    while (cin >> n >> p, (n || p))
    {
        int a[n] = {0};
        int i = 0;
        while (true)
        {
            if (p == 0)
            {
                p = a[i];
                a[i] = 0;
            }
            else
            {
                p--;
                a[i]++;
                bool isZero = 0;
                if (p == 0)
                {
                    for (int j = 0; j < n; j++)
                    {
                        if (a[j] != 0 && i != j)
                        {
                            isZero = 1;
                        }
                    }
                    if (isZero == 0)
                    {
                        cout << i << endl;
                        break;
                    }
                }
            }
            i += 1;
            i %= n;
        }
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int main() {
#ifdef LOCAL
  freopen("a.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  string a, b;
  cin >> a >> b;
  sort(a.begin(), a.end());
  sort(b.rbegin(), b.rend());
  dbg(a, b);
  if (a < b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 100000000;

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

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

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  rep(i,n){
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}


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

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

const long int maxN = 1'000'000'000'000;
int main(){
  long int n;
  cin >> n;

  long int maxd;
  maxd = maxN;
  for(long int i =1; i*i<=n; i++){
    if(n%i != 0) continue;
    long int kari;
    kari = i-1 + n/i - 1;
    if (kari < maxd)maxd = kari;
  }
  cout << maxd << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i, m){
        int x, y, z; cin >> x >> y >> z; x--, y--;
        uf.merge(x, y);
    }
    map<ll, int> mp; int cnt = 0;
    rep(i, n){
        int root = uf.root(i);
        if(mp[root]==false){mp[root]=true; cnt++;}
    }
    cout << cnt << ln;
}


Measured memory_bytes: 9776
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)
#define N_MAX (100000+10)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

bool broken[N_MAX];
int dp[N_MAX];

int main(void) {
    int N,M;
    cin>>N>>M;

    for(int i = 0;i < M;i++) {
        int a;
        cin>>a;
        broken[a] = true;
    }

    dp[0] = 1;
    for(int i = 1;i <= N;i++) {
        if(broken[i])
            continue;
        if(i >= 2)
            dp[i] = (dp[i-1] + dp[i-2]) % MOD;
        else
            dp[i] = dp[i-1];
    }

    cout<<dp[N]<<endl;

    return 0;
}






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

typedef long long ll;
#define Re return
#define In inline
#define St static
#define inc(l, i, r) for(i=l; i<r; ++i)
#define dec(l, i, r) for(i=r; i>l; --i)

const int mxn=1<<8; const ll p=1000000007;

int n, m, k, h[mxn]; ll ans=1, c[mxn][mxn];
struct edge{int v, o;} e[mxn];
In void aE(int u, int v)
{
    St int tot=1;
    e[++tot]=(edge){v, u[h]}, u[h]=tot;
}
#define forG for(i=u[h]; v=i[e].v; i=i[e].o)

In int gcd(int a, int b)
{
    for(;b; swap(a, b))
        a%=b;
    Re a;
}

In ll dP(ll a, ll b)
{
    St ll r;
//    printf("a: %d\nb: %d\n", a, b);
    for(r=1; b; a=a*a%p, b>>=1)
        b&1? r=r*a%p: 0;
//    printf("a^b: %d\n", r);
    Re r;
}

int cnt, bel[mxn];

In int chk(int u){Re bel[u]!=cnt? bel[u]=cnt, 1: 0;}

void Tar(int u, int w)
{
    St int tim, DFN[mxn], low[mxn], st[mxn], t, st2[mxn];
    if(DFN[u]) Re;
    int i, j, t2, r, v; DFN[u]=low[u]=++tim;
    forG
        if(DFN[v])
        {
            if(v!=w && DFN[v]<DFN[u])
                low[u]=min(low[u], DFN[v]), st[t++]=i;
        }
        else
        {
            st[t++]=i, Tar(v, u), low[u]=min(low[u], low[v]);
            if(low[v]>=DFN[u])
            {
                for(++cnt, r=t2=0; st[t]!=i; ++t2)
                {
                    --t;
//                    printf("v: %d\n", st[t]);
                    r+=chk(st[t][e].v)+chk(e[st[t]^1].v);
                }
//                printf("r: %d\n", r);
                
                if(t2<r) ans=ans*k%p;
                else if(r==t2)
                {
                    r=0;
                    inc(1, j, t2+1)
                        r=(r+dP(k, gcd(t2, j)))%p;
//            printf("R: %d\n", r);
                    ans=ans*r%p*dP(t2, p-2)%p;
//            printf("1 == %d\n", t2*dP(t2, p-2)%p);
                }
                else
                    ans=ans*c[t2+k-1][k-1]%p;
//                printf("A: %lld\n", ans);
            }
        }
    
}

int main()
{
    int i, j, x;
    scanf("%d%d%d", &n, &m, &k);
    inc(0, i, m)
        scanf("%d%d", &j, &x),
        aE(j, x), aE(x, j);
    inc(0, i, mxn)
        c[i][0]=1;
    inc(1, i, mxn)
        inc(1, j, i+1)
        c[i][j]=(c[i-1][j]+c[i-1][j-1])%p;

    inc(1, i, n+1) Tar(i, 0);
//    j=0;
//    inc(1, i, 2*m+1) if(!vs[i]) ++j;
//    ans=ans*dP(k, j>>1)%p;
//    printf("%d\n", j);
    printf("%lld\n", (ans+p)%p);
    Re 0;
}


Measured memory_bytes: 640
alpha = "abcdefghij"
n=int(input())
patterns = ["a"]
for _ in range(n-1):
    last_patterns = patterns.copy()
    patterns = []
    for string in last_patterns:
        useful_str = alpha[:len(set(string))+1]
        for str_ in useful_str:
            patterns.append(string + str_)

for pat in patterns:
    print(pat)

Measured memory_bytes: 14172
#include <stdio.h>
int main(void){

    int i, x, y, z;
    i = 1;
    while(1){
        scanf("%d %d\n", &x, &y);
        if(x == 0 && y == 0) break;
        if(x > y){
            z = x;
            x = y;
            y = z;
        }
        
        printf("%d %d\n", x, y);
    }
    
    return 0;
}


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

using namespace std;


typedef long long ll;
#define loop(i, init, val) for(i = init; i < val; i++)
#define srt(v) sort(v.begin(), v.end())

int main(){
	int i;
	ll h;
	cin >> h;

	int depth = int(log2(double(h))) + 1;
	ll bpow[depth]; bpow[0] = 1;
	loop(i,1,depth)	bpow[i] = bpow[i-1] * 2;

	ll sum = 0;
	loop(i, 0, depth)	sum += bpow[i];
	cout << ll(pow(2, depth)) - 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
signed main() {
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == 'L') {
		 cout << "No\n"; return 0;
	    }
		if (i % 2 == 1 && s[i] == 'R') { cout << "No\n"; return 0; }
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    ll l;
    cin >> l;
    ll N = 1000000;
    //vector<vector<pii> > g(20);
    vector<ll> power3(20);
    power3[0] = 1;
    for (int i = 1; i < 20; ++i) {
        power3[i] = power3[i - 1] * 3;
    }
    int m = 36;
    ll ol = l;
    for (int i = 14; i >= 0; --i) {
        if (l >= power3[i] * 2) {
            //cout << i + 1 << " " << 20 << " " << (l - power3[i]) << endl;
            //cout << i + 1 << " " << 20 << " " << (l - power3[i] * 2) << endl;
            l -= power3[i] * 2;
            m += 2;
        }
        if (l >= power3[i]) {
            //cout << i + 1 << " " << 20 << " " << (l - power3[i]) << endl;
            l -= power3[i];
            ++m;
        }
    }
    cout << 20 << " " << m << endl;
    l = ol;
    for (int i = 0; i < 12; ++i) {
        cout << i + 1 << " " << i + 2 << " " << 0 << endl;
        if (power3[i] * 2 <= N)
        cout << i + 1 << " " << i + 2 << " " << power3[i] << endl;
        if (power3[i] * 2 <= N)

        cout << i + 1 << " " << i + 2 << " " << power3[i] * 2 << endl;
    }
    for (int i = 14; i >= 0; --i) {
        if (l >= power3[i] * 2) {
            cout << i + 1 << " " << 20 << " " << (l - power3[i]) << endl;
            cout << i + 1 << " " << 20 << " " << (l - power3[i] * 2) << endl;
            l -= power3[i] * 2;
        }
        if (l >= power3[i]) {
            cout << i + 1 << " " << 20 << " " << (l - power3[i]) << endl;
            l -= power3[i];
        }
    }
    
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll  N;
    ll res = 1;
    cin >> N;
    
    int counter = 0;
    while(N != 0){
        N /= 2;
        res *= 2;
    }
    cout << res -1 << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int binarysearch(int);

int S[100000], n;

int main(){
  int q, i, C=0;
  int T[50000];

  scanf("%d", &n);

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

  scanf("%d", &q);

  for( i = 0 ; i < q ; i++ ){
    scanf("%d", &T[i]);
    if( binarysearch(T[i]) ) C++;
  }
  printf("%d\n", C);
  return 0;
}

int binarysearch(int t){
  int l=0, r=n, mid;
  while( l < r ){
    mid = ( l + r ) / 2;
    if( t == S[mid] ) return 1;
    if( t > S[mid] ) l = mid + 1;
    else if( t < S[mid] ) r = mid;
  }
  return 0;
}



Measured memory_bytes: 2268
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, A, B;
  cin>>N>>A>>B;

  int ansMAX = min(A, B);
  int ansMIN = max(0, (A+B)-N);
  cout<<ansMAX<<" "<<ansMIN<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll k,n;
int main(){
    cin>>n>>k;
    vector<ll> v(n,0);
    rep(i,n) cin>>v[i];
    int cnt=0;
    sort(v.begin(),v.end());
    if(k>=n){
        cout<<"0"<<endl;
    }
    else{
        ll ans=0;
        for(int i=0;i<n-k;i++) ans+=v[i];
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		if (count <= 1000) {
			String[] triangles = new String[count];
			for (int j = 0; j < count; j++) {
				int side1 = sc.nextInt();
				int side2 = sc.nextInt();
				int side3 = sc.nextInt();
				if (side1 >= 1 && side1 <= 1000) {
					if (side2 >= 1 && side2 <= 1000) {
						if (side3 >= 1 && side3 <= 1000) {
							String result = isRightTriangle(side1, side2, side3);
							triangles[j] = result;
						}
					}
				}
			}
			for (int k = 0; k < count; k++) {
				System.out.println(triangles[k]);
			}
		}
	}

	private static String isRightTriangle(int s1, int s2, int s3) {
		String test = "NO";
		if ((s1 * s1) == (s2 * s2) + (s3 * s3)) {
			test = "YES";
		} else if ((s2 * s2) == (s1 * s1) + (s3 * s3)) {
			test = "YES";
		} else if ((s3 * s3) == (s1 * s1) + (s2 * s2)) {
			test = "YES";
		}
		return test;
	}
}

Measured memory_bytes: 33784
#include<bits/stdc++.h>
using namespace std;
string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i != S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    final int N=1000000;
    boolean[] p=new boolean[N+1];
    p[0]=p[1]=true;
    for(int i=2;i<=Math.sqrt(N);++i){
      if(p[i]) continue;
      for(int j=i*i;j<=N;j+=i) p[j]=true;
    }
    int[] s=new int[N+1];
    for(int i=2;i<=N;++i) s[i]=s[i-1]+((p[i])?0:1);
    Scanner sc=new Scanner(System.in);
    while(sc.hasNext()){
      int n=sc.nextInt();
      System.out.println(s[n]);
    }
  }
}

Measured memory_bytes: 27404
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main()
{
    int n,m,i,j;
    int a[200000],b[200000];
    bool bucket[200000] = {0};
    

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

    for (i = 0; i < m; i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        if(a[i] == 1)bucket[b[i] - 1] = 1;
    }
    for (i = 0; i < m; i++)
    {
        if(b[i] == n && bucket[a[i] - 1] == 1)break;
    }

    if(i == m)printf("IMPOSSIBLE");
    else printf("POSSIBLE");

}

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

int n;
int s[nn];
int solve(){
    int dp[n+1]={0};
    dp[1] = 0;
    dp[2] = abs(s[2] - s[1]);
    dp[3] = min(abs(s[3]-s[1]),abs(s[2]-s[3])+dp[2]);
    for(int i=4;i<=n;i++){
        dp[i] = INT_MAX;
        int x = abs(s[i]-s[i-1])+dp[i-1];
        int y = abs(s[i]-s[i-2])+dp[i-2];
        
        dp[i] = min(dp[i],min(x,y)); 
    }
    return dp[n];
}

int32_t main() {
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }

    cout<<solve();
}


Measured memory_bytes: 1792
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize, m: usize, k: usize,
    }
    let mut board = vec![vec![0; m]; n];
    let mut cnt = 0;

    for n_ in 0..n + 1 {
        for m_ in 0..m + 1 {
            let acc = n_ * (m - m_) + m_ * (n - n_);

            if acc == k {
                return println!("Yes");
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
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(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s; cin >> s;
  char c = s[0];
  int ans = 0;
  rep(i,s.size()){
    ans += (c!=s[i]);
    c = s[i];
  }
  cout << ans;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int sum=0;
  int ext=0;
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N-1);
  REP(i,N) cin >> A[i];
  REP(i,N) cin >> B[i];
  REP(i,N-1) cin >> C[i];
  REP(i,N-1) if(A[i+1]==A[i]+1) ext += C[A[i]-1];
  REP(i,N) sum += B[i];
  cout << sum + ext << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main()
{
	cin>>s;
    n=s.size();
    if((s[0]==s[n-1]&&n%2==0)||(s[0]!=s[n-1]&&n%2==1)) printf("First\n");
    else printf("Second\n");
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define PINK 1
#define RED 2
int n,m[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX],p[MAX],color[MAX];
  int i,j;
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=PINK;
  while(1){
    minv=INFTY;
    int u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=RED){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=RED;
    for(j=0;j<n;j++){
      if(color[j]!=RED && m[u][j]!=INFTY){
	if(d[j]>d[u]+m[u][j]){
	  d[j]=d[u]+m[u][j];
	  color[j]=PINK;
	}
      }
    }
  }for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]==INFTY)
      printf("%d\n",-1);
    else printf("%d\n",d[i]);
  }
}
int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      m[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      m[u][v]=c;
    }
  }
  dijkstra();

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define rep3(i,n,m) for(long long i=n;i>=m;i--)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using graph= vector<vector<int>>; 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
 ll n;
 cin >> n ;
 vector<ll> A(n) ;
 rep(i,n) cin>> A[i] ;
 sort(A.begin(),A.end()) ;
 int sakai=0 ;
 int ans=0 ;
 if(A[0]==A[n-1]){
   if(A[0]==n-1||(A[0])*2<=n)
   ans=1 ;
 }

if(A[0]+1==A[n-1]){
 rep(i,n-1){
   if(A[i]!=A[i+1]){
     sakai =i+1 ;
     break ;
   }
} 
    ll k=A[n-1]-sakai ;
    if(0<k&& 2*k<=(n-sakai))
    ans =1 ;
}
   if(ans==1)
   cout <<"Yes"<<endl ;
   else 
    cout <<"No"<<endl;
    return 0;
}

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

int int_cmp(const int *a, const int *b)
{
    if (*a < *b)
        return (-1);
    else if (*a > *b)
        return (1);
    return (0);
}

int main(void){
  int N,K;
  scanf("%d%d",&N,&K);
  int p[N];
  for(int i=0;i<N;i++){
  scanf("%d",&p[i]);
  }
  
  qsort(p,N,sizeof(int),(int(*)(const void*, const void*))int_cmp);
  
  int sum=0;
  for(int i=0;i<K;i++){
  sum += p[i];
  }
  
  printf("%d",sum);
  
  return 0;
}

Measured memory_bytes: 1704
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<algorithm>
#include<climits>
#include<string>
#include<map>
#include<queue>
using namespace std;

int main(){

	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif

	int n,l;
	cin>>n>>l;

	vector<int> sum(n);
	sum[0]=l+1-1;
	for(int i=1;i<n;i++){
		sum[i] = sum[i-1]+l+i+1-1;
		//cout<<sum[i]<<endl;
	}

	int final_sum=sum[n-1];

	int min=INT_MAX,ans;

	for(int i=0;i<n;i++){
		if(abs(l+i+1-1)<min){
			min = abs(l+i+1-1);
			ans = final_sum - (l+i+1-1);
			//cout<<min<<" "<<ans<<endl;
		}
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
import sys
inf = 10000000000

def BellmanFord(edges,points,start):#edgeは1-indexedの起点/終点/距離
  #グラフの初期化
  dist=[inf for i in range(points)]
  dist[start-1]=0
  
  #辺の緩和
  for i in range(points):
    for edge in edges:
      if dist[edge[0]-1]!=inf and  dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
    dist1 = dist[N-1]
  for i in range(points):
    for edge in edges:
      if dist[edge[0]-1]!=inf and  dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
    dist2 = dist[N-1]
  if dist1 != dist2:return "Loop"
  return (dist)

N,M,P = [int(i) for i in input().split()]
Edges = []
for i in range(M):
    a,b,c = [int(i) for i in input().split()]
    Edges.append((a,b,P-c))
dist = BellmanFord(Edges,N,1)
if dist =="Loop":
    print(-1)
else:
    print(max(-dist[N-1],0))

Measured memory_bytes: 48216
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

int table[100000][3] = {};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    memset(table, -1, sizeof(table));
    queue<vector<int>> q;
    q.push(vector<int>{s, 0});
    table[s][0] = 0;
    int flag = 1;
    while (q.size() && flag)
    {
        vector<int> temp = q.front();
        q.pop();
        for (int i = 0; i < edge[temp[0]].size(); i++)
        {
            int dist = table[temp[0]][temp[1]] + 1;
            int st = dist % 3;
            if (table[edge[temp[0]][i]][st] == -1)
            {
                table[edge[temp[0]][i]][st] = dist;
                q.push(vector<int>{edge[temp[0]][i], st});
            }
            if (edge[temp[0]][i] == t && st == 0)
            {
                flag = 0;
            }
        }
    }
    if (flag)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << table[t][0] / 3 << endl;
    }
    return 0;
}

Measured memory_bytes: 7164
// practice with Dukkha
#include <algorithm>
#include <iostream>
#include <cstdlib>

using namespace std;

const int N = 100000;

int oo[N], *oj[N], qu[N * 3], dd[N * 3];

void init(int n) {
	for (int i = 0; i < n; i++)
		oj[i] = (int *) malloc(2 * sizeof *oj[i]);
}

void link(int i, int j) {
	int o = oo[i];
	if (o >= 2 && (o & o - 1) == 0)
		oj[i] = (int *) realloc(oj[i], (o << 1) * sizeof *oj[i]);
	oj[i][oo[i]++] = j;
}

int main() {
	int n, m; cin >> n >> m;
	init(n);
	while (m--) {
		int i, j; cin >> i >> j, i--, j--;
		link(i, j);
	}
	int s, t; cin >> s >> t, s--, t--;
	int u = s * 3 + 0, v = t * 3 + 0;
	int inf = n * 3;
	fill(dd, dd + n * 3, inf);
	int head = 0, cnt = 0;
	dd[u] = 0, qu[head + cnt++] = u;
	while (cnt) {
		u = qu[cnt--, head++];
		int i = u / 3, r = (u + 1) % 3;
		int d = dd[u] + 1;
		for (int o = 0; o < oo[i]; o++) {
			int j = oj[i][o];
			u = j * 3 + r;
			if (dd[u] == inf) {
				dd[u] = d;
				if (u == v) {
					cout << d / 3 << '\n';
					return 0;
				}
				qu[head + cnt++] = u;
			}
		}
	}
	cout << "-1\n";
	return 0;
}


Measured memory_bytes: 10036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
typedef long long ll;

int solve()
{
	int L, A, B, C, D;
	cin >> L >> A >> B >> C >> D;
	return L - max((A+(C-1))/C, (B+(D-1))/D);
}

int main(void)
{
	int ans = solve();
	cout << ans << endl;
}



Measured memory_bytes: 3096
N = int(input())
v_list = list(map(int, input().split()))

from heapq import *
que = []
heapify(que)

for v in v_list:
    heappush(que, v)

while len(que) != 1:
    a = heappop(que)
    b = heappop(que)
    heappush(que, (a+b)/2)
print(que.pop())

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

int main(){
  int n;
  cin >> n;
  vector<int> b(0);
  for(int i=0;i<n;i++){
    int input;
    cin >> input;
    b.push_back(input);
  }
  vector<bool> c(n,0);
  vector<int> d;
  for(int i=0;i<n;i++){
      int val = i+1;
    for(int j=n-1;j>=0;j--){
      if(b.at(j) <= val && c.at(j) == 0){
        c.at(j) = 1;
        d.push_back(b.at(j));
        break;
      }
      if(c.at(j) == 1) val--;
      if(j == 0){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << d.at(i) <<endl;
  }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int a;
  for(int i = 0; i < N; ++i) {
    cin >> a;
  }
  int ans = (N - K) / (K - 1) + min(1, (N - K) % (K - 1)) + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

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

  vector<bool> honest(N+1, false);
  vector<int> A(N+1);
  int x[20][20],y[20][20];
  for(int i = 1; i <= N; i++){
    cin >> A[i];
    for(int j = 1; j <= A[i]; j++){
      cin >> x[i][j] >> y[i][j];
    }
  }

  int maxv = 0;
  bool mujunexist = false;
  for(int bit = 0; bit < 1<<N; bit++){
    mujunexist = false;
    for(int k = 0; k < N; k++){
      if(bit & 1<<k){
        honest[k+1] = true;
      }
      else{
        honest[k+1] = false;
      }
    }
   for(int i = 1; i <= N; i++){
    for(int j = 1; j <= A[i]; j++){
      if(honest[i] == true){
        if(y[i][j] == 1){
          if(honest[x[i][j]] == false){
            mujunexist = true;
            break;
          }
        }
        if(y[i][j] == 0){
          if(honest[x[i][j]] == true){
            mujunexist = true;
            break;
          }
        }
      }
    }
   }
   int cnt = 0;
   if(!mujunexist){
     for(int i = 0; i < N+1; i++){
       if(honest[i]){
         cnt++;
       }
     }
     maxv = max(maxv, cnt);
   }

  }

  cout << maxv << endl;
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

const ll MOD = 1000000007;
using namespace std;
string str;

bool isnum(int idx){ return str[idx] >= '0' && str[idx] <= '9'; }

ll dec(ll left, ll right){
    if(right >= 64 || (1 << right) > left)return 0LL;
    else return (left >> right);
}

int getend(int idx){
    int depth = 1;idx++;
    for(;depth > 0 && idx < str.size();idx++){
        switch(str[idx]){
            case 'S': depth++;
                      break;
            case '>': if(idx < str.size()-2 && str[idx+1] == '>' && str[idx+2] != '>'){
                          idx++;
                          break;
                      }
                      depth--;
                      break;
        }
    }
    return idx-1;
}

ll tonum(int idx){
    int start = idx,size = 0;
    for(;idx < str.size() && isnum(idx); idx++)size++;
    return stoll(str.substr(start, size));
}

ll calc(int start, int end){
    //cerr << "call" << start << " : " << end << endl;
    bool flag = false;
    ll val = 0;
    for(int i = start; i < end; i++){
        ll temp = 0;
        if(str[i] == 'S'){
            int cend = getend(i);
            temp = calc(i+1, cend);
            temp = (temp*temp)%MOD;
            //cerr << "S" << temp << " " << i << endl;
            i = cend;
            //cerr << i << endl;
        }
        else if(str[i] == '>'){
            //cerr << "flag" << endl;
            flag = true;
            i++;
            continue;
        }
        else{
            temp = tonum(i);
            //cerr << "N" << temp << " " << i << endl;
            while(i < str.size() && isnum(i)) i++;
            i--;
        }
        if(flag){
            val = dec(val, temp);
            //cerr << "D" << val << endl;
            flag = false;
        }
        else{
            val = temp;
        }
    }
    return val;
}

int main(){
    while(true){
        str.clear();
        string raw;getline(cin, raw);
        for(auto e : raw)if(e != ' ' && e != '<')str.push_back(e);
        //cerr << str << endl;
        if(str == "#")break;
        cout << calc(0, str.size()) << endl;
    }
    return 0;
}



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

int a,b,c,gede;
int main(){
cin>>a;
c=a;
int d[a];
for(int i=0;i<a;i++){
		cin>>d[i];
	}
for(int i=0;i<a;i++){
	for(int j=i+1;j<a;j++){
		if(d[i]==d[j]&& d[i]!=101){
			c--;
			d[j]=101;
		}
	}
}

cout<<c<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define ll long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
typedef vector<ll> Array;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

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

	ll n;
	cin >> n;
	vector<P> xy(n);
	REP(i, n)cin >> xy[i].first >> xy[i].second;

	sort(all(xy), [&](P a, P b) {
		return atan2(a.second, a.first) > atan2(b.second, b.first);
	});
	double ans = 0;
	REP(i, n) {
		ll X = 0, Y = 0;
		REP(j, n) {
			X += xy[(i+j)%n].first;
			Y += xy[(i+j)%n].second;
			chmax(ans, sqrt(X * X + Y * Y));
		}
	}
	cout <<fixed<<setprecision(20)<< ans << endl;

	return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  a += d-1;
  c += b-1;
  if (a / d >= c / b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
const int mod=1e9+7;
int a[maxn],dp[maxn],vis[maxn];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]),vis[a[i]]=1;
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		if(vis[i]) continue;
		if(!vis[i-1]) dp[i]+=dp[i-1];
		if(i>=2&&!vis[i-2]) dp[i]+=dp[i-2];
		dp[i]%=mod;
	}
	cout<<dp[n]%mod<<endl;
 } 

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;

signed main(){
  int n,m=INF;
  cin>>n;
  vector<int> a(n),b(n);
  REP(i,n)cin>>a[i];
  REP(i,n){
    while(a[i]%2==0){
      b[i]++;
      a[i]/=2;
    }
  }
  int ans=INF;
  REP(i,n){
    if(ans>b[i])ans=b[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

int D[6];
class Dice{
  public:
    int p, q;
    
    Dice(int a, int b, int c, int d, int e, int f){
        D[0] = a;
        D[1] = b;
        D[2] = c;
        D[3] = d;
        D[4] = e;
        D[5] = f;
    }
    
    void move(char ord){
        if (ord == 'S'){
            p = D[4];
            D[4] = D[5];
            q = D[0];
            D[0] = p;
            p = D[1];
            D[1] = q;
            D[5] = p;
        }
        if (ord == 'E'){
            p = D[5];
            D[5] = D[2];
            q = D[3];
            D[3] = p;
            p = D[0];
            D[0] = q;
            D[2] = p;
        }
        if (ord == 'W'){
            p = D[5];
            D[5] = D[3];
            q = D[2];
            D[2] = p;
            p = D[0];
            D[0] = q;
            D[3] = p;
        }
        if (ord == 'N'){
            p = D[5];
            D[5] = D[4];
            q = D[1];
            D[1] = p;
            p = D[0];
            D[0] = q;
            D[4] = p;
        }
    }
    void R_rota(){
        p = D[1];
        D[1] = D[3];
        q = D[2];
        D[2] = p;
        p = D[4];
        D[4] = q;
        D[3] = p;
    }
    
    void L_rota(){
        p = D[1];
        D[1] = D[2];
        q = D[3];
        D[3] = p;
        p = D[4];
        D[4] = q;
        D[2] = p;
    }
};

int main(){
    
    int list1[6], list2[6];
    for ( int i = 0; i < 6; i++) scanf("%d",&list1[i]);
    for ( int i = 0; i < 6; i++) scanf("%d",&list2[i]);
    
    Dice sai2 (list2[0], list2[1], list2[2], list2[3], list2[4],list2[5]);
    
    for ( int i = 0; i < 6; i++){
        if ( list1[0] == D[i] ){
            if ( i == 1) sai2.move('N');
            else if ( i == 2 ) sai2.move('W');
            else if ( i == 3 ) sai2.move('E');
            else if ( i == 4 ) sai2.move('S');
            else if ( i == 5 ){
                sai2.move('W');
                sai2.move('W');
            }
        } 
    }

    if ( list1[1] == D[2] ) sai2.L_rota();
    else if ( list1[1] == D[3] ) sai2.R_rota();
    else if ( list1[1] == D[4] ){
        sai2.R_rota();
        sai2.R_rota();
    }
    
    for ( int i = 0; i < 6; i++){
        if ( list1[i] == D[i]){
            if ( i == 5 ) cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
            break;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll i,n,ans;
string a;
map<string,ll> mp;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,0,n){
        cin>>a;
        sort(all(a));
        mp[a] += 1;
    }
    for(auto x: mp) ans += (x.se * (x.se - 1)) / 2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(),(VECTOR).end()

int main(){

	int N;
	cin >> N;
	vector<int> A(3 * N);
	for(int i = 0; i < 3 * N; i ++){
		cin >> A[i];
	}
	sort(all(A));
	ll ans = 0;
	for(int i = 0; i < N; i ++){
		ans += A[3 * N - 1 - 1 - i * 2];
	}
	cout << ans << endl;

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    vector<ll> x(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    ll ans = 1 << 30;
    for(int i = 0; i < n - k + 1; i++){
        int r = i + k - 1;
        ll lr = abs(x[i]) + abs(x[i] - x[r]);
        ll rl = abs(x[r]) + abs(x[i] - x[r]);
        ans = min({ans, lr, rl});
    }
    cout << ans << endl;
}


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

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

typedef long long int ll;

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


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

  vector<ll> l(87);

  l[0]=2; l[1]=1;
  FOR(i,2,N+1){
    l[i] = l[i-1] + l[i-2];
  }
  cout << l[N] << endl;

}



Measured memory_bytes: 256