akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma GCC target("popcnt")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class ATherefore {
public:
  
  void solveOne(istream& cin, ostream& cout) {
    string s;
    cin >> s;
    int n = s.back() - '0';
    string ans = "hon";
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    
    }
    if (n == 0 || n == 1 || n == 6 || n == 8) {
      ans = "pon";
    }
    if (n == 3) ans = "bon";
    cout << ans << '\n';
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    int t = 1;
    // cin >> t;
    for (int tc = 1; tc <= t; ++tc) {
      //	cout << "Case #" << tc << ": ";
      solveOne(cin, cout);
    }
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	ATherefore solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define max_weight 20002 

using namespace std;
 
//ordened by weight and solidness
bool cmp(vector<ll> &a, vector<ll> &b)
{
	return a[0] + a[1] < b[0] + b[1];
}

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

	vector<vector<ll>> a(n, vector<ll>(3));
	//ll a[n][3];

	for (int i = 0; i < n; ++i)
	{
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}

	sort(a.begin(), a.end(), cmp);

	vector<ll> dp(max_weight);

	
	for (int i = 0; i < n; ++i)
	{
		for (ll aguenta = a[i][1]; aguenta >= 0; aguenta--)
		{
			dp[aguenta + a[i][0]] = max(dp[aguenta + a[i][0]], dp[aguenta] + a[i][2]);
		}


	}

	ll resp = -1;
	for (int i = 0; i < max_weight; ++i)
	{	
		resp = max(resp, dp[i]);
	}


	cout << resp << endl;

 
 
    return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
using namespace std;

//fixed << setprecision(10)
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int a,int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

map<int, int> prime;
void Prime(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}

int main() {
	int n;
	cin >> n;
	int i = 2;
	string s = "No";
	for (i = 9; i > 0; i--) {
		if (n % i == 0 && n / i < 10) {
			s = "Yes";
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int [] d = new int[N];
    for(int i = 0; i < N; i++) {
      d[i] = sc.nextInt();
    }

    sc.close();

    int answer = 0;
 
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        answer += d[i] * d[j];
      }
    }

    System.out.println(answer);

  }

}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
    int a[] = {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};
    int k;
    cin >> k;
    cout << a[k-1];
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 


Measured memory_bytes: 384
#include <string>
#include <iostream>
#include <vector>
#include <algorithm> 
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
int main()
{
	int a,b,c=0,o=1;
	cin>>a>>b;
	
	while(o<b)
	{
		o+=(a-1);
		c++;
	}
	
	cout<<c;

	return 0;
}

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

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
const int N=1e2+5;

int main()
{
   ll n=D();
   cout<<(n*(n+1)/2)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int sum=0,ans=0;
int main(){
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(i%2==0){
			if(s[i]=='1')
				sum++;
			else ans++;
		}
		else{
			if(s[i]=='0')
				sum++;
			else ans++;
		}
	}
	ans=min(sum,ans);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
bool sqint(int t){
    for(int i=0;i*i<=t;i++){
        if(i*i==t){
            return true;
        }
    }
    return false;
}
int main(){
    int n,d;
    cin>>n>>d;
    vvi vec(n,vi(d));
    cin>>vec;
    int ans=0;
    REP(i,n){
        REP(j,i){
            int t=0;
            REP(k,d){
                t+=(vec[i][k]-vec[j][k])*(vec[i][k]-vec[j][k]);
            }
            if(sqint(t)){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

long double x[15];
string u[15];

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

	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> u[i];
	}

	long double ans = 0.0;

	for (int i = 1; i <= N; i++) {
		if (u[i] == "JPY") { ans += x[i]; }
		else { ans += x[i] * 380000.0; }
	}

	cout <<setprecision(16)<<fixed<< ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
using System;

namespace Temp
{
    class Program
    {
        static void Main(string[] args)
        {
            int A;
            int B;
            int T;

            int Ans;

            string[] input = Console.ReadLine().Split(' ');
            A = int.Parse(input[0]);
            B = int.Parse(input[1]);
            T = int.Parse(input[2]);

            Ans = (T) / A * B;

            Console.WriteLine(Ans);
        }
    }
}

Measured memory_bytes: 11092
/*
    atcoder_begineer_c_112A       4246

   28/10/18
   by ahmed_drawy


*/


#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//#define push_back               pb;
//#define make_pair               mp;
#define lp(i,start , end)       for(int i = start ; i<end ; ++i)
#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)
#define all(v)                   ((v).begin(),(v).end())
#define sz(v)                  (int)((v).size())
#define clr(v,d)                memset(v , d , sizeof(v))
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2 *haven't understood this yet
#define isPowerOfTwo(S) (!(S & (S - 1)))            // done

#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))  // TBD


#define turnOffLastBit(S) ((S) & (S - 1))       // turn off last unset bit from right
#define turnOnLastZero(S) ((S) | (S + 1))       //turn on last unset bit from right
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))



typedef long long               ll;
typedef vector<int>             vi;
typedef vector  <ll>            vll;
typedef vector<vector<int> >    adj;
typedef pair<int ,int>          pii;


const double EPS =1e-7;
const int OO = 1e6;
bool sortpair( const pair<int , int> & x, const pair<int , int> & y)
{

    return  x.first != y.first ? x.first < y.first : x.second > y.second ;


}
int dcomp(double x , double y)
{
    return fabs(x-y) <= EPS? 0: x>y?1:-1;
}
void smile(){
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
}

void printarr(int arr [] , int n){
lp(i,0,n) cout<<arr[i]<<" ";cout<<endl;
}

void printset(int n ){
    stack <int> myst;
    while(n)    myst.push(n%2), n/=2;
    while(!myst.empty())    cout<<myst.top(), myst.pop();
    cout<<endl;
}
int main(){
	smile();int n;cin>>n;
	if(n==1)    cout<<"Hello World\n";
	else {
        int a , b ; cin>>a>>b;
        cout<<a+b;
	}


}


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

int main(void){

	int n,x,y,b,p;

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x >> y >> b >> p;
		if(b >= 5 && p >= 2)cout << (x * b + y * p)/10*8 << endl;
		else if(b >= 5){
			if(x * b + y * p > (x * b + y * (p + (2 - p)))/10*8)cout << (x * b + y * (p+(2-p)))/10*8 << endl;
			else cout << x * b + y * p << endl;
		}
		else if(p >= 2){
			if(x * b + y * p > (x * (b + (5 - b)) + y * p)/10*8)cout << (x * (b + (5 - b)) + y * p)/10*8 << endl;
			else cout << x * b + y * p << endl;
		}
		else cout << x * b + y * p << endl;
			
	}
	return 0;
}

Measured memory_bytes: 1160
a=int(input())

sum=0
for n in range(1, a+1): 
    if n % 3 == 0 and n % 5 == 0:
        continue
    elif n % 3 == 0:
        continue
    elif n % 5 == 0:
        continue
    else:
        sum+=n


print(sum)

Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
int n;
int sum= 0;
bool if_ten(){
    if(n==10 ||n==100 ||n==1000 ||n==10000 ||n==100000)
        return true;
    return false;
}
int main()
{
    cin>>n;
    if(if_ten()){cout<<10<<endl;exit(0);}

    while(n>0){
        sum+=n%10;
        n/=10;
    }
    cout<<sum<<endl;
    return 0;
}


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

int main() {
	double n;cin>>n;
	printf("%.10lf %.10lf\n",n*n*M_PI,n*2*M_PI);
}

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

int main()
{
	char c;
	cin >> c;
	if (c == 'a' )
		cout << "vowel";
	else if (c == 'e')
		cout << "vowel";
	else if (c == 'i')
		cout << "vowel";
	else if (c == 'o')
		cout << "vowel";
	else if (c == 'u')
		cout << "vowel";
	else
		cout << "consonant\n";
}


Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++)
			array[i] = scan.nextInt();
		for (int i = 1; i < n; i++) {
			for (int k = 0; k < n; k++)
				System.out.print(array[k] + (k == n - 1 ? "": " "));
			System.out.println();
			int v = array[i];
			int j = i - 1;
			while (j >= 0 && array[j] > v) {
				array[j + 1] = array[j];
				j--;
			}
			array[j + 1] = v;
		}
		for (int k = 0; k < n; k++)
			System.out.print(array[k] + (k == n - 1 ? "": " "));
		System.out.println();
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 30424
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<pair<int,int>,int> mm;
	vector<pair<int,int>> mv;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		mv.push_back(make_pair(a,b));
		
	}
	for(int i=0;i<(int)mv.size();i++){
		for(int j =0;j<(int)mv.size();j++){
			if(j == i)continue;
			pair<int,int> dif = {mv[i].first - mv[j].first , mv[i].second - mv[j].second};

			if(mm.count(dif))mm[dif]++;
			else mm[dif] = 1;
			
		}
	}
	int mx = 0;
	for(auto &e:mm)
	{
		mx = max(mx,e.second);
	}
	cout<<n-mx<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	int N;
	int flag;
	int i,j;
	flag=0;
	scanf("%d",&N);
	for(i=1; i<10; i++){
		for(j=1; j<10; j++){
			if(i*j == N) flag=1;
		}if(flag==1) break;
	}

	if(flag==1) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
void solve()
{
    ll n,m;cin>>n>>m;vector<ll>dp(n+2,0);vector<bool>ar(n+2,0);
    for(ll i=0;i<m;i++)
    {
        ll a;cin>>a;ar[a]=1;
        if(ar[a-1]||ar[a+1])
        {cout<<0;return;}
    }
    dp[0]=1;dp[1]=1;
    for(ll i=2;i<=n;i++)
    {
        if(!ar[i-1])
            dp[i]+=dp[i-1];
        if(!ar[i-2])
            dp[i]+=dp[i-2];
        dp[i]%=M;
    }
    cout<<dp[n]<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      final int k = scanner.nextInt();
      final int t = scanner.nextInt();

      int maxi = 0;
      for (int i = 0; i < t; i++) {
        final int a = scanner.nextInt();
        if (maxi < a) maxi = a;
      }

      int ans = 2 * maxi - k - 1;
      if (ans < 0) {
        System.out.println(0);
      } else {
        System.out.println(ans);
      }
    } finally {
      scanner.close();
    }
  }
}


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

using namespace std;

using ll = long long;

constexpr ll inf = 1<<20;
int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> h(n);
    for(auto & a : h) cin>>a;
    sort(h.begin(),h.end());
    ll ans = h[k-1] - h[0];
    for(int i=0;i<=n-k;++i){
        ans = min(ans,h[i+k-1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=0;
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		if(x>=k)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define lli long long int
#define LLI(n) lli n; cin >> n;
#define STR(n) string n; cin >> s;
#define Sort(n) sort(n.begin(), n.end());
#define Reve(n) reverse(n.begin(), n.end());
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)for (lli i = 0;i < s.size(); i++) { if (s.at(i) == c) { n++; } };

//素数
bool IsPrime(lli num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)return false;
  }
  return true;
}
//各桁の和
lli Sum(lli n)
{
  lli sum=0;
  if (n<0) return 0;
  while (n>0)
  {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  ios::sync_with_stdio(false);
  lli ans = 700;
  lli flag = 0;
  STR(s);
  s[3] = '8';
  OUT(s)
  return 0;
}


Measured memory_bytes: 256
// 22:00 -
//
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int M;
  cin >> M;
  cout << (24-M) + 24 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll L = gi();
    ll R = gi();
    if (R-L >= 2019)
        printf("0\n");
    else {
        ll r = 2019;
        for (ll i = L; i < R; i++)
            for (ll j = i+1; j <= R; j++) {
                ll rm = (i*j) % 2019;
                r = MIN(r, rm);
            }
        printf("%d\n", int(r));
    }

    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    q = int(input())
    b = [0] * q
    c = [0] * q
    for i in range(q):
        bb,cc = map(int,input().split())
        b[i] = bb
        c[i] = cc
    import collections
    cnt = collections.Counter(a)
    S = sum(a)

    for i in range(q):
        now_b = b[i]
        now_c = c[i]
        now_cnt = cnt[now_b]
        sub = (now_c - now_b) * now_cnt
        S += sub
        cnt[now_b] = 0
        cnt[now_c] += now_cnt
        # print(now_b,now_c,now_cnt)
        # print(cnt)
        print(S)

if __name__=='__main__':
    main()


Measured memory_bytes: 30048
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba-064a5016a 

#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod ((int)(1e9 + 7))
int dp[1000][1000];
int cal(int cost, int l, int r);
signed main()
{
	fast_io
	int n;
	cin >> n;
	int a[n + 1];
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int ps[n + 1] = {0};
	for(int i = 1; i <= n; i++)
		ps[i] = ps[i - 1] + a[i];
	for(int i = 0; i < 1000; i++)
		for(int j = 0; j < 1000; j++)
			dp[i][j] = 1e18L + 5;
	for(int i = 1; i <= n; i++)
	{
		dp[i][i] = 0;
	}
	for(int i = 1; i <= n - 1; i++)
	{
		dp[i][i + 1] = a[i] + a[i + 1];
	}
	for(int i = 3; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(j + i - 1 <= n)
			{
				int l = j;
				int r = j + i - 1;
				for(int k = l; k < r; k++)
				{
					dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + ps[r] - ps[l - 1]);
				}
			}
		}
	}
	cout << dp[1][n] << endl;
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>

int main() {
    int N, A, B;
    std::cin >> N >> A >> B;

    int train = N * A;
    int taxi = B;

    if (train < taxi) {
        std::cout << train << std::endl;
    } else {
        std::cout << taxi << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
// Jai Sai Ram
//Always help me!
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[2001][2001];
ll P=1e9+7;
void solve()
{
    ll i,j,k,l,m,n,o,p,q,r,s;
    cin>>n;
    p=LLONG_MAX;
    q=LLONG_MIN;
    r=LLONG_MAX;
    s=LLONG_MIN;
    for(i=0;i<n;i++)
    {
        cin>>j>>k;
        p=min(j+k,p);
        q=max(j+k,q);
        r=min(j-k,r);
        s=max(j-k,s);
    }
    cout<<max(abs(q-p),abs(r-s))<<endl;
    
}
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(0);
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

#define int long long

#define F first
#define S second
#define all(x) (x).begin(), (x).end()

using namespace std;

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

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;
    int ans = INT_MAX;

    for(int i = 0; i + t.size() <= s.size(); i++) {
        int cur = 0;
        for(int j = 0; j < t.size(); j++)
            if(t[j] != s[i+j])
                cur++;
        ans = min(ans, cur);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3624
import bisect


class SqrtSet:
    def __init__(self, block_limit=201):
        self.key = []
        self.child = [[]]
        self.block_limit = block_limit

    def search_lower(self, key):
        if key is None:
            return None
        ret = None
        i = bisect.bisect_left(self.key, key)
        if i != 0:
            ret = self.key[i - 1]
        block = self.child[i]
        i = bisect.bisect_left(block, key)
        if i != 0:
            ret = block[i - 1]
        return ret
        
    def search_higher(self, key):
        if key is None:
            return None
        ret = None
        i = bisect.bisect_right(self.key, key)
        if i != len(self.key):
            ret = self.key[i]
        block = self.child[i]
        i = bisect.bisect_right(block, key)
        if i != len(block):
            ret = block[i]
        return ret

    def insert(self, key):
        i = bisect.bisect(self.key, key)
        block = self.child[i]
        bisect.insort(block, key)
        if len(block) == self.block_limit:
            sep = self.block_limit // 2
            self.key.insert(i, block[sep])
            self.child.insert(i + 1, block[sep + 1:])
            self.child[i] = block[:sep]
                
    def dump(self):
        for b in self.child:
            print(len(b), end=" ")
        print("")
            
            
def main():
    n = int(input())
    p = list(map(int, input().split()))
    idx = [0] * n
    for i in range(0, n):
        idx[i] = i
    idx.sort(key=lambda i: p[i])
    t = SqrtSet()
    t.insert(-1)
    t.insert(n)
    ans = 0
    for i in range(n):
        right = t.search_higher(idx[i])
        left = t.search_lower(idx[i])
        ans+=(i+1)*(idx[i]-left)*(right-idx[i])
        t.insert(idx[i])
        #print(left,idx[i],right)
    print(ans)


main()


Measured memory_bytes: 25720
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int solve();
static int N, X;
static vector<int> L;

int solve() {
  int d = 0;
  int ret = 1;
  for (auto l : L) {
    d += l;
    if (d <= X) {
      ret += 1;
    }
  }
  return ret;
}

int main() {
  cin >> N >> X;
  for (int i = 0; i < N; i++) {
    int l;
    cin >> l;
    L.emplace_back(l);
  }
  cout << solve() << endl;
  return 0;
}


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


void solve(long long N, std::vector<long long> A){
    map<long long, long long> subordinate;
    for(int i = 1; i <= N; ++i) subordinate[i] = 0;
    for(int i = 0; i < N-1; ++i){
        subordinate[A[i]] += 1;
    }
    for(auto i = subordinate.begin(); i != subordinate.end(); ++i){
        cout << i->second << endl;
    }
    return;
}

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


Measured memory_bytes: 17272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)
const int mx=1e5+7;
vector<p>adj[mx];
vector<ll> vis(mx),dis(mx);
 queue<ll> q;
void bfs(ll s)
{

    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        for(auto i:adj[u])
        {
            if(!vis[i.ff])
            {
                q.push(i.ff);
                vis[i.ff]=1;
                dis[i.ff]=dis[u]+i.ss;
            }
        }
    }
}
//for a tree
int main()
{
    fast;
    ll n;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        ll u,v,w;
        cin>>u>>v>>w;
        adj[u].pb({v,w});
        adj[v].pb({u,w});
    }
    bfs(1);
    for(int i=1;i<=n;i++)
    {
       // cout<<dis[i]<<" ";
        cout<<(dis[i]&1?1:0)<<endl;
    }
}


Measured memory_bytes: 12160
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] s = new String[101];
        String tmp;
        for(int i=0;i<n;i++){
            s[i] = sc.next();
        }
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(s[i].compareTo(s[j])>0){
                    tmp = s[i];
                    s[i] = s[j];
                    s[j] = tmp;
                }
            }
        }
        for(int i=0;i<n;i++){
            System.out.print(s[i]);
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



int main(){
    int c[3][3];
    rep(i,3) rep(j,3) cin >> c[i][j];
    
    int p =min(c[0][0],min(c[0][1],c[0][2]))+1;
    int q =min(c[1][0],min(c[1][1],c[1][2]))+1;
    int r =min(c[2][0],min(c[2][1],c[2][2]))+1;
    bool ans = false;
    
    rep(i,p){
        rep(j,q){
            rep(k,r){
                int x[3][3];
                rep(l,3) x[0][l] = c[0][l]-i;
                rep(l,3) x[1][l] = c[1][l]-j;
                rep(l,3) x[2][l] = c[2][l]-k;
                
                if(x[0][0] == x[1][0] && x[1][0] == x[2][0]){
                    if(x[0][1] == x[1][1] && x[1][1]== x[2][1]){
                        if(x[0][2] == x[1][2] && x[1][2] == x[2][2])
                            ans = true;
                    }
                }
            }
        }
    }
    
    cout << yn(ans) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) int((x).size())
#define endl '\n'
#define ff first
#define ss second
#define debug(x) cout << #x << ": " << x << ' ';
#define debugg(x) cout << #x << ": " << x << '\n';
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T>   T add(T x, T y, T m) { return ((x % m)  + (y % m)) % m;}
template<typename T>   T mul(T x, T y, T m) { return ((x % m) * (long long)(y % m)) % m;}
template<typename T>   T sub(T x, T y, T m) { return add(x, -y + m);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};

const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

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

	ll n;
	cin >> n;

	unordered_map<ll, ll> freq;
	vector<ll> a(n);

	ll sum = 0;
	for(auto &x : a) {
		cin >> x;
		++freq[x];
		sum += x;
	}

	ll q;
	cin >> q;

	while(q--) {
		ll b, c;
		cin >> b >> c;
		sum -= b * freq[b];
		sum += c * freq[b];
		freq[c] += freq[b];
		freq[b] = 0;
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long a,b;
  cin>>a>>b;
  if(a>=b){
  	long long r = a%b;
  	long long mindist = r;
  	mindist = min(r,b-r);
  	cout<<mindist;
  }
  else{
  	long long mindist = b-a;
  	a = mindist; 
  	mindist = min(mindist,b-a);
  	cout<<mindist;
  }
}

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

int main() {
  int a,b,c,t;
  cin >> a >> b >> c;
  if(a>b){
    t=a;
    a=b;
    b=t;
  }
  if(b>c){
    t=c;
    c=b;
    b=t;
  }
  cout << a+b << endl;
}


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

using namespace std;

int FB[2048][2048];
int FW[2048][2048];
int dp[2048][2048];
int balls[4096];
int main() {
	int N; cin >> N;
	for (int i = 0; i < 2 * N; i++) {
		string s; cin >> s;
		int x; cin >> x;
		if (s == "B") balls[i] = -x;
		else balls[i] = x;
	}

	// Build all black
	for (int i = 0; i < 2 * N; i++) {
		if (balls[i] > 0) continue;
		int x = -balls[i];
		for (int j = 0; j < i; j++) if (balls[j] > 0) FB[x][balls[j]] = 1;
		for (int j = N; j >= 0; j--) FB[x][j] += FB[x][j + 1];
	}

	// Build all while
	for (int i = 0; i < 2 * N; i++) {
		if (balls[i] < 0) continue;
		int x = balls[i];
		for (int j = 0; j < i; j++) if (balls[j] < 0) FW[x][-balls[j]] = 1;
		for (int j = N; j >= 0; j--) FW[x][j] += FW[x][j + 1];
	}

	int base = 0;
	for (int i = 0; i < 2 * N; i++) {
		if (balls[i] < 0){
			for (int j = 0; j < i; j++) if (balls[j] < 0 && balls[j] < balls[i])  base += 1;
		}
		else{
			for (int j = 0; j < i; j++) if (balls[j] > 0 && balls[j] > balls[i])  base += 1;
		}
	}

	for (int i = N; i >= 1; i--) for (int j = N; j >= 1; j--) {
		dp[i][j] = min(FB[i][j] + dp[i + 1][j], FW[j][i] + dp[i][j + 1]);
	}
	cout << dp[1][1] + base << endl;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int ans=0;
  if(N==1) ans=M;
  else{
      for(int i=1; i<=M/N; i++){
        if((M-N*i)%i==0) ans=i;
      }
  }
  cout << ans << endl;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c == 17){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main(){
  string s, t;
  cin >> s >> t;
  int sl = s.size();
  int tl = t.size();
  int dp[sl+1][tl+1];
  for(int i = 0; i <= sl; i++){
    for(int j = 0; j <= tl; j++){
      if(i == 0 or j == 0){
        dp[i][j] = 0;
      }
      else if(s[i-1] == t[j-1]){
        dp[i][j] = 1+dp[i-1][j-1];
      }
      else{
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  int i = sl, j = tl;
  vector<char> str;
  while(i > 0 && j > 0){
    if(s[i-1] == t[j-1]){
      str.push_back(s[i-1]);
      i--;
      j--;
    }
    else{
    	if(dp[i][j-1] > dp[i-1][j]) j--;
    	else i--;
    }
            
  }
  reverse(str.begin(), str.end());
  for(int i = 0; i < str.size(); i++){
    cout << str[i];
  }
  cout << "\n";
}

Measured memory_bytes: 38696
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  ll N;
  cin>>N;
  vector<ll> A(1<<N);
  cin>>A;
  sort(A.begin(),A.end(),greater<ll>());
  vector<ll> nx(1<<N,0);
  vector<bool> used(1<<N,false),usn(1<<N,false);
  used[0]=true;
  for(int i=0;i<N;i++){
    ll nx=0;
    for(int j=0;j<(1<<N);j++){
      if(used[j]){
        while(nx>=(1<<N) || A[nx]>=A[j] || used[nx]){
          nx++;
          if(nx>=(1<<N)){cout<<"No"<<endl; return 0;}
        }
        usn[nx]=true;
        usn[j]=true;
        nx++;
      }
    }
    swap(usn,used);
  }
  cout<<"Yes"<<endl;
  
  return 0;
}


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

using namespace std;

const int MOD=1e9+7;
const double PI=3.14159265359;



int n,k1,k2;

int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<long long> v(n), cs(n);
    for(auto&i:v)cin>>i;
    cs[0]=v[0];
    for(int i=1; i<n; i++){
        cs[i]=cs[i-1]+v[i];
    }
    
    
    map<long long,long long> m;
    for(auto i:cs){
        auto it=m.find(i);
        if(it==m.end()){
            m[i]=1;
        }
        else{
            it->second++;
        }
    }
    long long ans=0;
    for(auto p:m){
        ans+=p.second*(p.second-1)/2;
        if(!p.first) ans+=p.second;
    }
    cout<<ans;
    
    
    return 0;
    
    
}


Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		if(A < 1200) {
			System.out.println("ABC");
		}
		else {
			System.out.println("ARC");
		}
	}
}

Measured memory_bytes: 35636
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ll n, a, b;
    while(cin>>a>>b>>n){
        ll ans=0;
        ans=a*(n)/b-a*((n)/b);
        for(ll i=1, j=b-1; i<=b&&j<=n; ++i,j+=b){
        	ans=max(ans, a*(j)/b-a*(j/b));
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
def main():
    n = int(input())
    abc_list = []
    for i in range(n):
        abc_list.append(list(map(int, input().split())))
    dp = [[0] * 3 for i in range(n)]
    dp[0][0] = abc_list[0][0]
    dp[0][1] = abc_list[0][1]
    dp[0][2] = abc_list[0][2]
    # print(dp)
    for i in range(1, n):
        dp[i][0] = abc_list[i][0] + max(dp[i - 1][1], dp[i - 1][2])
        dp[i][1] = abc_list[i][1] + max(dp[i - 1][0], dp[i - 1][2])
        dp[i][2] = abc_list[i][2] + max(dp[i - 1][0], dp[i - 1][1])
        # print(dp)
    print(max(dp[-1]))
        
if __name__ == "__main__":
    main()

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

int main(void) {
  int N;
  cin >> N;
  int four = 0;
  int two = 0;
  int others = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 4 == 0)
      four++;
    else if (a % 2 == 0)
      two++;
    else
      others++;
  }
  others += (two ? 1 : 0);
  if (four >= others - 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define N 10010
using namespace std;
int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	printf("%d",max(k-(n-m),0));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, h, w, a, b, dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, ans = 1e9;
  scanf("%lld%lld%lld", &h, &w, &k);
  char s[h][w + 10];
  queue< pair<ll, ll> > q;
  pair<ll, ll> p, d[h][w], t = make_pair(1, 1);
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) d[i][j].first = d[i][j].second = 1e9;
  for(i = 0; i < h; ++i) {
    scanf("%s", s[i]);
    for(j = 0; j < w; ++j) if(s[i][j] == 'S') 
      q.push(make_pair(i, j)), d[i][j].first = d[i][j].second = 0;
  }
  while(q.size()) {
    p = q.front(), q.pop();
    a = p.first, b = p.second;
    p = d[a][b];
    if(p.second < k) p.second++;
    else p.first++, p.second = 1;
    if(!(a * b) || a == h - 1 || b == w - 1) {
      if(ans > d[a][b].first) ans = d[a][b].first;
      continue;
    }
    if(d[a][b].first) {
      for(i = 0; i < 4; ++i) if(d[a + dx[i]][b + dy[i]] > p) {
        d[a + dx[i]][b + dy[i]] = p;
        q.push(make_pair(a + dx[i], b + dy[i]));
      }
    } else {
      for(i = 0; i < 4; ++i) {
        if(s[a + dx[i]][b + dy[i]] == '.') {
          if(d[a + dx[i]][b + dy[i]] > p) 
            d[a + dx[i]][b + dy[i]] = p, q.push(make_pair(a + dx[i], b + dy[i]));
        } else if(d[a + dx[i]][b + dy[i]] > t)
          d[a + dx[i]][b + dy[i]] = t, q.push(make_pair(a + dx[i], b + dy[i]));
      }
    }
  }
  printf("%lld", ans + 1);
  return 0;
}

Measured memory_bytes: 11520
N=int(input())
#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(N)] for i in range(N)]

for i in range(N):
    T=list(map(int,input().split()))
    if T[1]!=0:
        
        for j in range(T[1]):
            S[i][T[j+2]-1]=1

for i in S:
    print(*i)



Measured memory_bytes: 6388
# ABC076a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

r = int(input())
g = int(input())
# (r+ans)/2=g
# r/2+ans/2=g
# ans/2=g-r/2
# ans=2*g-r
print(2*g-r)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int arr[N];
    for(int i = 0; i < N; i++){
        cin >> arr[i];
    }
    
    int cnt = 0;
    
    for(int i = 0; i < N-1;i++){
        int mini = i;
        for(int j = i+1; j < N; j++){
            if(arr[j] < arr[mini]) {
                mini = j;
            }
        }
        if(i != mini) {
            int tmp = arr[i];
            arr[i] = arr[mini];
            arr[mini] = tmp;
            cnt++;
        }
    }
    
    for(int i = 0; i < N; i++){
        if(i != N-1) cout << arr[i] << " ";
        else cout << arr[i] << endl;
    }
    
    cout << cnt << endl;
}




Measured memory_bytes: 3120
using System;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[] h=new long[s[0]];
		long a=0,c=s[1]-s[2],ub=0,lb=1;
		for(int i=0;i<s[0];i++){
			h[i]=long.Parse(Console.ReadLine());
			ub=Math.Max(ub,h[i]);
		}
		long mid=(ub+lb)/2,ans=0;
		while(ub-lb>1){
			a=0;
			for(int i=0;i<s[0];i++){
				long d=h[i]-mid*s[2];
				if(d>0){a+=d/c+(d%c==0?0:1);}
			}
			if(mid>=a){ub=mid;ans=mid;}
			else{lb=mid;}
			mid=(ub+lb)/2;
		}
		a=0;
		for(int i=0;i<s[0];i++){
			long d=h[i]-mid*s[2];
			if(d>0){a+=d/c+(d%c==0?0:1);}
		}
		if(mid>=a){ans=mid;}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 17884
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    // 整数の入力
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int Z = sc.nextInt();

    // 出力
    System.out.println(Z + " " + X + " " + Y);
  }
}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
 int n;
 long long ans = 1;
 cin >> n;
 vector<long long>table(n);

 for (int i = 0; i < n; i++) {
   cin >> table.at(i);
   if (table.at(i) == 0) {
     cout << 0 << endl;
     return 0;
   }
 }
   
   for (int i = 0; i < n; i++) {
      long long k = table.at(i);

     if (1000000000000000000 / k >= ans) {
        ans *= table.at(i);
      }
      else {
        cout << -1 << endl;
        return 0;
      }
   }
   cout << ans << endl;
}



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

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    long n;

    int Length(long x)
    {
        if (x == 0) return 1;

        var length = 0;
        while (true)
        {
            if (x == 0) return length;

            x = x / 10;
            length++;
        }
    }

    int F(long x, long y)
    {
        return Math.Max(Length(x), Length(y));
    }

    int Solve()
    {
        var m = int.MaxValue;

        for (var x = 1L; x * x <= n; x++)
        {
            if (n % x != 0) continue;
            var y = n / x;
            m = Math.Min(m, F(x, y));
        }

        return m;
    }

    public void Run()
    {
        n = ReadLine(long.Parse)[0];
        WriteLineOne(Solve());
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
	int n;
	int sum = 0;
	int V[50];
	int C[50];
	int sub[50];

	cin >> n;
	REP(i, n) cin >> V[i];
	REP(i, n) cin >> C[i];

	REP(i, n){
		sub[i] = V[i] - C[i];
		if(sub[i] > 0) sum += sub[i];
	}
	cout << sum << endl; 
}

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

int find(int a, vector<int>&nums);

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>nums(n);
	vector<pair<int, int>>pairs(m);
	vector<int>uf(n);
	for (int i = 0; i < n; i++)uf[i] = i;
	for (int i = 0; i<n; i++) {
		cin >> nums[i];
		nums[i]--;
	}
	for (int i = 0; i<m; i++) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
        tmp1--;
        tmp2--;
		int p1 = find(tmp1, uf), p2 = find(tmp2, uf);
		if (p1 != p2) {
			uf[p2] = p1;
		}
	}
	int c = 0;
	for (int i = 0; i<n; i++) {
		if (find(i, uf) == find(nums[i], uf))c++;
	}
	cout << c;
	return 0;
}

int find(int a, vector<int>&nums) {
	if (nums[a] == a)return a;
	else {
		return nums[a] = find(nums[a], nums);
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define REP(i, n) FOR(i, 0, n)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
#define YES() printf("yes\n")
#define NO() printf("no\n")
 
#define N 112345
#define T 1005
int n, m;
ll t;
ll a[N], p[T], q[T], r[T];
void mul(ll *x, ll *y){
    fill(r, r+T, 0);
    REP(i, t){
        REP(j, t){
            ll s=x[i]+y[j];
            // printf("s[%lld]+t[%lld]=%lld+%lld\n", i, j, x[i], y[j]);
            if(x[i]%t!=i) continue;
            if(y[j]%t!=j) continue;
            LAR(r[(i+j)%t], s);
    }
    }
    REP(i, t) x[i]=r[i];
}
 
int main(){
    scanf("%d%d%lld\n", &n, &m, &t);
    REP(i, n) scanf("%lld", a+i);
    fill(p, p+T, 0);
    fill(q, q+T, 0);
    REP(i, n) LAR(q[a[i]%t], a[i]);
    while(m){
        if(m%2) mul(p, q);
        // REP(i, t) printf("%2lld ", q[i]); printf("\n");
        // REP(i, t) printf("%2lld ", p[i]); printf("\n");
        mul(q, q);
        m/=2;
    }
    for(int i=t-2; i>=0; i--) LAR(p[i], p[i+1]);
    int q;
    scanf("%d", &q);
    REP(i, q){
        ll x, y;
        scanf("%lld%lld", &x, &y);
        if(p[x]%t>=x && p[x]>=t*y) YES();
        else NO();
    }
}

Measured memory_bytes: 3920
#include <stdio.h>
int main(){
char S[10];
  scanf("%s",S);
  
  if((S[0]=='A' || S[1]=='A' || S[2]=='A') && (S[0]=='B' || S[1]=='B' || S[2]=='B')){
    printf("Yes\n");
  }else{
  printf("No\n");
  }
   return 0;
}

Measured memory_bytes: 1636
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  int sum = 0, a;
  for(int i = 0; i < M; i++) {
    cin >> a;
    sum += a;
  }
  cout << max(-1, N - sum) << endl;
  return 0;
}


Measured memory_bytes: 3592