akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    vector<int> v;
    int i = 1;
    while (1) {
        if (A * i % B == C) {
            cout << "YES" << endl;
            return 0;
        } else if (A * i % B == 0) {
            break;
        }
        i++;
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+3;
ll k[maxn];
int main()
{
    ll a;
    ll b;
    ll c;
    while(scanf("%lld%lld.%lld",&a,&b,&c)==3)
    {
        cout<<a*b+c*a/100<<endl;
    }
    return 0;
}
/*
2
1000000000000000000 1000000000000000000


32432 534342

*/


Measured memory_bytes: 3684
package main

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

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	k := nextInt()

	for i := 0; i < k; i++ {
		newa := a
		newb := b
		if i%2 == 0 {

			if a%2 == 1 {
				newa--
			}
			newa -= a / 2
			newb += a / 2

		} else {
			if b%2 == 1 {
				newb--
			}

			newb -= b / 2
			newa += b / 2
		}

		a = newa
		b = newb

	}

	fmt.Println(a, b)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i = 0; i < (long int)n; i++)
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int x;
  if(a>b){
    x = c-(a-b);
  }else{
    x = c;
  }
  if(x <= 0){
    x = 0;
  }
  cout << x;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N+1];
    rep(i, N) cin >> A[i];
    A[N] = 0;
    sort(A, A+N+1, greater<int>());
    int n = 0;
    while(n < N && A[n+1] > n+1) n++;
    //cout << n << endl;
    int x = A[n]-n, y = 0;
    while(n+y < N && A[n+y] > n) y++;
    //cout << x << ' ' << y << endl;
    if((x&1) && (y&1)) cout << "Second" << endl;
    else cout << "First" << endl;
}

Measured memory_bytes: 3952
#  --*-coding:utf-8-*--


def main():
    N = int(input())
    A = list(map(int, input().split()))

    B = [0]*N
    for i in range(N, 0, -1):
        s = sum(B[j-1] for j in range(i*2, N+1, i))
        B[i-1] = (s + A[i-1])%2

    X = list(filter(lambda i: B[i-1] == 1, range(1, N+1)))

    print(len(X))
    print(' '.join(map(str, X)))



if __name__ == '__main__':
    main()


Measured memory_bytes: 19828
x, y = input().split()
# x number of animal
# y number of legs
x, y = int(x),int(y)
for a in range(100):
    for b in range(100):
        if (a * 2) + (b * 4) == y and a + b == x:
            print("Yes")
            exit(0)
print("No")

Measured memory_bytes: 9204
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-b)<<endl;
}   




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,r;
	cin>>n>>r;
	if( n < 10 ) r += 100 * ( 10 - n );
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stack>
#include<cassert>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn=2e3+1;
int n,p[maxn],a[maxn],deg[maxn],dep[maxn];
int pos[maxn],bot[maxn],top[maxn];
bool exist[maxn],red[maxn],sorted[maxn];
vector<int>opt;

void Rotate(int u){
	opt.push_back(u);
	int tmp=a[0];
	stack<int>sta;
	while(1){
		sta.push(u);
		if(!u)break;
		u=p[u];
	}
	while(1){
		u=sta.top();
		sta.pop();
		if(sta.empty()){
			a[u]=tmp;
			break;
		}
		a[u]=a[sta.top()];
	}
}

void Clear(){
	for(int i=n;~i;--i){
		if(exist[i]&&!deg[i]&&a[i]==i){
			exist[i]=0;
			--deg[p[i]];
		}
	}
}

bool cmp(const int &a, const int &b){
	if(red[a]!=red[b])return red[a];
	return dep[a]>dep[b];
}

bool Doit(){
	Clear();
	if(!exist[0])return 0;
	for(int i=0;i<n;++i)red[i]=sorted[i]=0;
	int tot=0;
	for(int i=n-1;~i;--i){
		if(!exist[i])continue;
		pos[tot++]=i;
		if(!deg[i]){
			red[i]=1;
			bot[i]=top[i]=i;
		}
		if(!red[i])continue;
		if(deg[p[i]]==1){
			red[p[i]]=1;
			bot[p[i]]=bot[i];
		}
	}
	sort(pos,pos+tot,cmp);
	for(int i=0;i<tot;){
		if(red[a[0]]){
			int u=bot[a[0]];
			while(sorted[u]&&a[u]>a[0])
			u=p[u];
			Rotate(u);
			u=bot[u];
			sorted[top[u]]=1;
			top[u]=p[top[u]];
		}else Rotate(pos[i++]);
		while(i<tot&&sorted[pos[i]])++i;
	}
	return 1;
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;++i)exist[i]=true;
	for(int i=1;i<n;++i){
		cin>>p[i];
		++deg[p[i]];
		dep[i]=dep[p[i]]+1;
	}
	for(int i=0;i<n;++i)cin>>a[i];
	Doit();
	while(Doit());
	for(int i=0;i<n;++i)assert(a[i]==i);
	assert(opt.size()<=25000);
	cout<<opt.size()<<"\n";
	for(int i=0;i<opt.size();++i)
		cout<<opt[i]<<"\n";
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
//public class abc165_a{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		boolean flag = false;		
		for(int i=a ;i<=b ; i++){
			if(i%k == 0){
				flag = true;
				System.out.println("OK");
				break;
			}
		}
		if(!flag) System.out.println("NG");
	}

}

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

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> r(m);
  for(int i = 0; i < m; i++){
    cin >> r[i];
  }
  int ans1 = 0, ans2 = 0;
  for(int i = x; i > 0; i--){
    for(int j = 0; j < m; j++){
      if(i == r[j]) ans1++;
    }
  }
  for(int i = x; i <= n; i++){
    for(int j = 0; j < m; j++){
      if(i == r[j]) ans2++;
    }
  }
  cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 3608
import io.Source.stdin

object Main {

  def main(args: Array[String]) {
    for ((list) <- stdin.getLines().takeWhile(_ != "0 0").map(_.split(" ").map(_.toInt))) {
      val (h: Int, w: Int) = (list(0), list(1))
      printChessBoard(h, w)
    }
  }

  def printChessBoard(h: Int, w: Int) {
    for (i <- 1 to h) {
      for (j <- 1 to w) {
        printChar(isSharp(i, j))
      }
      println()
    }
    println()
  }
  
  def printChar(isSharp: Boolean) {
    if (isSharp) {
      print("#")
    } else {
      print(".")
    }
  }
  
  def isSharp(i: Int, j: Int): Boolean = {
    if ((i % 2 == 0 && j % 2 != 0) || (j % 2 == 0 && i % 2 != 0)) {
      false
    } else {
      true
    }
  }
}


Measured memory_bytes: 53356
#include "bits/stdc++.h"
using namespace std;

int dp[50][500][500];
int INF = pow(10, 9);
int main() {
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    int sumA = 0;
    int sumB = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i] >> C[i];
        sumA += A[i];
        sumB += B[i];
    }

    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 500; j++) {
            for (int k = 0; k < 500; k++) {
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int weightA = 0; weightA <= N * 10; weightA++) {
            for (int weightB = 0; weightB <= N * 10; weightB++) {
                if (weightA >= A[i] && weightB >= B[i]) {
                    dp[i + 1][weightA][weightB] = min(dp[i][weightA][weightB], dp[i][weightA - A[i]][weightB - B[i]] + C[i]);
                }
                else dp[i + 1][weightA][weightB] = dp[i][weightA][weightB];
            }
        }
    }

    int ans = INF;
    int cnt = min(sumA / Ma, sumB / Mb);
    for (int i = 1; i <= cnt; i++) {
        ans = min(ans, dp[N][i * Ma][i * Mb]);
    }
    if (ans == INF) cout << "-1" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 49024
n = gets.to_i
as = gets.split.each_with_object(Hash.new(0)) { |a, h| h[a.to_i] += 1 }

ans = 0
prev = 0

as.keys.sort.each do |k|
  v = as[k]
  next if v < 2

  s = prev * k
  s = [prev * k, k ** 2].max if v >= 4

  ans = s if s >= ans
  prev = k
end

puts ans


Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;


int main(){
  in a,b,k;
  cin>>a>>b>>k;
  if(a>=k){
     a -= k;
  }
  
  else if(a+b<=k){
     a =0;
    b=0;
  }
  
  else{
    b -=(k-a);
    a=0;
  }
  
  cout<<a<<" "<<b;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    int N;
    vector<int> X;
    cin >> N;
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        X.push_back(x);
    }
    int ans = 100000000;
    for(int i=1;i<=100;i++){
        int sum = 0;
        for(int j=0;j<N;j++){
            sum += (X[j] - i)*(X[j] - i);
        }
        ans = min(ans,sum);
    }
    cout << ans ;
}


Measured memory_bytes: 3192
fun main(array: Array<String>) {
    val o = readLine()!!
    val e = readLine()!!
    if(o.length == e.length) {
        repeat(o.length) {
            print(o[it])
            print(e[it])
        }
    }
    else {
        repeat(e.length) {
            print(o[it])
            print(e[it])
        }
        print(o[o.length-1])
    }
}

Measured memory_bytes: 29948
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class FDivisionOrSubstraction {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      ll ans = 0;
      for(ll i=2; i*i<=n; i++) {
        ll tmp = n;
        while(tmp%i==0) {
          tmp/=i;
        }
        if (tmp%i == 1) {
          ans++;
        }
      }

      for(ll p=1; p*p<(n-1); p++) {
        if (p==1) {
          // K=N-1
          if (n != 2) ans++;
        } else if (n%p == 1) {
          ans++;
        }
      }
      // K=N
      ans += 1;
      cout << ans << endl;
    }
};

signed main() {
  FDivisionOrSubstraction solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<P>> person(n);
  rep(i,0,n) {
    int a;
    cin >> a;
    rep(j,0,a) {
      int x,y;
      cin >> x >> y;
      x--;
      person[i].push_back(P(x,y));
    }
  }
  int ans = 0;
  rep(bit,0,1<<n) {
    bool flag = true;
    int cnt = __builtin_popcount(bit);
    if (ans > cnt) continue;
    vector<bool> ishonest(n,false);
    rep(i,0,n) {
      if ((bit >> i) & 1) ishonest[i] = true;
    }
    rep(i,0,n) {
      if ((bit >> i) & 1) {
        rep(j,0,person[i].size()) {
          int x = person[i][j].first, y = person[i][j].second;
          if (y != ishonest[x]) {
            flag = false;
          }
        }
      }
    }
    if (flag) ans = cnt;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<string> ans;
string str;
bool used[26];
int len;

void rec(int p){
  if(p==len){ans.push_back(str);return;}
  int ch=str[p]-'a';
  if(used[ch]){
    rec(p+1);
  }
  if(str[p]<'z'&&!used[ch+1]){
    used[ch+1]=true;
    str[p]++;
    rec(p+1);
    str[p]--;
    used[ch+1]=false;
  }

}
int main(){
  while(1){
    cin>>str;
    if(str=="#")break;
    for(int i=0;i<26;i++)used[i]=false;
    used[0]=true;
    ans.clear();
    len=str.size();
    rec(0);
    sort(ans.begin(),ans.end());
    cout<<ans.size()<<endl;
    if((int)ans.size()<=10){
      for(int i=0;i<(int)ans.size();i++)cout<<ans[i]<<endl;
    }else{
      for(int i=0;i<5;i++)cout<<ans[i]<<endl;
      for(int i=(int)ans.size()-5;i<(int)ans.size();i++){
	cout<<ans[i]<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2352
n = int(input())
xy = [[]  for _ in range(n)]
ans = 0

for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        xy[i].append(tuple([x - 1, y]))

for j in range(2 ** n):
    flag = False
    count = 0
    for k in range(n):
        if j >> k & 1 == 1:
            count += 1
            for x, y in xy[k]:
                if y == 0 and j >> x & 1 == 1:
                    flag = True
                if y == 1 and j >> x & 1 == 0:
                    flag = True
    if flag == False:
        ans = max(count, ans)

print(ans)


Measured memory_bytes: 43884
public class Main {
  private static void solve() {
    int n = ni();
    long ret = 0;
    for (int i = 0; i < n; i ++) {
      long l = nl();
      long r = nl();
      ret +=  r - l + 1;
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using vpii = vector<pair<int, int>>;
using ll = long long;

int		main(void)
{
	double L;

	cin >> L;
	double r1 = L / 3;
	L -= L / 3;
	double r2 = L / 2;
	L -= L / 2;
	double r3 = L;
	cout << fixed << setprecision(10);
	cout << r1 * r2 * r3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=1e6+10;
int num[maxx];
int fl[maxx];
int main() {
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		scanf("%d",&num[i]);
	} 
	sort(num,num+n);
	int cnt=0;
	memset(fl,1,sizeof(fl));
	rep(i,0,n){
		if(fl[ num[i] ] ){
			if( num[i]!=num[i+1] )
			cnt++;
			for(int j=1;j*num[i]<maxx;j++){
				fl[ j*num[i] ]=0;
			}		
		}

	}
	
	cout<<cnt;
} 

Measured memory_bytes: 8456
#include <stdio.h>
int main(){
  int i,j,k,n,x,cou=0;

  while(1){
    scanf("%d %d",&n,&x);
    if(n==0&&x==0)break;

    for(i=1;i<=n-2;i++){
      for(j=2;j<=n-1;j++){
	for(k=3;k<=n;k++){
	  if(i<j&&j<k&&i<k&&i+j+k==x)cou++;
	}
      }
    }
    printf("%d\n",cou);
    cou=0;
  }
  return 0;
}

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

int main(){
    ll N; cin>>N;
    ll min = 10e15;
    rep(i, 5){
        ll x; cin>>x;
        min = std::min(x, min);
    }

    cout << (ll)ceil(N/(double)min) + 4 << endl;
}


Measured memory_bytes: 3704
// aarsh01rsh@gmail.com
// Aarsh Sharma
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char ch) {
  string s(1, ch);
  return '\'' + s + '\'';
}
string to_string(const char *s) {
  return to_string((string)s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define f(i, x, n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int32_t main() {
  fast_io();

  int n, k; cin >> n >> k;
  vll a(n); f (i, 0, n) cin >> a[i];
  if (n == 2) {
    cout << abs(a[n-1] - a[0]);
    return 0;
  }
  vll dp(n);
  dp[0] = 0;
  // dp[1] = abs(a[1] - a[0]);
  // f (i, 2, k) {
  //   int mini = inf;
  //   f (j, 1, i+1) {
  //     if (abs(a[i]-a[i-j]) < mini) {
  //       mini = abs(a[i]-a[i-j]);
  //       dp[i] = dp[i-j] + abs(a[i]-a[i-j]);
  //     }
  //   }
  //   dp[i] = mini;
  // }
  f (i, 1, n) {
    int mini = inf;
    for (int j = 1; j <= min(i, k); j++) {
      if (abs(a[i]-a[i-j])+dp[i-j] < mini) {
        mini = abs(a[i]-a[i-j]) + dp[i-j];
      }
    }
    dp[i] = mini;
  }
  debug(dp);
  cout << dp[n-1];

  return 0;
}

Measured memory_bytes: 5636
#include <iostream>
#include <string>
#include <map>
#include <cstdio>
using namespace std;

int main(){
	map<string,bool> T;
	int n;
	char str[13],c[10];
	cin>>n;
	while(n--){
		scanf("%s%s",c,str);
		if(c[0]=='i')
			T[string(str)] = true;
		else{
			if(T[string(str)])
				printf("yes\n");
			else
				printf("no\n");
		}
	}
	return 0; 
}


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

int main(){
  int64_t n,m,ans;
  cin >> n >> m;
  if(n<=m/2){
    ans = n + (m-2*n)/4;
  }else{
    ans = m/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8


def main():

    count = int(input())

    monsters = list(map(int, input().split(' ')))

    monsters_at_start = sum(monsters)

    heroes = list(map(int, input().split(' ')))

    for i, hero in enumerate(heroes):

        if monsters[i] >= hero:

            monsters[i] -= hero

        elif monsters[i] < hero:

            hero -= monsters[i]

            monsters[i] = 0

            if monsters[i + 1] >= hero:

                monsters[i + 1] -= hero

            else:

                monsters[i + 1] = 0


    print(monsters_at_start - sum(monsters))

    return 0


if __name__ == '__main__':
    main()


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

#define _for(i,a,b) for(int i=(a);i<=(b);i++)
#define _fIter(i,Istart,Iend) for(int i=Istart;i<=Iend;i++)
#define _fM(i,c) for(int i=c.begin();i<c.end();i++)
typedef int _Bx_INT32_0;
	int n,m,k;
int dx[5]={0,-1,0,1,0};
int dy[5]={0,0,-1,0,1};

int main()
{

	cin>>n>>m>>k;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	char e[n+4][m+4];
    int dis[n+4][m+4];
    memset(dis,0x55,sizeof dis);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	cin>>e[i][j];
	//cout<<3;
	//cout<<m-(n-k);
	typedef struct pos{
		int x;
		int y;
	}POS;
	queue<POS>q;
	POS f1234567={a,b};
	q.push(f1234567);
	dis[a][b]=0;
	//cout<<8;
	while(!q.empty())
	{
		//cout<<2;
		POS h=q.front();
		q.pop();int tx=h.x;
				int ty=h.y;
		for(int j=1;j<5;j++)
			{
		for(int i=1;i<=min(k,max(n,m));i++)
		{
	  			//printf("#%d %d %d x=%d->%d,y=%d->%d\n",cnt,i,j,tx,h.x+dx[j]*i,ty,h.y+dx[j]*i);
	  			tx=h.x+dx[j]*i;
	  			ty=h.y+dy[j]*i;
					if(tx<=0||ty<=0||tx>n||ty>m||e[tx][ty]=='@')break;
				if(dis[tx][ty]>dis[h.x][h.y]+1){
					q.push({tx,ty});
					dis[tx][ty]=dis[h.x][h.y]+1;
				}else if(dis[tx][ty]<dis[h.x][h.y]+1)break;
			}
		}
	}
	//for(int i=1;i<=n;i++)
	//{
    //    for(int j=1;j<=m;j++)
	//        cout<<dis[i][j]<<' ';
	//    cout<<endl;
    //}
	cout<<(dis[c][d]==0x55555555?-1:dis[c][d])<<endl;
}
/*
3 5 2
3 2 3 4
.....
.@..@
..@..
*/

/*
9 9 8
1 1 9 9
.........
.@.......
..@......
...@.....
....@....
...@.@...
..@...@..
.@.....@.
.........
*/


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

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  int minX, maxX, minY, maxY;
  minX = minY = 0;
  maxX = W;
  maxY = H;

  for (int i = 0; i < N; ++i) {
    int x,y,a;
    cin >> x >> y >> a;
    switch (a) {
    case 1:
      if (minX < x && x < maxX) {
        minX = x;
      } else if (maxX <= x) {
        minX = maxX;
      }
      break;
    case 2:
      if (minX < x && x < maxX) {
        maxX = x;
      } else if (x <= minX) {
        maxX = minX;
      }
      break;
    case 3:
      if (minY < y && y < maxY) {
        minY = y;
      } else if (maxY <= y) {
        minY = maxY;
      }
      break;
    case 4:
      if (minY < y && y < maxY) {
        maxY = y;
      } else if (y <= minY) {
        maxY = minY;
      }
      break;
    }
  }

  int width = maxX - minX;
  int height = maxY - minY;

  cout << width * height << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int N, s[100001];

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

	long long ans = 0;
	for (int c = 1; c < N; c++) {
		long long sum = 0;
		for (int k = 0; (k + 1) * c < N - 1; k++) {
			if (k * c >= N - 1 - k * c && (N - 1) % c == 0) {
				break;
			}
			sum += s[(N - 1) - k * c] + s[k * c];
			ans = max(ans, sum);
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;

int main() {
	int N, K;
	cin >> N >> K;
	double ans = 0;
	for (int n = 1; n <= N; n++)
	{
		int m = max(0, (int)ceil(log2((double)K / n)));
		ans += 1 / pow(2, m);
	}
	ans /= N;

	cout << setprecision(12) << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
inline int in(){ int x; scanf("%d",&x); return x;}

const int INF = 1<<29;

typedef pair<int,int> P;

int g[110][110];

int main(){
  int i,j,k;
  int n,m;

  while(scanf("%d",&n)){
    if(n == 0) break;
    rep(i,n){ rep(j,n) g[i][j] = INF;}

    m = in();
    while(m--){
      int a, b, cost;
      scanf("%d,%d,%d",&a,&b,&cost);
      g[a][b] = g[b][a] = cost;
    }

//    rep(i,n){ rep(j,n) cout << g[i][j] << ' '; cout << endl;}

    int ans = 1;
    int rest = n;
    vector<int> end(n,0);
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(0,0));
    while(!q.empty()){
      int now = q.top().second;
      int cost = q.top().first;
      q.pop();

//      cout << now << ' ' << cost << endl;

      if(end[now] == 1) continue;
      end[now] = 1;
      int tmp = (cost /100 ) -1;
//      cout << "ans " << ans << endl;
//      cout << "tmp " << tmp << endl;
      ans += tmp;
      rest--;
      if(rest == 0) break;
      rep(i,n){
//        cout << "g[now][i] " << g[now][i] << endl;
        if(!end[i] && g[now][i] != INF) q.push(P(g[now][i],i));
      }
    }

    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int x,a,b;
    cin >> x >> a >> b;
    pr((x-a)%b);
}

Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def combination_mod_initialize(n, MOD=10**9+7):
    fac = [1]*(n+1)
    inv = [1]*(n+1)
    for i in range(1, n+1):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = inv[i-1] * pow(i, -1, MOD) % MOD
    return fac, inv

# 二項係数　高速
def combination_mod(n, r, fac, inv, mod=10**9+7):
    return fac[n] * inv[r] * inv[n-r]


def main():
    S = NI()
    fac, inv = combination_mod_initialize(10000, MOD)
    ans = 0
    if S <= 2:
        print(0)
        exit()
    for n in range(1, S//3+1):
        t = S - 3 * n
        ans += combination_mod(t+n-1, t, fac, inv, MOD)
    print(ans%MOD)



if __name__ == "__main__":
    main()

Measured memory_bytes: 9964
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
s1
..
sn

n 10^5
si 10
 */
int n;
ll a[5];
char str[] = "MARCH";

int main(){
  cin>>n;
  REP(i,n){
    string s;
    cin>>s;
    REP(j,5){
      if(s[0] == str[j])
        a[j]++;
    }
  }

  REP(i,5)
    LOG("%d ", a[i]);
  cerr<<endl;

  ll ans=0;
  REP(i,5){
    FOR_IN(j,i+1,5){
      FOR_IN(k,j+1,5){
        ans += a[i] * a[j] * a[k];
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a[4][3][10];
    for(int b=0;b<4;b++)
    for(int f=0;f<3;f++)
    for(int r=0;r<10;r++){
        a[b][f][r]=0;
    }

    int n;
    cin>>n;
    
    for(int i=0;i<n;i++)
    {
        int b,f,r,v;
        cin >> b>>f>>r>>v;
        a[b-1][f-1][r-1]+=v;
    }
    
    for(int b=0;b<4;b++)
    {
        for(int f=0;f<3;f++)
        {
            for(int r=0;r<10;r++){
                cout << " " << a[b][f][r];
            }
            cout << endl;
        }
        if(b<3)
        cout << "####################" << endl;
    }
}

Measured memory_bytes: 1164
#include <iostream>

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t sum = 1;
    bool over = false;
    for (int64_t i = 0; i < N; ++i)
    {
        int64_t A;
        std::cin >> A;
        if (A == 0)
        {
            sum = 0;
            over = false;
            break;
        }

        if (sum > 1000000000000000000 / A)
            over = true;

        sum *= A;
    }

    if (over)
        std::cout << -1;
    else
        std::cout << sum;
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

int main() {
	int a, p;
	cin >> a >> p;
	p += 3 * a;
	cout << (p / 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

bool ispal(string s) {
    int n = sz(s);
    rep(i, 0, n - 1) {
        if(s[i] != s[n - i - 1]) {
            return false;
        }
    }
    return true;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = sz(s);
    if(!ispal(s) || !ispal(s.substr(0, (n - 1) / 2)) || !ispal(s.substr((n + 1) / 2))) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	int h,w,x;
	char c[99];
	scanf("%d %d",&h, &w);
	for(int i=0; i<h; i++){
	scanf("%s", c);
	printf("%s\n%s\n", c, c);
	}
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
ans = [0] * n

for i in range(n):
    for j in range(i + 1, n):
        if j <= (x + y - 1) // 2 or (x + y - 2) // 2 <= i or j - i <= (y - x) // 2:
            ans[j - i] += 1
        else:
            ans[abs(i - x + 1) + abs(j - y + 1) + 1] += 1

for i in ans[1:]:
    print(i)

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

public static class Test
{
    public static IEnumerable<S> Scan<T, S>(this IEnumerable<T> ie, S init, Func<S, T, S> predicate)
    {
        var sum = init;
        foreach(var x in ie)
            yield return sum = predicate(sum, x);
    }
    
    public static void Main()
    {
        int.Parse(Console.ReadLine());
        var directions = Console.ReadLine().Select(x => x == 'E' ? 1 : 0).ToArray();
        
        var costs = directions
            .Scan(
                new { cost = directions.Sum(), prev = 1 },
                (s, x) => new { cost = s.cost + (1 - s.prev) - x, prev = x })
            .Select(x => x.cost);
        
        Console.WriteLine(costs.Min());
    }
}


Measured memory_bytes: 20832
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	if(a + b < c) printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=2e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	ll a, b, ans;
	cin >> a >> b;
	ans = (a*b)/__gcd(a, b);
	cout << ans << endl;
	return 0;
}


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

int main() {
  int64_t W, H, x, y;
  cin >> W >> H >> x >> y;
  bool is_center = (W % 2 == 0 && H % 2 == 0) && (W / 2 == x && H / 2 == y);
  cout << (static_cast<double>(W * H) / 2.0) << ' ' << (is_center ? '1' : '0') << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int house[4][3][10]={},n,i,b,f,r,v;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        house[b-1][f-1][r-1] += v;
    }
    for(b=0;b<4;b++){
        for(f=0;f<3;f++){
            for(r=0;r<10;r++){
                printf(" %d",house[b][f][r]);
            }
            printf("\n");
        }
        if (b != 3) printf("####################\n");
    }
    return 0;
}


Measured memory_bytes: 2044
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Author: z0marlin
Title: C.cpp
Time: 16-08-2019T23:13:25+0530 
I suck at CP T_T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
#include <bits/stdc++.h>
#if DEBUG
#define dprintf(...) printf(__VA_ARGS__)
#else
#define dprintf(...)
#endif
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define FORE(a, v) for(auto a:v)
#define MAX(a, b) ((a>b)?a:b)
#define MIN(a, b) ((a<b)?a:b)
#define MP(i, j) make_pair(i, j)
#define PB(a) push_back(a)
#define PPB(a) pop_back(a)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii_t;
typedef pair<ll,ll> pll_t;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;

const int MAX_SZ=1e6+2;
const int MOD=1e9+7;
ll t = 1, n, m, q, ql, qr;
char ch;

ll solve(){
    if(qr-ql>=2019) return 0;
    ll minP=2020;
    for(ll i = ql; i<=qr; i++){
        for(ll j=i+1; j<=qr; j++){
            minP = min(minP, (i%2019 * j% 2019)%2019);
        }
    }
    return minP;
}

int main(){
    // scanf("%d", &t);
    while(t--){
        scanf("%d%d", &ql, &qr);
    }
    printf("%lld\n", solve());
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

struct Node
{
  int parent;
  long counter;
  vector<int> children;
};

static vector<Node> nodes;

static void
make_tree(int parent, int myself)
{
  Node &node = nodes[myself];
  node.parent = parent;
  auto it = node.children.begin();
  while (it != node.children.end())
  {
    if (*it == parent)
    {
      it = node.children.erase(it);
    }
    else
    {
      make_tree(myself, *it);
      it++;
    }
  }
}

static void
propgate_counter(int n, long add)
{
  Node &node = nodes[n];
  node.counter += add;
  for (auto child: node.children)
  {
    propgate_counter(child, node.counter);
  }
}

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

  nodes.resize(N);
  for (int n = 0; n < N - 1; n++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    nodes[a].children.push_back(b);
    nodes[b].children.push_back(a);
  }

  // 木を構成する。
  make_tree(-1, 0);

  // 根のカウンターを読み込む。
  for (int q = 0; q < Q; q++)
  {
    int p, x;
    cin >> p >> x;
    nodes[p - 1].counter += x;
  }

  propgate_counter(0, 0);
  
  // ノード毎のカウンターを出力する。
  for (int n = 0; n < N; n++)
  {
    if (n != 0)
    {
      cout << ' ';
    }
    cout << nodes[n].counter;
  }
  cout << endl;
  return 0;
}


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

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    while(op != '?'){
        int c;
        if (op == '+') c = a + b;
        if (op == '-') c = a - b;
        if (op == '*') c = a * b;
        if (op == '/') c = a / b;
        cout << c << endl;
        cin >> a >> op >> b;
    }
}



Measured memory_bytes: 3088
l,r = map(int,input().split())

mod = 2019

lm = l % mod
rm = r % mod

ans = []
if r - l >= mod :
  print(0)
  exit()
else:
  for i in range(lm,rm):
    for j in range(i+1,rm+1):
      ans.append(i*j % mod)
  print(min(ans))

Measured memory_bytes: 75380
n = int(input())
a = list(map(int, input().split()))

odd = []
ans = []
for i in range(n):
  if i%2 == 0:
    odd.append(a[i])

for j in range(len(odd)):
  if odd[j]%2 == 1:
    ans.append(odd[j])

print(len(ans))

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

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    
    int res = 0;
    for(int i = 0; i < n;) {
        int num = 1;
        if(i + 1 < n && a[i] == a[i+1]) {
            while(a[i] == a[i+1]) {
                ++num;
                ++i;
            }
        }
        if(num % 2 == 1) ++res;
        ++i;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        StringBuilder sb = new StringBuilder();

        sb.append(z+" ");
        sb.append(x+" ");
        sb.append(y);

        System.out.println(sb.toString());
    }

}


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

int main(){
    double w, h, x, y; cin >> w >> h >> x >> y;
    int cnt=0;
    if(w==x+x && h==y+y) cnt = 1;
    double ans;
        ans = w*h/2;
    cout << setprecision(15) << ans << ' ';
    cout << cnt << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
    string s;
    cin >>s;
    if(s[0]=='9'||s[1]=='9'){
        cout <<"Yes";
        return 0;
    }
cout <<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  string S; cin>>S;
  vector<int>E(N);
  vector<int>W(N);
  for(int i=0;i<N;i++){
    if(S.at(i)=='E')E[i]++;
    else W[i]++;
    if(i!=0){E[i]+=E[i-1];W[i]+=W[i-1];}
  }
  vector<int>ans(N);
  for(int i=0;i<N;i++){
    if(i!=0)ans[i]+=W[i-1];
    ans[i]+=E[N-1]-E[i];
  }
  sort(ans.begin(),ans.end());
  cout<<ans[0]<<endl;
}

Measured memory_bytes: 7204
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int nn = n * (n - 1) / 2, mm = m * (m - 1) / 2;
    if (n == 1) {
        cout << mm << '\n';
    }
    else if (m == 1)
    {
        cout << nn << '\n';
    }
    else
        cout << nn + mm << '\n';
    
  
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

void dfs(vector<vector<pair<int, int> > > &t, vector<int> &ans, int p, int pc) {

    int c = 1;
    REP(i, t[p].size()) {
        if (ans[t[p][i].second] != 0) continue;
        if (c == pc) ++c;
        ans[t[p][i].second] = c;
        dfs(t, ans, t[p][i].first, c);
        ++c;
    }
}

void solve() {
    int N;
    cin >> N;

    vector<vector<pair<int, int> > > T(N);
    vector<int> ans(N-1);
    REP(i, N-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        T[a].push_back(make_pair(b, i));
        T[b].push_back(make_pair(a, i));
    }

    dfs(T, ans, 0, 0);

    int C = 0;
    REP(i, N-1) C = max(C, ans[i]);
    print(C);
    REP(i, N-1) print(ans[i]);
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

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

  sort(a.begin(), a.end(), greater<ll>());
  ll cnt = a[0];

  if (n == 2) {
    print(a[0]);
    return 0;
  }

  cnt += a[1];
  /* print(cnt); */

  vector<ll> b(3);
  b[0] = a[1];
  b[1] = a[2];
  b[2] = a[2];
  REP(i, n - 3) {
    cnt += b[i];
    b.emplace_back(a[3 + i]);
    b.emplace_back(a[3 + i]);
    /* print(cnt, b[i], b); */
  }
  print(cnt);
}


Measured memory_bytes: 11124
n = int(input())
X = []
Y = []
for i in range(n):
  x, y = map(int, input(). split())
  X.append(x)
  Y.append(y)
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    ans+=( (X[j]-X[i])**2 + (Y[j]-Y[i])**2 )**(1/2)
print(2*ans/n)

Measured memory_bytes: 3064
import math

x = int(input())

fL = [i**5 for i in range(0, 1001)]

for i, f1 in enumerate(fL):
    for j, f2 in enumerate(fL):
        a = j
        b = i
        if f1 + f2 == x:
            print(a, -b)
            exit()
        if f1 - f2 == x:
            print(b, a)
            exit()


Measured memory_bytes: 9204