akhauriyash/Code-Regression huggingface dataset:
#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++)
#define rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)

int main() {
	int N;
	int Q;
	int p_l;
	int r;
	int ret;
	int retl;

	cin >> N >> Q;
 	vector<int> c(N+1);//色玉
 	vector<int> d(N+1);//色玉の良い位置
	vector<int> data(N+1);//良い位置には1、悪い位置は0を代入
	vector<int> q_l(Q+1);//問題の左側
	vector<vector<int>> qi(N+1);//問題の番号管理
	vector<int> ans(Q+1);//答え

	rep3(i, 1, N) cin >> c.at(i);
	rep3(i, 1, Q) {
		cin >> q_l.at(i) >> r;
		qi.at(r).push_back(i);
	}
	rep3(i, 1, N) {
		p_l=d.at(c.at(i));
		if(p_l>0) for (int x = p_l; x <= N; x += x & -x)  data.at(x)--;
		for (int x = i; x <= N; x += x & -x)  data.at(x)++;
		d.at(c.at(i))=i;
		if(qi.at(i).size()>0){
			ret = 0;
			for (int x = i; x>0; x -= -x & x) ret += data.at(x);
			rep(j,qi.at(i).size()) {
				retl = 0;
				for (int x=q_l.at(qi.at(i).at(j))-1; x>0; x -= -x & x) retl += data.at(x);
				ans.at(qi.at(i).at(j))=ret-retl;
			}
		}
	}
	rep3(i, 1, Q) cout << ans.at(i) << endl;
	return 0;
}


Measured memory_bytes: 34160
N,M = gets.split.map &:to_i
Mod = 10**9+7
Xs = gets.split.map(&:to_i)
Ys = gets.split.map(&:to_i)
xx = (0...N-1).map{ |i| Xs[i+1] - Xs[i] }
yy = (0...M-1).map{ |i| Ys[i+1] - Ys[i] }
x = (0...xx.size).reduce(0){ |a,i|
  b = (i+1) * (xx.size-i) % Mod * xx[i] % Mod
  (a + b) % Mod
}
y = (0...yy.size).reduce(0){ |a,i|
  b = (i+1) * (yy.size-i) % Mod * yy[i] % Mod
  (a + b) % Mod
}
p x * y % Mod


Measured memory_bytes: 17184
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int N,K;
vector<int> hs,dist;
main() {
  cin>> N >> K;
  for(int i=1; i<=N; ++i) {
    int h; cin>>h;
    hs.push_back(h);
  }
  sort(hs.begin(), hs.end());
  for(int i=K-1; i<N; ++i) dist.push_back( hs[i] - hs[i-K+1] );
  cout<< *min_element(dist.begin(), dist.end()) <<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll dp[MAX_N];

ll a,b;

int main(){
  cin>>a>>b;
  ll ans=-inf;
  ans=max(ans,a*b);
  ans=max(ans,a-b);
  ans=max(ans,a+b);
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  
  if (A<=C){
    if (C<=B){
      cout<<"Yes"<<endl;
      return  0;
    }
  }
  
  if (A>=C){
    if (C>=B){
      cout<<"Yes"<<endl;
      return  0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    ll ans = 1LL, sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i];
        ans *= 3LL;
        ans %= M;
    }

    vector<vector<ll>> dp(500, vector<ll>(100000, 0));
    vector<vector<ll>> dp2(500, vector<ll>(100000, 0));
    dp[0][0] = dp2[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= sum; j++) {
            dp[i + 1][j + a[i]] += dp[i][j];
            dp[i + 1][j + a[i]] %= M;
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= M;

            dp2[i + 1][j + a[i]] += dp2[i][j];
            dp2[i + 1][j + a[i]] %= M;
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= M;
        }
    }

    ll x = 0;
    for (int i = (sum + 1) / 2; i <= sum; i++) {
        x += dp[N][i];
        x %= M;
    }

    ans = (ans - 3 * x) % M;
    if (sum % 2 == 0) ans += 3 * dp2[N][sum / 2];

    cout << (ans % M + M) % M << endl;
}

Measured memory_bytes: 783728
fun main () {
    val list: MutableList<String> = readLine()!!.split("").filter { it != "" } as MutableList<String>
    var count = 0
    var bool = false
    for (string in list) {

        if (string == "R") {
            if (bool) {
                count++
            } else {
                count = 1
                bool = true
            }
        } else {
            bool = false
        }

    }
    println(count)
}

Measured memory_bytes: 39756
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
const int N = 1e5 + 10;
struct ss{
	int next, to;
};ss data[N];
int n, k, p, ans;
int head[N], To[N];
inline void add(int a, int b)
{
	data[++p].next = head[a];
	data[p].to = b;
	head[a] = p;
}
int dfs(int a, int deep)
{
	int d = deep;
	for(int i = head[a];i;i = data[i].next)
	{
		int v = data[i].to;
		d = max(d, dfs(v, deep + 1));
	}
	if(d - deep == k - 1 && To[a] != 1)
	{
		ans ++;
		return 0;
	}
	return d;
}
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1;i <= n; ++i) scanf("%d", &To[i]);
	if(To[1] != 1) ans++, To[1] = 1;
	for(int i = 2;i <= n; ++i) add(To[i], i);
	dfs(1, 0);
	//if(ans)
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6528
N, K = map(int, input().split())


A = list(map(int, input().split()))

mae = [0] * N
ushiro = [0] * N
for i in range(N):
    for j in range(N):
        if i == j: continue
        if j < i and A[i] > A[j]:
            mae[i] += 1
        elif i < j and A[i] > A[j]:
            ushiro[i] += 1

ans = 0
for i in range(N):
    if K >= 2:
        ans += K*(2+(K-1))//2*ushiro[i] + (K-1)*(2+(K-2))//2*mae[i]
    else:
        ans += ushiro[i]


print(ans % (10**9+7))

Measured memory_bytes: 3188
package main

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

func main() {
	A := nextInt()
	B := nextInt()
	K := nextInt()
	m := map[int]struct{}{}
	for i := A; i < min(B+1, A+K); i++ {
		m[i] = struct{}{}
	}
	for i := B; i > max(A-1, B-K); i-- {
		m[i] = struct{}{}
	}

	var ns []int
	for n := range m {
		ns = append(ns, n)
	}
	sort.Ints(ns)
	for _, n := range ns {
		fmt.Println(n)
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

a,b,n = map(int,input().split())
ans = 0

if n < b-1:
    ans = math.floor((a*n)/b)
else:
    ans = math.floor((a*(b-1))/b)
print(ans)

Measured memory_bytes: 9484
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C++ (GCC 9.2.1)
*/

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

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod int(1e9+7)

int main(int argc, char const *argv[])
{
	// DON'T CHANGE
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	// here
	int Rcnt = 0, Rmax = 0;
	string s;
	cin >> s;
	for (char ch : s)
	{
		if(ch == 'R')	++Rcnt;
		else{
			Rmax = std::max(Rmax, Rcnt);
			Rcnt = 0;
		}
	}
	OUT(std::max(Rmax, Rcnt)) BR;
	RET;
}


Measured memory_bytes: 3608
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    string check = "CODEFESTIVAL2016";
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != check[i]){
            ans++;
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#define MAX_N 100000

int bit[MAX_N + 1];
int n;

void
bit_init()
{
	int i;

	for (i = 0; i <= n; ++i)
		bit[i] = 0;
}

void
bit_add(int i, int v)
{
	while (i <= n)
	{
		bit[i] += v;
		i += i & -i;
	}
}

int
bit_sum(int i)
{
	int sum = 0;
	while (i > 0)
	{
		sum += bit[i];
		i -= i & -i;
	}

	return sum;
}

int
main(int argc, char** argv)
{
	int q;
	int c, x, y;

	scanf("%d %d", &n, &q);
	bit_init();
	while (q--)
	{
		scanf("%d %d %d", &c, &x, &y);
		if (c == 0)
			bit_add(x, y);
		else
			printf("%d\n", bit_sum(y) - bit_sum(x - 1));
	}

	return 0;
}

Measured memory_bytes: 988
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

struct coin {
    ll a, b, c;
};

bool cmp(coin x, coin y) {
    return x.a - x.b < y.a - y.b;
}

ll ag[100005], au[100005];

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

    int x, y, z;
    cin >> x >> y >> z;
    int n = x + y + z;

    vector <coin> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i].a >> vec[i].b >> vec[i].c;

    sort(vec.begin(), vec.end(), cmp);

    priority_queue <ll, vector<ll>, greater<ll>> silver;
    for (int i = 0; i < y; i++) {
        silver.push(vec[i].b - vec[i].c);
        ag[y-1] += vec[i].b;
    }

    for (int i = y; i < y+z; i++) {
        ag[i] = ag[i-1];
        ll st = silver.top();
        ll dif = vec[i].b - vec[i].c;
        if (dif > st) {
            silver.pop();
            silver.push(dif);
            ag[i] += vec[i].b - st;
        } else {
            ag[i] += vec[i].c;
        }
    }

    priority_queue <ll, vector<ll>, greater<ll> > gold;
    for (int i = y + z; i < n; i++) {
        gold.push(vec[i].a - vec[i].c);
        au[y+z] += vec[i].a;
    }

    for (int i = y+z-1; i >= y; i--) {
        au[i] = au[i+1];
        ll gt = gold.top();
        ll dif = vec[i].a - vec[i].c;
        if (dif > gt) {
            gold.pop();
            gold.push(dif);
            au[i] += vec[i].a - gt;
        } else {
            au[i] += vec[i].c;
        }
    }

    ll ans = 0;
    for (int i = y-1; i < y+z; i++) ans = max(ans, ag[i] + au[i+1]);

    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main()
{
  int n, l;
  cin >> n >> l;
  string word;
  vector<string> v;
  for (int i = 0; i < n; i++) {
    cin >> word;
    v.push_back(word);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++)
    cout << v[i];
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int t=0;
	int a;cin>>a;
	while(a>0){
		t++;
		a-=t;
	}
	cout<<t<<endl;
}
























Measured memory_bytes: 256
<?php
  $s = str_split(trim(fgets(STDIN)));
  $t = str_split(trim(fgets(STDIN)));
  sort($s);
  rsort($t);
  $len = min(count($s),count($t));
  for($i=0; $i<$len; $i++){
      if($s[$i] == $t[$i]){
          unset($s[$i]);
          unset($t[$i]);
      }
  }
  if(count($s) == 0 && count($t)>0){
      echo "Yes";
      exit;
  }
  
  
  
  $len = max(count($s),count($t));
  
  
  
  for($i=0; $i<$len; $i++){
      if(isset($s[$i])) $ss = $s[$i];
      if(isset($t[$i])) $tt = $t[$i];
      if($ss < $tt){
          echo "Yes";
          exit;
      }else{
          echo "No";
          exit;
      }
  }
  echo "No";

Measured memory_bytes: 4728
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;


int main(){
ll A,B;

cin>>A>>B;
vector<ll> so;
ll tar = __gcd(A,B);
ll ans=1;
ll N=tar;
ll gen = sqrt(N);


if(tar==1){
  cout<<1<<endl;
  return 0;
}

for (ll i = 2; i<=gen ;i++) {
   
    if(tar%i==0){
      ans++;
    }
    
    while (tar%i == 0) { // 素数で割り切れなくなるまで割っていく　//割った個数を配列に足す
			tar /= i;
		}

    if(tar==1){
      break;
    }
	}



  if(tar>1){
    ans++;
  }


cout<<ans<<endl;






}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

vi adj[100001];
int col[100001];
int cor[100001];
vi pth;
int n;

int dfs(int x, int p)
{
    col[x] = (x == n);
    for (int y : adj[x])
    {
        if (y == p) continue;
        col[x] |= dfs(y, x);
    }
    if (col[x])
        pth.push_back(x);
    return col[x];
}

void dfs2(int x, int p)
{
    for (int y : adj[x])
    {
        if (y == p) continue;
        if (!cor[y])
        {
            cor[y] = cor[x];
            dfs2(y, x);
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1, -1);
    reverse(all(pth));

    for (int i = 0; i < pth.size(); ++i)
    {
        int x = pth[i];
        int y = pth[pth.size() - 1 - i];
        if (!cor[x])
            cor[x] = 1;
        if (!cor[y])
            cor[y] = 2;
    }
    for (int i = 1; i <= n; ++i)
        if (cor[i])
            dfs2(i, -1);

    int a = 0, b = 0;
    for (int i = 1; i <= n; ++i)
        (cor[i] == 1 ? a : b)++;

    if (a > b)
        cout << "Fennec";
    else
        cout << "Snuke";
}


Measured memory_bytes: 11768
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String ans = "No";
		if(s.length() % 2 != 0) {
			ans = "No";
		} else {
			String s1 = s.substring(0, s.length() / 2);
			String s2 = s.substring(s.length() / 2);
			if(s1.equals(s2)) {
				ans = "Yes";
			}
		}
		System.out.println(ans);
	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 21204
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	ans := a[0]
	for i := 1; i < n; i++ {
		ans = gcd(ans, a[i])
	}
	fmt.Println(ans)
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 4188
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main()
{
  int d,t,s;
  cin >> d >> t >> s;
  if(d>t*s) cout << "No\n";
  else cout << "Yes\n";
  return 0;
}

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

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

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

class SetUnion {
 public:
  explicit SetUnion(size_t size) : size_(size) {
    for (int i = 0; i <= size; ++i) {
      parent_.push_back(i);
      sub_tree_size_.push_back(1);
    }
  }
  int Find(int x) {
    if (parent_[x] == x) return x;
    return Find(parent_[x]);
  }
  void UnionSet(int s1, int s2) {
    int r1 = Find(s1);
    int r2 = Find(s2);
    if (r1 == r2) return;
    if (sub_tree_size_[r1] >= sub_tree_size_[r2]) {
      sub_tree_size_[r1] += sub_tree_size_[r2];
      parent_[r2] = r1;
    } else {
      sub_tree_size_[r2] += sub_tree_size_[r1];
      parent_[r1] = r2;
    }
  }
  bool SameComponent(int s1, int s2) {
    return Find(s1) == Find(s2);
  }
 private:
  std::vector<int> parent_;
  std::vector<int> sub_tree_size_;
  size_t size_;
};

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> nums;
  for (int i = 0; i < N; ++i) {
    int n;
    std::cin >> n;
    nums.push_back(n);
  }
  SetUnion u(N);
  for (int m = 0; m < M; ++m) {
    int A, B;
    std::cin >> A >> B;
    u.UnionSet(A, B); 
  }
  int cnt = 0;
  for (int i = 1; i <= N; ++i) {
    if (u.SameComponent(i, nums[i-1])) ++cnt;
  }
  std::cout << cnt << std::endl;

  return 0;
} 


Measured memory_bytes: 1912
#include<string.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<stdio.h>
using namespace std;
namespace mcf {
	// required <string.h> <vector> <queue> <algorithm>
	#define MAXN 500
	#define MAXM 110000
	#define wint int
	#define cint int
	const wint wEPS = 0;
	const wint wINF = 1001001001;
	const cint cEPS = 0;
	const cint cINF = 1001001001;
	int n, m, ptr[MAXN], next[MAXM], zu[MAXM];
	wint capa[MAXM], tof;
	cint cost[MAXM], toc, d[MAXN], pot[MAXN];
	int vis[MAXN], pree[MAXN];
	void init(int _n) {
		n = _n; m = 0; memset(ptr, ~0, n * 4);
	}
	void ae(int u, int v, wint w, cint c) {
		next[m] = ptr[u]; ptr[u] = m; zu[m] = v; capa[m] = w; cost[m] = +c; ++m;
		next[m] = ptr[v]; ptr[v] = m; zu[m] = u; capa[m] = 0; cost[m] = -c; ++m;
	}
	bool solve(int src, int ink, wint flo = wINF) {
		int i, u, v;
		wint f;
		cint c, cc;
		memset(pot, 0, n * sizeof(cint));
		//*
		for (bool cont = 1; cont; ) {
			cont = 0;
			for (u = 0; u < n; ++u) for (i = ptr[u]; ~i; i = next[i]) if (capa[i] > wEPS) {
				if (pot[zu[i]] > pot[u] + cost[i] + cEPS) {
					pot[zu[i]] = pot[u] + cost[i]; cont = 1;
				}
			}
		}
		//*/
		for (toc = 0, tof = 0; tof + wEPS < flo; ) {
			typedef pair<cint,int> node;
			priority_queue< node,vector<node>,greater<node> > q;
			for (u = 0; u < n; ++u) { d[u] = cINF; vis[u] = 0; }
			for (q.push(make_pair(d[src] = 0, src)); !q.empty(); ) {
				c = q.top().first; u = q.top().second; q.pop();
				if (vis[u]++) continue;
				for (i = ptr[u]; ~i; i = next[i]) if (capa[i] > wEPS) {
					cc = c + cost[i] + pot[u] - pot[v = zu[i]];
					if (d[v] > cc) { q.push(make_pair(d[v] = cc, v)); pree[v] = i; }
				}
			}
			if (!vis[ink]) return 0;
			f = flo - tof;
			for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v]; f=min(f,capa[i]); }
			for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v]; capa[i] -= f; capa[i ^ 1] += f; }
			tof += f;
			toc += f * (d[ink] - pot[src] + pot[ink]);
			for (u = 0; u < n; ++u) pot[u] += d[u];
		}
		return 1;
	}
}
int b[110];
int ABS(int a){return max(a,-a);}
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
	}
	mcf::init(a*2+2);
	int s=a*2;
	int t=a*2+1;
	for(int i=0;i<a;i++){
		mcf::ae(s,i,1,0);
		mcf::ae(i+a,t,1,0);
	}
	for(int i=0;i<a;i++){
		int at=0;
		for(int j=0;j<a;j++)if(i+1==b[j])at=j;
		for(int j=0;j<a;j++){
			if(i==j)continue;
			mcf::ae(i,j+a,1,ABS(at-j)*(i+1));
		}
	}
	mcf::solve(s,t,a);
	printf("%d\n",mcf::toc);
}

Measured memory_bytes: 1416
n = int(input())
def encode(k):
	if k==0:
		return '0'
	if k==1:
		return '1'
	if k % 2 == 0:
		string = '{}0'.format(encode(k // (-2)))
		return string
	if k % 2 == 1:
		string = '{}1'.format(encode((k-1) // (-2)))
		return string

print(encode(n))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		
		long n = sc.nextLong();
		
		System.out.println(solve(n));
		
	}
	
	long solve(long n){
		long x = n;
		int r = 0;
		
		long d1 = 1;
		boolean isNine = true;
		for(;x > 0;){
			if(x >= 10 && x % 10 != 9){
				isNine = false;
			}
			r += x % 10;
			x = x / 10;
			d1 *= 10;
		}
		d1 /= 10;
		if(d1 == 1){
			return n;
		}
		/*
		System.out.println(isNine);
		System.out.println(r);
		System.out.println(d1);
		*/
		if(isNine){
			return r;
		}
		
		return digitSum(d1-1 + (n/d1 - 1) * d1);
	}
	
	int digitSum(long n){
		int r = 0;
		for(;n > 0;){
			r += n%10;
			n /= 10;
		}
		return r;
	}
}


Measured memory_bytes: 23124
K = int(input())
if K % 7 == 0:
    L = 9 * K / 7
else:
    L = 9 * K

if L % 2 == 0 or L % 5 == 0:
    print(-1)
else:
    i = 1
    num = 10
    while True:
        num = num % L
        if num == 1:
            break
        else:
            i += 1
            num *= 10

    print(i)

Measured memory_bytes: 9104
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	ll x, y;
	ll z;
	int cnt = 0;;
	ll a=1;
	cin >> x >> y;
	z = y / x;
	while (1){
		if (a <= z){
			cnt++;
		}
		else{
			break;
		}
		a = a * 2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

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

const int N = 2e5 + 20, mod = 1e9 + 7;
int n;
pii p[N];
vector <int> vec;

int L[N], R[N], dp[N];

inline void add (int &a, int b)
{
	a += b;
	if (a >= mod) a -= mod;
}

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

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> p[i].F >> p[i].S;
		vec.pb(p[i].S);
	}

	sort(p, p + n);
	sort(vec.begin(), vec.end());

	int mx = 0;
	for (int i = 0; i < n; i++)
	{
		mx = max(mx, p[i].S);
		R[i] = lower_bound(vec.begin(), vec.end(), mx) - vec.begin() + 1;
	}

	int mn = p[n - 1].S;
	for (int i = n - 1; i >= 0; i--)
	{
		mn = min(mn, p[i].S);
		L[i] = lower_bound(vec.begin(), vec.end(), mn) - vec.begin();
	}


	int sum = 1, p = 0;
	dp[0] = 1;

	for (int i = 0; i < n; i++)
	{
		while (p < L[i]) add(sum, mod - dp[p]), p++;

		int val = sum;

		add(sum, val) ;
		add(dp[R[i]], val);
	}

	cout << dp[n] << '\n';
}


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

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

    vector<int> divisers;
    for(int c=1;c*c<=m;c++){
        if(m%c==0){
            divisers.push_back(c);
            if(m/c!=c) divisers.push_back(m/c);
        }
    }

    sort(divisers.begin(), divisers.end());
    reverse(divisers.begin(), divisers.end());

    for(auto it:divisers){
        if(n<=m/it){
            cout<<it<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
ans = 0
condition = [0 for i in range(n)]
for i in range(n):
    condition[i] = 0
    for j in range(m):
        condition[i] += a[i][j]*b[j]
    condition[i] += c
print(len([i for i in condition if i > 0]))


Measured memory_bytes: 3064
import sys

def flatten(data):
    for item in data:
        if hasattr(item, '__iter__'):
            for element in flatten(item):
                yield element
        else:
            yield item

n = int(sys.stdin.readline())
preorder = list(map(int, sys.stdin.readline().split()))
inorder = list(map(int, sys.stdin.readline().split()))

def eq(a, b):
    if type(a)!=type(b):  return False   
    if type(a)==list:     return set(flatten(a))== set(flatten(b)) 
    return a==b   

while len(preorder)>1:
    for i in range(len(preorder)-3,-2,-1):
        seq = preorder[i:i+3]
        for j in range(len(inorder)-3,-2,-1):
            if type(preorder[i+1])==int:
                if eq(preorder[i+1], inorder[j+1]) and eq(preorder[i+2], inorder[j+2]):
                    
                    preorder[i+1:i+3] = [[preorder[i+1], 0, preorder[i+2]]]
                    inorder[j+1:j+3]  = [[0, inorder[j+1], inorder[j+2]]]
                    break
                if eq(preorder[i+1], inorder[j+2]) and eq(preorder[i+2], inorder[j+1]):
                    
                    preorder[i+1:i+3] = [[preorder[i+1], preorder[i+2], 0]]
                    inorder[j+1:j+3]  = [[inorder[j+1], inorder[j+2], 0]]
                    break
            if i>=0 and j>=0 and type(preorder[i])==int and eq(preorder[i], inorder[j+1]) and eq(preorder[i+1], inorder[j]) and  eq(preorder[i+2], inorder[j+2]): 
                preorder[i:i+3]=[seq]
                inorder[j:j+3]=[inorder[j:j+3]]
                break
        else:  continue
        break


postorder=[]
def create_postorder(a):
    if type(a)==list:
        for i in [1, 2, 0]: 
            if type(a[i])==list:  create_postorder(a[i])
            elif a[i]>0:          postorder.append(a[i])
    else:  postorder.append(a)
create_postorder(preorder[0])
print(' '.join(map(str, postorder)))


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

bool check(vi &a, int k, int lm){
    ll cnt = 0;
    for(auto x : a){
        //x/w <= lm => w >= x/lm
        int w = x/lm;
        if(x%lm != 0) w++;
        cnt += (w-1);
        if(cnt > k) return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, i;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    int lo = 1;
    int hi = *max_element(all(a));
    int md;
    while(lo < hi){
        md = lo + (hi - lo)/2;
        bool ok = check(a, k, md);
        if(ok){
            hi = md;
        }else{
            lo = md+1;
        }
    }
    cout << lo << "\n";
    return 0;
}


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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnInsert(StNode*& rpoRoot, StNode* poNewMe)
{
  StNode*  poParnt = nullptr;
  StNode** ppoNode = &rpoRoot;

  while (*ppoNode)
  {
    poParnt = *ppoNode;
    if (poNewMe->m_nKey < poParnt->m_nKey)
      ppoNode = &poParnt->m_poLeft;
    else
      ppoNode = &poParnt->m_poRigt;
  }
  poNewMe->m_poParnt = poParnt;
  *ppoNode = poNewMe;
}

StNode* fnFind(StNode* poRoot, int nNo)
{
  StNode* poNode = poRoot;
  while (poNode)
    if (nNo == poNode->m_nKey)
      return poNode;
    else if (nNo < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;

  return nullptr;
}

void fnInOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnPreOrder(StNode* poNode)
{
  if (!poNode)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'f')
    {
      int nNo;
      cin >> nNo;
      if (fnFind(rpoRoot, nNo))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
  return 0;
}

Measured memory_bytes: 21860
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	int ans=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++){
		if(c%i==0){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
	

Measured memory_bytes: 3124
#include <stdio.h>
#include <math.h>

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(((a%2==0)&&(b%2==0))||((a%2==1)&&(b%2==1)))printf("%d",(a+b)/2);
  else printf("IMPOSSIBLE");
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  if(n==3){
    cout<<"2 5 63"<<endl;
    return 0;
  }
  if(n==4){
    cout<<"2 5 20 63"<<endl;
    return 0;
  }
  fr(i,n/8){
    cout<<12*i+2<<" "<<12*i+3<<" "<<12*i+4<<" "<<12*i+6<<" "<<12*i+8<<" "<<12*i+9<<" "<<12*i+10<<" "<<12*i+12<<" ";
  }
  if(n%8==1){
    cout<<12*(n/8+1);
  }
  if(n%8==2){
    cout<<12*(n/8+1)-6<<" "<<12*(n/8+1);
  }
  if(n%8==3){
    cout<<12*(n/8)+2<<" "<<12*(n/8)+4<<" "<<12*(n/8+1);
  }
  if(n%8==4){
    cout<<12*(n/8)+2<<" "<<12*(n/8)+4<<" "<<12*(n/8)+8<<" "<<12*(n/8)+10;
  }
  if(n%8==5){
    cout<<12*(n/8)+2<<" "<<12*(n/8)+3<<" "<<12*(n/8)+4<<" "<<12*(n/8)+6<<" "<<12*(n/8)+9;
  }
  if(n%8==6){
    cout<<12*(n/8)+2<<" "<<12*(n/8)+3<<" "<<12*(n/8)+4<<" "<<12*(n/8)+6<<" "<<12*(n/8)+9<<" "<<12*(n/8)+12;
  }
  if(n%8==7){
    cout<<12*(n/8)+2<<" "<<12*(n/8)+3<<" "<<12*(n/8)+4<<" "<<12*(n/8)+6<<" "<<12*(n/8)+8<<" "<<12*(n/8)+9<<" "<<12*(n/8)+10;
  }
  cout<<endl;
}

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

namespace AtCoder
{
    class Program
    {
        static int LoadInt() { return int.Parse(Console.ReadLine()); }
        static int[] LoadIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }

        static void Main(string[] args)
        {
            var N = LoadInt();
            var array = LoadIntArray();
            var flag = new int[N];
            // ケツから決める（N/2までは決定的）
            for(var i=N-1; i>=N/2; i--)
            {
                flag[i] = array[i];
            }
            for(var i=N/2-1; i>=0; i--)
            {
                var tmp = 0;
                for(var j=i; j<N; j+=i+1)
                {
                    tmp += flag[j];
                }
                if((tmp%2 == 0 && array[i]==1) || (tmp%2==1 && array[i]==0))
                {
                    flag[i] = 1;
                }
            }
            var result = Enumerable.Range(0, N).Where(x => flag[x] == 1).Select(x => x + 1).ToList();
            Console.WriteLine(result.Count);
            if (result.Count > 0)
            {
                Console.WriteLine(string.Join(" ", result));
            }
        }
    }
}


Measured memory_bytes: 34776
n=int(input())
A=list(map(int,input().split()))
B=[abs(i) for i in A]
P=0
for i in A:
    if i<0:P +=1
    elif i==0:print(sum(B));exit()

print(sum(B) if P%2==0 else sum(B)-2*min(B))

Measured memory_bytes: 14284
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int answer = 0;
    double h,w; cin >> h >> w;

    if((int)h == 1 || (int)w == 1){
        cout << 1 << endl;
        return 0;
    }

    double ans = ceil(h/2)*ceil(w/2)+((long long int)h/2)*((long long int)w/2);

    cout << (long long int)ans << endl;
}

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

using namespace std;

int main()

{
    int N, x;

    cin >> N >> x;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a, a + N);
    int count = 0;
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += a[i];
        count += 1;
        if (sum > x)
        {
            break;
        }
    }
    if (sum != x)
    {
        count -= 1;
    }

    cout << count;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int i;
  cin >> a;
  
  if (a >= 100){
    i++;
    if (a >= 110){
      i++;
      if (a == 111){
        i++;
      }
    }else if (a ==101){
      i++;
    }
  }else if (a >= 10){
    i++;
    if (a == 11){
      i++;
    }
  }else{
    if (a > 0){
      i++;
    }
  }
  cout << i << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	switch n % 10 {
	case 0:
		fmt.Println("pon")
	case 1:
		fmt.Println("pon")
	case 2:
		fmt.Println("hon")
	case 3:
		fmt.Println("bon")
	case 4:
		fmt.Println("hon")
	case 5:
		fmt.Println("hon")
	case 6:
		fmt.Println("pon")
	case 7:
		fmt.Println("hon")
	case 8:
		fmt.Println("pon")
	case 9:
		fmt.Println("hon")
	}

}

// ----

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


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

using std :: map;
using std :: pair;
using std :: vector;

#define exec_time() (1.0*clock()/CLOCKS_PER_SEC)
#define fst first
#define snd second

typedef long long LL;
typedef pair<LL, LL> Pll;

template <typename T> inline bool maximum(T &a, T b) { return a < b? a = b, 1 : 0; }
template <typename T> inline bool minimum(T &a, T b) { return a > b? a = b, 1 : 0; }
template <typename T> inline
T read(T &x, T f = 0)
{
	char c = getchar(); x = 0;
	for(; !isdigit(c); c = getchar())
		f |= c == '-';
	for(;  isdigit(c); c = getchar())
		x = x*10 + c-'0';
	return x = f? -x : x;
}

const int N = 3.5e2 + 10;
const int mod = 1e9 + 7;
const LL inf = 1LL << 61;

int n; LL K, a[N];
Pll tmp[N];
map<vector<LL>, vector<Pll> > id;
map<vector<LL>, vector<Pll> > ::iterator it;

void add(int &a, int b)
{
	a += b;
	if(a >= mod) a -= mod;
}

int calc(LL l, LL r)
{
	int res = 0;
	for(int i = 59; i >= 0; --i){
		LL idl = l & (1LL << i);
		LL idr = r & (1LL << i);
		if(idl == idr) res += (l >> i) & 1;
		else
		{
			res += (bool)(l & ((1LL<<i)-1));
			break;
		}
	}
	return res;
}

void Insert(int pos, LL rest)
{
	if(rest < 0) return ;

	LL Mn = inf;
	vector<LL> V;

	for(int i = 1; i <= n; ++i){
		V.push_back(tmp[i].snd - (i <= pos));
		minimum(Mn, V[i-1]);
	}
	if(Mn < 0) return ;

	for(int i = 0; i < n; ++i) V[i] -= Mn;
	std::sort(V.begin(), V.end());
	id[V].push_back(Pll(std::max(0LL, Mn-rest), Mn));

	return ;
}

void Init()
{
	id.clear();

	read(n), read(K);
	for(int i = 1; i <= n; ++i) read(a[i]);
	std::sort(a + 1, a + n + 1);

	for(int k = 0; k <= 60; ++k){
		for(int i = 1; i <= n; ++i){
			tmp[i].fst = a[i] & ((1LL << k) - 1);
			tmp[i].snd = a[i] >> k;
		}

		std::sort(tmp + 1, tmp + n + 1);
		LL l = 0, r = 0;
		int lst = 0;

		for(int cur = 1; cur <= n; cur = lst + 1){
			lst = cur;
			while(lst < n && tmp[lst+1].fst == tmp[cur].fst) ++lst;
			r = tmp[cur].fst;
			Insert(cur-1, K - k - calc(l, r));
			l = r + 1;
		}
	}

	return ;
}

void Work()
{
	int Ans = 0;
	for(it = id.begin(); it != id.end(); ++it){
		vector<Pll> o = it -> snd;
		LL l = 0, r = -1;

		std::sort(o.begin(), o.end());
		for(int i = 0; i < (int)o.size(); ++i){
			if(o[i].fst > r){
				add(Ans, (r - l + 1) % mod);
				l = o[i].fst, r = o[i].snd;
			}
			else maximum(r, o[i].snd);
		}
		add(Ans, (r - l + 1) % mod);
	}
	printf("%d\n", Ans);
}

int main()
{

//	int T; read(T);
//	while(T--){
		Init();
		Work();
//	}

	return 0;
}
//XXX

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    vector<vector<ll>> V(N, vector<ll>(N));
    vector<unordered_set<int> > G(N, unordered_set<int>());
    REP(i, N) {
        REP(j, N) {
            cin >> V[i][j];
        }
    }
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> PQ;
    REP(s, N) {
        vector<ll> dist(N, LLONG_MAX);
        VI parent(N, -1);
        PQ.push({0, s});
        dist[s] = 0;
        while (!PQ.empty()) {
            auto top = PQ.top();
            // debug(top.first, top.second);
            PQ.pop();
            int v = top.second;
            if (top.first > dist[v]) continue;
            REP(i, N) {
                if (i == v) continue;
                ll d = top.first + V[v][i];
                if (d < dist[i]) {
                    PQ.push({d, i});
                    dist[i] = d;
                    parent[i] = v;
                } else if (d == dist[i]) {
                    parent[i] = v;
                }
            }
        }
        // cout << "asdf\n";
        REP(i, N) {
            if (i == s) continue;
            if (dist[i] != V[s][i]) {
                cout << -1 << '\n';
                return 0;
            }
            G[parent[i]].insert(i);
            G[i].insert(parent[i]);
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int v : G[i]) {
            ans += V[v][i];
        }
    }
    cout << ans / 2  << '\n';
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M, p;
  cin >> N >> M >> p;
  vector< int > d(M);
  for(int i = 0; i < M; i++) {
    int a;
    cin >> a;
    d[i] = (a - p + N) % N;
  }
  sort(d.begin(), d.end());
  int ret = min(N - d[0], d[M - 1]);;
  for(int i = 0; i < M; i++) {
    if(i > 0) ret = min(ret, 2 * (N - d[i]) + d[i - 1]);
    if(i < M - 1) ret = min(ret, 2 * d[i] + N - d[i + 1]);
  }
  cout << ret * 100 << endl;
}

Measured memory_bytes: 1252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int L = cin.nextInt();
		string[] s = new string[N];
		for (int i = 0; i < N; i++)
		{
			s[i] = cin.next();
		}
		Array.Sort(s);
		for (int i = 0; i < N; i++)
		{
			Console.Write(s[i]);
		}
		Console.WriteLine();
	}
}

class Scanner
{
	string[] s;
	int i;

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

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

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

using namespace std;
using ll = long long;

constexpr ll kMod = 1e9 + 7;

ll dp[301][301][301];

int main()
{
  int n, m;
  cin >> n >> m;
  dp[0][n - 1][1] = 1;
  for (int i = 0; i < m; ++i)
  {
    for (int j = n; j >= 0; --j)
    {
      for (int k = 1; k <= n; ++k)
      {
        dp[i][j][k] %= kMod;
        dp[i + 1][j][k] += dp[i][j][k] * (n - j - k);
        if (j > 0)
          dp[i + 1][j - 1][k] += dp[i][j][k] * j;
        dp[i + 1][j][n - j] += dp[i][j][k] * k;
      }
    }
  }
  cout << dp[m][0][n] % kMod << endl;
}

Measured memory_bytes: 213248
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
	 int n;
	 cin>>n;
	  vector<int>arr(1000001,0);
	  
	  for(int i=1;i<=100;i++)
	  {
	  	for(int j=1;j<=100;j++)
	  	{
	  		for(int k=1;k<=100;k++)
	  		{
			
	  		  int temp=i*i+j*j+k*k+i*j+i*k+j*k;
	  		 
	  		
	  		   arr[temp]+=1;
	  		
	  	}
		  }
	  }
	  
 for(int i=1;i<=n;i++)
 {
 	 cout<<arr[i]<<endl;
 }
		   
}

			
			
           
    



   



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

const int mod =1000000007;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back

template<typename T, typename U>
inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U>
inline void amax(T &x, U y) { if(x < y) x = y; }

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

int h,w;
vvi dp(1001,vi(1001,-1));
string s[1001];
int solve(int r,int c){
	if(r==1&&c==1)
	return 1;
	if(r<1||c<1)
	return 0;
	if(s[r][c]=='#')
	return 0;
	int & ans=dp[r][c];
	if(ans==-1){
		ans=solve(r-1,c)+solve(r,c-1);
		ans%=mod;
	}
	return ans;
}

int main(){
	cin>>h >>w;
	for(int i=1;i<=h;++i){
		cin>>s[i];
		s[i]='0'+s[i];
	}
	cout<<solve(h,w)<<endl;
    return 0;
}


Measured memory_bytes: 5248
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

// 再帰関数による深さ優先探索
void dfs_visit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;  // 最初の訪問
  for ( v = 0; v < n; v++ ) {
    if ( M[u][v] == 0) continue;
    if ( color[v] == WHITE )
      dfs_visit(v);
  }
  color[u] = BLACK;
  f[u] = ++tt;  // 訪問の完了
}

void dfs() {
  int u;
  // 初期化
  for ( u = 0; u < n; u++ ) color[u] = WHITE;
  tt = 0;

  for ( u = 0; u < n; u++ )
    // 未訪問の u を始点として深さ優先探索
    if ( color[u] == WHITE ) dfs_visit(u);
  for ( u = 0; u < n; u++ )
    printf("%d %d %d\n", u + 1, d[u], f[u]);
}

int main() {
  int u, v, k, i, j;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
    for ( j = 0; j < n; j++ ) M[i][j] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ) {
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 2100