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

#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define pll pair<ll , ll>
#define vpll vector<pair<ll, ll> >
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define N 100001
#define HOLE 1000000007

ll fn(ll x,ll rn[])
{
    if(rn[x]==x) return x;
    else return rn[x]=fn(rn[x],rn);
}

void un(ll x,ll y,ll rn[],ll sz[])
{
    x=fn(x,rn);
    y=fn(y,rn);
    if(x==y) return;
    if(sz[x]<sz[y]) swap(x,y);
    sz[x]+=sz[y];
    rn[y]=x;
    return;
}

ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x)%HOLE;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%HOLE; // Change x to x^2
    }
    return res;
}

vector <ll> adjl[N];
ll marked[N]={0};
vector <ll> order;

void dfs (ll x){

    if(marked[x])
        return;
    marked[x]=1;

    REP(i,0,adjl[x].size()){

    }

    return;
}

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

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

        ll n;

        string s;

        cin>>s;

        int flag=0;

        n=s.size();

        REP(i,0,n/4){
            if(s[i]!=s[(n-3)/2-i]){
                flag=1;
            }
        }


        REP(i,0,n/4){
            if(s[i+n/2+1]!=s[(n-i-1)]){
                flag=2;
            }
        }

        REP(i,0,n/2){
            if(s[i]!=s[(n-i-1)]){
                flag=3;
            }
        }


        if(!flag){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }



    }

return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n;
 cin>>n;
 vector<ll> a(n);
 for(ll i=0;i<n;i++){
  cin>>a[i];
 }
 ll res = 0;
 map<ll,ll> cnt;
 for(ll i=0;i<n;i++){
  res += cnt[ i+1 -a[i] ];
  cnt[i+a[i]+1]++;
 }
 cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 27548
#include <stdio.h>

int sumofdigits(int n)
{
  int sum = 0;
  while (n > 0) {
      sum += n % 10;
      n /= 10;
    }
  return sum;
}
  
int main(void)
{
  int i;
  int ans = 0;
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  
  for (i = 1; i <= n; i++) 
    if (sumofdigits(i) >= a && sumofdigits(i) <= b)
      ans += i;
  
  printf("%d ", ans);
  return 0;
}

Measured memory_bytes: 128
using System;

public class Test
{
	public static void Main()
	{
		for (int i = 1; i < 10; i++)
			for (int j = 1; j < 10; j++)
			{
				Console.WriteLine(string.Format("{0}x{1}={2}", i, j, i * j));
			}
	}
}

Measured memory_bytes: 8908
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  int N; cin >> N;
  for(;N--;){
	double x[4], y[4];
	REP(i,4)
	  cin >> x[i] >> y[i];
	//x[0] -= x[1], y[0] -= y[1], x[2] -= x[3], y[2] -= y[3];

	if(abs((x[0]-x[1])*(y[2]-y[3])-(x[2]-x[3])*(y[0]-y[1]))<EPS)
	  cout << "YES" << endl;
	else
	  cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=1<<31-1=2147483647
constexpr ll INF = (ll)1e18;//1<<63-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/


signed main() {
	ll N,K;
	cin >> N >> K;
	vector<ll> a(N,0);
	rep(i,N)cin >> a[i];

	if(K==0){
		p(accumulate(a.begin(), a.end(), 0LL));
		return 0;
	}

	ll size=ceil(log2(K))+1;
	vector<ll> bit(size,0);

	rep(i,N){
		rep(j,size){
			if(a[i] & (1LL<<j)){
				bit[j]--;
			}else{
				bit[j]++;
			}
		}
	}

	ll k=0;
	for(ll i=size-1;i>=0;i--){
		if(bit[i]>0 && (k|(1LL<<i))<=K ){
			k|=(1LL<<i);
		}
	}
	debug(bit);
	debug(k);

	ll ans=0;
	rep(i,N){
		ans+=a[i]^k;
	}
	p(ans);
	return 0;
}


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

using namespace std;

#define ll long long
#define mod 1000000007
#define endl '\n'

int calc(int n){
    return (int)(sqrt(2*n + 0.25) - 0.5);
}

int main(){
    ll n;
    cin>>n;
    int ans = 0;
    for(ll i = 2;i*i<=n;i++){
        int c = 0;
        while(n % i == 0){
            c ++;
            n /= i;
        }
        ans += calc(c);
    }
    if(n > 1)ans ++;
    cout<<ans;
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  int count = 0;
  int start = 1;
  int end = (N < 9 ? N : 9);
  for (; start <= N; )
  {
    count += (end - start + 1);
    start *= 100;
    end = 100*(end + 1) - 1;
    if (N < end)
      end = N;
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int bubbleSort(vector<int> &a, int N){
  int res = 0;
  bool flag = true;
  while (flag){
    flag = false;
    for (int j=N-1; j>=1; j--){
      if (a[j] < a[j-1]){
        swap(a[j], a[j-1]);
        res++;
        flag = 1;
      }
    }
  }
  rep(i, N){
    cout <<a[i];
    if (i == N-1) cout <<endl;
    else cout <<" ";
  }
  return res;
}


int main() {
  int N; cin >>N;
  vector<int> a(N); rep(i, N) cin >>a[i];
  cout <<bubbleSort(a, N) <<endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  ll x, y;
  cin >> x >> y;
  
  if (n < k)
    cout << n * x << endl;
  else
    cout << k * x + (n - k) * y << endl;
  

  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<int>len(n);
	map<int,bool>vis;
	for(int i=0;i<n;i++){
		cin>>len[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				vector<int> foo(3);
				foo[0]=len[i];foo[1]=len[j];foo[2]=len[k];
				sort(foo.begin(),foo.end());
				if(foo[0]+foo[1]>foo[2] && foo[0]!=foo[1] && foo[0]!=foo[2] && foo[1]!=foo[2]){
					ans++;
				}
			}
		}
	}
	cout<<ans;

	

	return 0;
}

Measured memory_bytes: 3660
def main():
	line = input()
	vector = [int(x) for x in line.split()]
	r = vector[0]
	D = vector[1]
	x2000 = vector[2]
	y = x2000
	for i in range(10):
		y = r * y - D
		print(y)






if __name__ == "__main__":
	main()

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

from collections import Counter

# 2本以上ある棒のみ集計
C = Counter(A).most_common()
D = []
for (k,v) in C:
    if v>=2:
        D.append((k,v))

D.sort()

# 一番長い棒が4本あれば正方形(も長方形のうち)
if len(D)>=1 and D[-1][1]>=4:
    print(D[-1][0]**2)
elif len(D)>=2:
    print(D[-1][0]*D[-2][0])
else:
    print(0)

Measured memory_bytes: 21540
#include <iostream>
#include <algorithm>
using namespace std;
int a[200100];
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int years, cost;
	while (cin >> years >> cost)
	{
		if (years <= 5)
			cost = 0;
		else if (years <= 12)
			cost /= 2;
		
		cout << cost << '\n';
	}
	return 0;
}

Measured memory_bytes: 632
N = int(input())
if N == 100000:
    print(90909)
elif N >= 10000:
    print(9+900+(N-10000+1))
elif N >= 1000:
    print(909)
elif N >=100:
    print(9+(N-100+1))
elif N < 10:
    print(N)
else:
    print(9)

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int,readline().split())
s = input()
t = input()

MOD = 10**9+7
v = 2 # 初期状態
ans = 1
i = 0
while i < n:
    if s[i]==t[i]:
        i += 1
        if v==0:
            ans *= 2
        if v==2:
            ans *= 3
        v = 0
        ans %= MOD
    else:
        i += 2
        if v==0:
            ans *= 2
        if v==1:
            ans *= 3
        if v==2:
            ans *= 6
        v = 1
        ans %= MOD

print(ans%MOD)

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	int n;
	cin >> n;
	int max_h = 0;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;
		if (h >= max_h) {
			res++;
		}
		max_h = max(max_h, h);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,cc[1000][2],num=0,ff=0,f[701][701],ans=1e9;
bool b[701][701],v[701],c[701];
void dfs(int x,int p)
{
	if(v[x]&&c[x]!=p){ff=1;return;}
	if(v[x])return;
	cc[num][p]++;v[x]=1;c[x]=p;
	for(int i=1;i<=n;i++)if(x!=i&&!b[x][i])dfs(i,p^1);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		b[x][y]=b[y][x]=1;
	}
	for(int i=1;i<=n;i++)if(!v[i]){num++;dfs(i,0);}
	if(ff){puts("-1");return 0;}
	f[0][0]=1;
	for(int i=1;i<=num;i++)for(int j=0;j<=n;j++)if(f[i-1][j])f[i][j+cc[i][0]]=f[i][j+cc[i][1]]=1;
	for(int i=0;i<=n;i++)if(f[num][i]&&i*(i-1)/2+(n-i)*(n-i-1)/2<ans)ans=i*(i-1)/2+(n-i)*(n-i-1)/2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2688
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<iostream>
using namespace std;

const int N=1e5+1e3+7;

const long long M=1e10+1e3+7;

long long n,a,b,h[N],ans,dam,k,hh[N];

bool can(long long m)
{
	ans=0;
	memset(hh,0,sizeof(hh));
	for(int i=1;i<=n;i++)
		hh[i]=h[i]-b*m;
	for(int i=1;i<=n;i++)
	{
		if(hh[i]<=0)
			continue;
		else
		{
			if(hh[i]%(a-b))
				ans+=hh[i]/(a-b)+1;
			else
				ans+=hh[i]/(a-b);
		}
	}
	return ans>m;
}

int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	long long l=0,r=M+1;
	while(r-l>1)
	{
		long long mid=(l+r)>>1;
		if(can(mid))
			l=mid;
		else
			r=mid;
	}
	cout<<r;
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline

popcntsum = ((1<<1024) - 1)
Fa = [0] + [popcntsum//((1<<(1<<(i-1)))+1) for i in range(1,11)]
Fb = [0] + [Fa[i]<<(1<<(i-1)) for i in range(1,11)]
fila1 = Fa[1]
filb1 = Fb[1]
fila2 = Fa[2]
filb2 = Fb[2]
fila3 = Fa[3]
filb3 = Fb[3]
fila4 = Fa[4]
filb4 = Fb[4]
fila5 = Fa[5]
filb5 = Fb[5]
fila6 = Fa[6]
filb6 = Fb[6]
fila7 = Fa[7]
filb7 = Fb[7]
fila8 = Fa[8]
filb8 = Fb[8]
fila9 = Fa[9]
filb9 = Fb[9]
fila10 = Fa[10]
filb10 = Fb[10]
def popcount(x):
    x = (x&fila1) + ((x&filb1)>>1)
    x = (x&fila2) + ((x&filb2)>>2)
    x = (x&fila3) + ((x&filb3)>>4)
    x = (x&fila4) + ((x&filb4)>>8)
    x = (x&fila5) + ((x&filb5)>>16)
    x = (x&fila6) + ((x&filb6)>>32)
    x = (x&fila7) + ((x&filb7)>>64)
    x = (x&fila8) + ((x&filb8)>>128)
    x = (x&fila9) + ((x&filb9)>>256)
    x = (x&fila10) + ((x&filb10)>>512)
    return x


def check(S):
    if S == 0:
        return []
    if S < 0:
        return None
    G1 = [G[i]&S for i in range(N)]
    M = popcount(S)
    if M**2 == sum(G1[i] for i in range(N) if S&(1<<i)):
        return [(0, 1)]*M
    st = 0
    A = 0
    for i in range(N):
        if (1<<i) & S:
            st = i
            A = 1<<i
            break
    B = 0
    for i in range(N):
        if not (1<<i) & S:
            continue
        if not (G[st] & (1<<i)):
            B = 1<<i
            break
    T = (((1<<N)-1)^S)|A|B
    na = 1
    nb = popcount(B)
    T2 = None
    while T2 != T:
        T2 = T
        for i in range(N):
            if (1<<i) & T:
                continue
            fa = (na == popcount(G1[i]&A))
            fb = (nb == popcount(G1[i]&B))
            if fa and fb:
                continue
            if fa:
                A |= 1<<i
                T |= 1<<i
                na += 1
                continue
            if fb:
                B |= 1<<i
                T |= 1<<i
                nb += 1
                continue
            return None
    S2 = ((1<<N)-1) ^ T
    
    if na > nb:
        na, nb = nb, na
    ss = check(S2)
    if ss is None:
        return None
    return ss + [(na, nb)] 


N, M = map(int, readline().split())
G = [1<<i for i in range(N)]
for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    G[a] |= 1<<b
    G[b] |= 1<<a
ss = check((1<<N)-1)
if ss is None:
    print(-1)
else:
    SA, SB = list(map(list, zip(*ss)))
    res = 1
    for sa, sb in zip(SA, SB):
        res = (res<<sa)|(res<<sb)
    ans = 10**9+7
    for i in range(N+1):
        if not (1<<i)&res:
            continue
        ans = min(ans, (i-1)*i//2 + (N-i-1)*(N-i)//2)
    print(ans)

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

int main(){
    int N, T, cost;
    cin >> N >> T;
    cost = 10000;
    int c[100], t[100];
    for (int i = 0 ; i < N ; i++){
        cin >> c[i] >> t[i];
    }
    for (int j = 0 ; j < N ; j++){
        if(t[j] <= T){
            if(cost > c[j])cost = c[j];
        }
    }

    if( cost > 1000){
        cout << "TLE" << endl;
    }else{
        cout << cost << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
mod=10**9+7
ans=0
a=1
b=1
k=1
for i in range(m-n+1,m+1):
    b*=i
    b%=mod
for i in range(n+1):
    ans+=k*a*(b**2)
    ans%=mod
    a*=(n-i)*(m-i)*pow(i+1,mod-2,mod)
    a%=mod
    b*=pow(m-i,mod-2,mod)
    b%=mod
    k*=-1
print(ans)


Measured memory_bytes: 73952
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define lowbit(x) (x & (-x))

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 3e5 + 5;
struct Node { int l, r; } t[MAXN];
int a[MAXN], ans[MAXN];
vector < pair <int, int> > G;
int tr[MAXN];

inline bool cmp(Node x, Node y) { return x.l < y.l; }
inline void Add(int x) { for (; x; x -= lowbit(x)) ++tr[x]; }
inline int Que(int x) { int re = 0; for (; x <= 3e5; x += lowbit(x)) re += tr[x]; return re;}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; read(n), read(m);
  for (RI i = 1; i <= n; ++i)
    read(t[i].l), read(t[i].r);
  sort(t + 1, t + 1 + n, cmp);
  for (RI i = 1; i <= m; ++i)
    for (RI j = i + i; j <= m; j += i)
      G.push_back(make_pair(j - i, j));
  sort(G.begin(), G.end());
  int now = 0, si = G.size();
  for (RI i = 0; i < si; ++i) {
    while (now < n && t[now + 1].l <= G[i].first) Add(t[++now].r);
    ans[G[i].second - G[i].first] -= Que(G[i].second);
  }
  for (RI i = 1; i <= n; ++i)
    ++a[t[i].l], --a[t[i].r + 1];
  for (RI i = 1; i <= m; ++i)
    a[i] += a[i - 1];
  for (RI i = 1; i <= m; ++i)
    for (RI j = i; j <= m; j += i)
      ans[i] += a[j];
  for (RI i = 1; i <= m; ++i)
    printf("%d\n", ans[i]);

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 23528
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [H, W] = r.nn()

    const s: string[][] = []

    for (let i = 0; i < H; i++) {
      s.push(r.s().split(''))
    }
    let dlen = 0

    for (let y = 0; y < H; y++) {
      for (let x = 0; x < W; x++) {
        if (s[y][x] === '#') continue
        const s2 = [...s.map(l => [...l])]
        const queue: [number, number, number][] = [[y, x, 0]]

        s2[y][x] = 'x'

        let i = 0

        while (queue[i]) {
          const k = queue[i++]

          if (!k) return
          const [y, x, d] = k

          const check = (y, x) => {
            const res = s2[y] && s2[y][x] === '.'

            if (res) s2[y][x] = 'x'
            return res
          }

          if (check(y, x - 1)) queue.push([y, x - 1, d + 1])
          if (check(y, x + 1)) queue.push([y, x + 1, d + 1])
          if (check(y - 1, x)) queue.push([y - 1, x, d + 1])
          if (check(y + 1, x)) queue.push([y + 1, x, d + 1])

          dlen = Math.max(dlen, d)
        }
      }
    }
    return dlen
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


Measured memory_bytes: 10864
n = input()
P = [int(el) for el in input().split(" ")]

count = 0
for i in range(len(P)-2):
    p1 = P[i]
    p2 = P[i+1]
    p3 = P[i+2]
    
    if p1 < p2 < p3 or p3 < p2 < p1:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int  a,b,c;
  cin>>a>>b>>c;
  vector<int>ok(b,0);
  rep(i,101){
    ok[i*a%b]=1;
  }
  if(ok[c])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  return 0;

}


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

int main(){
  int N;
  cin >> N;
  int n = 1;
  while(n * 2 <= N){
    n *= 2;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    k, x = list(map(int,input().split()))
    if 500 * k >= x:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    class Reader {
        BufferedReader in;

        Reader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        Reader(String name) throws IOException {
            in = new BufferedReader(new FileReader(name));
        }

        StringTokenizer tokin = new StringTokenizer("");

        String next() throws IOException {
            if (!tokin.hasMoreTokens()) {
                tokin = new StringTokenizer(in.readLine());
            }
            return tokin.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        boolean hasNext() throws IOException {
            if (tokin.hasMoreTokens()) {
                return true;
            } else {
                String s = in.readLine();
                while (s != null && s.length() == 0) {
                    s = in.readLine();
                }
                if (s == null) {
                    return false;
                } else {
                    tokin = new StringTokenizer(s);
                    return true;
                }
            }
        }
    }

    class Writer {
        PrintWriter cout;

        Writer() throws IOException {
            cout = new PrintWriter(System.out);
        }

        Writer(String name) throws IOException {
            cout = new PrintWriter(new FileWriter(name));
        }

        StringBuilder out = new StringBuilder();

        void print(Object a) {
            out.append(a);
        }

        void close() {
            cout.print(out.toString());
            cout.close();
        }
    }

    long m = (long) 1e9 + 7;

    long S[];

    long calck(int s) {
        if (S[s] == -1) {
            long ans = 0;
            if (s >= 3) {
                ans += 1;
            }
            for (int i = 3; i < s; i++) {
                ans = (ans + calck(s - i)) % m;
            }
            S[s] = ans;
        }
        return S[s];
    }

    void run() throws IOException {
        Reader in = new Reader();
        Writer out = new Writer();
        int s = in.nextInt();
        S = new long[s + 1];
        for (int i = 0; i < s + 1; i++) {
            S[i] = -1;
        }
        out.print(calck(s));
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}

Measured memory_bytes: 34296
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

// 2つのベクトル(x1,y1),(x2,y2)のなす角を求める.
ld angle(int x1, int y1, int x2, int y2) {
	ll inner_product = (ll)x1 * x2 + (ll)y1 * y2;
	ld abs1 = (ld)pow((ll)x1 * x1 + (ll)y1 * y1, 0.5);
	ld abs2 = (ld)pow((ll)x2 * x2 + (ll)y2 * y2, 0.5);
	ld cos_theta = inner_product / (abs1 * abs2);
	return 180 * acos(cos_theta) / M_PI;
}

signed main() {
	int n; cin >> n;
	vector<pair<int, int>> xy(n);
	for (int i = 0; i < n; ++i)
		cin >> xy[i].first >> xy[i].second;

	sort(xy.begin(), xy.end());

	ld ans = ((ld)360.0) * n;

	while (next_permutation(xy.begin(), xy.end())) {
		ld tmp = (ld)0.0;
		int x, y; x = y = 0; // 現在の座標
		int dirx = 1, diry = 0;
		for (auto pi : xy) {
			tmp += angle(dirx, diry, pi.first - x, pi.second - y);
			dirx = pi.first - x;
			diry = pi.second - y;
			x = pi.first;
			y = pi.second;
		}
		tmp += angle(dirx, diry, -x, -y);
		ans = min(ans, tmp);
	}

	cout << setprecision(15) << ans << endl;

	return 0;
}


Measured memory_bytes: 3544
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n,a,b, h[N];


bool check(int num){
    long long  cnt = 0;
    for (int i = 0; i < n; i++){
        if(h[i] -(long long) b *num>0){
            cnt += (h[i] - b *num+a-b-1)/(a-b);
        }
        
        if(cnt>num)return false;
    }
    return true;
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>a>>b;
    for (int i = 0; i < n; i++)cin>>h[i];
    
    int l = 0, r = 1e9;
    
    while(r-l>1){
        int mid = l + (r-l)/2;
        if(check(mid))r = mid;
        else l = mid;
    }
    
    cout<<r<<endl;
    
    
    
    return 0;
}



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

int get(int a, int b){
    if ((a & 1) == (b & 1)){
        return get(a >> 1, b >> 1) + 1;
    }
    return 1;
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i){
        for (int j = i + 1; j <= n; ++ j){
            printf("%d%c", get(i, j), " \n"[j == n]);
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF (1<<21)
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define Rrep(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=a;i<n;i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)

int main() {

	ll n;
	cin >> n;

	cout << n * (n - 1) / 2 << endl;

	
	


	return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 105, K = 1e5 + 87;
const int MOD = 1e9 + 7;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n), dp(k + 1), pre(k + 1);
    for (int & x : a)
        cin >> x;
    fill_n(begin(dp), a[0] + 1, 1);
    for (int i = 1; i < n; ++i) {
        swap(pre, dp);
        for (int j = 1; j <= k; ++j)
            pre[j] = (pre[j] + pre[j - 1]) % MOD;
        dp[0] = 1;
        for (int j = 1; j <= k; ++j) 
            dp[j] = (pre[j] + (j > a[i] ? MOD - pre[j - a[i] - 1] : 0)) % MOD;
    }
    cout << dp[k] << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    vector<int> heights;
    
    for (int i = 0; i < 10; i++) {
        int tmp;
        cin >> tmp;
        heights.push_back(tmp);
    }
    
    sort(heights.begin(), heights.end(), greater<int>());
    cout << heights[0] << endl;
    cout << heights[1] << endl;
    cout << heights[2] << endl;
    
    return 0;
}


Measured memory_bytes: 3144
import sys
def input():
    return sys.stdin.readline()[:-1]
T=int(input())
from fractions import gcd
for i in range(T):
    A,B,C,D=map(int,input().split())
    if A<B or D<B:
        print("No")
        continue
    if B<=C+1:
        print("Yes")
        continue
    if B==D:
        if A%B<=C:
            print("Yes")
        else:
            print("No")
        continue
    g=gcd(B,D-B)
    if (C-A%g)//g<(B-1-A%g)//g:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 5332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main 
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = new String[4];
		strs = br.readLine().split(" ");
		Double[] coos = new Double[4];
		for(int i=0;i<strs.length;i++)	coos[i] = Double.parseDouble(strs[i]);
		
		double ver=0, hor=0, ans=0;
		ver = Math.abs(coos[2] - coos[0]);
		hor = Math.abs(coos[3] - coos[1]);
		ans = Math.sqrt(ver*ver+hor*hor);
		System.out.println(ans);
	}
}



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

template<size_t max_N, size_t prime_size>
struct Prime{
    bool sieve[max_N];
    int_fast64_t prime[prime_size];
    size_t counter = 0;
    Prime() : sieve(), prime() {
        for(int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for(int_fast64_t i = 2; i < max_N; ++i){
            if(sieve[i]){
                prime[counter] = i;
                ++counter;
                if(counter > prime_size)break;
            }
            for(int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
};

auto p = Prime<1000000, 78498>();

int main(){
    int_fast64_t N, P, a(1);
    scanf("%lld%lld", &N, &P);
    if(N == 1)return 0 & printf("%lld\n", P);
    for(int i = 0; i < 78498; ++i){
        int t(0);
        auto k = p.prime[i];
        while(P % k == 0){
            ++t;
            P /= k;
        }
        t /= N;
        for(int j = 0; j < t; ++j){
            a *= k;
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n];
  long long x = 0, y = 0;

  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    y += a[i];
  }

  long long result = LLONG_MAX;

  for (i = 0; i < n - 1; i++) {
    y -= a[i];
    x += a[i];
    result = min(result, (abs(x - y)));
  }

  cout << result << endl;


  return 0;
}


Measured memory_bytes: 1024
program main
  implicit none
  integer i, X, Y, ans
  read(*, *)X, Y
  ans = 1
  if (Y < 2*X) then
    ans = 0
  elseif (Y > 4*X) then
    ans = 0
  elseif (mod(Y,2) == 1) then
    ans = 0
  endif
  if (ans == 0) then
    write(*, *) 'No'
  else
    write(*, *) 'Yes'
  endif

  
end program main


Measured memory_bytes: 2856
N = int(input())
a = list(map(int,input().split()))
b = 0
for i in range(N):
	b += a[i]

if type(b/N) == int:
	m = b/N
	c = 0
	for i in range(N):
		c += (a[i] - m)**2
	print(int(c))
else:
	m = int(b/N) + 1
	n = int(b/N)
	c = 0
	d = 0
	for i in range(N):
		c += (a[i] - m)**2
		d += (a[i] - n)**2
	e = min(c,d)
	print(e)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
  private static final Scanner scanner = new Scanner(System.in);

  public static void main(String[] args) {
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    solve(a, b);
  }

  private static void solve(int a, int b) {
    int count = 0;
    for (int i = 1; i < a || (i <= a && i <= b); i++) {
      count++;
    }
    System.out.println(count);
  }

}


Measured memory_bytes: 21844
k, a, b = map(int, input().split())

if b - a <= 2 or k-(a-1) <= 0:
    ans = 1 + k
else:
    k = k - (a-1)
    n = k // 2
    ans = (n-1) * (b-a) + b + (k-2*n)
print(ans)

Measured memory_bytes: 9180
import collections
N, M = map(int, input().split())
ans = collections.defaultdict(int)
for i in range(N):
  tmp = list(map(int, input().split()))
  tmp = tmp[1:]
  for j in tmp:
    ans[j]+=1
  
maxnum = max(ans.values())
if maxnum == N:
  anslist = [kv[0] for kv in ans.items() if kv[1] == maxnum]
  print(len(anslist))
else:
  print(0)

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll inv(ll x){
	return po(x,mod-2);
}
ll C(ll n,ll k){
	ll res=1;
	rep(i,k){
		res=res*(n-i)%mod;
	}
	rep(i,k){
		res=res*inv(i+1)%mod;
	}
	return res;
}
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=po(2,n)-1;
	ans-=C(n,a)+C(n,b);
	ans%=mod;
	if(ans<0)ans+=mod;
	cout<<ans<<endl;
}




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

int main() {
    string s ;
	cin >> s;
	int N = s.size();
	long long a=0;
	long long b=0;
	for(int i=0;i<N;i++){
	    if(s[i]=='W'){
			a++;
			b+=i;
		}
	}
    cout << b-a*(a-1)/2<<endl;
 
}


Measured memory_bytes: 640
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	_ = getNextInt(scanner)
	k := getNextInt(scanner)
	s := strings.Split(getNextString(scanner), "")
	s[k-1] = strings.ToLower(s[k-1])
	fmt.Fprintln(writer, strings.Join(s, ""))
}


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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int N = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            int[] D = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            Array.Sort(D);

            int i,num = 0;
            for (i = 0; i < N; i++)
            {
                num = num + D[2*i];
            }
            Console.WriteLine(num);
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
int main(void){
    int a,b;
    while(1){
    scanf("%d %d", &a, &b);
    if ( a == 0 && b == 0 ) break;  
    
    if (a<b){
    printf("%d %d\n",a,b);
    } else {
    printf("%d %d\n",b,a);
    }}
    return 0;
}



Measured memory_bytes: 1980
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, M, tmpA, tmpB, answer = 0;
	cin >> N >> M;
	vector<int> H(N);
	for (int count = 0; count < N; count++)
	{
		cin >> H.at(count);
	}
	vector<bool> A(N, true);
	for (int count = 0; count < M; count++)
	{
		cin >> tmpA >> tmpB;
		if (H.at(tmpA - 1) > H.at(tmpB - 1))
		{
			A.at(tmpB - 1) = false;
		}
		else if (H.at(tmpA - 1) < H.at(tmpB - 1))
		{
			A.at(tmpA - 1) = false;
		}
		else
		{
			A.at(tmpA - 1) = false;
			A.at(tmpB - 1) = false;
		}
	}
	for (int count = 0; count < N; count++)
	{
		if (A.at(count))
			answer++;
	}
	cout << answer << endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc138_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  sort(c.begin(), c.end());
  double ans = c[0];
  repi(i, 1, N) { ans = (ans + c[i]) / 2; }

  printf("%.6lf", ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long long int a = 0,b = 0;
    scanf("%d %d",&a,&b);
    long long int tmp = 0;
    for(long long int i = 1;i <= b;i += 1){
        tmp += a;
    }
    for(long long int i = 0;i < 5000 * 10001;i += 1){
        if(tmp == i * 2){
            printf("Even\n");
            return 0;
        }
    }
    printf("Odd\n");
    return 0;
}

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

int main() {
    int a ,b, c;
    cin >> a >> b >> c;
    
    if (a < b){
        if (b < c){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)
#define size(x) int(x.size())

#define INF 1000000000000
int main()
{
  ll n, m, x;
  cin >> n >> m >> x;
  ll ans = INF;
  vector<vector<ll>> v(n);
  vector<ll> mon;
  rep(i, n)
  {
    ll ma;
    cin >> ma;
    mon.push_back(ma);
    rep(j, m)
    {
      ll in;
      cin >> in;
      v[i].push_back(in);
    }
  }
  // rep(p, m)
  // {
  //   cout << tot[p] << endl;
  // }
  // cout << 1111111 << endl;
  rep(i, 1 << n)
  {
    vector<ll> tot(m, 0);
    ll money = 0;
    rep(j, n) if (i >> j & 1)
    {
      rep(k, m)
      {
        tot[k] += v[j][k];
      }
      money += mon[j];
    }
    // cout << 1111111 << endl;
    // rep(p, m)
    // {
    //   cout << tot[p] << endl;
    // }
    // cout << 1111111 << endl;
    bool ok = true;
    rep(l, m)
    {
      if (tot[l] < x)
      {
        ok = false;
      }
    }
    if (!ok)
    {
      continue;
    }
    ans = min(ans, money);
  }
  if (ans == INF)
  {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  set<int> s;
  int x;
  int flag = 1;
  vector<int> A(N);
  rep(i, N)
    A[i] = 0;
  rep(i, N) {
    cin >> x;
    if (s.count(x) == 1) {
      flag = 0;
      cout << "NO" << endl;
      break;
    }
    s.insert(x);
  }
  if (flag == 1)
    cout << "YES" << endl;
}


Measured memory_bytes: 10368
#include <iostream>
  #include <vector>
  #include <string.h>
  #include <stack>
  #include <queue>
  #include <algorithm>
  #include <climits>
  #include <cmath>
  #include <map>
  #include <set>
  #include <assert.h>
  #include <stdio.h>
  #define REP(i,n) for(ll i=0;i<(n);i++)
  #define MOD 1000000007
  #define int long long
  #ifdef int
  const long long INF = LLONG_MAX / 10;
  #else
  const int INF = 1010101010;
  #endif
  using namespace std;
  typedef long long ll;
  typedef vector<vector<ll> > mat;
  typedef pair<int, int> P;
  //typedef pair<double, double> P;
  const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
  const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
  
  string s;
  int x, y;
  const int Z = 8003;
  const int N = 2 * Z + 1;
  bool dp[2][2][N];
  char hoge[505050];
  // char s[N];

  signed main() {
    cin >> s;
    // scanf("%s", s);
    cin >> x >> y;
    // scanf("%lld%lld", &x, &y);
    int n = s.length();
    // int n = strlen(s);

    // REP(i,8000) s += 'a';

    dp[0][0][Z] = dp[1][0][Z] = 1;

    int pos = 0LL;
    while (pos < n && s[pos] == 'F') {
      pos++;
      x--;
    }

    int t = 0LL;
    while (pos < n) {
      pos++;
      t ^= 1;
      int L = 0;
      while (pos < n && s[pos] == 'F') {
        pos++;
        L++;
      }
      REP(i,N) dp[t][1][i] = 0; //1の方は計算結果
      REP(i,N) {
        if (!dp[t][0][i]) continue;
        dp[t][1][i-L] = dp[t][1][i+L] = 1;
      }
      REP(i,N) dp[t][0][i] = dp[t][1][i];
    }

    if (dp[0][0][Z+x] && dp[1][0][Z+y]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

    return 0;
  }

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

using namespace std;

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

	int k;
	long long int num = 0;
	int res = 0;
	cin >> k;

	if(k%2==0 || k%5==0)
	{
		cout << -1 << '\n';
		return 0;
	}
	
	while(1)
	{
		res++;
		num = ((num*10)%k);
		num += 7;
		num%=k;
		if(num==0)
		{
			break;
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}

int myPow(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    return x * myPow(x, p-1);
}

int main() {
    int a,b;
    cin >>a >> b;

    int cand = max(a,b);
    int less = min(a,b);
    rep(i,cand){
        cout << less;
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int vis[1000];
int cc(int n)
{
    while(n)
    {
        int x=n%10;
        n=n/10;
        if(vis[x])
            return 0;
    }
    return 1;
}
int main()
{
    int n,k,x;
    cin>>n>>k;
    for(int i=0;i<k;i++)
    {
        cin>>x;
        vis[x]=1;
    }
  for(int i=n;;i++)
  {
      if(cc(i))
      {
          cout<<i;
          return 0;
      }
  }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	double A, B;
	cin >> A >> B;
	if (A > B)
	{
		cout << "GREATER";
	}
	else {
		if (A < B)
		{
			cout << "LESS";
		}
		else {
			if (A == B)
			{
				cout << "EQUAL";
			}
		}
	}
	return 0;
}

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

int main() {
    int Al, Ar, Bl, Br, Cl, Cr, Dl, Dr;
    Al = Ar = Bl = Br = Cl = Cr = Dl = Dr = 0;
    double l, r;
    while (cin >> l >> r) {
        if (1.1 <= l) Al ++;
        else if (0.6 <= l) Bl ++;
        else if (0.2 <= l) Cl ++;
        else Dl ++;

        if (1.1 <= r) Ar ++;
        else if (0.6 <= r) Br ++;
        else if (0.2 <= r) Cr ++;
        else Dr ++;
    }
    cout << Al << " " << Ar << endl;
    cout << Bl << " " << Br << endl;
    cout << Cl << " " << Cr << endl;
    cout << Dl << " " << Dr << endl;
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    ll res=0;
    ll c[10][10];
    rep(i,10)rep(j,10)c[i][j]=0;
    rep(i,n+1){
        int x=i;
        int p1=x%10;
        while(x>=10)x/=10;
        c[p1][x]++;
    }
    rep(i,10)rep(j,10){
        if(i==0||j==0)continue;
        res+=c[i][j]*c[j][i];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3636
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    N = input(int)
    A = input([int, N - 1])
    ans = [0] * N
    for a in A:
        ans[a - 1] += 1
    for a in ans:
        print(a)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 33332