akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;

void solve(){
	int n = N;
	int s = 0;
	while(n) s += n % 10, n /= 10;
	cout << (N % s ? "No" : "Yes") << endl;
}

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


Measured memory_bytes: 256
h1_init,a_t,h2_init,a_a = list(map(int, input().split()))
h1=h1_init
h2=h2_init

while h1>=0 or h2>=0:
  h2=h2-a_t
  if h2<=0:
    print("Yes")
    break
    
  h1=h1-a_a
  if h1<=0 :
    print("No")
    break

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

using namespace std;

#define ll long long int
#define vi vector<int>
#define prec fixed<<setprecision(10)
#define mod 1000000007
#define set(x) __builtin_popcount(x)
#define ffs(x) __builtin_ffs(x)
#define clz(x) __builtin_clz(x)
#define inf 1000000007
#define linf 1000000000000000007


int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
  	int n;
  	cin >> n;
  	string s;
  	cin >>s;
  	long long r=0,g=0,b=0;
	for(int i=0;i<n;i++){
		if(s[i] == 'R'){
			r++;
		}else if(s[i] == 'G'){
			g++;
		}else{
			b++;
		}
	}
	long long count1=0;
  	for(int i=0;i<n;i++){
  		for(int j=i+1;j<n;j++){
  			if(2*j-i < n){
  				if(s[i]!=s[j] && s[j]!=s[j-i+j] &&s[j-i+j]!=s[i])count1++;
  			}
  		}
  	}
  	
  	cout << (r*g*b >=1?r*g*b- count1:0);
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

class UnionFind {
public:
    struct Node {
        long long parent;
        long long rank;
        Node() = default;
        Node(const long long& _parent,
             const long long& _rank) :
            parent(_parent),
            rank(_rank) { }
    };

    std::vector<Node> node;

    UnionFind(const long long& num_node) :
        node(num_node) {
        for(long long i = 0; i < num_node; i++) {
            node[i].parent = i;
        }
    }

    long long getRoot(const long long& x) {
        return (node[x].parent == x) ?
            x : node[x].parent = getRoot(node[x].parent);
    }

    void unite(const long long& x,
               const long long& y) {
        auto rx = getRoot(x);
        auto ry = getRoot(y);
        if(rx != ry) {
            if(ry < rx) std::swap(rx, ry);
            if(node[rx].rank < node[ry].rank) {
                node[rx].parent = ry;
            }
            else {
                node[ry].parent = rx;
                if(node[rx].rank == node[ry].rank) {
                    node[rx].rank++;
                }
            }
        }
    }

    bool checkSameRoot(const long long& x,
                       const long long& y) {
        return getRoot(x) == getRoot(y);
    }
};

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

    int N, K, L;
    std::cin >> N >> K >> L;

    UnionFind road(N), tr(N);
    REP(i, K) {
        int p, q;
        std::cin >> p >> q;
        road.unite(p - 1, q - 1);
    }
    REP(i, L) {
        int r, s;
        std::cin >> r >> s;
        tr.unite(r - 1, s - 1);
    }

    map<pair<int, int>, int> map;
    REP(i, N) {
        auto p = make_pair(road.getRoot(i), tr.getRoot(i));
        auto itr = map.find(p);
        if(itr != map.end()) {
            itr->second++;
        }
        else {
            map.insert(make_pair(p, 1));
        }
    }

    REP(i, N) {
        std::cout << map[make_pair(road.getRoot(i), tr.getRoot(i))] << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 18176
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		List<Long> positive = new ArrayList<>();
		List<Long> negative = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			long x = sc.nextLong();
			if(x < 0) {
				negative.add(x);
			} else {
				positive.add(x);
			}
		}
		Collections.sort(positive);
		Collections.sort(negative, Comparator.reverseOrder());
		long ans = Long.MAX_VALUE;
		for(int i = 0; i < k - 1 && i < negative.size(); i++) {
			if(k - i - 2 < positive.size())	{
				ans = Math.min(ans, positive.get(k - i - 2) - 2 * negative.get(i));
			}
		}
		if(negative.size() > 0 && negative.size() >= k) {
			ans = Math.min(ans, -negative.get(k - 1));
		}
		for(int i = 0; i < k - 1 && i < positive.size(); i++) {
			if(k - i - 2 < negative.size()) {
				ans = Math.min(ans, 2 * positive.get(i) - negative.get(k - i - 2));
			}
		}
		if(positive.size() > 0 && positive.size() >= k) {
			ans = Math.min(ans, positive.get(k - 1));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 63920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll a[3];

int main(void){
	rep(i,3)cin>>a[i];
	sort(a,a+3);
	cout<<(a[2]==a[1]&&a[1]==a[0]?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            int[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int N = nbrs[0];
            int M = nbrs[1];
            int C = nbrs[2];

            int[] b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int res = 0;
            int sum;

            for(int i = 0; i < N; i++)
            {
                int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                sum = C;
                for(int y = 0; y < M; y++)
                {
                    sum += a[y] * b[y];

                }

                if (sum > 0)
                    res++;
            }

            Console.WriteLine(res);
        }
    }
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int a, b; cin >> a >> b;
    int ans = 0;
    int tmp = 0;
    while(true) {
        if(tmp+1 >= b) break;
        ans++;
        tmp += a-1;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

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

    int n;
    cin >> n;
    int h[100010];
    rep(i, n) cin >> h[i];
    int cnt = 0, ans = 0;
    int before = -1;

    rep(i, n) {
        if (h[i] <= before) {
            cnt++;
            before = h[i];
            ans = max(ans, cnt);
        } else {
            before = h[i];
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author HP
 */
public class Main {

   
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int N=0;
        if(sc.hasNextInt())
        {
            N=sc.nextInt();
        }
        int[]Arr=new int[N];
        for(int i=0;i<N;i++)
        {
            Arr[i]=sc.nextInt();
        }
        
          int[]Arr1=new int[N];
          for(int i=0;i<N;i++)
          {
             Arr1[Arr[i]-1]=i+1;
          }
          for(int i=0;i<N;i++)
          {
          System.out.print(Arr1[i]+" ");
          }
 
        // TODO code application logic here
    }
    
}


Measured memory_bytes: 58772
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	ll n; cin >> n;
	
	vector<ll> a(5); rep(i,5) cin >> a[i];
	
	
	sort(all(a));
	
	ll mini=a[0];
	
	//cout << mini << endl;
	
	ll r=n/mini;
	if(n%mini==0) r--;
	
	cout << r+5 << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        switch (S) {
            case "SUN":
                System.out.println(7);
                return;
            case "MON":
                System.out.println(6);
                return;
            case "TUE":
                System.out.println(5);
                return;
            case "WED":
                System.out.println(4);
                return;
            case "THU":
                System.out.println(3);
                return;
            case "FRI":
                System.out.println(2);
                return;
            case "SAT":
                System.out.println(1);
                return;
        }

    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

int c(char *p,int d){return ((26+*p-*(p+1))%26==d);}
int a(char *p){return((*p<'a')||(*p>'z'));}
char *decode (char *inbuf, int s) {
  int p = 0;
  while (inbuf[p] != 0) {
    if ((inbuf[p] >= 'a')&&(inbuf[p]<='z')) {
      int t = inbuf[p] + s;
      //inbuf[p] = inbuf[p] + (char)s;
      if (t > 'z')      inbuf[p] = (char)(t - 26);
      else if (t < 'a') inbuf[p] = (char)(t + 26);
      else              inbuf[p] = (char)t;
    }
    p++;
  }
  return (inbuf);
}

int main(){
  char inbuf[82];
  while(fgets(inbuf,80,stdin)){
    int s;
    char *p=inbuf;
    while(*p){
      s = 0;
      if(c(p,12)){
	//      if (((*p-*(p+1))==12)||((*p-*(p+1))==-14)) {
	/* the */
	if (((*p-*(p+2))==15)||((*p-*(p+2))==-11)) {
	  if(a(p+3))
	    s = 't' - *p;
	}
	/* that */
	else if (((*p-*(p+2))==19)||((*p-*(p+2))==-7)) {
	  if (*p-*(p+3) == 0)
	  if(a(p+4))
	      s = 't' - *p;
	}
	/* this */
	else if (((*p-*(p+2))==11)||((*p-*(p+2))==-15)) {
	  if (((*p-*(p+3))==1)||((*p-*(p+3))==-25))
	  if(a(p+4))
	      s = 't' - *p;
	}
      }
      if (s) break;
      p++;
    }
    printf("%s",decode(inbuf, s));
  }
  return 0;
}

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

using namespace std;

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

  if (find(S.begin(), S.end(), 'a') != S.end() and find(S.begin(), S.end(), 'b') != S.end() and find(S.begin(), S.end(), 'c') != S.end()) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
n, y = map(int, input().split())

man, gosen, sen = -1, -1, -1
for i in range(n + 1):
  for j in range(n - i + 1):
    if y == 10000 * i + 5000 * j + 1000 * (n - i - j):
      man = i
      gosen = j
      sen = n - i - j
      break
print(man, gosen, sen)


Measured memory_bytes: 2940
n = int(input())
p = list(map(int, input().split(' ')))
count = 0
for i in range(1,n-1):
    if p[i-1] < p[i] < p[i+1]:
        count += 1
    elif p[i-1] > p[i] > p[i+1]:
        count+= 1
print(count)


Measured memory_bytes: 3060
H,N = map(int,input().split())

A = []
B = []
for _ in range(N):
    i1,i2 = map(int,input().split())
    A.append(i1)
    B.append(i2)


# HPが0のとき
dp = {}
# 全てコスト無限大としておく
for hp in range(H+1):
    dp[hp] = float('inf')

dp[H] = 0
for hp in range(H,-1,-1):
    # 遷移 = 魔法を1つ使う
    for i in range(N):
        # 遷移先
        hp_next = hp - A[i]
        if hp_next < 0: hp_next = 0
        # 遷移先のコスト
        mp_next = dp[hp] + B[i]
        

        dp[hp_next] = min(dp[hp_next],mp_next)

print(dp[0])

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;
const int MAX_N=400;


struct TILE{
	int c[4];
	int index;
	TILE(int a=0,int b=0,int f=0, int d=0,int ind=0){
		c[0]=a;
		c[1]=b;
		c[2]=f;
		c[3]=d;
		index=ind;
	}
	bool operator < (const TILE &t)const{
		REP(i,4){
			if (c[i]!=t.c[i]){
				return c[i]<t.c[i];
			}
		}
		return false;
	}
	bool operator == (const TILE &t)const{
		REP(i,4){
			if (c[i]!=t.c[i]){
				return false;
			}
		}
		return true;
	}
};

TILE rotate(const TILE &t,int x){
	TILE res=t;
	REP(i,x){
			TILE temp=res;
			REP(j,4){
				res.c[j]=temp.c[(j+3)%4];
			}
	}
	return res;
}

int N;
TILE T[MAX_N*4];
int pa[4]={1,0,3,2};

int main(){
	scanf("%d",&N);
	REP(i,N){
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		T[i*4]=TILE(a,b,c,d,i);
		FOR(j,1,4){
			T[i*4+j]=rotate(T[i*4],j);
		}
	}
	sort(T,T+N*4);
	ll ans=0;
	TILE TI[6];
	int cnt[4];
	int cnt2[4][4];
	REP(i,N*4){
		TI[0]=T[i];
		REP(j,N*4){
			if (TI[0].index>=T[j].index) continue;
			TI[1]=T[j];
			memset(cnt,0,sizeof(cnt));
			REP(k,4){
				TI[k+2]=TILE(TI[0].c[(k+1)%4],TI[0].c[k],TI[1].c[pa[k]],TI[1].c[pa[(k+1)%4]],0);
			}
			REP(k,4){
				cnt[k]=upper_bound(T,T+N*4,TI[k+2])-lower_bound(T,T+N*4,TI[k+2]);
				REP(a,2){
					REP(b,4){
						if (TI[k+2]==rotate(TI[a],b)){
							cnt[k]--;
						}
					}
				}
			}
			REP(k,4){
				FOR(a,k+1,4){
					cnt2[k][a]=0;
					REP(b,4){
						if (TI[k+2]==rotate(TI[a+2],b)){
							cnt2[k][a]++;
						}
					}
				}
			}
			bool f=false;
			ll temp=1;
			REP(k,4){
				REP(a,k){
					cnt[k]-=cnt2[a][k];
				}
				if (cnt[k]<0){
					f=true;
				}else{
					temp*=cnt[k];
				}
			}
			if (!f){
				ans+=temp;
			}
		}
	}
	ans/=12;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
import sys
import collections
#import numpy as np

readline = sys.stdin.readline

def main():
    N = int(input())
    #A1 = np.array(list(map(int, readline().split())))
    A = list(map(int, readline().split()))

    count = [0] * (max(A) + 3)
    for a in A:
        count[a+1] += 1
        count[a] += 1
        count[a+2] += 1

    print(max(count))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14292
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 2e3 + 10;
const int inf = 0x7ffffff;

ll dp[maxn][maxn];

void solve()
{
    int N;
    cin >> N;
    vector<pair<ll, ll>> vec(N);
    for (int i = 0; i < N;i++)
    {
        cin >> vec[i].first;
        vec[i].second = (ll)(i + 1);
    }
    sort(vec.rbegin(), vec.rend());
    for (int i = 1; i <= N;i++)
    {
        for (int j = 0; j <= i;j++)
        {
            int l = j + 1, r = N - i + j;
            if(r + 1 <= N)
                dp[l][r] = max(dp[l][r], dp[l][r + 1] + vec[i - 1].first * abs(vec[i - 1].second - r - 1));
            if(l - 1 >= 1)
                dp[l][r] = max(dp[l][r], dp[l - 1][r] + vec[i - 1].first * abs(vec[i - 1].second - l + 1));
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N;i++)
    {
        ans = max(ans, dp[i][i] + vec[N - 1].first * abs(i - vec[N - 1].second));
    }
    cout << ans << "\n";
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 26380
import sys
N=int(input())
l=[]
q=0
cnt=0
BA=0
BN=0
NA=0

if 1<=N<=10**4:
	for i in range(N):
		st=input()
		if 2<=len(st)<=10:
			l.append(st)
		else:
			sys.exit()
	for i in l:
		cnt+=i.count('AB')
		if i[0]=='B' and i[-1]=='A':
			BA+=1
		elif i[0]=='B':
			BN+=1
		elif i[-1]=='A':
			NA+=1
	if BA>0:
		cnt+=BA-1
		if BN>0:
			cnt+=1
			BN-=1
		if NA>0:
			cnt+=1
			NA-=1
	if BN>0 and NA>0:
		cnt+=min(BN,NA)
	print(cnt)
	

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

int main (void){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[0] == s[2] && s[0] == s[3]){
        cout << "No" << endl;
    }else{
        if(s[0] == s[1] && s[2] == s[3]){
            cout << "Yes" << endl;
            }else if(s[0] == s[2] && s[1] == s[3]){
                cout << "Yes" << endl;
                }else if(s[0] == s[3] && s[1] == s[2]){
                    cout << "Yes" << endl;
                    }else{
                        cout << "No" << endl;
                        }
    }
    return 0;
}



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

using namespace std;

const int INF = 1e9;

int dp[101010];

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];

  for (int i = 0; i < 101010; i++) dp[i] = INF;

  dp[0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j <= i + K; j++) {
      int cost = abs(h[i] - h[j]);
      dp[j] = min(dp[j], dp[i] + cost);
    }
  }

  cout << dp[N - 1] << endl;

  return 0;
}

Measured memory_bytes: 1024
use std::io;

fn main() {
    let mut input = String::new();
    match io::stdin().read_line(&mut input) {
        Ok(_) => {
            execute(input.as_str());
        },
        Err(error) => {
            println!("{}", error);
        }
    }
}

fn execute(s: &str) {
    let v = s.trim().replace(" " , "").parse::<i32>().unwrap();

    for n in 4..317 {
        let square = n * n;
        if square == v {
            println!("Yes");
            return;
        } else if square > v {
            break
        }
    }

    println!("No")
}

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

using namespace std;

#define PB push_back
#define MP make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

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

int main() {
  int N, A;
  cin >> N >> A;
  cout << ((N%500<=A)?"Yes":"No") << endl;
  return 0;
}


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

int main() {
  ll N;
  cin >> N;
  
  ll ans = N-1;
  
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {

      ans = i + N / i -2;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    long long a;
    set<long long> st;
    map<long long ,int> mp;
    rep(i,n){
        cin >> a;
        st.insert(a);
        mp[a]++;
    }
    auto itr = st.end();
    int cnt = 0;
    long long ans[2] = {0,0};
    for(int i = 0;i<st.size();i++){
        itr--;
        while(mp[*itr]>=2){
            ans[cnt]=*itr;
            cnt++;
            if(cnt==2) break;
            mp[*itr]-=2;
        }
        if(cnt==2) break;
    }
    cout << ans[0]*ans[1] << endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s,t,u;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if(u==s) a--;
    if(u==t) b--;
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<29;

int main(){
    ll a,b;
    cin >> a>>b;
    cout << a/gcd(a,b)*b <<endl;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    int N; cin>>N;

    for (int i = 0; i < N; ++i) {
        int tmp; cin>>tmp;
        if(tmp%2==0){
            if(tmp%3!=0 && tmp%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
s = input()

first = int(s[:2])
second = int(s[2:])

if first == 0 and second == 0:
    print("NA")
else:
    if first > 12 and second <= 12 and second != 0:
        print("YYMM")
    elif first <= 12 and second <= 12:
        if first != 0 and second == 0:
            print("MMYY")
        elif second !=0 and first == 0:
            print("YYMM")
        else:
            print("AMBIGUOUS")
    elif first <= 12:
        print("MMYY")
    else:
        print("NA")


Measured memory_bytes: 3060
#include <stdio.h>

typedef unsigned long long li;

int table[2][13] = {{365, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
					{366, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};

li conv(int y, int m, int d)
{
	li ret;
	int i;
	li t = y - 1;
	ret = 0;
	ret += t * 365 + (t / 4) - (t / 100) + (t / 400);
	
	if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)){
		for (i = 1; i <= m - 1; i++){
			ret += table[1][i];
		}
	}
	else {
		for (i = 1; i <= m - 1; i++){
			ret += table[0][i];
		}
	}
	ret += d;
	return (ret);
}

int main(void)
{
	char rec[256];
	li t;
	int i, j;
	int dot;
	while (scanf("%s", rec), rec[0] != '#'){
		dot = 0;
		for (i = 0; rec[i] != '\0'; i++){
			if (rec[i] == '.') dot++;
		}
		if (dot == 2){
			int year, month, day;
			sscanf(rec, "%d.%d.%d", &year, &month, &day);
			t = (conv(year, month, day) - conv(2012, 12, 21)) % (1872000);
			
			printf("%lld.", t / (20 * 20 * 20 * 18));
			t %= (20 * 20 * 20 * 18);
			printf("%lld.", t / (20 * 20 * 18));
			t %= (20 * 20 * 18);
			printf("%lld.", t / (20 * 18));
			t %= (20 * 18);
			printf("%lld.", t / 20);
			t %= 20;
			printf("%lld\n", t);
		}
		else {
			li b, ka, tt, w, ki;
			int y, sum;
			sscanf(rec, "%lld.%lld.%lld.%lld.%lld", &b, &ka, &tt, &w, &ki);
			t = b * (20 * 20 * 20 * 18) + ka * (20 * 20 * 18) + tt * (20 * 18) + w * 20 + ki + conv(2012, 12, 21);
			
			for (i = 0; i < 10000; i++){
				if (t <= i * 365 + (i / 4) - (i / 100) + (i / 400)) break;
			}
			y = i;
			printf("%d.", y);
			y--;
			t -= (y * 365 + (y / 4) - (y / 100) + (y / 400));
			sum = 0;
			y++;
				for (j = 1; j <= 12; j++){
					if (t > table[y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)][j]){
						t -= table[y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)][j];
					}
					else {
						break;
					}
				}
				printf("%d.%lld\n", j, t);
		}
	}
	
	return (0);
}

Measured memory_bytes: 1040
#include<iostream>
#include <algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

const int mod = 1000000007;
struct mint {
  ll x;

  mint(ll 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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint combi(ll l, ll r) {
  mint lm = 1;
  for(ll i=l-r+1; i<=l; i++) lm *= i;
  mint rm = 1;
  for(ll i=1; i<=r; i++) rm *= i;
  return lm * rm.pow(1e9+7-2);
}

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

  mint ans = 2;
  ans = ans.pow(n)-1;
  ans = ans - (combi(n, a) + combi(n, b));
  cout << ans.x << endl;
  return 0;
}


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

const ll INF = 1001001001;
const ll mod = 1000000007;

int main(){
    int n, h; cin >> n >> h;
    vector<pair<ll, ll>> a(n);
    vector<ll> b(n);
    ll st = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i].first >> a[i].second;
        b[i] = a[i].second;
    }
    sort(a.begin(), a.end(), greater<pair<int, int>>());
    ll cnt = 0;
    for(int i = 0; i < n; i++){
        if(b[i] > a[0].first){
            st += b[i];
            cnt++;
        }
    }
    if(st >= h){
        sort(b.begin(), b.end(), greater<ll>());
        ll tmp = 0;
        for(int i = 0; i < n; i++){
            tmp += b[i];
            if(tmp >= h){
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
    else{
        h -= st;
        cout << cnt + (h + a[0].first - 1) / a[0].first << endl;
    }
    
}

Measured memory_bytes: 5612
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NAB = Sarray();
            var N = NAB[0];
            var A = NAB[1];
            var B = NAB[2];
            if (B < A)
            {
                WriteLine(0);
                return;
            }
            if (1 == N && A != B)
            {
                WriteLine(0);
                return;
            }
            var min = A * (N - 1) + B;
            var max = A + B * (N - 1);
            WriteLine(max - min + 1);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll n,m,c;
    cin >>n>>m>>c;
    vector<ll> b;
    rep(i, m){
        ll bb ;
        cin>>bb;
        b.push_back(bb);
    }
    ll sum=0;
    rep(i, n){
        vector<ll> a;
        rep(i, m){
            ll bb ;
            cin>>bb;
            a.push_back(bb);
        }
        auto in = inner_product(
        a.begin(), a.end(),
        b.begin(),
        c);
        if(in > 0) sum++;
    }
    pr(sum);
    return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int n;cin>>n;
   cout<<"A";
   if(n<1200)cout<<"B";
   else if(n<2800)cout<<"R";
   else cout<<"G";
   cout<<"C"<<endl;
   return 0;
}

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

int main(){
	int n,x,count = 0;
	int a[101] = {};
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x;
		a[i] = x;
	}
	bool flag = true;
	while(flag){
		flag = 0;
		for(int j = n-1;j > 0;j--){
			if(a[j] < a[j-1]){
			swap(a[j],a[j-1]);
			flag = 1;
			count++;
			}
		}
	}
	for(int i = 0;i < n;i++){
		if(i == n-1)cout << a[i] <<endl;
		else cout << a[i] << " ";
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    Q = int(readline())
    dd = Counter(A) 
    S = sum(A)
    
    for _ in range(Q):
        b, c = map(int, readline().split())
        dd[c] += dd[b]
        S = S - b*dd[b] + c*dd[b]
        dd[b] = 0
        print(S)
if __name__ == '__main__':
    main()


Measured memory_bytes: 88832
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M;
	cin >> N >> M;

	vector<vector<lint>> city(N);
	vector<pair<int, lint>> city_order(M);

	for (int i = 0; i < M; i++)
	{
		int n;
		lint y;
		cin >> n >> y;
		city[n - 1].push_back(y);
		city_order[i] = make_pair(n - 1, y);
	}

	for (int i = 0; i < N; i++)
	{
		sort(all(city[i]));
	}

	for (int i = 0; i < M; i++)
	{
		int n = city_order[i].first;
		lint y = city_order[i].second;

		int count = lower_bound(all(city[n]), y) - city[n].begin() + 1;
		n++;
		//cout << y << " " << count << endl;
		printf("%06d%06d\n", n, count);

		//cout << n << " " << count << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e6+5;
ll inf=1e15;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    
    while(t--)
    {
        
        int n,k;
        cin>>n>>k;
        ll ar[n];
        for(int i=0;i<n;i++)
            cin>>ar[i];
        ll dp[n+1];
        for(int i=1;i<=n;i++)
            dp[i]=inf;
        dp[0]=0;
        dp[1]=0;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<=min(k,i-1);j++)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(ar[i-1]-ar[i-j-1]));
            }
        }

        cout<<dp[n];
    }

    return 0;
}

Measured memory_bytes: 5132
from collections import deque
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

c = list(map(int, input().split()))
c.sort()
score = sum(c)-c[-1]

for i in range(n):
    if len(graph[i]) == 1:
        next_v = deque([i])
        break
# dfs
ans = [-1]*n
while next_v:
    v = next_v.popleft()
    ans[v] = c.pop()
    for i in graph[v]:
        if ans[i] != -1:
            continue
        next_v.append(i)

print(score)
print(*ans, sep=" ")


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

int main() {
  int d;
  cin>>d;
  if(d==25) cout<<"Christmas"<<endl;
  if(d==24) cout<<"Christmas Eve"<<endl;
  if(d==23) cout<<"Christmas Eve Eve"<<endl;
  if(d==22) cout<<"Christmas Eve Eve Eve"<<endl;

  }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll N, K;
int A[200000];
bool used[200000];
int cnt[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }
    int tmp = 0;
    int cur = 0;
    while(!used[tmp]){
        used[tmp] = true;
        cnt[tmp] = cur;
        tmp = A[tmp];
        cur++;
    }
    int cycle = cur-cnt[tmp];
    if(K < cur){
        for(int i = 0; i < N; i++){
            if(cnt[i] == K){
                cout << i+1 << endl;
                return 0;
            }
        }
    }else{
        K -= cur;
        K %= cycle;
        for(int i = 0; i < N; i++){
            if(cnt[i] == cnt[tmp]+K){
                cout << i+1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 5400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K,S; cin >> N >> K >> S;
    vector<ll> ans(N);
    rep(i,N){
        if (i<K) ans[i]=S;
        else {
            if (S!=INF) ans[i]=S+1;
            else ans[i]=1;
        }
    }
    rep(i,N){
        cout << ans[i];
        if (i!=N-1) cout << ' ';
        else cout << endl;
    }
}

Measured memory_bytes: 2176
# coding: utf-8
import sys
from math import sin, cos, radians

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 2点間の距離、x座標とy座標、複素数
A, B, H, M = lr()
d1 = radians(30 * H + 30 * M / 60)
d2 = radians(360 * M / 60)
# a**2 = b**2 + c**2 - 2*b*c*cos(A)
C = A * A + B * B - 2 * A * B * cos(d1-d2)
answer = C ** .5
print(answer)


Measured memory_bytes: 9468
def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def cross_point(c, d):
    l = d - c
    v1 = cross(lv, l)
    v2 = cross(lv, lt - c)
    return c + v2 / v1 * l


n = int(input())
points = [complex(*map(int, input().split())) for _ in range(n)]
point0 = points.pop(0)
points.append(point0)

q = int(input())
while q:
    x1, y1, x2, y2 = map(int, input().split())
    ls, lt = (x1 + 1j * y1, x2 + 1j * y2)
    lv = lt - ls

    area = 0
    prev = point0
    prev_flag = cross(lv, prev - ls) >= 0
    cp1, cp2 = None, None
    for p in points:
        curr_flag = cross(lv, p - ls) >= 0
        if prev_flag and curr_flag:
            area += cross(prev, p)
        elif prev_flag != curr_flag:
            cp = cross_point(prev, p)
            if prev_flag:
                area += cross(prev, cp)
                cp1 = cp
            else:
                area += cross(cp, p)
                cp2 = cp
        prev, prev_flag = p, curr_flag
    if cp1 is not None and cp2 is not None:
        area += cross(cp1, cp2)
    print(area / 2)
    q -= 1

Measured memory_bytes: 7852
module lib1

let allLines = seq{
    let mutable line = System.Console.ReadLine()
    while line <> null do
        yield line
        line <- System.Console.ReadLine()
}

let mutable line = System.Console.ReadLine()

let data = 
    line.Split(' ')

let H = int64 data.[1]

let katanas =
    allLines
    |> Seq.map (fun l ->
        let ll = l.Split(' ')
        int64 ll.[0], int64 ll.[1]
    )
    |>Seq.toList

let maxA = List.maxBy (fun x -> fst x) katanas
let B = List.sortBy (fun x -> snd x) katanas |> List.rev
let hp, count =
    B
    |> List.fold (fun s (_, b) ->
        if b < fst maxA || fst s <= int64 0 then s
        else
            let newHP = fst s - b
            newHP, snd s + 1
    ) (H, 0)

let addCount = float hp / float (fst maxA) |> ceil |> int64
if hp > int64 0 then System.Console.WriteLine(int64 count + addCount)
else System.Console.WriteLine(count)


Measured memory_bytes: 36288
#include<iostream>
#include<algorithm>
#include<vector>
#define MAX 110000
using namespace std;

vector<int> ay[MAX];
int an,bn,x,y,r;

int D(int t){
	int ret=0;
	while(ret*ret<=r*r-t*t)ret++;
	return ret-1;
}

int main(){
	
	while(cin>>an>>bn>>r&&an+bn){
	for(int i=0;i<MAX;i++){
		ay[i].clear();
	}
	r*=4;
	for(int i=0;i<an;i++){
		cin>>x>>y;
		ay[x].push_back(y);
	}
	for(int i=0;i<an;i++){
		sort(ay[i].begin(),ay[i].end());
	}
	int ans=0;
	while(bn--){
		cin>>x>>y;
		for(int i=max(0,x-r);i<=min(MAX-100,x+r);i++){//??¢?´¢??????????±????x??§?¨?
			ans+=lower_bound(ay[i].begin(),ay[i].end(),y+D(x-i)+1)-lower_bound(ay[i].begin(),ay[i].end(),y-D(x-i));
		}//                 ??? x??§?¨???????y??§?¨??????????????????¢?´¢??????y??§?¨??????????
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 6948
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int f(const string &s){
	if(s[0]=='*')return -1;
	int res=0;
	rep(i,s.size()){
		if(s[i]!='/'){
			res=res*10+s[i]-'0';
		}
	}
	return res;
}

bool contain(const string &s,const string &t){
	rep(i,s.size()){
		if(s.compare(i,t.size(),t)==0)
			return true;
	}
	return false;
}

int main(){
	int n;
	string title[100],auther[100];
	int date[100];
	int q;
	cin>>n;
	rep(i,n){
		string s;
		cin>>title[i]>>auther[i]>>s;
		date[i]=f(s);
	}
	cin>>q;
	rep(i,q){
		if(i)cout<<endl;
		string ti,au,s,t;
		int from,to;
		cin>>ti>>au>>s>>t;
		from=f(s);
		to=f(t);
		rep(j,n){
			if( (ti=="*"||contain(title[j],ti)) && (au=="*"||contain(auther[j],au))
				&& (from<=date[j]) && (to==-1||to>=date[j]) ){
					cout<<title[j]<<endl;
			}
		}
	}
	return 0;
}

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



int main () {
  int x;
  cin>>x;
  for(int a=0;a<1000;a++){
    ll A=1;
    rep(i,5) A*=a;
   for(int b=-1000;b<1000;b++){
     ll B=1;
     rep(i,5) B*=b;
     if(A-B==x){
       printf("%d %d\n",a,b);
       return 0;
     }
     
   }
  }
}

Measured memory_bytes: 3764
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace codeTester.contest190707
{
    class ProblemC
    {
        static List<long> values = new List<long>();
        static long answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            values = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            long L = values[0];
            long R = values[1];
            if (R - L >= 2019)
            {
                answer = 0;
                return;
            }
            long tmpMin = 2018;
            for (long i = L; i < R; i++)
            {
                for (long j = i + 1; j <= R; j++)
                {
                    long tmp = ((i % 2019) * (j % 2019)) % 2019;
                    if (tmp < tmpMin)
                    {
                        DebugPrint(i.ToString() + " * " + j.ToString() + " = " + tmp.ToString());
                        tmpMin = tmp;
                    }
                }
            }
            answer = tmpMin;
        }

        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }

        static void DebugPrint(string msg)
        {
            // 提出時に消す
            // Console.WriteLine(msg);
        }
    }
}


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

int N, A, B;
vector<int> h;

bool enough(int T) {
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    if (h[i] <= B * T) continue;

    int n = h[i] - B * T;
    int d = A - B;
    cnt += n / d;
    if (n % d) cnt++;
  }
  return cnt <= T;
}

main() {
  cin >> N >> A >> B;
  h.resize(N);
  for (int i = 0; i < N; i++) cin >> h[i];
  sort(h.begin(), h.end());

  int l = -1, r = h.back() / B + 1;
  while (r - l > 1) {
    int m = (r + l) / 2;
    ( enough(m) ? r : l ) = m;
  }
  cout << r << endl;
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;


int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll> > v;
    ll a;
    rep(i, n){
        cin >> a;
        v.push_back(make_pair(a, i));
    }
    sort(v.begin(), v.end());

    rep(i, n){
        cout << v[i].second+1 << " ";
    }


    return 0;
}


Measured memory_bytes: 2544
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int leye[]=new int[4];
        int reye[]=new int[4];
        for(int i=0;i<4;i++){
            leye[i]=0;
            reye[i]=0;
        }
        while(sc.hasNext()){
            double l=sc.nextDouble();
            double r=sc.nextDouble();
            if(l>=1.1){
                leye[0]++;
            }else if(l>=0.6){
                leye[1]++;
            }else if(l>=0.2){
                leye[2]++;
            }else{
                leye[3]++;
            }
            if(r>=1.1){
                reye[0]++;
            }else if(r>=0.6){
                reye[1]++;
            }else if(r>=0.2){
                reye[2]++;
            }else{
                reye[3]++;
            }
        }
        for(int i=0;i<4;i++){
            System.out.println(leye[i]+" "+reye[i]);
        }
    }
}


Measured memory_bytes: 28124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int c=0;
  double a=0,b=0,x=0;
  cin >> a;
  cin >> b;
  x = (a + b)/2 + 0.5;
  c = x;
  cout << c << endl;
  
  return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    set<string> st;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        st.insert(s);
    }
    if(st.size()==3)cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
    return 0;
}


Measured memory_bytes: 256
(defmacro defsolver (name vars &body body)
  `(defun ,name ()
     (let (,@(mapcar #'list
		    vars
		    (mapcar (constantly '(read))
			    vars)))
       ,@body)))

(defun f (h w)
  (let ((w1 (ash w -1)))
    (loop for h1 from 1 to (- h 1)
       minimize
	 (let* ((h2 (- h h1))
		(sa (* h1 w))
		(sb (* h2 w1))
		(sc (* h2 (- w w1))))
	   (- (max sa sb sc)
	      (min sa sb sc))))))

(defun g (h w)
  (if (= h 2)
      (- w (ash w -1))
      (loop for h1 from 1 to (- h 2)
	 minimize
	   (let* ((rem (- h h1))
		  (h2 (ash rem -1))
		  (sa (* h1 w))
		  (sb (* h2 w))
		  (sc (* (- h h1 h2) w))
		  (areas (remove-if-not (lambda (x) (> x 0)) (list sa sb sc))))
	     (- (apply #'max areas)
		(apply #'min areas))))))

(defsolver prob-c (h w)
  (cond ((and (= h 2)
	      (= w 2))
	 (format t "1~%"))
	((or (= (mod h 3) 0)
	     (= (mod w 3) 0))
	 (format t "0~%"))
	(t
	 (format t "~a~%" (min (f h w)
			       (f w h)
			       (g h w)
			       (g w h))))))
(prob-c)

Measured memory_bytes: 31080
n=int(input())
for i in range(n):
    a,b,c = input().split()
    x = int(a)
    y = int(b)
    z = int(c)
    p = [x,y,z]
    p.sort()
    if pow(p[0],2) + pow(p[1],2) == pow(p[2],2):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

vector<pair<ll ,ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            num++;
            n /= p; 
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;

ll fac[MAX], finv[MAX], inv[MAX];

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

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

int main() {

    int N, M;
    cin >> N >> M;
    
    COMinit();

    auto vec = prime_factorize(M);
    
    ll res = 1;

    for (auto pa : vec) {
        int num = pa.second;
        ll tmp = COM(num + N - 1, N - 1);
        res = (res * tmp) % MOD;
    }

    cout << res << endl;

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    bool flag = false;
    for( int i = 1; i <= 9; i++)
    {
        for( int j = 1; j <= 9; j++ )
        {
            if( i * j == n ){
                flag = true;
                break;
            }
        }
    }
    if( flag == true ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256