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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var s = cin.Read;

            var dp1 = new int[n + 1];
            dp1[0] = 0;
            for (int i = 1; i < n; ++i)
            {
                dp1[i] = dp1[i - 1];
                if (s[i - 1] == 'W')
                    dp1[i]++;
            }

            var dp2 = new int[n + 1];
            dp2[n - 1] = 0;
            for (int i = n - 2; i >= 0; --i)
            {
                dp2[i] = dp2[i + 1];
                if (s[i + 1] == 'E')
                    dp2[i]++;
            }

            var min = n + 1;
            for (int i = 0; i < n; ++i)
            {
                min = Math.Min(dp1[i] + dp2[i], min);
            }
            Console.WriteLine(min);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
    }
}


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

int main() {
  
 int N;
 cin >> N;
  
 double K;
 double j;
  
  if(N % 2 == 0){
    cout << 0.5 << endl;
  }
  else{
    K = (N / 2) + 1;
    j = K / N;
    cout << j << endl;
  }
      
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        List<String> cards = new ArrayList<>();
        Stream.of('S', 'H', 'C', 'D')
              .forEach(c -> {
                  IntStream.rangeClosed(1, 13)
                           .forEach(n -> {
                               cards.add(c + " " + n);
                           });
              });
        Scanner sc = new Scanner(System.in);
        sc.nextLine();
        while(sc.hasNext()) {
            String card = sc.nextLine();
            cards.remove(card);
        }
        cards.forEach(c -> {
            System.out.println(c);
        });
    }
}



Measured memory_bytes: 32572
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
m = [int(i) for i in input().split()]
sup = 2000*20
# dp[i][j]: i番目までの整数を用いてjを作れるかどうかTrue/False
dp = [[False for i in range(sup)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(sup):
        dp[i][a[i-1]-1] = True
        if j-a[i-1] >= 0:
            dp[i][j] = dp[i-1][j] or dp[i-1][j-a[i-1]]
        else:
            dp[i][j] = dp[i-1][j]
# print(dp[-1][:10])
for i in range(q):
    if dp[-1][m[i]-1]:
        print('yes')
    else:
        print('no')


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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    int sz1 = s1.size();
    int sz2 = s2.size();
    if(s1[sz1-1] == s2[0] && s2[sz2-1] == s3[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3588
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

struct Edge {
    int from, to, cost;
    Edge(int t, int c) : to(t), cost(c) {}
    Edge(int f, int t, int c) : from(f), to(t), cost(c) {}
    bool operator<(const Edge &e) const {
        return cost < e.cost;
    }
};

const int MAXN = 4010;
struct UnionFind {
    int node[MAXN];
    UnionFind() {
        memset(node, -1, sizeof(node));
    }
    int find(int x) {
        return node[x] < 0 ? x : node[x] = find(node[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        node[x] += node[y];
        node[y] = x;
        return true;
    }
};

using Graph = vector< vector<Edge> >;
int max_edge[MAXN][MAXN];

void dfs(Graph &G, int cur, int par, int orig) {
    int prev_max = max_edge[orig][cur];
    for(auto e : G[cur]) {
        if(e.to == par) continue;
        chmax(max_edge[orig][e.to], max(prev_max, e.cost));
        dfs(G, e.to, cur, orig);
    }
}
 
UnionFind uf;
signed main() {
    int N, M; cin >> N >> M;
    
    vector<Edge> edges;
    for(int i=0; i<M; i++) {
        int u, v, cost; cin >> u >> v >> cost;
        u--; v--;
        edges.emplace_back(u, v, cost);
    }
    sort(edges.begin(), edges.end());

    int sum = 0;
    Graph MST(N);
    for(int i=0; i<M; i++) {
        Edge e = edges[i];
        if(uf.unite(e.from, e.to)) {
            MST[e.from].emplace_back(e.from, e.to  , e.cost);
            MST[e.to  ].emplace_back(e.to,   e.from, e.cost);
            sum += e.cost;
        }
    }

    for(int i=0; i<N; i++) dfs(MST, i, -1, i);

    /*
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            printf("max_edge[%lld][%lld] = %lld\n", i+1, j+1, max_edge[i][j]);
        }
    }
    */

    int Q; cin >> Q;
    for(int i=0; i<Q; i++) {
        int s, t; cin >> s >> t;
        s--; t--;
        // printf("max_edge = %lld\n", max_edge[s][t]);
        cout << sum - max(max_edge[s][t], max_edge[t][s]) << endl;
    }
    return 0;
}

Measured memory_bytes: 138088
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
const ll start = -120;
const ll ender = 120;

vector<int>fifth;

double kthRoot(double n, int k)
{
    return pow(k,
               (1.0 / k)
                   * (log(n)
                      / log(k)));
}

ll power(ll a){

return a*a*a*a*a;

}


int main()
{
    ll x;
    cin>>x;
    ll a,b;



    for(int i=start;i<=ender;i++){

        for(int j=start;j<=ender;j++){

            if(power(i)-power(j)==x){
                a=i;
                b=j;
                break;
            }
        }

    }
   cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 3600
program ABC088B
    implicit none
    integer(8)::N,i
    integer(8)::result=0
    integer(8),allocatable,dimension(:)::A

    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    A=iqsort(A)
    A=A(N:1:-1)
    do i=1,N
        if(mod(i,2)==1)then
            result=result+A(i)
        else
            result=result-A(i)
        end if
    end do

    print'(i0)',result
contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort
end program ABC088B

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(true){
    c -= b;
    if(c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    else{
      a -= d;
      if(a <= 0){
        cout << "No" << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3620
n = int(input())
an = [int(i) for i in input().split()]
bn = [int(i) for i in input().split()]
cn = [int(i) for i in input().split()]
ans = sum(bn)
for i in range(1,n):
  if an[i] == an[i-1] + 1:
    ans += cn[an[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  string s; cin >> s;
  if (N % 2) {
    cout << "No" << CRLF;
    return;
  }
  auto sub = s.substr(0, N/2);
  sub += sub;
  auto ans = s == sub;
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin>>k;
  if(k==1||k==2||k==3||k==5||k==7||k==11||k==13||k==15||k==17||k==19||k==23||k==29||k==31){
    cout<<"1"<<endl;
  }else if(k==4||k==6||k==9||k==10||k==14||k==21||k==22||k==25||k==26){
    cout<<"2"<<endl;
  }else if(k==28||k==30){
    cout<<"4"<<endl;
  }else if(k==8||k==12||k==18||k==20||k==27){
    cout<<"5"<<endl;
  }else if(k==16){
    cout<<"14"<<endl;
  }else if(k==24){
    cout<<"15"<<endl;
  }else{
    cout<<"51"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int h, w; cin >> h >> w;
    vector<string> s(h + 2);
    s[0].resize(w + 2);
    rep(i, w + 2) s[0][i] = '.';
    rep(i, h) {
        string t; cin >> t;
        t = "." + t + ".";
        s[i + 1] = t;
    }
    s[h + 1].resize(w + 2);
    rep(i, w + 2) s[h + 1][i] = '.';
    
    repi(i, 1, h + 1) {
        repi(j, 1, w + 1) {
            if(s[i][j] == '#') {
                cout << '#';
                continue;
            }
            int cnt = 0;
            for(int x = i - 1; x <= i + 1; ++x) {
                for(int y = j - 1; y <= j + 1; ++y) {
                    if(x == i && y == j) continue;
                    if(s[x][y] == '#') cnt++;
                }
            }
            cout << cnt;
        }
        print("");
    }

    return 0;
}


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

queue<int> _que;

void Bfs(int root, vector<vector<int>> &edge, vector<int> &ans,vector<int> &color){
    color[root] = 2;

    int now = root;
    for( auto k : edge[now] ){
        if( color[k] != 0 ) continue;
        ans[k] += ans[now];
        _que.push(k);
    }

    while( !(_que.empty()) ){
        now = _que.front();
        color[now] = 2;

        for( auto k : edge[now] ){
            if( color[k] != 0 ) continue;
            ans[k] += ans[now];
            _que.push(k);
            color[k]++;
        }

        _que.pop();
    }

    
}

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

    vector<int> ans(N);
    vector<int> color(N);
    int q, x;
    for( int i = 0; i < Q; i++ ){
        cin >> q >> x; q--;
        ans[q] += x;
    }

    Bfs(0,edge,ans,color);

    for( int k : ans )cout << k << endl;
}

Measured memory_bytes: 16376
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = sc.nextInt();
	static long[] A = new long[N];
	static long[] B = new long[N];
	static long[] D = new long[N];
	static {
		Arrays.setAll(A, i->sc.nextLong());
		Arrays.setAll(B, i->sc.nextLong());
		Arrays.setAll(D, i-> A[i] - B[i]);
	}
	public static void main(String[] args) {
		long[] remains = Arrays.stream(D).filter(i -> i > 0).sorted().toArray();
		long[] shortages = Arrays.stream(D).filter(i -> i < 0).toArray();
		long shortage = Arrays.stream(shortages).sum();
		int ans = shortages.length;
		for (int j = remains.length - 1; j > -1; j--) {
			if (shortage >= 0) {
				break;
			}
			shortage += remains[j];
			ans++;
		}
		if (shortage < 0) {
			ans = -1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 92788
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

ll d[101][9];

int main(){
	int h, w, k;
	cin >> h >> w >> k;

	int c[9];
	c[0]=1; c[1]=1;
	for(int i=2; i<9; i++){
		c[i]=c[i-1]+c[i-2];
	}
	d[0][1]=1;
	for(int i=2; i<=9; i++){
		d[0][i]=0;
	}

	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			if(j==1){
				d[i][j]=(c[j-1]*c[w-j]*d[i-1][j]+c[j-1]*c[w-j-1]*d[i-1][j+1])%mod;
			}else if(j==w){
				d[i][j]=(c[j-2]*c[w-j]*d[i-1][j-1]+c[j-1]*c[w-j]*d[i-1][j])%mod;
			}else{
				d[i][j]=(c[j-2]*c[w-j]*d[i-1][j-1]+c[j-1]*c[w-j]*d[i-1][j]+c[j-1]*c[w-j-1]*d[i-1][j+1])%mod;
			}
		}
	}
	cout << d[h][k] << endl;
	return 0;
}

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

    class Program
    {
        static void Main()
        {
            string input = Console.ReadLine();
            string input2 = Console.ReadLine();
            string ans = "Yes";
            if (input != input2.LeftB(input2.Length - 1))
            {
                ans = "No";
            }
            else if (input.Length + 1 != input2.Length)
            {
                ans = "No";
            }
            Console.WriteLine(ans.ToString());
        }


    }
    static class Extentions
    {
        #region 拡張メソッド（string）

        public static string LeftB(this string stTarget, int iByteSize)
        {
            return MidB(stTarget, 1, iByteSize);
        }

        public static string MidB(this string stTarget, int iStart)
        {
            System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8");
            byte[] bBytes = hEncoding.GetBytes(stTarget);

            return hEncoding.GetString(bBytes, iStart - 1, bBytes.Length - iStart + 1);
        }

        public static string MidB(this string stTarget, int iStart, int iByteSize)
        {
            System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8");
            byte[] bBytes = hEncoding.GetBytes(stTarget);

            return hEncoding.GetString(bBytes, iStart - 1, iByteSize);
        }

        public static string RightB(this string stTarget, int iByteSize)
        {
            System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8");
            byte[] bBytes = hEncoding.GetBytes(stTarget);

            return hEncoding.GetString(bBytes, bBytes.Length - iByteSize, iByteSize);
        }

        public static bool IsNullOrEmpty(this string str)
        {
            return string.IsNullOrEmpty(str);
        }

        /// <summary>
        /// カルチャに依存した比較、または大文字と小文字を区別しない比較などの序数による比較を指定できる Contains。
        /// </summary>
        /// <param name="value">対象文字列</param>
        /// <param name="partialValue">部分文字列</param>
        /// <param name="comparison">カルチャ、大文字と小文字の区別、および並べ替え規則を指定する StringComparison</param>
        /// <returns>一致する場合に true を返します。</returns>
        public static bool Contains(this string value, string partialValue, StringComparison comparison = 0)
        {
            return value.IndexOf(partialValue, comparison) >= 0;
        }

        #endregion
    }


Measured memory_bytes: 18316
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

int main(void){
  std::string s;
  std::cin >> s;
  
  std::vector<std::pair<int, int> > sections;
  char last = 'R';
  int count_r = 0;
  int count_l = 0;
  for(int i=0; i<s.size(); i++){
    if(last == 'L' && s[i] == 'R'){
      sections.push_back(std::make_pair(count_r, count_l));
      count_r = 1;
      count_l = 0;
    }else if(s[i] == 'R'){
      count_r++;
    }else{
      count_l++;
    }
    last = s[i];
  }
  sections.push_back(std::make_pair(count_r, count_l));
  
  for(const auto& elem: sections){
    
    for(int i=0; i<elem.first-1; i++){
      std::cout << "0 ";
    }
    std::cout << std::ceil(elem.first/2.0)+std::floor(elem.second/2.0) << " ";
    std::cout << std::floor(elem.first/2.0)+std::ceil(elem.second/2.0) << " ";
    for(int j=1; j<elem.second; j++){
      std::cout << "0 ";
    }
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 1144
from heapq import heappush, heappop
h, w = map(int, input().split())
mp = [[-1] + list(input()) + [-1] for _ in range(h)]
mp.insert(0, [-1] * (w + 2))
mp.append([-1] * (w + 2))
que = []
for y in range(1, h + 1):
  for x in range(1, w + 1):
    if "1" <= mp[y][x] <= "9":
      mp[y][x] = int(mp[y][x])
    elif mp[y][x] == ".":
      mp[y][x] = 0
      heappush(que, (0, x, y))
vec = ((0, 1), (0, -1), (1, 1), (1, 0), (1, -1), (-1, 1), (-1, 0), (-1, -1))
while que:
  turn, x, y = heappop(que)
  for dx, dy in vec:
    nx, ny = x + dx, y + dy
    if mp[ny][nx] > 0:
      mp[ny][nx] -= 1
      if mp[ny][nx] == 0:
        heappush(que, (turn + 1, nx, ny))

print(turn)


Measured memory_bytes: 16420
import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int n = reader.nextInt(), zeroCount = 0;
		int[] arr2 = new int[n];
		for (int i = 0; i < n; i++) {
			arr2[i] = reader.nextInt();
			if (arr2[i] == 0) {
				zeroCount++;
			}
		}
		int[] arr = new int[n - zeroCount];
		if (arr.length < 2) {
			System.out.println(0);
		}
		else {
			int encountered = 0;
			for (int i = 0; i < arr2.length; i++) {
				if (arr2[i] == 0) {
					encountered++;
				}
				else {
					arr[i - encountered] = arr2[i];
				}
			}
			long ret = 0;
			BigInteger modThing = new BigInteger("" + ((int) Math.pow(10, 9) + 7));
			BigInteger prev = (new BigInteger("" + arr[arr.length - 2])).multiply(new BigInteger("" + arr[arr.length - 1]));
			BigInteger fakePrev = new BigInteger("0");
			ret += prev.mod(modThing).intValue();
			ret %= Math.pow(10, 9) + 7;
			for (int i = arr.length - 3; i >= 0; i--) {
				BigInteger single = (new BigInteger("" + arr[i])).multiply(new BigInteger("" + arr[i + 1]));
				BigInteger newOne = prev.multiply(new BigInteger("" + arr[i])).divide(new BigInteger("" + arr[i + 1]));
				prev = single.add(newOne);
				ret += prev.mod(modThing).intValue();
				ret %= Math.pow(10, 9) + 7;
			}
			
			System.out.println(ret);
		}
		reader.close();
	}
	
}


Measured memory_bytes: 62944
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <iostream>
#include <deque>
#define  N 100005
#define  ul unsigned long long
#define  ll long long int
#define  loop0(i,a,b) for(int i = a;i<b;++i)
#define  loop1(i,a,b) for(int i = a;i<=b;++i)
#define  ini0(i,b) for(int i = b;i>=0;--i)
#define  ini1(i,b) for(int i = b-1;i>=0;--i)
#define  pl pair<ll,ll>
#define  pi pair<int,int>
#define  ff first
#define  ss second
#define  bg begin()
#define  ed end()

#define  READ freopen("input.txt","r",stdin);
#define  WRITE freopen("output.txt","w",stdout);

#define  test1(x) cout<<#x<<" : "<<x<<endl;   
#define  test2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl;
#define  test3(x,y,z) cout<<#x<<" : "<<x<<"   "<<#y<<" : "<<y<<"  "<<#z<<" : "<<z<<endl;


int bgval(int n, int a)
{
	int rt = n / a;
	if (n%a != 0) rt++;
	return rt;
}


using namespace std;

map<string, int> mp;

ll phi(ll n)
{
	ll result = n; // Initialize result as n 

	// Consider all prime factors of n and subtract their 
	// multiples from result 
	for (ll p = 2; p * p <= n; ++p) {

		// Check if p is a prime factor. 
		if (n % p == 0) {

			// If yes, then update n and result 
			while (n % p == 0)
				n /= p;
			result -= result / p;
		}
	}

	// If n has a prime factor greater than sqrt(n) 
	// (There can be at-most one such prime factor) 
	if (n > 1)
		result -= result / n;
	return result;
}

bool isprime(ll n) {
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	//cin >> t;
	while (t--)
	{
		int n,k=0;
		cin >> n;
		/*vector<ll> vc(n,0), dp(n,INT_MAX);
		for (auto &it : vc) cin >> it;
		dp[0] = 0;*/
		ll a, b, c;
		ll ans[N][4] = { 0 };
		
		for (int i = 1;i<=n;i++)
		{
			cin >> a>> b>>c;
			if (i == 1)
			{
				ans[1][1] = a;
				ans[1][2] = b;
				ans[1][3] = c;
			}
			else
			{

				ans[i][1] += max(ans[i - 1][2], ans[i - 1][3]) +a;
				ans[i][2] += max(ans[i - 1][1], ans[i - 1][3])+b;
				ans[i][3] += max(ans[i - 1][2], ans[i - 1][1])+c;
			}

			
		}

	


		
		cout << max(ans[n][1],max(ans[n][2],ans[n][3])) << endl;
	
	}


	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int D;
    cin>>D;
    vector<int>c(27);
    rrep(i,26)cin>>c[i];
    vector<vector<int>>s(D+1,vector<int>(27));
    rrep(d,D){
        rrep(i,26)cin>>s[d][i];
    }
    vector<vector<int>>last(D+1,vector<int>(27));
    vector<int>C(D+1);
    vector<int>v(D+1);
    vector<int>t(D+1);
    vector<int>S(D+1);
    rrep(d,D){
        pair<int,int> ans = make_pair(-2e9,0);
        //Tを全部試して一番満足度の高いタイプを実施
        rrep(T,26){
            C[d] = 0;
            last[d][T] = d;
            rrep(i,26){
                C[d] += c[i]*(d-last[d][i]);
            }
            v[d] = S[d-1]+s[d][T]-C[d];
            ans = max(ans, pair<int,int>(v[d],T));
            last[d][T] = last[d-1][T];
        }
        S[d] = ans.first;
        t[d] = ans.second;
        last[d][t[d]] = d;
    }
    rrep(d,D){
        cout<<t[d]<<endl;
    }

    return 0;
}

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

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
typedef  unsigned long long          ll;
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  unordered_map<int, int>    mii;
typedef  vector<ll>                 vll;
typedef  long double                 ld;

const int N=505;
vi v[N];

int main()
{
  
 /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
    #endif */
  int n,m,q,l,r,ans,cnt;
  cin>>n>>m>>q;
  forn(i,m)
  {
    cin>>l>>r;
    v[l].pb(r);
  }
  rep(i,1,n)
   asort(v[i]);
  
  while(q--)
  {
    cin>>l>>r;
    ans=0;
    rep(i,l,r)
    {
        cnt=upper_bound(all(v[i]),r)-v[i].begin();
        ans+=cnt;
    }
    cout<<ans<<endl;
  }
  return 0;
}  

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S[3];
    rep(i, 3) cin >> S[i];
    int ans = 0;
    rep(i, N) {
        set<int> st;
        rep(j, 3) st.insert(S[j][i]);
        ans += (int)st.size() - 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    rep(i, M) cin >> B.at(i);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, N) {
        rep(j, M) {
            cin >> A.at(i).at(j);
        }
    }

    int ans = 0;
    rep(i, N) {
        int sum = 0;
        rep(j, M) {
            sum += A.at(i).at(j) * B.at(j);
        }
        sum += C;
        if (sum > 0) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MAX (ll(1e6)+7)
#define MOD (ll(1e9)+7)
#define INF (ll(1e18)+7)

#define elif else if
#define def inline auto
#define for(a,b) for(ll a=0;a<(b);++a)
#define array_size(a) ll(sizeof(a)/sizeof(a[0]))
#define ios_boost cin.tie(0);ios::sync_with_stdio(false)
#define digit(a) to_string(a).length()
#define lcm(a,b) a*b/gcd(a,b)
char N='\n',S=' ';
def gcd(ll a,ll b){ll c;while(a){c=a;a=b%a;b=c;}return b;}

int main(){
	ios_boost;
	ll N,i;
	cin>>N>>i;
	cout<<N-i+1<<"\n";
}

//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


Measured memory_bytes: 256
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
int gcd(int, int);
int main(){
	int n, k;
	int a[100010];
	cin>>n>>k;
	int i;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	int Max=a[1];
	int d=a[1];
	for(i=2;i<=n;i++){
		Max=max(a[i],Max);
		d=gcd(a[i],d);
	}
	int t=1;
	if(k%d!=0) t=0;
	if(k>Max) t=0;
	if(t==1) cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE"; 
	return 0;
}
int gcd(int a, int b){
	int t1=a, t2=b;
	int i;
	for(i=1;;i++){
		if(t1==0||t2==0) break;
		t1=t1%t2;
		if(t1==0||t2==0) break;
		t2=t2%t1;
	}
	return t1+t2;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var a int
	var b int
	var c int

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	num := b / a
	if num <= c {
		fmt.Println(num)
	} else {
		fmt.Println(c)
	}
}


Measured memory_bytes: 512
def grid_compression(a, h, w):
    hh = []
    for i in range(h):
        ok = True
        for j in range(w):
            if a[i][j] == '#':
                ok = False
                break
        if ok:
            hh += [i]
    ww = []
    for i in range(w):
        ok = True
        for j in range(h):
            if a[j][i] == '#':
                ok = False
                break
        if ok:
            ww += [i]
    aa = []
    for i in range(h):
        if i in hh:
            continue
        aa.append('')
        for j in range(w):
            if j in ww:
                continue
            aa[-1] += a[i][j]
    return '\n'.join(aa)

h, w = map(int, input().split())
a = []
for _ in range(h):
    a += [list(input())]
print(grid_compression(a, h, w))


Measured memory_bytes: 3188
N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
    exit()
MOD = 10**9 + 7
m = 1
n = 1
for i in range(1, M+1):
    m *= i
    m %= MOD
for i in range(1, N+1):
    n *= i
    n %= MOD

if M == N:
    print(m*n*2 % MOD)
else:
    print(m*n % MOD)


Measured memory_bytes: 3060
main :: IO ()
main = do
  getLine
  a1 <- map read . words <$> getLine
  a2 <- map read . words <$> getLine
  let
    po = sum $ init a2
    a = zip (tail a1) (init a2)
    sums = scanl1 (\(x1, y1) (x2, y2) -> (x1 + x2, y1 + y2)) a
    ans = foldl (\x (y, z) -> (y + po - z) : x) [] sums
  print $ head a1 + last a2 + if null ans then 0 else maximum (po:ans)

Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/22/2018
 
 21:30-21:33 analysis
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL M;
LL A[MAX_N];

unordered_map<int,int> X;
LL cum[MAX_N];
void solve() {
  cum[0]=0;
  REP(i,N) cum[i+1]=cum[i]+A[i];
  LL res=0;
  REPE(i,N) {
    LL x=cum[i]%M;
    if(X.count(x)) res+=X[x];
    X[x]++;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M;
  REP(i,N) cin>>A[i];
  solve();
  return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(a)  begin(a),end(a)
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef long long unsigned int llu;


/*---------------------------------------------------------------------------------*/


int main(){
   int N,K;
   scanf("%d %d",&N,&K);
   ll x[N];
   ll y[N];
   rep(i,N) scanf("%lld %lld",&x[i],&y[i]);

   ll hidari;
   ll migi;
   ll ue;
   ll sita;
   llu min = 10000000000000000000;
   llu s;
   int sum;
   rep(i1,N){
     rep(i2,N){
       rep(i3,N){
         rep(i4,N){
           hidari = x[i1];
           migi = x[i2];
           ue = y[i3];
           sita = y[i4];
           s = abs((x[i1]-x[i2])*(y[i3]-y[i4]));
           sum = 0;
           rep(i,N){
             if(x[i]>=hidari && x[i]<=migi && y[i]<=ue && y[i]>=sita) sum++;
           }
           if(sum >= K && s < min) min = s;
         }
       }
     }
   }

   printf("%llu",min);
  return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> degree(N, 0);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		degree[a-1]++;
		degree[b-1]++;
	}
	for (int i = 0; i < N; i++) {
		cout << degree[i];
		if (i != N - 1) cout << "\n";
	}
}

Measured memory_bytes: 256
n,t = map(int,input().split())
tl =list(map(int,input().split()))

    
s = 0
for i in range(n-1):
    p = tl[i + 1] - tl[i]
    if p >= t:
        s = s + t
    else:
        s = s + p
        
s = s + t
print(s)

Measured memory_bytes: 26708
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll d(char c) {
	return (26 - (c - 'a')) % 26;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    string s; 
    cin >> s ;
    ll n = s.size() ;
    ll k ;
    cin >> k ;
    //return cout << d('f') , 0;
    //k = min (k , (ll)1000 * 10000) ;
    ll po = 0 ;
    while (k) {
		if (po < n   -  1&& s[po] == 'a') po ++ ;
		if (po == n - 1) break;
		ll x = d(s[po]) ;
		if (k >= x) {
			s[po] = 'a' ;
			k -= x ;
			po ++ ;
			continue ;
		}
		while (po < n - 1 && k) {
			if (d(s[po]) <= k) {
				
				k -= d(s[po]) ;
				s[po] = 'a' ;
				po ++ ;
				continue ;
			}
			po ++ ;
		}
		
	}
	if (k && po == n - 1) s[po] = char('a' + ((s[po] - 'a') + k % 26)  % 26) ;
	cout << s ;
    
    return (0) ;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int N; 
int A[MAX_N];

int main(void){
	cin >> N;
	for(int i = 0; i < MAX_N; i++){
		A[i] = 0;
	}
	for(int i = 1; i <= N; i++){
		int input;
		cin >> input;
		input--;
		A[input]++;
	}
	int kind_of_card = 0;
	for(int i = 0; i < MAX_N; i++){
		if(A[i] != 0) kind_of_card++;
	}
	if(kind_of_card % 2 == 1) cout << kind_of_card << endl;
	else cout << kind_of_card - 1 << endl;
	return 0;
}


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

int main() {
  ll n; cin >> n;
  ll ans = 0;
  n--;
  ans = n*(n+1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
#define INF 10000010
using namespace std;

void chmin(int &a, int b) {if(a > b) a = b;}

int main() {
	int D, G; cin >> D >> G;
	vector<int> p(D+1, 0), c(D+1, 0);
	for(int i = 1; i <= D; i++) cin >> p[i] >> c[i];

	vector<vector<int>> dp(D+1, vector<int>(G+1, INF));
	for(int i = 0; i <= D; i++) dp[i][0] = 0;

	for(int i = 0; i <= D; i++){
		for(int j = 0; j <= G; j += 100){
			if(i > 0){
				for(int k = 0; k < p[i]; k++){
					if(j - k * i * 100 >= 0){
						chmin(dp[i][j], k + dp[i - 1][j - k * i * 100]);
					}else{
						chmin(dp[i][j], k);
					}
				}
				if(j - p[i] * i * 100 - c[i] >= 0){
					chmin(dp[i][j], p[i] + dp[i - 1][j - p[i] * i * 100 - c[i]]);
				}else{
					chmin(dp[i][j], p[i]);
				}
			}
		}
	}

	cout << dp[D][G] << endl;
}

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

float N,T,A;
float H[1100];

int main(){

    cin >> N >> T >> A;
    REP(i,N) cin >> H[i];
    float ans = 100000;
    int ans_i;
    REP(i,N){
        float temp = abs(A - (T - H[i] * 0.006));
        if(ans > temp){
            ans_i = i + 1;
            ans = temp;
        }
    }

    cout << ans_i << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdint.h>
#include <stdio.h>

#define MAX_DATA_NUM 100

void dump_array(int32_t num, int32_t *array)
{
  int i = 0;
  for (i = i; i < num; i++) {
    printf("%d", array[i]);
    if (i < (num - 1)) {
      printf(" ");
    }
  }

  printf("\n");
  return;
}

void insertion_sort(int32_t num, int32_t *data)
{
  int i;
  for (i = 0; i < num; i++) {
    int32_t v = data[i];
    int j = i - 1;
    while ((j >= 0) && data[j] > v) {
      data[j + 1] = data[j];
      j--;
    }
    data[j + 1] = v;
    dump_array(num, data);
  }

  return;
}

int main(void)
{
  int32_t num;
  int32_t data[MAX_DATA_NUM];

  scanf("%d", &num);
  int i;
  for (i = 0; i < num; i++) {
    scanf("%d ", &data[i]);
  }

  insertion_sort(num, data);

  return 0;
}

Measured memory_bytes: 608
//DP1
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i=0;i<n;i++){
		cin >> h.at(i);
	}
	vector<int> cost(n);
	cost.at(0) = 0;
	cost.at(1) = abs(h.at(0) - h.at(1));
	for(int i=2;i<n;i++){
		cost.at(i) = min(cost.at(i-2) + abs(h.at(i) - h.at(i-2)),cost.at(i-1) + abs(h.at(i) - h.at(i-1)));
	}
	cout << cost.at(n-1) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

long long L,R,y;
int main(){
  int l,r,x=2100;

  cin>>L>>R;

l=L%2019;
r=R%2019;

y=R-L;


if(r<=l || 2019<=y){
  cout<<0;
}else{
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      x=min(x,(i*j)%2019);
    }
  }
  cout<<x;
}


  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		while(true){
			int n=sc.nextInt(), m=sc.nextInt();
			if(n==0 && m==0) break;
			boolean flg[] = new boolean[n+1];
			PriorityQueue<Packet> pq = new PriorityQueue<Packet>();

			while(m-- > 0)
				pq.add(new Packet(sc.nextInt(),sc.nextInt(),sc.nextInt()));

			flg[1] = true;
			while(!pq.isEmpty()){
				Packet p = pq.poll();
				if(flg[p.s]) flg[p.d]=true;
			}

			int ans = 0;
			for(int i=1;i<=n;i++) if(flg[i]) ans++;

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

class Packet implements Comparable<Packet>{
	int t,s,d;

	public Packet(int t, int s, int d){
		this.t = t;
		this.s = s;
		this.d = d;
	}

	public int compareTo(Packet p){
		return this.t - p.t;
	}
}

Measured memory_bytes: 16000
while True:
    a = input()
    b = a.split(' ')
    H = int(b[0])
    W = int(b[1])
    if H == 0 and W == 0:
        break
    print('#'*W)
    for i in range(H-2):
        print('#'+'.'*(W-2)+'#')
    print('#'*W)
    print()

Measured memory_bytes: 7640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    ll X;
    cin >> X;
    ll now = 100;
    ll cnt = 0;
    while (true)
    {
        if (now >= X)
        {
            cout << cnt << endl;
            return 0;
        }
        cnt++;
        now = now * 1.01;
    };
    cout << cnt << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
    int n;
    int R[200000];
    int i,j;
    int max=-1000000000;
    int min;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&R[i]);
    min=R[0];
    for(i=1;i<n;i++){
        max=max<R[i]-min ? R[i]-min:max;
        min=min>R[i] ? R[i]:min;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string s;
    cin >> s;
    bool ok = true;

    ok = s[2] == s[3] && s[4] == s[5];

    if (!ok)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}

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

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

int main() {
	int k, ans = 0;
  	cin >> k;
  	for (int i = 1; i <= k; i++)
      	for (int j = 1; j <= k; j++)
          	for (int l = 1; l <= k; l++)
              	ans += gcd(i, gcd(j, l));
  	cout << ans << endl;
}


Measured memory_bytes: 3624
A, B, K = map(int, input().split())

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

print(sorted(set(make_div(A))&set(make_div(B)), reverse=True)[K-1])

Measured memory_bytes: 9344
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;
                                                                                                     
ll MOD=1000000007;                                                                                     
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    for(int i=k;i<n;i++){
        if(a[i-k]<a[i]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


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

int main(void) {
	int i = 1, ans = 0;
	string s, n;
	cin >> s;
	n = s[0];
	for (; i < s.size(); i++) {
		if (s[i] != n[0]) {
			ans++;
			n = s[i];
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size();
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int MOD=1e9+7;
int INF=1e9+7;
//
long long C[26];
int main(){
  string S;
  cin>>S;
  long long L=S.size();
  char c='a';
  FOR(i,0,L){
    C[S[i]-c]++;
  }
  long long s=0;
  FOR(i,0,26){
    s+=(C[i]*(C[i]-1)/2);
  }
  long long N=(L*(L-1)/2)-s;
  cout<<N+1<<endl;
  return 0;
}


Measured memory_bytes: 640
# フェルマーの小定理
N, K = map(int, input().split())

m = 1000000007


def make_factorial_table(n):
    result = [0] * (n + 1)
    result[0] = 1
    for i in range(1, n + 1):
        result[i] = result[i - 1] * i % m
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


n = max(K, N - K + 1)
fac = make_factorial_table(n)

result = []
for i in range(1, K + 1):
    result.append(mcomb(K - 1, i - 1) * mcomb(N - K + 1, i) % m)
print('\n'.join(str(i) for i in result))


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

int main(){
    string A,B;
    cin >> A >> B;
    if (A.size() > B.size()){
        cout << "GREATER" << endl; 
    }
    else if (A.size() == B.size() && A > B){
        cout << "GREATER" << endl; 
    }
    else if (A == B){
        cout << "EQUAL" << endl;
    }
    else{
        cout << "LESS" << endl;
    }
}

Measured memory_bytes: 256