akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0
# 全探索
for i in range(2**N):
    light = 0
    for j in range(M):
        count = 0
        for k in range(1, ks[j][0]+1):
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
        if count % 2 == p[j]:
            light += 1
    if light == M:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

const double EPS=1e-8;
const double INF=1e9;

typedef complex<double>Point;

#define EQ(a,b) (fabs((a)-(b))<EPS)
#define EQV(a,b) (abs((a)-(b))<EPS)
struct Segment{
    Point p1,p2;
    Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};

typedef Segment Line;

struct Circle{
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

typedef vector<Point>Polygon;

double dot(Point a,Point b){
    return real(a)*real(b)+imag(a)*imag(b);
}

double cross(Point a,Point b){
    return real(a)*imag(b)-imag(a)*real(b);
}

bool isOrthogonal(Point a,Point b){
    return EQ(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return EQ(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

bool isParallel(Point a,Point b){
    return EQ(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return EQ(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}


int main(){
    int N;
    scanf("%d",&N);
    while(N--){
        Point a,b,c,d;
        scanf("%lf%lf",&a.real(),&a.imag());
        scanf("%lf%lf",&b.real(),&b.imag());
        scanf("%lf%lf",&c.real(),&c.imag());
        scanf("%lf%lf",&d.real(),&d.imag());
        if(isParallel(Segment(a,b),Segment(c,d)))puts("2");
        else if(isOrthogonal(Segment(a,b),Segment(c,d)))puts("1");
        else puts("0");
    }

    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
template<class T>bool domin(T &a, const T &b){return a>b?a=b,1:0;}
template<class T>bool domax(T &a, const T &b){return a<b?a=b,1:0;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf("%lld",&a);return a;}

int main() {
  int n=gi();
  int mn=MODV, mx=0;
  for(int i=0;i<n;i++){
    int v=gi();
    domin(mn,v);
    domax(mx,v);
  }
  cout<<mx-mn<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>


void bubbleSort(int *,int);
void swap(int *, int *);

int main(){

  int i,j,n,*tmp;

  scanf("%d",&n);
  
  tmp = (int *)malloc( sizeof(int) * n);
  
  for(i = 0;i < n;i++){
    scanf("%d",&tmp[i]);
  }

  bubbleSort(tmp,n);

  free(tmp);

  return 0;

}

void bubbleSort(int *A,int N){
  int i = 0,j,sum = 0;

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

  for(i = 0;i < N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",sum);
}



void swap(int *a, int *b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()

const int N = 8;
const int inf = (1<<20);
char m[N][N];

inline int getval(int c,int j,int bit){
  if      (j == -1)j=0;
  else if (j ==  c)j=c-1;
  return (bit&(1<<j)) != 0;
}

inline int checkij(int r,int c,int i,int j,int bit0,int bit1,int bit2){
  int ret=0;
  int bit=0;
  //bit0
  if (i-1 < 0)bit=bit1;
  else        bit=bit0;
  REP(k,-1,2)ret+=getval(c,j+k,bit);

  //bit1
  bit=bit1;
  REP(k,-1,2)ret+=getval(c,j+k,bit);

  //bit2
  if (i+1 == r)bit=bit1;
  else         bit=bit2;
  REP(k,-1,2)ret+=getval(c,j+k,bit);
  return ret;
}

inline bool isvalid(int r,int c,int now,int bit0,int bit1,int bit2){
  rep(j,c){
    int cnt=checkij(r,c,now-1,j,bit0,bit1,bit2);
    if ((m[now-1][j] == '#'&&cnt>=5) ||
	(m[now-1][j] == '.'&&cnt<5 ));
    else return false;
  }
  return true;
}

int dp[1<<N][1<<N][N];
int dp2[1<<N][1<<N][N];
int bitcount[1<<N];

void solve(int r,int c,int bit0,int bit1,int now){
  if (now == r){
    if (isvalid(r,c,now,bit0,bit1,0)){
      dp[ bit0][bit1][now-1]=bitcount[bit1];
      dp2[bit0][bit1][now-1]=bitcount[bit1];
    }else {
      dp[ bit0][bit1][now-1] =-inf;
      dp2[bit0][bit1][now-1]= inf;
    }
    return;
  }
  int &ret= dp[ bit0][bit1][now-1];
  int &ret2=dp2[bit0][bit1][now-1];
  if (ret == -2*inf ){
    ret=-inf;
    ret2=inf;
    rep(i,(1<<c)){
      if (isvalid(r,c,now,bit0,bit1,i)){
	solve(r,c,bit1,i,now+1);
	if (dp[bit1][i][now] != -inf){
	  ret =max(ret, dp[bit1][i][now]+bitcount[bit1]);
	}
	if (dp2[bit1][i][now] != inf){
	  ret2=min(ret2,dp2[bit1][i][now]+bitcount[bit1]);
	}
      }
    }
  }
  return;
}

main(){
  rep(i,(1<<N))bitcount[i]=__builtin_popcount(i);
  int c,r,tc=1;
  while(cin>>c>>r && r){
    cout <<"Case " << tc++ << ": ";
    rep(i,r)cin>>m[i];
    rep(i,(1<<c)){
      rep(j,(1<<c)){
	rep(k,r){
	  dp[i][j][k]=-2*inf;
	  //dp2[i][j][k]=2*inf;
	}
      }
    }
    int maxi=-2*inf,mini=inf;
    rep(i,(1<<c)){
      solve(r,c,0,i,1);
      if (dp[0][i][0] >= 0)maxi=max(maxi,dp[0][i][0]);
      if (dp2[0][i][0] != inf)mini=min(mini,dp2[0][i][0]);
    }

    if (maxi < 0){
      cout <<"Impossible" << endl;
      continue;
    }else  cout << maxi-mini << endl;
  }
  return false;
}



/*
void test(){
  int bit0=17,bit1=14,bit2=24;
  int r=3,c=5;
  rep(j,c)cout << checkij(r,c,0,j,0,bit0,bit1)<<" ";cout << endl;
  rep(j,c)cout << checkij(r,c,1,j,bit0,bit1,bit2)<<" ";cout << endl;
  rep(j,c)cout << checkij(r,c,2,j,bit1,bit2,0)<<" ";cout << endl;
}

void output(int c,int bit){
  rep(j,c){
    if ((1<<j)&bit) cout <<"#";
    else cout << ".";
  }
  cout << endl;
}

*/

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

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

    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = 0;
    ans += n / (a + b) * a;
    long long t = n % (a + b);
    if (t >= a) {
        ans += a;
    } else {
        ans += t;
    }
    cout << ans << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll L, N;

ll solve(vector<ll> &X){
	vector<ll> S(N+1, 0), T(N+1, 0);
	REP(i, N) S[i+1] = S[i] + X[i];
	REP(i, N) T[i+1] = T[i] + (L-X[N-1-i]);

	ll res = 0;

	for(int t=N;t>=1;t--){
		ll tmp = 0;
		tmp += 2*T[t/2];
		tmp += 2*(S[N-t+(t+1)/2] - S[N-t]);
		if(t%2==0){
			tmp -= (L-X[N-t/2]);
		}else{
			tmp -= X[N/2+(N-t)/2];
		}
		chmax(res, tmp);
	}

	return res;
}

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

    cin >> L >> N;
    vector<ll> X(N), Y(N);
    REP(i, N) cin >> X[i];
    REP(i, N) Y[i] = L - X[N-1-i];

    ll cand1 = solve(X);
    ll cand2 = solve(Y);

    cout << max(cand1, cand2) << endl;

    return 0;
}

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

int main(){
  int i,j;
  int max;
  int n=0; //海を眺められる旅館の数
  
  int N;
  std::cin >> N; //山の数を決定
  
  int H[N];
  for(i=0;i<N;i++){
    std::cin >> H[i];
  }
  
  for(i=0;i<N;i++){
    if(i==0){
      n++; //一番西の旅館は海を眺められる
    }
    else{
      max=H[i];
      for(j=0;j<i;j++){
        if(max<H[j]){
          max=H[j];
        }
      }
      if(max==H[i]){
        n++;
      }
    }
  }
  std::cout << n << std::endl;
}

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

int main() {
  int N;
  cin >> N;
  int sum=0;
  int l=0,r=0;
  for(int i=0;i<N;i++){
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {


  vector<vector<int>> c(3,vector<int> (3));

  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
    cin >> c.at(i).at(j);
    }
  }//入力終了

  bool tak = false;//高橋君

  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      for(int k=0;k<=100;k++){
        int a=c.at(0).at(0),b=c.at(1).at(0),x=c.at(2).at(0);
        int d=c.at(0).at(1),e=c.at(1).at(1),f=c.at(2).at(1);
        int g=c.at(0).at(2),h=c.at(1).at(2),y=c.at(2).at(2);
        
        if((a-i==b-j)&&(b-j==x-k)){
          if((d-i==e-j)&&(e-j==f-k)){
            if((g-i==h-j)&&(h-j==y-k)){
              tak=true;          
            }
          }
        }
      
      }
    } 
  }

  if(tak) cout << "Yes" << endl;
  
  else cout << "No" << endl;
  
  return 0;
}

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

int main() {
    int d;
    cin >> d;
    
    string s = "";
    if (d == 25) {
        s = "Christmas";
    }
    if (d == 24) {
        s = "Christmas Eve";
    }
    if (d == 23) {
        s = "Christmas Eve Eve";
    }
    if (d == 22) {
        s = "Christmas Eve Eve Eve";
    }

    cout << s << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e5+100;

int a[N],cnt[N];

int calc(int x)
{
    return x*(x-1)/2;
}

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

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i],
        cnt[a[i]]++;
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=calc(cnt[i]);
    for(int i=1;i<=n;i++)
        cout<<ans-calc(cnt[a[i]])+calc(cnt[a[i]]-1)<<"\n";
}


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

int main()
{
    bool a[3];

    cin >> a[0] >> a[1] >> a[2];

    if( a[0] == 1 && a[1] == 1 && a[2] == 0 || a[0] == 0 && a[1] == 0 && a[2] == 1 )
        cout << "Open" << endl;
    else
        cout << "Close" << endl;
        
    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int translate(char Head){
	switch(Head){
	case 'R':return 0;
	case 'Y':return 1;
	case 'B':return 2;
	case 'M':return 3;
	case 'G':return 4;
	case 'C':return 5;
	}
	return -1; //must not reach here
}

class Dice{
public:
	Dice(){
		num_of_data = 0;
	};

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isNewPattern(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";

		for(int i = 0; i < num_of_data; i++){
			for(int k = 0; k < 6; k++)number[k] = data_bank[i][k];
			for(int k = 0; k < 24; k++){
				roll(order[k]);
				for(int j = 0; j < 6; j++){
					if(inputed[j] != number[j])
						break;
					if(j == 5)
						return false;
				}
			}
		}
		return true;
	}

	void init(){
		num_of_data = 0;
	}

	int getNumOfData(){
		return num_of_data;
	}

	void addData(int table[6]){
		data_bank[num_of_data][0] = table[0];
		data_bank[num_of_data][1] = table[1];
		data_bank[num_of_data][2] = table[2];
		data_bank[num_of_data][3] = table[3];
		data_bank[num_of_data][4] = table[4];
		data_bank[num_of_data][5] = table[5];
		num_of_data++;
	}

private:

	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}
private:
	int number[6];
	int data_bank[30][6];
	int num_of_data;
};

int main(){
	int n,tmp[6];
	char c1[10],c2[10],c3[10],c4[10],c5[10],c6[10];
	Dice dice;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		dice.init();

		for(int i = 0; i < n; i++){
			scanf("%s %s %s %s %s %s",c1,c2,c3,c4,c5,c6);
			tmp[0] = translate(c1[0]);
			tmp[1] = translate(c2[0]);
			tmp[2] = translate(c3[0]);
			tmp[3] = translate(c4[0]);
			tmp[4] = translate(c5[0]);
			tmp[5] = translate(c6[0]);

			if(dice.isNewPattern(tmp)){
				dice.addData(tmp);
			}
		}
		printf("%d\n",n-dice.getNumOfData());

	}
}


Measured memory_bytes: 2584
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  ll n,T; cin>>n>>T;
  ll sum=0;
  vector<ll> t(n);
  rep(i,n) cin>>t[i];

  rep(i,n-1){
    if(t[i+1]-t[i]<T) sum+=t[i+1]-t[i];
    else sum+=T;
  }
  sum+=T;
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main() {
    int N, L, T, cnt = 0;
    cin >> N >> L >> T;
    vector<int> p(N);
    for(int i = 0; i < N; ++i) {
        int X, W, a, b;
        cin >> X >> W;
        W = pow(-1, W - 1);
        a = W * T;
        b = (X + a) % L;
        p[i] = b < 0 ? b + L : b;
        cnt += a / L;
        a %= L;
        if(X + a >= L || X + a < 0)
            cnt += W;
        cnt %= N;
    }
    sort(p.begin(), p.end());
    cnt = cnt < 0 ? cnt + N : cnt;
    for(int i = cnt; i < N + cnt; ++i)
        cout << p[i % N] << endl;
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main(){
    int n,b,i,c;
    cin>>n;
    i=1;
    char a;
    int S[13]={0};
    int H[13]={0};
    int C[13]={0};
    int D[13]={0};
    while(i<=n){
        cin>>a>>c;
        b=c-1;
        if (a=='H'){
            H[b]=1;
        }
        if (a=='S'){
            S[b]=1;
        }
        if (a=='C'){
            C[b]=1;
        }
        if (a=='D'){
            D[b]=1;
        }
        i+=1;
    }
    for(int x=0;x<13;++x){
        if (S[x]==0) cout<<"S"<<" "<<x+1<<endl;}
    for(int x=0;x<13;++x){
        if (H[x]==0) cout<<"H"<<" "<<x+1<<endl;}
    for(int x=0;x<13;++x){
        if (C[x]==0) cout<<"C"<<" "<<x+1<<endl;}
    for(int x=0;x<13;++x){
        if (D[x]==0) cout<<"D"<<" "<<x+1<<endl;}
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>

using namespace std;

int main(void){
    int N;
    cin >> N;

    string color_info;
    cin >> color_info;

    int slime_count = 1;
    char s = color_info[0];

    for (unsigned int i = 0; i < color_info.length(); i++){
        if (color_info[i] == s) continue;
        slime_count++;
        s = color_info[i];
    }

    cout << slime_count << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n,m;
    cin >> n >> m;
    vector < vector <int> > s(m,vector <int>(0));
    vector <int> p(m);

    rep(i,m){
        int k;
        cin >> k;
        rep(j,k){
            int S;
            cin >> S;
            s[i].push_back(S);
        }
    }
    rep(i,m){
        cin >> p[i];
    }
    
    int ans = 0;

    for(int i=0; i<(1<<n); i++){//スイッチの組
        bitset <10> c(i);
        int lamp = 0;
        for(int j=0; j<m; j++){//電球1つずつ検証
            int cntj = 0;
            
            for(int x:s[j]){
                if(c.test(x-1)) cntj ++;
            }

            if(cntj % 2 == p[j]) lamp ++;
        }        
        if(lamp == m) ans ++;
    }
    cout << ans << endl;
}


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

const int MAXN = 1000;
const long long INF = -1e18;
int N, W;
int w[MAXN];
long long v[MAXN];
long long dp[105][100005];

long long rec(int idx, int weight)
{
    if (weight > W)
    {
        return INF;
    }
    if (dp[idx][weight] != -1)
        return dp[idx][weight];

    if (idx == N)
    {
        if (weight > W)
            return INF;
        return 0;
    }
    dp[idx][weight] = max(rec(idx + 1, weight + w[idx]) + v[idx], rec(idx + 1, weight));
    return dp[idx][weight];
}

int main()
{
    cin >> N >> W;
    for (int i = 0; i < N; i++)
        cin >> w[i] >> v[i];
    for (int i = 0; i < 105; i++)
        for (int j = 0; j < 100005; j++)
            dp[i][j] = -1;
    cout << rec(0, 0) << endl;
    return 0;
}

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

int main() {
  int count =0;
  string str1, str2;
  cin >> str1;
  cin >> str2;
  
for (int i = 0; i <3 ; i++) {
 if(str1.at(i) == str2.at(i)) {
    count = count +1;
 }
}

cout << count << endl;
}


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

int main(){
  complex<double> a1, a2, b1, b2;
  while(cin>>a1.real()>>a1.imag()>>a2.real()>>a2.imag()>>b1.real()>>b1.imag()>>b2.real()>>b2.imag()){
    if(b2.real()<a1.real() || a2.real()<b1.real() || b2.imag()<a1.imag() || a2.imag()<b1.imag())cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
  }
  return 0;
}

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


int main() {
    int n;
    cin>>n;
    map<string,int> s;
    string tmp;
    rep(i,n){
        cin>>tmp;
        s[tmp]++;
    }
    cout<<s.size()<<endl;
    return 0;

}



Measured memory_bytes: 19232
@S=map$|++,@p=@i=0..10**5;$\-=<>;sub f{my$U=pop;$p[$U]=$U-$p[$U]?f($p[$U]):$U}/ />${*a=-$'}||(($u=f$a)-($v=f$`)and$S[$p[$v]=$u]+=$S[$v]),$a=$`for<>;$\+=$S[f${-$_}]for@i;print

Measured memory_bytes: 61184
from math import ceil, log2

n, k = [int(x) for x in input().split()]

ans = 0
p = 1 / n
for i in range(1, n + 1):
    if i < k:
        m = ceil(log2(k / i))
        ans += p * (0.5 ** m)
    else:
        ans += p
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define forn for(int i=0;i<n;i++)
//#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    forn
    cin>>a[i];
    string ans="APPROVED";
    forn
    {
    	if(a[i]%2==0)
    	{
    		if((a[i]%3!=0)&&(a[i]%5!=0))
    		ans="DENIED";
		}
	}
	cout<<ans;
}
 


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

# define MAX_N 100010 // 10^5 + 10

// UnionFindTree
// 使い方(インスタンス名 : tree)
// インスタンス生成 : UnionFind tree;
// tree.init(要素数)
// uniteしたりsameかどうか判定したり

class UnionFind{
    private:
        int par_[MAX_N];
        int rank_[MAX_N];
        int size[MAX_N];
        int groups_;
    
    public:
        void init(int n){ // initializes the tree 
            for(int i=0; i<n; i++){
                par_[i] = i;
                rank_[i] = 0;
                size[i] = 1;
            }
            groups_ = n;
        } 
        int rootOf(int x){ // returns the root of x 
            if(par_[x] == x){
                return x;
            }
            else{
                return par_[x] = rootOf(par_[x]);
            }
        } 
        void unite(int x, int y){ // unites x and y 
            x = rootOf(x);
            y = rootOf(y);
            if(x == y) return;
            if(rank_[x] < rank_[y]){
                par_[x] = y;
                groups_--;
                size[y] += size[x];
            }
            else{
                par_[y] = x;
                groups_--;
                size[x] += size[y];
                if(rank_[x] == rank_[y]) rank_[x]++;
            }
        }
        bool isSameGroupe(int x, int y){ // whether x and y are united
            return rootOf(x) == rootOf(y);
        }
        int countGroups(){ // returns the number of groups
            return groups_;
        }
        // 6 / 19 Updated!! (連結成分のサイズを返す)
        int sizeOf(int x){
            return size[rootOf(x)];
        }
};

int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    vector<ll> c(n);
    UnionFind tree;
    tree.init(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
        tree.unite(i, p[i]);
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }

    // scr[i][j] := i から出発して j回 移動した時のスコア
    ll scr[5050][5050];
    memset(scr, 0, sizeof(scr));

    for(int i = 0; i < n; i++){
        ll now = i;
        for(int j = 0; j <= n; j++){
            if(j-1 >= 0){
                now = p[now];
                scr[i][j] = scr[i][j-1] + c[now];
            }
            else{
                scr[i][j] = 0;
            }
        }
    }

    // ループを調べる
    vector<ll> lp(n); // lp[i] := i が含まれるループのスコアの総和
    for(int i = 0; i < n; i++){
        lp[i] += c[i];
        for(int j = 0; j < n; j++){
            if(i != j && tree.isSameGroupe(i, j)){
                lp[i] += c[j];
            }
        }
    }

    ll ans = ll(-10e11);
    for(int i = 0; i < n; i++){
        ll len = tree.sizeOf(i); // i が含まれるループの長さ

        // あまりの長さで場合分け(なんで、これで、通るの???????????)
        for(int r = 0; r < len; r++){
            if(r > k) continue;
            ll q = (k - r) / len;
            if(r == 0 && q == 0) continue;
            if(lp[i] > 0) ans = max(ans, lp[i] * q + scr[i][r]);
            else if(r > 0) ans = max(ans, scr[i][r]);
        }

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

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

int Go(int *a,int n,int k){
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++) 
     for(int j=i+1;j<n && j<=i+k;j++)
       dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
    return dp[n-1];
}

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  cout<<Go(a,n,k)<<endl;
  return 0;
}

Measured memory_bytes: 3984
N,K = map(int, input().split())
D = {}
for i in range(N):
    a,b = map(int, input().split())
    if a not in D:
        D[a] = b
    else :
        D[a] += b

tmp = 0
for i in sorted(D.keys()):
    tmp += D[i]
    if tmp >= K :
        print(i)
        break

Measured memory_bytes: 10596
N = int(input())
a = [int(i) for i in input().split()]

c = [0] * (10**5 + 1)

for i in a:
    c[i] += 1
    if i != 0 and i != 10 ** 5:
        c[i-1] += 1
        c[i+1] += 1
    elif i == 0:
        c[i+1] += 1
    else:
        c[i-1] += 1

print(max(c))


Measured memory_bytes: 13836
#include <iostream>

 using namespace std;

int main()
{
  int i, h, m, s;
   cin >> i;
   h = i /3600;
   m = i / 60 - h * 60;
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl;

   return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    if (n == i * 108 / 100) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf(":(");
}

Measured memory_bytes: 128
def bingo(line):
    for num in line:
        if not num in b:
            return False
    return True

A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

lines = []
lines.append([A[0][0], A[0][1], A[0][2]])
lines.append([A[1][0], A[1][1], A[1][2]])
lines.append([A[2][0], A[2][1], A[2][2]])

lines.append([A[0][0], A[1][0], A[2][0]])
lines.append([A[0][1], A[1][1], A[2][1]])
lines.append([A[0][2], A[1][2], A[2][2]])

lines.append([A[0][0], A[1][1], A[2][2]])
lines.append([A[0][2], A[1][1], A[2][0]])

for line in lines:
    for num in line:
        if bingo(line):
            print('Yes')
            exit(0)

print('No')
exit(0)

Measured memory_bytes: 3064
#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 long long INF = 1LL<<60;
#define rev(s) (string((s).rbegin(), (s).rend()))


ll dp[110][100010]={0};


int main () {
    int n;

    ll W;

    cin>>n>>W;
    ll w[110];
    ll v[110];



    rep(i,n) {
        cin>>w[i]>>v[i];
    }

    

    rep(i,n) {
        rep(j,W+1) {
            if(j-w[i]>=0) {
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            }
            dp[i+1][j]=max(dp[i][j],dp[i+1][j]);

        }
    }

    cout<<dp[n][W]<<endl;

}

Measured memory_bytes: 79360
dxy = [(1, 0), (0, 1), (-1, 0), (0, -1)]
def rec(maze, visited, locat):
  # ４方向全て試す
  for i in dxy:
    n_locat = (locat[0] + i[0], locat[1] + i[1])
    if 0 <= n_locat[0] < len(maze) and 0 <= n_locat[1] < len(maze[0]):
      if maze[n_locat[0]][n_locat[1]] == '.':
        if visited[n_locat[0]][n_locat[1]] == False:
          global count 
          count += 1
          visited[n_locat[0]][n_locat[1]] = True
          rec(maze, visited, n_locat)
  return count
while(True):
  w, h = map(int, input().split())
  if w == 0 and h == 0:
    break
  maze = [[]for i in range(h)]
  visited = [[False for i in range(w)] for j in range(h)]
  for i in range(h):
    mazel = list(input())
    maze[i] = mazel
  count = 1 # @のいちを予めカウントしておく
  for i in range(h):
    for j in range(w):
      if maze[i][j] == '@':
        s = [i, j]
        break
    else:
      continue
    break
  print(rec(maze, visited, s))


Measured memory_bytes: 6016
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll X; cin >> X;
    ll ans = 0, i = 0;
    while(ans < X) {
        i ++;
        ans += i;
    }
    cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 5000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,K=map(int,input().split())

if N==1:
    print(1)
elif K==1:
    print(pow(2,N-2,mod))
elif K==N:
    dp=[[0 for i in range(K+1)] for j in range(K)]
    imos=[0]*(K+1)

    dp[0][K]=1
    imos[K]=1

    for i in range(1,K):
        for j in range(K-i,K+1):
            if j==K-i:
                dp[i][j]=(imos[K]-imos[j])%mod
            else:
                dp[i][j]=(dp[i-1][j]+imos[K]-imos[j])%mod
        imos=[dp[i][j] for j in range(K+1)]
        for j in range(1,K+1):
            imos[j]+=imos[j-1]
            imos[j]%=mod
    print(dp[N-1][1])
else:
    dp=[[0 for i in range(K+1)] for j in range(K)]
    imos=[0]*(K+1)

    dp[0][K]=1
    imos[K]=1

    for i in range(1,K):
        for j in range(K-i,K+1):
            if j==K-i:
                dp[i][j]=(imos[K]-imos[j])%mod
            else:
                dp[i][j]=(dp[i-1][j]+imos[K]-imos[j])%mod
        imos=[dp[i][j] for j in range(K+1)]
        for j in range(1,K+1):
            imos[j]+=imos[j-1]
            imos[j]%=mod

    ans=0
    for M in range(N-K+1,N+1):
        id=M-N+K
        ans+=dp[K-1][id]*cmb(M-2,N-K-1,mod)

    ans*=pow(2,N-K-1,mod)
    print(ans%mod)

Measured memory_bytes: 107304
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
ll A[201010];
ll sum[201010];
ll xorsum[201010];

int main() {
  cin >> N;
  repe(i, 1, N) {
    cin >> A[i];
    sum[i] = sum[i - 1] + A[i];
    xorsum[i] = xorsum[i - 1] ^ A[i];
  }
  A[N + 1] = INF;
  sum[N + 1] = INF;
  xorsum[N + 1] = INF;

  int r = 1;
  ll ans = 0;
  repe(l, 1, N) {
    r = max(r, l);
    ll ssum = sum[r] - sum[l - 1];
    ll xxorsum = xorsum[r] ^ xorsum[l - 1];
    repe(j, r + 1, N + 1) {
      ssum += A[j];
      xxorsum ^= A[j];
      r = j - 1;
      if (ssum != xxorsum) {
        break;
      }
    }
    ans += r - l + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
	static int cur;
	static String S;
	private static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int k = sc.nextInt();
		for (int l=0; l<k; l++){
			S = sc.next();
			cur = 0;
			int a = parse();
			System.out.println(a);
		}
	}
	static int parse() {
		return expression();
	}
	static int digit(){
		assert(Character.isDigit(S.charAt(cur)));
		int n = S.charAt(cur) -'0';
		cur++;
		return n;
	}
	static int number() {
		int n = digit();
		while ((cur < S.length()) && Character.isDigit(S.charAt(cur)))
			n = n*10 + digit();
		return n;
	}
	static int expression(){
		int sum = term();
		while (S.charAt(cur) != '='){
			if (S.charAt(cur) == '+'){
				cur++;
				sum+=term();
			}
			else if (S.charAt(cur)=='-'){
				cur++;
				sum-=term();
			}
			else break;
		}
		return sum;
	}
	static int factor(){
		if (S.charAt(cur)!='(') return number();
		cur++;
		int n = expression();
		assert(S.charAt(cur)==')');
		cur++;
		return n;
	}
	static int term(){
		int a = factor();
		while (true) {
			if (S.charAt(cur) == '*'){
				cur++;
				a*=factor();
			}
			else if (S.charAt(cur) == '/'){
				cur++;
				a/=factor();
			}
			else break;
		}
		return a;
	}
}

Measured memory_bytes: 26212
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int N, ans;
vector<string> s;
vector<int> ng(100);
map<char, ll> mp;
ll dfs(auto itr, ll bit, ll sum)
{
    if(itr == mp.end()) return sum == 0;
    ll res = 0;
    char ch = itr->first;
    ll k = itr->second;
    itr++;
    for(int i = 0; i <= 9; i++)
    {
        if(i == 0 and ng[ch]) continue;
        if(bit & (1<<i)) continue;
        res += dfs(itr, bit | (1<<i), sum + k * i);
    }
    return res;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N, N)
    {
        ans = 0;
        s.resize(N);
        mp.clear();
        fill(ng.begin(), ng.end(), 0);
        for(int i = 0; i < N; i++)
        {
            string tmp; cin >> tmp;
            s[i] = tmp;
            if(tmp.size() > 1) ng[tmp.front()] = 1;
            ll k = 1;
            for(int j = s[i].size() - 1; j >= 0; j--)
            {
                mp[s[i][j]] += k * (i != N - 1 ? 1 : -1);
                k *= 10;
            }
        }
        auto itr = mp.begin();
        cout << dfs(itr, 0, 0) << endl;
    }
    return 0;
}


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

using namespace std;
const int N = 11;
int n, m, cnt[N], p[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	scanf("%d %d", &n, &m);
	vector<int> v[N];
	for (int i = 0; i < m; ++i) {
		int k;
		scanf("%d", &k);
		while (k--) {
			int s;
			scanf("%d", &s);
			v[i].push_back(s - 1);
		}
	}
	for (int i = 0; i < m; ++i)
		scanf("%d", p + i);
	int res = 0;
	for (int msk = 0; msk < (1 << n); ++msk) {
		memset(cnt, 0, sizeof cnt);
		bool valid = true;
		for (int i = 0; i < m; ++i) {
			for (auto s: v[i]) {
				cnt[i] += (msk & (1 << s)) != 0;
			}
			valid &= cnt[i] % 2 == p[i];
		}
		if (valid)
			++res;
	}
	printf("%d\n", res);
	return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a*b == 2) cout << 3;
  else if(a*b == 3) cout << 2;
  else if(a*b == 6) cout << 1;
  return 0;
}

Measured memory_bytes: 384
H,W = list(map(int,input().split()))

ans = float('inf')
a,b,c = H//3*W,(H-H//3)*(W//2),(H-H//3)*(W-W//2)
ans = min(ans,max(a,b,c)-min(a,b,c))
a,b,c = (H+2)//3*W,(H-(H+2)//3)*(W//2),(H-(H+2)//3)*(W-W//2)
ans = min(ans,max(a,b,c)-min(a,b,c))
a,b,c = W//3*H,(W-W//3)*(H//2),(W-W//3)*(H-H//2)
ans = min(ans,max(a,b,c)-min(a,b,c))
a,b,c = (W+2)//3*H,(W-(W+2)//3)*(H//2),(W-(W+2)//3)*(H-H//2)
ans = min(ans,max(a,b,c)-min(a,b,c))
a,b,c = H//3*W,H//3*W,((H+2)//3)*W
ans = min(ans,max(a,b,c)-min(a,b,c))
a,b,c = W//3*H,W//3*H,((W+2)//3)*H
ans = min(ans,max(a,b,c)-min(a,b,c))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std; 
using namespace __gnu_pbds;
 
typedef long long ll;
typedef double db;
typedef long double ld;
typedef string str;
 
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<str, str> pstr;
 
typedef vector<int> vi; 
typedef vector<ll> vll; 
typedef vector<db> vdb; 
typedef vector<ld> vld;
typedef vector<str> vstr; 
typedef vector<pi> vpi;
typedef vector<pll> vpll; 
typedef vector<pdb> vpdb; 
 
#define fi first
#define se second
#define mp make_pair
#define pf push_front 
#define pb push_back
#define ins insert 
#define eb emplace_back 
#define fbo find_by_order
#define ook order_of_key
#define rsz resize
#define lb lower_bound 
#define ub upper_bound 

#define len(s) (int)s.length()
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))

#define rep(a, b, c) for(int a=b; a<c; a++) 
#define per(a, b, c) for(int a=b; a>c; a--) //do not include boundaries on the right
#define repn(a, b, c) for(int a=b; a<=c; a++) 
#define pern(a, b, c) for(int a=b; a>=c; a--) //include boundaries on the right
 
#define yes cout << "YES"<< "\n" 
#define no cout << "NO" << "\n" 
#define out(x) cout << x << "\n"
#define outs(x) cout << x << " "
#define el cout << "\n"

#define navi ios_base::sync_with_stdio(false); cin.tie(NULL)    
 
const ll mod = 1e9+7;
const double eps = 1e-9;

int main(){
	navi;
	int n, k; cin >> n >> k;
  vi price;
  rep(i,0,n){int x; cin >> x; price.pb(x);}
  srt(price);
  int ans=0;
  rep(j,0,k){ans+=price[j];}
  cout << ans;
}


Measured memory_bytes: 3656
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  int N; cin >> N;
  vector<int> d(N); REP(i, N) cin >> d[i];
  sort(ALL(d));

  int ans = 0;
  REP(K, 110000) {
    int geq = lower_bound(ALL(d), K) - d.begin();
    if (N - geq == geq) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> v(n), a(n), b(n);
  for (int i = 0; i < n; i++) v[i] = i + 1;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];

  int numa = -1, numb = -1, count = 0;
  do {
    bool cana = true, canb = true;
    for (int i = 0; i < n; i++) {
      if (a[i] != v[i]) cana = false;
      if (b[i] != v[i]) canb = false;
    }
    if (cana) numa = count;
    if (canb) numb = count;
    count++;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(numa - numb) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
MOD = 10**9 + 7
N = int(input())
C = [int(input()) for _ in range(N)]

dic = dict()
dp = [None] * N
for i, x in enumerate(C):
    if x in dic:
        dp[i] = dic[x]
    dic[x] = i

dp2 = [0] * N
dp2[0] = 1
for i in range(1, N):
    dp2[i] = dp2[i - 1]
    if dp[i] is not None and i - 1 != dp[i]:
        dp2[i] = (dp2[i] + dp2[dp[i]]) % MOD

print(dp2[-1])


Measured memory_bytes: 36488
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max( {a*c, a*d, b*c,b*d } ) << endl;

}

Measured memory_bytes: 3632
def main():
    R, G, B, N = map(int, input().split())
    ans = 0

    for r in range(N//R + 1):
        for g in range(N//G + 1):

            res = (N - (R*r + G*g)) 

            if res < 0 :
                break

            if res % B == 0:
                ans += 1

    print(ans)

if __name__ == "__main__":
    main()

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


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


int Sint(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 GCD(int a,int b)
{
  int r, tmp;
   /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


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


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,ans=0;
  cin>>n;
  ans+=(n/11)*2;
  if(1<=n%11 && n%11<=6){
    ans++;
  }else if(7<=n%11 && n%11<=10){
    ans+=2;
  }
  cout<<ans<<endl;
}
///////////////////////////



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

int main() {
  int ans = 0;
  string w,t;
  cin >> w;
  while(cin >> t) {
    if(t == "END_OF_TEXT") break;
    rep(i,sz(t)) {
      if('a' <= t[i] && t[i] <= 'z') continue;
      else if('A' <= t[i] && t[i] <= 'Z') t[i] += 32;
    }
    if(t == w) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c;
  cin>>a>>b>>c;
  if(a>c)
    cout<<"NO"<<endl;
  else if(a+b>=c)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;

  
  return(0);
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
c=0
d=[]
for i in range(N):
        if(i+1==a[i]):
            d.append("x")
        else:
            d.append("o")
for i in range(len(d)):
    if d[i]=="x":
        if i==len(d)-1:
            d[i]="o"
            d[i-1]="o"
            c+=1
        else:
            d[i]="o"
            d[i+1]="o"
            c+=1
        
print(c)

Measured memory_bytes: 14008
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int c;
        Point dl = new Point();
        dl.x = 0;
        dl.y = 0;
        Point ur = new Point();
        ur.x = a;
        ur.y = b;

        for (int i = 0; i < n; i++) {
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
            switch (c) {
                case 1: if (dl.x < a) dl.x = a; break;
                case 2: if (ur.x > a) ur.x = a; break;
                case 3: if (dl.y < b) dl.y = b; break;
                case 4: if (ur.y > b) ur.y = b; break;
            }
        }
        if (ur.x >= dl.x && ur.y >= dl.y) {
            System.out.println((ur.x - dl.x) * (ur.y - dl.y));
        } else {
            System.out.println(0);
        }
    }

    static private class Point {
        int x,y;
    }
}


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

using namespace std;

const int N = 200005;

char s[N];
long long cnt[30];

int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  long long ans = 1;
  for (int i = 1; i <= n; ++i) {
    ++cnt[s[i] - 'a'];
    ans += i - cnt[s[i] - 'a'];
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<algorithm>

int main(void){
    int n;
    std::cin >> n;

    std::map<int, int> find_max_i;

    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;

        find_max_i[a-1]++;
        find_max_i[a]++;
        find_max_i[a+1]++;
    }

    int max_i = 0;

    for (auto p : find_max_i) {
        auto value = p.second;
        max_i = std::max(max_i, value);
    }

    std::cout << max_i << std::endl;
    return 0;

}

Measured memory_bytes: 4736
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        if(a%2==0){
            if(a%3>0&&a%5>0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll N,A,B; cin>>N>>A>>B;

    ll res = 0;
    for(ll i = 1; i <= N; ++i) {
        ll sum = 0;
        ll tmp = i;
        while(tmp != 0) {
            sum += tmp % 10;
            tmp /= 10;
        }
        if(A <= sum && sum <= B) {
            res += i;
        }
    }
    cout << res << endl;

    return 0;
}


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

void _130() {
    int n, x;
    int l[100];
    cin >> n >> x;
    for (int i = 0; i < n; ++i) { 
        cin >> l[i];
    }

    int d = 0;
    for (int i = 0; i < n; ++i) {
        d = d + l[i];
        // cout << d << endl;
        if (d > x) {
            cout << i + 1 << endl;
            return;
        }
    }
    cout << n + 1 << endl;
}

void _131() {
    int n, l;
    cin >> n >> l;

    int sum = (l - 1) * n + (1 + n) * n / 2;
    // cout << sum << endl;

    int taste = 0;
    int min_taste = 100;
    for (int i = 0; i < n; ++i) {
        taste = l + (i + 1) - 1;
        // cout << "taste" << taste << endl;
        if (abs(taste) < abs(min_taste))
            min_taste = taste;
        // cout << min_taste << endl;
    }
    cout << sum - min_taste << endl;
}

int main()
{
    _131();
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  cin>>N;
  vector<int> b(N);
  for(int i=0; i<N; i++)
  {
    cin >>b.at(i);
  }
  int t=0;
  int p=0;
  for(int i=0; i<N; i++)
  {
    t++;
    p=b.at(p)-1;
    if(p==1)
    {
      cout<<t<<endl;
      return 0;
    }
  }
  cout <<-1<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  long long N,K,c,H;
  vector<long long> v;
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> H;
    v.push_back(H);
  }
  if(K < N){
    std::sort(v.begin(), v.end() );
    for(int i = 0; i < N - K; i++){
      c += v[i];
    }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 2420