akhauriyash/Code-Regression huggingface dataset:
N, M = [int(x) for x in input().split()]

sum_c = 0
dic = {0:1}
for x in input().split():
    x = int(x)
    sum_c += x
    a = sum_c%M
    
    if dic.get(a,0) == 0:
        dic[a] = 1
    else:
        dic[a] += 1

ans = 0
ans += dic[0]*(dic[0]-1)/2
dic.pop(0)
for v in dic.values():
    ans += v*(v-1)/2
print(int(ans))

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

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

  vector<int> a(N);
  int i;
  for(i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());

  i=0;
  for(i=0; i<N; i++){
    x-=a.at(i);
    if(x<0){
      break;
    }
  }
  if(i==N && x>0){
    cout << i-1 << endl;
  }else{
    cout << i << endl;
  }
}



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

using namespace std;

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

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	for (int i=1; i<n; i++) {
		int cnt = 0;

		for (char c='a'; c<='z'; c++) {
			bool left=false, right=false;
			for (int j=0; j<i; j++) {
				if(s[j]==c) left=true;
			}
			for (int j=i; j<n; j++) {
				if (s[j]==c) right=true;
			}
			if (left&&right) cnt++;
		}

		if (ans<cnt) ans=cnt;
	}

	cout << ans << endl;
}


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0, c = 0; i < n; i++)
		if (s[i] == '(')
			c++;
		else if (c)
			c--;
		else
			cout << '(';
	cout << s;
	for (int i = 0, c = 0; i < n; i++)
		if (s[n - 1 - i] == ')')
			c++;
		else if (c)
			c--;
		else
			cout << ')';
	cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int   long long 
#define endl "\n"
using namespace std;

signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t;cin>>t;
  if(t == 0) cout<<1<<endl;
  else cout<<0<<endl;
}


/*
 ==========================
    Author-Shivmangal
 ==========================
 */




Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main()
{
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(r>x||r>y){
		cout<<"No"<<endl;
	}else if(y+r>H||x+r>W){
		cout<<"No"<<endl;
	}else{cout<<"Yes"<<endl;}
	
	return 0;
}


Measured memory_bytes: 3068
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define ll long long
const int N = 2005;
const ll mod = 1e9+7;

int n,m,a[N],b[N];
ll dp[N][N],sum[N][N];

int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= m; i++) cin >> b[i];
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++){
			if(a[i] == b[j]) dp[i][j] = sum[i-1][j-1] + 1;
			else dp[i][j] = 0;
			sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j];
			dp[i][j] %= mod;
			sum[i][j] %= mod;
	}
	cout << (sum[n][m] + 1 + mod) % mod;
}

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

int main() {
  string S, T;
  int a=0;
  cin >> S >> T;
  rep(i, S.size()){
    if(S==T){
      a=1;
      break;
    }
    S=S.back()+S.substr(0,S.size()-1);
  }
  if(a==1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
    int n;
    cin>>n;
    ll ans = pow(n,3);
    cout<<ans<<endl;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	var K, S int
	K, S = readInt(), readInt()
	cnt := 0
	for i := 0; i <= K; i++ {
		for j := 0; j <= K; j++ {
			if k := S - (i + j); 0 <= k && k <= K {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [isize; n],
    }

    let mut dp = vec![0; n];
    
    for i in 1..n {
        let mut tmp = 1 << 60;
        for j in 1..k+1 {
            if i >= j {
                tmp = cmp::min(tmp, dp[i-j] + (h[i]-h[i-j]).abs());
            }
        }
        dp[i] = tmp;
    }

    println!("{}", dp[n-1]);

}


Measured memory_bytes: 6396
### subroutines

def d2n(ds)
  sum = 0
  for d in ds
    sum = sum * 10 + d
  end
  sum
end

def next_a(ai, l)
  ds = []
  k = 0
  while ai > 0
    ds[k] = ai % 10
    ai /= 10
    k += 1
  end
  while k < l
    ds[k] = 0
    k += 1
  end

  min_d = d2n(ds.sort!)
  max_d = d2n(ds.reverse!)
  max_d - min_d
end

### main

loop do
  a0, l = gets.split.map(&:to_i)
  break if (a0 | l) == 0

  as = [a0]
  i = j = 0

  loop do
    i += 1
    as[i] = next_a(as[i - 1], l)
    j = as.index(as[i])
    break if j < i
  end

  puts [j, as[i], i - j].join(' ')
end

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

int main(){
  int n;
  cin >> n;
  int A[n];
  for(int i = 0; i < n; i++){
    cin >> A[i];
  }
  int ans = 0;
  for(int i = 1;i < n;i++){
    if(A[i] == A[i-1]){
      ans += 1;
      A[i] = -1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>

template <typename C>
void print_container(const C &c, const std::string &name)
{
  std::cout << name << ": ";
  std::for_each(c.cbegin(), c.cend(),
                [](auto &x) { std::cout << x << ", "; });
  std::cout << std::endl;
}

template <typename Map>
void chomp(Map &x, uint64_t k)
{
  auto it = x.begin();
  uint64_t i = 0;
  uint64_t min = *x.begin();
  while(it != x.end()) {
    if(k <= i && *it != min) {
      it = x.erase(it);
    } else {
      min = *it;
      it++;
    }
    i++;
  }
}

int main()
{
  uint64_t X, Y, Z, K;
  std::cin >> X >> Y >> Z >> K;
  std::multiset<uint64_t, std::greater<uint64_t> > A, B, C;
  for(uint64_t i=0; i<X; i++) {
    uint64_t t; std::cin >> t;
    A.insert(t);
  }
  for(uint64_t i=0; i<Y; i++) {
    uint64_t t; std::cin >> t;
    B.insert(t);
  }
  for(uint64_t i=0; i<Z; i++) {
    uint64_t t; std::cin >> t;
    C.insert(t);
  }

  // chmop after K-element
  chomp(A, K);
  // print_container(A, "A");
  chomp(B, K);
  // print_container(B, "B");
  chomp(C, K);
  // print_container(C, "C");

  // calc A+B top-K
  std::multiset<uint64_t, std::greater<uint64_t> > AB;
  uint64_t min = *A.begin() + *B.begin();
  for(const auto &a: A) {
    for(const auto &b: B) {
      auto ab = a + b;
      if(AB.size() < K) {
        AB.insert(ab);
        min = *AB.rbegin();
      } else if(min < ab) {
        AB.erase(--AB.end());
        AB.insert(ab);
        min = *AB.rbegin();
      }
    }
  }
  // print_container(AB, "AB");

  std::multiset<uint64_t, std::greater<uint64_t> > ABC;
  min = *AB.begin() + * C.begin();
  for(const auto &ab: AB) {
    for(const auto &c: C) {
      auto abc = ab + c;
      if(ABC.size() < K) {
        ABC.insert(abc);
        min = *ABC.rbegin();
      } else if(min < abc) {
        ABC.erase(--ABC.end());
        ABC.insert(abc);
        min = *ABC.rbegin();
      }
    }
  }
  // print_container(ABC, "ABC");

  uint64_t i = 0;
  for(auto abc: ABC) {
    if(i == K) break;
    std::cout << abc << std::endl;
    i++;
  }

  return 0;
}


Measured memory_bytes: 4048
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,j,cnt1,cnt2;
	cnt1=0;
	cnt2=0;
	//cout<<"1"<<endl;
	cin>>n;
	//cout<<n<<endl;
	for(i=1;i<=n;i=i+2){
		for(j=1;j<=n;j++){
			if(i%j==0){
				cnt1=cnt1+1;
			}
		}
		if(cnt1==8){
			cnt2=cnt2+1;
		}
		cnt1=0;
	}
	//cout<<"2"<<endl;
	cout<<cnt2<<endl;
	
	return 0;
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A+B==C+D)cout << "Balanced" << endl;
  else if(A+B>C+D)cout << "Left" << endl;
  else if(A+B<C+D)cout << "Right" << endl;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  string s;
  cin>>s;
  if(s.back()=='s')cout<<s+"es";
  else cout<<s+"s";
  return 0;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

ll n, m, l, ans;
bool memo[10];

ll num(ll tri, ll ord){
	ll c = (tri / (ll)pow(4, ord)) % 4;
	if(c==0) return 0;
	if(c==1) return 3;
	if(c==2) return 5;
	if(c==3) return 7;
} 

int main(){
	cin >> n;
	for(int i=0;i<pow(4, 9);i++){
		ll d = 0;
		ll z = -1;
		memo[0] = 0;
		memo[3] = 0;
		memo[5] = 0;
		memo[7] = 0;
		for(int j=0;j<=(ll)(log(i)/log(4));j++){
			d += num(i, j) * (ll)pow(10, j); 
			memo[num(i, j)] = true;
		}
		if(n>=d && memo[3] && memo[5] && memo[7] && !memo[0]){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
from heapq import heapify, heappop, heappush, heappushpop

class PriorityQueue:
    def __init__(self, heap=None):
        '''
        heap ... list
        '''
        self.heap = heap or []
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)


def solve(N,A,B,C,D):
    pq = PriorityQueue()
    visited = dict()

    best = 2 ** 63
    pq.push((0, N))

    while len(pq) > 0:
        cost, now = pq.pop()
        if now < 0:
            continue
        if now in visited and visited[now] <= cost:
            continue
        visited[now] = cost

        # debug("cost %lld, now %lld, [%d]\n", cost, now, last);
        if now == 0:
            best = min(best, cost)

        for d in range(-4, 5):
            x = now + d
            c = cost + D*abs(d)
            if x == 0:
                best = min(best, c)
            if x % 5 == 0:
                minc = min(C, D*(x - x//5))
                pq.push((c+minc, x//5))

        for d in range(-2, 3):
            x = now + d
            c = cost + D*abs(d)
            if x == 0:
                best = min(best, c)
            if x % 3 == 0:
                minc = min(B, D*(x - x//3))
                pq.push((c+minc, x//3))

        for d in range(-1, 2):
            x = now + d
            c = cost + D*abs(d)
            if x == 0:
                best = min(best, c)
            if x % 2 == 0:
                minc = min(A, D*(x - x//2))
                pq.push((c+minc, x//2))

    return best

if __name__ == '__main__':
    T = int(input())
    for t in range(T):
        N,A,B,C,D = map(int, input().split(' '))
        print(solve(N,A,B,C,D))


Measured memory_bytes: 13132
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = list(map(int, input().split()))

    ans = 0
    for C in range(1, N):
        n = N // C
        dp = [0] * n
        used = set([0])
        for k in range(1, n):
            A = N - 1 - k*C
            if A in used or k*C in used or A == k*C:
                break
            used.add(A)
            used.add(k*C)

            dp[k] = dp[k-1] + S[A] + S[k*C]

        ans = max(ans, max(dp))

    return ans


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


Measured memory_bytes: 19412
def jud(l):
  for i in range(3):
    for j in range(3):
      if l[i][j] != 0:
        break
      if j == 2:
        return 1
  for i in range(3):
    for j in range(3):
      if l[j][i] != 0:
        break
      if j == 2:
        return 1
  for i in range(3):
      if l[i][i] != 0:
          break
      if i == 2:
          return 1
  for i in range(3):
      if l[i][2-i] != 0:
          break
      if i == 2:
          return 1
  return 0
          
       
def op(l,a):
  for i in range(3):
    for j in range(3):
      if l[i][j] == a:
        l[i][j] = 0
  return l

l = []
for i in range(3):
  l.append(input())
  l[i] = l[i].split()
  for j in range(3):
    l[i][j] = int(l[i][j])
num = int(input())
for i in range(num):
  a = int(input())
  l = op(l,a)
if jud(l) == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll sumr[4010];
ll sumg[4010];
ll sumb[4010];

void solve(){

    ll n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,4010){
        sumr[i]=0;
        sumg[i]=0;
        sumb[i]=0;
    }
    rep(i,n){
        sumr[i+1]=sumr[i];
        sumg[i+1]=sumg[i];
        sumb[i+1]=sumb[i];
        if(s[i]=='R') sumr[i+1]++;
        if(s[i]=='G') sumg[i+1]++;
        if(s[i]=='B') sumb[i+1]++;
    }

    ll ans = 0;
    for(ll i=0; i<n; i++){
        for(ll j=i+1; j<n; j++){
            char p = s[i];
            char q = s[j];
            char r;
            if(p=='R'&&q=='G'||p=='G'&&q=='R') r='B';
            else if(p=='R'&&q=='B'||p=='B'&&q=='R') r='G';
            else if(p=='B'&&q=='G'||p=='G'&&q=='B') r='R';
            else continue;
            ll k = 2*j-i;

            if(r=='R'){
                if(s[k]=='R') ans--;
                ans += sumr[n]-sumr[j+1];
            }
            if(r=='G'){
                if(s[k]=='G') ans--;
                ans += sumg[n]-sumg[j+1];
            }
            if(r=='B'){
                if(s[k]=='B') ans--;
                ans += sumb[n]-sumb[j+1];
            }
        }
    }

    cout << ans << endl;


}

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


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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> v(N);
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    v[b].push_back(a);
    v[a].push_back(b);
  }
  int c[N];
  int ans=0;
  rep(i,N) {cin >> c[i];ans+=c[i];}
  sort(c,c+N,greater<int>());
  ans-=c[0];
  queue<int> q;
  q.push(0);
  bool u[N];
  rep(i,N) u[i]=false;
  u[0]=true;
  int d[N];
  d[0]=c[0];
  int cnt=1;
  while(!q.empty()){
    int x=q.front();
    q.pop();
    for(auto y:v[x]) if(u[y]==false){
      u[y]=true;
      d[y]=c[cnt];
      cnt++;
      q.push(y);
    }
  }
  cout << ans << endl;
  rep(i,N) cout << d[i] << (i==N?"\n":" ");
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){

    int n;
    cin >> n;
    VI a(n);
    REP(i,n)cin >> a[i];
    double res=0.0;
    REP(i,n)res+=(double)1/a[i];
    cout << 1/res << endl;

    return 0;
}

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

int arr[100001][3];
int dp[100001][3];
int solve(int n,int i,int k)
{
	if(i==0)
	{
		return max(solve(n,1,0)+arr[0][0],max(solve(n,1,1)+arr[0][1],solve(n,1,2)+arr[0][2]));
	}
	if(i==n)
		return 0;
	int x=0,y=0;
	if(dp[i][k]!=-1)
		return dp[i][k];
	if(k==2)
	{
		x=solve(n,i+1,0)+arr[i][0];
		y=solve(n,i+1,1)+arr[i][1];
	}
	else if(k==0)
	{
		x=solve(n,i+1,1)+arr[i][1];
		y=solve(n,i+1,2)+arr[i][2];
	}
	else
	{
		x=solve(n,i+1,0)+arr[i][0];
		y=solve(n,i+1,2)+arr[i][2];
	}
	return dp[i][k]=max(x,y);
}

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(n,0,-1);
	return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

//----------------------------------------


#include<random>

int main(void)
{

	ll l, r;
	ll ans = 9999999999999999;
	cin >> l >> r;

	for (ll i = l; i <= r; i++)
	{
		for (ll j = l; j < i; j++)
		{
			ans = min(ans, (i*j)%2019);
			if (ans == 0)
			{
				cout << 0 << endl;
					return 0;
			}
		}
	}
	cout << ans << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;


int dp[100100][20];


signed main() {
  string N; cin >> N;
  int l = N.size();
  vector<int> n;
  for (auto a : N) {
    if ( a == '?') {
      n.push_back(-1);
    } else {
      n.push_back(a - '0');
    }
  }

  // for (auto b : n) {
  //   cout << b << endl;
  // }

  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  
  for (int i = 0; i < l; i++) {
    for (int j = 0; j < 13; j++) {
      if (n[i] != -1) {
        dp[i+1][(j * 10 + n[i]) % 13] += (dp[i][j] % 1000000007);
        dp[i+1][(j * 10 + n[i]) % 13] %= 1000000007;
      } else {
        for (int x = 0; x <= 9; x++) {
          dp[i+1][(j * 10 + x) % 13] += (dp[i][j] % 1000000007);
          dp[i+1][(j * 10 + x) % 13] %= 1000000007;
        }
      }
    }
  }
  cout << dp[l][5] << endl;
}


Measured memory_bytes: 17012
N = int(input())
A = list(map(int, input().split()))
m = A[0]
if 0 in A:
    print('0')
else:
    for i in range(1,N):
        m *= A[i]
        if m > 10**18:
            print('-1')
            break
    else:
        print(m)




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

const int N = 1e5;
vector<int> conns[N];
int res[N];

void fill(int i, int p, int& j, const vector<int>& vals) {
	for (auto t : conns[i]) {
		if (t == p) continue;
		fill(t, i, j, vals);
	}
	res[i] = vals[j];
	++j;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n-1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		conns[a].push_back(b);
		conns[b].push_back(a);
	}

	vector<int> cs(n);
	for (int i = 0; i < n; ++i) cin >> cs[i];
	sort(cs.begin(), cs.end());

	int j = 0;
	fill(0, 0, j, cs);

	ll ans = 0;
	for (int i = 1; i < n; ++i) ans += res[i];

	cout << ans << '\n';
	for (int i = 0; i < n; ++i) cout << res[i] << ' '; cout << '\n';
}


Measured memory_bytes: 3840
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	string s1,s2;
	s1="ABC";
	s2 = "ARC";
	string en;
	cin>>en;
	if(en.compare(s1)==0)cout<<s2<<endl;
	else cout<<s1<<endl;
	
	return 0;
}

Measured memory_bytes: 3100
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    string s;
    scan(s);
    auto n = s.length.to!int;

    int r = s.count!"a == '0'".to!int;
    int b = s.count!"a == '1'".to!int;

    int rem = abs(r - b);

    int ans = n - rem;

    writeln(ans);
}




int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 508
#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 ans = 1;
    char now = s[0];

    for(int i=1; i<n; i++){
        if(s[i] == now) continue;
        else { ans++; now = s[i];}
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

void func(void)
{
//DEBUG_OUT("----\n");
    uint32 N, M;
    cin >> N >> M;
    vector< pair<uint32,uint32> > ab(M);
    for(uint32 i=0; i<M; i++){
        uint32 tmpA, tmpB;
        cin >> tmpA >> tmpB;
        ab[i].first = tmpA;
        ab[i].second = tmpB;
    }

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

    // for iland N
    vector<uint32> forNList(M, UINT32_MAX);
    uint32 forNcnt = 0;
    for(uint32 i=0; i<M; i++){
        if(ab[i].second == N){
            forNList[forNcnt] = ab[i].first;
            forNcnt++;
        }
    }
    forNList.erase(forNList.begin() + forNcnt, forNList.end());
    sort(forNList.begin(), forNList.end());
	forNList.erase(unique(forNList.begin(), forNList.end()), forNList.end());

    vector<int8> truefalse(200000, -1);
    for(uint32 i=0; i<forNList.size(); i++){
        truefalse[ forNList[i] ] = 1;
    }

    uint32 prevSecond = 0;
    for(uint32 i=0; i<M; i++){
        if(ab[i].first==1){
            if(ab[i].second != prevSecond){
                if(1 == truefalse[ab[i].second]){
                    cout << "POSSIBLE" << endl;
                    return;
                }
                prevSecond = ab[i].second;
            }
        }else{
            break;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return;
}



Measured memory_bytes: 2816
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint i,n,mae=mod,ans=0;
	cin>>n;
	for(i=0;i<n;i++){
		llint x;cin>>x;
		if(mae>=x){ans++;}
		mae=x;
	}
	cout<<ans<<endl;
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
ll d,g;
cin >>d>>g;
ll p[d],c[d],u[d];
for(ll i=0;i<d;i++) cin >> p[i]>>c[i];
ll ans=100000,sum,k,a;
for(ll i=0;i<1<<d;i++){
  priority_queue<ll> q;
  sum=0,k=0;
  for(ll j=0;j<d;j++) u[j]=0;
  for(ll j=0;j<d;j++){
    if(i&(1<<j)){
      sum+=((p[j]*100*(j+1))+c[j]);
      k+=p[j];u[j]=1;
    }
    else{
      for(ll k=0;k<p[j];k++){
        q.push((j+1)*100);
      }
    }
  }
  while(sum<g){
    if(q.empty()) break;
    sum+=q.top();
    k++;
    q.pop();
  }
  if(sum>=g) ans=min(ans,k);
}
cout <<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> s(N);
	auto sum = 0;
	for (auto i = 0; i < N; ++i)
	{
		cin >> s[i];
		sum += s[i];
	}

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

	if (sum % 10 == 0)
	{
		auto i = 0; 
		for (; i < N; ++i)
		{
			if (s[i] % 10 > 0)
			{
				sum -= s[i];
				break;
			}
		}

		if (i == N)
		{
			sum = 0;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  test130
//
//  Created by  on 2019/06/16.
//  Copyright © 2 All rights reserved.
//
//
//  main.cpp
//  new
//
//  Created on 2019/06/09.
//  Copyright  All rights reserved.
//

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define int long long
using namespace std;

int n,ans,p;

signed main(){
    cin>>n>>p;
    n-=p*2;
    if (n<0) {
        n=0;
    }
    cout<<n<<endl;
}






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

int main() {
	int h, w;
	cin >> h >> w;
	char c[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
		}
	}
	vector<string> ans;
	for (int i = 0; i < h; i++) {
		bool flag = true;
		for (int j = 0; j < w; j++) {
			if (c[i][j] == '#') flag = false;
		}
		if (!flag)ans.push_back(c[i]);
	}
	bool FLAG[w] = {};
	for (int j = 0; j < w; j++) {
		bool flag = true;
		for (int i = 0; i < ans.size(); i++) {
			if (ans[i][j] == '#') flag = false;
		}
		if (!flag) FLAG[j] = true;
	}
	cout << endl;
	for (int i = 0; i < ans.size(); i++) {
		for (int j = 0; j < w; j++) {
			if (FLAG[j]) cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

map<ll, ll> memo, p;
ll d;

ll solve(ll n){
    if (n==0) return 0;
    if (n==1) return d;
    if (memo.count(n)) return memo[n];

    ll res = 1e18;
    if (n < res/d) res = n*d;
    for (auto x : p){
        ll l = n/x.fi;
        ll r = (n+x.fi-1)/x.fi;
        res = min(res, llabs(x.fi*r-n)*d+x.se+solve(r));
        res = min(res, llabs(x.fi*l-n)*d+x.se+solve(l));
    }
    memo[n] = res;
    return res;
}

int main()
{
    int t;
    cin >> t;
    rep(i,t){
        memo.clear();p.clear();
        ll n;
        cin >> n >> p[2] >> p[3] >> p[5] >> d;
        cout << solve(n) << endl;
    }
}

Measured memory_bytes: 4400
#include<cstdio>
#include<cstring>
using namespace std;
int main(void)
{
    int n;
    int a[4];
    char ch[10];
    char str[4][10]={{"AC"},{"WA"},{"TLE"},{"RE"}};
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        getchar();
        for(int i=0;i<n;++i)
        {
            scanf("%s",ch);
            for(int j=0;j<4;++j)
            {
                if(strcmp(ch,str[j])==0)
                a[j]++;
            }
        }
        for(int i=0;i<4;++i)
            printf("%s x %d\n",str[i],a[i]);
    }
    
    return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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



///////////////////////////

ll N;

vector<ll> g[MAX];

vector<ll> tree[MAX];//根付き木に変換したときの隣接行列

bool see[MAX] = {};

void dfs(ll v) {
	see[v] = 1;
	rep(i, g[v].size()) {
		ll w = g[v][i];
		if (see[w] == 1) { continue; }
		tree[v].push_back(w);
		dfs(w);
	}
	//cout << v << tree[v].size()<<endl;
	return;
}

ll son[MAX] = {};//子ノードの個数

void son_calc(ll v) {
	son[v] = 0;
	rep(i, tree[v].size()) {
		ll w = tree[v][i];
		son_calc(w);
		son[v] += son[w] + 1;
	}
	//cout << v << son[v] << endl;
	return;
}

ll p(ll n) {
	if (n == 0) { return 1; }
	if (n == 1) { return 2; }
	ll x = p(n / 2);
	return x * x%MOD*p(n % 2) % MOD;
}

ll iv(ll i) {
	if (i == 1) { return 1; }
	return MOD - iv(MOD%i)*(MOD / i) % MOD;
}

int main() {
	ll N;
	cin >> N;

	repn(i, N - 1) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	dfs(1);
	son_calc(1);
	
	ll ans = 0;

	for (int u = 1; u <= N; u++) {
		vector<ll> branch;

		ll sum = 0;
		rep(i, tree[u].size()) {
			ll v = tree[u][i];
			branch.push_back(son[v] + 1);
			sum += son[v] + 1;
		}

		if (u != 1) { branch.push_back(N - 1 - sum); }

		ll x = p(N-1)+branch.size()-1;
		rep(i, branch.size()) {
				x -= p(branch[i]);
				x %= MOD;
				if (x < 0) { x += MOD; }
				//cout << u << branch[i] << endl;
		}

			ans = (ans + x) % MOD;
	}

	ans = iv(p(N))*ans % MOD;

	cout << ans;


	system("PAUSE");

}


Measured memory_bytes: 72692
N = int(input())

keta = len(str(N))

ans = 0

if keta == 1:
    ans = N

elif keta % 2 == 0:
    ans = 9
    k = 3
    while k < keta:
        ans += 10**k - 10**(k-1)
        k += 2

else:
    ans = 9
    k = 3
    while k < keta:
        ans += 10**k - 10**(k-1)
        k += 2
    ans += N - 10**(keta-1) + 1

print(ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


int main(void) {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	


	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		cout << 'x';
	}

    





	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    string s;
    cin >> s;
    int one_cnt = 0,zero_cnt = 0;
    for(int i = 0;i<(int)s.length();i++)
    {
        if(s[i] == '0')
        zero_cnt ++;
        else
        one_cnt++;
    }
    cout  << 2*min(zero_cnt,one_cnt) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
ll n;
cin>>n;

ll a[n+1];
ll v[n+1];
cin>>a[0];
rep(i,n){
	cin>>a[i];
}
for(int i=0;i<=n;i++){
	v[i]=(ll)-1;
}

ll ans=0;
ll now=0;

if(n==0){if(a[0]==1)cout<<1<<endl;
else cout<<-1<<endl;
return 0;
}
if(a[0]>=1 && n>=1){
	cout<<-1<<endl;
	return 0;
}

v[0]=(ll)1;
for(int i=1;i<=n;i++){
	int fin=0;
v[i]=v[i-1]*(ll)2-a[i];
if(v[i-1]>=inf){
for(int j=i+1;j<=n;j++){
	v[j]=v[i];
}
fin=1;
}
if(fin)break;

if(v[i]<0){cout<<-1<<endl;
return 0;}
if(v[i]==0){
	if(i!=n){cout<<-1<<endl;
	return 0;}
}
}


for(int i=n;i>=0;i--){
	if(i==n){
		now+=a[i];
		ans+=now;
continue;
	}
	ll pnow=now;
	
now=(now+(ll)1)/(ll)2;
if(i==0){
	ans+=(ll)1;
	break;
}
if(now==0)
if(now>v[i]){
	cout<<-1<<endl;
	return 0;
}
if(pnow>=v[i]){
	now=v[i];
}
if(pnow<v[i]){
	now=pnow;
}
now+=a[i];
ans+=now;
}


cout<<ans<<endl;
return 0;

}



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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> ss(n);
    for (auto &s : ss) {
        cin >> s;
    }
    sort(begin(ss), end(ss));
    for (auto s : ss) {
        cout << s;
    }
    cout << endl;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int a, b;
  cin >> a >> b;
  int l = 0;
  int x = b;
  while (x){
    l++;
    x/=10;
  }
  forn(i,l) a *= 10;
  a += b;
  debug() << imie(a);
  if (int(sqrt(a)+0.5)*int(sqrt(a)+0.5) == a){
    cout << "Yes";
  } else cout << "No";
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 256
using System;

namespace Tenka1BC2019_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var K = int.Parse(Console.ReadLine());

            var a = S[K - 1];

            var ans = "";
            foreach (var s in S)
            {
                if (s != a)
                {
                    ans += '*';
                }
                else
                {
                    ans += s;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
def main():
    A, B, K = (int(i) for i in input().split())
    result = set()
    A_min = min(A+K-1, B)
    B_max = max(A, B-K+1)
    for i in range(A, A_min+1):
        result.add(i)
    for j in range(B_max, B+1):
        result.add(j)
    for i in sorted(result):
        print(i)


if __name__ == '__main__':
    main()

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

int main(){
	int a,b,c;cin>>a>>b>>c;
int x=7*a+b,cnt=0;
cnt+=c/x*7;int y=c%x;if(y>0)cnt+=min((y-1+a)/a,7);
cout<<cnt<<endl;
}


Measured memory_bytes: 3104
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {
	
	string a, b, c;
	cin >> a >> b >> c;
	string s = "a";
	int ac = 0, bc = 0, cc = 0;
	while (true) {
		if (s[0] == 'a') {
			if (a[ac] == NULL) {
				cout << "A" << endl;
				break;
			}

			s[0] = a[ac];
			ac++;
		}
		if (s[0] == 'b') {
			if (b[bc] == NULL) {
				cout << "B" << endl;
				break;
			}

			s[0] = b[bc];
			bc++;
		}
		if (s[0] == 'c') {
			if (c[cc] == NULL) {
				cout << "C" << endl;
				break;
			}

			s[0] = c[cc];
			cc++;
		}
	}

	return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


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

    if(s.length()!=a+b+1)
    {
        cout<<"No"<<endl;
    }
    else
    {
        ll flag=0;
        for(i=0;i<a;i++)
        {
            if(s[i]>'9' || s[i]<'0')
            {
                flag=1;
                break;
            }
        }

        for(i=a+1;i<s.length();i++)
        {
            if(s[i]>'9' || s[i]<'0')
            {
                flag=1;
                break;
            }
        }

        if(s[a]!='-')
        {
            flag=1;
        }

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


Measured memory_bytes: 256