akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n, k; cin >> k >> n;
	vector<ll> a(n); for (int i = 0; i < n; i++)cin >> a[i];
	ll res = 0;
	for (int i = 0; i < n; i++) {
		if (i + 1 < n) {
			chmax(res, a[i + 1] - a[i]);
		}
		else {
			chmax(res, a[0] + k - a[i]);
		}
	}
	cout << k - res << endl;
	return 0;
}

Measured memory_bytes: 4784
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り


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

int main() {
  int n,x,y;
  cin >> n;
  x = n/2;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  
  y = d.at(x) - d.at(x-1);
  cout << y << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = n /(a+b);
        long y = n - (a+b)*x;
        long ans = x*a + Math.min(y, a);
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if (a+b>=c-1){
		printf("%d\n",b+c);
		return 0;
	}
	printf("%d\n",a+b+1+b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
int P;
int X[111];
int Y[111];
int dp[111][111][111];
int cal(int x,int y){
    x--;y--;
    if(x==y)return max(Y[x]-X[x],0);

    int need=max(Y[x]-X[x],0);//?????\????????????????????£??????
    for(int i=x+1;i<=y;i++){
        int nX=max(0,X[i]-need);
        need=max(Y[i]-nX,0);

    }
    return need;
}
int main(){
    cin>>N>>P;
    REP(i,N){
        cin>>X[i]>>Y[i];
    }
    //dp????????????????????????
    REP(i,111){
        REP(j,111){
            REP(k,111){
                dp[i][j][k]=-1;
            }
        }
    }
    dp[0][0][0]=P;
    
    //dp?????´??°
    REP(i,N+1){
        if(i==0)continue;
        REP(j,N+1){
            //????????????
            REP(k,i){
                dp[i][j][i]=max(dp[i][j][i],dp[i-1][j][k]);
            }
            if(j==0)continue;
            //??????
            REP(k,N+1){               
                dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-1][k]-cal(k+1,i));
            }
            //????????????
            dp[i][j][i-1]=max(dp[i][j][i-1],dp[i-1][j-1][i-1]-cal(i,i));
        }
    }
    //
    int ans=0;
    REP(i,N+1){
        REP(j,N+1){
            REP(k,N+1){
                if(dp[i][j][k]!=-1){
                   ans=max(ans,j);
                }
            }
        }
    }
    
   /* REP(i,N+1){
        REP(j,N+1){
            REP(k,N+1){
                cout<<"dp[i]["<<j<<"]["<<k<<"]="<<dp[i][j][k] <<" "<<endl;;
            }
        }
        cout<<endl;
    }*/
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8436
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve()
{
	ll n;
	cin>>n;
	ll ans = 0;
	for (ll i = 1; i <= n ; ++i)
	{
		ans += (i)*(n-i+1);
	}
	for (int i = 0; i < n-1; ++i)
	{
		ll u,v;
		scanf("%lld %lld", &u, &v);
		if(u>v)
			swap(u,v);
		ans -= u*(n-v+1);
	}
	printf("%lld\n", ans);
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i = 0;i<n;i++) cin >> a[i];
  int j = 1;
  for(int i = 0;i<n;i++){
    if(a[i]==j) j++;
  }
  if(j==1){cout << -1;return 0;}
  else cout << n-j+1;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    string s,ans="Yes";
    cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[0])ans="No";
    cout<<ans<<endl;
}

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

if N == 0 and A[0] == 1:
    print(1)
    exit()
 
if A[0] != 0:
    print(-1)
    exit()

A.reverse()
max_list = [A[0]]
before_top = A[0]
for i in range(1, len(A)):
    max_list.append(before_top + A[i])
    before_top = max_list[i]
    
A.reverse()
max_list.reverse()
ans = 1
before_top = 1
for i in range(1, len(A)):
    if A[i] <= before_top*2:
        ans += min(before_top*2, max_list[i])
        before_top = min(before_top*2, max_list[i]) - A[i]
    else:
        print(-1)
        exit()
        
print(ans)

Measured memory_bytes: 20092
def is_prime(n):
    factors = 0
    for i in range(1, n+1):
        if n % i == 0:
            factors += 1

        if (factors > 2):
            break

    return factors == 2


X = int(input())

if (is_prime(X)):
    print(X)
else:
    while (not is_prime(X)):
        X += 1

    print(X)

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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
map<int,int>mp;
const int N=1e7+100;
int n,m;
vector<int>ve[10];
int vis[10];
int ans;
void dfs(int v,int step)
{
    if(step==n){
        ans++;
        return ;
    }
    for(auto k:ve[v]){
        if(!vis[k]){
            vis[k]=1;
            dfs(k,step+1);
            vis[k]=0;
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y;cin>>x>>y;
        ve[x].push_back(y);
        ve[y].push_back(x);
    }
    vis[1]=1;
    dfs(1,1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3588
n, k = gets.chomp.split.map(&:to_i)

if k.odd?
  p (n / k) ** 3
  exit
end

u = 0
m = 0
(1..n).each do |i|
  case i % k
  when 0
    u += 1
  when k / 2
    m += 1
  end
end
p u ** 3 + m ** 3


Measured memory_bytes: 1788
n=int(input())
t,a = map(int, input().split())
h= list(map(int, input().strip().split()))
for i in range(n):
    h[i]=abs(1000*t-6*h[i]-1000*a)
for i in range(n):
    if h[i]==min(h):
        print(i+1)

Measured memory_bytes: 9264
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a[1000],t=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>(k+1)/2)
            t+=k-a[i];
        else
            t+=a[i];
    }
    cout<<2*t;
}


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

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

  int x,a,b; cin >> x >> a >> b;

  x -= a;
  cout << (x%b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll N;
	cin >>N;
	ll w;
	ll mother;
	for(ll h=max(1LL,N/4LL);;h++){
		if(4LL*h==N){continue;}
		for(ll n=max((N*h)/(4LL*h-N),1LL);n<=3500LL;n++){
			/* 4/N = 1/h +1/n+ 1/w
				4hnw=Nnw+Nhw+Nhn
				4hnw-Nnw-Nhw=Nhn
				w(4hn-Nn-Nh)=Nhn
				4hn-Nn>Nh
				n(4h-N)>Nh
				n>(Nh/(4h-N))
				4h-N>0
				h>N/4
			*/
			clog << h << " " << n << " --  " << mother << endl;
			mother=4 * h * n - N *(n+h);
			if(mother <=0){//4*h*n < Nn+Nh-> 4hn-Nn<Nh
			// n(4h-N)<Nh ==> n<Nh/(4h-N)

			/*
				4h-N >0
				4h>N
				h>N/4
			*/
				continue;
			}
		//	clog << (4*h*n - N*n - N*h)<<endl;
			if ( (N * h * n) % mother == 0)
			{
				w = (N*h*n) / (mother);
				printf("%lld %lld %lld\n",h,n,w);
				return 0;
			}
			
		}
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
int main()
{
    ll p,n,i,s;
    s=0;
    cin>>n;
    ll y[n+2],x[n+2];
    for(i=0;i<=n;i++)
    {
        y[i]=0;
    }
    for(i=0;i<n;i++)
    {
        cin>>x[i];
        y[x[i]]++;
    }
    for(i=0;i<=n;i++)
    {
        s=s+(y[i]*(y[i]-1))/2;
    }
    for(i=0;i<n;i++)
    {
        p=s-(y[x[i]]*(y[x[i]]-1))/2;
        y[x[i]]--;
        p=p+(y[x[i]]*(y[x[i]]-1))/2;
        y[x[i]]++;
        cout<<p<<"\n";
    }

}

Measured memory_bytes: 5760
N = int(input())
AU = list(map(int, input().split()))
AD = list(map(int, input().split()))

AUS = [AU[0]]
ADS = [AD[-1]]

for i in range(1, N):
  AUS.append(AUS[-1] + AU[i])
  ADS.append(ADS[-1] + AD[-1-i])

ADS.reverse()

ans = 0
for i in range(N):
  temp = AUS[i]+ADS[i]
  ans = max(ans, temp)

print(ans)

Measured memory_bytes: 9192
#include <cstdio>
#include <vector>

using namespace std;

vector<int> v[200010];
int vaz[200010];

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int n,m,x,y;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        if(y==n) vaz[x]=1;
        v[y].push_back(x);
        if(x==n) vaz[y]=1;
    }
    for(int i=0;i<v[1].size();i++)
    {
        int vec=v[1][i];
        if(vaz[vec]==1) {printf("POSSIBLE");return 0;}
    }
    printf("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 12784
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k,c;
  cin>>n>>k>>c;
  string s;
  cin>>s;
  vecint fwd(n), bwd(n);
  int cnt = 0;
  int old = -1e9;
  REP(i,n) {
    if (s[i] == 'o' && i - old > c) {
      ++cnt;
      old = i;
    }
    fwd[i] = cnt;
  }
  cnt = 0;
  old = 1e9;
  REP(i,n) {
    int j = n-1-i;
    if (s[j] == 'o' && old - j > c) {
      ++cnt;
      old = j;
    }
    bwd[j] = cnt;
  }
  vecint hist(n+1);
  REP(i,n) {
    if (s[i] == 'o' && fwd[i] + bwd[i] == k+1) ++hist[fwd[i]];
  }
  REP(i,n) {
    if (s[i] == 'o' && fwd[i] + bwd[i] == k+1 && hist[fwd[i]] == 1) cout<<(i+1)<<"\n";
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 4244
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<cstring>
#include<utility>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<deque>
#include<cctype>
using namespace std;
int main() 
{
	int r,g,b;
	scanf("%d %d %d",&r,&g,&b);
	if((g*10+b)%4==0)
	{
		cout<<"YES";
	}
	else
	cout<<"NO"; 
	return 0; 
}
    

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n;
    cin >> n;
    map<Int, Int> mp;
    bool result = true;
    Int a;
    for (Int i = 0; i < n; ++i) {
        cin >> a;
        if (mp[a] != 0) {
            result = false;
        } else {
            mp[a] = 1;
        }
    }
    if (result) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}



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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  if (l > r) {
    cout << "Left" << endl;
  } else if (l == r) {
    cout << "Balanced" << endl;

  } else {
    cout << "Right" << endl;
  }
}

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

using namespace std;

int main(){
  long  a,b,k;
  long a_,b_;
  cin >> a >> b >> k;
  if(a>=k){
    a_ = a-k;
    b_ = b;
  }else if(a+b>=k){
    a_ = 0;
    b_ = b-(k-a);
  }else{
    a_ = 0;
    b_ = 0;
  }
  cout << a_ << " " << b_ << endl;
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,k;
vector<int>n;
int main()
{
    cin>>a;
    for(int s=0;s<a;s++)
    {
        cin>>k;
        if((s+a+1)%2)n.push_back(k);
        else n.insert(n.begin(),k);
    }
    for(int s=0;s<a;s++)cout<<n[s]<<" ";
}

Measured memory_bytes: 3060
while True:
  H,W=map(int,input().split())
  if(W==0 and H==0):
    break
  for i in range(H):
    for j in range(W):
      if(i%2==1):
        if(j%2==1):
          print("#",end="")
        else:
          print(".",end="")
      else:
        if(j%2==0):
          print("#",end="")
        else:
          print(".",end="")
    print()
  print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#include <regex>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  ll N,K,Q,A[100000],B[100000]={0};
  cin>>N>>K>>Q;
  for (int i(0);i<Q;i++){
    cin>>A[i];
    B[A[i]-1]++;
  }
  for (int i(0);i<N;i++){
    if (B[i]>Q-K) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

int main () {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  int m = h[0];
  int c = 0;

  rep(i,n) {
    if(h[i] >= m) {
      m = max(m, h[i]);
      c++;
    }
  }

  cout << c << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> L(90, 0);
  L.at(0) = 2, L.at(1) = 1;
  
  for (int i = 2; i < 90; i++) {
    L.at(i) = L.at(i-1) + L.at(i-2);
//    printf("L.at(%d) = %d\n", i, L.at(i));
  }
  
//  printf("N = %d\n", N);
  cout << L.at(N) << endl;
}

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

int main() {
  long k;
  string s,ans;
  set<string> a;
  cin >> s >> k;
  for(long i=0;i<s.size();i++) {
    string aaa="";
    for(long j=0;j<k;j++) {
      if(i+j==s.size()) break;
      aaa=aaa+s[i+j];
      a.insert(aaa);
      if(a.size()<=k) continue;
      auto itr=a.end();
      itr--;
      a.erase(itr);
    }
  }
  auto itr=a.end();
  itr--;
  cout << *itr << endl;
}

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;


const int  mod = 1000000007;
struct mint{
    ll x;
    mint (ll x=0) : x((x%mod+mod)%mod){}//カッコの中で初期化している
    mint& operator+=(const mint a){//operatorは構造体同士の比較に用いられる
        if((x +=a.x)>=mod) x-=mod;
        return *this;//thisとは現在のオブジェクトのこと
    }
    mint& operator-=(const mint a){
        if((x +=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a){
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a){
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a){
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const{
        if(!t) return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }
    mint inv() const{
        return pow(mod-2);//逆元
    }
    mint&operator/=(const mint a) {
        return (*this)*=a.inv();
    }
    mint&operator/(const mint a) const{
    mint res(*this);
    return res/=a;
    }
};


int main(void){
    int n;
    cin>>n;
    vector<vector<int> > v(200005);
    vector<int>c(n);
    rep(i, n){
        int a;
        cin>>a;
        v[a].push_back(-i);
        c[i] = a;
    }
    vector<mint>dp(n);
    dp[0] = 1;
    rep(i, n-1){
        dp[i+1] = dp[i];
        if(c[i] == c[i+1]) continue;
        auto itr = lower_bound(v[c[i+1]].rbegin(), v[c[i+1]].rend(), -i+1);
        if(itr == v[c[i+1]].rend()) continue;
        dp[i+1] += dp[*itr*(-1)];
    }
    cout<<dp[n-1].x<<endl;
    return 0;
}

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

int n,num,run;

int main(){
	cin>>n;
	for(int i = 1;i <= n;i++){
		cin>>num;
		if(num % 2 == 0){
			if((num % 3 == 0) || (num % 5 == 0)){
				run++;
				continue;
			}else{
				cout<<"DENIED"<<endl;
				break;
			}
		}else{
			run++;
		}
	}
	if(run == n){
		cout<<"APPROVED"<<endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n, p;
	cin>>n>>p;
	ll c = 0;
	vector<ll> v(n);
	rep(i, n){
		ll a, b;
		cin>>a>>b;
		a *= 100-p;
		b *= p;
		c += b;
		v[i] = a+b;
	}
	sort(all(v)); reverse(all(v));
	ll res = 0;
	for(ll i = 0; i < n; i++){
		c -= v[i];
		if(c<=0){
			cout<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        sc.close();

        int ans = 1;
        for (int i = 1; i < n; i++) {
            boolean isOk = true;
            for (int j = 0; j < i; j++) {
                if (h[j] > h[i]) {
                    isOk = false;
                    break;
                }
            }
            if (isOk) {
                ans++;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
using ll = long long;

struct eratosthenes
{
    int n;
    vector<int> f;
    vector<pair<int, int>> primes;

    eratosthenes(int n) : f(n + 1)
    {
        ll i, j;
        f[0] = f[1] = -1;
        for (i = 2; i <= n; i++)
        {
            if (!f[i])
            {
                f[i] = i;
                primes.push_back(make_pair(i, 0));
                for (j = i * i; j <= n; j += i)
                {
                    if (!f[j])
                    {
                        f[j] = i;
                    }
                }
            }
        }
    }

    vector<int> genosis(int x)
    {
        vector<int> g;

        while (x != 1)
        {
            g.push_back(f[x]);
            x /= f[x];
        }

        return g;
    }

    vector<pair<int, int>> genosiscount(int x)
    {
        vector<pair<int, int>> gc;
        vector<int> g = genosis(x);

        if (g.empty() == 1)
        {
            return {};
        }

        gc.push_back(make_pair(f[x], 0));

        for (auto &i : g)
        {
            if (gc.back().first == i)
            {
                gc.back().second++;
            }
            else
            {
                gc.push_back(make_pair(i, 1));
            }
        }

        return gc;
    }
};

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % 1000000007;
        x = (x * x) % 1000000007;
        y >>= 1;
    }
    return ans;
}

int main(void)
{
    eratosthenes a(1e6 + 1);
    int N;
    int A[10010];
    int i, j;
    ll ans = 0;
    ll lcm = 1;

    cin >> N;

    for (i = 0; i < N; i++)
    {
        cin >> A[i];

        for (auto &j : a.genosiscount(A[i]))
        {
            for (auto &k : a.primes)
            {
                if (j.first == k.first && j.second > k.second)
                {
                    k.second = j.second;
                }

                if (j.first < k.first)
                {
                    break;
                }
            }
        }
    }

    for (auto &x : a.primes)
    {
        lcm = lcm * power(x.first, x.second) % 1000000007;
    }

    for (i = 0; i < N; i++)
    {
        ll add = lcm * power(A[i], 1000000005) % 1000000007;
        ans = (ans + add) % 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5368
#include <cstdio>
#include <iostream>
#include <iomanip>
using namespace std;

int main(){

	int a,b;

	cin >> a >> b;
	cout << a/b <<  " " << a%b <<  " " << fixed << setprecision(5) << (double)a/b << endl;
	return 0;
}

Measured memory_bytes: 3276
import java.util.*;
public class Main {
    public static void main(String[] args) {
        String returnFlag ="No";
        Scanner scanner = new Scanner(System.in);
        int totalN = scanner.nextInt();
        int cake4 =0;
        int donut7=0;
        while(donut7*7<=totalN){
            cake4=0;
            while ((donut7*7+cake4*4)<=totalN){
                if(donut7*7+cake4*4==totalN){
                    returnFlag="Yes";
                    break;
                }
                cake4++;
            }
            donut7++;
        }
        System.out.println(returnFlag);
    }
}


Measured memory_bytes: 22996
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//いやーコンテスト中は絶対無理
int hist[300001], cnt[300001];
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	rep(i, N) hist[getint()]++;
	rep1(i, N) cnt[hist[i]]++;

	int ruiseki = N;
	int mae = 1;
	int kei = 1;
	int ijou = 0;

	const int dm = 1 << 21;
	char dn[dm], * di = dn;
	char C[10];
	int keta = 0;
	int X = N;
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}

	for (int i = N; i >= 1; i--) {
		ijou += cnt[i];
		ruiseki -= cnt[i] * i;
		while ((kei - ijou) * i <= ruiseki) kei++;

		for (int j = mae; j < kei; j++) {
			for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
			*di++ = '\n';
		}

		C[0]--;
		int k = 0;
		while (C[k] < '0') {
			C[k++] = '9';
			C[k]--;
		}
		if (C[keta - 1] == '0') keta--;

		mae = kei;
	}
	for (int j = mae; j <= N; j++) {
		*di++ = '0';
		*di++ = '\n';
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int ans=0;
  if(A>=13)ans=B;
  else if(A<=12 && A>=6)ans=B/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int H = Integer.parseInt(scn.next());
		scn.next();
		ArrayList<String> strs = new ArrayList<>();
		for (int i = 0; i < H; i++) {
			strs.add(scn.next());
		}
		for (int i = 0; i < H; i++) {
			System.out.println(strs.get(i));
			System.out.println(strs.get(i));
		}
	}
}

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

int main (void){
  long n, k, q;
  cin >> n >> k >> q;
  vector<long> a;
  for(int i = 0; i < q; i++){
    long x;
    cin >> x;
    a.push_back(x-1);
  }
  
  vector<long> p(n, 0);
  for(int i = 0; i < q; i++){
    p[a[i]]++;
  }
  
  for(auto x : p){
    if(k - (q - x) < 1){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
    //cout << k - (q - x) << endl;
  }
  return 0;
}


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

int main()
{
    long long int l,r,i,j,n,mini=99999999;
    cin>>l>>r;
    if(l*r<2019)
    {
        cout<<l*(l+1)<<endl;
        return 0;
    }
    else
    {
        if((l*r)%2019==0)
            cout<<0<<endl;
        else if(l<2019 && r>2019)
            cout<<0<<endl;
        else if(l%2019==0 || r%2019==0)
            cout<<0<<endl;
        else
        {
            j=1;
            for(i=l*2019; i<=r; i*j,j++)
            {
                if(i%2019==0)
                {
                    cout<<0<<endl;
                    return 0;
                }
            }
            for(i=l; i<=r; i++)
            {
                for(j=i+1; j<=r; j++)
                {
                    mini=min(mini,(i*j)%2019);
                    if(mini==0)
                    {
                        cout<<0<<endl;
                        return 0;
                    }
                }
            }
            cout<<mini<<endl;
        }
    }
    return 0;
}

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

int n;
int activity[100005][3];
int dp[100005][3];

int func(int r,int c){
	if(r>=n)return INT_MIN;
	if(dp[r][c]!=-1)return dp[r][c];
	int op1=INT_MIN,op2=INT_MIN;
	if(c==0){
		op1=func(r+1,c+1);
		op2=func(r+1,c+2);
	}
	else if(c==1){
		op1=func(r+1,c-1);
		op2=func(r+1,c+1);
	}
	else{
		op1=func(r+1,c-1);
		op2=func(r+1,c-2);
	}
	if(op1!=INT_MIN || op2!=INT_MIN)
	dp[r][c]=activity[r][c]+max(op1,op2);
	else dp[r][c]=activity[r][c];
	return dp[r][c];
}

int main(){
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>activity[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	int op1=func(0,0);
	
	int op2=func(0,1);
	int op3=func(0,2);
	cout<<max(op1,max(op2,op3))<<endl;
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int k,n;
        cin>>k>>n;
        int a[n];
        loop(i,0,n-1) cin>>a[i];
        int ans = a[n-1]-a[0];
        loop(i,1,n-1){
            ans = min(ans,k+a[i-1]-a[i]);
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 1792
from collections import deque

N = int(input())
S = input()

s = deque(S)

ans = []
r, l, cnt = 0, 0, 0

while s:
    q = s.popleft()
    if q == ')':
        cnt -= 1
        if cnt < 0:
            l += 1
            cnt += 1
    else:
        cnt += 1
        
if cnt > 0: r += cnt

print('('*l + S + ')'*r)

Measured memory_bytes: 3316
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  string S;
  cin >> S;
  for(int i=0; i<S.size(); ++i) {
    cout << "x";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		StringBuilder S = new StringBuilder(sc.next());
		StringBuilder T = new StringBuilder(sc.next());		
		
		boolean flag = isSame(S,T);
		if (!flag) {
			for(int i = 0; i < S.length(); i++) {
				char c = S.charAt(0);
				S.deleteCharAt(0);
				S.append(c);
				if (isSame(S,T)) {
					flag = true;
					break;
				}
			}
		}
		if(flag)out.println("Yes");
		else out.println("No");
		out.close();
	}
	static boolean isSame(StringBuilder s, StringBuilder t) {
		boolean ret = true;
		for(int i = 0; i < s.length(); i++) {
			char c1 = s.charAt(i);
			char c2 = t.charAt(i);
			if(c1 != c2) {
				ret = false;
				break;
			}
		}
		return ret;
	}
	static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

int arr[N][3];


    
void test_case() {

   int n;
   cin>>n;


   string s;
   cin>>s;

   ll ans =0;

   ll r=0,g=0,b=0;



   for(int i=n-1; i>=0; i--) {

       if(s[i] == 'R') {
           r++;
       }
       else if(s[i] == 'G') {
           g++;
       } else {
           b++;
       }
   }

   for(int i=0; i<n-1; i++) {
       for(int j=i+1; j<n; j++) {
           
           int k = j*2 - i;
           if(k>=n) {
               break;
           }
           if ((s[i] != s[j]) && (s[j] != s[k]) && (s[i] != s[k])) {
               ans++;
           }
             
       }
   }

   cout<<r*g*b - ans<<endl;

   





}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int S[4];
    cin >> S[0] >> S[1] >> S[2] >> S[3];
    sort(S, S + 4);
    if (S[0] == 1 && S[1] == 4 && S[2] == 7 && S[3] == 9) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    vint t(3);
    rep(i, 3) cin >> t[i];
    sort(all(t));
    int ans = t[0] + t[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def sort(a, n)
  for i in 0..n-2
    min_index = i
    for j in i+1..n-1
      if a[min_index] > a[j]
        min_index = j
      end
    end
    if min_index != i
      a[i], a[min_index] = a[min_index], a[i]
    end
  end
  a
end




n,l = gets.chomp.split(" ").map(&:to_i)
a = []

for i in 1..n
  s = gets.chomp.to_s
  a.push(s)
end

a = sort(a, n)

for i in 0..n-1
 print a[i]
end

Measured memory_bytes: 1788
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char **argv)
{
	double w;
	while (scanf("%lf", &w) != EOF)
	{
		if (w <= 48)
			printf("light fly\n");
		else if (w <= 51)
			printf("fly\n");
		else if (w <= 54)
			printf("bantam\n");
		else if (w <= 57)
			printf("feather\n");
		else if (w <= 60)
			printf("light\n");
		else if (w <= 64)
			printf("light welter\n");
		else if (w <= 69)
			printf("welter\n");
		else if (w <= 75)
			printf("light middle\n");
		else if (w <= 81)
			printf("middle\n");
		else if (w <= 91)
			printf("light heavy\n");
		else
			printf("heavy\n");
	}

	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,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 pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
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, M;
  cin>>N>>M;

  Int ans = 0;
  ans += N * (N - 1) / 2;
  ans += M * (M - 1) / 2;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import networkx as nx

N = int(input())
ABs = [tuple(map(int, input().split())) for _ in range(N)]
CDs = [tuple(map(int, input().split())) for _ in range(N)]

# 0 <= i <   N  -> i: ABs[i]
# N <= i < 2*N  -> i: CDs[i-N]
# i == 2*N+1    -> start
# i == 2*N+2    -> goal

DG = nx.DiGraph()
DG.add_nodes_from(range(2 * N + 3))
for i in range(N):
    for j in range(N):
        if ABs[i][0] < CDs[j][0] and ABs[i][1] < CDs[j][1]:
            DG.add_edge(i, j + N, capacity = 1)

DG.add_edges_from([(2 * N + 1, i, {"capacity":1}) for i in range(N)])
DG.add_edges_from([(i, 2 * N + 2, {"capacity":1}) for i in range(N, 2*N)])

print(nx.maximum_flow_value(DG, 2 * N + 1, 2 * N + 2))


Measured memory_bytes: 56732
#include<stdio.h>
#define NUM 21
int main()
{
  int n,m;
  int i,j;
  int x,y;
  int robox,roboy;
  int place[NUM][NUM];
  int sum;
  int step;
  char c;
  while(1)
    {
      scanf("%d",&n);
      if(n==0) break;
      for(i=0;i<NUM;i++)
	{
	  for(j=0;j<NUM;j++)
	    {
	      place[i][j]=0;
	    }
	}
      for(i=0;i<n;i++)
	{
	  scanf("%d %d",&x,&y);
	  place[x][y]=1;
	}
      robox=10;
      roboy=10;
      scanf("%d",&m);
      for(j=0;j<m;j++)
	{
	  while(1)
	    {
	      scanf("%c",&c);
	      if((c=='N')||(c=='E')||(c=='S')||(c=='W')) break;
	    }
	  scanf("%d",&step);
	  switch(c)
	    {
	    case 'N':
	      for(i=0;i<step;i++) place[robox][++roboy]=0;
	      break;
	    case 'E':
	      for(i=0;i<step;i++) place[++robox][roboy]=0;
	      break;
	    case 'S':
	      for(i=0;i<step;i++) place[robox][--roboy]=0;
	      break;
	    case 'W':
	      for(i=0;i<step;i++) place[--robox][roboy]=0;
	      break;
	    }
	}
      sum=0;
      for(i=0;i<NUM;i++)
	{
	  for(j=0;j<NUM;j++)
	    {
	      sum+=place[i][j];
	    }
	}
      if(sum) printf("No\n");
      else printf("Yes\n");
    }  
  return 0;
}

Measured memory_bytes: 580
M=1000003
o=->a,n{n<1?1:(n%2>0?a:1)*o[a,n/2]**2%M}
f=f=1,*(1..M).map{|i|f=f*i%M}
gets
$<.map{|s|x,d,n=s.split.map &:to_i
t=x*o[d,M-2]%M
p d<1?o[x,n]:M<t+n||t<1?0:f[t+n-1]*o[f[t-1],M-2]*o[d,n]%M}

Measured memory_bytes: 19452
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)

int N;
lint MOD;

lint power(lint x, lint n, lint MOD=MOD)
{
    lint ans = 1;
    while (n>0)
    {
        if (n & 1) (ans *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ans;
}

vector<lint> fac, facInv, inv;
void facInit(int nmax)
{
    fac = facInv = inv = vector<lint>(nmax + 1, 1);
    for (int i = 2; i <= nmax; i++)
    {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        facInv[i] = facInv[i-1] * inv[i] % MOD;
    }
}

lint nCr(int n, int r)
{
    if (n<r || r<0) return 0;
    return (fac[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}


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

    vector<lint> part(N + 1, 0);

    vector<vector<lint> > dp(N+1, vector<lint>(N+1)); // dp[i][j] : 品1~iの一部をj杯に分割する総数
    REP(i, N+1) dp[i][0] = 1;
    FOR(i, 1, N+1) FOR(j, 1, N+1) {
        dp[i][j] = (dp[i-1][j] * (j + 1) + dp[i-1][j-1]) % MOD;
    }

    REP(n, N+1) {
        lint pattern = power(2, N - n);
        lint pattern_p = power(2, N - n, MOD - 1);
        REP(j, n+1) (part[n] += (dp[n][j] * power(pattern, j) % MOD) * power(2, pattern_p)) %= MOD;
    }

    lint ans = 0;
    REP(n, N+1) (ans += ((MOD + 1 - n%2*2) * nCr(N, n) % MOD) * part[n]) %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 72832
#include<bits/stdc++.h>
using namespace std;
int fact(int n);

int main(){
    int N; cin >> N;
    int x[N], y[N];
    for(int i = 0; i < N; i++) cin >> x[i] >>y[i];
    int f = fact(N);


    double sum = 0;
    int dia = N*(N-3)/2 + N;
    int n = f/N * 2;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            sum += (double)n * sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
        }
    }

    printf("%0.7f\n", sum/f);

}

int fact(int n){
    if(n < 2) return 1;

    int ans = 1;

    for(int i = 1; i <= n; i++){
        ans *= i;
    }

    return ans;
}

Measured memory_bytes: 256
H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(H)]
Q=int(input())
X=[[[0,0] for _ in range((H*W)//D+1)] for _ in range(D)]
for i in range(H):
    for j in range(W):
        X[A[i][j]%D][A[i][j]//D][0]=i
        X[A[i][j]%D][A[i][j]//D][1]=j
M=[[0]*((H*W)//D+1) for _ in range(D)]
for d in range(D):
    for k in range((H*W)//D):
        M[d][k+1]=abs(X[d][k+1][0]-X[d][k][0])+abs(X[d][k+1][1]-X[d][k][1])+M[d][k]

for i in range(Q):
    L,R=map(int,input().split())
    print(M[L%D][R//D]-M[L%D][L//D])

Measured memory_bytes: 45992
s = gets.chomp.split('').map(&:to_i)
n = s.length

arr1 = Array.new(n) {|i| i % 2 }
arr2 = Array.new(n) {|i| (i + 1) % 2 }
#p s, arr1, arr2
cnt1 = 0
cnt2 = 0
n.times do |i|
  cnt1 += s[i] ^ arr1[i]
  cnt2 += s[i] ^ arr2[i]
end
#p cnt1, cnt2
puts([cnt1, cnt2].min)

Measured memory_bytes: 9340
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N, K; cin >> N >> K;
    int ans = 1;
    rep(i,0,N) {
        ans = min(2 * ans, ans + K);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate
from bisect import bisect_left


def main():
    n, k = map(int, input().split())
    memo = [0] * (10 ** 5 + 1)
    for _ in range(n):
        i, j = map(int, input().split())
        memo[i] += j
    ans = bisect_left(list(accumulate(memo)), k)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 10624
let () =
  let id x = x in
  let calc_9 () =
    let rec read_m n =
      if n == 0 then [] else (Scanf.scanf "%d\n" id)::(read_m (n-1))
    in
    let l = read_m 9 in
    List.fold_left (+) 0 l
  in
  let rec loop () =
    let total = Scanf.scanf "%d\n" id in
    if total == 0 then
      ()
    else
      let t9 = calc_9 () in
      Printf.printf "%d\n" (total - t9);
      loop ()
  in
  loop ()

Measured memory_bytes: 2312
n = int(input())
a = list(map(int, input().split()))

a.sort()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if a[i] != a[j] and a[j] != a[k] and a[k] != a[i] and a[i]+a[j] > a[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9188
import sys
import math
import bisect

def solve(A):
    n = len(A)
    ans = [0] * n
    for i in range(n):
        ans[A[i]-1] = i + 1
    return ans

def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = solve(A)
    print(' '.join(list(str(a) for a in ans)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 18376