akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = uint64_t;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,tot1 = 0;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; ++i){
    cin >> a[i];
    tot1 ^= a[i];
  }
  for(ll i = 0; i < n; ++i) a[i] &= ~tot1;
  ll rank = 0;
  for(int i = 59; i >= 0; --i){
    ll idx = n;
    for(ll j = rank; j < n; ++j){
      if(a[j]&(1ll<<i)){
        idx = j;
        break;
      }
    }
    if(idx == n) continue;
    if(idx > rank) a[rank] ^= a[idx];
    for(ll j = rank+1; j < n; ++j){
      a[j] = min(a[j],a[j]^a[rank]);
    }
    ++rank;
  }
  ll tot2 = 0;
  for(ll i = 0; i < n; ++i) tot2 = max(tot2,tot2^a[i]);
  cout << tot1+2*tot2;
  return 0;
}

Measured memory_bytes: 1024
#from functools import lru_cache
import sys
from itertools import product,combinations
from functools import reduce,lru_cache
import heapq

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def list_t(l): return vfunc(lambda *args:args)(*l)

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

def factorization(n):
    out={}
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            out.update({i:0})
            while n%i==0:
                out[i]+=1
                n=int(n/i)
    if n != 1: out.update({n:1})
    return out

n=int(reader()[0][0])

dl = vfunc(lambda i:factorization(i))(range(1,n+1,2))
f = lambda d:reduce(lambda a,b:a*b,vfunc(lambda n:d[n]+1)(d)) if len(d)>1 else vfunc(lambda n:d[n]+1)(d)[0] if len(d)==1 else 0
s = vfunc(f)(dl)
#print(s)
print(len(list(filter(lambda a:a==8,s))))


Measured memory_bytes: 68140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i;
		double v1,v2,sum=0,sum1=0,ans,in[]=new double[12];
		double x;
		while(sc.hasNext()){
			String str[]=sc.next().split(",");
			for(i=0;i<12;i++){
				in[i]=Double.parseDouble(str[i]);
			}
			v1=in[10];v2=in[11];
			for(i=0;i<10;i++){
				sum+=in[i];
			}
			x=v1*sum/(v2+v1);
//			System.out.println(sum+" "+v1+" "+v2);
//			System.out.println(x);
			for(i=0;i<10;i++){
				sum1+=in[i];
				if(x<=sum1){
					System.out.println(i+1);
					sum1=0;sum=0;break;
				}
			}
		}//while
	}
}

Measured memory_bytes: 12000
#include<cstring>
#include<cstdio>

using namespace std;

int main(void){
	char st1[128];
	char st2[128];
	int ans = 0;
	
	while(scanf("%s", st1) != EOF){
		int r = strlen(st1);
		
		for(int i = 0; i < r; i++){
			st2[i] = st1[r-i-1];
		}
		st2[r] = '\0';
		if(!strcmp(st1,st2))ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int n,m,k;
  long int a[200001]={0};
  long int b[200001]={0};
  int maxa=0,maxb=0,ans=0;
  int i,j;
  scanf("%d %d %d",&n,&m,&k);
  for(i=1;i<=n;i++)
  {
    scanf("%ld",&a[i]);
    a[i]=a[i]+a[i-1];
    if(a[i]<=k) maxa=i;
  }
  for(i=1;i<=m;i++)
  {
    scanf("%ld",&b[i]);
    b[i]=b[i]+b[i-1];
    if(b[i]<=k) maxb=i;
  }
  for(i=0;i<=maxa;i++)
  {
    for(j=maxb;j>=0;j--)
    {
      if(b[j]<=k-a[i])
      {
        maxb=j;
        break;
      }
    }
    if(ans<i+j) ans=i+j;
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int N; cin >>N;
  vll vx(N),vy(N),vh(N);
  int si=-1;
  rep(i,0,N) {
    cin >>vx[i] >>vy[i] >>vh[i];
    if (0<vh[i]) {si=i;}
  }

  ll resx=-1,resy=-1,resh=-1;
  for (ll x=0;x<=100;x++) {
    for (ll y=0;y<=100;y++) {
      ll h=vh[si]+abs(x-vx[si])+abs(y-vy[si]);
      bool ok=true;
      rep(i,0,N) {
        if (0<vh[i] && h-vh[i]!=abs(x-vx[i])+abs(y-vy[i])) {ok=false;}
        if (vh[i]==0 && (abs(x-vx[i])+abs(y-vy[i]))<h) {ok=false;}
      }
      if (ok) {resx=x,resy=y,resh=h;}
    }
  }

  cout <<resx <<" " <<resy <<" " <<resh <<'\n';
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

int main() {
    ll l, r;
    cin >> l >> r;
    l--; r++;

    //k桁で条件を満たす通り数 上位に1がある L<x y<Rが上位だけで確定
    //00,10,11
    //h=0のとき00のh=0と11のh=1 h=1のときh=1
    //i=0のときl=0なら11のi=1と10,00のi=0、l=1なら11のi=0 i=1のときi=1
    //j=0のときr=1なら00のj=1と10,11のj=0、r=0なら00のj=0 j=1のときj=1

    ll dp[61][2][2][2] = {};
    dp[0][1][1][1] = 1;

    for (int k = 0; k < 60; k++) {
        ll m = 1LL << k;
        for (int h = 0; h < 2; h++) {
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 2; j++) {
                    int b = 0b111;
                    if (h == 0) b &= 0b101;
                    if (i == 0 && l & m) b &= 0b100;
                    if (j == 0 && !(r & m)) b &= 0b001;

                    ll t = 0;
                    if (b & 0b001) t += dp[k][h][i][j + (j == 0 && (r & m))];
                    if (b & 0b010) t += dp[k][h][i][j];
                    if (b & 0b100) t += dp[k][1][i + (i == 0 && !(l & m))][j];
                    
                    dp[k + 1][h][i][j] = t % P;
                }
            }
        }
    }

    cout << dp[60][0][0][0] << endl;

    return 0;
}

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

using namespace std;

struct Dice {
    int s[6];

    int &top() { return s[0]; }

    int &south() { return s[1]; }

    int &east() { return s[2]; }

    int &west() { return s[3]; }

    int &north() { return s[4]; }

    int &bottom() { return s[5]; }

    void roll(char c) {
        string b("EWNSRL");
        int v[6][4] = {{0, 3, 5, 2},
                       {0, 2, 5, 3},
                       {0, 1, 5, 4},
                       {0, 4, 5, 1},
                       {1, 2, 4, 3},
                       {1, 3, 4, 2}};
        for (int k = 0; k < 6; ++k) {
            if (b[k] != c) continue;
            int t = s[v[k][0]];
            s[v[k][0]] = s[v[k][1]];
            s[v[k][1]] = s[v[k][2]];
            s[v[k][2]] = s[v[k][3]];
            s[v[k][3]] = t;
        }
    }
};

int main() {
    Dice d;
    for (int i = 0; i < 6; ++i) cin >> d.s[i];
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) d.roll(s[i]);
    cout << d.top() << endl;
    return 0;
}


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

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;

static const int INF = 1LL << 60;
static const int MAX_N = 20005;

int n, m, k, A[MAX_N], dp[MAX_N];

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

    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    fill(dp, dp + MAX_N, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        int tmax = 0, tmin = INF;
        for (int j = 1; j <= m && i + j <= n; ++j) {
            tmax = max(tmax, A[i + j - 1]);
            tmin = min(tmin, A[i + j - 1]);
            dp[i + j] = min(dp[i + j], dp[i] + k + j * (tmax - tmin));
        }
    }

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

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    string judge = "APPROVED";
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        if (A.at(i) % 2 == 0) {
            if (A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
                judge = "DENIED";
                break;
            }
        }
    }
    cout << judge << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{   
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int k,s,count=0;

	cin>>k >> s;
	for(int x=0;x<=k;x++)
	
    {
    	for(int y=0;y<=k;y++)
          {
    	   int z=s-x-y;
    	   {
    	   		if(z<=k && z>=0)
    			{
    				count++;
    			}
    	   }
          }
    	   
    
    }
    cout << count<<"\n" ;
}


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

const int MAX_BI_DIGIT = 60;
const long MOD_CONST = 1000000007;


using namespace std;
int main()
{
	int n;
	
	cin >> n;

	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		//printf("%lld\n", a[i]);
	}

	long long sum = 0;
	for (int j = 0; j < MAX_BI_DIGIT;j++) {
		long long cnt_0 = 0;
		long long cnt_1 = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] >> j & 1) {
				cnt_1++;
			}
			else {
				cnt_0++;
			}

		}
		//printf("%lld %lld\n", (1LL<<j), (1LL << j)*(cnt_0 * cnt_1) );
		long long num = cnt_0;
		num = (num* cnt_1) % MOD_CONST;
		for (int i = 0; i < j; i++) {
			num = (num * 2) % MOD_CONST;
		}
		sum = (sum + num) % MOD_CONST;
		
		//printf("%ld %ld\n", sum,(sum < MOD_CONST));
	}
	sum %= MOD_CONST;
	
	printf("%lld\n", sum);
	
	return 0;


}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while (x != NIL){
    y = x;
    if (z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
    z->parent = y;
    if (y == NIL)
      root = z;
    else if (z->key < y->key)
      y->left = z;
    else
      y->right = z;
}

void inorder(Node u){
  if (u == NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25124
#include <iostream>
#include <string>
#include <map>
using namespace std;

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

  map<char, char> m, n;
  for(int i = 0; i < s.size(); i++){
    if(m.find(s[i]) == m.end()){
      m[s[i]] = t[i];
    }else{
      if(m[s[i]] != t[i]){
        cout << "No" << endl;
        return 0;
      }
    }

    if(n.find(t[i]) == n.end()){
      n[t[i]] = s[i];
    }else{
      if(n[t[i]] != s[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 776
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;

    return 0;
}

Measured memory_bytes: 3652
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()

	ans := uint(100*(n+18*m)) << uint(m)
	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>

#define INF 1 << 29

using namespace std;

typedef pair<int,int> s;

char a[11];

int main(){
  scanf("%s", a);
  if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I'){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int visited[200000] = {};

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    ll A[N]; rep(i, N){cin >> A[i]; A[i]--;}
    int cnt = 0, now = 0, heiro_len;
    while(true){
        cnt++;
        visited[now] = cnt;
        if(visited[A[now]]){
            heiro_len = (cnt+1) - visited[A[now]];
            now = A[now];
            break;
        }
        else now = A[now];
    }
    if(K <= cnt){
        int ans = 0;
        rep(i, K){
            ans = A[ans];
        }
        cout << ans+1 << endl;
    }
    else{
        K -= cnt;
        K %= heiro_len;
        int ans = now;
        rep(i, K) ans = A[ans];
        cout << ans+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5944
fun main(args: Array<String>) = println(run {
    val s = readLine()!!.map { it-'0' }
    val n = s.size
    val wb = IntArray(n){ (it+1)%2 }
    val bw = IntArray(n){ it%2 }
    val max1 = s.indices.count { i -> s[i]!=wb[i] }
    val max2 = s.indices.count { i -> s[i]!=bw[i] }
    Math.min(max1, max2)
})

Measured memory_bytes: 40808
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

#define rep(i,k,N) for(ll i=k;i<N;i++)

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll X;
    cin>>X;
    vector<pair<ll,ll>> a;
    a.PB(MP(0,0));
    rep(i,1,1000){
        a.PB(MP(i*i*i*i*i,i));
        a.PB(MP(-i*i*i*i*i,-i));
    }
    sort(all(a));
    reverse(all(a));
    rep(i,0,a.size()){
        rep(j,i,a.size()){
            if(a[i].first-a[j].first == X){
                cout<<a[i].second<<" "<<a[j].second;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3688
from collections import deque
S=list(map(lambda x: 1 if x=="T" else 0,input()))

q=deque()

for i in S:

    if i:
        if (not q) or q[-1]!=0:
            q.append(i)
        elif q and q[-1]==0:
            q.pop()
    else:
        q.append(i)
print(len(q))

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

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

  
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  
  if( a<b ) {
    cout << "Yes" << endl;
  }
  else {
    cout <<"No" << endl;
  }
}


Measured memory_bytes: 256
import kotlin.math.pow

fun main() {
    var inLine = readLine()!!.split(" ").map(String::toInt)
    val h = inLine[0]
    val w = inLine[1]
    val limitk = inLine[2]
    val cList = mutableListOf<MutableList<String>>()
    var result = 0

    for(i in 1 .. h){
        var tmpList = readLine()!!.split("")
        tmpList = tmpList.drop(1).dropLast(1)
        cList.add(tmpList.toMutableList())
    }

    val ptn = 2.0.pow((h + w)).toInt()
    val digit = h + w

    for(i in 0 until ptn){
        val hwStr = (("%"+digit+"s").format(i.toString(2))).replace(" ","0")
        var bCnt = 0
        for(j in 0 until h){
            if(hwStr[j] != '1'){
                for(k in 0 until w){
                    if(hwStr[h + k] != '1'){
                        if(cList[j][k] == "#"){
                            bCnt += 1
                        }
                    }
                }
            }
        }
        if(bCnt == limitk){
            result++
        }
    }

    println(result)
}

Measured memory_bytes: 56196
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=5;
        int num[]=new int[5];
        for(int i=0;i<n;i++)num[i]=sc.nextInt();
        int k=sc.nextInt();
        boolean po=true;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(Math.abs(num[i]-num[j])>k)po=false;
            }
        }
        System.out.println((po)?"Yay!":":(");
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define int long long
#define M 1000000007
using namespace std;
int32_t main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	int a;
	string s;
	cin>>a>>s;
	if (a<3200)
		cout<<"red";
	else
		cout<<s;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
#define int ll
using namespace std;
#define rep(i,n) for(int i=0; i<n;i++)
#define INF 1e9
int MOD =INF+7;
signed main(){
    int n=0;
    string s;
    cin>>s;
    rep(i,s.size())if(s[i]=='1')n++;
    cout<<n<<endl;
}


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

using namespace std;

typedef long long ll;

int a[100010];
set <int> s;

int main() {
  #ifdef HOME
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
 
  int n, x, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x >= 3200) {
      ans++;
    } else {
      if (x >= 1 && x <= 399) {
        s.insert(1);
      } else if (x >= 400 && x <= 799) {
        s.insert(2);
      } else if (x >= 800 && x <= 1199) {
        s.insert(3);
      } else if (x >= 1200 && x <= 1599) {
        s.insert(4);
      } else if (x >= 1600 && x <= 1999) {
        s.insert(5);
      } else if (x >= 2000 && x <= 2399) {
        s.insert(6);
      } else if (x >= 2400 && x <= 2799) {
        s.insert(7);
      } else if (x >= 2800 && x <= 3199) {
        s.insert(8);
      }
    }
  }
  int sz = s.size();
  if (sz == 0) {
    cout << 1 << " " << ans << endl;
    return 0;  
  }
  cout << sz << " " << ans + sz << endl;
    
  #ifdef HOME
    fprintf(stderr, "Time take:- %.3fs\n", (double) clock() / CLOCKS_PER_SEC);
    fflush(stderr);
  #endif
  return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	for (int i = 0; i < m; i++) cin >> x[i];
	sort(x.begin(), x.end());
	vector<int> dif(m - 1);
	for (int j = 0; j < m - 1; j++) dif[j] = x[j + 1] - x[j];
	sort(dif.begin(), dif.end());
	int ans = 0;
	for (int k = 0; k < m - n; k++) ans = ans + dif[k];
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n, m, Q;
    cin >> n >> m >> Q;
    vi l(m), r(m);
    rep(i, m) {
        cin >> l[i] >> r[i];
        --l[i];
        --r[i];
    }
    vi p(Q), q(Q);
    rep(i, Q) {
        cin >> p[i] >> q[i];
        --p[i];
        --q[i];
    }

    vvi hyou(n, vi(n));
    rep(i, m) {
        hyou[l[i]][r[i]]++;
    }
    /*rep(i, n) {
        rep(j, n) {
            cout << hyou[i][j] << ' ';
        }
        cout << endl;
    }*/


    vvi sum(n, vi(n));
    rep(j, n) {
        for(int i = j; i >= 0; --i) {
            if(i == j) {
                sum[i][j] = hyou[i][j];
            } else if(i+1 == j) {
                sum[i][j] = sum[i+1][j] + sum[i][i] + hyou[i][j];
            } else {
                sum[i][j] = sum[i+1][j] + sum[i][j-1] + hyou[i][j] - sum[i+1][j-1];
            }
        }
    }

    //cout << endl;

    /*rep(i, n) {
        rep(j, n) {
            cout << sum[i][j] << ' ';
        }
        cout << endl;
    }

    cout << 99 << endl;*/

    rep(i, Q) {
        cout << sum[p[i]][q[i]] << '\n';
    }
}

Measured memory_bytes: 5248
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, M = MAP()
a = [INT() for _ in range(M)]

check = [0]*(N+1)
for i in a:
	check[i] = 1

dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
for i in range(2, N+1):
	for j in range(1, 3):
		if not check[i-j]:
			dp[i] = (dp[i] + dp[i-j])%mod

print(dp[N])


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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int n, m;
struct{
	Int p, d;
} uf[112345];

int main(){
	cin >> n >> m;
	RC(i, n){
		uf[i].p = i;
	}
	RC(i, m){
		Int l, r, d;
		cin >> l >> r >> d;
		--l;
		--r;
		while(uf[l].p != uf[uf[l].p].p){
			uf[l].d += uf[uf[l].p].d;
			uf[l].p = uf[uf[l].p].p;
		}
		while(uf[r].p != uf[uf[r].p].p){
			uf[r].d += uf[uf[r].p].d;
			uf[r].p = uf[uf[r].p].p;
		}
		if(uf[l].p == uf[r].p){
			if(uf[l].d + d != uf[r].d){
				cout << "No" << endl;
				return 0;
			}
		}else{
			uf[uf[r].p].d = d + uf[l].d - uf[r].d;
			uf[uf[r].p].p = uf[uf[l].p].p;
		}
	}
	cout << "Yes" << endl;

}


Measured memory_bytes: 1792
n, k = map(int, input().split())
ans = [0]*k
mod = 10**9 + 7
red = n-k

def comb(n, r):
    res = 1
    for i in range(1, r+1):
        res = res*(n-i+1) % mod
        res = res*pow(i, mod-2, mod) % mod
    return res


for i in range(k):
    red = n-k - i
    if red < 0:
        print(0)
    else:
        sikiri = i + 1
        print(comb(k-1, i)*comb(sikiri + red, red) % mod)


Measured memory_bytes: 41968
s = input()
N = len(s)

a = ord('a')

check = [[False for j in range(26)] for i in range(N)]

for i in range(N):
    check[i][ord(s[i])-a] = True

for j in range(26):
    same = True
    for i in range(N):
        if not check[i][j]:
            same = False
    if same:
        print(0)
        exit()

ans = 1
while True:
    for i in range(N-ans):
        for j in range(26):
            if check[i][j] or check[i+1][j]:
                check[i][j] = True
    for j in range(26):
        same = True
        for i in range(N-ans):
            if not check[i][j]:
                same = False
        if same:
            print(ans)
            exit()
    ans += 1



Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    long N= Long.parseLong(sc.next());
    long ans =0;
    ans = (N / 11) * 2;
    if (N % 11 >= 1 && N % 11 <= 6) {
      ans++;
    } else if (N % 11 >= 7) {
      ans += 2;
    }
    System.out.print(ans); 
  }
}

Measured memory_bytes: 22868
# coding: utf-8

n = int(input())
ws = [input() for _ in range(n)]
flg = True

if len(ws) == len(set(ws)):
    for i in range(1, n):
        if ws[i][0] != ws[i-1][-1]:
            flg = False
else:
    flg = False


print('Yes' if flg else 'No')


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

int main() {
    string s;
    cin >> s;
    vector<int> cnt(26, 0);
    rep(i,s.size()){
        cnt[s[i]-'a'] = 1;
    }
    rep(i,26){
        if(cnt[i]!=1) {
            printf("%c\n", 'a'+i);
            return 0;
            }
    }
    cout << "None" << endl; 
    return 0;
}

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

int main(){
int n,x,a[101],ans=0;
cin>>n>>x;
for(int i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
for(int i=0;i<n-1;i++){
if(a[i]>x)break;
x-=a[i];
ans++;}
cout<<(x==a[n-1]?ans+1:ans);}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int a,count=0;
  cin >> a;
  while(a) count+=a%10,a/=10;
  cout << count << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  rep(i, n){
    int a;
    cin >> a;
    if(a % 2 == 1){
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
}

Measured memory_bytes: 3636
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
q=gi
ar=[]
ans=[]
q.times do
  inp=gsmi
  case inp[0]
  when 0
    ar<<inp[1]
  when 1
    ans<<ar[inp[1]]
  when 2
    ar.pop
  end
end
puts ans


Measured memory_bytes: 8536
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;

int main(){ 
int N,sum[2000];
  cin >> N;
  
  int a=0;
  for(int i=2;i<=N;i++){
    a = i;
    for(int j=2;j<=N;j++){
      if(a==0){
        break;
      }
      while(a%j==0){
        a/=j;
        sum[j] += 1;
      }
    }
  }
  
  long long b=1;
  for(int i=2;i<=N;i++){
    b=b*(sum[i]+1)%1000000007;
  }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int ans;
	int n, t, e;
	int i;
	int x;
	
	ans = -1;
	scanf("%d %d %d", &n, &t, &e);
	
	for (i = 0; i < n; i++){
		scanf("%d", &x);
		
		if (t % x <= e || t % x >= x - e){
			ans = i + 1;
		}
	}
	
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int a,b,k;
  cin >> a >> b >> k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      a /= 2;
      b += a;
    } else {
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}



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

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

    int flag = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(i * (m - j) + j * (n - i) == k){
                flag = 1;
                break;
            }
        }
    }

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

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

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

    int n;
    cin >> n;
    map<int, int> ct;
    vector<ii> v;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ct[x]++;
    }
    for(auto p : ct)
        v.push_back(p);
    if(v.size() >= 4 || (v.size() == 1 && v[0].first != 0)) {
        cout << "No\n";
        return 0;
    }
    int a, ca, b, cb, c, cc;
    a = v[0].first;
    ca = v[0].second;
    if(v.size() == 2) {
        if(a != 0 || v[1].second != 2*v[0].second) {
            cout << "No\n";
            return 0;
        }
    }
    if(v.size() == 3) {
        b = v[1].first;
        c = v[2].first;
        cb = v[1].second;
        cc = v[2].second;
        if(((a ^ b) != c) || ca != cb || ca != cc) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 4988
s=input()
N = s.count("N")
E = s.count("E")
W = s.count("W")
S = s.count("S")
if ((N==S==0 and E>0 and W>0)
    or (E==W==0 and N>0 and S>0)
    or (N>0 and S>0 and E>0 and W>0)):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
// Shift-JIS（シフトジス）

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

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main()
{
    int N; cin >> N;
    bool f = false;

    for (int i = 0; i < 26; i++)
    {
        for (int j = 0; j < 15; j++)
        {
            if (4 * i + 7 * j == N)
            {
                f = true;
            }
        }
    }

    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const int LIM = 3;

#define LLD_SPEC "%lld"

int main() {
    int h, w;
    scanf("%d%d", &h, &w);

    int n;
    scanf("%d", &n);

    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i], &b[i]);
        --a[i];
        --b[i];
    }

    set<pair<int, int>> filled;
    for (int i = 0; i < n; ++i) {
        filled.insert(make_pair(a[i], b[i]));
    }

    vector<long long> result(LIM * LIM + 1, 0);

    set<pair<int, int>> used;

    for (int i = 0; i < n; ++i) {
        int x = a[i];
        int y = b[i];
        for (int dx = -(LIM - 1); dx <= 0; ++dx) {
            for (int dy = -(LIM - 1); dy <= 0; ++dy) {
                int nx = x + dx;
                int ny = y + dy;

                if (nx >= 0 && nx + LIM <= h && ny >= 0 && ny + LIM <= w && used.find(make_pair(nx, ny)) == used.end()) {
                    used.insert(make_pair(nx, ny));

                    int curCount = 0;
                    for (int tx = 0; tx < LIM; ++tx) {
                        for (int ty = 0; ty < LIM; ++ty) {
                            if (filled.find(make_pair(nx + tx, ny + ty)) != filled.end()) {
                                ++curCount;
                            }
                        }
                    }

                    ++result[curCount];
                }
            }
        }
    }

    result[0] = 1LL * (h - LIM + 1) * (w - LIM + 1);
    for (int i = 1; i < (int) result.size(); ++i) {
        result[0] -= result[i];
    }

    for (int i = 0; i < (int) result.size(); ++i) {
        printf(LLD_SPEC "\n", result[i]);
    }

    return 0;
}

Measured memory_bytes: 47872
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;



int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int32 n, a, b;
	cin >> n >> a >> b;
	cout << min(a*n, b) << endl;
	return 0;
}

Measured memory_bytes: 256
while(1):
    [m,n]=[int(x) for x in raw_input().split()]
    if m==0:
        break
    else:
        truenum=0
        player=[x for x in range(1,m+1)]
        for i in range(n):
            shout=raw_input()
            if len(player)>1:
                pnow=player.pop(0)
                truenum=truenum+1
                if truenum%15==0:
                    if shout=="FizzBuzz":
                        player.append(pnow)
                elif truenum%5==0:
                    if shout=="Buzz":
                        player.append(pnow)
                elif truenum%3==0:
                    if shout=="Fizz":
                        player.append(pnow)
                else:
                    if shout==str(truenum):
                        player.append(pnow)
        print " ".join([str(x) for x in sorted(player)])

Measured memory_bytes: 4588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 a,sum=0LL;
    for(i64 i=0LL;i<4LL;++i){
        scanf("%lli",&a);
        sum+=a;
    }
    printf("%lli\n%lli\n",sum/60LL,sum%60LL);
    return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
const int N=5005;
int a[N],f[N],dp[N][N],n,b[N];
int cmp(int x,int y){
	return min(a[x],a[y]-b[x])>min(a[y],a[x]-b[y]);
}
signed main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),f[i]=i;
	sort(f+1,f+n+1,cmp);
	for (int i=0;i<N;i++)
		for (int j=1;j<N;j++)dp[i][j]=2e9+1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=i;j++){
			dp[i][j]=dp[i-1][j];
			if (a[f[i]]>=dp[i-1][j-1])dp[i][j]=min(dp[i][j],dp[i-1][j-1]+b[f[i]]);
		}
	for (int i=n;i>=0;i--)
		if (dp[n][i]<=2e9){
			printf("%d\n",i);
			return 0;
		}
}

Measured memory_bytes: 98304
#include<iostream>
#include<algorithm>
using namespace std;
int s[501501],a[1001],n,m,t;
int BNS(int key){
	int ret=0,ran=t/2,nse=0;
	while(true){
		nse+=ran;
		if(s[nse]<=key)ret=max(ret,nse);
		else nse-=ran;
		ran/=2;
		if(!ran)break;
	}
	return ret;
}
int main(){
	while(true){
	cin>>n>>m;
	if(!n&&!m)break;
	a[0]=0,t=1,s[0]=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		for(int j=0;j<=i;j++)if(a[i]+a[j]<=m)s[t]=a[i]+a[j],t++;
	}
	sort(s,s+t);
	int ans=0;
	for(int i=0;i<t;i++)ans=max(ans,s[i]+s[BNS(m-s[i])]);
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 5068
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main (){
    long long r,d,x;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++){
            long long y=r*x-d;
        cout<<y<<endl;
        x=y;
    }
      return 0;
}


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

int main(){
    int n;
    int x[101];
    int y[101];
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 0; i < n; i++) cin >> y[i];
    
    long long int d1 = 0, d2 = 0, d3 = 0;
    int max = -1;
    for(int i = 0; i < n; i++){
        d1 += abs(x[i]-y[i]);
        d2 += pow(x[i]-y[i], 2);
        d3 += pow(abs(x[i]-y[i]), 3);
        if(max < abs(x[i]-y[i])) max = abs(x[i]-y[i]);
    }
    
    printf("%.6f\n", (double)d1);
    printf("%.6f\n", sqrt(d2));
    printf("%.6f\n", pow(d3, 1.0/3.0));
    printf("%.6f\n", (double)max);
    
    return 0;
}


Measured memory_bytes: 3348
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    from collections import Counter
    C=Counter(map(int,input().split()))
    l=len(C)
    if l<=k:
        print(0)
        return
    v=sorted(list(C.values()))
    print(sum(v[:l-k]))
resolve()

Measured memory_bytes: 92720
import sys
import collections

sys.setrecursionlimit(10**6)
MOD = pow(10,9)+7

def kaijo(n):
    if n <= 1:
        return 1
    else:
        return n * kaijo(n-1)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    N = int(input())
    if N == 1:
        print(1)
        return
    counter = collections.Counter([])
    for n in range(N, 0, -1):
        counter += collections.Counter(prime_factorize(n))
    items = list(zip(*counter.items()))
    ans = 1
    for i in items[1]:
        ans *= i+1
        ans %= MOD
    print(ans)

    #n = kaijo(N)
    #print(n)
    #m = make_divisors(n)
    ##m.sort()
    #print(m)
    #print(len(m)%MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main()
{
	scanf("%lld%lld",&n,&m);
	if(m%2==1)
	{
		printf("%lld\n",(n/m)*(n/m)*(n/m));
	}else
	{
		if((n/m)*m+m/2<=n)
		{
			printf("%lld\n",((n/m)+1)*((n/m)+1)*((n/m)+1)+(n/m)*(n/m)*(n/m));
		}else
		{
			printf("%lld\n",(n/m)*(n/m)*(n/m)*2);
		}
	}
}

Measured memory_bytes: 3788
n, k = map(int, input().split())

have = [False] * n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        have[j-1] = True

count = 0
for i in range(n):
    if not have[i]:
        count += 1
print(count)

Measured memory_bytes: 67732
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    vector<bool>hoge(26,true);
    string ans="abcdefghijklmnopqrstuvwxyz";
    rep(i,s.size())hoge[s[i]-'a']=false;
    rep(i,hoge.size())if(hoge[i]){cout<<ans[i]<<endl; return 0;}
    cout<<"None"<<endl;
}

Measured memory_bytes: 512
import sys;input=sys.stdin.readline
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
mod=998244353
X = []
rs = []
for _ in range(K):
    l, r = map(int, input().split())
    rs.append((l, r))
st = Bit(N)
st.add(1, 1)
for i in range(2, N+1):
    t = 0
    for l, r in rs:
        if i-l<1:
            continue
        t += st.sum(i-l) - st.sum(max(i-r-1, 0))
        t%=mod
    st.add(i, t)
print((st.sum(N)-st.sum(N-1))%mod)


Measured memory_bytes: 75644
#include <iostream>
using namespace std;
int main(void){
    int n,q;
    cin >> n;
    int S[n];
    for(int i=0;i<n;i++){
        cin >> S[i];
    }
    cin >> q;
    int T[n];
    for(int i=0;i<q;i++){
        cin >> T[i];
    }
    
    int count = 0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(T[i]==S[j]){
                count++;
                break;
            }
        }
    }
    cout << count << endl;
    
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int f[N][2],pre[N][2];char s[N];
void solve(int n,int pos){
	if(n==0) return;
	solve(n-1,pre[n][pos]);
	if(pos==0) cout<<"P";
	else cout<<"D";
}
int main(){
	cin>>(s+1);int n=strlen(s+1);
	for(int i=1;i<=n;++i){
		if(s[i]=='P'){
			f[i][0]=max(f[i-1][0],f[i-1][1]);
			pre[i][0]=(f[i][0]==f[i-1][1]);
			f[i][1]=-N;
		}
		if(s[i]=='D'){
			f[i][0]=-N;
			f[i][1]=max(f[i-1][0]+2,f[i-1][1]+1);
			pre[i][1]=(f[i][1]==f[i-1][1]+1);
		}
		if(s[i]=='?'){
			f[i][0]=max(f[i-1][0],f[i-1][1]);
			pre[i][0]=(f[i][0]==f[i-1][1]);
			f[i][1]=max(f[i-1][0]+2,f[i-1][1]+1);
			pre[i][1]=(f[i-1][1]+1==f[i][1]);
		} 
	}
	//cout<<f[n][1]<<endl;
	if(max(f[n][0],f[n][1])==f[n][0]){
		solve(n,0);
	}
	else solve(n,1);
	return 0;
}

Measured memory_bytes: 10028
import sys
import numpy as np 
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
from itertools import permutations

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, R = I[:3]
r = I[3:3+R] - 1
a, b, c = I[3+R:].reshape(-1, 3).T
a -= 1; b -= 1
graph = csr_matrix((c, (a, b)), shape=(n, n))

def main():
    dist = floyd_warshall(graph, directed=False).astype(np.int64)
    *perms, = permutations(r)
    perms = np.array(perms)
    res = dist[perms[:, :-1], perms[:, 1:]]
    ans = np.amin(np.sum(res, axis=1))
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 26820
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a; cin >> a;
    vector<char> s(26);
    s = {'q','w','e','r','t','y','u','i','o','p','l','k','j','h','g','f','d','s','a','z','x','c','v','b','n','m'};
    bool ans = false;
    for(int i = 0; i < 26;i++){
        if(a == s.at(i)){
         ans = true;
         break;
        }
    }
    if(ans) cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int cnt=0,sum=0;
    cin>>s;
    reverse(s.begin(), s.end());
    for(int i=0; i<s.size()-1; ){
        if(s[i]=='B'){
            char temp = 'W';
            for(int j=i+1; j<s.size(); j++){
                if(s[j]==temp){cnt++;i=j;break;}
                else{i=j;}
            }
        }
        else if(s[i]=='W'){
            char temp = 'B';
            for(int j=i+1; j<s.size(); j++){
                if(s[j]==temp){cnt++;i=j;break;}
                else {i=j;}
            }
        }
    }
   cout<<cnt<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //string s1,s2,s3;
    long long int k,n,m,i,a[200010],f=0,j,min,x,sum;
    double d;
    cin>>n>>k;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }sum=0;
    for(i=0;i<k;i++)
    {
        sum+=a[i];
    }
    min = sum;
    x = 0;
    for(i=1;i<n-k+1;i++)
    {
        sum = sum-a[i-1]+a[i-1+k];
        if(min<sum)
        {
            min = sum;
            x = i;
        }
    }d = 0;
    for(i=x;i<x+k;i++)
    {
        d = d+(a[i]+1)*1.0/2;
    }
    printf("%.12lf\n",d);
    return 0;
}





Measured memory_bytes: 1792
#ifndef DEBUG
#pragma GCC optimize("O3,unroll-loops")
#pragma loop_opt(on)
#endif
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define cerr
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define All(v) v.begin(),v.end()
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MOD = 1e9+7;

signed main() {
    FAST;

    int n, d, x;
    cin >> n >> d >> x;
    Fr(i, 0, n) {
        int a;
        cin >> a;
        x += (d-1)/a+1;
    }
    cout << x << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000

main()
{
  int i, j, k, v, N, A[MAX];

  scanf("%d", &N);
  for(i=0; i<N; i++)
    {
      scanf("%d", &A[i]);
    }

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

      while(j >= 0 && A[j] > v)
	{
	  A[j+1] = A[j];
	  j--;
	}
      A[j+1] = v;
      
    }

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

  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
ll modpow(ll n, int k) {
	ll r = 1;
	while (k > 0) {
		if (k&1) (r *= n) %= mod;
		(n *= n) %= mod;
		k >>= 1;
	}
	return r;
}
ll f(int n) {
	return modpow(2, n);
}
int main() {
	int N;
	cin >> N;
	ll res = 1, res0 = 0;
	map<pair<ll,ll>,pair<int,int>> cnt;
	for (int i = 0; i < N; ++ i) {
		ll a, b;
		cin >> a >> b;
		if (b < 0) { a = -a; b = -b; }
		if (a == 0 && b == 0) {
			++ res0;
		} else {
			auto g = abs(gcd(a, b));
			a /= g;
			b /= g;
			if (a <= 0) {
				++ cnt[{b,-a}].second;
			} else {
				++ cnt[{a,b}].first;
			}
		}
	}
	for (auto p : cnt) {
		auto t = f(p.second.first) + f(p.second.second) + mod - 1;
		(res *= t) %= mod;
	}
	res = (res + res0 + mod - 1) % mod;
	cout << res << endl;
}


Measured memory_bytes: 15932