akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : v )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

const ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

int main()
{
	ll M, K;
	cin >> M >> K;

	ll n = pow( 2, M );

	if ( K >= n ) // K>=2^Mのとき
	{
		cout << "-1" << endl;	//	数列aは作れない
	}
	else if ( M == 1 )
	{
		if ( K == 0 )
		{
			cout << "0 0 1 1" << endl;
		}
		else
		{
			cout << "-1" << endl;	//	数列aは作れない
		}
	}
	else
	{
		// 数列aは、0,1,...,2^M,K,2^M,2^M-1....1,0,Kとする
		rep( i, n )
		{
			if ( i != K )
			{
				cout << i << " ";
			}
		}
		cout << K << " ";

		rrep( i, n )
		{
			if ( i != K )
			{
				cout << i << " ";
			}
		}
		cout << K << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define cy cout << "YES" << endl;
#define cn cout << "NO" << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{

    long long a,b,c,d,e;
    cin >> a;
     map<long long,long long>mp;
    vector<long long>vec;
    while(a--)
    {
        cin >> b;
        mp[b]++;
    }

    for(auto it=mp.begin();it!=mp.end();it++){
        if(it->second>=4)
        {
            vec.push_back(it->first);
            vec.push_back(it->first);
        }
        if(it->second>=2)

        {
            vec.push_back(it->first);
        }

    }
    sort(vec.begin(),vec.end());
    if(vec.size()>1)
    {
        long long x=vec[vec.size()-1]*vec[vec.size()-2];
        cout << x << endl;

    }
    else{
        cout << 0 << endl;
    }


}

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

int main()
{
    int n,m,l,r,a,b,i;
    cin>>n>>m;
    a=0,b=n+1;
    for(i=0;i<m;i++)
    {
        cin>>l>>r;
        a=max(a,l);
        b=min(b,r);
    }
    if(b>=a)
        cout<<b-a+1<<endl;
    else
        cout<<0<<endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  int cnt = 0;
  int mx = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b)
      cnt++;
    else
      cnt = 0;
    chmax(mx, cnt);
  }
  if (mx >= 3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;  //このネームスペースを使う

int main(){
  int N,D ;
  int range ;
  
  int i;

  cin >> N >> D;

  range = 2*D+1; //監視員一人が監視できる範囲

  for(i=1;i<=N;i++){
    if(range * i >= N){
      cout << i << endl ;
      break;
    }
  }
  return 0;
}



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

typedef long long ll;
const int N = 100054, M = N * 2;

struct edge {
	int u, v, w;
	edge (int u0 = 0, int v0 = 0, int w0 = 0) : u(u0), v(v0), w(w0) {}
} e[M];

int n, E = 0;
int first[N], next[M];
int p[N], size[N];
int cG = 0, G[3];
ll ans = 0;

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline void down(int &x, const int y) {x > y ? x = y : 0;}
inline int min(const int x, const int y) {return x < y ? x : y;}

inline void addedge(int u, int v, int w) {
	e[++E] = edge(u, v, w), next[E] = first[u], first[u] = E;
	e[++E] = edge(v, u, w), next[E] = first[v], first[v] = E;
}

void dfs(int x) {
	int i, y, max = 0; size[x] = 1;
	for (i = first[x]; i; i = next[i])
		if ((i - 1) ^ (p[x] - 1) ^ 1)
			p[y = e[i].v] = i, dfs(y), size[x] += size[y], up(max, size[y]),
			ans += (ll)e[i].w * min(size[y], n - size[y]);
	if (up(max, n - size[x]), max <= n / 2) G[cG++] = x;
}

int main() {
	int i, u, v, w, mn = INT_MAX;
	scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d%d", &u, &v, &w), addedge(u, v, w);
	dfs(1);
	if (cG == 1) for (i = first[*G]; i; i = next[i]) down(mn, e[i].w);
	else assert(cG == 2), mn = e[p[*G]].w;
	printf("%lld\n", ans * 2 - mn);
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];
    int ans = 0;
    rep(i, 0, n - 2){
        int MAX = max({p[i], p[i + 1], p[i + 2]});
        int MIN = min({p[i], p[i + 1], p[i + 2]});
        if(p[i + 1] != MAX && p[i + 1] != MIN) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int a,b;

		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();
		b = sc.nextInt();

		int count = 0;
		int totalTapCnt = 1;

		while (totalTapCnt < b) {
			totalTapCnt += a - 1;
			++count;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 23636
#include <iostream>

int main()
{
  int K, S;
  std::cin >> K >> S;
  
  int ans = 0;

  for ( int x = 0; x <= K; x++ ) {
    for ( int y = 0; y <= K; y++ ) {
      int max_z = S - (x+y);
      if (max_z >= 0 && max_z <= K) {
        ans++;
      }
    }
  }

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


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
      
    	Scanner sc = new Scanner(System.in);
      
      	int a = sc.nextInt();
        int b = sc.nextInt();
      
      	int x = (a + b)/2;
      
        if ((a+b)%2==0){
          System.out.println((a+b)/2);
        } else {
          System.out.println((a+b+1)/2);
        }
    }
}

Measured memory_bytes: 23892
#import math
#from functools import reduce
from fractions import gcd
#from functools import lru_cache


#def lcm_base(x, y):
#    return (x * y) // gcd(x, y)

#def lcm(numbers):
#    return reduce(lcm_base, numbers, 1)


def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


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

t_lcm = lcm(A)
count = 0
for i in A:
    count += t_lcm//i
    
print(count%(10**9+7))


Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    ll ary[60][2];
    rep(i,60) rep(j,2) ary[i][j] = 0;
    rep(i,n)
    {
        ll a;
        cin >> a;
        rep(j,60)
        {
            ll b = 1;
            b = b << j;
            if (a & b)
            {
                ary[j][1]++;
                // cout << i << " " << a << " " << b << " " << j << endl;
            }
            else
            {
                ary[j][0]++;
            }
        }
    }

    // rep(i,60)
    // {
    //     if (ary[i][1]!=0)
    //     {
    //         cout << i << " " << ary[i][0] << " " << ary[i][1] << endl;
    //     }
    // }


    ll ans = 0;
    rep(i,60)
    {
        ll tmpnum = ary[i][0] * ary[i][1];
        tmpnum %= MOD;
        ll c = 1;
        c = c << i;
        c %= MOD;
        tmpnum *= c;
        tmpnum %= MOD;
        ans += tmpnum;
        ans %= MOD;
    }
    cout << ans << endl;
    
}




Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long X=sc.nextLong();
		long t=sc.nextLong();
		System.out.println(Math.max(0, X-t));
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>

int main(){
	char str[1201];
	char komoji[27]="abcdefghijklmnopqrstuvwxyz";
	char oomoji[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int mojisuu,i,j;
	
	fgets(str,sizeof(str),stdin);
	mojisuu=(int)strlen(str);
	
	for(i=0;i<mojisuu;i++){
		for(j=0;j<26;j++){
			if(str[i]==komoji[j]){
				str[i]=oomoji[j];
				break;
			}else if(str[i]==oomoji[j]){
				str[i]=komoji[j];
				break;
			}
			
		}
		printf("%c",str[i]);
	}
	
	//printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,q;
vector<int>edge[200005];
ll x[200005];
void dfs(int v,int u){
	if(u != -1) x[v] += x[u];
	rep(i,edge[v].size()){
		if(edge[v][i] == u) continue;
		dfs(edge[v][i],v);
	}
}
int main(){
	cin>>n>>q;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);
		edge[a].pb(b);edge[b].pb(a);
	}
	rep(i,q){
		int a,b;scanf("%d%d",&a,&b);
		x[a] += b;
	}
	dfs(1,-1);
	repn(i,n) cout<<x[i]<<endl;
}

Measured memory_bytes: 24320
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    s = iss()
    print(s + 'es' if s[-1] == 's' else s + 's')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9824
num_list = [] 
n = int(input())
for i in range(n):
    num_list.append(int(input()))
tmp = num_list.copy()
tmp.sort()
tmp = tmp[::-1]

if tmp[0] == tmp[1]:
    num = tmp[0]
    for i in range(n):
        print(num)
        
else:
    for i in range(n):
        num = tmp[0]
        if num_list[i] != tmp[0]:
            print(tmp[0])
            
        else:
            print(tmp[1])

Measured memory_bytes: 14136
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    char a,b;
    cin>>a>>b;
    if(a==b) cout<<"H"<<endl;
    else cout<<"D"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll go(ll n)
{
	if(n%2==1)
	{return 0;}
	ll div=10,ans=0;
	while(1)
	{
		if((n/div)==0)break;
		ans+=n/div;
		div*=5;
	}
	return ans;
	
}

int main()
{ios_base::sync_with_stdio(false);
ll n;
cin>>n;
ol(go(n));
return 0;
}



Measured memory_bytes: 256
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  int a = n / 111;
  int b = n % 111;
  if(b != 0) cout<< (a+1) *111 <<endl;
  else cout<<a * 111<<endl;
}

Measured memory_bytes: 256
import numpy as np
#import functools
#import operator
from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math
#import sympy

N = int(input())
#N,K,d= map(int,input().split())
L = list(map(int,input().split()))
#S = str(input())
#T = str(input())
c,C=0,0

def has_duplicates(seq):
    return len(seq) != len(set(seq))

for v in comb(L,3):
    if has_duplicates(v):
        continue

    if sum(v)-max(v)>max(v):
        c+=1

print(c)


Measured memory_bytes: 27160
#include <iostream>                                                                                       
#include <vector>                                                                                         
                                                                                                          
using namespace std;                                                                                      
                                                                                                          
int main (void) {                                                                                         
  int n, a;                                                                                               
  cin >> n;                                                                                               
  vector<int> v;                                                                                          
  for (int i=0; i<n; i++) {                                                                               
    cin >> a;                                                                                             
    v.push_back(a);                                                                                       
  }                                                                                                       
  for (int i=1; i<n; i++) {                                                                               
    cout << v[v.size()-i] << " " << flush;                                                                
  }                                                                                                       
  cout << v[0] << endl;                                                                                   
}                                                                                                         
                                                                                                          
                                                                                                          
                                                                                                          
                                   

Measured memory_bytes: 3136
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, t = (int(_) for _ in input().split())
    
    print((t//a)*b)
    
if __name__ == '__main__':
    main()


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

int main(){
  int n;
  cin >> n;
  ll power=1;
  rep(i,n){
    power *= (i+1);
    if(power >= 1000000007) power = power % 1000000007;
  }
  
  cout << power << endl;
  
  return 0;
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    # print(P)
    # print(Q)

    a = 0
    b = 0
    cnt = 0
    for R in itertools.permutations(range(1, N+1), N):
        R = [r for r in R]
        cnt += 1
        if R == P:
            a = cnt
        if R == Q:
            b = cnt
        # print(R)
    
    print(abs(a-b))


if __name__ == '__main__':
    main()

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

int main()
{
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> grids(H, vector<char>(W));
  
  // 入力
  for(int i = 0; i < H; ++i)
  {
    for(int j = 0; j < W; ++j)
    {
      cin >> grids.at(i).at(j);
    }
  }
  
  // 行削除
  vector<char> deleterow(W, '.');
  for(int i = grids.size() - 1; i >= 0; --i)
  {
    if(grids.at(i) == deleterow)
    {
      grids.erase(grids.begin() + i);
    }
  }
  
  // 列削除
  vector<int> deleteclmnum;
  for(int i = 0; i < W; ++i)
  {
    bool flg = true;
    for(int j = 0; j < grids.size(); ++j)
    {
      if(grids.at(j).at(i) != '.')
      {
        flg = false;
      }
    }
    
    if(flg)
    {
      deleteclmnum.push_back(i);
    }
  }
  sort(deleteclmnum.rbegin(), deleteclmnum.rend());
  
  for(int i = 0; i < grids.size(); ++i)
  {
    for(int j = 0; j < deleteclmnum.size(); ++j)
    {
      grids.at(i).erase(grids.at(i).begin() + deleteclmnum.at(j));
    }
  }
  
  
  // 出力
  for(int i = 0; i < grids.size(); ++i)
  {
    for(int j = 0; j < grids.at(i).size(); ++j)
    {
      cout << grids.at(i).at(j);
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[0 for i in range(5)]
for i in range(n):
  s=input()
  if s[0]=="M":
    l[0]+=1
  elif s[0]=="A":
    l[1]+=1
  elif s[0]=="R":
    l[2]+=1
  elif s[0]=="C":
    l[3]+=1
  elif s[0]=="H":
    l[4]+=1

ans=0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      if 1<=l[i] and 1<=l[j] and 1<=l[k]:
        ans+=l[i]*l[j]*l[k]
print(ans)

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

#define DOGS 1000000000000001LL

uint64_t pow(uint64_t b, uint64_t n) {
  uint64_t result = 1;
  for (uint64_t i = 0; i < n; i++) {
    result = result * b;
  }
  return result;
}
int main() {
  uint64_t N;
  cin >> N;

  vector<uint64_t> dognums;
  vector<uint64_t> dogtotals;
  dogtotals.push_back(0);
  dognums.push_back(0);

  int i = 1;
  while (true) {
    uint64_t dognum = pow(26, i);

    dognums.push_back(dognum);
    dogtotals.push_back(dognum + dogtotals[dogtotals.size() - 1]);

    i++;
    if (dognum >= DOGS) {
      break;
    }
  }

  //   for (uint64_t t : dogtotals) {
  //     cout << t << endl;
  //   }
  //   for (uint64_t n : dognums) {
  //     cout << n << " n" << endl;
  //   }

  int keta = 1;
  while (true) {
    if (dogtotals[keta] >= N) {
      break;
    }
    keta++;
  }

  // uint64_t NN = N - dogtotals[keta - 1];
  uint64_t NN = N;

  vector<char> name(keta);
  for (int j = 0; j < keta; j++) {
    /// cout << NN << " NN" << endl;
    uint64_t NNN = (NN % 26);
    if (NNN == 0) {
      NNN = 26;
    }
    name[j] = 'a' - 1 + NNN;
    NN = (NN - 1) / 26;
  }

  for (int k = name.size() - 1; k >= 0; k--) {
    char cc[] = {"\n"};
    cc[0] = name[k];
    string s(cc);
    cout << s;
  }
  cout << endl;
}


Measured memory_bytes: 4024
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

k,t = lr()
a = lr()
maxa = max(a)
if maxa > (k+1)//2:
    print((maxa-((k+1)//2))*2-1)
else:
    print(0)

Measured memory_bytes: 77508
Sa, Sb, Sc = open(0).read().split()
# print(Sa, Sb,Sc)
numSa = len(Sa)
numSb = len(Sb)
numSc = len(Sc)
# print(numSa,numSb,numSc)
i=j=k=0
flgA = True
flgB = flgC = False
l=0
# noDebug = False
while(True):
    if flgA == True:
#         print("A",i)
        flgA = False
        if numSa==i:
             print("A")
#             noDebug = True
             break
        if Sa[i] == "a":
            flgA = True
        elif Sa[i] == "b":
            flgB = True
        else:
            flgC = True
        i+=1
    elif flgB == True:
#         print("B",j)
        flgB = False
        if numSb==j:
            print("B")
#             noDebug = True
            break
        if Sb[j] == "a":
            flgA = True
        elif Sb[j] == "b":
            flgB = True
        else:
            flgC = True
        j+=1
    elif flgC == True:
#         print("C",k)
        flgC = False
        if numSc==k:
            print("C")
#             noDebug = True
            break
        if Sc[k] == "a":
            flgA = True
        elif Sc[k] == "b":
            flgB = True
        else:
            flgC = True
        k+=1
    else:
        pass
#     if noDebug == False:
#         print(l)
#         print(l,"::",Sa[i],i,Sb[j],j,Sc[k],k) 
#     l+=1

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
        ll n,a,b;
        cin>>n>>a>>b;
        ll q = n/(a+b),r = n%(a+b);
        ll ans = q*a;
        if(r<=a)
            ans+=r;
        else
            ans+=a;
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			long a=sc.nextInt();
			long b=sc.nextInt();
			System.out.println(gcd(a,b)+" "+lcm(a,b));
		}
	}
	static long gcd(long a,long b){
		if(a%b==0){
			return b;
		}else{
			return gcd(b,a%b);
		}
	}
	static long lcm(long a,long b){
		return a*b/gcd(a,b);
	}
}

Measured memory_bytes: 17216
#import decimal
#decimal.getcontext().prec==500 Floatの桁数を500まで増やす
#Decimal(c).sqrt() それで平方根を求める
#Decimal(1) / Decimal(7) 1/7
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd
import sys
#input = sys.stdin.readline


#N=int(input())

N=int(input())
A=[int(input()) for i in range(N-1)]
data=[set() for i in range(N+1)]
data2=[[] for i in range(N+1)]
for i in range(N-1):
    data[A[i]].add(i+2)
    data2[i+2].append(A[i])
stack=[[i+2,0] for i in range(N-1) if not data[i+2]]
lst=[[] for i in range(N+1)]
while stack:
    a,m=stack.pop()
    if a==1:
        print(m)
        exit()
    p=A[a-2]
    data[p].remove(a)
    lst[p].append(m)
    if not data[p]:
        stack.append([p,max([x+i+1 for i,x in enumerate(sorted(lst[p],reverse=True))])])


Measured memory_bytes: 119636
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
//#define DEBUG

int main()
{
    short friends, broughtCake, allMember;
    short numOfCake[100] = {};
    short cakeTotal = 0;

    //read
    scanf("%hd %hd", &friends, &broughtCake);
    for(int i = 0; i < broughtCake; i++)
    {
        scanf("%hd", &numOfCake[i]);
        cakeTotal += numOfCake[i];
    }
    allMember = friends + 1;

#ifdef DEBUG
    printf("friends:%d  cake total:%d\n", friends, cakeTotal);
    short cpf = (cakeTotal - (cakeTotal % allMember))/ allMember;
    printf("cake/member:%d rem:%d\n", cpf, cakeTotal % allMember);
#endif

    //sum
    short myCake = (cakeTotal - (cakeTotal % allMember))/ allMember;
    if((cakeTotal % allMember) != 0)
    {
        myCake++;
    }

    //output
    printf("%d\n", myCake);
}


Measured memory_bytes: 2136
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a == b)cnt++;
		else cnt = 0;
		if (cnt == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define re register

using namespace std;

string n;
int pos1,pos2;

int main()
{
	cin.tie(0);
	cin>>n;
	for(re int i=0;i<n.size();i++)
	  {
	  	if(n[i] == 'C') 
		  for(re int j=i+1;j<n.size();j++)
		    if(n[j] == 'F') {cout<<"Yes\n";return 0;}
	  }
	cout<<"No\n";
} 

Measured memory_bytes: 256
def find(A):
    A=sorted(A)
    N=len(A)
    left=A[:N//2]
    right=A[N//2:]
    a=left[-1]
    b=right[0]
    return b-a
input()
A=list(map(int,input().strip().split(' ')))
print(find(A))
    

Measured memory_bytes: 14396
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b;
    if(a>9||a<1||b>9||b<1||lround(a)!=a||lround(b)!=b){
        cout<<-1<<endl;
    }
    else{
        cout<<a*b<<endl;
    }
}

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

ll dp[301][301];

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


	int N, M;
	scanf("%d %d", &N, &M);

	int xm[301][4], xM[301][4];
	rep1(i, N) {
		xm[i][1] = N;
		xm[i][2] = N;
		xM[i][2] = -1;
		xM[i][3] = -1;
	}
	rep(i, M) {
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		chmin(xm[r][x], l);
		chmax(xM[r][x], l);
	}

	const int mod = 1e9 + 7;
	dp[0][0] = 1;
	rep1(i, N) {
		for (int j = i - 1; j >= 0; j--) for (int k = i - 1; k >= j; k--) {
			dp[j][i] += dp[j][k];
			dp[k][i] += dp[j][k];
		}

		for (int j = i; j > xm[i][2]; j--) {
			for (int k = i; k >= j; k--) dp[j][k] = 0;
		}
		for (int j = xm[i][2]; j > xM[i][3]; j--) {
			for (int k = i; k > xm[i][1]; k--) dp[j][k] = 0;
			if (i % 3 == 0) {
				for (int k = xm[i][1]; k > xM[i][2]; k--) {
					dp[j][k] %= mod;
				}
			}
			for (int k = xM[i][2]; k >= 0; k--) dp[j][k] = 0;
		}
		for (int j = xM[i][3]; j >= 0; j--) {
			for (int k = i; k >= j; k--) dp[j][k] = 0;
		}
	}

	ll kotae = 0;
	rep(j, N + 1) rep(k, N + 1) {
		kotae += dp[j][k] % mod;
	}
	printf("%lld", kotae% mod);

	Would you please return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
using namespace std;



int main()
{
  unordered_map<string,int>m;
  string s;
  cin >> s;
  string s1 = s;
  fr(i,0,s.size())
  {
      s1 = s;
      m[s]=1;
      fr(j,i,s1.size())
      {
          s1.erase(s1.begin()+j);
          j--;
          m[s1]=1;
      }
  }
  if(m["keyence"]==1)
  {
      cout << "YES";
  }
  else
  cout << "NO";

  return 0;
}


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

int main() {
    string str;
    cin >> str;
    if(str == "hi" || str == "hihi" || str == "hihihi" || str == "hihihihi" || str == "hihihihihi") cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve
{
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1)
    {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i)
        {
            if (f[i])
                continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i)
            {
                if (!f[j])
                    f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x; }
    vector<int> factorList(int x)
    {
        vector<int> res;
        while (x != 1)
        {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }

    vector<pair<int,int>> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<pair<int,int>> res(1, pair<int,int>(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}


void solve(long long N, std::vector<long long> A)
{
    Sieve sieve = Sieve(1e6);
    map<int,int> mp;
    for(int prime:sieve.primes){
        mp[prime] =0;
    }
    ll L = 1;
   
    for(int i=0;i<N;i++){
        for(pair<int,int> p:sieve.factor(A[i])){
            // cerr <<"p=" << p.first << "num=" << p.second << endl;
            mp[p.first] = max( mp[p.first] ,p.second);
        }
    }
    for(int prime:sieve.primes){
        L *= mod_pow((ll)prime,(ll)mp[prime],MOD);
        L %= MOD;
    }
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += (L * modinv(A[i], MOD));
        ans %= MOD;
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    string s;
    cin >> s;

    set<char> ans;
    rep(i,s.size()) ans.insert(s[i]);

    if( ans.size() == s.size() ) cout << "yes" << endl;
    else cout << "no" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
// ver1.7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  int ct = 0,now = 0;
  while(now < n){
    now += ct;
    ct++;
  }
  cout << ct-1 << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  vector<int> pos, neg;
  rep(i, n) {
    int a;
    cin >> a;
    if (a >= 0)
      pos.push_back(a);
    else
      neg.push_back(a);
  }

  ll ans = 0;
  for (auto x : pos) ans += x;
  for (auto x : neg) ans += abs(x);

  if (neg.size() % 2 == 1) {
    int mn = 1001001001;
    for (auto x : pos) mn = min(mn, x);
    for (auto x : neg) mn = min(mn, abs(x));
    ans -= (ll)2 * mn;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3864
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;


int main()
{
	ll i, j, k, l, m, sum, flag, N, M;
	sum = 0;
	flag = 0;
	cin >> N;
  if(N==1){
  output("Yes");
    output(2);
    cout<<1<<" "<<1<<endl;
    cout<<1<<" "<<1<<endl;
    return 0;
  }
	ll s[500][500];
	REP(i, 1, N*2) {
		if (i*(i - 1) == 2*N) {
			flag = 1;
			break;
		}
	}
	k = i;
	if (flag == 0) {
		output("No");
	}
	else {
		output("Yes");
		output(k);
		ll z;
		z = 1;
		REP(i, 1, k + 1) {
			REP(j, 0, k - i) {
				s[i][j + i] = z;
				s[i + j+1][i] = z;
				z++;
			}
		}
		
		REP(i, 1, k + 1) {
			cout << k - 1 << " ";
			REP(j, 1, k) {
				cout << s[i][j] << " ";
			}
			cout << endl;
		}
	}
    return 0;
}



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

using namespace std;

typedef long long ll;

int main(){
	int n; double sum = 0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum+=a[i];
	}
	sum /= n;
	double dif = 101;int ans;
	for(int i = 0; i < n; i++){
		if(abs(sum-a[i]) < dif){
			ans = i;
			dif = abs(sum-a[i]);
		}
	}
	cout << ans << 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;

class UFT {
  vector<int> parent;
  vector<int> rank; //木の高さ
  vector<int> size;
public:
  UFT(int n){
    parent = vector<int>(n);
    rank = vector<int>(n,0);
    size = vector<int>(n,1);
    for(int i = 0; i < n; i++)
      parent[i] = i;
  }
  int find_root(int x){
    if ( parent[x] == x ) return x;
    return parent[x] = find_root( parent[x] );
  }
  void unite(int x, int y){
    int u = find_root(x);
    int v = find_root(y);
    if ( u == v ) return;
    if ( rank[u] < rank[v] ){
      parent[u] = v;
      size[v] += size[u];
    }else{
      parent[v] = u;
      size[u] += size[v];
      if ( rank[u] == rank[v] ) rank[x]++;
    }
  }
  bool is_same ( int x, int y ){
    return find_root(x) == find_root(y);
  }
  int size_of ( int x ){
    return size[ find_root(x) ];
  }
};

int N, M;
int K[100000];
set<int> L;
vector<int> l[100000];
int main(){
  cin >> N >> M;
  UFT uft(M);
  REP(i,N){
    cin >> K[i];
    REP(j,K[i]){
      int t;
      cin >> t;
      t--;
      l[i].push_back( t );
      L.insert( t );
      if( j > 0 ){
	uft.unite( l[i][0], l[i][j] );
      }
    }
  }
  if( uft.size_of( l[0][0] ) == L.size() ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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

typedef long long ll;

ll dp[111][111][256];
ll N,K;
int A[111];
ll J[111];
const ll MOD = 1000000007LL;
void update(ll &a,ll b){
  a += b;
  a %= MOD;
}

ll solve(){
  J[1] = 1;
  for(int i=2;i<=N;i++) J[i] = (J[i-1] * (ll)i)%MOD;
  dp[0][0][0] = 1LL;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<256;k++){
        update( dp[i+1][j+1][k^A[i]], dp[i][j][k] );
        update( dp[i+1][j][k], dp[i][j][k] );
      }
    }
  }
  ll res = 0;
  for(int i=1;i<=N;i++){
    //cout << N << " " << i << " " << K << " " << dp[N][i][K] << endl;
    update( res, dp[N][i][K] * J[i] );    
  }
  return res;
}
int main(){
  cin >> N >> K;
  for(int i=0;i<N;i++) cin >> A[i];
  cout << solve() << endl;
}


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


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n){
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 1000+10;
const int max_v = max_n*max_n/2;

int N;
int id[max_n][max_n];
vector<int> to[max_v];

int toId(int i,int j) {
    if(i > j)
        swap(i,j);

    return id[i][j];
}

bool visited[max_v];
bool calc[max_v];
int dp[max_v]; //max length of path from v

int dfs(int v) {
    if(visited[v]) {
        if(!calc[v])
            return -1;
        return dp[v];
    }

    visited[v] = true;
    dp[v] = 1;

    for(auto u: to[v]) {
        int res = dfs(u);
        if(res == -1)
            return -1;
        dp[v] = max(dp[v], res+1);
    }

    calc[v] = true;
    return dp[v];
}

int main(void) {
    cin>>N;

    vector<vector<int>> A(N, vector<int>(N-1));
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < N-1;j++) {
            cin>>A[i][j];
            A[i][j]--;
        }
    }

    int V = 0;
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < N;j++) {
            if(i < j)
                id[i][j] = V++;
        }
    }

    for(int i = 0;i < N;i++) {
        for(int j = 0;j < N-1;j++) {
            A[i][j] = toId(i,A[i][j]);
        }
        for(int j = 0;j < N-2;j++) {
            to[A[i][j+1]].push_back(A[i][j]);
        }
    }

    int ans = 0;
    for(int i = 0;i < V;i++) {
        int res = dfs(i);
        if(res == -1) {
            cout<<-1<<endl;

            return 0;
        }
        ans = max(ans,res);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 38784
require 'set'

def get_ints
  gets.split.map(&:to_i)
end


n,m = get_ints

hash = {}

m.to_i.times do
  a, b = get_ints
  hash[a] = [] unless hash[a]
  hash[b] = [] unless hash[b]

  hash[a].push(b)
  hash[b].push(a)
end

t = [1]
dones = Set.new
dones.add(1)

result_hash = {}

search = ->() do
  return if t.empty?

  res = t
  t = []

  res.each do |num|
    hash[num].each do |x|
      result_hash[x] = num unless result_hash[x] || x == 1
      t.push(x) unless dones.include?(x)
      dones.add(x)
    end
  end
  search.call
end

search.call

if result_hash.keys.length == n - 1
  puts 'Yes'
  result_hash.keys.sort.each do |key|
    puts result_hash[key]
  end
else
  puts 'No'
end


Measured memory_bytes: 50288
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int total = 0;
	rep(i, 0, n) {
		cin >> a[i]; total += a[i];
	}
	double num = total * 1.0 / (4 * m);
	int cnt = 0;
	rep(i, 0, n) {
		if (a[i] >= num) cnt++;
		if (cnt == m) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
	return 0;
}

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


typedef struct tree_t{
	int key;
	struct tree_t *left;
	struct tree_t *right;
}TREE_T;

TREE_T *TREE;


TREE_T *Find(int key)
{
	TREE_T *y = NULL;
	TREE_T *x = TREE;


	while(x != NULL){
		if(key == x->key)
			return x;
		y = x;
		if(key < x->key)
			x = x->left;
		else
			x = x->right;
	}

	return NULL;
}


int Insert(int key)
{
	TREE_T *p;
	TREE_T *y = NULL;
	TREE_T *x = TREE;


	if( (p = (TREE_T *)malloc(sizeof(TREE_T))) == NULL){
		printf("malloc error\n");
		return 0;
	}
	p->key = key;
	p->left = NULL;
	p->right = NULL;

	while(x != NULL){
		y = x;
		if(p->key < x->key)
			x = x->left;
		else
			x = x->right;
	}

	if(y == NULL)
		TREE = p;
	else if(p->key < y->key)
		y->left = p;
	else
		y->right = p;

	return 1;
}


// kind = 0:通りがけ 1:行きがけ
void Walk_tree(TREE_T *p, int kind)
{
	if(kind == 1)
		printf(" %d", p->key);

	if(p->left != NULL)
		Walk_tree(p->left, kind);

	if(kind == 0)
		printf(" %d", p->key);

	if(p->right !=NULL)
		Walk_tree(p->right, kind);
}


int main()
{
	TREE_T *p;
	int n;
	char command[10];
	int key;
	int i;

	TREE = NULL;

	scanf("%d", &n);

	for(i = 0; i < n; i++){
		scanf("%s", command);

		if(!strcmp(command, "insert")){
			scanf("%d", &key);
			Insert(key);
		}else if(!strcmp(command, "print")){
			Walk_tree(TREE, 0);
			printf("\n");
			Walk_tree(TREE, 1);
			printf("\n");
		}else if(!strcmp(command, "find")){
			scanf("%d", &key);
			if(Find(key))
				printf("yes\n");
			else
				printf("no\n");
		}
	}


	return 0;
}


Measured memory_bytes: 14216
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

using namespace std;

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

    for(int i = 1; i <= n; i++) {
        int dif = abs(a[i-1] - a[i+1]) - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]));
        b[i] = dif;
        sum += abs(a[i-1] - a[i]);
    }

    sum += abs(a[n]-a[n+1]); 
    for(int i = 1; i <= n; i++) {
        cout << sum + b[i] << endl;
    }

    return 0;
}
    



Measured memory_bytes: 2048