akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define int long long int
#define ld long double
#define ar array
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<int> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const int ths = 1LL << 40;
const int NN = 5e3 + 6;

const int maxN = 1003;

int modexp(int a, int n) {

    int r = 1;
    while(n) {
        if(n & 1)
            r = (r * a);
        a = (a * a);
        n >>= 1;
    }
    return r;
}

void solve()
{

    int n;
    cin>>n;
    string ans = "";
    int ini = 0;
    for(int i = 0; i <= 11; i ++)
        ini += modexp(26, i);
    for(int i = 12; i >= 0; i --) {
        for(int j = 26; j >= 1; j --) {
            int x = j * modexp(26, i);
            if(x + ini <= n) {
                ans += 'a' + j - 1;
                n -= x;
                break ;
            }
        }
        if(i > 0)
            ini -= modexp(26, i - 1);
    }
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

int main(){
  int n, l;  cin >> n >> l;
  vector<string> vec(n);
  rep(i, 0, n)  cin >> vec[i];
  sort(all(vec));
  rep(i, 0, n)  cout << vec[i];
  cout << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int ,int>;

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

#define INF 1LL << 62
#define MOD (int)1e9 + 7
#define rep(i,n) for(int i = 0;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back

string s[100010];   
string K;

int main() {
	
	vector<int> v;

	for (int i = 0; i < 3; i++) {
		int a;
		cin >> a;
		v.pb(a);
	}
	sort(all(v));
	v.erase(unique(v.begin(), v.end()) ,v.end());

	cout << v.size() << endl;

	return 0;
}

Measured memory_bytes: 1024
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    ll K; cin >> K;
    vector<vector<int>> G(N);
    veci A(N);
    int cur = 0;
    int next;
    REP(i,N) {
        int a; cin >> a;
        a--;
        G[i].push_back(a);
        A[i] = a;
    }
    int ans;
    if(N >= K) {
        REP(i,K) {
            ans = A[cur];
            cur = A[cur];
            }
    } else {
        ll rest = K-N;
        int v;
        REP(i,N) {
            next = A[cur];
            cur = A[cur];
        }
        v = A[next];
        int cnt = 1;
        if(K-N == 1) {
            cout << v+1 << endl;
            return 0;
        }
        while(v != next) {
            v = A[v];
            cnt++;
        }
        rest = rest%cnt;
        REP(i,rest) {
            next = A[next];
        }
        ans = next;
    }
    cout << ans+1 << endl;

}


Measured memory_bytes: 14876
#include <cstdio>
using namespace std;
 
int a[4];
int c[8];
int k;
 
int calc(){
    int op = c[k++];
    int ret = 0;
    if(op >= 0){
        ret = op;
    }
    else if(op >= -3){
        int x = calc();
        int y = calc();
        if(op == -1){
            ret = x + y;
        }
        else if(op == -2){
            ret = x - y;
        }
        else{
            ret = x * y;
        }
    }
    else{
        throw 0;
    }
    return ret;
}
 
void print(){
    int op = c[k++];
    if(op >= 0){
        printf("%d", op);
    }
    else{
        char ch;
        if(op == -1){ ch = '+'; }
        else if(op == -2){ ch = '-'; }
        else{ ch = '*'; }
 
        putchar('(');
        print();
        printf(" %c ", ch);
        print();
        putchar(')');
    }
}

const int brnum = 100000;
 
void solve(int i, int S, int oprem, int numrem){
    if(i == 6){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[6] = a[j];
            }
        }
        try{
            k = 0;
            if(calc() == 10 && k == 7){
                k = 0;
for(int j=0;j<brnum;++j)putchar('(');
                print();
for(int j=0;j<brnum;++j)putchar(')');
                puts("");
                throw "";
            }
        }catch(int){}
        return;
    }
 
    if(oprem > 0){
        for(int op = -1; op >= -3; --op){
            c[i] = op;
            solve(i + 1, S, oprem - 1, numrem + 1);
        }
    }
 
    if(numrem > 0){
        for(int j = 0; j < 4; ++j){
            if(S >> j & 1){
                c[i] = a[j];
                solve(i + 1, S ^ 1 << j, oprem, numrem - 1);
            }
        }
    }
}
 
int main(){
    while(1){
        for(int i = 0; i < 8; ++i){
            c[i] = -9;
        }
        for(int i = 0; i < 4; ++i){
            scanf("%d", &a[i]);
        }
        if(a[0] == 0){ break; }
        try{
            solve(0, 15, 3, 0);
            puts("0");
        }catch(...){}
    }
}

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

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

	long long int h,w;

	cin >> h >> w;

	if(h%3==0 || w%3==0)
	{
		cout << 0 << '\n';
		return 0;
	}

	long long int res = 1e18;
	for(long long int i=1;i<h;i++)
	{
		long long int area1 = i*w;
		long long int area2 = (h-i)*(w/2);
		long long int area3 = w*h - area1 - area2;
		long long int Max = max(area1,max(area2,area3));
		long long int Min = min(area1,min(area2,area3));
		res = min(res,abs(Max-Min));
	}
	
	for(long long int i=1;i<w;i++)
	{
		long long int area1 = i*h;
		long long int area2 = (w-i)*(h/2);
		long long int area3 = w*h - area1 - area2;
		long long int Max = max(area1,max(area2,area3));
		long long int Min = min(area1,min(area2,area3));		
		res = min(res,abs(Max-Min));
	}


	long long int area1 = ((h/3)+1)*w;
	long long int area2 = (h/3)*w;
	long long int area3 = w*h - area1 - area2;
	long long int Max = max(area1,max(area2,area3));
	long long int Min = min(area1,min(area2,area3));		
	res = min(res,abs(Max-Min));
	area1 = ((w/3)+1)*h;
	area2 = (w/3)*h;
	area3 = w*h - area1 - area2;
	Max = max(area1,max(area2,area3));
	Min = min(area1,min(area2,area3));	
	res = min(res,abs(Max-Min));

	cout << res << '\n';

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll A,B,C;
    cin>>A>>B>>C;
    ll D=C-A-B;
    if(D>0&&4*A*B<D*D)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007
#define INF 100000000

using namespace std;

class AStrings {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        string s, t;
        cin >> s >> t;
        cout << t + s << endl;
    }
};


int main() {
    AStrings solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main()
{
    int n = 0;
    cin >> n;
    if(n==1)
    {
        cout << "Hello World";
        return 0;
    }
    int a = 0,b = 0;
    cin >> a >> b;
    cout << a+b;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main() {
   int H, W;
   cin >> H >> W;
   vector<vector<char>> M(H, vector<char>(W));
   for(int i = 0; i < H; i++){
       for(int j = 0; j < W; j++) cin >> M[i][j];
   }
   vector<vector<char>> Me(H + 1, vector<char>(W + 1));
   for(int i = 1; i < H + 1; i++){
       for(int j = 1; j < W + 1; j++){
           Me[i][j] = M[i - 1][j - 1];
       }
   }
   for(int i = 1; i < H + 1; i++){
       for(int j = 1; j < W + 1; j++){
           if(Me[i][j] == '#'){
               if (Me[i - 1][j] == '.'
                   and Me[i][j - 1] == '.'
                   and Me[i][j + 1] == '.'
                   and Me[i + 1][j] == '.')
               {
                   puts("No");
                   return 0;
               }
           }
       }
   }
   puts("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

void solve(int N, int K) {
  ll ans = K;
  rep(i, N - 1)
    ans *= K - 1;
  cout << ans << endl;
}

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

  int N, K;
  cin >> N >> K;

  solve(N, K);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void)
{
	int a,b,c,d;
	bool k;
	cin>>a>>b>>c>>d;
	while(1)
	{
		c-=b;
		if(c<=0)
		{
			cout<<"Yes";break;
		}
		a-=d;
		if(a<=0)
		{
			cout<<"No";break;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
import sys
import bisect
n = int(input())
arr = list(map(int, input().split())) + [sys.maxsize]
nq = int(input())
lines = sys.stdin.readlines()
ans = [None] * nq
for i in range(nq):
    q = int(lines[i])
    idx = bisect.bisect_left(arr, q)
    ans[i] = '1' if arr[idx] == q else '0'

print('\n'.join(ans))


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

int main() {
int a, b = 5;
while(1) {
cin >>a >>b;
if (a == 0 && b == 0) {
break;
}
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
cout << "#";
}cout <<endl;
}cout << endl;
}return 0;
}




Measured memory_bytes: 3052
#include<cstdio>
#include<vector>
#include<stack>
using namespace std;

typedef pair<int,int> pii;

bool solve(){
  int n;
  stack<pii> stone;
  scanf("%d",&n);
  if(n==0) return false;
  for(int i=0;i<n;i++){
    int color;
    scanf("%d",&color);
    if(i&1){
      pii p = stone.top(); stone.pop();
      if(p.first==color){
        p.second++;
        stone.push(p);
      }else{
        p.first ^= 1;
        p.second++;
        if(!stone.empty()&&stone.top().first==p.first){
          pii p1 = stone.top(); stone.pop();
          p.second += p1.second;
          stone.push(p);
        }
        else stone.push(p);
      }
    }else{
      if(i){
        pii p = stone.top(); stone.pop();
        if(p.first==color){
          p.second++;
          stone.push(p);
        }else{
          stone.push(p);
          stone.push(pii(color,1));
        }
      }
      else stone.push(pii(color,1));
    }
  }
  int ans = 0;
  while(!stone.empty()){
    if(stone.top().first==0) ans += stone.top().second;
    stone.pop();
  }
  printf("%d\n",ans);
  return true;
}

int main(){
  while(true) if(!solve()) return 0;
}

Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TEST int t;cin>>t;for(int T=1;T<=t;T++)
#define F first
#define S second
int main()
{
	//TEST
	{
		ll n;
		cin>>n;
		ll d=n/1000;
		ll c=(d+1)*1000;
		 ll ans=c-n;
		 if(n%1000==0)
			cout<<"0"<<endl;
	//	ll ans=min(c-n,(n-(d*1000)));
		else cout<<ans<<endl;
	 }
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main(){
    IOS;
    string s;
    cin >> s;
    in a=0,b=0;
    rep(i,0,sz(s)){
        if(s[i] == 'A'){
            a++;
        }
        else b++;
    }
    (a==0 or b==0) ? cout << "No\n" : cout << "Yes\n";
}

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

const int W = 200000;
int N;
vector<double> A;
double dp[20][W];

int main(){
    cout.precision(16);
    cout.setf(ios::fixed);

    cin >> N;
    A.resize(N);
    for(auto &v: A) cin >> v;
    
    for(int i=0; i<N; i++)
        for(int j=0; j<W; j++)
            dp[i][j] = 1e9;
    
    for(int i=0; i<N; i++){
        for(int j=1; j<W; j++){
            if(0 < i){
                for(int k=j; k<W; k+=j)
                    dp[i][k] = min(dp[i][k], dp[i-1][j]);
            }else
                dp[i][j] = 0;
            dp[i][j] = max(dp[i][j], abs(A[i]-j)/A[i]);
        }
    }
        
    double ans = 1;
    for(int i=0; i<W; i++)
        ans = min(ans, dp[N-1][i]);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 34448
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
d = c.copy()
k = c.keys()
for i in k:
    d[i] = c[i]*(c[i]-1) // 2
s = sum(list(d.values()))
for i in a:
    print(s - d[i] + max(0, (c[i]-1)*(c[i]-2)//2))

Measured memory_bytes: 34096
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int H, W;
	cin >> H >> W;

	int h, w;
	cin >> h >> w;

	cout << (H - h) * W - (H - h) * w;

	return 0;
}


Measured memory_bytes: 3616
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
//use std::collections::HashMap;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let x: i32 = sc.read();

    if x < 1200 {
        println!("ABC");
    } else if x < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, K, ans=0;
string S; cin >> N >> K >> S;
if(S[0]=='R'&&S[1]=='R'){ ans++; }
if(S[N-1]=='L'&&S[N-2]=='L'){ ans++; }
for(int i=1; i<=N-2; i++){
if((S[i]=='L'&&S[i-1]=='L')||(S[i]=='R'&&S[i+1]=='R')){ans++;}
}
ans=min(N-1,ans+2*K);
cout << ans << "\n";
}

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

int ABC(char *s);

int main()
{
	char s[55];
	int x;
	cin>>x;
	for(int i=0;i<x;i++)
        cin>>s[i];
	printf("%d\n",ABC(s));
	return 0;
}

int ABC(char *s)
{
	int len = strlen(s);
	int i,count = 0;
	for(i = 0;i <= len-3;i++)
	{
		if('A' == s[i+0] && 'B' == s[i+1] && 'C' == s[i+2])
		{
			count++;
			i += 2;
		}
	}
	return count;
}


Measured memory_bytes: 3700
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <functional>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <string>
#include <cstring>
#include <ctype.h>
#include <assert.h>

#define fi first
#define se second
#define sz(x) ((int)x.size())

using namespace std;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pli;
typedef pair<lli,lli> pll;

int n,cost[100010];
lli pos[100010],c;
lli fs[100010],bs[100010];

lli proc() {
	for(int i=1;i<=n;i++) fs[i] = fs[i-1] - (pos[i]-pos[i-1]) + cost[i];
	for(int i=1;i<=n;i++) fs[i] = max(fs[i], fs[i-1]);
	
	lli s=0,mx=0,res=0;
	for(int i=n+1;i;i--) {
		res = max(res, fs[i-1] + mx);

		s = s + (pos[i-1]-pos[i])*2 + cost[i-1];
		mx = max(mx,s);
	}
	return res;
}

int main() {
	scanf("%d%lld",&n,&c);
	for(int i=1;i<=n;i++) scanf("%lld%d",pos+i,cost+i);
	pos[n+1]=c;

	lli ans = max(proc(),0ll);
	reverse(pos+1,pos+n+1);
	reverse(cost+1,cost+n+1);
	for(int i=1;i<=n;i++) pos[i] = c-pos[i];
	printf("%lld\n",max(proc(),ans));
	
	return 0;
}


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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int H,W; cin>>H>>W;
    map<int,int> S;//S[now] = start_ind
    multiset<int> vals;//横方向の差分の集合
    //__init__
    rep(i,W)S[i] = i;
    rep(i,W)vals.insert(0);

    rep(i,H){
        int l,r; cin>>l>>r;
        --l;
        auto it = S.lower_bound(l);//obstacle 上 now;
        int mr = -1;
        while(it != S.end() && it->first <= r){
            //削除候補
            mr = max(mr,it->second);//startの候補を削除
            vals.erase(vals.find(it->first-it->second));
            S.erase(it++);
        }
        if(mr != -1 && r < W){
            vals.insert(r-mr);
            S[r] = mr;
        }
        int ans = -1;
        if(vals.size()>0){
            ans = *vals.begin() + (i+1);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 22364
#include <iostream>
using namespace std;
int main(){
	long long int K,A,B;
	cin>>K>>A>>B;
	long long int max=0;
	max=K+1;
	int mh=0;
	mh=max;
	int ct=1;
	if(B-A>2){
		if((K+1-A)%2==0){
			max=A+(B-A)*((K+1-A)/2);
		}else{
			max=A+(B-A)*((K+1-A)/2)+1;
		}
	}
	
	

	/*
	while(1){
		mh=mh-2*ct;
		if(mh<0){
			break;
		}
		mh=mh+(B-A)*ct;
		if(mh>max){
			max=mh;
		}else{
			break;
		}
		
		mh=K+1;
		ct++;
	}
	*/
	cout<<max<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main(N,F,P):
    inf = float("INF")
    ans = -inf
    
    for i in range(1,1<<10):
        count = [0]*N
        tmp = 0
        for j in range(10):
            if((i>>j)&1):
                for k in range(N):
                    if F[k][j]==1:
                        count[k] += 1
            else:
                continue
            
        for l in range(N):
            tmp += P[l][count[l]]
        ans = max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    N = int(input())
    F,P = [],[]
    for i in range(N):
        F.append([int(j) for j in input().split()])
    for i in range(N):
        P.append([int(j) for j in input().split()])
    main(N,F,P)

Measured memory_bytes: 3064
import scala.io.Source.stdin

object Main extends App {
  def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)

  println {
    {
      for(s <- stdin.getLines.map(_.split(" ").map(_.toLong))) yield {
          val g = gcd(s(0),s(1))
          g + " " + (s(0)*s(1)/g)
      }
    }.mkString("\n")
  }
}

Measured memory_bytes: 43500
fn main() {
    let (a, b, c, d): (i32, i32, i32, i32) = readln();
    let ans = if a + b < c + d {
        "Right"
    } else if a + b > c + d {
        "Left"
    } else {
        "Balanced"
    };
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    H, W, K = mi()
    c = [list(input()) for i in range(H)]
    cnt = 0

    for row in range(2**H):
        for column in range(2**W):
            tmp = [['.']*W for i in range(H)]
            for i in range(H):
                for j in range(W):
                    if (row>>i)&1 or (column>>j)&1:
                        tmp[i][j] = 'r'
                    else:
                        tmp[i][j] = c[i][j]
            s = 0
            for i in range(H):
                for j in range(W):
                    if tmp[i][j] == '#':
                        s += 1
            if s == K:
                cnt += 1
    
    print(cnt)


if __name__ == '__main__':
    main()


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  if((10 * g + b) % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    if(n%k){
        cout << "1" << endl;
    }else{
        cout << "0" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int number[300000];

void func1(int array[], int size, int num) {
	int i;
	
	for(i = 0; i < size; i++)
		array[i] = num;
}

int main() {
	int n;
	int i, j;
	int temp;

	func1(number, 300000, 1);
	
	number[0] = 0; number[1] = 0;

	for(i = 2; i < 300000; i++) {
		if(number[i])
			for(j = 2; i * j < 300000; j++)
				number[i * j] = 0;
	}

	while(1) {
		scanf("%d", &n);
		if(!n) break;

		temp = 0;

		for(i = n + 1; i <= 2 * n; i++)
			if(number[i]) temp++;

		printf("%d\n", temp);
	}

	return 0;
}

Measured memory_bytes: 1772
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template <typename H> void print(H head) { std::cout << head << std::endl; }
template <typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

char get(ll x) {
  if (x == 0) return '0';
  if (x == 1) return '3';
  if (x == 2) return '5';
  return '7';
}

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

  ll N;
  std::cin >> N;

  ll ans = 0LL;
  std::map<ll, bool> mused;
  for (ll S = 1; S < std::pow(4, 9); S++) {
    std::string str;
    ll status = S;
    while (status > 0) {
      ll x = status % 4;
      str += get(x);
      status /= 4;
    }
    ll num = atoi(str.c_str());
    if (num > N) continue;
    if (mused[num]) continue;
    if (str.find("3") == std::string::npos) continue;
    if (str.find("5") == std::string::npos) continue;
    if (str.find("7") == std::string::npos) continue;
    if (std::to_string(num).find("0") != std::string::npos) continue;
    mused[num] = true;
    ans++;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 12544
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

dic={}

n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]

for i in range(m):
    a,b=ab[i]
    if a==1:
        dic[b]=1

# print(dic)
for i in range(m):
    a,b=ab[i]
    if b==n and a in dic:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 119292
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


long long A[5];
int main() {
    for (int i = 0; i < 5; ++i) cin >> A[i];
    long long maxdiff = 0, res = 0;
    for (int i = 0; i < 5; ++i) {
        long long r = A[i] % 10;
        if (r) res += A[i] + 10 - r, maxdiff = max(maxdiff, 10 - r);
        else res += A[i];
    }
    cout << res - maxdiff << endl;
}














Measured memory_bytes: 256
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

x = sorted(P)
xl = list(itertools.permutations(x))

tp = tuple(P)
tq = tuple(Q)

a = xl.index(tp)
b = xl.index(tq)

ans = abs(a - b)

print(ans)

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    cout<<(char)(a[0]+'A'-'a')<<(char)(b[0]+'A'-'a')<<(char)(c[0]+'A'-'a')<<endl;
}

Measured memory_bytes: 256
import numpy as np

C = []
for _ in range(3):
    c = list(map(int, input().split()))
    C.append(c)

A = np.array([
    [1, 0, 0, 1, 0, 0],
    [0, 1, 0, 1, 0, 0],
    [0, 0, 1, 1, 0, 0],
    [1, 0, 0, 0, 1, 0],
    [0, 1, 0, 0, 1, 0],
    [0, 0, 1, 0, 1, 0],
    [1, 0, 0, 0, 0, 1],
    [0, 1, 0, 0, 0, 1],
    [0, 0, 1, 0, 0, 1],
])

Aplus = np.array([
    [1, 0, 0, 1, 0, 0, C[0][0]],
    [0, 1, 0, 1, 0, 0, C[1][0]],
    [0, 0, 1, 1, 0, 0, C[2][0]],
    [1, 0, 0, 0, 1, 0, C[0][1]],
    [0, 1, 0, 0, 1, 0, C[1][1]],
    [0, 0, 1, 0, 1, 0, C[2][1]],
    [1, 0, 0, 0, 0, 1, C[0][2]],
    [0, 1, 0, 0, 0, 1, C[1][2]],
    [0, 0, 1, 0, 0, 1, C[2][2]],
])

rankA = np.linalg.matrix_rank(A)
rankAp = np.linalg.matrix_rank(Aplus)

if rankA == rankAp:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14408
N = int(input())
A = [int(input()) for _ in range(N)]
A_s = sorted(A, reverse = True)


A_max = A_s[0]
A_max2 = A_s[1]

for i in A:
    if i == A_max:
        print(A_max2)
    else:
        print(A_max)


Measured memory_bytes: 19024
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

class SegTree {
public:
	enum { N = 8192 };
	SegTree() : val(2*N-1){}
	void init(){
		for(int i=0;i<val.size();i++){
			val[i] = make_pair(0, 0);
		}
	}
	void setVal(int v, int i){
		int t = i + N - 1;
		val[t] = make_pair(v, i);
		while(t){
			t = (t-1)/2;
			if(val[t].first < v){
				val[t] = make_pair(v, i);
			}
		}
	}
	pair<int, int> get(int l, int r, int p=0, int a=0, int b=N){
		if(b <= l || r <= a) return make_pair(-1, -1);
		if(l <= a && b <= r) return val[p];
		return max(get(l, r, 2*p+1, a, (a+b)/2), get(l, r, 2*p+2, (a+b)/2, b));
	}
private:
	vector< pair<int, int> > val;
};

long long cost[5001][5001];
SegTree seg;

void update(int l, int r){
	if(l >= r) return;
	pair<int, int> p = seg.get(l, r);
	cost[l][p.second] += p.first;
	cost[l][r] -= p.first;
	cost[p.second+1][p.second] -= p.first;
	cost[p.second+1][r] += p.first;
	update(l, p.second);
	update(p.second+1, r);
}

int main(){
	std::ios_base::sync_with_stdio(false);
	int N, M;
	long long A[5000];
	static long long B[5000][200];
	while(cin >> N >> M){
		for(int i=0;i<=N;i++){
			for(int j=0;j<N;j++) cost[i][j] = 0;
		}
		A[0] = 0;
		for(int i=1;i<N;i++) cin >> A[i];
		for(int i=1;i<N;i++) A[i] += A[i-1];
		for(int i=0;i<N;i++){
			for(int j=0;j<M;j++) cin >> B[i][j];
		}
		for(int i=0;i<M;i++){
			seg.init();
			for(int j=0;j<N;j++) seg.setVal((int)B[j][i], j);
			update(0, N);
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++) cost[i][j+1] += cost[i][j];
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++) cost[j+1][i] += cost[j][i];
		}
		long long res = 0;
		for(int i=0;i<N;i++){
			for(int j=i;j<N;j++){
				res = max(res, cost[i][j] - A[j] + A[i]);
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 203776
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N;
  string S;
  cin >> N;
  cin >> S;
  vector<long> black(N + 1);
  vector<long> white(N + 1);
  black[0] = 0;
  white[0] = 0;
  long _black = 0;
  long _white = 0;
  rep (i, N) {
    if (S[i] == '.') _white ++;
    else _black++;
    black[i + 1] = _black;
    white[i + 1] = _white;
  }
  long result = N;
  rep (i, N + 1) {
    long todo_white = i - white[i];
    long todo_black = (N - i) - (black[N] - black[i]);
    long todo = todo_white + todo_black;
    if (result > todo) result = todo;
  }
  cout << result << endl;
  return 0;
}


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

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

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

	sort(s.begin(), s.end());

	for (auto x : s) {
		cout << x;
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	string str;
	while(cin >> str){
		for (int i = 0; i < str.size(); ++i)
		{
			if(str[i] == '@'){
				for (int j = 0; j < str[i + 1] - '0'; ++j)
				{
					cout << str[i + 2];
				}
				i += 2;
			}else{
				cout << str[i];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1172
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,d,x;
    cin >> n >> d >> x;

    vector<int> a(n);
    for(auto &x:a)cin >> x;

    int ate=0;
    for(int i=0;i<n;i++){
        for(int j=0;j*a[i]+1<=d;j++){
            ate++;
        }
    }

    cout << ate+x << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(20)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	ans += min(a, k);
	k -= a;
	k -= b;
	if (k > 0) {
		ans -= min(k, c);
	}
	cout << ans;
}

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


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

	// test
	solve();

	return 0;
}

Measured memory_bytes: 3688
N = int(input())
s = [sorted(list(map(int, input().split()))) for _ in range(3)]
ans = [[1]*(N) for _ in range(3)]

for i in range(2):

    for j in range(1,N):
        ans[i][j] = ans[i][j]+ans[i][j-1]

    last = -1
    for j in range(N):
        target = s[i+1][j]
        lo = last
        hi = N-1
        while hi - lo > 1:
            m = (hi+lo)//2
            if s[i][m] < target:
                lo = m
            else:
                hi = m
        if s[i][hi] < target:
            last = hi
        elif s[i][lo] < target:
            last = lo
        if last >= 0:
            ans[i+1][j] = ans[i][last]
        else:
            ans[i+1][j] = 0

print(sum(ans[2]))


Measured memory_bytes: 26472
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    vector<string> S;

    REP(i,n){
        char v[10];
        scanf("%s",v);
        sort(v,v + 10);
        string s = v;
        S.push_back(s);

    }
    sort(S.begin(), S.end());
    int ans = 0;
    int tmp = 0;
    REP(i,n-1){
        if(S[i] == S[i + 1]){
            if(tmp == 0) tmp = 2;
            else tmp ++;
        }
        else{
            ans += (tmp) * (tmp - 1) / 2;
            tmp = 0;
        }
    }
    ans += (tmp ) * (tmp - 1) / 2;
    cout << ans << endl;
    //sort(v.begin(),v.end());

    //sort(S,S + n);
    //REP(i,n) cout << S[i] << endl;


}

Measured memory_bytes: 5748
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> X(N);
	vector<int> Y(N);

	for(int i = 0; i < N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}

	sort(Y.begin(), Y.end());

	int medl = Y[N/2 - 1];
	int medr = Y[N/2];

	for(auto x: X) {
		if(x <= medl) cout << medr << endl;
		else cout << medl << endl;
	}

	return 0;
}


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

int main() {
  int N, M, C, total;
  int ans = 0;
  cin >> N >> M >> C;
  int total_row = N + 1;
  vector<vector<int> > data(total_row, vector<int>(M));
  for(int i = 0; i < total_row; i++){
    for(int j = 0; j < M; j++){
      cin >> data.at(i).at(j);
    }
  }
  
  for(int i = 1; i < total_row; i++){
    total = C;
    for(int j = 0; j < M; j++){
      total = total + data.at(i).at(j) * data.at(0).at(j);
    }
    if(total > 0){
        ans = ans + 1;
    }
  }
  
  cout << ans << endl;
  
}

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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};

struct Line {
	double a, b, c;
};

struct BIT {
	int N;
	vector<int> bit;
	BIT(int n) : N(n), bit(N + 1){}
	void add(int a, int w) {
		for(int x = a; x < N; x |= x + 1) {
			bit[x] += w;
		}
	}
	int sum(int a) {
		int ret = 0;
		for(int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) {
			ret += bit[x];
		}
		return ret;
	}
};

ll getTransNum(vector<int> &r) {
	BIT bit(r.size());
	ll ret = 0;
	for(int i = 0; i < r.size(); i++) {
		ret += i - bit.sum(r[i]);
		bit.add(r[i], 1);
	}
	return ret;
}

bool ok(vector<Line> &L, double c, bool vertical) {
	vector<pair<double, int>> L_c;
	if (vertical) {
		for (int i = 0; i < L.size(); i++) {
			// Ax+By=C
			// By=C-Ax
			// y=(C-Ax)/B
			double y = (L[i].c - L[i].a * c) / L[i].b;
			L_c.push_back(mp(y, i));
		}
	} else {
		for (int i = 0; i < L.size(); i++) {
			// Ax+By=C
			// Ax=C-By
			// x=(C-By)/A
			double x = (L[i].c - L[i].b * c) / L[i].a;
			L_c.push_back(mp(x, i));
		}
	}

	sort(L_c.begin(), L_c.end());
	vector<int> r;
	for (int i = 0; i < L_c.size(); i++) {
		r.push_back(L_c[i].second);
		//cout << i << ": (" << L_c[i].first << ", " << L_c[i].second << ")" << endl; 
	}

	ll n = getTransNum(r);
	int minn = L.size() * (L.size() - 1) / 2;
	if (minn % 2 == 0) {
		minn = minn / 2;
	} else {
		minn = minn / 2 + 1;
	}
	return n >= minn;
}

int main() {
	int N;
	cin >> N;
	vector<Line> L;
	for (int i = 0; i < N; i++) {
		double a, b, c;
		cin >> a >> b >> c;
		L.push_back((Line){a, b, c});
	}
	vector<Line> L_x = L;
	vector<Line> L_y = L;
	sort(L_x.begin(), L_x.end(), [](Line &lhs, Line &rhs){return lhs.a / lhs.b < rhs.a / rhs.b;});
	sort(L_y.begin(), L_y.end(), [](Line &lhs, Line &rhs){return lhs.b / lhs.a < rhs.b / rhs.a;});

	double ans_x, ans_y;
	double a = -1e30;
	double b = 1e30;
	//cout << L_x.size() * (L_x.size() - 1) / 4 << endl;
	for (int i = 0; i < 200; i++) {
		double c = (a + b) / 2;
		//cout << "a: " << a << ", b: " << b << endl;
		if (ok(L_x, c, true)) { // 交点 >= N * (N - 1) / 4
			b = c;
		} else {
			a = c;
		}
	}
	ans_x = b;
	
	a = -1e30, b = 1e30;
	for (int i = 0; i < 200; i++) {
		double c = (a + b) / 2;
		if (ok(L_y, c, false)) { // 交点 >= N * (N - 1) / 4
			b = c;
		} else {
			a = c;
		}
	}
	ans_y = b;

	printf("%.9f %.9f\n", ans_x, ans_y);
	return 0;
}



Measured memory_bytes: 4776
#include <stdio.h>
     
    int main(){
    	int n;
    	int i;
        int p[20];
      	int sum = 0;
      	scanf("%d ",&n);
      	for(i=0; i<n; i++){
      		scanf("%d",&p[i]);
        }
    	for(i=1; i<n-1; i++){
        	if(((p[i-1]<p[i])&&(p[i]<p[i+1]))||((p[i+1]<p[i])&&(p[i]<p[i-1]))){
            	sum++;
            }
        }
        printf("%d",sum);
        return 0;
    }

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

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;
int A[N];

int32_t main(){
    fast;
    int n ; cin >> n;
    if(n==0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

//直角三角形か判定
int rt(int a, int b, int c) {
    int tmp;
    if(a > c) {
        tmp = a;
        a = c;
        c = tmp;
    }
    if(b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }
    if(a*a+b*b == c*c) return 1;
    else return 0;
}

int main(void){

    int n;
    int a, b, c;
    
    scanf("%d\n", &n);
    while(n--) {
        scanf("%d %d %d\n", &a, &b, &c);
        if (rt(a,b,c) == 1) printf("YES\n");
        else printf("NO\n");
    }
    
    return 0;
}


Measured memory_bytes: 2020
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
struct BIT {
    int N;
    vector<T> dat;

    // 0-indexing
    explicit BIT(int n): N(n), dat(N + 1, 0) {}

    T sum(int i) {
        T s = T();
        for(++i; i > 0; i -= i & -i) s += dat[i];
        return s;
    }

    void add(int i, const T& x) {
        for (++i; i <= N; i += i & -i) dat[i] += x;
    }

    // min_x {x | v1 + v2 + ⋯ + vx ≧ w}
    // Assuming v_q >= 0
    int lower_bound(T w) {
        if (w <= 0) return 0;

        int x = 0; T k = 1;
        while (k * 2 <= N) k <<= 1;
        for (; k > 0; k /= 2) {
            if (x + k <= N && dat[x + k] < w) {
                w -= dat[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, Q;
    cin >> N >> Q;

    vll c(N);
    REP(i, N) cin >> c[i], c[i]--;

    vector<vector<pair<int, int>>> query(N);
    REP(i, Q) {
        int l, r; cin >> l >> r;
        --l; --r;
        query[r].eb(l, i);
    }

    vector<int> last(N, -1);
    BIT<int> bit(N);
    vector<int> ans(Q);
    REP(i, N) {
        if (~last[c[i]]) bit.add(last[c[i]], -1);
        last[c[i]] = i;
        bit.add(i, 1);

        for(auto &p: query[i]) {
            ans[p.se] = bit.sum(i) - bit.sum(p.fi-1);
        }
    }

    for (auto &e: ans) {
        print(e);
    }
    
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,m,head[maxn],tot,cnt,fa[maxn],d[maxn];
struct edge{int to,nxt;}e[maxn<<1];

void ins(int u,int v) {e[++tot]=(edge){v,head[u]},head[u]=tot;}

int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}

void dfs(int x,int fa) {
    for(int i=head[x];i;i=e[i].nxt) if(e[i].to!=fa) dfs(e[i].to,x);
    if(x==1) return ;
    if(d[x]&1) d[x]++,printf("%d %d\n",x,fa);
    else d[fa]++,printf("%d %d\n",fa,x);
}

int main() {
    read(n),read(m);for(int i=1;i<=n;i++) fa[i]=i;
    if(m&1) return puts("-1"),0;
    for(int i=1;i<=m;i++) {
        int x,y,u,v;read(x),read(y);
        u=find(x),v=find(y);
        if(u==v) printf("%d %d\n",x,y),d[x]++;
        else ins(x,y),ins(y,x),fa[u]=v;
    }dfs(1,0);
    return 0;
}


Measured memory_bytes: 13056
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl
#define endl "\n"

const int MAXN=300000;

int main() {
    string s;
	cin >> s;
	int n = s.length();
	ll count = 0;
	ll count2 = 0;
	forn(i,n){
		if(s[i]=='B'){
			count++;
		}else{
			count2+=count;
		}
	}
	cout << count2 << endl;
	return 0;
}



Measured memory_bytes: 640
// D - Knapsack 1
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define chmax(x,y) x=max(x,y)

int N,W;
int weights[101]; // 重さ
int values[101]; // 価値
ll dp[101][100001]; // [i][j]: 品番iまでで容量j以下のときの価値の和の最大 (初期化 0)

int main(){
	cin>>N>>W;
	rp(i, 1, N+1) cin>>weights[i]>>values[i]; // i:[i,N]
	rp(i, 1, N+1){ // 品番 i:[1,N]
		int wi = weights[i], vi = values[i];
		rp(j, 0, W+1){ // 容量 j:[0,W]
			dp[i][j] = dp[i-1][j];
			if(0 <= j-wi)
				chmax(dp[i][j], dp[i-1][j - wi] + vi);
		}
	}
	cout<< dp[N][W] <<endl;
}


Measured memory_bytes: 78336