akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int N;

void read() {
    cin >> N;
}


void work() {
    if (N == 0) {
        cout << 0 << endl;
        return;
    }

    vector<int> idxList;
    
    while (N != 0) {
        int sum = 0;
        
        int idx = N < 0 ? 1 : 0;
        long long toAdd = N < 0 ? -2 : 1;
        while (abs(sum) < abs(N)) {
            sum += toAdd;
            idx += 2;
            toAdd *= 4;
        }
        
        idx -= 2;
        toAdd /= 4;

        idxList.push_back(idx);
        N -= toAdd;
    }
    
    string ans = string(idxList[0] + 1, '0');
    for (int i = 0; i < idxList.size(); ++i) {
        ans[idxList[i]] = '1';
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using t = tuple<ll, ll, ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

ll n, m, q;
vector<ll> a(55), b(55), c(55), d(55);

ll ans = 0;

void dfs(int idx, ll prev, vector<ll> &av) {
  if (idx == n) {
    ll sum = 0;
    for (int i = 0; i < q; i++) {
      // cout << av[i];
      if (av[b[i]] - av[a[i]] == c[i]) {
        sum += d[i];
      }
    }
    // cout << ln << sum << ln << ln;

    ans = max(sum, ans);

    return;
  }

  for (int i = prev; i <= m; i++) {
    vector<ll> cp = av;
    cp[idx] = i;
    dfs(idx + 1, i, cp);
  }
}

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

  cin >> n >> m >> q;

  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  vector<ll> v(11);

  dfs(0, 1, v);

  cout << ans << ln;

  return 0;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

long long INF = 1LL << 60;
int N, M, X;
vector<long long> C;
vector<vector<int> > A;

int main() {
    cin >> N >> M >> X;
    C.resize(N);
    A.resize(N);
    rep (i, N) {
        cin >> C[i];
        A[i].resize(M);
        rep (j, M) {
            cin >> A[i][j];
        }
    }

    long long ans = INF;
    for (int b = 0; b < (1 << N); b++) {
        long long cost = 0;
        vector<int> params(M);
        for (int k = 0; k < N; k++) {
            if ((b >> k) & 1) {
                cost += C[k];
                rep (i, M) params[i] += A[k][i];
            }
        }
        bool ok = true;
        rep (i, M) if (params[i] < X) ok = false;
        if (ok) ans = min(ans, cost);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int size=Integer.parseInt(s.next());
		int[][] h=new int[size][3];
		for(int i=0;i<size;i++)
		{
			for(int j=0;j<3;j++)
			{
				h[i][j]=s.nextInt();
			}
		}
		System.out.println(new Main().happiness(h));
		s.close();
	}
	
	public int happiness(int[][] activities)
	{
	
		for(int row=1;row<activities.length;row++)
		{
			for(int col=0;col<activities[0].length;col++)
			{
				activities[row][col]+=getMax(activities,row-1,col);
			}
		}
		return getMax(activities,activities.length-1,activities[0].length);
	}

	private int getMax(int[][] activities, int row, int c) {
		// TODO Auto-generated method stub
		int max=0;
		for(int col=0;col<activities[0].length;col++)
			if(col!=c)
				max=Math.max(max, activities[row][col]);
		return max;
	}

}


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

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

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

    if(N == M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3556
while True:
    i = 0
    n,x = map(int,raw_input().split())
    if n == x == 0:
        break
    for a in range(1,n+1):
        for b in range(1,a+1):
            for c in range(1,b+1):
                if not a == b == c and not a == b and not a == c and not b == c:
                    if a+b+c == x:
                        i = i + 1
    print i

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

int main(void){
    int n;
    cin >> n;
    vector<long long int> luca; 
    luca.push_back(2);
    luca.push_back(1);
    for(int i=0;i<n-1;i++){
        luca.push_back(luca[i]+luca[i+1]);
    }
    cout << luca.back();
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define int long long
#define ull unsigned long long
#define pii pair<int,int>
#define vii vector<int>
#define f first
#define s second
// #define endl "\n"
#define all(container) container.begin(), container.end()
#define onlyunique(v) v.erase(unique(all(v)), v.end());

#define TRACE
#ifdef AYUSH
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

int const mod = 1e9 + 7;
int const inf = 1e18;

int power(int x, int y, int mod = 2e18) { int ans = 1; x %= mod; while (y) {if (y & 1)ans = (x * ans) % mod; x = (x * x) % mod; y >>= 1;} return ans;}
int modinv(int a, int m) {return power(a, m - 2, m);}

void solve() {
	int n, k; cin >> n >> k;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	multiset<int> b;
	int c = 1;
	b.insert(1);
	do{
		c = a[c];
		b.insert(c);
	}while(b.count(c) < 2);
	int x= c;
	c = 1;
	int m = 0;
	do{
		c = a[c];
		++m;
	}while(c != x);
	if(k < m){
		int ans = 1;
		while(k--){
			ans = a[ans];
		}
		cout<<ans<<endl;return;
	}
	k -= m;
	int cc = b.size() - 1;
	cc -= m;
	if(cc == 0) cc = m;
	k %= cc;
	for(int i=0;i<k;++i){
		c = a[c];
	}
	cout<<c<<endl;
}
signed main() {
	IOS
	int t = 1, T = 1;
	// cin>>t;
	while (t--) {
		// cout<<"Case #"<<T<<": ";
		solve();
		// ++T;
	}
	return 0;
}

Measured memory_bytes: 13956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


bool check(ll N, vector<ll>&D){
    while(N>=0){
        ll x = N%10;
        for(auto elm : D){
            if(x == elm)
                return false;
        }
        if(N<10) N = -1;
        else N /= 10;

    }
    return true;
}

void solve(long long N, long long K, std::vector<long long> D){

    for (ll i = N; i < 100001; i++)
    {
        if(check(i,D)){
            cout << i << endl;
            return;
        }
    }
    
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, K, std::move(D));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n<2)cout << 1;
  else if(n<4)cout << 2;
  else if(n<8)cout << 4;
  else if(n<16)cout << 8;
  else if(n<32)cout << 16;
  else if(n<64)cout << 32;
  else cout << 64;
}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);



void solve()
{
    int n;
    cin >> n;
    cout << n / 3 << "\n";
}

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

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> d(61, 0);

    rep(i, n) rep(j, 61) d[j] += (a[i] >> j) & 1; //各桁の１の合計

    ll x = 0, sum = 0;
    repr(i, 60)
    {
        if (d[i] < n - d[i] && x + (1LL << i) <= k) //０の方が多い場合は桁を１にする。
        {
            x += 1LL << i;
            sum += (n - d[i]) * (1LL << i);
        }
        else
            sum += d[i] * (1LL << i);
    }
    OP(sum);

    return 0;
}

Measured memory_bytes: 1024
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

const int N = 1e5 + 123;

int n , k , a[200] ;
bool dp[N];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i++)
		cin >> a[i];
	for(int i = 1 ; i <= k ; i++){
		for(int j = 1 ; j <= n ; j++){
			if(i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
			else break;
		}
	}
	if(dp[k])
		cout <<"First";
	else
		cout <<"Second";
		
}

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

int main()
{
    int a,b;
    string s;
    cin >> a >> b >> s;
    for(int i = 0; i<s.size(); i++){
        if(i == a){
          	if(s[i] !='-'){
            	cout << "No" << endl;
            	return 0;
            }
        }else{
            if(s[i] =='-'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, flg=0;
    char S[100];

    cin >> N;
    for(int i=0; i<N; i++)
        cin >> S[i];


    for(int i=0; i<N; i++)
    {
        if( S[i] == 'Y' )
            flg = 1;
    }

    if( flg )
        cout << "Four" << endl;
    else
        cout << "Three" << endl;
    
    return 0;
}

Measured memory_bytes: 256
# Two Colors Card Game
n = int(input())
s = []
for i in range(n):
    s.append(input())
m = int(input())
t = []
for i in range(m):
    t.append(input())
s_, t_ = set(s), set(t)
ans = 0
for x in s_:
    if s.count(x) - t.count(x) >= ans:
        ans = s.count(x) - t.count(x)
print(ans)


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

int cnt[26];
int main () {
  string s; cin >> s;
  for (int i = 0; i < s.size(); i++) {
    cnt[s[i]-'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (cnt[i] % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
  

Measured memory_bytes: 256
import java.util.Scanner;

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

    int a = scanner.nextInt();
    String s = scanner.next();
    if (a >= 3200) System.out.println(s);
    else {
      System.out.println("red");
    }
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define db "NPALIN"
#define fi first
#define se second
#define endl '\n'
#define int long long
const int INF = 1e15 + 1;
const int mod = 1e9 + 7;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<PII, int> PII2;
typedef pair<int, PII> PII3;

void docfile()
{
    if (ifstream("FORM.inp"))
    {
        freopen("FORM.inp", "r", stdin);
        freopen("FORM.out", "w", stdout);
    }
    else if (ifstream(db".inp"))
    {
        freopen(db".inp", "r", stdin);
        freopen(db".out", "w", stdout);
    }
}

//---------------------------------------------------------------------------
const int N = 2 * 1e5 + 2;
char a, b;

void solve()
{
    string x = "", y = "";
    int n = a - '0';
    int m = b - '0';
    for(int i = 1; i <= n; i++) x += b;
    for(int i = 1; i <= m; i++) y += a;
    if(x <= y) cout << x;
    else cout << y;
}

void input()
{
    cin >> a >> b;
    solve();
}

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

    //int test = 1; cin >> test; while(test--)
    input();
}


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

/*
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
*/


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void) {
  int a, b;
  cin >> a >> b;
  if(a < 1 || 9 < a || b < 1 || 9 < b) {
    cout << -1 << endl;
    return 0;
  }
  cout << a * b << endl;
  return 0;
}

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

namespace abc151_c
{
    static class Program
    {
        static void Main(string[] args)
        {
            var items = Console.ReadLine().ToIntArray();
            // 問題数
            var n = items[0];
            // 提出数
            var m = items[1];
            // 問題と、その成否
            var ac = new bool[n];
            var wa = new int[n];
            for (int i = 0; i < m; i++)
            {
                var answers = Console.ReadLine().Split(' ');
                var index = answers[0].ToInteger() - 1;
                if (answers[1] == "AC")
                {
                    ac[index] = true;
                }
                if (!ac[index])
                {
                    wa[index]++;
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (!ac[i])
                {
                    wa[i] = 0;
                }
            }

            Console.WriteLine($"{ac.Sum(k => k ? 1 : 0)} {wa.Sum()}");
        }

        static int ToInteger(this string s)
        {
            return int.Parse(s);
        }

        static int[] ToIntArray(this string s, char separator = ' ')
        {
            var items = s.Split(separator);
            var ret = new int[items.Length];
            for (int i = 0; i < items.Length; i++)
            {
                ret[i] = items[i].ToInteger();
            }
            return ret;
        }
    }
}


Measured memory_bytes: 15688
def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))
	dp=[0]*N
	for i in range(1,N):
		dp[i] = min(dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i))
	print(dp[N-1])
main()


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

int solve(int n) {
    vector<set<int>> p(n);
    REP(i,n) {
        int m;
        cin>>m;
        REP(j,m) {
            int t;
            cin>>t;
            p[i].insert(t);
        }
    }
    int k;
    cin>>k;
    vector<int> l(k);
    REP(i,k) cin>>l[i];

    int ans=-1;
    REP(i,n) {
        bool criminal=true;
        REP(j,k) {
            if(!CONTAIN(p[i],l[j])) {
                criminal=false;
                break;
            }
        }
        if(criminal) {
            if(ans!=-1) {
                return -1;
            }
            ans=i+1;
        }
    }
    return ans;
}
signed main() {
    while(1) {
        int n;
        cin>>n;
        if(n==0) break;
        cout<<solve(n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue> 
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0; i<=n; i++)
        for (int j=0; j<=n; j++)
            if (i*4+j*7==n) 
                {printf("Yes\n"); return 0;}
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            int iN = int.Parse(Console.ReadLine().Trim());
            List<List<char>> lstInp = new List<List<char>>();
            for (int i = 0; i < iN; i++) { lstInp.Add(Console.ReadLine().Trim().ToList()); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<char> lstOut = new List<char>();
            for (int i = 0; i < lstInp[0].Count; i++)                                           // 1つめの文字列の文字1文字ずつ確認
            {
                Boolean bOk = true;
                for (int j = 1; j < lstInp.Count; j++)                                          // 他の文字列で存在確認
                {
                    if (!lstInp[j].Contains(lstInp[0][i])) { bOk = false; break; }              // 共通する文字1文字ずつ確認
                }
                if (bOk)                                                                        // 共通する文字存在
                {
                    lstOut.Add(lstInp[0][i]);                                                   // 共通する文字保持
                    for (int j = 1; j < lstInp.Count; j++)                                      // 他の文字列からその共通文字1文字削除
                    {
                        for (int k = 0; k < lstInp[j].Count; k++)                               // 他の文字列一つの文字列内
                        {
                            if (lstInp[j][k] == lstInp[0][i]) { lstInp[j].RemoveAt(k); break; } // 共通文字1文字削除
                        }
                    }
                }
            }
            if (lstOut.Count > 1) { lstOut.Sort(); }

            //出力
            if (lstOut.Count > 0) { Console.WriteLine("{0}", new String(lstOut.ToArray()).ToString().Trim()); }
            else { Console.WriteLine("{0}", "".ToString().Trim()); }

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int cityCount = sc.nextInt();
            int trainCount = sc.nextInt();
            int queryCount = sc.nextInt();

            int[][] trainPoint = new int[cityCount + 2][cityCount + 2];
            int[][] cityPoint = new int[cityCount + 2][cityCount + 2];
            for (int t = 0; t < trainCount; t++) {
                trainPoint[sc.nextInt()][sc.nextInt()]++;
            }
            // for(int i = 1; i <= cityCount; i++) {
            // for(int edge = 1; edge <= cityCount; edge++) {
            // cityPoint[i][]
            //
            // }
            // }
            for (int edge = 0; edge < cityCount; edge++) {
                for (int startPoint = 1; startPoint + edge <= cityCount; startPoint++) {
                    cityPoint[startPoint][startPoint + edge] = cityPoint[startPoint][startPoint + edge - 1];
                    for (int i = 0; i <= edge; i++) {
                        cityPoint[startPoint][startPoint + edge] += trainPoint[startPoint + i][startPoint + edge];
                    }
                }
            }

            for (int q = 0; q < queryCount; q++) {
                int l = sc.nextInt();
                int r = sc.nextInt();
                System.out.println(cityPoint[l][r]);
            }

        }
    }
}


Measured memory_bytes: 154184
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<vector<int>>com(n);
  vector<vector<int>>num(n);
  vector<ed>es(m);
  if(m==0){cout<<-1<<endl;return 0;}

  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    com[a].push_back(c);
    com[b].push_back(c);
  }
  int cnt=0;
  rep(i,n)
  {
    int tn=cnt++;
    sort(all(com[i]));
    com[i].erase(unique(all(com[i])),com[i].end());
    num[i].resize(com[i].size()+1);
    rep(j,com[i].size())
    {
      num[i][j]=cnt++;
    }
    num[i][com[i].size()]=tn;
  }
  vector<int>dist(cnt+2,-1);
  vector<vector<P>>edge(cnt+2);
  rep(i,n)rep(j,com[i].size())
  {
    int t=num[i].back();
    int tn=num[i][j];
    edge[t].push_back({1,tn});
    edge[tn].push_back({0,t});
  }
  rep(i,m)
  {
    int to=lower_bound(all(com[es[i].a]),es[i].c)-com[es[i].a].begin();
    int from=lower_bound(all(com[es[i].b]),es[i].c)-com[es[i].b].begin();
    to=num[es[i].a][to];
    from=num[es[i].b][from];

    edge[to].push_back({0,from});
    edge[from].push_back({0,to});
  }
  int start=0,end=num[n-1].back();
  priority_queue<P,vector<P>,greater<P>>q;
  q.push({0,start});
  while(!q.empty())
  {
    P tp=q.top();q.pop();
    if(dist[tp.second]!=-1)continue;
    dist[tp.second]=tp.first;
    for(P nn:edge[tp.second])
    {
      if(dist[nn.second]!=-1)continue;
      q.push({nn.first+tp.first,nn.second});
    }
  }
  cout<<dist[end]<<endl;
  //rep(i,dist.size())cout<<i<<" "<<dist[i]<<endl;
  /*
  cout<<end<<endl;
  rep(i,edge.size())rep(j,edge[i].size())
  {
    cout<<i<<" "<<edge[i][j].first<<" "<<edge[i][j].second<<endl;
  }
  */


  return 0;

}


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

int main(void){
	long long N;
	int S,x;
	cin >> N;
	for(int i=0;i<10;i++){
		x=N;
		for(int j=0;j<i;j++){
			x/=10;
		}
		S+=x%10;
	}
	if(N%S==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {

    int i,H,N,a,sum=0;



    scanf("%d %d",&H,&N);



    for(i=0;i<N;i++)
    {
        scanf("%d",&a);
        sum = sum + a;
    }

    if(sum>=H)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

// value


void solve() {

    string S;
	cin >> S;

	int ans = 100000;

	for(int i=0;i <= S.size() - 3;i++){
		ans = abs(753 - stoi(S.substr(i,3))) < ans ? abs(753 - stoi(S.substr(i,3))) : ans;
	}

	cout << ans << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}


Measured memory_bytes: 256
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1) * 2 ** max(0, n - j - 1)
            ans += x * p

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << min(n, k) * x + max(0, n - k) * y << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int inf=1<<30;
inline int rd(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x; 
}ll ans;
int jiec[2000050],inv[2000050];
inline int C(int m,int n){
	return 1ll*jiec[n]*inv[m]%mod*inv[n-m]%mod;
}
inline int ss(int x,int y,int x2,int y2,int x3,int y3){
	int res=0;
	for(int i=y;i<=y2;i++){
		res=(res+1ll*C(x3-x2-1,x3-x2-1+y3-i)*C(x2-x,x2-x+i-y)%mod*(x2-x+1+i-y)%mod)%mod;
	}	
	for(int i=x;i<=x2;i++){
		res=(res+1ll*C(y3-y2-1,y3-y2-1+x3-i)*C(y2-y,y2-y+i-x)%mod*(y2-y+1+i-x)%mod)%mod;
	}
	return res;
}
int x,x2,x3,x4,x5,x6;
int y,y2,y3,y4,y5,y6;
inline int calc(int a,int b,int a2,int b2){
	int res=0;res+=ss(a,b,x4,y4,a2,b2);
	res+=ss(a,b,x3-1,y3-1,a2,b2);res%=mod;
	res-=ss(a,b,x3-1,y4,a2,b2);
	res-=ss(a,b,x4,y3-1,a2,b2);
	return (res%mod+mod)%mod;
	
}
inline int solve(int x,int y){
	int res=0;
	res+=calc(x,y,x6+1,y6+1);res+=calc(x,y,x5,y5);res%=mod;
	res-=calc(x,y,x6+1,y5);res-=calc(x,y,x5,y6+1);
	return (res%mod+mod)%mod;
}
int main(){
	jiec[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=2000000;i++) jiec[i]=1ll*jiec[i-1]*i%mod;
	for(int i=2;i<=2000000;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=2000000;i++) inv[i]=1ll*inv[i-1]*inv[i]%mod;
	x=rd(),x2=rd(),x3=rd(),x4=rd(),x5=rd(),x6=rd();
	y=rd(),y2=rd(),y3=rd(),y4=rd(),y5=rd(),y6=rd();
	ans+=solve(x-1,y-1);ans+=solve(x2,y2);ans-=solve(x-1,y2);ans-=solve(x2,y-1);
	ans=(ans%mod+mod)%mod;
	cout<<ans;
	return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> x(n);
    rep(i,0,n) cin >> x[i];
    ll mini=1e10+7;
    rep(i,0,102){
        ll tmini=0;
        rep(j,0,n){
            tmini += (i-x[j]) * (i-x[j]);
        }
        mini = min(mini,tmini);
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#include <iostream>


int calc(int a, char op, int b) {
  int ans;
  switch (op) {
    case '+':
      ans = a + b;
      break;
    case '-':
      ans = a - b;
      break;
    case '/':
      if (a == 0 || b == 0) {
        ans = 0;
      } else {
        ans = a / b;
      }
      break;
    case '*':
      ans = a * b;
      break;
  }
  return ans;
}


int main(void) {
  int a, b;
  char op;

  for (int i = 0; i < 20000; i ++) {
    std::cin >> a >> op >> b;
    if (op == '?') break;
    std::cout << calc(a, op, b) << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
#define MAX 25
#define NIL -1
struct Node_struct{int p,right,left,s;};
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX],H[MAX];

int getSibling(int u){
  if(T[u].p == NIL){
    return NIL;
  }
  if(T[T[u].p].left != u && T[T[u].p].left != NIL){
    return T[T[u].p].left;
  }
  if(T[T[u].p].right != u && T[T[u].p].right != NIL){
    return T[T[u].p].right;
  }
  return NIL;
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left != NIL){
    h1 = setHeight(T[u].left) + 1;
  }
  if(T[u].right != NIL){
    h2 = setHeight(T[u].right) +1;
  }
  if(h1>h2){
    H[u]=h1;
  }else{
    H[u]=h2;
  }
  return H[u]; 
}


void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].left!=NIL) calcDepth(T[u].left,p+1);
  if(T[u].right!=NIL) calcDepth(T[u].right,p+1);
}

void print(int u){
  int deg=0;
  printf("node %d: parent = %d, ", u, T[u].p);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].left != NIL){
    deg++;
  }
  if(T[u].right != NIL){
    deg++;
  }
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",setHeight(u));
  if(T[u].p==NIL) printf("root");
  else if(T[u].left==T[u].right && T[u].left==NIL) printf("leaf");
  else printf("internal node");
  printf("\n");
  
}

int main(){
  int i;
  int n;
  int id;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].right = T[i].left = NIL;
  for(i=0; i<n; i++){
    if(i==0){
      T[0].p=NIL;
    }
    scanf("%d", &id);
    scanf("%d %d", &T[id].left,&T[id].right);
    T[T[id].right].p = T[T[id].left].p = id;
    T[T[id].right].s = T[id].right;
    T[T[id].left].s = T[id].left;
  }
  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);  
  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 2108
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli h,k,a,b,i;
	cin>>a>>b>>h>>k;
	double t,n;
	n=h*30 + k/2.0;
	t=6*k;
	t=n-t;
	t=(pi*t)/180;
	n=a*a+b*b-2*a*b*cos(t);
	cout<<fixed<<setprecision(20)<<sqrt(n);
	return 0;
}

Measured memory_bytes: 4168
def main():
    max_p = -1_000_000_000
    n = int(input())
    min_v = int(input())

    for i in range(1, n):
        now_v = int(input())
        now_p = now_v - min_v
        if max_p < now_p:
            max_p = now_p
        if now_v < min_v:
            min_v = now_v

    print(max_p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<mint>> dp(n + 1, vector<mint>(k + 1, 0));
    vector<vector<mint>> dp2(n + 1, vector<mint>(k + 2, 0));
    dp[0][k] = 1;
    dp2[0][k + 1] = 1;
    rep(i, n) {
        rep(j, k + 1) {
            dp[i + 1][j] = dp2[i][min(k, j + a[i]) + 1] - dp2[i][j];
        }
        rep(j, k + 1) {
            dp2[i + 1][j + 1] += dp2[i + 1][j] + dp[i + 1][j];
        }
    }
    cout << dp[n][0].x << endl;
    return 0;
}


Measured memory_bytes: 161932
#include<iostream>
#include<map>
#include<string>
using namespace std;
 
int main(){
    int n;
    string st;
    char ch[12];
    map<string,bool> T;
     
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> st >> ch;
        if(st == "insert"){
            T[string(ch)] = true;
        }else if(st == "find"){
            if(T[string(ch)]) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
     
    return 0;
}


Measured memory_bytes: 47384
#include<stdio.h>
int main()
{
    int i,c=0,ara[26]={0};
    char s[5];
    scanf("%s",s);
    for(i=0;i<4;i++)
        ara[s[i]-'A']++;
    for(i=0;i<26;i++)
        if(ara[i]&&ara[i]!=2)
        c++;
    if(c)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
from collections import deque

N = int(input())
A = [list(map(int, input().split()))[::-1] for _ in range(N)]

# pop_count = 0
l = [[0 for _ in range(N+1)] for _ in range(N+1)]
day = 0
q = deque([(i+1, a.pop()) for i, a in enumerate(A)])

while q:
    day += 1
    r = deque()
    while q:
        p = q.popleft()
        # print(p)
        # if p == "m":
        #     q.append("m")
        #     day += 1
        #     continue
        x, y = p
        if x > y:
            x, y = y, x
        l[x][y] += 1
        if l[x][y] >= 2:
            l[x][y] -= 2
            if A[x-1]:
                r.append((x, A[x-1].pop()))
            if A[y-1]:
                r.append((y, A[y-1].pop()))
    q = r

if all(map(len, A)):
    print(-1)
else:
    print(day)

Measured memory_bytes: 45816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;

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

  vll A;
  for (int i=0;i<N;++i){
    ll a;cin>>a;A.push_back(a);
  }

  vll cumsum(N+1);
  cumsum[0]=0;
  for (int i=0;i<N;++i){
    cumsum[i+1]=cumsum[i]+A[i];
  }

  for (int i=0;i<N+1;++i){
    cumsum[i]%=M;
  }

  map<ll, ll> table;
  for (int i=0;i<N+1;++i){
    table[cumsum[i]]++;
  }

  ll ans=0;

  for (auto p:table){
    ll c=p.second;
    ans+=c*(c-1)/2;
  }

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

Measured memory_bytes: 5748
#include <iostream>
using namespace std;
int main (){
 int a,b,c,d,e,k;
 cin >> a;
 cin >> b;
 cin >> c;
 cin >> d;
 cin >> e;
 cin >> k;
 if (e - a <= k)
   cout << "Yay!" << endl;
  else 
    cout << ":(" << endl;

 
  return 0;
  
}

Measured memory_bytes: 760
use std::io;

fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

fn read_ints() -> Vec<i32>{
    let s = read_line();
    let split:Vec<&str> = s.trim().split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

fn main(){
    //let array = read_ints();
    //let x = array[0];
    //let y = array[1];
    
    let line = read_line();
    let x = line.chars().nth(0).unwrap();
    let y = line.chars().nth(2).unwrap();

    let x = x as i32;
    let y = y as i32;

    match (x-y) {
        n if n < 0 => println!("<"),
        n if n > 0 => println!(">"),
        _ => println!("=")
    }
}



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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    int r(0),l(-1);
    rep(i,s.size()){
        if(l==-1 && s[i]=='A'){
            l = i;
        }
        if(s[i]=='Z'){
            r = i;
        }
    }

    cout << r-l+1 << endl;

    return 0;
}

Measured memory_bytes: 3728
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> v(N);
  REP(i,N) cin>>v[i];

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

  int ans=0;
  for(int i=0;i<K;i++) {
    auto it = v.rbegin() + i;
    ans += *it;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

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

int main()
{
    ll l, r;
    cin >> l >> r;
    ll ans = 2018;
    if (r - l > 2018)
    {
        cout << 0 << endl;
    }
    else
    {
        for (ll i = l; i < r; i++)
        {
            for (ll j = l + 1; j < r + 1; j++)
            {
                chmin(ans, ((i * j) % 2019));
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	string s;cin>>s;
	if(s=="Sunny") cout<<"Cloudy"<<endl;
	if(s=="Cloudy") cout<<"Rainy"<<endl;
	if(s=="Rainy") cout<<"Sunny"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

ll n, a, b, hmax;
vector<ll> h;

bool isEnough(ll x) {
    ll atack_times = 0;
    REP(i,n) {
        ll tmp = max(0LL, h[i]-b*x);
        atack_times += (tmp+a-1)/a;
    }
    return atack_times<=x;
}

ll meguru_binary_search() {
    ll ng = 0;
    ll ok = hmax/b+1;

    while(abs(ok-ng) > 1){
        ll mid = (ok+ng)/2;
        if (isEnough(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}


int main(int argc, char const *argv[]) {
    cin >> n >> a >> b;
    a-=b;
    h.resize(n);
    hmax = 0;
    REP(i,n) {
        cin >> h[i];
        if (h[i] >= hmax) hmax = h[i];
    }
    cout << meguru_binary_search() << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

string s, t;
int a[128][100005];
long long ans;
bool v[128][100005];

int main()
{
//    freopen("input.txt", "r", stdin);
    cin>>s>>t;
    for(int i = 0; i < s.size(); i++)
    {
        for(int j = i; j >= 0; j--)
        {
            if(v[s[i]][j]) break;
            v[s[i]][j] = true, a[s[i]][j] = i - j;
        }
    }
    for(int i = 0; i < t.size(); i++)
    {
        if(!v[t[i]][ans % s.size()])
        {
            ans = (ans + s.size() - 1) / s.size() * s.size();
        }
        if(!v[t[i]][ans % s.size()])
        {
            printf("-1");
            return 0;
        }
        ans += a[t[i]][ans % s.size()];
        ans++;
    }
    printf("%lld", ans);
    return 0;
}


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

#define int long long
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; }

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

	cout << (n == 0 ? 1 : 0) << endl;

	return 0;
}


Measured memory_bytes: 3564