akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    ull i,x;
    long double prd=100;
cin>>x;
    for(i=1;i<5000;i++){
      prd=prd*1.01;
      //cout<<prd<<" ";
      prd=floor(prd);
      //cout<<prd<<" "<<x<<endl;
      if(prd>=x)
        break;
    }
    cout<<i<<endl;
  }


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int A, B;
  cin >> A >> B;
  
  cout << max({A+B,A-B,A*B}) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,k;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d)cout<<"Yes";else{
		if(abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes";else cout<<"No";
	}
}

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

t1 = 0
for i in range(N-1):
    for j in range(i+1,N):
        if A[i] > A[j]:
            t1 += 1

t2 = 0
for i in range(N-1):
    for j in range(i+1,N):
        if A[i] < A[j]:
            t2 += 1

ans = t1 * (K*(K+1)//2) + t2 * (K*(K-1)//2)
print(ans % (10**9 + 7))

Measured memory_bytes: 3188
using System;

namespace B___Five_Dishes
{
    class Program
    {
        static void Main (string[] args)
        {
            var a = new int[5];
            var min = int.MaxValue;
            var x = 0;
            for (var i = 0; i < 5; i++)
            {
                a[i] = (int.Parse (Console.ReadLine ()));
                if (a[i] % 10 >= 1 && a[i] % 10 < min)
                {
                    min = a[i] % 10;
                    x = i;
                }
            }
            var t = 0;
            for (var i = 0; i < a.Length; i++)
            {
                if (i != x)
                {
                    t += a[i];
                    if (a[i] % 10 != 0)
                        t += 10 - a[i] % 10;
                }
            }
            Console.WriteLine (t + a[x]);
        }
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x,y;
    cin>>x>>y;
    if(x%y==0){
        cout<<-1<<endl;
    }
    else{
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
using mint = modint998244353;
struct S{mint val, base;};
S op(S a, S b) {return S{a.val+b.val, a.base+b.base};}
S e() {return S{0, 0};}
S mapp(mint f, S x) {return S{f == -1 ? x.val : x.base * f, x.base};}
mint comp(mint f, mint g) {return f == -1 ? g : f;}
mint id() {return -1;}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<S> init(N);
  mint b = 1;
  IREP(i, N) {
    init[i] = S{b, b};
    b *= 10;
  }
  lazy_segtree<S, op, e, mint, mapp, comp, id> seg(init);
  REP(q, Q) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    seg.apply(l, r, d);
    cout << seg.all_prod().val.val() << "\n";
  }
}

Measured memory_bytes: 10156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		int once = (n - m) * 100 + m * 1900;
		int ans = once * (int) Math.pow(2, m);

		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	int n, p;
	cin >> n >> p;
	int cnt_odd = 0;
 
	long long ans = 1;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a % 2 == 1) cnt_odd++;
		ans *= 2;
	}
 
	if(p == 1){
		if(cnt_odd == 0) ans = 0;
		else ans /= 2;
	}else{
		if(cnt_odd != 0) ans /= 2;
	}
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
if x == y:
    print(0)
elif abs(x) == abs(y):
    print(1)
elif x >= 0 and y >= 0:
    if y > x:
        print(y - x)
    else:
        print(x - y + 2 - (y == 0))
elif y >= 0:
    if y > abs(x):
        print(y - abs(x) + 1)
    else:
        print(abs(x) - y + 1 - (y == 0))
elif x < 0 and y < 0:
    x = abs(x)
    y = abs(y)
    if y > x:
        print(y - x + 2)
    else:
        print(x - y)
elif y < 0:
    y = abs(y)
    if y > x:
        print(y - x + 1)
    else:
        print(x - y + 1)

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int main() {
  string S;cin>>S;
  int K;cin>>K;
  // Kが１なら一番最初
  // それ以外なら、頭から1があるだけ長さを維持。
  // Kまで１が続いているなら1
  // 一番前が1でKが１なら1
  if (K==1) {
    OUT(S[0]);
  } else {
    int one_length = 0;
    while(S[one_length] == '1') one_length++;
    if (K <= one_length) {
      OUT(1);
    } else {
      OUT(S[one_length]);
    }
  }

  return 0;
}

Measured memory_bytes: 256
ar = gets.split

n = ar[0].to_i
k = ar[1].to_i

m1 = (n-k).abs

if (n > k) then
  m1 = n - k*(n/k)
end
  
loop do
  m2 = (m1-k).abs
  if (m2>m1) then
    break
  end
  m1 = m2
end

  print m1

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define SENTINEL (1000000001)

int c = 0;
int S[500000];
int L[250001];
int R[250001];
char str[5500000];
char *p = str;

static void Merge(int A[], int left, int mid, int right);
static void MergeSort(int A[], int left, int right);
static int getNum(void);

int main(void) {
	int i;
	int n;
	
	fread(str, sizeof(str[0]), sizeof(str)/sizeof(str[0]), stdin);
	n = getNum();
	for (i = 0; i < n; ++i) {
		S[i] = getNum();
	}
	
	MergeSort(S, 0, n);
	
	for (i = 0; i < n; ++i) {
		if (i > 0) {
			putchar(' ');
		}
		printf("%d", S[i]);
	}
	putchar('\n');
	
	printf("%d\n", c);

	return 0;
}

int getNum(void) {
	int n = 0;
	while ((*p >= '0') && (*p <= '9')) {
		n = n * 10 + (int)(*p - '0');
		++p;
	} 
	++p;
	return n;
}

void Merge(int A[], int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	memcpy(L, A + left, n1 * sizeof(int));
	memcpy(R, A + mid, n2 * sizeof(int));
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; ++k) {
		++c;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
}

void MergeSort(int A[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int a,b;
	cin>>a>>b;
	int ans;
	if(a==b)ans = 2*b;
	else ans = max(a,b)*2 -1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	ll ct = 1, ca = 1;
	for (int i = 0; i < n; ++i) {
		ll t, a; cin >> t >> a;
		ll m = max((ct + t - 1) / t, (ca + a - 1) / a);
		ct = m*t;
		ca = m*a;
	}
	cout << ct + ca << endl;

	return 0;
}

Measured memory_bytes: 256
// stones

#include <iostream>
using namespace std;

int main()
{
    int n, k;
    int stones[102];
    bool dp[100003];
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> stones[i];
    }
    fill(dp, dp + k + 1, true);
    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i - stones[j] >= 0 && dp[i - stones[j]])
                dp[i] = false;
        }
    }
    if (dp[k])
        cout << "Second" << endl;
    else
        cout << "First" << endl;
}

Measured memory_bytes: 384
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim M As Integer = CInt(Math.Floor(Math.Sqrt(N)))
        WriteLine(Math.Pow(M, 2))
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 19920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    vec<ll> A(N);
    rep(i,N)cin >> A[i];
    sort(all(A));
    if(K > A.back()){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    ll G = A[0];
    rep(i,N)G = __gcd(G, A[i]);
    if(G == 1){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    if(__gcd(K, G) == 1){
        cout << "IMPOSSIBLE"  << endl;
    }
    else{
        cout << "POSSIBLE" << endl;
    }
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        int count = 0;
        for(int j = 0; j < n; j++) {
            if((j % 2 == 0) && (num[j] % 2 == 1))
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35832
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double A = 0;

		for(int i = 0 ;i < N;i++) {
			 A+=1/sc.nextDouble();
		}
		System.out.println(1/A);
	}
}

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

int main(){
  int N,X,Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  map<int, long> m;
  for(int i = 1; i < N; i++){
    m[i] = 0;
  }
  
  int a[N][N];
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      a[i][j] = abs(j - i);
    }
  }


  
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      a[i][j] = min(a[i][j], a[i][X] + 1 + a[Y][j]);
      m[a[i][j]]++;
    }
  }
  
  for(auto x:m){
    cout << x.second << endl;
  }
}


Measured memory_bytes: 16000
//
//AOJ 2104 Country Road
//date:20170417
//640009E
//Yang Bo
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

int main()
{
  int t = 0; //??????????????????????????°
  int n = 0, k = 0; //n:??¶????????°, k:?????????????????°

  cin >> t; //??????????????????????????°?????\???
  
  do {
    cin >> n >> k; //??¶????????°n??¨?????????????????°k?????\???
   
    //int a[n] = {0}; //??¶?????§?¨???????????????????
    vector<int> a(n);
    
    for(int i = 0; i < n; i++)
      cin >> a[i]; //??¶?????§?¨??????\???
    if(k>=n){
      cout<<"0\n";
      continue;
    } 
    //int m = n - 1;
    //int b[m] = {0}; //??¶??¨??¶??????????????¢??????????????????
    vector<int> b(n-1);
    for (int i = 0; i < n-1; i++)
      b[i] = a[i + 1] - a[i]; //??¶??¨??¶??????????????¢?????£??\
    
    sort(begin(b), end(b), greater<int>()); //?????¢???????????????????????????

    /*cout<<"DEBUG ";
    for(int i=0;i<n;i++)cout<<a[i]<<" ";
    for(int i=0;i<n-1;i++)cout<<b[i]<<" ";
    cout<<endl;
    */
    int ans = a[n - 1] - a[0]; //?????????????????????????????£??\
    for (int i = 0; i < k - 1; i++)
      ans = ans - b[i]; //????????????????????????????????????????????????
    
    cout << ans << '\n';
    
  } while (--t > 0);
}

Measured memory_bytes: 3504
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int absi(int x) {
	return (x < 0 ? -x : x);
}

int main() {
	long long int N;
	vector<int> A;
	vector<int> B;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
		B.push_back(a - i - 1);
	}

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

	long long int b;
	if(N%2 == 0) {
		b = (B[N/2-1] + B[N/2]) / 2;
	} else {
		b = B[N/2];
	}

	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += absi(B[i] - b);
	}

	cout << ans << endl;
}


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

main() {
  string a;
  string b;
  cin >> a >> b;
  int num;
  istringstream ss;
  ss = istringstream(a + b);
  ss >> num;

  for (int i = 4; i <= 316; i++) {
    if (num == i * i) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3596
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a,b := scanInt()-1, scanInt()-1
	fmt.Fprintln(wr, a*b)
}


Measured memory_bytes: 640
#include <stdio.h>

 int main(void){
       int n,i,m =100000;
         scanf("%d",&n);
             for( i=1; i<=n; i++){
                   m = m*1.05;
                  if(m%1000)
                   m = (m/1000+1)*1000;
               }
               printf("%d\n",m);
               return 0;
    }

Measured memory_bytes: 592
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    s = IS()
    n = len(s)
    t = s.replace('x', '')
    if t != t[::-1]:
        print(-1)
        return None
    l = 0
    r = n-1
    cnt = 0
    while l < r:
        if s[l] != s[r]:
            if s[l] == 'x':
                l += 1
            elif s[r] == 'x':
                r -= 1
            cnt += 1
        else:
            l += 1
            r -= 1
    print(cnt)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=3*1e5+3;
int add(int a,int b)
{
      a+=b;
      if(a>=MOD) a-=MOD;
      return a;
}
int sub(int a,int b)
{
      a-=b;
      if(a<0) a+=MOD;
      return a;
}
int mul(int a,int b)
{     
      return ((long long)a*b)%MOD;
}
int rev(int a)
{
      return mpow(a,MOD-2);
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n,k;
      cin>>n>>k;
      int a[n];
      for(int i=0;i<n;i++)
      {
            cin>>a[i];
      }
      int ans=0;
      for(int i=0;i<n;i++)
      {
            for(int j=i+1;j<n;j++)
            {
                  if(a[i]>a[j]) ans=add(ans,k);
            }
            int cnt=0;
            for(int j=0;j<n;j++)
            {
                  if(a[i]>a[j]) cnt++;
            }
            ans=add(ans,mul(k,mul(k-1,mul(cnt,rev(2)))));
      }
      cout<<ans;
}
// .. / .. / .. /..
// x+2*x+3x...(k-1)x 
// I never lose. I either win or I learn


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

S=[0]*(N+1)
for i in range(N):
    S[i+1]=(A[i]+S[i])%M


def tr(k):
    return k*(k-1)//2


countlist=dict()
check=set()


for i in range(1,N+1):
    countlist[S[i]]=countlist.get(S[i],0)+1

    
    


ANS=countlist.get(0,0)

for i in countlist.keys():
    ANS+=tr(countlist[i])



print(ANS)






Measured memory_bytes: 16956
#include <stdio.h>
int main()
{
    int  a,b,c,i,j,k;
    //char ch,ch1;
    scanf("%d %d",&a, &b);
   if(a==2 && b==2) printf("Yes\n");
   else if((a==1 || a==3 || a==5 || a==7 || a==8 || a==10 || a==12) && (b==1 || b==3 || b==5 || b==7 || b==8 || b==10 || b==12))
   printf("Yes\n");
   else if((a==4 || a==6 || a==9|| a==11) && (b==4 || b==6 || b==9|| b==11)) printf("Yes\n");
   else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
Scanf.scanf "%d %d %d" (fun n a b ->
    let x = Array.init n (fun _ -> Scanf.scanf " %d" (fun x ->x)) in

    let rec loop i acc =
        if i = n then acc else
            loop (i + 1) (acc + min (a * (x.(i) - x.(i - 1))) b)
    in
    loop 1 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 6636
package main

import (
	"fmt"
	"math"
)

var dp []int64

func main() {
	var n, w int64
	fmt.Scanf("%d%d", &n, &w)
	weight := make([]int64, n)
	values := make([]int64, n)
	for i := 0; i < int(n); i++ {
		fmt.Scanf("%d%d", &weight[i], &values[i])
	}
	ans := maximumPossibleSumKnapsack2(n, w, values, weight)
	fmt.Println(ans)
}

func createDPTable(v int64) []int64 {
	dp = make([]int64, v+1)
	for i := range dp {
		dp[i] = 1 << 32
	}
	dp[0] = 0
	return dp
}

func maximumPossibleSumKnapsack2(n int64, w int64, values []int64, weight []int64) int64 {
	var totalValues int64
	for i := range values {
		totalValues += values[i]
	}
	dp = createDPTable(totalValues)
	for items := 0; items < int(n); items++ {
		for value := totalValues - values[items]; value >= 0; value-- {
			dp[value+values[items]] = int64(math.Min(float64(dp[value+values[items]]), float64(dp[value]+weight[items])))
		}
	}
	var ans int64 = 0
	for i := 0; i <= int(totalValues); i++ {
		if dp[i] <= w {
			ans = int64(math.Max(float64(ans), float64(i)))
		}
	}
	return ans
}


Measured memory_bytes: 2680
#%%
def dfs_deep_measure(st, h, w, reach):
    #木の深さを、各ノードに対して求める。
    deep = [[500] * w for _ in range(h)]
    check = [[0] * w for _ in range(h)]
    stack = [st]
    st_i, st_j = st[0], st[1]
    check[st_i][st_j] = 1
    deep[st_i][st_j] = 0
    while len(stack) > 0:
        tmp = stack.pop(0)
        tmp_i, tmp_j = tmp[0], tmp[1]
        tmp_list = reach[tmp_i][tmp_j]
        for i in range(len(tmp_list)):
            t_i, t_j = tmp_list[i][0], tmp_list[i][1]
            if check[t_i][t_j] != 1:
                stack.append((t_i, t_j))
                check[t_i][t_j] = 1
                for j in range(len(reach[t_i][t_j])):
                    ii = (reach[t_i][t_j])[j][0]
                    jj = (reach[t_i][t_j])[j][1]
                    deep[t_i][t_j] = min(deep[ii][jj]+1, deep[t_i][t_j])
    return deep


h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
reach = [[[] for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w):
        for k in range(len(move)):
            if s[i][j] == '#':
                pass
            else:
                x = i + move[k][0]
                y = j + move[k][1]
                if 0 <= x <= h-1 and 0 <= y <= w-1:
                    if s[x][y] == '.':
                        reach[i][j].append((x, y))




ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            pass
        else:
            tmp_deep = dfs_deep_measure((i, j), h, w, reach)
            #print(tmp_deep)
            #print(tmp_deep)
            for k in range(h):
                for l in range(w):
                    if tmp_deep[k][l] != 500:
                        ans = max(ans, tmp_deep[k][l])


print(ans)

Measured memory_bytes: 47960
#include <bits/stdc++.h>
using namespace std;
vector<int> getAns(int lv, int a, int b) {
	if (lv == 0) {
		vector<int> v;
		v.push_back(a), v.push_back(b);
		return v;
	}
	if (((a >> lv) & 1) != ((b >> lv) & 1)) {
		int c = b ^ (1 << (lv - 1));
		vector<int> fr = getAns(lv - 1, a, c ^ (1 << lv)), sd = getAns(lv - 1, c, b);
		for (auto x : sd)
			fr.push_back(x);
		return fr;	
	}
	else {
		vector<int> fr = getAns(lv - 1, a, b), rn;
		for (auto x : fr)
			rn.push_back(x), rn.push_back(x);
		int z = 0;
		for (int i = 1; i < rn.size(); i++) {
			if (i % 2)
				z = 1 - z;
			rn[i] = rn[i] ^ (z << lv);
		}
		return rn;
	}
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2) {
		cout << "NO";
		return 0;
	}		
	cout << "YES\n";
	vector<int> ans = getAns(n - 1, a, b);
	for (auto u : ans)
		cout << u << " ";
	return 0;
}



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

int main(){
    using namespace std;
    vector<vector<unsigned long>> factor(1000001);
    for(unsigned long i{1}; i < 1000001; ++i)for(unsigned long j{i}; j < 1000001; j += i)factor[j].push_back(i);
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    unordered_map<unsigned long, unsigned long> mp;
    unsigned long mask{random_device{}()};
    for(auto&& i : A){
        cin >> i;
        ++mp[i ^ mask];
    }
    unsigned long ans{0};
    for(const auto& i : A)[&]{
        unsigned long cnt{0};
        for(const auto& j : factor[i]){
            cnt += mp[j ^ mask];
            if(cnt > 1)return;
        }
        ++ans;
    }();
    cout << ans << endl;
    return 0;
}

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

int main()
{
    long long  a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
    return 0;
}


Measured memory_bytes: 3636
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};
ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}

int main() {
  ll n; cin>>n;
  ll an = mod_pow(10,n) - mod_pow(9,n) * 2 + mod_pow(8, n);
  an += 100 * M; an %= M;
  cout<<an<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 100010;
int n, A, B, res, p[maxn], ban[maxn];
vector<int> edge[maxn];
int getdis(int now = A, int last = -1){
	static int dep;
	int res = 0;
	++dep;
	for(int u : edge[now])if(last != u){
		p[u] = now;
		if(u == B)return dep;
		res = getdis(u, now);
		if(res)return res;
	}
	--dep;
	return res;
}
int getfar(int now, int last = -1){
	int res = 0;
	for(int u : edge[now])if(u != last && !ban[u]){
		res = max(res, getfar(u, now)+1);
	}
	return res;
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> A >> B;
	for(int a, b, i = 1;i < n;++i){
		cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	int D = getdis();
	//cout << "D " << D << '\n';
	int adv = (D-1)/2;
	res = adv;
	for(int i = 0;i < adv;++i)B = p[B];
	if(D&1)A = p[B];
	else A = p[p[B]];
	while(B != A)ban[B] = true, B = p[B];
	int last = getfar(A);
	//cout << "LST " << last << '\n';
	cout << last + res + ((D&1) ? 0 : 1) << '\n';
}


Measured memory_bytes: 9600
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	int N; cin >> N;
	vector<int>X(N), Y(N),P(N);
	REP(i, N)cin >> X[i] >> Y[i] >> P[i];

	vector<ll>cost(N, INF);
	vector<int>pos(N);
	REP(k, N + 1) {
		vector<int>v(N);
		FORR(i, N, N - k)v[i] = 1;
		ll ans = LINF;
		do {
			REP(bit, 1 << k) {
				int idx = 0;
				REP(i, N) {
					cost[i] = INF;
					if (v[i])pos[idx++]=i;
					chmin(cost[i], abs(X[i]));
					chmin(cost[i], abs(Y[i]));
				}
				REP(i, k) {
					int idx = pos[i];
					//x
					if (bit&(1 << i)) {
						int x = X[idx];
						REP(i, N)chmin(cost[i], abs(X[i] - x));
					}
					//y
					else {
						int y = Y[idx];
						REP(i, N)chmin(cost[i], abs(Y[i] - y));
					}
				}
				ll res = 0;
				REP(i, N)res += cost[i] * P[i];
				chmin(ans, res);
			}
		} while (next_permutation(all(v)));
		print(ans);
	}
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b;
    c=a*b;
    if(a>9 || b>9)
        c=-1;
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
int main(){
  int r,c,i,j,hyo[101][101];

  scanf("%d %d",&r,&c);
  for(i=0;i<r;i++){
    for(hyo[i][c]=0,j=0;j<c;j++){
      scanf("%d",&hyo[i][j]);
      hyo[i][c]+=hyo[i][j];
    }
  }
  for(i=0;i<=c;i++)for(hyo[r][i]=0,j=0;j<r;j++) hyo[r][i]+=hyo[j][i];

  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      printf("%d",hyo[i][j]);
	if(j!=c) printf(" ");
	else printf("\n");
    }
  }
 
  return 0;
}

Measured memory_bytes: 644
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String S[] = s.split("");
        for (int i = 0; i < S.length; i++) {
            String check = S[i];
            for (int j = 0; j < S.length; j++) {
                if (i == j)
                    continue;
                if (S[i].equals(S[j])) {
                    System.out.println("no");
                    return;
                }
            }
        }
        System.out.println("yes");
    }
}

Measured memory_bytes: 21716
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int sum[100010];

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

  int N, M; cin >> N >> M;
  REP(i, M){
    int l, r; cin >> l >> r;
    sum[l]++; sum[r+1]--;
  }
  int ans = 0;
  REP(i, N){
    sum[i+1] += sum[i];
    if(sum[i+1] == M){
      
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	n=n%100;
	n=n%10;
	if(n==2||n==4||n==5||n==7||n==9) printf("hon\n");
	else if(n==0||n==1||n==6||n==8) printf("pon\n");
	else if(n==3) printf("bon\n");
	return 0;
}


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

int main(void) {
	string str;
	
	while(cin >> str) {
		int len = str.length();
		for(int i = 0; i < len; ++i) {
			char c = str[i];
			if(c == '@') {
				int n = str[i + 1] - '0';
				char s = str[i + 2];
				i += 2;
				for(int j = 0; j < n; ++j) {
					cout << s;
				}
			} else {
				cout << c;
			}
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
map<string,bool> bj;
int main()
{
	int n,i;
	bool ans=0;
	cin >> n;
	string no;
	cin >> no;
	bj[no] = 1;
	for(i=1;i<n;i++)
	{
		string w;
		cin >> w;
		if(bj.find(w) != bj.end())
			ans = 1;
		else
			bj[w] = 1;
		if(no[no.length()-1] != w[0])
			ans = 1;
		no = w;
	}
	if(ans)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

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

int main(int argc, char const *argv[])
{
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int ans = INT_MAX;
	vector<int> f(26, 0);
	for (int i = 0; i <= n-m; ++i)
	{
		int tmp = 0;
		for (int j = 0; j < m; ++j)
		{
			if (s[i+j] != t[j]) {
				tmp++;
			} 
		}
		ans = min(ans, tmp);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3576
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        n: i64,
        m: usize,
        a: [i64; m],
    }
    let ans = max(-1, n - a.iter().sum::<i64>());
    println!("{}", ans);
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 5 && b == 5 && c == 7){
        cout << "YES" << endl;
    }
    else if(a == 5 && b == 7 && c == 5){
        cout << "YES" << endl;
    }
    else if(a == 7 && b == 5 && c == 5){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

readArrayDefault :: (MArray a e m, Ix i) => a i e -> e -> i -> m e
readArrayDefault arr def i = do
    bounds <- getBounds arr
    if inRange bounds i then readArray arr i else return def

main = do
    getLine
    as <- getInts
    let r = last as
    let (x:t) = init as
    arr <- newArray (0,20) 0 :: IO (IOArray Int Integer)
    writeArray arr x 1
    forM_ t $ \y -> do
        m <- sequence [(+) <$> readArrayDefault arr 0 (z-y) <*> readArrayDefault arr 0 (z+y) | z <- [0..20]]
        forM_ (zip [0..20] m) $ \(i,s) -> writeArray arr i s
    readArray arr r >>= print
    
    

Measured memory_bytes: 4340
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MOD=1e9+7;
const int INF=1<<29;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
  int n,m;
  cin>>n>>m;
  vector<int> dp(n+1);
  dp[0]=1;
  vector<bool> visited(n);
  for(int i=0;i<m;i++){
	   int x;
	   cin>>x;
	   visited[x]=true; 
	 }
	for(int i=1;i<=n;i++){
	  if(visited[i])continue;
	  if(i>=1)dp[i]=(dp[i]+dp[i-1])%MOD;
	  if(i>=2)dp[i]=(dp[i]+dp[i-2])%MOD;	
	}
	cout<<dp[n]<<endl;	
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}


Measured memory_bytes: 1024
from math import ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))

def is_ok(X):
    #最大値をX以下にできるか
    cnt = 0
    for a in A:
        cnt += ceil(a/X)-1
    return cnt <= K

def bisearch(high,low):
    while high - low > 1:
        mid = (high+low)//2
        if is_ok(mid):
            high = mid
        else:
            low = mid
    return high

print(bisearch(10**9+1,0))

Measured memory_bytes: 104328
#include <stdio.h>
int main(void)
{
	while(1){
		int i,j,n;
		int count = 0;
		int sum;
		scanf("%d",&n);
		if (!n) break;
		for(i=1;i<=n/2;i++){
			sum = i;
			for(j=i+1;sum<n;j++){
				sum += j;
			}
			if (sum == n){
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
/**
 * @author      : cromarmot (yexiaorain@gmail.com)
 * @license     : GPL
 * @created     : 星期六 10月 05, 2019 20:18:37 CST
 */

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

typedef long long ll;
#define ten5 100000+10
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define iif(c,t,f) ((c)?(t):(f))
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
const double pi = acos(-1.0);

int n;

char s[210][210];

// 如果可以相邻 就可以二分?

int imp[210];
int stk[210];
int stki = 0;

bool impchk(){
  int st = 0;
  int rear = 1;
  stk[0] = 0;
  imp[0] = 1;
  while(st < rear){
    int p = stk[st];
    rep(i,0,n){
      if(s[p][i] == '0')continue;
      if(imp[i] == 0){
        imp[i] = 3-imp[p];
        stk[rear++] = i;
        continue;
      }
      if(imp[i] != 3- imp[p]){
        return true;
      }
    }

    st++;
  }
  return false;
}

int Floyd[210][210];

int main(){
  cin>>n;
  rep(i,0,n){
    scanf("%s",s[i]);
  }
  if(impchk()){
    cout<<-1<<endl;
    return 0;
  }
  rep(i,0,n){
    rep(j,0,n){
      Floyd[i][j] = s[i][j] == '0'?999:1;
    }
  }


  // 两个点最远距离
  rep(k,0,n){
    rep(i,0,n){
      rep(j,0,n){
        if(i == j) continue;
        if(Floyd[i][k] != 999 && Floyd[k][j] != 999 && Floyd[i][j] > Floyd[i][k] + Floyd[k][j]){
          Floyd[i][j] = Floyd[i][k] + Floyd[k][j];
        }
      }
    }
  }
  int ans = 0;
  rep(i,0,n){
    rep(j,0,n){
      if(i == j) continue;
      ans= max(ans,Floyd[i][j]);
    }
  }
  cout<<ans+1<<endl;
  return 0;
}

/*
 *
 * hash prime
   61,83,113,151,211,281,379,509683,911
   1217,1627,2179,2909,3881,6907,9209
   12281,16381,21841,29123,38833,51787,69061,92083
   122777,163729,218357,291143,388211,517619,690163,999983
   1226959,1635947,2181271,2908361,3877817,5170427,6893911,9191891
   12255871,16341163,21788233,29050993,38734667,51646229,68861641,91815541
   122420729,163227661,217636919,290182597,386910137,515880193,687840301,917120411
   1000000007,1000000009
 * */



Measured memory_bytes: 512
N = int(input())
A = list()
B = list()
m = float('inf')
for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

if A == B: print(0)
else:
    seriesSum = sum(A)
    for i in range(N):
        if A[i] > B[i]:
            m = min(m, B[i])
    print(seriesSum - m)


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

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

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);

    if (b == 1) {
        printf("0\n");
        return 0;
    }

    for (int i = 1;; i++)
        if (a * i - (i - 1) >= b) {
            printf("%d\n", i);
            return 0;
        }

    return 0;
}


Measured memory_bytes: 256
using System;

namespace Aizu {
    class OnlineJudge {
        static void Main() {
            int count = 0;
            var table = new[] { 'A', 'Z' };
            var input = Console.ReadLine();
            var output = new System.Text.StringBuilder();
            for (var i = 0; i < input.Length; ++i) {
                if (input[i] == table[(count & 1)]) {
                    if ((++count & 1) == 0) {
                        output.Append("AZ");
                    }
                }
            }
            Console.WriteLine(output.Length > 0 ? output.ToString() : "-1");
        }
    }
}

Measured memory_bytes: 8936
/**
 * @author yuzining
 * @date 2020/07/12 18:51
*/

#ifdef local
#include "D:\vscode\acm\local.hpp"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
  return 0;
}
#endif

int f[10005];

void Main() {
  for(int i = 1; i <= 100; i++) {
    for(int j = 1; j <= 100; j++) {
      for(int k = 1; k <= 100; k++) {
        const int cur = i * i + j * j + k * k + i * j + i * k + j * k;
        if(cur > 10000) continue;
        f[cur]++;
      }
    }
  }
  int n; cin >> n;
  for(int i = 1; i <= n; i++) {
    cout << f[i] << "\n";
  }
}

Measured memory_bytes: 3696
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    string s;
    cin>>s;
    int l=s.length();
    int ans=MOD;
    for(int i=0;i<l-1;i++){
        if(s[i]!=s[i+1]){
            int a=max(i+1,l-i-1);
            if(a<ans){
                ans=a;
            }
        }
    }
    if(ans==MOD){
        ans=l;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512