akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC105_D___Candy_Distribution
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0];
            var M = NM[1];
            var Ai = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            var accum = new long[N + 1];
            for (int i = 1; i < N + 1; i++) accum[i] = accum[i - 1] + Ai[i - 1];
            var modMap = new Dictionary<long, long>();
            for (int i = 0; i < N + 1; i++)
            {
                var mod = accum[i] % M;
                if (!modMap.ContainsKey(mod))
                {
                    modMap.Add(mod, 1);
                }
                else
                {
                    modMap[mod]++;
                }
            }
            long result = 0;
            foreach (int m in modMap.Keys) result += modMap[m] * (modMap[m] - 1) / 2;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 20960
#include<stdio.h>
int main(void)
{
	int t,n,i,gk=0;
	for(i=0;i<4;i++){
		scanf("%d %d",&t,&n);
		if(t==1){
			gk=6000*n;
		}
		else if(t==2){
			gk=4000*n;
		}
		else if(t==3){
			gk=3000*n;
		}
		else if(t==4){
			gk=2000*n;
		}
		printf("%d\n",gk);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
  int n,t;
  cin >> n >> t;
  vector<ll> a(n);
  ll mod=1000000007;
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a.begin(),a.end());
  ll ans=1;
  for(int i=0; i<n; i++) {
    ans*=distance(lower_bound(a.begin(),a.end(),a[i]-t),a.begin()+i)+1;
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1796
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	while(n!=0)
	{
		if(n%10==2) ans++;
		n/=10;
	 } 
	 cout<<ans;
	return 0;
} A*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,h,w;
	cin>>n>>h>>w;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a>=h&&b>=w) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuffer buf =new StringBuffer();
    	int m,f;

    	    int[]c = new int[3];

    	 while(true){
     	    int n = sc.nextInt();
     	    int x = sc.nextInt();
     	    int count = 0;
    	    if(n==0&&x==0){
    	        break;

    	    }else{
    	    	for(int a=1;a<=n;a++){
        	    	c[0]=a;
        	    	for(int b=1;b<=n;b++){
        	    		if(a<b){
        	    			c[1]=b;
        	    			for(int d=1;d<=n;d++){
        	    				if(b<d){
        	    					c[2]=d;
        	    					if(c[0]+c[1]+c[2]==x){
        	    						count +=1;
        	    					}
        	    				}
        	    			}
        	    		}
        	    	}
        	    }
    	    }
    	    System.out.println(count);
    	 }


}
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

set<LL> st;
void dfs(LL s, int d, int num) {
    st.insert(s);
    if(d == 11) return;

    if(num > 0) {
        dfs(s * 10 + (num - 1), d + 1, num - 1);

    }
    if(num < 9) {
        dfs(s * 10 + (num + 1), d + 1, num + 1);

    }
    dfs(s * 10 + num, d + 1, num);

    return;
}

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

    int k;
    cin >> k;
    for(int i = 0; i <= 9; ++i) {
        dfs(i, 1, i);

    }

    int p = 0;
    for(auto it = st.begin(); it != st.end(); ++it, ++p) {
        if(p == k) {
            cout << (*it) << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 27520
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
 
using namespace std;
 
int main() {
 
    double R;
    cin >> R;
 
    double PI = 3.141592653589;
 
    cout << fixed << setprecision(10) << 2 * PI * R << endl;
 
    return 0;
 
}

Measured memory_bytes: 3788
from queue import Queue
H, W = map(int, input().split())
G = [list(input()) for _ in range(H)]
white = 0
for g in G:
    white += g.count('.')
been = [[-1] * W for _ in range(H)]
d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
que = Queue()
que.put((0, 0))
been[0][0] = True
while not que.empty():
    h, w = que.get()
    for dx, dy in d:
        nh = h + dx
        nw = w + dy
        if nh < 0 or H <= nh or nw < 0 or W <= nw:
            continue
        if been[nh][nw] != -1:
            continue
        if G[nh][nw] == '#':
            continue
        been[nh][nw] = been[h][w] + 1
        que.put((nh, nw))
if been[H-1][W-1] == -1:
    print(-1)
else:
    print(white - been[H-1][W-1])

Measured memory_bytes: 9640
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 100100
using namespace std;

int n,m,ans,last;
struct Que
{
	int l,r;
	bool operator < (const Que &u) const
	{
		return r<u.r;
	}
}que[N];

int main()
{
	int i,j;
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&que[i].l,&que[i].r);
	}
	sort(que+1,que+m+1);
	for(i=1;i<=m;i++)
	{
		if(last>=que[i].l) continue;
		last=que[i].r-1;
		ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 1024
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    x,y,z=map(int,input().split())
    print(z,x,y)


if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int h, w, n;
	cin >> n >> h >> w;
	n++;
	cout << (n - h) * (n - w) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n;
    cin>>n;
    lli r = n % 10;
    if(r == 3)  {
        cout<<"bon";
    }
    else if(r == 0 || r == 1 || r == 6 || r == 8) {
        cout<<"pon";
    }
    else {
        cout<<"hon";
    }
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <cctype>
#include <cstdio>
using namespace std;

int main(){
   char num[1001];

   while(1){
      int sum = 0,i = 0;
      scanf("%s",num);
      if(num[0]=='0') break;

      while(num[i] != '\0'){
         sum += num[i]-'0';
         ++i;
      }
      printf("%d\n",sum);
   }
   return 0;
}



Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main (){
    int a,b,c,t;
    cin>>a>>b>>c;
    if(a>b){
        t=a;
        a=b;
        b=t;
}
    if(b>c){
        t=b;
        b=c;
        c=t;
    }
    
    
    if (a>b){
        t=a;
        a=b;
        b=t;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
    }
    
    


Measured memory_bytes: 3092
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e3 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3]) puts("Bad");
	else puts("Good");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001007;
using P = pair<int, int>;

int main(){
    ll n; cin >> n;
    int cnt = 0;
    ll a;
    queue<ll> run;
    rep(i,9) run.push(i+1);
    while (cnt != n){
        a = run.front(); run.pop();
        if (a % 10 == 0){
            run.push(10 * a);
            run.push(10 * a + 1);
        }
        else if (a % 10 == 9){
            run.push(10 * a + 8);
            run.push(10 * a + 9);
        }
        else {
            run.push(10 * a + (a % 10) - 1);
            run.push(10 * a + (a % 10));
            run.push(10 * a + (a % 10) + 1);
        }
        cnt++;
    }
    cout << a << endl;
}

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

int N, M, A[10009], B[10009];

int main() {
	while (true) {
		cin >> N >> M; if (N + M == 0) break;
		for (int i = 1; i <= N; i++) { A[i] = 0; B[i] = 0; }
		for (int i = 1; i <= M; i++) {
			vector<int>vec; int S, P; cin >> S >> P;
			for (int j = 0; j < P; j++) { int pos; cin >> pos; vec.push_back(pos); }

			if (vec.size() == 1) { B[vec[0]] += S; }
			for (int j = 0; j < vec.size(); j++) A[vec[j]] += S;
		}

		vector<pair<int, int>>L1, L2;
		for (int i = 1; i <= N; i++) L1.push_back(make_pair(A[i], i));
		for (int i = 1; i <= N; i++) L2.push_back(make_pair(B[i], i));
		sort(L1.begin(), L1.end()); reverse(L1.begin(), L1.end());
		sort(L2.begin(), L2.end());

		int maxn = 0;
		for (int j = 0; j < min(2, (int)L1.size()); j++) {
			for (int k = 0; k < min(2, (int)L2.size()); k++) {
				if (L1[j].second != L2[k].second) maxn = max(maxn, L1[j].first - L2[k].first);
			}
		}
		cout << maxn + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll X,K,D;
  cin >> X >> K >> D;
  if(X<0 && X/D < -K) {
    cout << abs(X+K*D) << endl;
    return 0;
  }
  if(X>0&&K < (X+D-1)/D) {
    cout << abs(X-K*D) << endl;
    return 0;
  }
  ll x = abs(X) % D;
  ll k = K-(abs(X))/D;
  if(k%2==1) {
    cout << abs(D-x) << endl;
  } else {
    cout << abs(x) << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010];
    rep(i, n) cin >> a[i];
    sort(a, a + n, greater<int>());
    int l = a[0];
    int r = a[1];
    rep(i, n) {
        int d1 = min(abs(l - r), r);
        int d2 = min(abs(l - a[i]), a[i]);
        if (d1 < d2) {
            r = a[i];
        }
    }
    cout << l << " " << r << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    vll A(N);
    rep(i, N) cin >> A[i];
    ll S = 0;
    rep(i, N) S += A[i];

    int cnt = 0;
    rep(i, N) {
        if (S <= ll(4) * ll(M) * A[i]) {
            cnt++;
        }
    }
    if (cnt >= M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define form(l, r, i)	for(int i = l; i <= r; ++i)
#define forv(r, l, i)	for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const int inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modwdop = 998244353ll;
 
ll pp = 13337ll;
ll modw = 1e9 + 7;
 
using namespace std;
 
int a[12][N];
 
int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    forn(i, h)
    {
    	string s;
        cin >> s;
        forn(j, w)	a[i][j] = s[j] == '1';
    }
    int ans = inf;
    for(int mask = (1 << h) - 1; mask >= (1 << (h - 1)); mask--)
	{
		vector<int> x(h, 0);
        int num = __builtin_popcount(mask);
        num--;
        forn(j, w)
		{
            if(num > ans)	break;
            int cur = 0;
            forn(i, h)
			{
                cur += a[i][j];
                if(mask & (1 << i)) {
                    x[i] += cur;
                    cur = 0;
                    if(x[i] > k)
					{
						j--;
                        num++;
                        x = vector<int>(h, 0);
                        break;
                    }
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    r0;
}

Measured memory_bytes: 6400
main :: IO ()
main  = do
    [n, k] <- map read . words <$> getLine
    xs <-  map read . words <$> getLine
    putStrLn $ show $ sum $ take k $ quicksort xs

quicksort :: Ord a => [a] -> [a]
quicksort [] = []
quicksort (x:xs) = quicksort (filter (< x) xs) ++ [x] ++ quicksort (filter (>= x) xs)
    

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

vl a,p;

ll c(ll n,ll x){
	if(n==0){
		if(x<=0){
			return 0;
		}
		else return 1;
	}
	else if(x<=1+a[n-1]){
		return c(n-1,x-1);
	}
	else return p[n-1]+1+c(n-1,x-2-a[n-1]);
}

int main(){
	ll n,x;cin>>n>>x;
	a.resize(n);
	p.resize(n);
	a[0]=1;p[0]=1;
	for(int i=1;i<n;++i){
		a[i]=a[i-1]*2+3;
		p[i]=p[i-1]*2+1;
	}
	cout<<c(n,x)<<endl;
}

Measured memory_bytes: 256
C = []
for i in range(3):
    a,aa,aaa = (int(i) for i in input().split())
    C.append((a,aa,aaa))

if C[2][0] - C[1][0] == C[2][1] - C[1][1] and C[2][1] - C[1][1] == C[2][2] - C[1][2]:
    if C[1][0] - C[0][0] == C[1][1] - C[0][1] and C[1][1] - C[0][1] == C[1][2] - C[0][2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
use std::collections::HashSet;

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let abc: Vec<u32> = read_vec();

  let ans = abc.into_iter().collect::<HashSet<u32>>().len();

  println!("{}", ans);
}


Measured memory_bytes: 4352
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);
    const nums = args.slice(1, N + 1);
    const isValid = nums.every((n) => {
        var ns = n.split(' ');
        var t = parseInt(ns[0], 10),
            x = parseInt(ns[1], 10),
            y = parseInt(ns[2], 10);
        var sum = x + y;

        return (t >= sum) && ((t % 2) === (sum % 2));
    });

    if (isValid) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29932
md = input().split(" ");
m = int(md[0]);
d = int(md[1]);

ans = 0;

for i in range(1,m+1) :
	for j in range(1,d+1) :
		one = j % 10;
		ten = j // 10;
		if ten >= 2 and one >= 2 and ten * one == i :
			ans += 1;

print(ans);

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

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  for(int i = 0; i < N; i++){
    cin >> A[0][i];
  }
  for(int i = 0; i < N; i++){
    cin >> A[1][i];
  }
  A[1][0] += A[0][0];
  for(int i = 1; i < N; i++){
    A[0][i] += A[0][i - 1];
    A[1][i] += max(A[0][i], A[1][i - 1]);
  }
  cout << A[1][N - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
H = np.array(list(map(int, input().split())))
DP = np.zeros(n, dtype="int")
DP[1] = abs(H[1] - H[0])
for i in range(2, n):
    ik = max(0, i - k)
    DP[i] = np.min(DP[ik: i] + np.abs(H[i] - H[ik: i]))

print(DP[-1])

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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}


int h,w,k;
ll ans=0;
//vector<vector<int>> v(6,vector<int>(6));

/*
void dfs(int dep, int x, vector<vector<int>> v){
    if(x==k){
        ans++;
        for(int depi=dep;depi<h+k;depi++){
            int tmp=0;
            if(depi<h){
                rep(i,6){
                    if(v[depi][i]==1){
                        tmp++;
                    }
                }
            }else{
                int tmpp= depi-h;
                rep(i,6){
                    if(v[i][tmpp]==1){
                        tmp++;
                    }
                }
            }
            if(tmp==0){ans++;}
        }
        rep(i,2){
            rep(j,3){
                cout<< v[i][j]<< " ";
            }
            cout<<endl;
        }
        if(dep<h+k-1) {
            dfs(dep + 1, x, v);
        }
    }else if(x>k){
        if(dep<=h+k-1) {
            dfs(dep+1,x,v);
            int tmp=0;
            if(dep<h){
                rep(i,6){
                    if(v[dep][i]==1){
                        tmp++;
                        v[dep][i] = 0;
                    }
                }
            }else{
                int tmpp= dep-h;
                rep(i,6){
                    if(v[i][tmpp]==1){
                        tmp++;
                        v[i][tmpp]=0;
                    }
                }
            }
            dfs(dep+1,x-tmp,v);
        }
    }
}
*/
void dfs(int dep, int x, vector<vector<int>> v){
    if (dep==h+w) {
        if(x==k){
            ans++;
        }
    }
    if (dep <= h + w - 1) {
        if (x >= k) {
            dfs(dep + 1, x, v);
            int tmp = 0;
            if (dep < h) {
                rep(i, 6) {
                    if (v[dep][i] == 1) {
                        tmp++;
                        v[dep][i] = 0;
                    }
                }
            } else {
                int tmpp = dep - h;
                rep(i, 6) {
                    if (v[i][tmpp] == 1) {
                        tmp++;
                        v[i][tmpp] = 0;
                    }
                }
            }
            dfs(dep + 1, x - tmp, v);
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>h>>w>>k;
//    vector<vector<int>> v(h);
vector<vector<int>> v(6,vector<int>(6));
    char tmp;
    int cnt=0;
    rep(i,h){
        rep(j,w){
            cin>>tmp;
            if(tmp=='#'){
//                v[i].push_back(j);
                v[i][j]=1;
                cnt++;
            }
        }
    }

    dfs(0,cnt,v);
    fin(ans);

}




Measured memory_bytes: 3648
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e+5;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

void solve() {
    bool flag[N+1] = {};
    int count[N+1] = {};
    REP(i, 2, N+1) {
        if (!flag[i]) {
            for (int j = i + i; j < N + 1; j += i) {
                flag[j] = true;
            }
        }
    }
    for (int i = 3; i < N + 1; i += 2) {
        if (!flag[i] && !flag[(i + 1) / 2]) {
            ++count[i];
        }
    }
    REP(i, 3, N + 1) {
        count[i] += count[i - 1];
    }

    int q;
    int l, r;
    cin >> q;
    rep(i, q) {
        cin >> l >> r;
        cout << count[r] - count[l - 1] << endl;
    }
}

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


Measured memory_bytes: 1152
N = int(input())
jobs = [0]*N
for i in range(N):
    a, b = map(int, input().split())
    jobs[i] = (a, b)

jobs.sort(key=lambda x:x[1])

now = 0
jobIndex = 0
for i in range(N):
    if now + jobs[i][0] > jobs[i][1]:
        print("No")
        exit()
    now += jobs[i][0]

print("Yes")


Measured memory_bytes: 37444
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
int N, M;
string dp[10100], INF = "-";

string max_str(string s, string t)
{
    if (s == INF)
        return t;
    if (s.size() == t.size())
        return (s > t ? s : t);
    else
        return (s.size() > t.size() ? s : t);
}

int main()
{
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++)
        cin >> A[i];
    for (int i = 0; i < 10100; i++)
        dp[i] = INF;
    dp[0] = "";
    for (int i = 0; i <= N; i++)
    {
        if (dp[i] == "-")
            continue;
        for (int j = 0; j < M; j++)
        {
            dp[i + match[A[j] - 1]] = max_str(dp[i + match[A[j] - 1]], dp[i] + to_string(A[j]));
        }
    }
    cout << dp[N] << endl;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	string s;
	cin >> s;
	int answer;
	if (s == "SUN")
		answer = 7;
	else if (s == "MON")
		answer = 6;
	else if (s == "TUE")
		answer = 5;
	else if (s == "WED")
		answer = 4;
	else if (s == "THU")
		answer = 3;
	else if (s == "FRI")
		answer = 2;
	else if (s == "SAT")
		answer = 1;
	else
		assert(false);
	cout << answer << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll R;
  cin>>R;
  printf("%.20f\n",1.0*R*2*M_PI);
  
}


Measured memory_bytes: 3760
#include<stdio.h>
#include<string.h>
int main(void)
{
  int n;
  int count1=0;
  int count2=0;
  int ans;
  char s[10*10*10*10*10];
  
  scanf("%s",s);
  n=strlen(s);
  char s1[n];
  char s2[n];
  //正解になる配列
  for(int i=0;i<n;i+=2)
  {
    s1[i]='0';  s1[i+1]='1';
    s2[i]='1';  s2[i+1]='0';
  }
  //printf("%s\n",s1);
  //printf("%s\n",s2);
  //違う箇所をcountする
  for(int j=0;j<n;j++)
  {
    if(s[j]!=s1[j])
    {
      count1++;
    }
    if(s[j]!=s2[j])
    {
      count2++;
    }
  }
  if(count1<count2)
  {
    ans=count1;
  }
  else
  {
    ans=count2;
  }
  printf("%d",ans);

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

signed main(){
	int n,sum = 0,ma;
	bool use[10000001] = {};
	cin >> n;
	for(int i = 1;i <= n;i++){
		sum += i;
		if(sum >= n){
			ma = i;
			break;
		}
	}
	for(int i = ma;i >= 1;i--){
		if(n >= i){
			use[i] = true;
			n -= i;
		}
		if(!n) break;
	}
	for(int i = 0;i <= ma;i++){
		if(use[i]) cout << i << endl;
	}
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    data_type n,r,counter=0;
    cin>>n>>r;
    while(n)
    {
       n/=r;
       counter++;
    }
    cout<<counter<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int n) : par(n , -1), rank(n, 0) { }
    void init(int n) { par.assign(n, -1), rank.assign(n, 0); }

    int root(int x) {
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]); //ここで経路圧縮
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};


int main() {
    int N, M; cin >> N >> M;

    UnionFind tree(N);

    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        tree.unite(a - 1, b - 1);
    }

    int ans = 0;

    rep(i, N) {
        if (tree.par[i] == -1) ans++;
    }

    cout << ans << endl;


}


Measured memory_bytes: 1024
while true
  n = gets.chomp.to_i
  break if n == 0

  m = gets.chomp.to_i

  edges = []
  m.times do
    e = gets.chomp.split(",").map{|s| s.to_i}
    e[2] = e[2] / 100 - 1
    edges.push e
  end
  #p [n, m, edges]

  edges.sort!{|a, b| a[2] <=> b[2]}

  nodes = n.times.map{false}

  connected = [0]
  nodes[0] = true

  sumw = 0

  while connected.length < n
    for i in (0...edges.length)
      n0, n1, w = edges[i]

      if nodes[n0] || nodes[n1]
        if ! nodes[n0]
          nodes[n0] = true
          connected.push n0
          sumw += w
        elsif ! nodes[n1]
          nodes[n1] = true
          connected.push n1
          sumw += w
        end

        edges.delete_at(i)
        break
      end
    end
  end

  puts sumw
end

Measured memory_bytes: 6176
n = int(input())
s = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if s[i] == i+1:
        s[i],s[i+1] = s[i+1],s[i]
        ans += 1
if s[n-1] == n:
    for i in range(n-1,1,-1):
        #print(i)
        if s[i] == i+1:
            s[i],s[i-1] = s[i-1],s[i]
            #print(s)
            ans += 1
print(ans)

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

int main() {
  int N;
  cin >> N;
  int s[N];
  for(int i=0; i<N; i++) {
    cin >> s[i];
  }
  sort(s,s+N);
  int ans=0;
  for(int i=0; i<N; i++) {
    ans+=s[i];
  }
  int ans2=ans;
  if(ans%10==0) {
    for(int i=0; i<N; i++) {
      ans-=s[i];
      if(ans%10!=0) {
        break;
      }
    }
    for(int i=0; i<N; i++) {
      if(s[i]%10!=0) {
        ans2=ans2-s[i];
        break;
      }
      if(i==N-1&&ans2%10==0) {
        ans2=0;
      }
    }
  }
  cout << max(ans, ans2) << endl;
}

Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  //算出
  var ans = "No";
  for(var i=1 ; i<10 ; i++){
    for(var j=1 ; j<10 ; j++){
      if( i*j === N){
        ans = "Yes";
        break;
      }
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
N = int(input())
ans = N*[0]

for x in range(1,int(N**0.5)):
  for y in range(1,int(N**0.5)):
    for z in range(1,int(N**0.5)):
      n = (x+y+z)**2-(x*y+y*z+z*x)
      if n<=N:
        ans[n-1]+=1

print(*ans,sep="\n")

Measured memory_bytes: 9636
import math
n,d = map(int,input().split())
x = []
for _ in range(n):
  x.append(list(map(int,input().split())))
score = 0
for i in range(n):
  for j in range(n):
    tmp = 0
    for dd in range(d):
      tmp += ( x[i][dd] - x[j][dd] ) ** 2
    sq = math.floor(tmp ** (1/2))
    if tmp == sq ** 2:
      score += 1
print((score-n)//2)

Measured memory_bytes: 3064
N = int(input())
B = list(map(int, input().split()))

inf = float('inf')
A = [inf] * N

for i in range(N-1):
    if A[i] > B[i]:
        A[i] = B[i]
    if A[i+1] > B[i]:
        A[i+1] = B[i]
print(sum(A))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using P = pair<int, int>;
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    set<P> g;
    rep(i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--;
        g.insert({a, b});
        g.insert({b, a});
    }
    for (int i = 1; i < n - 1; i++) {
        if(g.count({0, i}) && g.count({i, n - 1})) { 
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 22420
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

void solve(int test) {
    ll n, d, ans = 0;
    cin >> n >> d;
    d *= d;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        x *= x, y *= y;
        trace(x+y, d);
        if (x + y <= d) ans++;
    }
    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }
}


Measured memory_bytes: 3652
/*
	@coder: Yeshayah
	@problem: 
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int tc, op, v;
	string k, a, b;
	map<string, vector<int>> mapa;
	cin >> tc;
	while (tc--) {
		cin >> op;
		if (op > 2) {
			cin >> a >> b;
			map<string, vector<int>>::iterator it = mapa.lower_bound(a);
			for (; it != mapa.end() && it -> first <= b; it++)
				for (int i : it -> second)
					cout << it -> first << " " << i << "\n";
		} else {
			cin >> k;
			if (!op) {
				cin >> v;
				mapa[k].push_back(v);
			} else if (op < 2) {
				if (mapa.find(k) != mapa.end()) {
					for (int i : mapa[k])
						cout << i << "\n";
				}
			} else mapa.erase(k);
		}
	}
	return 0;
}


Measured memory_bytes: 24272
S = [int(e) for e in input().split()]
list_a =  [int(e) for e in input().split()]
list_b =  [int(e) for e in input().split()]

dis_list = []

for i in range(S[2]):
    dis_list.append([int(e) for e in input().split()])

min_num1 = min(list_a) + min(list_b)

min_num2_list = []

for l in dis_list:
    min_num2_list.append(list_a[l[0]-1] + list_b[l[1]-1] - l[2])

min_num2 = min(min_num2_list)

if min_num1 > min_num2:
    print(min_num2)
else:
    print(min_num1)

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

int main() {
    int N;
    string S;
    cin >> N >> S;

    int res = 0;
    for(int i=1; i<int(S.size()); i++) {
        int temp = 0;
        vector<bool> a(26, 0), b(26, 0);
        for(int j=0; j<i; j++) {
            a[S[j]-'a'] = true;
        }
        for(int j=i; j<int(S.size()); j++) {
            if(a[S[j]-'a'] && !b[S[j]-'a']) temp++;
            b[S[j]-'a'] = true;
        }
        res = max(res, temp);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
val Int.absoluteValue: Int
    get() = if (this >= 0) this else -this
fun minOf(a:Int, b:Int): Int {
    return if (a > b) b else a
}
fun maxOf(a: Int, b:Int): Int {
    return if (a > b) a else b
}
fun main(args:Array<String>): Unit {
    val (n, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val x = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()
    val leftDist = IntArray(n){if (x[it] < 0) -x[it] else 0}
    val rightDist = IntArray(n){if (x[it] > 0) x[it] else 0}
    var min = Int.MAX_VALUE
    for (i in 0 .. n - k){
        min = minOf(min, minOf(leftDist[i], rightDist[i + k - 1]) * 2 + maxOf(leftDist[i], rightDist[i + k - 1]))
    }
    println(min)
}

Measured memory_bytes: 52008
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    l = kwargs["l"]
    r = kwargs["r"]
    d = kwargs["d"]
    res = 0

    for i in range(l, r + 1):
        if i % d == 0:
            res += 1

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["l"], kwargs["r"], kwargs["d"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31020
import math
N = []
while 1:
  x = input()
  if x==0: break
  N.append(x)
n0 = max(N)
A = [0]*(n0+1)
A[0:3]=[1,1,2]
for i in range(0,n0-2): A[i+3]=sum(A[i:i+3])
for e in N: print int(math.ceil(A[e]/3650.0))

Measured memory_bytes: 4372
while True:
    N,M = map(int,input().strip().split(" "))
    if [N,M] == [0,0]:
        break
    L = []
    S = 0
    for i in range(N):
        l = list(map(int,input().strip().split(" ")))
        l.reverse()
        L.append(l)
        S = S + l[0]*l[1]
    L.sort()
    for j in range(0,N):
        t = N-j-1
        if M >= L[t][1]:
            S = S - L[t][0]*L[t][1]
            M = M - L[t][1]
        elif 0 < M:
            S = S - L[t][0]*M
            M = M - L[t][1]
    print(S)


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

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> pi(n+1,-1);
  //vector<vector<int>> ps(n);
  vector<int> ps(n);
  rep(i,n) {
    int l = pi[a[i]];
    //if (l != -1) ps[l].push_back(i);
    if (l != -1) ps[l] = i;
    pi[a[i]] = i;
  }

  vector<vector<P>> qs(n);
  rep(qi,q) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    qs[l].emplace_back(r,qi);
  }

  vector<int> ans(q);
  BIT<int> d(n);
  for (int x = n-1; x >= 0; --x) {
    // for (int y : ps[x]) { 
    //     cout << y << endl;
    //     d.add(y,1); 
    // }
    //cout << ps[x] << endl;
    if(ps[x] != 0)
        d.add(ps[x],1);
    for (P query : qs[x]) {
      int r = query.first, i = query.second;
      ans[i] = (r-x+1) - d.sum(r);
    }
  }

  rep(i,q) cout << ans[i] << endl;
  return 0;
}


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

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

long long lcm(long long x, long long y)
{
	return x * y / gcd(x, y);
}

signed main(void)
{
	long long a, b, c, d;
	long long ans;
	cin >> a >> b >> c >> d;

	ans = 0;
	ans += b - (b / c + b / d - b / lcm(c, d));
	ans -= (a - 1) - ((a - 1) / c + (a  - 1)/ d - (a - 1)/ lcm(c, d));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
int n, c;
int x[maxn];

int read() {
  if (scanf("%d%d", &n, &c) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
  }
  return true;
}

long long s[maxn];

void solve() {
  reverse(x, x + n);
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + x[i];
  }
  long long res = infll;
  for (int k = 1; k <= n; k++) {
    long long cur = (long long) (n + k) * c;
    for (int l = 0, i = 0; l < n; l += k, i++) {
      int r = min(n, l + k);
      cur += (!i ? 5 : 2 * i + 3) * (s[r] - s[l]);
      if (cur >= infll) {
        break;
      }
    }
    res = min(res, cur);
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int w, h;
bool vis[11][11];
char a[11][11];
string res;
map<char, int> mpp;
char cdir[4] = {'U', 'R', 'D', 'L'};

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {-1, 0, 1, 0};

bool dfs(int p, int q, int cnt, char dir, string str)
{
  if(cnt == 0){
    res = str;
    return true;
  }

  int t = mpp[dir], dx, dy;
  bool f;
  for(int i = 0; i < 4; ++i){
    if(i == t) continue;
    f = false;
    dx = q+xdir[i];
    dy = p+ydir[i];
    while(0 <= dx && dx < w && 0 <= dy && dy < h){
      if(a[dy][dx] == 'o' && vis[dy][dx]){
	f = true;
	break;
      }

      dx += xdir[i];
      dy += ydir[i];
    }
    if(f){
      vis[p][q] = false;
      if(dfs(dy, dx, cnt-1, cdir[i], str+cdir[i])) return true;
      vis[p][q] = true;
    }
  }

  return false;
}

int main()
{
  int s, t, cnt;
  char dir;

  mpp['U'] = 2;
  mpp['R'] = 3;
  mpp['D'] = 0;
  mpp['L'] = 1;

  while(cin>>h>>w && h+w){
    res = "";
    cnt = 0;
    fill(&vis[0][0], &vis[h][0], true);

    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; ++j){
	cin >> a[i][j];
	if(a[i][j] == 'o') ++cnt;
	else if(a[i][j] != '.'){
	  dir = a[i][j];
	  s = i;
	  t = j;
	}
      }

    vis[s][t] = false;
    dfs(s, t, cnt, dir, "");
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  vector<string> s(3);
  rep(i,3){
    cin >> s[i];
  }
  vector<int> cnt(3,0);
  vector<int> n(3);
  rep(i,3){
    n[i] = s[i].size();
  }
  int num=0;
  int nextnum;
  while(1){
    if(cnt[num]==n[num]){
      if(num==0){
	cout << "A" << "\n";
      }
      else if(num==1){
	cout << "B" << "\n";
      }
      else{
	cout << "C" << "\n";
      }
      break;
    }
    //    cout << num << "\n";
    if(s[num][cnt[num]]=='a'){
      nextnum = 0;
    }
    else if(s[num][cnt[num]]=='b'){
      nextnum = 1;
    }
    else{
      nextnum = 2;
    }
    cnt[num]++;
    num = nextnum;
  }
  return 0;
}


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

int main(void) {
  int n, t[100000], x[100000], y[100000], p = 0, ctime = 0;

  if(scanf("%d", &n) == 1);

  for(int i = 0; i < n; i++) {
    if(scanf("%d %d %d", &t[i], &x[i], &y[i]) == 1);

    while(1) {
      if(ctime < t[i] && p < x[i] + y[i]) {
        p++;
        ctime++;
      } else if(ctime < t[i] && p >= x[i] + y[i]) {
        p--;
        ctime++;
      }
      if((ctime == t[i] && p != x[i] + y[i]) || t[i] < x[i] + y[i]) {
        printf("No");
        i = n+1;
        break;
      } else if(ctime == t[i] && p == x[i] + y[i]) {
        break;
      }
    }
    if(ctime == t[i] && i == n - 1) {
      printf("Yes");
      break;
    }
  }



  return 0;
}


Measured memory_bytes: 1280
/**
*    created: 03.07.2020 02:22:54
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#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 all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int ans = INF;
    int n;
    cin >> n;
    rep(i,n) {
        int a;
        cin >> a;
        int cnt = 0;
        while(a % 2 == 0) {
            cnt++;
            a /= 2;
        }
        chmin(ans,cnt);
    }
    cout << ans << endl;
    return 0;   
}

Measured memory_bytes: 3616