akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    int n;
    cin>>n;
    vector<int> vec;
    rep(i,(int)n){
        int a;
        cin>>a;
        vec.push_back(a);
    }
    SORT(vec);
    vec.erase(unique(vec.begin(),vec.end()),vec.end());

    if((int)vec.size()<n){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
 
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
#include<string>
#define int long long
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
    int n,m;
    cin>>n>>m;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;++i) cin>>arr[i],sum+=arr[i];
    sort(arr,arr+n,greater<int>());
    //int sum=0;
    int cnt=0;
    for(int i=0;i<n;++i)
    {
        if(arr[i]>=((double)1/(4*m))*sum) cnt++;
    }
    if(cnt>=m) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
}


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--) solve();

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int n, t;
int x, mx, mn, cnt;

int main(){
	scanf("%d%d", &n, &t);
	mn = 1e9;
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		if(x - mn > mx){
			mx = x - mn, cnt = 1;
		}else if(x - mn == mx) cnt++;
		mn = min(mn, x);
	}
	printf("%d", cnt);
}

Measured memory_bytes: 3792
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

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

void Calc() {
  int n, a, b;
  in, n, a, b;

  string s = in;

  int cnt = 0;
  int cnt2 = 0;
  rep(i, size(s)) {
    if (s[i] == 'a') {
      if (cnt < a + b) {
        cnt++;
        cout << ("Yes") << endl;
      } else {
        cout << ("No") << endl;
      }
    } else if (s[i] == 'b') {
      if (cnt < a + b && cnt2 < b) {
        cnt++;
        cnt2++;
        cout << ("Yes") << endl;
      } else {
        cout << ("No") << endl;
      }
    } else {
      cout << ("No") << endl;
    }
  }
}


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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, w;
  std::cin >> n >> w;

  std::vector<std::vector<int64_t>> v(4, std::vector<int64_t>());
  for (auto &i : v) {
    i.reserve(n);
  }

  int64_t w1, v1;
  std::cin >> w1 >> v1;

  v[0].push_back(v1);

  for (int64_t i = 1; i < n; i++) {
    int64_t w_i, v_i;
    std::cin >> w_i >> v_i;
    v[w_i - w1].push_back(v_i);
  }

  for (auto &i : v) {
    std::sort(i.begin(), i.end(), std::greater<int64_t>());
    i.insert(i.begin(), 0);
    for (int64_t j = 1; j < i.size(); j++) {
      i[j] += i[j - 1];
    }
  }

  int64_t ans = 0;

  for (int64_t i = 0; i < v[0].size(); i++) {
    for (int64_t j = 0; j < v[1].size(); j++) {
      for (int64_t k = 0; k < v[2].size(); k++) {
        for (int64_t l = 0; l < v[3].size(); l++) {
          const auto weight = w1 * i + (w1 + 1) * j + (w1 + 2) * k
            + (w1 + 3) * l;
          if (w < weight) {
            break;
          } else {
            ans = std::max(ans, v[0][i] + v[1][j] + v[2][k] + v[3][l]);
          }
        }
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

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

    string s;
    cin >> s;
    
    if (s[1] == 'B')
        s[1] = 'R';
    else
        s[1] = 'B';
    
    cout << s << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 3604
n, m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**n): #スイッチの状態
    cnt = 0
    for j in range(m): #電球の状態
        s_on = 0
        for k in range(s[j][0]):
            s_on += (i >> (s[j][k+1]-1) & 1)
        if s_on % 2 == p[j]:
            cnt += 1
    if cnt == m:
        ans += 1

print(ans)

Measured memory_bytes: 73776
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    int k = scan.nextInt();
    ArrayList<Long> a = new ArrayList<Long>();
    ArrayList<Long> b = new ArrayList<Long>();
    for (int i=0;i<n;i++){
      long g = scan.nextLong();
      if (g == 0){
        k -= 1;
      }
      if (g < 0){
        g = -g;
        a.add(g);
      }
      else if (g > 0){
        b.add(g);
      }
    }

    if (k <= 0){
      System.out.println(0);
      return;
    }

    int a1 = a.size();
    int b1 = b.size();

    long[] c = new long[a1+1];
    long[] d = new long[b1+1];

    for(int j=0;j<b1;j++){
      d[j+1] = b.get(j);
    }

    for(int k1=0;k1<a1;k1++){
      c[k1+1] = a.get(a1-k1-1);
    }

    long sum = 0;

    if (a1>=k){
      sum = c[k];
      for (int p=1;p<b1;p++){
        if (p > k){
          break;
        }
        long current = 0;
        if (c[k-p] >= d[p]){
          current += d[p];
        }
        else{
          current += c[k-p];
        }
        current += (c[k-p] + d[p]);

        if (sum > current){
          sum = current;
        }
      }
    }
    else{
      if (c[a1] < d[k-a1]){
        sum += c[a1];
      }
      else{
        sum += d[k-a1];
      }
      sum += c[a1]+d[k-a1];
      for (int p=1;k-a1+p<b1;p++){
        if (k-a1+p > k){
          break;
        }
        long current = 0;
        if (p == a1){
          current = d[k];
          if (sum > current){
            sum = current;
          }
          break;
        }

        if (c[a1-p] >= d[k-a1+p]){
          current += d[k-a1+p];
        }
        else{
          current += c[a1-p];
        }
        current += c[a1-p] + d[k-a1+p];
        if (sum > current){
          sum = current;
        }
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 60656
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

template<ll p, ll b>
struct FastRollingHash{
  vector<ll> h;
  vector<ll> e;
  ll n, m;
  ll mod(ll x){
    x = (x & m) + (x >> p);
    return (x >= m) ? (x - m) : x;
  }
  void init(const string &s){
    n = s.length();
    m = (1LL << p) - 1;
    h = vector<ll>(n+1, 0);
    e = vector<ll>(n+1, 1);
    for(int i = 0; i < n; i++){
      h[i+1] = mod(mod(h[i]*b)+s[i]);
      e[i+1] = mod(e[i]*b);
    }
  }
  FastRollingHash(){}
  FastRollingHash(const string &s){
    init(s);
  }
  ll get(int s, int t){
    ll res = h[t] - mod(h[s]*e[t-s]);
    return (res < 0) ? (res + m) : res;
  }
};

int n;
string s[310];
string t[610];

FastRollingHash<31, 31> rhs[310];
FastRollingHash<31, 31> rht[310];

int main(){

  n = in();
  REP(i, n){
    s[i] = stin();
    t[i] = s[i];
    s[i] += s[i];
  }

  REP(i, n){
    REP(j, n){
      if(i < j){
        swap(t[i][j], t[j][i]);
      }
    }
  }
  REP(i, n){
    t[i] += t[i];
  }
  
  REP(i, n){
    rhs[i].init(s[i]);
    rht[i].init(t[i]);
  }

  ll ans = 0;
  REP(i, n){
    REP(j, n){
      bool ok = true;
      REP(k, n){
        int si = (i+k)%n;
        int tj = (j+k)%n;
        if(rhs[si].get(j, j+n) != rht[tj].get(i, i+n)){
          ok = false;
          break;
        }
      }
      if(ok){
        ans++;
      }
    }
  }

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


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <numeric>
#include <limits>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
using ll = long long;

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

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

int main() {
	ll n, t[100], ans = 1;
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::cin >> t[i];
		ans = lcm(ans, t[i]);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto &__VA_ARGS__:(c))
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,M;
	cin>>N>>M;
	vector<int> a(N);
	fore(a,i) cin>>i;

	fore(a,i) if (i%2==1) {
		cout<<0<<'\n';
		return 0;
	}

	sort(a.begin(),a.end());
	a.erase(unique(a.begin(),a.end()),a.end());

	int max=a.back();
	a.pop_back();
	int res=0;
	for (int X=max/2; X<=M; X+=max) {
		bool ok=true;
		fore(a,i) if ((X-i/2)%i!=0) {
			ok=false;
			break;
		}
		if (ok) res++;
	}
	cout<<res<<'\n';
}


Measured memory_bytes: 640
class Dice
  attr_accessor :v, :h
  def initialize(pips)
    pips = pips.split.map(&:to_i)
    @v = [pips[0], pips[1], pips[5]]
    @h = [pips[3], pips[2], pips[4]]
  end

  def rotate(dir)
    tmp = @v[0]
    case dir
    when 'E'; @v[0] = @h[0]; @h[0] = @v[2]; @v[2] = @h[1]; @h[1] = tmp
    when 'W'; @v[0] = @h[1]; @h[1] = @v[2]; @v[2] = @h[0]; @h[0] = tmp
    when 'S'; @v[0] = @h[2]; @h[2] = @v[2]; @v[2] = @v[1]; @v[1] = tmp
    when 'N'; @v[0] = @v[1]; @v[1] = @v[2]; @v[2] = @h[2]; @h[2] = tmp
    end
  end

  def pip
    @v[0]
  end
end

d = Dice.new gets
gets.chomp.each_char do |c|
  d.rotate(c)
end
puts d.pip

Measured memory_bytes: 6112
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
int a[12][6]={{4,2,0,9,7},{1,10,8,6,4},{9,7,5,3,1},{6,4,2,0,9},{3,1,10,8,6},
{0,9,7,5,3},{8,6,4,2,0},{5,3,1,10,8},{2,0,9,7,5},{10,8,6,4,2},{7,5,3,1,10}};
int main(){
    cin>>n>>m;
    ans=((n-2)/11)*5;
    for(int i=0;i<(n-2)%11;i++)
        for(int j=0;j<5;j++)
            if(a[i][j]==m) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<char, int> P;

int N, Q;
int father[MAXN]; // 并查集中的父节点
int parent[MAXN]; // 树中的父节点
int vis[MAXN]; // 结点标记次数
vector<int> e[MAXN]; // 记录边，即树的结构e[i][j]表示i的第j+1孩子
stack<P> st; // 存储操作

void dfs(int i, int f = 1) {
	if (vis[i])
		f = i;
	father[i] = f;
	vector<int> &ei = e[i];
	for (vector<int>::iterator it = ei.begin(); it != ei.end(); ++it) {
		dfs(*it, f);
	}
}

//void Init() {
//	for (int i = 0; i < MAXN; ++i) {
//		father[i] = i;
//	}
//}
int Find(int x) {
	if (father[x] == x)
		return x;
	return father[x] = Find(father[x]);
}

int main(int argc, char const *argv[]) {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	while (scanf("%d%d", &N, &Q) != EOF && !(N == 0 && Q == 0)) {
		int i, j, q;
		LL res = 0;
		char opt[5];
		for (i = 1; i <= N; ++i) {
			e[i].clear();
		}
		fill(vis, vis + MAXN, 0);
		vis[1] = 1;
		for (i = 2; i <= N; ++i) {
			scanf("%d", &j);
			e[j].push_back(i);// 结点j的孩子i,用于dfs
			parent[i] = j; // 结点i的父亲j
		}
		for (int i = 0; i < Q; ++i) {
			scanf("%s %d", opt, &j);
			if (opt[0] == 'M') {
				++vis[j];// 结点j标记次数
			}
			st.push(P(opt[0], j));// 将操作入栈，操作名和结点
		}
		dfs(1); // 寻找最近染色祖先
		// 逆序处理操作
		while (!st.empty()) {
			i = st.top().second; // 被操作结点
			if (st.top().first == 'M') { 
				if (--vis[i] == 0) // 直到多余标记结束
					father[i] = Find(parent[i]); // 取消染色
			} else {
				res += Find(i); // 查询操作，返回最近染色祖先
			}
			st.pop(); // 处理下一操作
		}
		printf("%lld\n", res);
	}
	//system("pause");
	return 0;
}



Measured memory_bytes: 14036
import bisect
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ng=-1
ok=A[-1]*2+1
B=[[0]*n for k in range(2)]
ii=0
while ok-ng>1:
  mid=(ok+ng)//2
  d=0
  for i in range(n):
    c=n-bisect.bisect_right(A,mid-A[i],lo=0,hi=len(A))
    B[ii][i]=c
    d=d+c
  if d<m:
    ok=mid
    ii=(ii+1)%2
  else:
    ng=mid
D=[0]
for i in range(n):
  D.append(D[-1]+A[n-i-1])
ans=0
for i in range(n):
  x=B[(ii+1)%2][i]
  ans=ans+A[i]*x+D[x]
ans=ans+(m-sum(B[(ii+1)%2]))*ok
print(ans)

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

int main() {
  char S[1001] = {'\0'};
  char T[1001] = {'\0'};

  int count = 0,min = 1000;
  int len_S = 0;
  int len_T = 0;

  gets(S);
  gets(T);
  len_S = strlen(S);
  len_T = strlen(T);

  for(int i=0;i + len_T <= len_S;i++){
    count = 0;
    for(int j=0;j<len_T;j++){
      // printf("%d %d\n",i,j);
      // printf("%s\n",S);
      // for(int k = 0;k<i;k++) printf(" ");
      // printf("%s\n",T);
      if(S[i+j] != T[j]){
        count++;
      }
    }
    if(min > count) min = count;
  }
  printf("%d\n",min);


  return 0;
}


Measured memory_bytes: 1604
# import time
# t1=time.time()
def LI():return list(map(int,input().split()))
# def I(): return int(input())
# from collections import deque, Counter, defaultdict
# from heapq import heappop, heappush
# from pprint import pprint
# import numpy as np
import itertools
nums = [0,1]

h,w,k=LI()
c=[]
for _ in range(h):
    c.append(list(input()))

f=0
for i in range(h):
    for j in range(w):
        if c[i][j]=="#":
            f+=1
# print(f)

ans=0
for ii in list(itertools.product(nums,repeat=h)):
    for jj in list(itertools.product(nums,repeat=w)):
        # print(ii,jj)
        cnt=0
        for i,ci in enumerate(ii):
            for j,cj in enumerate(jj):
                if ci==1 or cj==1:
                    if c[i][j]=="#":
                        cnt+=1
        if cnt==f-k:
            # print(ii,jj)
            ans+=1
                
        
print(ans)

Measured memory_bytes: 74020
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

long long power(long long x, long long n, long long mod = 1000000009) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

void resolve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int cnt = 1;
    REP(i,0,n) {
        if (a[i] % 2 == 0) cnt *= 2; 
    }
    cout << power(3,n) - cnt << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,L;
  cin >> N >> L;
  vector<int> vec(N);
  int unreal , real = 0;
  vector<int> vecexcept(N);
  rep(i,N)
  {
    vec[i] = L + i;
  }
  rep(i,N)
  {
    unreal += vec[i];
  }
  rep(i,N)
  {
    vecexcept[i] = unreal -vec[i];
  }
  int m = 2222;
  rep(i,N)
  {
    m = min(abs(unreal - vecexcept[i]),m);
  }
  rep(i,N)
  {
    if(abs(unreal - vecexcept[i])==m)
    {
      cout << vecexcept[i] << endl;
      break;
    }
  }
  return 0;
}


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

int val=1,n;
double k;
int main (){
    cin>>n>>k;
    int z=k;
    while(double(k)/2>1){
        val++;
        k/=2;
    }
   
  if(n>=val){
       cout<<pow(2,val)+z*(n-val); 
    }
    
    else{
        cout<<pow(2,n);
    }
}

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

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(q), point(n);
    int ai;
    for(int i= 0; i< q; i++){
        cin >> ai;
        a[i] = ai;
    }

    cout << endl;
    for (int i = 0; i < point.size(); i++)
        point[i] = k - q;
    
    for(auto ait = a.begin(); ait != a.end(); ++ait)
            point[*ait - 1]++;
    
    for (int i = 0; i < point.size(); i++){
        if(point[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000

void push(int);
int pop();
void isEmpty();
void isFull();

int top,stac[MAX];

int main(){
  int x;
  int n1=0,n2=0;
  char s[100];
  top=0;
  
  while( scanf("%s", s) != EOF ){

    if ( s[0] == '+' ){
      if(top==0) isEmpty();
      else if(top>=MAX-1) isFull();
      n2=pop();
      n1=pop();

      push(n1+n2);
      
    } else if ( s[0] == '-' ){
      if(top==0) isEmpty();
      else if(top>=MAX-1) isFull();
      n2=pop();
      n1=pop();

      push(n1-n2);
      
    } else if ( s[0] == '*' ){
      if(top==0) isEmpty();
      else if(top>=MAX-1) isFull();
      n2=pop();
      n1=pop();

      push(n1*n2);
      
    } else {
      x = atoi(s);
      push(x);
    }

  }

  printf("%d\n",pop());
  return 0;
}


void push(int x){
  if(top>=MAX-1) isFull();

  stac[top]=x;
  top++;
}

int pop(){
  int x;
  if(top==0) isEmpty();
  top--;
  return stac[top];
}

void isEmpty(){
  printf("this stac is empty!\n");
  exit(2);
}

void isFull(){
  printf("this stac is full!\n");
  exit(2);
}



Measured memory_bytes: 2108
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long

int main(){
    int a;
    ll b,n;
    cin>>a>>b>>n;
    ll ans;
  if(b<=n) ans=((ll)a*(b-1))/b-a*((b-1)/b);
  else ans=((ll)a*n)/b-a*(n/b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    rep(i, M) cin >> a[i];
    
    int mod = 1000000007;
    vector<int> dp(N + 1, -1);
    dp[0] = 1;
    rep(i, M) dp[a[i]] = 0;
    REP(i, N + 1) {
        if (dp[i] == 0) continue;
        if (i == 1) dp[i] = 1;
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]
A.sort(reverse = True, key = lambda x: x[2])

for i in range(101):
    for j in range(101):
        px, py, ph = A[0] # 高さ最大
        H = ph + abs(px - i) + abs(py - j)
        if all(h == max(H - abs(x - i) - abs(y - j) , 0) for x, y, h in A):
            print(i, j, H)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  while(1){
    int n,q,i,j,m,d,c[101]={},a,mx=-1;
    cin>>n>>q;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin>>m;
      for(j=0;j<m;j++){
	cin>>d;
	c[d]++;
	if(c[d]>mx){
	  mx=c[d];
	  a=d;
	}
	else if(mx==c[d]&&a>d)a=d;
      }
    }
    if(mx<q)cout<<"0"<<endl;
    else cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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 gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  vector<int> C(N), D(N);
  rep(i,N) {
    C[(i+(N/2))%N]=B[i];
    D[(i+((N+1)/2))%N]=B[i];
  }
  bool ok = true;
  rep(i,N){
    if(A[i]==C[i])ok =false;
  }
  if(ok){
    cout << "Yes" << endl;
    rep(i,N){
      if(i) cout << " ";
      cout << C[i];
    }
    cout << endl;
    return 0;
  }
  ok = true;
  rep(i,N){
    if(A[i]==D[i])ok =false;
  }
  if(ok){
    cout << "Yes" << endl;
    rep(i,N){
      if(i) cout << " ";
      cout << D[i];
    }
    cout << endl;
    return 0;
  }
  reverse(all(B));
  ok = true;
  rep(i,N){
    if(A[i]==B[i]) ok = false;
  }
  if(ok) {
    cout << "Yes" << endl;
    rep(i,N){
      if(i) cout << " ";
      cout << B[i];
    }
    cout << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

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

  vector<int> dp(N + 1);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    dp[i + 1] = dp[i];
    if (i > 0 && S.substr(i - 1, 2) == "AC") {
      dp[i + 1]++;
    }
  }

  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    cout << dp[r + 1] - dp[l + 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1536
#include<iostream>

using namespace std;

int main(){
	int N,T,c[100],t[100];
	cin >> N >> T;
	int mincost=1001;
	int mincostnum=-1;
	for(int i=0;i<N;i++){
		cin >> c[i];
		cin >> t[i];
	}
	
	for(int i=0;i<N;i++){
		if(t[i]<=T){
			if(mincost>c[i]){
				mincostnum=i;
				mincost=c[i];
			}
		}
	}
	if(mincostnum==-1){
		cout << "TLE";
	}else{
		mincostnum++;
		cout << mincost;
	}
	
	
}

Measured memory_bytes: 256
# code festival 2016 qa
# 方針：好きな人の好きな人が自分である数を求めて２で割る

n = gets.to_i
a = gets.split.map { |s| s.to_i - 1 }
ans = 0

n.times do |i|
  if a[a[i]] == i
    ans += 1
  end
end

puts ans / 2

Measured memory_bytes: 8068
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 500;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

ll gcd(ll m, ll n)
{
	return n != 0 ? gcd(n, m % n) : m;
}

ll lcm(ll m, ll n)
{
	if ((0 == m) || (0 == n)) return 0;
	return ((m / gcd(m, n)) * n);
}

void SearchPattern(map<ll, ll>& a, ll b, ll c)
{
	ll x = 1;
	while (!a.count((b * x) % c)){
		a[(b * x) % c] = 1;
		x = (b * x) % c;
	}
}

map<ll, ll> aa, bb, cc;
int main()
{
	ll a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f && a | b | c | d | e | f){
		aa.clear(); bb.clear(); cc.clear();

		SearchPattern(aa, a, b);
		SearchPattern(bb, c, d);
		SearchPattern(cc, e, f);

		cout << lcm(lcm(aa.size(), bb.size()), cc.size()) << endl;
 	}

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int flag = 1;
    map<int, int> mp;

    int tmp;
    for(int i=0; i<N; i++) {
        cin >> tmp;
        if(mp[tmp]==1) {
            flag = 0;
            break;
        } else {
            mp[tmp] = 1;
        }
    }

    cout << ((flag==1) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
  int n,MAX=0;
  cin>>n;
  int a[n];
  r(i,n){
    cin>>a[i];
    if(a[i]>1)MAX=max(a[i],MAX);
  }
  unordered_set<int>st;
  r(i,n)r(j,n){
    st.insert(__gcd(a[i],a[j]));
  }
  for(auto &e:st){
    if(e==1)continue;
    int sum=0;
    r(i,n){
      if(a[i]%e==0)sum+=a[i];
    }
    MAX=max(sum,MAX);
  }
  cout<<MAX<<endl;
}


Measured memory_bytes: 3144
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let d: u32 = read(&mut stdin_lock, &mut buf, b' ');
    let n: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = if n == 100 {
        100i32.pow(d) * 101
    } else {
        100i32.pow(d) * n
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
require 'prime'

n, p = gets.split.map(&:to_i)
h = Hash.new(0)
g = Prime::EratosthenesGenerator.new
d = g.next
q = p
while d < Math.sqrt(p)
  while q % d == 0
    h[d] += 1
    q /= d
  end
  d = g.next
end
h[q] += 1 if q > 1
if h == {} || p == 1
  puts 1
elsif n == 1
  puts p
else
  ans = 1
  h.sort_by{|k, v| -v}.each do |k, v|
    while v >= n
      ans *= k
      v -= n
    end
  end
  puts ans
end

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

    // define
# define loop(i,a,n) for(int i=a;i<n;++i)
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(0);
# define ll long long int 
# define endl '\n'
# define mp make_pair
# define mt make_tuple
# define pb push_back
# define eb emplace_back
# define in insert
# define rev(i,a,n) for(int i=n-1;i>=a;--i)
# define test int t; cin>>t; while(t--)

/* debug */
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _itRS(_ss); err(_itRS, args); }

void err(istream_iterator<string> itRS) {}
template<typename T, typename... Args>
void err(istream_iterator<string> itRS, T a, Args... args) {
    cerr << *itRS << " = " << a << endl;
    err(++itRS, args...);
}


const int MOD=1000000007;


int T[10001];
int main()
{
    fast
    int h,a;
    cin>>h>>a;
    if(h%a==0)
    {
        cout<<h/a<<endl;
    }
    else
    {
        cout<<h/a+1<<endl;
    }
    
    return 0;
}

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

int main()
{
	vector< pair< double, int > > athletes;
	vector< pair< double, int > > finalists;

	for( int i = 0; i < 3; ++i ){
		vector< pair< double, int > > party;
		for( int j = 0; j < 8; ++j ){
			int id;
			double time;
			cin >> id >> time;
			party.push_back( make_pair( time, id ) );
		}
		sort( party.begin(), party.end(), greater< pair< double, int > >() );
		finalists.push_back( party[ 7 ] );
		finalists.push_back( party[ 6 ] );
		party.pop_back();
		party.pop_back();
		athletes.insert( athletes.end(), party.begin(), party.end() );
	}
	sort( athletes.begin(), athletes.end() );
	finalists.push_back( athletes[ 0 ] );
	finalists.push_back( athletes[ 1 ] );

	for( int i = 0; i < 8; ++i ){
		cout << finalists[ i ].second << " " << fixed << setprecision( 2 ) << finalists[ i ].first << endl;
	}

	return 0;
}

Measured memory_bytes: 1304
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int r, D, x_2000;
    cin >> r >> D >> x_2000;
    
    int x_i = x_2000;
    for (int i = 0; i < 10; i++) {
        int x_iPlus1 = r * x_i - D;
        cout << x_iPlus1 << endl;
        x_i = x_iPlus1;
    }
    
    return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n,k = map(int, input().split())
a = list(map(int, input().split()))
ans = a[0]
for i in range(n):
    ans = gcd(ans,a[i])
m = max(a)
if k%ans == 0 and k <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 14252
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

long long int MOD = 1000000007;
int N,K,L;
struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};
int main(){
	cin>>N>>K>>L;
	UnionFind uf1,uf2;
	uf1.init(N);
	uf2.init(N);
	for(int i=0;i<K;i++){
		int x,y;
		cin>>x>>y;x--;y--;
		uf1.unionSet(x,y);
	}
	for(int i=0;i<L;i++){
		int x,y;
		cin>>x>>y;x--;y--;
		uf2.unionSet(x,y);
	}
	map<pii,int> rt;
	pii hoge[214514];
	for(int i=0;i<N;i++){
		hoge[i]=mp(uf1.root(i),uf2.root(i));
		rt[hoge[i]]++;
	}
	for(int i=0;i<N;i++){
		cout<<rt[hoge[i]]<<" ";
	}
	cout<<endl;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	ll a, b, c, ans;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		ans = 0ll;
	} else {
		ans = min(a * b, min(b * c, a * c));
	}
	cout << ans << endl;
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int n = stdIn.nextInt();
	String s = stdIn.next();
	int count=0;
	String S=s.replaceAll("ABC","-");
	for(int i=0;i<S.length();i++){
	    if(S.charAt(i)=='-'){
		count++;
	    }
	}
	System.out.println(count);
    }
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int l, r;
  cin >> l >> r;
  int ans = INF;
  bool jud = false;

  rep(i, l, r + 1) {
    rep(j, i + 1, r + 1) {
      chmin(ans, (i * j) % 2019);
      if ((i * j) % 2019 == 0) {
        jud = true;
        break;
      }
    }
    if (jud == true) break;
  }

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

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

namespace contest_Csharp
{
    class Program
    {


        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var vals = Console.ReadLine().Split(' ').
                Select(x => long.Parse(x)).ToList();

            var N = vals[0];

            var A = Console.ReadLine().Split(' ').
                Select(x => long.Parse(x)).ToList();
            var NL = new long[5000000];
            foreach (var a in A)
            {
                NL[a]++;
            }
            long Sum = A.Sum();

            var vals2 = Console.ReadLine().Split(' ').
                Select(x => long.Parse(x)).ToList();

            var Q = vals2[0];

            for (long i = 0; i < Q; i++)
            {
                var v = Console.ReadLine().Split(' ').
                Select(x => long.Parse(x)).ToList();
                long B = v[0], C = v[1];

                Sum = Sum - NL[B] * B + NL[B] * C;
                NL[C] += NL[B];
                NL[B] = 0;

                Console.WriteLine(Sum);

            }

            //Console.WriteLine();
            Console.Out.Flush();
        }




    }
}




Measured memory_bytes: 46424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0040
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int A = int.Parse(S.Split(' ')[0]);

            if (1000 <= A)
            {
                Console.WriteLine("ABD");
            }
            else
            {
                Console.WriteLine("ABC");
            }
        }
    }
}


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

int main(){
    i64 ans[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    i64 a;
    cin>>a;
    cout<<ans[a-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
n, q = list(map(int, input().split()))
nodes = [[] for _ in range(n)]
for _ in range(n-1):
    ai, bi = list(map(int, input().split()))
    nodes[ai-1].append(bi-1)
    nodes[bi-1].append(ai-1)
    
cnts = [0]*n
for _ in range(q):
    pi, xi = list(map(int, input().split()))
    cnts[pi-1] += xi
    
stack = []
visited = set()
stack.append(0)
while stack:
    current = stack.pop(-1)
    visited.add(current)
    for j in nodes[current]:
        if j in visited:
            continue
        cnts[j] += cnts[current]
        stack.append(j)
        
print(*cnts)

Measured memory_bytes: 117836
#include<bits/stdc++.h>
using namespace std;
#define mx 111000
#define ll long long int
int main()
{
    //ll a;
    char c;
    cin >> c;
    if(c>=65 && c<=90)
        cout << "A" << endl;
    else if(c>=97 && c<=122)
        cout << "a" << endl;
    //cout <<  << endl;
    return 0;
}


Measured memory_bytes: 3496
n = int(input())
li = list(map(int,input().split()))

count = 0
for i in range(1,n-1):
    if li[i] < li[i+1] and li[i] >= li[i-1]:
        count += 1
    elif li[i] < li[i-1] and li[i] >= li[i+1]:
        count += 1

print(count)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#define N 5010
using namespace std;
int a[N][N];
char s[N];
int main()
{
	int n,ans = 0;
	scanf("%d",&n);
	scanf("%s",s + 1);
	for(int i = 1;i <= n;i ++)
		for(int j = 1;j <= n;j ++)
		{
			if(s[i] == s[j])
				a[i][j] = 1 + a[i - 1][j - 1];
			ans = max(ans,min(a[i][j],abs(j - i)));
		}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s, t;
  cin>>s>>t;
  cout<<t<<s<<'\n';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <map>
using namespace std;

map<int, int> f;

int main(void)
{
    int n, x;
    int i;
    long long o;

    scanf("%d", &n);
    for(i = o = 0; i < n; i ++)
    {
        scanf("%d", &x);
        o += f[i - x];
        f[i + x] ++;
    }
    printf("%lld\n", o);

    return 0;
}


Measured memory_bytes: 20644
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  string s;
  cin >> s;
  if(s.at(0) == 'A' && s.at(s.size()-1) != 'C'){
    int num = 0;
    int B = 0;
    int a;
    for(int i = 2; i < s.size()-1;i++){
      if(s.at(i) == 'C') num++;
    }
    for(int i = 1; i < s.size(); i++){
      a = s.at(i);
      if(a >= 65 && a <= 90  ) ++B;
    }
    if(num == 1 && B == 1) cout << "AC" << endl;
    else cout << "WA" << endl;
  }
  else cout << "WA" << endl;
}

Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String str = br.readLine();
		System.out.println(str.toUpperCase());
	}
}

Measured memory_bytes: 16848
# https://atcoder.jp/contests/abc135/submissions/7969271
# 写経

def main():
    K = int(input())
    X, Y = map(int, input().split())

    if K % 2 == 0 and (X + Y) % 2 != 0:
        print(-1)
        return

    def next_vec(x, y):
        # 原点からx,yを目指すとき
        if x < 0:
            dx, dy = next_vec(-x, y)
            return -dx, dy
        if y < 0:
            dx, dy = next_vec(x, -y)
            return dx, -dy
        if x < y:
            dx, dy = next_vec(y, x)
            return dy, dx
        # 1手
        if x + y == K:
            return x, y
        # 2手...(1)
        if x + y <= K + K and (x + y) % 2 == 0:
            return (x + y) // 2, (x + y) // 2 - K
        # 3手以上
        return K, 0

    x, y = 0, 0
    ans = []
    while (x, y) != (X, Y):
        dx, dy = next_vec(X - x, Y - y)
        x += dx
        y += dy
        ans.append('{} {}'.format(x, y))

    print(len(ans))
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

"""
写経して計算の意味を考えた

(1)
x+y=D<2K
2手要する
S(A,B)->M(?,?)->G(X,Y)
S->M: 距離K未満=D-K詰め
M->G: 距離K詰め

S,Gから等距離Lの点M'
M'からGから離れる方向に距離Fの点M
SM'=M'G: 距離L
MM': 距離F

S->M'->M->M'->G
(S->M'->M)->M'->G: 初手
S->M': Gに距離L近づく
M'->M: Gから距離F離れる
dD_1=L-F=D-K...1

S->M'->(M->M'->G): 次手
M->M': Gに距離F近づく
M'->G: Gに距離L近づく
dD_2=L+F=K...2

1,2の連立で
L=D/2<K
F=K-D/2...(1)と符合逆だがこれは大きさ

SからGに向かって
L=D/2近づき
F離れることは可能か？
D=x+y
x>=yとすると
2D=2(x+y)<=2(2x)
D<=2x
D/2<=x
x,y方向の離れている距離のうちより離れている方向xでは
距離D/2以上離れているので、
この方向でSからGに向かってL=D/2近づくこと(=Mに到達)はできる
その後、y方向でMからGに向かうのと逆方向に
F=K-D/2進めば
次にGに向かって最短経路を進むと
距離KでGに到達できるようなM'に到達できる
"""


Measured memory_bytes: 22916