akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int h, w;
char tb[2001][2001];

int r[2001][2001];
int r2[2001][2001];

int c[2001][2001];
int c2[2001][2001];

int main() {

	cin >> h >> w;
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> tb[i][j];
		}
	}

	for (int i = 0; i < h; i++) {
		int val = 0;
		for (int j = 0; j < w; j++) {
			if (tb[i][j] == '.')r[i][j]=val;
			if (tb[i][j] == '#')val=j+1;
		}
	}

	for (int i = 0; i < h; i++) {
		int val = w;
		for (int j = w; j>=1; j--) {
			if (tb[i][j-1] == '.')r2[i][j-1]=val;
			if (tb[i][j-1] == '#')val=j-1;
		}
	}

	for (int j = 0; j < w; j++) {
		int val = 0;
		for (int i = 0; i < h; i++) {
			if (tb[i][j] == '.')c[i][j] = val;
			if (tb[i][j] == '#')val = i+1;
		}
	}

	for (int j = 0; j < w; j++) {
		int val = h;
		for (int i = h; i >= 1; i--) {
			if (tb[i-1][j] == '.')c2[i-1][j] = val;
			if (tb[i-1][j] == '#')val = i-1;
		}
	}

	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (tb[i][j] == '.') {
				int tmp = (r2[i][j] - r[i][j])+ (c2[i][j] - c[i][j])-1;

				ans = max(ans, tmp);
			}
		}
	}

	cout << ans << endl;
	return 0;
}

/*
1 7
##.#..#
*/

Measured memory_bytes: 66688
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

vector<int> topological(vector<vector<int>>& g) {
	vector<int> topo;
	int n = g.size();
	vector<int> deg(n);
	for (int i = 0; i < n; i++) for (auto next : g[i]) deg[next]++;
	queue<int> q;
	for (int i = 0; i < n; i++) if (deg[i] == 0) q.push(i), topo.push_back(i);
	while (!q.empty()) {
		int cur = q.front();
		q.pop();
		for (auto next : g[cur]) {
			deg[next]--;
			if (deg[next] == 0) {
				q.emplace(next);
				topo.push_back(next);
			}
		}
	}
	return topo;
}

void solve() {
	int n; cin >> n; if (n == 0) exit(0);
	vector<string> vs(n);
	for (int i = 0; i < n; i++) cin >> vs[i];
	vector<vector<int>> g(26);
	for (int i = 0; i + 1 < n; i++) {
		string& s = vs[i];
		string& t = vs[i + 1];
		bool u = false;
		for (int j = 0; j < min(s.size(), t.size()); j++) {
			if (s[j] != t[j]) {
				g[s[j] - 'a'].emplace_back(t[j] - 'a');
				u = true;
				break;
			}
		}
		if (!u and s.size() > t.size()) {
			cout << "no" << "\n";
			return;
		}
	}

	auto t = topological(g);
	if (t.size() == 26) cout << "yes" << "\n";
	else cout << "no" << "\n";
}

int main()
{

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

	int kkt = 89;
	while (kkt) {
		solve();
	}
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii3(h, w, n); ii2(sr, sc); sr--; sc--;
    string s, t; cin >> s >> t;
    int u = 0, d = h, l = 0, r = w;
    repr(i, n){
        if(t[i]=='U') d = min(d+1, h);
        else if(t[i]=='D') u = max(u-1, 0);
        else if(t[i]=='L') r = min(r+1, w);
        else l = max(l-1, 0);

        if(s[i]=='U') u++;
        else if(s[i]=='D') d--;
        else if(s[i]=='L') l++;
        else r--;

        if(u >= d || l >= r){
            out("NO"); return 0;
        }
    }
    if(u <= sr && sr < d && l <= sc && sc < r){
        out("YES"); return 0;
    }
    out("NO");
}

Measured memory_bytes: 776
def main():
    n = int(input())
    hs = list(map(int, input().split()))

    costs = [0] * n
    costs[0] = 0
    costs[1] = abs(hs[1] - hs[0])
    for i in range(2,n):
        costs[i] = min(costs[i-2] + abs(hs[i] - hs[i-2]), costs[i-1] + abs(hs[i] - hs[i-1]))

    print(costs[-1])
    return

main()

Measured memory_bytes: 13980
#include<bits/stdc++.h>
#define N 35
using namespace std;
typedef pair<int,int> P;
int h,w,s,n[N][N],S,A[N][N];
P memo[N][N][N][N];

int getsum(int u,int d,int l,int r){
  return A[d][r]-A[d][l-1]-A[u-1][r]+A[u-1][l-1];
}

P dfs(int u,int d,int l,int r){
  if(memo[u][d][l][r].first!=-1)return memo[u][d][l][r];
  for(int i=u;i<d;i++){
    if(!(S-getsum(u,i,l,r)<=s&&S-getsum(i+1,d,l,r)<=s))continue;
    P r1=dfs(u,i,l,r),r2=dfs(i+1,d,l,r);
    memo[u][d][l][r]=max(memo[u][d][l][r],P(r1.first+r2.first,min(r1.second,r2.second)));
  }
  for(int i=l;i<r;i++){
    if(!(S-getsum(u,d,l,i)<=s&&S-getsum(u,d,i+1,r)<=s))continue;
    P r1=dfs(u,d,l,i),r2=dfs(u,d,i+1,r);
    memo[u][d][l][r]=max(memo[u][d][l][r],P(r1.first+r2.first,min(r1.second,r2.second)));
  }
  if(memo[u][d][l][r].first==-1)memo[u][d][l][r]=P(1,s-(S-getsum(u,d,l,r)));
  return memo[u][d][l][r];
}

int main(){
  while(1){
    cin>>h>>w>>s;
    if(!h&&!w&&!s)break;
    for(int i=1;i<=h;i++)
      for(int j=1;j<=w;j++)cin>>n[i][j];
    memset(memo,-1,sizeof(memo));
    memset(A,0,sizeof(A));
    for(int i=1;i<=h;i++)
      for(int j=1;j<=w;j++)A[i][j]=A[i][j-1]+n[i][j];
    for(int j=1;j<=w;j++)
      for(int i=2;i<=h;i++)A[i][j]+=A[i-1][j];
    S=A[h][w];
    P ans=dfs(1,h,1,w);
    cout<<ans.first<<' '<<ans.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 12912
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		int firstNumber = Integer.parseInt(line[0]);
		int secoundNumber = Integer.parseInt(line[1]);
		
		int result =0;
		
		int smallerNumber = Math.max(firstNumber, secoundNumber);
		result += smallerNumber;
		if(smallerNumber == firstNumber) {
			firstNumber += -1;
		}else {
			secoundNumber += -1;
		}
		
		int secoundSmaller = Math.max(firstNumber, secoundNumber);
		result += secoundSmaller;
		
		
		System.out.println(result);

		
		
		
	}
}
	
	

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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,sum=0;
    cin>>n;
    vector<int> a(n+2);
    a[0]=0;
    a[n+1]=0;
    for(int i = 1; i <= n; i++)
    {
        cin>>a[i];
    }
    
    for(int i = 0; i <= n; i++)
    {
        sum+=abs(a[i]-a[i+1]);
    }
    
    for(int i = 1; i <= n; i++)
    {
        int tmp = sum -abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
        cout<<tmp<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

signed main(){
  int n;string s;cin>>n>>s;
  rep(i,s.length()){
    s[i] = s[i]+n;
    if(s[i] > 'Z'){
      s[i] -= 26;
    }
  }
  cout << s << endl;
} 


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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;

int main() {


    mp::cpp_int a, b, n;

    cin >> a >> b >> n;

    assert(a >= 0);
    assert(b >= 0);

    mp::cpp_int x = min(n, b - 1);
//    for (mp::cpp_int x = 0; x <= 100; x++) {
    mp::cpp_int now = ((a * x) / b) - a * (x / b);
    assert(now >= 0);
    cout << now << endl;
//    }

}


Measured memory_bytes: 3716
#include<stdio.h>

int main()
{

  int a,b,m,n;
  /*二つの自然数を入力*/
  scanf("%d",&a);
  scanf("%d",&b);
  /*自然数a<bを入れ替えて計算を統一*/
  if(a<b){
    n=a;
    a=b;
    b=n;
  }
  /*ユークリッドの互除法を使う*/
  m=a%b;
  
  while(m!=0){
    a=b;
    b=m;
    m=a%b;}
  /*最大公約数出力*/
  printf("%d\n",b);
  return 0;}



Measured memory_bytes: 2732
s=input()
if s == 'SUN': print(7)
elif s == 'MON': print(6)
elif s == 'TUE': print(5)
elif s == 'WED': print(4)
elif s == 'THU': print(3)
elif s == 'FRI': print(2)
elif s == 'SAT': print(1)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
int main()
{
  int n, t; cin >> n >> t;
  vi a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  
  vii dp1(n+1, vi(t+1, 0));
  vii dp2(n+1, vi(t+1, 0));

  rep1(i,n) {
    rep(j,t) {
      if(j - a[i-1] >= 0) dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-a[i-1]] + b[i-1]);
      else dp1[i][j] = dp1[i-1][j];
    }
  }
  
  rev2(i,n-1,0) {
    rep(j,t) {
      if(j - a[i] >= 0) dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-a[i]] + b[i]);
      else dp2[i][j] = dp2[i+1][j];
    }
  }  

  int res = 0;
  rep(i,n) {
    int tmp = 0;
    rep(j,t) {
      int k = t - j - 1;
      chmax(tmp, dp1[i][j] + dp2[i+1][k]);
    }
    chmax(res, tmp + b[i]);
  }
  cout << res << "\n";
  
  return 0;
}


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



int main() {
  ll n;
  cin>>n;
  vector<P> v(n);
  vector<ll> l;
  vector<ll> r;

ll MAX=0;

  rep(i,n){
    ll a1,b1;
    cin>>a1>>b1;
    v[i]=make_pair(a1,b1);
  //  V.push_back(a1);
  //  V.push_back(b1);
  //  mp1[a1]++;
  //  mp2[b1]++;
    l.push_back(a1);
    r.push_back(b1);
    MAX=max(a1,MAX);
    MAX=max(b1,MAX);

  }
  //sort(V.begin(),V.end());
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  ll minl,minr,minl1,minr1;
    
    if (n%2==1){
        minl=l[(n-1)/2];
       minr=r[(n-1)/2];
        cout<<minr-minl+1;
        return 0;
        
    }
    else{
  
            minl=l[n/2-1];
            minl1=l[n/2];
            minr=r[n/2-1];
            minr1=r[n/2];
        
        
        ll minr2=minr+minr1;
        ll minl2=minl+minl1;
        cout<<minr2-minl2+1;
        return 0;
        }
    

 
  
    

  /*
  ll maxr=MAX;
  ll maxl=0;
  bool check=true;
  ll prev1;
  ll prev2;


  for(auto i=mp1.begin();i!=mp1.end();i++){
    ll now=i->first;
    //右に何個あるか
    //ll idxr=upper_bound(l.begin(),l.end(),now)-l.begin();
    ll idxl=lower_bound(r.begin(),r.end(),now)-r.begin();


    if (n%2==1){
    //  if ((n-idxr)<=((n-1)/2) and idxl<=((n-1)/2)) {
     if (idxl>((n-1)/2)) {
        maxr=now;
        break;
      }
    }
    else if (n%2==0){
      // if ((n-idxr)<=((n-1)/2) and idxl<=((n-1)/2)) {
       if (idxl>(n/2)) {
          maxr=now;
          break;
        }
    }
    prev1=now;
  }

  for(auto i=mp1.begin();i!=mp1.end();i++){
    ll now=i->first;
    //右に何個あるか
    //ll idxr=upper_bound(l.begin(),l.end(),now)-l.begin();
    ll idxl=lower_bound(r.begin(),r.end(),now)-r.begin();


    if (n%2==1){
    //  if ((n-idxr)<=((n-1)/2) and idxl<=((n-1)/2)) {
     if (idxl>((n-1)/2)) {
        maxl=prev2;
        break;
      }
    }
    else if (n%2==0){
      // if ((n-idxr)<=((n-1)/2) and idxl<=((n-1)/2)) {
       if (idxl>(n/2)) {
          maxl=prev2;
          break;
        }
    }
    prev2=now;

  }

  for(auto i=mp2.begin();i!=mp2.end();i++){
    ll now=i->first;
    //右に何個あるか
    ll idxr=upper_bound(l.begin(),l.end(),now)-l.begin();
    //ll idxl=lower_bound(r.begin(),r.end(),now)-r.begin();
    if (n%2==1){
    //  if ((n-idxr)<=((n-1)/2) and idxl<=((n-1)/2)) {
     if (idxr>((n-1)/2)) {
        maxl=now;
        break;
      }
    }
    else if (n%2==0){
      // if ((n-idxr)<=((n-1)/2) and idxl<=((n-1)/2)) {
       if (idxr>(n/2)) {
          maxl=now;
          break;
        }
    }
  }

  ll ans=maxr-maxl;
  cout<<maxr<<' '<<maxl<<endl;
  cout<<ans;
*/

}


Measured memory_bytes: 8212
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  double a;
  int n;
  cin>>n;
  if(n%2==0){
    cout<<0.5<<endl;
  }else{
  a=(n+1)/2;
  cout<<a/n<<endl;
  }
  
}
///////////////////////////

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

for i in range(n):
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)



Measured memory_bytes: 5976
from itertools import permutations

# input
N = int(input())

a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))

all_p = list(permutations(range(1, N + 1, 1)))
print(abs((all_p.index(a) + 1) - (all_p.index(b) + 1)))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long int
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define umpii unordered_map<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define mii map<int,int>
#define pqh priority_queue<int>
#define pql priority_queue<int,vi,greater<int>>
#define setbits(x) __builtin_popcountll(x);
#define zerobits(x)__builtin_ctzll(x);
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
#define mod 1000000007

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, cap;
	cin >> n >> cap;
	int weight[n], val[n];
	for (int i = 0; i < n; i++) {
		cin >> weight[i];
		cin >> val[i];
	}
	int dp[n + 1][cap + 1];
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= cap; j++) {
			if (i == 0 or j == 0)
				dp[i][j] = 0LL;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= cap; j++) {
			if (j >= weight[i - 1]) {
				dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - weight[i - 1]]);

			} else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][cap];

	return 0;
}

Measured memory_bytes: 82432
function main()
    divide = ["dream", "dreamer", "erase", "eraser"]

    S = chomp(readline())

    ans = true
    lenS = length(S)
    while lenS > 0
        is_contains = false
        for i = 1:4
            if length(divide[i]) <= lenS
                if S[lenS - length(divide[i]) + 1:lenS] == divide[i]
                    is_contains = true
                    lenS -= length(divide[i])
                end
            end
        end

        if !is_contains
            ans = false
            break
        end
    end

    if ans
        println("YES")
    else
        println("NO")
    end
end

main()


Measured memory_bytes: 116872
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

constexpr static int MAXN = 50;
constexpr static int MAXA = (1 << 18);

int n, k, S, T;
int a[MAXN], b[MAXN];
int64_t choose[MAXN + 1][MAXN + 1];
int64_t nsubsets[MAXN + 1];

int64_t calc() {
    if ((S | T) != T)
        return 0;

    int m = 0;
    for (int i = 0; i < n; i++)
        if ((a[i] & S) == S && (a[i] | T) == T)
            b[m++] = a[i];

    // for each mask subset, count subsets that have same bits, use PIE
    int64_t total = 0;
    for (int mask = 0; mask < MAXA; mask++) {
        if ((mask | (S ^ T)) != (S ^ T))
            continue;
        map <int, int> cnt;
        for (int i = 0; i < m; i++)
            cnt[b[i] & mask]++;

        int64_t nsame = 0;
        for (auto kv : cnt) {
            // cout << kv.second << " ";
            nsame += nsubsets[kv.second];
        }
        // cout << endl;

        int bits = __builtin_popcount(mask);
        if (bits % 2 == 0)
            total += nsame;
        else
            total -= nsame;
    }
    return total;
}

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

    cin >> n >> k >> S >> T;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    choose[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        choose[i][0] = choose[i][i] = 1;
        for (int j = 1; j < i; j++)
            choose[i][j] = choose[i - 1][j] + choose[i - 1][j - 1];
    }
    for (int i = 1; i <= n; i++) {
        nsubsets[i] = 0;
        for (int j = 1; j <= k && j <= i; j++)
            nsubsets[i] += choose[i][j];
    }

    cout << calc() << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<double,double> dd;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<ii> > vvip;
typedef vector<ii> vii;
typedef map<int,int> mpi;
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define NA -1
#define ALL(v) v.begin(),v.end()
#define mp make_pair
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout<<#a<<" :";FOR(i123,x,y)cout<<setw(4)<<(a)[i123];cout<<endl;}
#define foreach(e, x) for (__typeof(x.begin()) e = x.begin(); e != x.end(); e++) 
#define clr(x) memset(x,0,sizeof(x));
#define sz(x) int((x).size())
#define endl '\n'
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const ld pi = acos(-1);
#define sc(t) scanf("%d",&t)
// vector<string> split(const string &s, char delim) {
//     stringstream ss(s);
//     string item;
//     vector<string> tokens;
//     while (getline(ss, item, delim)) {
//         tokens.push_back(item);
//     }
//     return tokens;
// }
typedef pair<pll,ll> ppll;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
#define re return

int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	//     freopen("output.txt","w",stdout);;
	// #endif
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	while(b--)
	{
		a++;
		if( a==24)
			a=0;
	}cout<<a<<endl;

}


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

int main(){
	string str;
	while(cin >> str,str[0]-'0'){
		int sum=0;
		for(int i=0;i<str.size();i++){
			sum+=str[i]-'0';
		}
		cout <<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

int freq[2][N];

signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int n;
    cin>>n;
    
    int arr[n+50];
    forn(i,1,n){cin>>arr[i];freq[i%2][arr[i]]++;}
    int ans=MOD;
    while(1){int d=0,val=0;
    
    forn(i,1,100050)if(freq[0][i]>d)d=freq[0][i],val=i;
    ans=n/2-d;
    int val1=0,d1=0;
    forn(i,1,100050)if(i!=val)if(freq[1][i]>d1)d1=freq[1][i],val1=i;
    ans+=n/2-d1;
        break;
    }
    
    int ans1;
    int d=0,val=0;
    
    forn(i,1,100050)if(freq[1][i]>d)d=freq[1][i],val=i;
    ans1=n/2-d;
    int val1=0,d1=0;
    forn(i,1,100050)if(i!=val)if(freq[0][i]>d1)d1=freq[0][i],val1=i;
    ans1+=n/2-d1;
    
    
    cout<<min(ans,ans1);




     return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 3840
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N+1,0), B(M+1,0);
    rep(i,1,N+1) cin >> A[i];
    rep(i,1,M+1) cin >> B[i];
    vector<ll> A_sum(N+1), B_sum(M+1);
    ll tmp = 0;
    rep(i,0,N+1) {
        tmp += A[i];
        A_sum[i] = tmp;
    }
    tmp = 0;
    rep(i,0,M+1) {
        tmp += B[i];
        B_sum[i] = tmp;
    }

//    for (auto a : A_sum) cout << a << endl;
//    for (auto b : B_sum) cout << b << endl;


    int ans = 0;
    for (int num_A = 0; num_A <= N; num_A++) {
        if (A_sum[num_A] > K) break;
        int num_B = upper_bound(all(B_sum), K-A_sum[num_A]) - B_sum.begin() - 1;
        ans = num_A + num_B > ans ? num_A + num_B : ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair< int, int >;
 
int main() {
    int N;
    cin >> N;
    int a = N / 10, b = N % 10;
    if (a == 9 or b == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  ll sum = 0;
  rep(i, n){
    int in;
    cin >> in;
    mp[in]++;
    sum += in;
  }
  int q;
  cin >> q;
  rep(_q, q){
    int b, c;
    cin >> b >> c;
    sum -= (ll)b*mp[b];
    sum += (ll)c*mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 8008
#include<bits/stdc++.h>
using namespace std;
#include<string.h>
  int func()
  {
    int i,j,k;
    int a,b,n=0;
    for(i=0;i<5;i++)
    {
      cin >> a;
      if(a==0)
      {
        cout << i+1 ;
        break;
      }
    }
    return 0;
  }
  int main()
  {
  ios::sync_with_stdio(0);
  cin.tie(0);
/*  long long tc;
  cin >> tc;
  while(tc--)
  {
    func();
  }*/
//  int tc;
//  cin >> tc;
//  while(tc--)
  func();
  return 0;
  }


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

int n, k, ans;
vector<int> dist;
vector<vector<int>> G;


void dfs(int v, int p = -1){
    for(auto nv : G[v]){
        if(nv == p) continue;
        dfs(nv, v);
        if(dist[nv] == k-1) if(p != -1) { ans++; continue; }
        if(dist[nv]+1 > dist[v]) dist[v] = dist[nv]+1;
    }
}

int main(){
    cin >> n >> k;
    G.assign(n,vector<int>());
    rep(i,n){
        int a; cin >> a; a--;
        if(i == 0){ if(a != 0) ans++; continue; }
        G[a].push_back(i);
    }
    dist.assign(n,0);
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 15364
N = int(input())
#x = map(int, input().split())
x = list(map(int, input().split()))

#s = float('Inf')
s = float('Inf')
for i in range(min(x), max(x) + 1):
    score = 0
    for j in x:
        score += (j - i)**2 
    s = min(s, score)

print(s)

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

int main(){
  int n; cin >> n;
  int max = 0, max2 = 0, ind; 
  for(int i = 0; i<n;i++){
    int a;
    cin >> a;
    if(max <= a){
      max2 = max;
      ind = i;
      max = a;
    }else if(max2 <= a){
      max2=a;
    }
  }
  for(int i = 0; i < n; i++){
    if(i == ind){
      cout << max2 << endl;
    }else{
      cout << max << endl;
    }
  }
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char map[505][505];
int def[505][505];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
vector<int>to[200005];
ll a[200005];

int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	ll x = 0;
	ll ans;
	ll price = sum;
	for (int i = n - 1; i > 0; i--) {
		x += a[i];
		ans = sum - x;
		price = min(abs(ans-x),price);
	}
	cout << price << endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];

    
    int res = 0;
    while (true) {
      
        if (*max_element(h.begin(), h.end()) == 0) break;
        
      
        int i = 0;
        while (i < N) {
            if (h[i] == 0) ++i; 
            else {
                ++res; 
                while (i < N && h[i] > 0) {
                    --h[i]; 
                    ++i; 
                }
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll getSum(ll BITree[], ll index)
{
    ll sum = 0;
    while (index > 0)
    {
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[], ll n, ll index, ll val)
{
    while (index <= n)
    {
       BITree[index] += val;
       index += index & (-index);
    }
}
ll getInvCount(ll arr[], ll n)
{
    ll invcount = 0;
    ll maxElement = 0;
    for (ll i=0; i<n; i++)
        if (maxElement < arr[i])
            maxElement = arr[i];
    ll BIT[maxElement+2];
    for (ll i=0; i<=maxElement+1; i++)
        BIT[i] = 0;
    for (ll i=n-1; i>=0; i--)
    {
        invcount += getSum(BIT, arr[i]);
        updateBIT(BIT, maxElement, arr[i]+1, 1);
    }
    return invcount;
}

vector< ll > v[5009];
ll a[200009];
main()
{
    string s;
    cin >> s;
    for (ll i = 0; i < s.size(); i++)
        v[s[i]].push_back( i );
    vector< pair < ll , ll > > V;
    ll F=-1;
    ll C=0;
    for (ll i = 'a'; i <= 'z'; i++)
    {
        C += v[i].size() % 2;
        for (ll j = 0; j < v[i].size(); j++)
        {
            if( v[i][j] == v[i][v[i].size()-1-j])
            {
                F=v[i][j];
            }
            else
            if( v[i][j] < v[i][v[i].size()-1-j])
            {
                V.push_back({ v[i][j], v[i][v[i].size()-1-j]});
            }
        }
    }
    if (C > 1)
    {
        cout<< -1 << endl;
        return 0;
    }
    ll t = 0;
     sort(V.begin() , V.end() );
    for (ll i = 0; i < V.size(); i++)
    {
        a[t++] = ( V[i].first );
        swap( V[i].first , V[i].second);
    }
    if (F != -1) a[t++] = ( F );
    reverse( V.begin () , V.end() );
    for (ll i = 0; i < V.size(); i++)
    {
        a[t++] = ( V[i].first );
    }
    cout << getInvCount(a, t) << endl;
}


Measured memory_bytes: 8820
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    int ans = 0;
    rep(i,n+1) {
        if (i%2==1) {
            int cnt = 0;
            repf(j,1,i+1) {
                if (i%j==0) cnt++;
            }
            if (cnt == 8) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);
            int D = int.Parse(input[3]);
            Console.WriteLine(Math.Max(A * B, C * D));
        }
    }
}

Measured memory_bytes: 11092
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static long mod = 998244353;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0;
		
		long res = 0;


		long n = long.Parse(Console.ReadLine());
		long[] d=divisor(n);
		for ( long i = 1; i < d.Length; i++ ) {
			long t = d[i] - 1;
			if ( n / t == n % t ) { res += t; }
		}



			Console.WriteLine(res);


		return;

	}
	static public long[] divisor(long n) {
		List<long> rev = new List<long>();
		long i = 0;
		for ( i = 1; i * i <= n; i++ ) {	//	i^2
			if ( n % i == 0 ) {
				rev.Add(i);
				if ( i != n / i ) {
					rev.Add(n / i);
				}
			}
		}

		long[] re = new long[rev.Count];
		i = 0;
		foreach ( long t in rev ) {
			if ( i % 2 == 0 ) {
				re[i / 2] = t;
			} else {
				re[re.Length - ( i / 2 ) - 1] = t;
			}
			i++;
		}

		return re;
	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;

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


Measured memory_bytes: 256
#include<iostream>
#include<map>

using namespace std;

int data[105]={0};
int main(){
	int x;
	int ma=0;
	while(cin>>x){
		data[x]++;
		ma=max(data[x],ma);
	}
	for(int i=0;i<105;i++){
		if(data[i]==ma)cout<<i<<endl;
	}
	
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long  double
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define mp(p) make_pair(p)
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz(v) ((int)v.size())
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cout << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
const int N  = 105;
ll n, aa[N],bb[N], m, x, y,z,ts,a,b,c,d,t[N][N],q,l,r,k,p,h ;
map<int, int > mii,mii2 ;
map<pair<ll,ll>, ll > mpp ;
bool prime[N];
vector <int> ans ;
vector <int> v;
queue <int> q1,q2 ;
set<int>s ;
stack<int> ss;
int freq[N];
string ch ;
pair<ll  , ll > pl[N] ;
ll res[N];

ll get(ll x){

    //cout<<d<<endl ;

   ll sum = 0 ;
   for(int i = 0 ;i<n ; i++){
      for (int j = 0 ; j< m ; j ++){
            if (t[i][j]>x){
                if (((t[i][j]-x) % d )!= 0 )
                    return 1e9 ;
                sum+=(t[i][j]-x) / d;

            }
            else {
                if (((x-t[i][j])%d )!= 0 )
                    return 1e9 ;
                sum+=(x-t[i][j]) / d ;

            }

        }

   }

   return sum ;
}



int main(){

    FASTIO;
   cin>>n>>m ;
   if (n==1||m==1)
    cout<<1 ; 
    else 
   cout<<(n*m)/2 + (n*m)%2 ;
}


Measured memory_bytes: 256
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const adjLists = Array.from(Array(n), () => []);
  lines.forEach((l, i) => l.split(' ').splice(2).forEach(e => adjLists[i].push(e-1)));

  const d = [], f = [];
  dfs(adjLists, d, f);
  for (let i = 0; i < n; i++) {
    console.log(`${i + 1} ${d[i]} ${f[i]}`);
  }
})();

function dfs(adjLists, d, f) {
  const WHITE = 0, GRAY = 1, BLACK = 2;
  const size = adjLists.length;
  const color = Array.from(adjLists, () => WHITE);

  let time = 0;
  function visit(u) {
    color[u] = GRAY;
    d[u] = ++time;
    adjLists[u].forEach(v => {
      if (color[v] === WHITE) {
        visit(v);
      }
    });
    color[u] = BLACK;
    f[u] = ++time;
  }
  adjLists.forEach((e, u) => {
    if (color[u] === WHITE) visit(u);
  });
}



Measured memory_bytes: 17064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 1e4+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const ull MOD = 16769023;
const ull MOD1 = 1125899839733759;
int n,k;
struct node
{
	ll x,y;
	bool operator<(const node& p)const
	{
		if(x == p.x)
			return y<p.y;
		return x<p.x;
	}
};

node a[maxN];
int get(int p,int q)
{
	set<pll> H;
	for(int i=1;i<=n;i++)
	{
		H.insert(pll(a[i].x,a[i].y));
	}
	int ans = 0;
	while(!H.empty())
	{
		auto it = H.begin();
		int x = it->first;
		int y = it->second;
		ans++;
		while(H.find(pll(x,y)) != H.end())
		{
			H.erase(pll(x,y));
			x += p;
			y += q;
		}
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].x,&a[i].y);
	}
	if(n == 1)
	{
		puts("1");
		return 0;
	}
	sort(a+1,a+1+n);
	int ans = 10000;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++) if (i!=j)
		{
			int p = a[j].x - a[i].x;
			int q = a[j].y - a[i].y;
			
			if(p<0)
			{
				p = -p;
				q = -q;
			}			
			int cnt = get(p,q);
			ans = min(ans,cnt);
		}
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 101

using namespace std;

int main(){
  int n, i, j, k, l, m;
  bool g[MAX][MAX];
  
  for(i=1;i<MAX;++i){
    for(j=1;j<MAX;++j)
      g[i][j] = false;
  }
  
  cin >> n;
  for(i=1;i<=n;++i){
    cin >> k >> l;
    for(j=1;j<=l;++j){
      cin >> m;
      g[k][m] = true;
    }
  }
  
  for(i=1;i<=n;++i){
    for(j=1;j<=n;++j){
      cout << g[i][j];
      if(n != j)cout << " ";
    }
    cout << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 3096
N = gets.to_i
A = gets.split.map(&:to_i)
1.upto(N-1) do |i|
  puts A.join(' ')
  v = A[i]
  j = i-1
  while j >= 0 && A[j] > v
    A[j+1] = A[j]
    j -= 1
  end
  A[j+1] = v
end
puts A.join(' ')



Measured memory_bytes: 6892
n,k=map(int,input().split())
mod=10**9+7


FACT=[1]
for i in range(1,5*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(5*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0
for i in range(min(k+1,n)):
    ANS+=Combi(n-1,n-i-1)*Combi(n,i)
    #print(i,ANS)

print(ANS%mod)

Measured memory_bytes: 83680
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

bool ok(string S) {
    bool ok1 = false;
    bool ok2 = false;
    bool ok3 = false;
    for(char c : S) {
        if(c == '3') ok1 = true;
        if(c == '5') ok2 = true;
        if(c == '7') ok3 = true;
    }
    if(ok1 && ok2 && ok3) return true;
    else return false;
}

int main() {
    int N;
    cin >> N;
    queue<string> que;
    que.push("3");
    que.push("5");
    que.push("7");
    ll ans = 0;
    while(1) {
        string v = que.front();
        que.pop();
        if(stol(v) > N) break;
        if(ok(v)) ans++;
        que.push(v+'3');
        que.push(v+'5');
        que.push(v+'7');
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
	int a, b;
	char op;

	while (true)
	{
		cin >> a >> op >> b;
		if (op == '?') break;
		switch (op)
		{
		case '+':
			cout << a + b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		case '%':
			cout << a % b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

signed main()
{
    int N; cin >> N;
    vi a(N);
    rep(i, N) cin >> a[i];

    int cnt[3] = {};

    rep(i, N) {
        switch (a[i] % 4) {
            case 0: cnt[0]++; break;
            case 2: cnt[1]++; break;
            default: cnt[2]++; break;
        }
    }

    //rep(i, 3) cout << "cnt[" << i << "] = " << cnt[i] << endl;

    cnt[1] %= 2;

    bool f = true;

    f &= cnt[0] + 1 >= cnt[2];
    //cout << "f = " << f << endl;
    cnt[0] -= cnt[2] - 1;

    if (cnt[1] == 1) f &= cnt[0] >= 1;
    //cout << "f = " << f << endl;

    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S = LS2()
N = len(S)

for i in range(N-1):
    if S[i] == S[i+1]:
        print(i+1,i+2)
        exit()
for i in range(N-2):
    if S[i] == S[i+2]:
        print(i+1,i+3)
        exit()
print(-1,-1)

Measured memory_bytes: 69148
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
i = 0
while n > i:
    an = a.pop()
    if x > an:
        x -= an
        ans += 1
    elif x == an:
        x -= an
        ans += 1
        break
    elif x < an:
        x -= an
        break
    i += 1
    if len(a) == 0:
        break
if x > 0:
    ans -= 1
print(ans)


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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

int main()
{
    vector<ll> a(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> a[i];
    }

    sort(all(a));

    println((a[0] + a[1] == a[2] ? "Yes" : "No"));
}


Measured memory_bytes: 3616
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); puts("");}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v;}
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) {cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}

#if (( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

#define pb push_back
#define mp make_pair
#define all(x)  (x).begin(),(x).end()
#define tr(c, it)   for(auto it=c.begin(); it!=c.end(); it++)
#define clr(a, b)   memset(a, b, sizeof(a))

const int INF = 0x3f3f3f3f;

int n;
char s[200010];
LL x;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif

    int cas = 1;
    //scanf("%d", &T);
    while(~scanf("%lld",&x))
    {
        LL ans = x / 11 * 2;
        x %= 11;

        if(x)
        {
            if(x <= 6) ans++;
            else ans += 2;
        }
        printf("%lld\n", ans);





    }

    return 0;
}


Measured memory_bytes: 256