akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

template<class T> inline bool chmin(T& a, const T b) { if (a>b) { a=b; return true; } return false; }
template<class T> inline bool chmax(T& a, const T b) { if (a<b) { a=b; return true; } return false; }


int n;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    vi a(n);
    map<int,ll> mp;
    //VIN(a);
    REP(i,n){
        int tmp;
        cin>>tmp;
        a[i] = tmp;
        mp[tmp]++;
    }

    map<int,ll> cbs;
    ll allpat = 0;

    for(auto& e:mp){
        cbs[e.first] = e.second*(e.second-1)/2;
        allpat += cbs[e.first];
    }

    REP(i,n){
        ll ans = 0;
        ll bancb = 0;
        bancb += ( (mp[a[i]]-1) * max(0LL,mp[a[i]]-2) ) / 2;

        ans = allpat - cbs[a[i]] + bancb;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
using namespace std;


int main(int argc,char *argv[])
{
    ll cnt=0,n,k,r,s,p;
    static char t[100010];
    cin>>n>>k>>r>>s>>p>>t;
    for(int i=0; i<k; i++)
    {
        switch(t[i])
        {
        case 's':
            cnt+=r;
            break;
        case 'p':
            cnt+=s;
            break;
        case 'r':
            cnt+=p;
            break;
        }
    }
    for(int i=k; i<n; i++)
    {
        if(t[i]==t[i-k])
            t[i]='0';
        else
            switch(t[i])
            {
            case 's':
                cnt+=r;
                break;
            case 'p':
                cnt+=s;
                break;
            case 'r':
                cnt+=p;
                break;
            }

    }
    cout<<cnt;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

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


int main() {
  int n, k; cin>>n>>k;
  vector<int> p(n);
  rep(i, n) cin>>p[i];
  vector<double> b(n);
  rep(i, n) {
    b[i] = (p[i]+1)/2.0;
  }
  vector<double> acc(n+1,0);
  rep(i,n) acc[i+1] = acc[i]+b[i];
  double ans = 0;
  REP(i, k, n+1) {
    ans = max(ans, acc[i]-acc[i-k]);
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main()
{
 int l,n,mim,sum=0,vdt=0;
 cin>>n>>l;
 int of[n+1],al[n+1];
 for(int i=1;i<=n;i++){
    of[i-1]=l+i-1;
 }
 for(int i=1;i<=n;i++){
    if(of[i-1]>=0){
        al[i-1]=of[i-1]*1;
    }
    else{
        al[i-1]=of[i-1]*(-1);
    }
 }
 for(int i=0;i<n;i++){
    vdt=0;
    for(int j=0;j<n;j++){
    if(al[i]<al[j]){
        vdt++;
    }
    }
    if(vdt==n-1){
        mim=i+1;
    }
 }
 for(int i=0;i<n;i++){
    sum=sum+of[i];
 }
 sum=sum-(mim+l-1);
 cout<<sum;
 return 0;
}

Measured memory_bytes: 256
n=int(input())
b=list(map(int,input().split()))
a=[0]*n
a[0]=b[0]
a[1]=b[0]
for i in range(1,n-1):
    x=b[i]
    a[i+1]=x
    if a[i]>x:
        a[i]=x
print(sum(a))


Measured memory_bytes: 3060
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N, X = getNM()
A = getList()
ans = 0
flag = True
while flag:
    flag = False
    for i in range(N - 2):
        minus1 = A[i] + A[i + 1] - X
        minus2 = A[i + 1] + A[i + 2] - X
        if minus1 > 0 and minus2 > 0:
            minuspoint = min(minus1, minus2, A[i + 1])
            A[i + 1] -= minuspoint
            ans += minuspoint
            flag = True
between = [A[i] + A[i + 1] - X for i in range(N - 1)]
for i in between:
    if i > 0:
        ans += i
print(ans)


Measured memory_bytes: 69852
#include <iostream>
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    long long K;
    cin >> K;
    int x = 0;
    int count;
    for (count = 0; count < K; count++) {
        x = (x * 10 + 7) % K;
        if (x == 0)
            break;
    }
    
    if (count == K)
        cout << -1;
    else
        cout << count + 1 ;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

vector<LL> f(LL n){
  vector<LL> v;
  FOR(i, 1, 1e10)
  {
    if(i*i>n){
      break;
    }

    if(n%i==0){
      v.push_back(i);
      v.push_back(n/i);
    }
  }
  return v;
}

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

  LL n;
  cin>>n;
  vector<LL> v(n);
  REP(i, n)
  {
    cin >> v[i];
  }
  vector<LL> v0 = f(v[0]);
  vector<LL> v1 = f(v[1]);

  LL max = -1;

  REP(i,v0.size()){
    LL fl = 0;
    REP(j, v.size())
    {
      if(j==0){
        continue;
      }
      if(v[j]%v0[i]!=0)
      {
        fl++;
      }
    }
    if(fl<=1){
      if(max<v0[i]){
        max = v0[i];
      }
    }
  }
  REP(i,v1.size()){

    LL fl = 0;
    REP(j, v.size())
    {
      if(j==1){
        continue;
      }
      if(v[j]%v1[i]!=0)
      {
        fl ++;
      }
    }
    if(fl<=1){
      if(max<v1[i]){
        max = v1[i];
      }
    }
  }

  cout << max << endl;
}


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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;} //　a*bでオーバーしないように/を先に

ll f(ll x, int c, int d) {
  ll res = x;
  res -= x/c;
  res -= x/d;
  res += x/lcm(c,d);
  return res;
}


int main() {
  ll a, b;
  int c, d;
  cin >> a >> b >> c >> d;
  
  ll ans = f(b,c,d) - f(a-1,c,d);
  
  cout << ans << endl;
  return 0;
}

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



int main()
{

    int n;
    cin>>n;


    vector<int> v(n-1);

    map<int,int> m;
    map<int,int> :: iterator it;


    for(int i=0;i<n-1;i++){
        cin>>v[i];

        m[v[i]]++;


    }


    //cout<<m.size()<<endl;


    vector<int> ans(n,0);

   // for(int i=0;i<n;i++)ans.push_back(0);

    for(it=m.begin();it!=m.end();it++){
          int x=it->first;
          x--;
          ans[x]=it->second;

    }



    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;

    }

    return 0;
}



Measured memory_bytes: 14348
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

using ll=long long;

struct BIT{
	vector<ll> data;
	void Init(int n){
		data.assign(n,0);
	}
	void Add(int i,int v){
		while(i<(int)data.size()){
			data[i]+=v;
			i+=(i+1)&(-i-1);
		}
	}
	void Range(int b,int e,int x){
		Add(b,x);
		Add(e,-x);
	}
	ll Get(int i){
		ll ret=0;
		while(i>=0){
			ret+=data[i];
			i-=(i+1)&(-i-1);
		}
		return ret;
	}
} bx,by;

struct Query{
	int x,d,l;
};

int main(){
	int n=read(),q=read();
	vector<Query> qs;
	REP(_,q){
		int x=read(),d=read(),l=read();
		qs.PB(Query{x,d,l});
	}
	reverse(qs.begin(),qs.end());
	bx.Init(n);
	by.Init(n);
	REP(i,n)
		bx.Range(i,i+1,i);
	for(auto k:qs){
		if(k.d==1){
			//y=x-k.x
			int l=-1,r=n;
			while(r-l>1){
				const int m=(l+r)/2;
				ll x=bx.Get(m),y=by.Get(m);
				if(y>x-k.x)
					l=m;
				else
					r=m;
			}
			bx.Range(0,r,-k.l);
			by.Range(0,r,-k.l);
		}else{
			//y=-x+k.x
			int l=-1,r=n;
			while(r-l>1){
				const int m=(l+r)/2;
				ll x=bx.Get(m),y=by.Get(m);
				if(y<-x+k.x)
					l=m;
				else
					r=m;
			}
			bx.Range(r,n,k.l);
			by.Range(r,n,-k.l);
		}
	}
	REP(i,n)
		printf("%lld\n",-by.Get(i));
}

Measured memory_bytes: 8368
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll a, b , c, x;
    ll ans = 0;
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                ll total = 500*i + 100*j + 50*k;
                if(total == x) ++ans;
            }
        }
    }
    cout << ans << endl;
}
   

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<utility>
using namespace std;



int main(){
	int n;
	while(cin>>n&&n){
		stringstream ss;
		string s;
		cin.ignore();
		while(n--){
			getline(cin,s);
			ss<<s<<' ';
		}
		char k;
		cin>>k;
		map<string,int> mp;
		map<string,int>::iterator it;
		while(ss>>s){
			if(s[0]==k)++mp[s];
		}
		set<pair<int,string> > a;
		set<pair<int,string> >::iterator ita;
		for(it=mp.begin();it!=mp.end();++it)
			a.insert(make_pair(-it->second,it->first));
		int cnt=0;
		for(ita=a.begin();cnt++<5&&ita!=a.end();++ita){
			if(cnt!=1)cout<<' ';
			cout<<ita->second;
		}
		if(a.begin()==a.end())cout<<"NA";
		cout<<endl;
	}
	return 0;
}

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

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

//K>=10 , In Rate=Out
//In Rate= Displayed Rate+100*(10-K)

if(K>=10){cout<<N;}
else {cout<<N+(100*(10-K));}

     }

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mdl=1000000007;
in fu(in nu, in nn, in ou){
  if(nu<nn)
    return 0;
  if(nu>nn)
    return 2;
  return ou;
}
vector<VVI> wys,nwys;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  ++n;
  in nn;
  wys.resize(3,VVI(2,VI(2)));
  wys[1][1][0]=1;
  forn(i,61){
    nn=!!(n&(1LL<<i));
    nwys=vector<VVI>(3,VVI(2,VI(2)));
    forn(ou,3){
      forn(cnc,2){
	forn(cc,2){
	  if(!cnc && !cc)
	    continue;
	  forn(nu,2){
	    forn(nx,2){
	      bool ncnc=0;
	      bool ncc=0;
	      forn(a,2){
		forn(b,2){
		  forn(actc,2){
		    if(actc==0 && !cnc)
		      continue;
		    if(actc==1 && !cc)
		      continue;
		    in au=a+b+actc;
		    in ax=a^b;
		    if(au%2!=nu || ax!=nx)
		      continue;
		    if(au/2)
		      ncc=1;
		    else
		      ncnc=1;
		  }
		}
	      }
	      if(ncnc || ncc)
		nwys[fu(nu,nn,ou)][ncnc][ncc]+=wys[ou][cnc][cc];
	    }
	  }
	}
      }
    }

    wys=nwys;
    forv(i,wys){
      forv(j,wys[i]){
	forv(k,wys[i][j])
	  wys[i][j][k]%=mdl;
      }
    }
  }
  in sm=0;
  sm+=wys[0][1][0];
  sm+=wys[0][1][1];
  sm%=mdl;
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

const maxBuf = 200100

var debug = false

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	if debug {
		testFile, _ := os.Open("./test/sample-2.in")
		sc = bufio.NewScanner(testFile)
	}
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

/* #### main #### */
func main() {
	H := readInt()
	W := readInt()

	odd := W/2 + W%2
	even := W / 2

	if H == 1 || W == 1 {
		fmt.Println(1)
		return
	}

	if H%2 == 0 {
		fmt.Println((even + odd) * (H / 2))
	} else {
		fmt.Println((even+odd)*(H/2) + odd)
	}
}


Measured memory_bytes: 1784
n,y=map(int,input().split())

for i in range(n+1):
    ai=10000*i
    if ai > y: continue
    else:
        for j in range(n+1-i):
            bj=5000*j
            if ai + bj > y :break
            else : 
                k=n-i-j
                if  ai + bj + 1000*k == y:
                    print(i,j,k)
                    exit()

print(-1,-1,-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+5;
const long long mod = 1e9+7;
long long Sort[maxn];
long long ans[maxn];
int dir[9][2]={-2,-2,-2,-1,-2,0,-1,-2,-1,-1,-1,0,0,-2,0,-1,0,0};
int tot;
int main()
{
	long long H,W,N;
	scanf("%lld%lld%lld",&H,&W,&N);
	long long Ans=(long long)(H-2)*(long long)(W-2);
	for(int i=0;i<N;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		for(int j=0;j<9;j++)
		{
			int xx=x+dir[j][0];
			int yy=y+dir[j][1];
			if(xx>=1 && xx<=H-2 &&yy>=1 && yy<=W-2)
			{
				Sort[tot++] = xx * mod + yy;
			}
		}
	}
	sort(Sort,Sort+tot);
	int cnt=1;
	for(int i=0;i<tot;i++)
	{
		if(Sort[i]==Sort[i+1])
			cnt++;
		else
		{
			ans[cnt]++;
			cnt=1;
			Ans--;
		}
	}
	printf("%lld",Ans);
	for(int i=1;i<10;i++)
		printf(" %lld",ans[i]);
	printf("\n");
	return 0;
}

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

int main()
{
  int h,n;
  cin>>h>>n;
  int a[n],sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  if(sum>=h)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)














int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    REP(i, n){
        if(a[i] != b.back()){
            cout << b.back() << endl;
        }
        else{
            cout << b[n - 2] << endl;
        }
    }
}


Measured memory_bytes: 4736
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let print_int n = Printf.printf "%d\n" n

let () =
  let a = scan_int() and b = scan_int() in
  let ans =
    if b = 1 then 0
    else if b < a then 1 
    else 1 + (b-2) / (a-1) in
  print_int ans  

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll k;
  cin >> k;
  vector<ll> a(k);
  for(int i = 0;i < k;i++)cin >> a[i];
  ll minres = 0;
  ll maxres = 0;
  if(a[k - 1] != 2){
    cout << -1 << endl;
    return 0;
  }
  minres = 2;
  maxres = 3;
  for(int i = k - 1;i >= 0;i--){
    minres = (minres + a[i] - 1) / a[i] * a[i];
    maxres = (maxres + a[i] - 1) / a[i] * a[i];
  }
  maxres--;
  if(minres == maxres + 1)cout << -1 << endl;
  else cout << minres << " " << maxres << endl;
}

Measured memory_bytes: 4052
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> r(N);
	for (int i = 0; i < N; i++)
		cin >> r[i];
	sort(r.begin(), r.end());
	double ma = 0;
	for (int n = 3; n <= N; n++) {
		vector<int> a(r.end() - n, r.end());
		do {
			vector<double> x(n), y(n);
			for (int i = 0; i < n; i++) {
				x[i] = a[i] * cos(M_PI*2 / n * i);
				y[i] = a[i] * sin(M_PI*2 / n * i);
			}
			for (int t = 0; t < 5; t++) {
				int i = rand() % n;
				int j = (i + n - 1) % n, k = (i + 1) % n;
				double dx = x[k] - x[j], dy = y[k] - y[j];
				double _dx = dy, _dy = -dx;
				double r = sqrt(_dx * _dx + _dy * _dy);
				x[i] = _dx / r * a[i];
				y[i] = _dy / r * a[i];
			}
			double sum = 0;
			for (int i = 0; i < n; i++) {
				int j = (i + 1) % n;
				sum += x[i] * y[j] - y[i] * x[j];
			}
			ma = max(ma, sum);
		} while (next_permutation(a.begin() + 1, a.end()));
	}
	printf("%.15f\n", ma / 2);
}

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

void Main() {
  int N, K;
  cin >> N >> K;

  vector<int> a(N);
  int max_a = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    max_a = max(max_a, a[i]);
  }

  int l = 0, r = max_a + 1;
  while (r - l > 1) {
    int c = (l + r) / 2;

    int sum = 0;
    for (int i = 0; i < N; i++) {
      if (a[i] % c == 0) {
        sum += a[i] / c - 1;
      } else {
        sum += a[i] / c;
      }
    }
    if (sum <= K) r = c;
    else l = c;
  }
  cout << r << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public string[] StringArray()
    {
        Line = Console.ReadLine().Split(Separator);
        Index = Line.Length;
        return Line;
    }

    public int[] IntArray()
    {
        var l = StringArray();
        var res = new int[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = int.Parse(l[i]);
        }
        return res;
    }

    public long[] LongArray()
    {
        var l = StringArray();
        var res = new long[l.Length];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = long.Parse(l[i]);
        }
        return res;
    }
}

class Program
{
    private int N, C;
    private int[] s, t, c;
    private void Scan()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        C = sc.NextInt();
        s = new int[N];
        t = new int[N];
        c = new int[N];
        for (int i = 0; i < N; i++)
        {
            s[i] = sc.NextInt() * 2 - 1;
            t[i] = sc.NextInt() * 2;
            c[i] = sc.NextInt() - 1;
        }
    }

    public void Solve()
    {
        Scan();
        var imos = new int[200001, C];
        for (int i = 0; i < N; i++)
        {
            imos[s[i], c[i]]++;
            imos[t[i], c[i]]--;
        }
        for (int i = 1; i <= 200000; i++)
        {
            for (int j = 0; j < C; j++)
            {
                imos[i, j] += imos[i - 1, j];
            }
        }
        int max = 0;
        for (int i = 0; i < 200000; i++)
        {
            int cnt = 0;
            for (int j = 0; j < C; j++)
            {
                cnt += imos[i, j] > 0 ? 1 : 0;
            }
            max = Math.Max(max, cnt);
        }
        Console.WriteLine(max);
    }



    static void Main(string[] args)
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 39616
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fr(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front


int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
	int e;
	cin>>e;
	cout<<3*e*e;
}


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

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )

#define INF 1000000000

void swap(int* x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;
}

int binary_search(int p[], int n, int key)
{
	int left, right, middle;

	left = 0;
	right = n-1;


	while (left <= right)
	{
		middle = (left + right) / 2;

		if (p[middle] == key)
			return middle;
		else if (p[middle] > key)
		{
			right = middle - 1;
		}
		else if (p[middle] < key)
		{
			left = middle + 1;
		}
	}

	return -1;

}

void bubble_sort(int p[], int n)
{
	int i, j;

	for (i = 0; i < n-1; i++)
	{
		for (j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[i], &p[i + 1]);
		}
	}
}

int main()
{
	int H[10000], W[10000];
	int i, j,k,count = 0;

	for (i = 0;; i++)
	{
		scanf("%d%d", &H[i], &W[i]);

		if (H[i] == 0 && W[i] == 0)
			break;

		count++;
	}

	for (i = 0; i < count; i++)
	{
		for (j = 0; j < H[i]; j++)
		{
			for (k = 0; k < W[i]; k++)
			{
				if (j == 0 || j == H[i]-1 || k == 0 || k == W[i]-1)
					printf("#");
				else
					printf(".");
			}

			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2128
let lcs x y =
  let m = String.length x in
  let n = String.length y in
  let dp = Array.make_matrix (m+1) (n+1) 0 in
  let rec duduwa i j =
    if j > n then doit (i + 1)
    else begin
      dp.(i).(j) <- if x.[i-1] = y.[j-1] then dp.(i-1).(j-1) + 1 else max dp.(i - 1).(j) dp.(i).(j-1);
      duduwa i (j + 1)
    end
  and doit i =
    if i > m then dp.(m).(n)
    else duduwa i 1
  in
  doit 1

let () =
  let q = read_int () in
  let rec doit i =
    if i < q then begin
      let x = read_line () in
      let y = read_line () in
      Printf.printf "%d\n" (lcs x y);
      doit (i + 1)
    end
  in
  doit 0

Measured memory_bytes: 18660
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{
  int h,w;
  cin>>h>>w;
  ll dp[h][w];
  dp[0][0]=1;

  rep(i,h)
  {
    rep(j,w)
    {
      char c;
      cin>>c;
      if(i!=0 || j!=0)
      {
        dp[i][j]= ( (i-1>=0)?dp[i-1][j]:0 )+ ( (j-1>=0)?dp[i][j-1]:0 );
        dp[i][j]%=mod;          
      }

      if(c=='#')
        dp[i][j]=0;
    }
  }


  h--;w--;
  cout<<dp[h][w]<<endl;
} 

int main()
{

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

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

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

  return 0;
}


Measured memory_bytes: 11456
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}

fn main() {
    //n,a読み込み
    let _n = read::<u32>();
    let mut a = read_vec::<u32>();

    //リストの内容物を全て2で割るのを繰り返す
    let mut ans = 0;
    loop {
        if a.iter().any(|n| n%2 != 0){
            break;
        }
        ans += 1;

        a = a.iter().map(|n| n / 2).collect();
    }


    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <cstdio>           // printf(), scanf()
#include <algorithm>        // upper_bound()

using namespace std;
static const int MAX_N = 100000;

int
main(int argc, char** argv)
{
	int n, q;
	int a;
	long int b[MAX_N + 1];
	long int x;
	int i, j;

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

	for (i = 0; i < q; ++i)
	{
		scanf("%ld", &x);
		long int count = 0;
		for (j = 1; j <= n; ++j)
			count += upper_bound(b, b + (n + 1), b[j - 1] + x) - (b + j);

		printf("%ld\n", count);
	}

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    if (N < 65) cout << 0 << endl;
    else if (N <= 90) cout << 1 << endl;
    else if (N < 97) cout << 0 << endl;
    else if (N <= 122) cout << 2 << endl;
    else cout << 0 << endl;
}


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

typedef long long ll;

ll gcd( ll a, ll b );
ll lcm( ll a, ll b );

ll n, t[100], ans;

int main()
{
    scanf("%lld", &n );

    for ( int i = 0; i < n; ++i ) {
        scanf("%lld", &t[i] );
    }

    ans = t[0];

    for ( int i = 1; i < n; ++i ) {
        ans = lcm( t[i], ans );
    }

    printf("%lld\n", ans );

    return 0;
}

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

ll lcm( ll a, ll b )
{
    return a / gcd( a, b ) * b;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
using namespace std;
int main(){
    int w,h,n,nx,ny,mx,my,tot=0;
    cin>>w>>h>>n>>nx>>ny; n--;
    while(n--){
        cin>>mx>>my;
        if((my>ny&&mx>nx)||(my<ny&&mx<nx)){
            tot+=(min(abs(mx-nx),abs(my-ny))+abs(abs(mx-nx)-abs(my-ny)));
        }
        else{
            tot+=(abs(mx-nx)+abs(my-ny));
        }
        nx=mx;ny=my;
    }
    cout<<tot<<endl;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void){
int a,b,c,d,n;
int count;
while(scanf("%d",&n)!=EOF){
count=0;
for(a=0;a<=9;a++){
for(b=0;b<=9;b++){
for(c=0;c<=9;c++){
for(d=0;d<=9;d++){
if(a+b+c+d==n){
count++;
}
}
}

}
}
printf("%d\n",count);}
return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		System.out.println(Math.min(B / A, C));
	}
}

Measured memory_bytes: 21716
N, *rest = $stdin.read.split.map(&:to_i)

class Section < Struct.new(:start, :len, :velo)
  def end
    start + len
  end
end

start = 0

SECTIONS = rest.first(N).zip( rest.last(N) ).map {|t, v| Section.new(start, t, v).tap { start+=t } }
SECTIONS.unshift( Section.new(0, 0, 0) )
total_time = SECTIONS.map(&:len).inject(:+)
SECTIONS.push( Section.new(total_time, 0, 0) )

def min_v(t)
  SECTIONS.map {|s|
    case
    when t <= s.start
      s.velo + (s.start - t)
    when s.start < t && t <= s.end
      s.velo
    else
      s.velo + (t - s.end)
    end
  }.min
end

ans = 0

prev_min_v = min_v(0)
0.step(total_time - 0.5, 0.5) do |t|
  current_min_v = min_v(t+0.5)
#p [prev_min_v,current_min_v]
  ans += 0.5*0.5*(prev_min_v + current_min_v)
  prev_min_v = current_min_v
end

p ans


Measured memory_bytes: 5116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
// priority_queue<int> PQ;

int a[200006];
int cnt[1000006];
int k[1000006];

int main(){
  int n;

  scanf("%d", &n);
  int i,j;
  for(i = 1;i <= 1000000;i++){
    cnt[i] = 0;
    k[i] = 0;
  }

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

  int ans = 0;

  if(cnt[1] >= 2){
    printf("0\n");
    return 0;
  }

  if(cnt[1] == 1){
    printf("1\n");
    return 0;
  }

  for(i = 2;i <= 1000000;i++){
    if(cnt[i] >= 2) k[i] = 0;
  }

  for(i = 2;i <= 1000000;i++){
    if(cnt[i] >= 1){
      for(j = i*2;j <= 1000000;j += i){
        k[j] = 0;
      }
    }
  }

  for(i = 2;i <= 1000000;i++) if(k[i] == 1) ans++;

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

  return 0;
}

Measured memory_bytes: 12348
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
using namespace std;
typedef long long ll;

ll solveDP(vector<ll> v){
    int n = v.size();
    vector<vector<ll>> dp(n, vector<ll>(n));

    for(int i = 0; i < n; i++)
        dp[i][i] = v[i];

    for(int len = 2; len <= n; len++){
        for(int i = 0; i <= n - len; i++){
            int j = i + len - 1;
            dp[i][j] = max((-1 * dp[i][j-1]) + dp[j][j], (-1 * dp[i+1][j]) + dp[i][i]);
        }
    }

    return dp[0][n-1];
}

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

    vector<ll> v(n);

    for(ll & x : v)
        cin>>x;

    // cout<<solverec(v, 0, v.size()-1, 0)<<endl;
    cout<<solveDP(v)<<endl;

    return 0;
}

Measured memory_bytes: 70784
import numpy as np
import heapq

INF=10**15
N,M=map(int,input().split())
adj=[[] for i in range(N)]
for i in range(M):
    L,R,C=map(int,input().split())
    L-=1
    R-=1
    adj[L].append((R,C))
    adj[R].append((L,C))
for i in range(N-1):
    adj[i+1].append((i,0))
    
s=0
g=N-1
heap=[]
table=np.array([INF for i in range(N)])
table[s]=0
heapq.heappush(heap,(table[s],s))
                
while heap:
    q=heapq.heappop(heap)
    a=q[1]
    if q[0]>table[a]: continue
    for ne in adj[a]:
        p=ne[0]
        co=ne[1]
        if table[p]>table[a]+co:
            table[p]=table[a]+co
            heapq.heappush(heap,(table[p],p))
ans=table[g]
if ans==INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 61036
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n; std::bitset<2000 * 2000 + 1> dp(1); long s = 0;
	for(int i = 0; i < n; i++){
		int a; cin >> a; s += a;
		
		dp |= (dp << a);
	}
	
	s = (s + 1) / 2;
	for(int i = s;; i++){
		if(!dp[i]) continue;
		cout << i << endl;
		break;
	}
	return 0;
}


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

int main(int argc, char const *argv[])
{
	int i;
	int a = 0,b = 0,c = 0;
	char S[3];
	scanf("%s",S);

	for(i = 0;i < 3; ++i){
		if(S[i] == 'a')	++a;
		else if(S[i] == 'b')	++b;
		else ++c;
	}
	if(a == 1 && b == 1 && c == 1)	printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    boolean ans=false;

    for (int i=0;i<s.length();i++) {
      if (i%2==0) {
        if (s.charAt(i)=='R'||s.charAt(i)=='U'||s.charAt(i)=='D') {
          ans=true;
        }else{
          ans=false;
          break;
        }
      }else{
        if (s.charAt(i)=='L'||s.charAt(i)=='U'||s.charAt(i)=='D') {
          ans=true;
        }else{
          ans=false;
          break;
        }
      }
    }

    if (ans==true) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    ll N;
    cin >> N;

    ll neck = pow(10,15), tmp;

    rep(i, 5) {
        cin >> tmp;
        neck = min(neck, tmp);
    }

    ll ans = 5;
    if(neck != 1){
        cout << ans + N / neck;
    }
    else {
        cout << ans + N - 1;
    }
    return 0;
}


Measured memory_bytes: 3644
using System;
using System.Linq;

namespace _0325
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = new string[6];
            int[] a = new int[6];
            int[] b = new int[6];
            for (int i = 0; i < 6; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Array.Sort(x);
                s[i] = x[0] + " " + x[1];
                a[i] = x[0];
                b[i] = x[1];
            }
            Array.Sort(s);
            Array.Sort(a);
            Array.Sort(b);
            bool ok = true;
            for (int i = 0; i < 3 && ok; i++)
            {
                if (s[i * 2] != s[i * 2 + 1])
                {
                    ok = false;
                }
            }
            if (a[0] != a[2] || a[4] != b[0] || b[2] != b[4])
            {
                ok = false;
            }
            Console.WriteLine(ok ? "yes" : "no");
            //Console.ReadLine();
        }
    }
}

Measured memory_bytes: 10304
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

const int MAX = 1000000;
int N;

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

    vector<bool> is_prime(MAX,true);
    vector<int> prime(MAX,0);
    is_prime[0] = is_prime[1] = false;
    prime[0] = prime[1] = 0;
    int p = 0;
    for(int i = 2; i < MAX; ++i){
        if(is_prime[i]){
            for(int j = i*2; j < MAX; j += i) is_prime[j] = false;
        }
    }

    for(int i = 1; i < MAX; ++i){
        prime[i] = prime[i-1] + is_prime[i];
    }

    while(cin >> N){
        cout << prime[N] << '\n';
    }
    return 0;
}


Measured memory_bytes: 6600
def reverse(s): 
    return s[::-1] 
  
def countPalindrome(s): 
    count = 0
    rev = reverse(s) 
    for i in range(0,int(len(s)/2)):
      if s[i] != rev[i]:
        count = count + 1
    return count
    


          
s = str(input())
print(countPalindrome(s))

Measured memory_bytes: 3060
n=int(input())
s=input()

r=[[0,0,0] for _ in range(n)]
c=0
l={"GB":0,"BG":0,"RB":1,"BR":1,"RG":2,"GR":2}
for i in range(n):
  if s[i] =="R":
    r[i][0]=r[i-1][0]+1
    r[i][1]=r[i-1][1]
    r[i][2]=r[i-1][2]
  elif s[i]=="G":
    r[i][1]=r[i-1][1]+1
    r[i][0]=r[i-1][0]
    r[i][2]=r[i-1][2]
  elif s[i]=="B":
    r[i][2]=r[i-1][2]+1
    r[i][0]=r[i-1][0]
    r[i][1]=r[i-1][1]

for i in range(n-2):
  for j in range(i+1,n-1):
    if s[i]==s[j]:
      continue
    else:
      c+=r[n-1][l[s[i]+s[j]]]-r[j][l[s[i]+s[j]]]
     # print("p",i,j,c)
      
      if 2*j-i<n:
        if s[2*j-i]!= s[i] and s[2*j-i]!=s[j]:
          c-=1
      #   print("m",i,j,c)
  
print(c)
      

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  
  else if (A + B == C + D) {
   cout << "Balanced" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
}


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

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

# solve
ans = 0
tmp = 0
for i in range(N):
    if S[i] == 'I':
        tmp += 1
    else:
        tmp -= 1
    ans = max(ans, tmp)

# output
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 5050,inf=0x3f3f3f3f;
int n,f[N][N],res;
struct node{
	int p,h;
}a[N];
bool cmp(node a, node b){return a.p+a.h<b.p+b.h;}
int main() {
	read(n);rep(i,1,n)read(a[i].h),read(a[i].p);
	sort(a+1,a+n+1,cmp);
	rep(i,0,n)rep(j,0,n)f[i][j]=inf;f[0][0]=0;
	rep(i,0,n-1)rep(j,0,i)if(f[i][j]<inf){
		umin(f[i+1][j],f[i][j]);
		if(f[i][j]<=a[i+1].h)umin(f[i+1][j+1],f[i][j]+a[i+1].p),umax(res,j+1);
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 99072
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    std::cin >> s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){std::cout << "Bad" << std::endl;}
    else std::cout << "Good" << std::endl;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int k, t;
  cin >> k >> t;

  int maxv = 0;
  rep(i, t) {
    int a; cin >> a;
    chmax(maxv, a - 1 - (k - a));
  }

  cout << maxv << "\n";

  return 0;
}

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

int main(){
//srandom((unsigned long)time(NULL));

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

int ans=0;

for(int i=0;i<2;i++){
    //cout<<"at"<<i<<" "<<ans<<endl;
    if(a>b){
        ans+=a;
        a-=1;
        
    }else{
        ans+=b;
        b-=1;
        
    }
}

cout<<ans<<endl;


return 0;
}

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

int main() {
  int a, b, C;
  double S, L, h, rad;
  cin >> a >> b >> C;
  
  rad = acos(-1)*C / 180;
  S = a*b*sin(rad)/2;
  double c = sqrt(a*a + b*b - 2*a*b*cos(rad));
  L = a+b+c;
  h = b*sin(rad);
  
  printf("%lf\n%lf\n%lf\n", S, L, h);
  
      
}



Measured memory_bytes: 3480
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())

MOD = 10 ** 9 + 7

ALL = pow(10, N, MOD)
ONE = pow(9, N, MOD)
TWO = pow(8, N, MOD)

ans = ALL - ONE - ONE + TWO
ans %= MOD

print(ans)



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

struct UnionFind{

    vector<int> par;
    vector<int> sizes;

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

    int find(int x) { //xの根を得る
        if (x == par[x]) return x;
        return par[x] = find(par[x]); //根を張り替えながら再帰的に根ノードを探す
    }

    void unite(int x, int y) { //xとyの集合を併合
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

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

    int size(int x) {
        return sizes[find(x)];
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;//unionfindは0index
    }
    int ans=0;
    for(int i=0;i<m;i++){
        UnionFind uf(n);
        for(int j=0;j<m;j++){
            if(i!=j){
                uf.unite(a[j],b[j]);
            }
        }
        if(!uf.same(a[i],b[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());
		int c = Integer.parseInt(scan.next());
		int d = Integer.parseInt(scan.next());

		while(true){
			c -=b;
			if(c <= 0){
				System.out.println("Yes");
				break;
			}

			a -=d;
			if(a <= 0){
				System.out.print("No");
				break;
			}
		}

	}

}
//end

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

int main(){
  int N, L;
  cin >> N >> L;
  int taste=0;
  for(int i=1; i<=N; i++){
    taste += L+i-1;
  }
  if(L-1>=0){
    taste -= L;
  }else if(L+N-1<=0){
    taste -= L+N-1;
  }
  cout << taste << endl;
  return 0;
}

Measured memory_bytes: 384
import itertools
N,M=map(int,input().split())
grid = []
for i in range(N):
    array = []
    while len(array) < N:
      array.append(0)
    grid.append(array)
for i in range(M):
    s,t=map(int,input().split())
    grid[s-1][t-1] = 1
    grid[t-1][s-1] = 1
i = 1
lis = []
while i <= N:
  lis.append(i)
  i += 1
ans = 0
for nums in itertools.permutations(lis):
    if nums[0]!=1:
      pass
    else:
      k = 0
      flag = 0
      while k < N-1:
        if grid[nums[k]-1][nums[k+1]-1] == 1:
          pass
        else:
          flag = 1
        k += 1
      if flag == 0:
        ans += 1
print(ans)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

struct UnionFind {
	int s, num; // [0, s) の s 個の要素がある。num は非空集合の個数。
	vector<vector<int>> v;
	vector<int> find;
	
	UnionFind() { s = 0; }
	UnionFind(int s) { init(s); }
	void init(int arg_s) {
		num = s = arg_s;
		v.clear();
		find.clear();
		inc(i, s) { v.PB({i}); find.PB(i); }
	}
	bool unite(int x, int y) {
		assert(inID(x, 0, s) && inID(y, 0, s));
		if(find[x] == find[y]) { return false; }
		num--;
		if(v[find[x]].size() > v[find[y]].size()) { swap(x, y); }
		int fx = find[x];
		for(auto && e: v[fx]) { v[find[y]].PB(e); find[e] = find[y]; }
		v[fx].clear();
		return true;
	}
};

// ----

string s, t;

int main() {
	cin >> s >> t;
	
	UnionFind uf(2 * 26);
	
	inc(i, s.size()) {
		uf.unite(s[i] - 'a', 26 + t[i] - 'a');
	}
	
	int ma = 0;
	inc(i, uf.v.size()) { setmax(ma, static_cast<int>(uf.v[i].size())); }
	
	cout << (ma <= 2 ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 776