akhauriyash/Code-Regression huggingface dataset:
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){
	int N,i;
	ll sum = 0;
	cin >> N;

	for(i = 1; i <= N; i++)
	{
		if(i%3==0 && i%5==0)
			continue;
		else if(i%3 == 0)
			continue;
		else if(i%5 == 0)
			continue;
		else
			sum = sum + i;
	}

	cout << sum << endl;
    

    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[100], used = 0;
string str[3];
int solve(int sum, int k, int f){
	if(f)sum += a[k+1];
	else sum -= a[k+1];
	if(k == 2 && sum == 7 && used == 0){
		used = 1;
		if(f){str[2] = '+';return 1;}
		else {str[2] = '-';return 1;}
	}
	if(k == 2)return 0;
	int flag = 0, x, y;
	flag = max(flag, solve(sum, k+1, 1));
	flag = max(flag, solve(sum, k+1, 0));
	if(flag){
		if(f)str[k] = '+';
		else str[k] = '-';
		return 1;
	}
	return 0;
}

int main(){
	int v, s = 1000;cin >> v;
	for(int i = 0;i < 4;i++){
		a[i] = v/s;
		v = v%s;
		s/=10;
	}
	int x = 0, y = 0;
	x = max(x, solve(a[0], 0, 1));
	x = max(x, solve(a[0], 0, 0));
	if(x){
		for(int i = 0;i < 3;i++){
			cout << a[i] << str[i];
		}
		cout << a[3] << "=" << 7;
	}
	//for(int i = 0;i < 4;i++)cout << a[i] << " ";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	//0 -> Taro wins, 1-> Jiro wins
	vector<bool> dp(k+1,1);
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i-a[j]>=0 && dp[i-a[j]]==1)
			{
				dp[i]=0;
			}
		}
	}
	if(dp[k]==0)
	{
		cout<<"First\n";
	}
	else
	{
		cout<<"Second\n";
	}
}

int main()
{
	int t;
	t=1;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define l long long
l rec(l n)
{
	if(n==1)
		return 1;
	return 2*rec(n/2)+1;
}
int main()
{
  l n;
  cin>>n;
  l ans=rec(n);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<cassert>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct P
{
  int suit,value;
  P(int suit=inf,int value=inf):suit(suit),value(value){}
  bool operator < (const P& a)const
  { return (suit!=a.suit?suit<a.suit:value<a.value); }
  bool operator == (const P& a)const
  { return suit == a.suit && value == a.value; }
};

typedef vector<P> vP;
typedef vector<vP> vvP;
typedef vector<int> vi;
typedef vector<vi> vvi;
map<vvP,int> mincost;
/*
void print(vector<vP> &vvp)
{
  cout << "print-----" << endl;
  rep(i,vvp.size())
    {
      rep(j,vvp[i].size())
	{
	  if(vvp[i][j] == P(inf,inf))
	    cout << "(x,x) "; 
	  else 
	  cout << "(" << vvp[i][j].suit << "," << vvp[i][j].value << ") ";
	}
      cout << endl;
    }
  cout << endl;
}
*/
bool check(vvP &v)
{
  rep(y,4)
    {
      rep(x,8)
	{
	  if(x == 7)
	    {
	      if(!(v[y][x] == P(inf,inf))) return false;
	      continue;
	    }
	  if(!(v[y][x].suit == y+1 && v[y][x].value == x+1)) return false;
	}
    }
  return true;
}


struct Pox
{
  vvP state;
  int cost;
  vi gap;
  Pox(vvP state,int cost=inf):state(state),cost(cost){ gap.clear(); }
  bool operator < (const Pox& a)const
  { return cost > a.cost; }
};

void bfs(vvP &vec)
{
  priority_queue<Pox> Q;
  Pox poxas7 = Pox(vec,0);

  rep(y,4)rep(x,8)if(vec[y][x] == P(inf,inf))poxas7.gap.push_back(x+y*8);

  Q.push(poxas7);
  mincost.clear();
  mincost[vec] = 0;

  while(!Q.empty())
    {
      Pox pox = Q.top(); Q.pop();

      if(check(pox.state))
	{
	  cout << pox.cost << endl;
	  return;
	}

      int pos[5][8];
      rep(y,4)rep(x,8)if(pox.state[y][x] == P(inf,inf)){}
      else pos[pox.state[y][x].suit][pox.state[y][x].value] = x + y * 8;

      rep(i,4)
	{
	  vi gaps = pox.gap;
	  int x = pox.gap[i] % 8;
	  int y = pox.gap[i] / 8;
	  P p = pox.state[y][x-1];

	  p.value++;
	  if(p.value >= 8)continue;
	  assert(x-1 >= 0);
	  int nx = pos[p.suit][p.value] % 8;
	  int ny = pos[p.suit][p.value] / 8;

	  vvP np = pox.state;
	  swap(np[y][x],np[ny][nx]);

	  Pox npox = Pox(np,pox.cost+1);

	  gaps[i] = nx + ny  * 8;
	  npox.gap = gaps;
	  
	  if(mincost.find(np) == mincost.end())
	    {
	      mincost[np] = pox.cost + 1;
	      Q.push(npox);
	    }		  
	  else if(mincost[np] > pox.cost + 1)
	    {
	      mincost[np] = pox.cost + 1;
	      Q.push(npox);
	    }
	}
    }
  cout << -1 << endl;
}

void compute(vvP &vec)
{
  bfs(vec);
}

int main()
{
  int T;
  while(cin >> T)
    {
      while(T--)
	{
	  mincost.clear();
	  vvP vec(4,vP(8));
	  int ps[5][2];
	  rep(i,4)
	    {
	      rep(j,7)
		{
		  int num;
		  scanf("%d",&num);
		  vec[i][j+1].suit = floor(num/10.0);
		  vec[i][j+1].value = num%10;
		  if(vec[i][j+1].value == 1)
		    {
		      ps[vec[i][j+1].suit][0] = j+1;
		      ps[vec[i][j+1].suit][1] = i;
		    }
		}
	    }
	  
	  REP(i,1,5)
	    {
	      int x = ps[i][0], y = ps[i][1];
	      swap(vec[i-1][0],vec[y][x]);
	    }      
	  
	  compute(vec);
	}
    }
  return 0;
}

Measured memory_bytes: 34260
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <unordered_map>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    string S;
    unordered_map<string, ll> ma;
    cin>>N;
    rep(i,N){
        cin>>S;
        ma[S]++;
    }
    cout<<ma.size()<<endl;
    return 0;
}


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

struct DicCount
{
    bool pFound;
    bool qFound;
    int pDicIndex;
    int qDicIndex;
};

DicCount countDictionaryOrder(vector<int> p_vec, vector<int> q_vec, vector<int> now_going_vec, int n)
{

    if (now_going_vec.size() == n)
    {
        DicCount result_count = {false, false, 1, 1};

        if (p_vec == now_going_vec)
        {
            result_count.pFound = true;
        }

        if (q_vec == now_going_vec)
        {
            result_count.qFound = true;
        }

        return result_count;
    }
    else
    {
        DicCount sum_count = {false, false, 0, 0};

        for (int i = 1; i <= n; ++i)
        {
            auto itr = find(now_going_vec.begin(), now_going_vec.end(), i);
            if (itr == now_going_vec.end())
            {
                vector<int> new_vec(now_going_vec.size());
                copy(now_going_vec.begin(), now_going_vec.end(), new_vec.begin());
                new_vec.push_back(i);

                DicCount deeper_count = countDictionaryOrder(p_vec, q_vec, new_vec, n);

                if (!sum_count.pFound)
                {
                    sum_count.pDicIndex += deeper_count.pDicIndex;

                    if (deeper_count.pFound)
                    {
                        sum_count.pFound = true;
                    }
                }

                if (!sum_count.qFound)
                {
                    sum_count.qDicIndex += deeper_count.qDicIndex;

                    if (deeper_count.qFound)
                    {
                        sum_count.qFound = true;
                    }
                }

                if (sum_count.pFound && sum_count.qFound)
                {
                    break;
                }
            }
        }

        // for (int i = 0; i < now_going_vec.size(); ++i)
        // {
        //     cout << now_going_vec.at(i) << " ";
        // }
        // cout << endl;

        // cout << sum_count.pFound << " " << sum_count.qFound << " " << sum_count.pDicIndex << " " << sum_count.qDicIndex << endl;

        return sum_count;
    }
}

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

    vector<int> pList, qList;
    for (int i = 0; i < 2; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            int input;
            cin >> input;

            if (i == 0)
            {
                pList.push_back(input);
            }
            else
            {
                qList.push_back(input);
            }
        }
    }

    // cout << endl;

    vector<int> newVec(0);
    DicCount dicCount = countDictionaryOrder(pList, qList, newVec, n);

    // cout << "pIndex: " << dicCount.pDicIndex << ", qIndex: " << dicCount.qDicIndex << endl;

    int diff = abs(dicCount.pDicIndex - dicCount.qDicIndex);

    cout << diff << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x, y, xg, yg;
    
    scanf("%d %d", &x, &y);
    
    switch(x){
        case 1 :
        case 3 :
        case 5 :
        case 7 :
        case 8 :
        case 10 :
        case 12 :
            xg = 1;
            break;
        case 4 :
        case 6 :
        case 9 :
        case 11 :
            xg = 2;
            break;
        case 2 :
            xg = 3;
    }
    
    switch(y){
        case 1 :
        case 3 :
        case 5 :
        case 7 :
        case 8 :
        case 10 :
        case 12 :
            yg = 1;
            break;
        case 4 :
        case 6 :
        case 9 :
        case 11 :
            yg = 2;
            break;
        case 2 :
            yg = 3;
    }
    
    if(xg == yg) printf("Yes");
    else         printf("No");
            
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){ 
    char s;
    cin >> s;
    if(s <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
#define st first
#define nd second

using namespace std;

typedef long long ll;

pair <ll,ll> v[200005];
///pozitie,health
queue <pair<ll,ll>> q;
///pozitie,valoare
ll n,d,a;
ll i,c,nr;
pair <ll,ll> p;
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>d>>a;
    for(i=1;i<=n;i++){
        cin>>v[i].st>>v[i].nd;
    }
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++){
        while(!q.empty() && q.front().st<v[i].st){
            c+=q.front().nd;
            q.pop();
        }
        if(v[i].nd-c>0){
            nr+=ceil((v[i].nd-c)*1.0/a);
            q.push({v[i].st+2*d,-(ceil((v[i].nd-c)*1.0/a)*a)});
            c+=ceil((v[i].nd-c)*1.0/a)*a;
        }
    }
    cout<<nr<<'\n';
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    pair<int,int> p[m];
    for(int i=0;i<m;i++){
        int b,c;
        cin>>b>>c;
        p[i]={c,b};
    }
    sort(p,p+m,greater<pair<int,int>>());
    vector<int> v;
    for(int i=0;i<m&&v.size()<n;i++){
        int b=p[i].second;
        int c=p[i].first;
        for(int j=0;j<b&&v.size()<n;j++){
            v.push_back(c);
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        if(i<v.size()&&a[i]<v[i]){
            ans+=v[i];
        }else{
            for(;i<n;i++){
                ans+=a[i];
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2044
while True:
    try:
        a,b,c,d,e,f = (float(x) for x in input().split())
        x = (c * e - b * f) / (a * e - b * d)
        y = (c * d - a * f) / (b * d - a * e)
        
        if x == 0: x = 0
        if y == 0: y = 0
        print(format(x, ".3f"), format(y, ".3f"))
    except EOFError:
        break


Measured memory_bytes: 5588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#define Mo (1000000007)
using namespace std;
const int N=200010;
int sum,ans,tt,tim;
bool w[N];
vector <int> q[N];
int f[N][2],g[N],dep[N],s[N],v[N],head[N],to[N],nxt[N],d[N],a[N*2],fa[20][N],dfn[N],ed[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') ch=getchar(),o=-1;
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void lnk(int x,int y) {
    to[++tt]=y,nxt[tt]=head[x],head[x]=tt;
}
inline void dfs(int x,int d) {
    dep[x]=d,dfn[x]=++tim;
    for(int i=1;i<20;i++) fa[i][x]=fa[i-1][fa[i-1][x]];
    q[d].push_back(x);
    for(int i=head[x];i;i=nxt[i])
	fa[0][to[i]]=x,dfs(to[i],d+1);
    ed[x]=tim;
}
inline int lca(int x,int y) {
    if(x==y) return x;
    if(dep[x]<dep[y]) swap(x,y);
    for(int i=19;~i;i--)
	if(dep[fa[i][x]]>=dep[y]) x=fa[i][x];
    if(x==y) return x;
    for(int i=19;~i;i--)
	if(fa[i][x]^fa[i][y]) x=fa[i][x],y=fa[i][y];
    return fa[0][x];
}
inline int pre(int x) {
    f[x][0]=1,f[x][1]=0;
    if(w[x]) {f[x][1]=1;return 1;}
    int tp=0,sz=0;
    for(int i=head[x];i;i=nxt[i]) sz+=pre(to[i]);
    s[0]=1;
    for(int i=head[x];i;i=nxt[i]) {
	v[++tp]=to[i];
	s[tp]=1LL*s[tp-1]*f[to[i]][0]%Mo;
    }
    for(int i=tp,j=1;i;i--) {
	int y=v[i];
	g[y]=1LL*s[i-1]*j%Mo;
	(f[x][1]+=1LL*f[y][1]*g[y]%Mo)%=Mo;
	j=1LL*j*f[y][0]%Mo;
    }
    f[x][0]=(d[sz]+Mo-f[x][1])%Mo;
    return sz;
}
inline void calc(int x,int res) {
    if(w[x]) {
	(ans+=1LL*d[sum]*res%Mo)%=Mo;
	return;
    }
    for(int i=head[x];i;i=nxt[i])
	calc(to[i],1LL*res*g[to[i]]%Mo);
}
inline bool cmp(const int &x,const int &y) {
    return dfn[x]<dfn[y];
}
int main() {
    int n;
    cin>>n;++n;
    d[0]=1;
    for(int i=1;i<=n;i++) d[i]=2LL*d[i-1]%Mo;
    for(int i=2;i<=n;i++) lnk(gi()+1,i);
    dfs(1,1);
    memset(head,0,sizeof(head));
    for(int t=1;t<=n;t++) {
	if(!q[t].size()) break;
	sum=n-q[t].size();
	int m=0,k,tp=0;
	for(int i=0;i<q[t].size();i++) w[a[++m]=q[t][i]]=1;
	k=m;
	for(int i=1;i<k;i++) a[++m]=lca(a[i],a[i+1]);
	sort(a+1,a+1+m,cmp);
	for(int i=1;i<=m;i++) {
	    if(a[i]==a[i-1]) continue;
	    while(tp&&dfn[a[i]]>ed[v[tp]]) --tp;
	    lnk(v[tp],a[i]),v[++tp]=a[i];
	}
	pre(a[1]),calc(a[1],1);
	for(int i=1;i<=m;i++) head[a[i]]=w[a[i]]=0;
	tt=0;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 46976
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  double pi=3.141592653589;
  char s[100], p[100];
  string scp, s2, chk;
  scanf("%s %s", &s, &p);
  scp=s;
  chk=p;
  s2=scp+scp;
  if(s2.find(p)!= string :: npos){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    string s;
    int score;
    int x;
};
bool cmp(node a,node b){
    if(a.s == b.s){
        return a.score>b.score;
    }
    else{
        return a.s < b.s;
    }
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t;
    cin >> t;
    node a[t+1];
    int name,score;
    for(int cs = 0; cs < t; cs++){
        cin >> a[cs].s >> a[cs].score;
        a[cs].x = cs+1;
    }
    sort(a,a+t,cmp);
    for(int i = 0; i < t; i++){
        cout << a[i].x << endl;
    }
    return 0;
}


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

int main(){
    ll n;
    cin >> n;
    ll a;
    int ans=0;
    rep(i,n){
        cin >> a;
        if(a%2!=0){
            ans=1;
        }
    }

    if(ans==1){

    
    cout << "first" << endl;
    } 
    else{
        cout << "second" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
typedef long long         ll;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
#define pb					push_back
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w	", stdout);
#else
#endif

}
ll v[100007],w[100007],we, n;
ll mem[101][100007];
ll knap(int i, int rem)
{
	if (i == n)
		return 0;
	ll& ret = mem[i][rem];
	if (~ret)return ret;
	ll choice1 = knap(i + 1, rem); // LEAVE
	ll choice2 = 0;

	if (rem>=w[i])
		choice2 = knap(i + 1, rem-w[i])+v[i];

	return ret= max(choice1, choice2);
}
int main()
{
	//GOAT();
	clr(mem, -1);
	cin >> n >> we;
	for (int i = 0; i < n; i++)
		cin >>w[i]>> v[i];
	cout << knap(0,we) << endl;




}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
int n,x,y,ans=1;
int main(){
	cin>>n;
	cin>>y;
	for(int i=1;i<n;i++){
		cin>>x;
		if(x==1){ans++;break;}
		if(x<y){ans++;y=x;}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
//pprockys
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,k,i,j;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for(i=2;i<n;i++)
	{
	    dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
	    j=2;
	    while(j<=k&&i-j>=0)
	    {
	        dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	        j++;
	    }
	}
	cout<<dp[n-1];
}

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

int main() {
  int A, B;
  char op;
  cin >> A;
  cin >> op;
  cin >> B;
  
  int C;
  if (op == '+')
    C = A + B;
  if (op =='-')
    C = A - B;
  cout << C << endl;
}



Measured memory_bytes: 256
import fractions

def lcm(a, b):
    y = a*b / fractions.gcd(a, b)
    return int(y)

A, B, C, D = map(int, input().split())

A -= 1

lcm_cd = lcm(C, D)
a_by_c = A // C
a_by_d = A // D
b_by_c = B // C
b_by_d = B // D
a_by_cd = A // lcm_cd
b_by_cd = B // lcm_cd

toB = B - (b_by_c + b_by_d - b_by_cd)
toA = A - (a_by_c + a_by_d - a_by_cd)

print(toB - toA)

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

d_max = K-A[N-1]+A[0]
sum = d_max

for i in range(N-1):
    d = abs(A[i]-A[i+1])
    d_max = max(d,d_max)
    sum += d

print(sum-d_max)    


Measured memory_bytes: 26420
// chal ab jayda mat udd, agle me niche jaega...

#include <bits/stdc++.h>
using namespace std;

#define rep(i,st,en) for(__typeof(en) i=(st)-(st>en); i!=(en)-(st>en); i+=1-2*(st>en))
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(), v.end()
#define COVID_19 ios_base::sync_with_stdio(0);  cin.tie(NULL);  cout.tie(NULL);
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{cout << *it << " = " << a << endl;    err(++it, args...);}
typedef long long ll;
const ll mod = 1e9+7;

int main() {
    COVID_19
    int n;  cin>>n;
    int x, y;   cin>>x>>y;
    vector<int> adj[n+1];
    rep(i,1,n) {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);
    vector<int> ans(n+1, 0);
    rep(i,1,n) {
        vector<bool> visited(n+1, false);
        vector<int> hei(n+1, 0);
        queue<int> q;
        visited[i] = true;
        q.push(i);
        while(not q.empty()) {
            int v = q.front();
            q.pop();
            for(int u: adj[v]) {
                if (not visited[u]) {
                    hei[u] = hei[v]+1;
                    if(u > i)
                        ans[hei[u]]++;
                    visited[u] = true;
                    q.push(u);
                }
            }
        }
        // rep(i,1,n)
        //     cout<<ans[i]<<' ';
        // cout<<endl;
    }
    rep(i,1,n)
        cout<<ans[i]<<endl;
    return 0;
}

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

int main(){
  int N;
  int A;
  int k;

  cin >> N;
  cin >> A;

  k = N % 500;

  if(A >= k){
    cout << "Yes" << endl;
  }

  if(A < k){
    cout << "No" << endl;
  }
}  


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

int main(){
        int n;
        cin>>n;
        long long int tot1=0, tot2=0, ans1=0, ans2=0;
        for(int i=0; i<n; i++){
                long long int a;
                cin>>a;
                tot1+=a;
                tot2+=a;
                if(i%2==0){
                        if(!(tot1>=1)){
                                ans1+=1-tot1;
                                tot1=1;
                        }
                        if(!(tot2<=-1)){
                                ans2+=tot2-(-1);
                                tot2=-1;
                        }
                }
                else{
                        if(!(tot1<=-1)){
                                ans1+=tot1-(-1);
                                tot1=-1;
                        }
                        if(!(tot2>=1)){
                                ans2+=1-tot2;
                                tot2=1;
                        }
                }
        }
        cout<<min(ans1, ans2)<<endl;
        return 0;
}


Measured memory_bytes: 256
def main():
    from itertools import combinations
    n = int(input())
    ab = [tuple(sorted(list(map(int, input().split())))) for _ in [0]*(n-1)]
    m = int(input())
    uv = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    d = dict()
    for i, (a, b) in enumerate(ab):
        d[(a-1, b-1)] = i

    def tree_path(root, goal):
        d = [-1]*n  # 根からの距離
        d[root] = 0
        q = [root]
        cnt = 0
        while q:  # BFS
            cnt += 1
            qq = []
            while q:
                i = q.pop()
                for j in g[i]:
                    if d[j] == -1:
                        d[j] = cnt
                        qq.append(j)
            q = qq
        now = goal
        path = [goal]
        while True:
            dist = d[now]
            for i in g[now]:
                if d[i] < dist:
                    now = i
                    path.append(i)
                    break
            if dist == 1:
                break
        return path

    seiyaku = [set() for _ in [0]*m]

    for i, (u, v) in enumerate(uv):
        path = tree_path(u-1, v-1)
        for j in range(len(path)-1):
            x, y = min(path[j], path[j+1]), max(path[j], path[j+1])
            seiyaku[i].add(d[(x, y)])

    # print(seiyaku)

    cnt = 2**(n-1)

    for i in range(1, m+1):
        flag = 1
        if i % 2 == 1:
            flag = -1
        cc = combinations(list(range(m)), i)
        # print(list(cc))
        for c in cc:
            # print(c)
            s = set()
            for j in c:
                s |= seiyaku[j]
            cnt += (2**(n-1-len(s)))*flag
            # print((2**(n-1-len(s)))*flag)
    print(cnt)


main()


Measured memory_bytes: 41948
#coding:utf-8
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def binary_search(imin, imax, target):
    n = int(imax - imin + 1)
    if n == 1:
        if S[imin] == target:
            return 1
        else:
            return 0
            
        
    if n % 2 == 0:
        c = int(imin + n/2)
        if target >= S[c]:
            imin = c
            return binary_search(imin, imax, target)

        else:
            imax = c-1
            return binary_search(imin, imax, target)



    else:
        n = (n-1)/2
        c = int(imin + n)
        if target >= S[c]:
            imin = c
            return binary_search(imin, imax, target)

        else:
            imax = c-1
            return binary_search(imin, imax, target)


        

def judge(array, target, imin, imax,c):
    if target >= array[c]:
        imin = c
        return binary_search(imin, imax, target)

    else:
        imax = c-1
        return binary_search(imin, imax, target)



cnt = 0
for target in T:
    cnt += binary_search(0, n-1, target)

print(cnt)




Measured memory_bytes: 16724
#include <stdio.h>

#define H 250

int parent(int i) {return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i + 1;}

int main(){

  int n,i,j,p,r,l;
  int A[H+1];

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&A[i]);

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=n)  printf("left key = %d, ",A[left(i)]);
    if(right(i)<=n) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;

}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<mint> b(100001,1),w(100001,1);
void dfs(vvl &g,ll v,ll par=-1){
    for(auto p:g[v]){
        if(p==par)continue;
        dfs(g,p,v);
        w[v]*=b[p]+w[p];b[v]*=w[p];
    }
}
int main(){
    ll n;cin >> n;
    vvl g(n);
    rep(i,n-1){
        ll a,b;cin >> a >> b;a--;b--;
        g[a].pb(b);g[b].pb(a);
    }
    dfs(g,0);
    cout << b[0]+w[0] <<endl;
}

Measured memory_bytes: 17012
n = int(input())
a = [int(i) for i in input().split(" ")]

def a_i(p):
    global a
    if p < 0:
        return 0
    elif n <= p:
        return 0
    return a[p]

s = abs(a[0])
for i in range(1, n):
    s += abs(a[i] - a[i - 1])
s += abs(a[n - 1])

for i in range(0, n):
    p = a_i(i - 1) - a[i]
    q = a[i] - a_i(i + 1)
    m = p * q
    if m < 0:
        print(s - 2 * min(abs(p), abs(q)))
    else:
        print(s)

Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, C;
    cin >> N >> M >> C;
  
vector<int> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
   }
  
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
   }
  
  int count = 0;

    
  for (int i = 0; i < N; i++){
    int sum = 0;
    for (int j = 0; j < M; j++) {
      sum += A.at(i).at(j) * B.at(j);
    }
    if(sum + C > 0){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
let rec list_init n f = if n <= 0 then [] else let x = f () in x :: list_init (n-1) f
let rec remove x = function [] -> [] | (y::ys') -> if x = y then ys' else y :: remove x ys'
let step (acc, zs) (x,y) =
  match List.filter (fun (a,b) -> a < x && b < y) zs with
  | []     -> (acc,   zs)
  | (z::_) -> (acc+1, remove z zs)
let () =
  Scanf.scanf "%d" (fun n ->
  let a = list_init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> x, y))
  |> List.sort (fun (_,b) (_,d) -> d - b) in
  list_init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> x, y))
  |> List.sort compare |> List.fold_left step (0, a)) |> fst |> Printf.printf "%d\n"


Measured memory_bytes: 640
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<int,int> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	vector<int> a;
	int x,y,z,ans;
	cin>>x>>y>>z;
	a.push_back(x);
	a.push_back(y);
	a.push_back(z);
	sort(a.begin(),a.end());
	ans=a[2]*10+a[1]+a[0];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;} //最小公倍数

//-------------------------------------------------
//
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
//




//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s ;
  cin >> s ;
  if(s=="AAA" || s=="BBB"){
    no() ;
  }
  else{
    yes() ;
  }
  
  
  
  return 0 ;
}




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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

void solve () {
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
  #endif
	int t = 1;
	while (t--) {
		solve();
	}
 	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <ios>
#include <sstream>
#include <cstdio>

#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <regex>
#include <utility>
#include <random>

#include <cstddef>
#include <cstdint>
#include <cfloat>
#include <limits>

#include <array>
#include <bitset>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <valarray>
#include <vector>
#include <deque>
#include <forward_list>

#define FOR(i, a, b) for(auto i{a}; i < (b); ++i)
#define RFOR(i, a, b) for(auto i{(b)-1};i >= (a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) std::begin(a), std::end(a)
#define EACH(x, xs) for (auto &x : xs)
#define CAST static_cast

template<typename T>
constexpr bool in_range(T const &l, T const &a, T const &u){ return l < a && a < u; };
constexpr double inf {std::numeric_limits<double>::infinity()};

#define FAST_TYPE
#ifdef FAST_TYPE
using i32 = std::int_fast32_t;  using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t;
#else
using i32 = std::int_least32_t;  using i64 = std::int_least64_t;
using u32 = std::uint_least32_t; using u64 = std::uint_least64_t;
#endif

using imx = std::intmax_t;
using umx = std::uintmax_t;

using namespace std;

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

  i32 X, A;

  cin >> X >> A;

  if (X < A)
    cout << 0 << endl;
  else
    cout << 10 << endl;;

  return 0;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    dp = [[0] * N for _ in range(N+1)]
    dp[1][0] = 1
    for i in range(M):
        dp_new = [[0] * N for _ in range(N+1)]
        for j in range(N+1):
            for k in range(N):
                dp_new[j][k] = (dp_new[j][k] + dp[j][k] * k)%mod
                if k+1 < N:
                    dp_new[j][k+1] = (dp_new[j][k+1] + dp[j][k] * (N - j - k))%mod
                if j+k <= N:
                    dp_new[j+k][0] = (dp_new[j+k][0] + dp[j][k] * j)%mod
        dp = dp_new
    print(dp[N][0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 94660
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let mut i = 0;
    let mut flag = true;
    for c in s.chars() {
        if i % 2 == 0 {
            if c == 'L' {
                flag = false;
                break;
            }
        } else {
            if c == 'R' {
                flag = false;
                break;
            }
        }
        i += 1;
    }
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
vector<int> values, costs;
int n, aux, mx, res;
void bt(int m, int val) {
	if(m == n) {
		mx = max(mx, val);
		return;
	}
	int tmp = values[m] - costs[m];
	if(tmp > 0)	bt(m + 1, val + tmp);
	else	bt(m + 1,  val);
	return;
}
int main() {
	cin>>n;
	for(int i = 0; i < n; i++) {
		cin>>aux;
		values.push_back(aux);
	}
	for(int i = 0; i < n; i++) {
		cin>>aux;
		costs.push_back(aux);
	}
	bt(0, 0);
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    ll a[1000] = {0};
    REP(i,m){
        ll inp;
        cin >> inp;
        a[inp+500] = 1;
        //cout << inp+500 << endl;
    }
    ll ans;
    ll up = 0;
    ll down = 0;
    REP(i,n+5){
        up += a[i+x+500];
        //cout << i+x+501 << " : " << up << endl;
        down += a[x+500-i];
        //cout << x+501-i << " : " << down <<endl;
        ans =min(up,down);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>

intmax_t f(intmax_t n) {
  // 1 ^ 2 ^ ... ^ n
  intmax_t res = 0;
  if (n % 4 == 1 || n % 4 == 2) res |= 1;
  for (intmax_t i = 2; i <= n; i <<= 1) {
    intmax_t rem = n % (i << 1);
    if (rem < i) continue;
    if (rem % 2 == 0) res |= i;
  }
  return res;
}

int main() {
  intmax_t A, B;
  scanf("%jd %jd", &A, &B);

  intmax_t fB = f(B);
  intmax_t fA = f(A);
  intmax_t res = fB ^ fA ^ A;
  printf("%jd\n", res);
}


Measured memory_bytes: 128
n, m = map(int, input().split())
H = list(map(int, input().split()))

T = [1 for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if H[a] < H[b]:
        T[a] = 0
    elif H[a] > H[b]:
        T[b] = 0
    else:
        T[a], T[b] = 0, 0

print(T.count(1))


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

int main()
{
    int  S;
    cin >> S;
    int h, m, s;
    s = S % 60;
    m = (S / 60) % 60;
    h = (S / 60 / 60) % 60;
    
    cout << h << ":"<< m << ":" << s <<  "\n";

}


Measured memory_bytes: 3104
N = gets.to_i

says = []

N.times do
  a = gets.to_i

  words = []

  a.times do
    person, truth = gets.split.map(&:to_i)

    words << [person - 1, truth]
  end

  says << words
end

ans = 0

0.upto(2 ** N - 1) do |mask|
  success = true

  N.times do |n|
    next if mask[n] == 0

    words = says[n]

    words.each do |person, truth|
      if truth == 1
        if mask[person] == 0
          success = false
        end
      else
        if mask[person] == 1
          success = false
        end
      end
    end

    break unless success
  end

  if success
    ans = [ans, mask.to_s(2).count('1')].max
  end
end

puts ans


Measured memory_bytes: 1788
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()

	for i:= 1; i<=9; i++ {
		if n % i == 0 && n/i >=1 && n / i <= 9 {
			fmt.Printf("Yes")
			return
		}
	}
	fmt.Printf("No")
	return
}


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

#define deb(x) cout << #x << "=" << x << endl;
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fo1(i, n) for (ll i = 1; i <= n; i++)i
#define sn(x) cin >> x;
#define pn(x) cout << x << "\n"
#define ps(x) cout << x << " ";
#define pb() cout << "\n";
#define sort(x) sort(x.begin(), x.end())

using namespace std;


typedef long long ll;
ll INF = INT_MAX;



void solve()
{

    ll n;
    cin >> n;
    vector<ll>v(n),dp(n);

fo(i,n){
    cin>>v[i];
    dp[i]=INF;
}
   
dp[0]=0;
dp[1]=abs(v[1]-v[0]);

for(ll i=2;i<n;i++){
    for(ll j=1;j<=2;j++){
           dp[i]= min(dp[i],abs(v[i-j]-v[i])+dp[i-j]);
       } 
   }

    cout << dp[n-1] << endl;

}

int main()
{

#ifndef ONLINE_JUDGE
   freopen("a.in", "r", stdin);
    freopen("err.txt", "w", stderr);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll test = 1;
    //cin >> test;
    while (test--)
    {
        ll n;

        solve();
    }
}


Measured memory_bytes: 4748
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int Number = sc.nextInt();
    int count=0;
    int valLen =0;
    for(int i=1; i<=Number;i++){
      valLen= String.valueOf( i ).length();
    	if(valLen%2==1){
        count++;
        }
    }System.out.println(count);
  }
}



Measured memory_bytes: 28244
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define TR(it,c) for( typeof(c.begin()) it = c.begin(); it != c.end(); ++it )
#define TRR(it,c) for( typeof(c.rbegin()) it = c.rbegin(); it != c.rend(); ++it
#define REP(i,a) for (int i = 0; i < (a); i++)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)

#define DRI(a) int a; scanf("%d", &a);
#define DRII(a, b) int a, b; scanf("%d %d", &a, &b);
#define DRIII(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c);
#define RI(a) scanf("%d", &a);
#define RII(a, b) scanf("%d %d", &a, &b);
#define RIII(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define MM(arr, num) memset((arr), (num), sizeof((arr)))
#define DEB(x) cerr << ">>> " << (#x) << " -> " << (x) << endl;
#define DEBA(x,n) cerr << (#x) << " "; deba((x),(n));
void deba(int * a, int n){ cerr << "| "; REP(i,n) cerr << a[i] << " "; cerr << "|" << endl;}


inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<30;
typedef long long ll;
typedef unsigned long long ull;
/*******************************************************/

vi gn[223456];
vi gm[223456];

int vis[223456];
int vis2[223456];

pair<int, int> p[223456];
map< pair<int,int>, int > mp;

void dfs(int name, int u){
        REP(i, gn[u].size()){
            if ( !vis[gn[u][i]] ){ vis[gn[u][i]] = 1; p[gn[u][i]] = MP( name, 0 ); dfs( name, gn[u][i] ); }
        }
}

void dfs2( int name, int u){
        REP(i, gm[u].size() ){
            if ( !vis2[gm[u][i]] ){ vis2[gm[u][i]] = 1; p[gm[u][i]] = MP(  p[gm[u][i]].ff, name ); dfs2( name, gm[u][i] ); }
        }
    }

int main() {

  DRIII(n,k,l);

  REP(i,k){ DRII(x,y);   gn[x].PB(y); gn[y].PB(x); }
  REP(i,l){ DRII(x,y);   gm[x].PB(y); gm[y].PB(x); }

  FOR(i,1,n){
  if(vis[i] == 0){vis[i] = 1;
  p[i] = MP( i, 0 );
  dfs(i,i);}
  }

  FOR(i,1,n){
  if(vis2[i]== 0){vis2[i] = 1;
  p[i] = MP(  p[i].ff, i );
  dfs2(i,i);}
  }
  FOR(i,1,n){
    mp[p[i]]++;
    //cout << p[i].ff << " " <<  p[i].ss << endl;
  }

  FOR(i,1,n){
    cout << mp[p[i]] << " ";
  }
  cout <<endl;

  return 0;
}


Measured memory_bytes: 30592
N = str(input())
hon = ["2","4","5","7","9"]
pon = ["0","1","6","8"]
bon = ["3"]
if N[len(N)-1] in hon:
  print("hon")
elif N[len(N)-1] in pon:
  print("pon")
elif N[len(N)-1] in bon:
  print("bon")

Measured memory_bytes: 9028
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

void solve()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>> grid(H, vector<int>(W, 0));
	rep(i, H)
	{
		rep(j, W)
		{
			char t;
			cin >> t;
			if (t == '1')
				grid[i][j] = 1;
		}
	}
	/*rep(i, H)
	{
		rep(j, W)
		{
			cout << grid[i][j];
		}
		cout << endl;
	}*/

	int ans = 1e9;
	rep(i, pow(2, H - 1) + 1)
	{
		vector<int> border;
		rep(j, H - 1)
		{
			if (i & (1 << j))
			{
				border.push_back(j + 1);
			}
		}

		border.push_back(H);
		int bor_size = border.size();
		int cnt = bor_size - 1;

		vector<int> block(bor_size);
		vector<int> bb(bor_size);
		rep(j, W)
		{
			int bef = 0;
			bool next = false;
			rep(k, bor_size)
			{
				bb[k] = block[k];
				FOR(l, bef, border[k])
				{
					if (grid[l][j])
					{
						block[k]++;
					}
				}
				bef = border[k];
				if (block[k] > K)
				{
					next = true;
				}
			}
			if (next)
			{
				cnt++;
				rep(k, bor_size)
				{
					block[k] -= bb[k];
				}
			}
			if(next&&bef==H){
				rep(k,bor_size){
					if(block[k]>K){
						cnt=1e9;
					}
				}
			}
		}
		//cout<<cnt<<endl;
		ans = min(ans, cnt);

	}
	cout << ans << endl;
}

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


Measured memory_bytes: 256
N = int(input())
points = []
for i in range(N):
    x, y = map(int, input().split())
    points.append((x, y))

import itertools
totalDist = 0
totalSum = 0
for perm in itertools.permutations(list(range(N))):
    curLength = 0
    for i in range(1, N):
        curLength += ((points[perm[i]][0] - points[perm[i - 1]][0]) ** 2 + (points[perm[i]][1] - points[perm[i - 1]][1]) ** 2) ** 0.5
    totalDist += curLength
    totalSum += 1
print(totalDist/totalSum)


Measured memory_bytes: 42604