akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1LL<<60
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

struct UF {
	vector<int> v;
	UF(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};


int main() {
	int n; cin >> n;
	vector<pair<int, p_ii>> edge;
	vector<pair<p_ii, int>> p1(n), p2(n);
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		p1[i] = pair<p_ii,int>{ p_ii{a, b}, i };
		p2[i] = pair<p_ii,int>{ p_ii{b, a}, i };
	}
	sort(p1.begin(), p1.end());
	sort(p2.begin(), p2.end());

	for (int i = 0; i < n-1; i++) {//xについての辺
		p_ii p = p1[i].first, q = p1[i + 1].first;
		int tmp = min(abs(p.first - q.first), abs(p.second - q.second));
		edge.push_back(pair<int, p_ii>(tmp, p_ii(p1[i].second, p1[i + 1].second)));
	}

	for (int i = 0; i < n - 1; i++) {//yについての辺
		p_ii p = p2[i].first, q = p2[i + 1].first;
		int tmp = min(abs(p.first - q.first), abs(p.second - q.second));
		edge.push_back(pair<int, p_ii>(tmp, p_ii(p2[i].second, p2[i + 1].second)));
	}

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

	ll ret = 0;
	UF road(n + 2);

	for (int i = 0; i < edge.size(); i++) {
		p_ii p = edge[i].second;
		if (!road.same(p.first, p.second)) {
			road.unite(p.first, p.second);
			ret += (ll)edge[i].first;
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 7284
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans;
  if((a+b) > (c+d)){
    cout << "Left" << '\n';
  } else if((a+b) == (c+d)){
    cout << "Balanced" << '\n';
  } else{
    cout << "Right" << '\n';
  }

return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var K int
	arr := make([]int, 3)
	fmt.Scan(&arr[0], &arr[1], &arr[2], &K)
	for i := 0; i < K; i++ {
		max := 0
		idx := 0
		for j := 0; j < 3; j++ {
			if arr[j] > max {
				max = arr[j]
				idx = j
			}
		}
		arr[idx] *= 2
	}
	r := 0
	for i := 0; i < 3; i++ {
		r += arr[i]
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  int n,m,s,g;
  scanf("%d %d %d %d",&n,&m,&s,&g);
  s--;g--;
  struct edge{
    Int to,a,b,s;
    edge(){}
    edge(Int to,Int a,Int b):to(to),a(a),b(b){
      s=sqrt((double)b)-a;
      if(s<0) s=0;
    }    
  };
  vector<vector<edge> > G(n);
  for(Int i=0;i<m;i++){
    Int u,v,a,b;
    scanf("%lld %lld %lld %lld",&u,&v,&a,&b);
    u--;v--;
    G[u].emplace_back(v,a,b);
    G[v].emplace_back(u,a,b);
  }
  const Int INF = 1e17;
  using P = pair<Int, Int>;
  priority_queue<P, vector<P>, greater<P> > pq;
  vector<Int> dp(n,INF);

  dp[s]=0;
  pq.emplace(dp[s],s);

  while(!pq.empty()){
    Int x,v;
    tie(x,v)=pq.top();pq.pop();
    if(dp[v]<x) continue;
    
    for(auto e:G[v]){
      for(Int k=-1;k<=1;k++){
	Int t=max(e.s+k,dp[v]);
	Int c=t+(e.b+t+e.a-1)/(t+e.a);
	if(dp[e.to]>c){
	  dp[e.to]=c;
	  pq.emplace(dp[e.to],e.to);
	}
      }
    }
  }
  
  if(dp[g]>=INF) dp[g]=-1;  
  printf("%lld\n",dp[g]);
  return 0;
}



Measured memory_bytes: 31952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    for(int i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        x[i] = a - b;
        y[i] = a + b;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    cout << max(x[n-1] - x[0], y[n-1] - y[0]) << endl;
}
    



Measured memory_bytes: 6436
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <bitset>
#include <functional>
#include <set>
#include <map>
#include <array>

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
//#define int long long int
const int MOD = 1000000007;
const int INF = 100100100;
const double EPS = 0.000000001;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool pairCompare(const P& pair1, const P& pair2) {
    return pair1.second > pair2.second;
}
int N, A, B, C;
int l[1000];
int dfs(int i, int a, int b, int c){
  if(i==N) return (min(a,min(b,c))>0) ? abs(a-A)+abs(b-B)+abs(c-C) - 30 : INF;
  int ans0 = dfs(i+1, a, b, c);
  int ans1 = dfs(i+1, a+l[i], b, c)+10;
  int ans2 = dfs(i+1, a, b+l[i], c)+10;
  int ans3 = dfs(i+1, a, b, c+l[i])+10;
  return min(ans0, min(ans1, min(ans2, ans3)));
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> A >> B >> C;
  REP(i, N){
    cin >> l[i];
  }
  cout << dfs(0,0,0,0) << endl;
  return 0;
}


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


// int N = 9;
// int Y = 45000;

int r;

int main() {
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int i,j,k,l,m,n,x,y,r,cnt=0;
    cin>>n;
 for(i=0;i<n;i++){cin>>x;
         cnt+=x;
   }
  cnt=cnt-n;
cout<<cnt<<endl;


}

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

int main() {
    int n;
    scanf("%d", &n);
    if (n == 1) {
        printf("0");
        return 0;
    }
    vector<int> h(n);
    rep(i, n) {
        scanf("%d", &h[i]);
    }
    int max = 0;
    int kari_max = 0;
    rep(i, n - 1) {
        if (h[i + 1] <= h[i]) {
            kari_max++;
        } else {
            if (kari_max > max) {
                max = kari_max;
            }
            kari_max = 0;
        }
    }
    if (kari_max > max) {
        max = kari_max;
    }
    printf("%d", max);
    return 0;
}

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


int main() {
	int a, b;
	cin >> a >> b;
	if (500 * a >= b)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;

ll gcd(ll a,ll b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(void){
    ll n,p;
    ll ans = 0;
    cin >> n >> p;
    for(int i=1;i<sqrt(p)+1;i++){
        if(p%i==0){
            ll x =  pow(i,n);
            if(p%x==0){
                if(i>ans){
                ans = i;
            }
            }
        }
    }
    if(n == 1){
        ans = p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int64_t N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int64_t p=1000000007;
  int64_t sum=0;
  int64_t cnt=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(A[i]>A[j]){cnt++;}
    }
  }
  sum+=(cnt*K%p);
  cnt=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A[i]>A[j]){cnt++;}
    }
  }
  sum+=cnt%p*(K*(K-1)/2%p);//割り算のMODは途中でMODしてはいけない
  cout<<sum%p<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
vector<i64> l, r, im;
int main() {
  cin >> n >> m;
  init_n(l, n + 1);
  init_n(r, n + 1);
  init_n(im, n + 2);

  for (i64 i = 0; i < m; ++i) {
    i64 l, r; cin >> l >> r;
    im[l]++;
    im[r + 1]--;
  }
  i64 ans = 0;
  for (i64 i = 1; i <= n; ++i) {
    im[i] += im[i - 1];
    if (im[i] == m) ++ans;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2688
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define inf 1000000000
#define Inf 223372036854775807
#define maxn 20100
using namespace std;
typedef long long ll;
const ll mod=998244353;
const long double eps=1e-9;
const long double PI=acos(-1.0);

int num[4];

int main()
{
    cin>>num[1]>>num[2]>>num[3];
    sort(num+1, num+4);
    if (num[1]==num[2] && num[2]!=num[3])
    {
        cout<<"Yes";
        return 0;
    }
    if (num[3]==num[2] && num[1]!=num[3])
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
use std::collections::HashSet;
use std::borrow::Borrow;
use std::ops::IndexMut;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let n = v[0];
    let k = v[1];
    let q = v[2];

    let mut s: Vec<i32> = Vec::new();

    for _ in 0..n {
        s.push(k);
    }

    for _ in 0..q {
        let a: i32 = read();
        let i: usize = (a - 1) as usize;

        let t = &mut s[i];
        *t += 1;
    }

    for i in 0..n {
        let i = i as usize;
        let mut t = s.get(i).unwrap().borrow() - q;

        if t > 0 {
            println!("Yes")
        } else {
            println!("No")
        }
    }
}


Measured memory_bytes: 4732
#include <stdio.h>
#include <stdlib.h>

int compar(const int *val1, const int *val2);

int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  int a[n];
  int b[n];
  for(int i=0; i<n; i++){
    b[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }

  qsort(a,n,sizeof(int),(int (*)(const void *, const void *))compar);

  int count = 0, num = 0;
  b[0] = 1;
  for(int i = 1; i < n; ++i){
    if(a[i] != a[i-1]) count++;
    b[count] +=	1;
  }

  qsort(b,n,sizeof(int),(int (*)(const void *, const void *))compar);
  for(int i = k; i < n; ++i){
    num += b[i];
    if(b[i] == 0) break;
  }

  printf("%d",num);
  return 0;
}
/*比較関数*/
int compar(const int *val1, const int *val2) {
    if ( *val1 > *val2 ) {
	return -1;
    } else if ( *val1 == * val2 ) {
	return 0;
    } else {
        return 1;
    }
}



Measured memory_bytes: 2556
#include<iostream>
#include<vector>
using namespace std;
vector<int64_t> prod_permutation(vector<int64_t> v, vector<int64_t> w) {//v○wの計算(先にwで置換、その後vで置換)
	if (v.size() != w.size()) {
		cout << "error" << endl;
		return v;
	}
	else {
		vector<int64_t> ret;
		for (int i = 0; i<v.size(); i++) {
			ret.push_back(v[w[i]]);
		}
		return ret;
	}
}
vector<int64_t> pow_permutation(vector<int64_t> v, int64_t N) {//置換vをN乗した結果を返す。
	if (N % 2 == 0) {
		if (N == 0) {
			vector<int64_t> ret;
			for (int i = 0; i<v.size(); i++) {
				ret.push_back(i);
			}
			return ret;
		}
		else {
			vector<int64_t> ret = pow_permutation(v, N / 2);
			return prod_permutation(ret, ret);
		}
	}
	else {
		if (N == 1) {
			return v;
		}
		else {
			vector<int64_t> ret = pow_permutation(v, (N - 1) / 2);
			return prod_permutation(prod_permutation(v, ret), ret);
		}
	}
}
int main() {
	int64_t N;
	int64_t x[100000];
	int64_t M;
	int64_t K;
	int64_t a[100000];
	cin >> N;
	int64_t dx[100000];
	for (int i = 0; i<N; i++) {
		cin >> x[i];
		if (i != 0) {
			dx[i - 1] = x[i] - x[i - 1];
		}
	}
	cin >> M >> K;
	for (int i = 0; i<M; i++) {
		cin >> a[i];
	}
	vector<int64_t> v;
	for (int i = 0; i<N - 1; i++) {
		v.push_back(i);
	}
	for (int i = 0; i<M; i++) {
		int64_t tmp = v[a[i] - 2];
		v[a[i] - 2] = v[a[i] - 1];
		v[a[i] - 1] = tmp;
	}
	vector<int64_t> ret = pow_permutation(v, K);
	//int64_t dx_permu[100000];
	//for (int i = 0; i<N - 1; i++) {
	//	dx_permu[ret[i]] = dx[i];
	//}
	int64_t ans = x[0];
	for (int i = 0; i<N - 1; i++) {
		cout << ans << endl;
		//ans += dx_permu[i];
		ans += dx[ret[i]];
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt=0;
        for(int i=0; i<n-2; i++){
    if(s.at(i)=='A' && s.at(i+1)=='B'&& s.at(i+2)=='C')
    cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	arr := strings.Split(s.Text(), " ")
	stack := []int{}
	for _, s := range arr {
		if s == "+" || s == "-" || s == "*" {
			n1 := stack[len(stack)-2]
			n2 := stack[len(stack)-1]
			stack = stack[:len(stack)-2]
			switch s {
			case "+":
				stack = append(stack, n1 + n2)
			case "-":
				stack = append(stack, n1 - n2)
			case "*":
				stack = append(stack, n1 * n2)
			}
		} else {
			n, _ := strconv.Atoi(s)
			stack = append(stack, n)
		}
	}
	fmt.Println(stack[0])
}



Measured memory_bytes: 1136
export class Main {
  static main(input): string {
    const [a, b, c]: number[] = input.split(" ").map(Number);
    const times: number = Math.floor(b / a);
    return `${times < c ? times : c}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

int e[201][201];

int N, M, R;

signed main()
{
    cin >> N >> M >> R;

    vector<int> r;
    REP(i, R)
    {
        int a;
        cin >> a;
        r.push_back(a);
    }

    REPS(i,N) REPS(j,N) e[i][j] = i==j ? 0 : INF;
    REP(i, M)
    {
        int from, to, cost;
        cin >> from >> to >> cost;
        e[from][to] = cost;
        e[to][from] = cost;
    }

    REPS(k, N) REPS(i, N) REPS(j, N)
        e[i][j] = min(e[i][j], e[i][k] + e[k][j]);

    sort(r.begin(), r.end());
    int ans = INF;
    do
    {
        int tmp = 0;
        for (int i = 0; i < R-1; ++i)
        {
            tmp += e[r[i]][r[i+1]];
        }
        ans = min(ans, tmp);
    }
    while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans = 1000;
  int z = N%3;
  if(N < 6){
    cout << N << endl;
  }
  else{
    N = N - N %3;
    for(int a=0; a<6; a++){
      for(int b=0; b<6; b++){
        for(int c=0; c<6; c++){
          for(int d=0; d<6; d++){
            for(int e=0; e<6; e++){
              for(int x=0; x<3; x++){
              for(int f=0; f<9; f++){
                for(int g=0; g<9; g++){
                  for(int h=0; h<9; h++){
                    for(int i=0; i<9; i++){
                      for(int j=0; j<2; j++){
                        if(a*6+b*36+c*216+d*1296+e*7776+x*46656+f*9+g*81+h*729+i*6561+j*59049 == N){
                          ans = min(ans, a+b+c+d+e+f+g+h+i+j+x);
                        }
                      }
                    }
                  }
                }
              }
              }
            }
          }
        }
      }
    }
  cout << ans + z<< endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,st,sr;
    int i;
    cin>>s>>st;
    for (i=st.length()-1;i>=0;i--)
    sr+=st[i];
    if (sr==s) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

void MOD(vector<bool> &mod) {
	int n = 1000000005;
	for (int i = 0;i < 30;i++) {
		if (n % 2==1)
			mod[i] = true;
		else
			mod[i] = false;
		n /= 2;
	}
}

long long rev(long long n,vector<bool> mod) {
	//~10e9+5
	vector <long long> da(30,n);
	long long ans=1;
	if (mod[0])
		ans = n;
	for (int i = 1;i < 30;i++) {
		da[i] = (long long)(da[i - 1] * da[i - 1]) % 1000000007;
		if (mod[i])
			ans = (ans * da[i]) % 1000000007;
	}
	return ans;
}

long long kaijo(long long n) {
	long long ans = 1;
	for (int i = 1;i < n + 1;i++)
		ans = (ans*i) % 1000000007;
	return ans;
}

long long COMB(long long n, long long k,vector<bool> mod) {
	long long ans = (rev(kaijo(k),mod)*rev(kaijo(n - k),mod)) % 1000000007;
	return (kaijo(n)*ans) % 1000000007;
}

int main() {
	long long n, m, k;
	cin >> n >> m >> k;
	vector<bool> mod(30);
	MOD(mod);
	long long ans = 0;
	//n*m-2Ck-2*m*m*(n-i)
	long long pat = (m*m) % 1000000007;
	long long comb = COMB(n*m - 2, k - 2,mod);
	//cout << comb << endl;
	for (int i = 1;i < n;i++) {
		long long x = ((n - i)*pat) % 1000000007;
		x = (x*comb) % 1000000007;
		x = (x*i) % 1000000007;
		//cout << x << endl;
		ans = (ans + x) % 1000000007;
		//cout << ans << endl;
		if (ans < 0) {
			cout << i << endl;
			return 0;
		}
	}
	//cout << ans << endl;
	pat = (n*n) % 1000000007;
	for (int i = 1;i < m;i++) {
		long long x = ((m - i)*pat) % 1000000007;
		x = (x*comb) % 1000000007;
		x = (x*i) % 1000000007;
		ans = (ans + x) % 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int paint[3];
	for (int i = 0; i < 3; ++i) {
		cin >> paint[i];
	}
	sort(paint, paint + 3);
	if (paint[0] == paint[2]) {
		cout << 1 << endl;
	}
	else if (paint[0] == paint[1] || paint[1] == paint[2]) {
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
//#include<ext/rope>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
const double PI=acos(-1.0);
const double eps=1e-6;
ll a[100005];
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        sort(a+1,a+1+n);
        ll s=1;
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                s=0;
                break;
            }
            else if(s>INFL/a[i] ||a[i]>INFL/s){
                cout<<-1<<endl;
                return 0;
            }
            else s=s*a[i];
        }
        if(s<0 || s>1000000000000000000) s=-1;
        cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 4420
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

char a[100005];
int b[100005], c[100005];
int main()
{
	scanf("%s", a + 1);
	int len = strlen(a + 1);
	string s = "";
	for(int i = 1; i <= len; i++){
		if(a[i] != 'x'){
			s += (char)a[i];
		}
	}
	int n = s.size();
	bool ok = 1;
	for (int i = 0; i <= (n - 1) / 2; i++) if(s[i] != s[n - i - 1]) ok = 0;
	if(!ok) printf("-1\n");
	else {
		int ans = 0;
		int l = 1, r = len;
		while(l <= r) {
			if(a[l] == 'x') {
				while(a[l] != a[r]) l++, ans++;
			}
			else if(a[r] == 'x') {
				while(a[l] != a[r]) r--, ans++;
			}
			l++, r--;
		}
		printf("%d\n", ans);
	}
}

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


Measured memory_bytes: 2632
#include <stdio.h>
#define NUMBER 100

int main(void){
        int n, i;
        int x[NUMBER];
        scanf("%d", &n);
        for(i=0;i<n;i++)
                scanf("%d", &x[i]);
        for(i=n-1;i>=0;i--){
                if(i!=n-1)
                        printf(" ");
                printf("%d", x[i]);
        }
        putchar('\n');
        return 0;
}

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

#define LL long long
int h, w, d, a, x[100005], y[100005], l, r, q, dis[100005];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    cin >> h >> w >> d;
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++) {
            cin >> a;
            x[a] = i, y[a] = j;
        }

    for(int i = d + 1; i <= h * w; i++) dis[i] = dis[i-d] + abs(x[i] - x[i-d]) + abs(y[i] - y[i-d]);

    cin >> q;
    while(q--) {
        cin >> l >> r;
        cout << dis[r] - dis[l] << '\n';
    }        
}

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

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++){
        if (n%i == 0 && n/i < 10 && n/i > 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long H,W,h,w,sum=0;
  cin >> H >> W >> h >> w;
  int ans[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans[i][j]=1000;
      sum+=1000;
    }
  }
  for(int i=h-1;i<H;i+=h){
    for(int j=w-1;j<W;j+=w){
      ans[i][j]=-(h*w-1)*1000-1;
      sum-=1000;
      sum+=ans[i][j];
    }
  }
  if(sum<=0){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << ans[i][j] << ((j==W-1)?'\n':' ');
    }
  }
  return 0;
}

Measured memory_bytes: 2560
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)					// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl << msec << " msec " << endl;
}

#endif

class DPA
{
public:
	DPA()
	{
		cin >> n;
		h.resize(n);
		rep(i, 0, n)
			cin >> h[i];
	}
	void Run(void)
	{
		vector<ll> dp(n);
		dp[0] = 0;
		dp[1] = abs(h[1] - h[0]);
		rep(i, 2, n)
			dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));

		cout << dp[n - 1];
	}
private:
	ll n;
	vector<ll> h;
};

int main(void)
{
	DPA dpa;
	dpa.Run();

	return 0;
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max(a*c, max(a*d, max(b*c, b*d)));
  cout << ans << endl;
}


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

int n, t, mi, dis = -1, cnt = 0;
vector<int> a;
map<int, int> mp;

int main() {
  cin >> n >> t;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  mi = a[0];
  for(int i = 0; i < n; ++i) {
    int now = a[i];
    if(now > mi) dis = max(dis, now - mi);
    mi = min(mi, now);
  }
  for(int i = 0; i < n; ++i) {
    int now = a[i];
    if(mp.find(now - dis) != mp.end()) ++cnt;
    ++mp[now];
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 5368
import sys

S = input()
def judge_S(S):
    sliced_S = S[2:-1]
    if S[0] != "A":
        return "WA"
    else:
        S = S[1:]
    if sliced_S.count("C") != 1:
        return "WA"
    else:
        S = S.replace("C", "")
    if not S.islower():
        return "WA"

    return "AC"


print(judge_S(S))

Measured memory_bytes: 3060
def main():
    s = input()
    x,y = map(int,input().split())

    x1 = []
    y1 = []
    cnt = 0
    cnt2 = 0

    for i in range(len(s)):
        s1 = s[i]
        if s1 == 'F':
            cnt += 1
        else:
            if cnt2 == 0:
                x -= cnt
            elif cnt2 % 2 == 0:
                x1.append(cnt)
            else:
                y1.append(cnt)
            cnt = 0
            cnt2 += 1

    if cnt2 == 0:
        x -= cnt

    if cnt > 0 and cnt2 > 0:
        if cnt2 % 2 == 0:
            x1.append(cnt)
        else:
            y1.append(cnt)

    if len(x1) == 0 and len(y1) == 0 and x == 0 and y == 0:
        print('Yes')
        exit()

    if sum(x1) < abs(x) or sum(y1) < abs(y):
        print('No')
        exit()

    dp1 = [[False] * (sum(x1)+1)*2 for _ in range((len(x1)+1))]
    dp2 = [[False] * (sum(y1)+1)*2 for _ in range((len(y1)+1))]
    dp1[0][sum(x1)+1] = True
    dp2[0][sum(y1)+1] = True

    for i in range(len(x1)):
        for j in range((sum(x1)+1)*2):
            if dp1[i][j]:
                dp1[i+1][j+x1[i]] = True
                dp1[i+1][j-x1[i]] = True

    for i in range(len(y1)):
        for j in range((sum(y1)+1)*2):
            if dp2[i][j]:
                dp2[i+1][j+y1[i]] = True
                dp2[i+1][j-y1[i]] = True

    if dp1[-1][sum(x1)+1+x] and dp2[-1][sum(y1)+1+y]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 164572
a,b,c,d=map(int,input().split())

# ==================== gcd   最大公約数
from fractions import gcd
#from math import gcd

a1=a-1
bn=b-(b//c+b//d-b//(c*d//gcd(c,d)))
an=a1-(a1//c+a1//d-a1//(c*d//gcd(c,d)))

print(bn-an)


Measured memory_bytes: 5304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    vector <int>c;
    for(int i=0;i<3;i++){int m;cin>>m;c.push_back(m);}
    sort(c.begin(),c.end());
    cout<<c[2]*10+c[1]+c[0]<<endl;
}


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

int main() {

	string S;
	long long K;
	cin >> K >> S;


	if (S.size() <= K) {
		cout << S << endl;
	}

	else {
		for (int i = 0; i < K; i++) {
			cout << S[i] ;
		}
		cout << "..." << endl;
	}

}


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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);


void calculate(){
    int N;
    input(N);
    std::vector<int> A(N);
    inputVector(A);
    bool flag = true;
    for(auto i : A)
    {
        if(i % 2 == 0 and (i % 3 != 0 and i % 5 != 0))
        {
            flag = false;
        }
    }
    std::cout << (flag ? "APPROVED\n" : "DENIED\n");
}

int main(int,char**){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    calculate();
}



void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

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

int main(){
	int n,q;
	string s;
	cin >> n >> s >> q;
	vector<set<int>> S(26);
	rep(i,n){
		S[s[i]-'a'].insert(i);
	}
	rep(iq,q){
		int q; cin >> q;
		if(q == 1){
			int i;
			char c;
			cin >> i >> c;
			i--;
			S[s[i] - 'a'].erase(i);
			s[i] = c;
			S[s[i] - 'a'].insert(i);
		} else if (q == 2){
			int l,r;
			cin >> l >> r;
			l--;r--;
			int ans = 0;
			rep(j,26){
				auto itr = S[j].lower_bound(l);
				if(itr != S[j].end() && *itr <= r) ans++;
			}
			cout << ans << endl;
		}
	}
    return 0;
}



Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 998244353;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll dp[3100][3100][3] = {0};

int main(){
    int n, s;
    cin >> n >> s;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= s; j++) {
            for(int k = 0; k < 3; k++) {
                for(int l = 0; l <= k; l++) {
                    (dp[i+1][j][k] += dp[i][j][l]) %= MOD;
                }
                dp[i+1][j][k] %= MOD;
            }

            if(j - a[i] >= 0) {
                if(j == a[i]) (dp[i+1][j][1] += dp[i][0][0]) %= MOD, (dp[i+1][j][2] += dp[i][0][0]) %= MOD;
                (dp[i+1][j][1] += dp[i][j-a[i]][1]) %= MOD;
                (dp[i+1][j][2] += dp[i][j-a[i]][1]) %= MOD;
            }
        }
    }
    cout << dp[n][s][2] << endl;
}


Measured memory_bytes: 219264
#include <bits/stdc++.h>
#include <vector>
using namespace std;
typedef long long ll;
int N, M;
vector <int> edges[55];
int par[55];
int depth[55];
int ancestor[55][55];
int vertexA[55];
int vertexB[55];
int prefix[55];

void dfs(int v, int p, int d){
    par[v] = p;
    depth[v] = d;
    for (int e: edges[v]){
        if (e != p) dfs(e, v, d+1);
    }
}

int dfsCount(int v, int p){
    int ans = 0;
    int subtreeSum = 0;
    for (int e: edges[v]){
        if (e != p) {
            ans += dfsCount(e, v);
            if (prefix[e] > 0) ans++;
            prefix[v] += prefix[e];
        }
    }
    //cout << v << " " << subtreeSum << endl;
    return ans;
}

int lca(int u, int v){
    if (depth[u] < depth[v]) swap(u,v);
    while (depth[u] > depth[v]){
        u = par[u];
    }
    while (u != v){
        u = par[u];
        v = par[v];
    }
    return u;
}

void update(int v, int anc){
    //cout << v << " b " << anc << endl;
    prefix[v]++;
    prefix[anc]--;
}

int bitCount(ll msk){
    int tot = 0;
    for (ll i=0; i<64; i++) {
        if (msk & (1LL << i)) tot++;
    }
    return tot;
}

int main() {
    cin >> N;
    int a, b;
    for (int i=0; i<N-1; i++){
        scanf("%d %d", &a, &b);
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    dfs(0,0,0);
    cin >> M;
    for (int i=0; i<M; i++){
        scanf("%d %d", &a, &b);
        vertexA[i] = a-1;
        vertexB[i] = b-1;
        ancestor[b-1][a-1] = ancestor[a-1][b-1] = lca(a-1,b-1);
    }
    ll ans = 0;
    for (ll msk = 0; msk < (1LL<<M); msk++){
        memset(prefix, 0, sizeof(prefix));
        for (ll i = 0; i < M; i++) {
            if ((msk & (1LL<<i)) == 0) continue;
            update(vertexA[i], ancestor[vertexA[i]][vertexB[i]]);
            update(vertexB[i], ancestor[vertexA[i]][vertexB[i]]);
        }
        int val = dfsCount(0,0);
        //cout << val << endl;
        ans += (1LL << (N - 1 - val)) * ((bitCount(msk) % 2 == 0) ? 1 : -1);
        //cout << msk << " a " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  bool state = true;
  string S;
  cin >> S;

  if(S.at(2) != S.at(3) || S.at(4) != S.at(5)){
    state = false;
  }
  /*
  if(S.size() != 6){
    state = false;
  }
  */
  if(state){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

ll mind(int x,vector<int> &v){
  int ok = v.size()-1,ng = -1;
  while(ok - ng > 1){
    int next = (ok+ng)/2;
    if(v[next] > x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

ll maxd(int x,vector<int> &v){
  int ok = 0,ng = v.size();
  while(ng - ok > 1){
    int next = (ok+ng)/2;
    if(v[next] < x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}


int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N)cin >> A[i];
  for(int i = K+1;i <= N;i++){
    if(A[i-1] > A[i-K-1]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 4844
N = int(input())
A = list(map(int, input().split()))
b = sum(A[::2]) - sum(A[1::2]) - A[-1]

M = [0] * N
M[0], M[-1] = A[-1] + b, A[-1] - b 

for i in range(1, len(M) - 1):
    M[i] = 2 * A[i - 1] - M[i - 1]

print(*M)

Measured memory_bytes: 64868
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b;
    cin >> a >> b;

    a += b;
    if (a >= 10) puts("error");
    else cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

void solve( long L, long R ) {
    long ans = 2018;
    if ( R - L + 1 >= 2019 ) {
        std::cout << 0 << std::endl;
        return;
    }
    for (long i=L; i<=R-1; ++i) {
        for (long j=i+1; j<=R; ++j) {
            long tmp = ( i * j ) % 2019;
            ans = std::min( ans, tmp );
        }
    }
    std::cout << ans << std::endl;
}

int main() {
    long L, R;
    std::cin >> L >> R;

    solve( L, R );
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int a, b;
  scanf("%d %d", &a, &b);

  if(a == 1) a = 14;
  if(b == 1) b = 14;

  if(a < b) printf("Bob\n");
  else if(a > b) printf("Alice\n");
  else printf("Draw\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

LL getRange(vector<LL>& a, LL v, LL m){
    vector<LL> cum(a.size()+1);
    for(LL i = 0; i < a.size(); ++i){
        cum[i+1] = cum[i] + a[i];
    }
    LL score = 0;
    LL right_cnt = 0;
    LL equal_cnt = 0;
    for(LL i = 0; i < a.size(); ++i){
        LL left = lower_bound(a.begin(), a.end(), v-a[i]) - a.begin();
        LL right = upper_bound(a.begin(), a.end(), v-a[i]) - a.begin();
        equal_cnt += right - left;
        score += cum[right] + a[i] * right;
        right_cnt += right;
        //cerr << "right=" << right << ",score=" << cum[right] << ", " << a[i] << endl;
    }
    LL rest = a.size() * a.size() - right_cnt;
    //cerr << "n=" << a.size() << ", rest=" << rest << ", score=" << score <<", cum=" << cum[a.size()]<< endl;
    if(rest > m) return -1;
    LL rest_score = cum[a.size()]*a.size()*2 - score;
    return rest_score + v * min(equal_cnt, m - rest);
}


int main(){
    LL n, m;
    cin >> n >> m;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    LL right = 0;
    LL left = a[n-1] + a[n-1] + 1;
    LL ans = 0;
    while(left - 1 > right){
        LL middle = (left + right) / 2;
        LL score = getRange(a, middle, m);
        if(score >= 0){
            ans = max(ans, score);
            left = middle;
        }else{
            right = middle;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4852
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int X,N;
  cin >> X >> N;
  vector<bool> f(110,false);
  int p;
  int i;
  for(i=0;i<N;i++) {
    cin >> p;
    f[p] = true;
  }
  i=0;
  while(true) {
    if(i%2 == 0) {
      if(X+i/2<105?!f[X+i/2]:false) {
        cout << X+i/2 << endl;
        return 0;
      }
    }
    else {
      if(X-(i+1)/2>=0?!f[X-(i+1)/2]:false) {
        cout << X-(i+1)/2 << endl;
        return 0;
      }
    }
    i++;
  }
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    int k; cin >> k;
    int d; cin >> d;
    for(int i = n; i <= k; i++)
    {
        if(i % d == 0)
            result++;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3596
s = input()
n = list(s)
l = len(s)
check = 0

if l%2 == 1:
    for i in range(0,l-1):
        if n[i] != n[l-(i+1)]:
            check =1
            break
    for i in range(0,int((l-1)/2)-1):
        if n[i] != n[int(((l-1)/2)-(i+1))]:
            check =1
            break
    for i in range(0,int((l-1)/2)-1):
        if n[int((l-1)/2)+1+i] != n[(l-1-i)]:
            check=1
            break
    if check ==0:
        print('Yes')
    else:
        print('No')
else:
    print ('No')

Measured memory_bytes: 3064
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
mod=10**9+7
def factorial(x): #階乗計算
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): #約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): #素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n,m = map(int,input().split())
    p=[0 for _ in range(n)]
    box=[1 for _ in range(n)]
    p[0]=1
    for _ in range(m):
        a,b=map(int,input().split())
        if p[a-1]==1 and box[a-1]==1:
            p[b-1]=1
            p[a-1]=0
            box[a-1]-=1
            box[b-1]+=1
        elif p[a-1]==1 and box[a-1]!=1:
            p[b-1]=1
            p[a-1]=1
            box[a-1]-=1
            box[b-1]+=1
        else:
            box[a-1]-=1
            box[b-1]+=1
    print(sum(p))
main()

Measured memory_bytes: 48560
/* ALDS1_5_B: Merge Sort */

#include <iostream>
#include <climits>

int n_compared = 0;

void merge(int A[], int left, int mid, int right) {
    int n_left  = mid - left;
    int n_right = right - mid;
    int L[n_left], R[n_right];

    for (int i = 0; i < n_left; i++)
        L[i] = A[left + i];
    for (int i = 0; i < n_right; i++)
        R[i] = A[mid + i];
    L[n_left] = R[n_right] = INT_MAX;

    int i_l = 0, i_r = 0;
    for (int i_a = left; i_a < right; i_a++) {
        A[i_a] = ( L[i_l] <= R[i_r] ) ? L[ i_l++ ] : R[ i_r++ ];
        n_compared++;
    }
}

void merge_sort(int A[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);  // left to mid - 1
        merge_sort(A, mid, right); // mid to right - 1
        merge(A, left, mid, right);
    }
}

int main() {
    std::ios::sync_with_stdio(false);

    int n = 0;
    std::cin >> n;

    int A[n];
    for (int i = 0; i < n; i++)
        std::cin >> A[i];

    merge_sort(A, 0, n);

    std::cout << A[0];
    for (int i = 1; i < n; i++)
        std::cout << " " << A[i];
    std::cout << std::endl;
    std::cout << n_compared << std::endl;

    return 0;
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<n/(a+b)*a+min(n%(a+b),a)<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  map <string, int> tmp;
  queue <int> q;
  for (int i = 0; i < n; i++) {
    string str;
    int min;
    cin >> str >> min;
    tmp[str] = i;
    q.push(min);
  }
  
  string x;
  cin >> x;
  
  for (int i = 0; i <= tmp.at(x); i++) {
    q.pop();
  }
  
  int ans = 0;
  while (!q.empty()) {
    ans += q.front();
    q.pop();
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256