akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int kaijo(int n){
    int fact = 1;
    if(n == 0) return 1;
    else{for(int i = 1; i <= n; i++){
        fact*=i;
    }
    }
    return fact;
}


/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

//for(int i = ; i < ; i++){}

int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<setprecision(10)<<w*h/2.0<<" ";
    if(x*2==w&&y*2==h) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll h, w;
  cin >> h >> w;
  string s[h];
  REP(i, h) cin >> s[i];

  int cnt;
  REP(i, h){
    REP(j, w){
      cnt = 0;
      if(s[i][j] == '#') cout << '#';
      else{
        REP(p, 3){
          REP(q, 3){
            if(i - 1 + p >= 0 && i - 1 + p <= h - 1 && j - 1 + q >= 0 && j - 1 + q <= w - 1){
              if(s[i - 1 + p][j - 1 + q] == '#') cnt++;
            }
          }
        }
        cout << cnt;
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0 && x+r <=w && y+r<= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3104
n=str(input())

t=list(n)

x=t.count('K')
y=t.count('U')
z=t.count('P')
w=t.count('C')

a=[x,y,z,w]

if x>0 and y>0 and z>0 and w>0:
    print(min(a))
else:
    print(0)



Measured memory_bytes: 5560
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main() {
	long long n, k;
	cin >> n >> k;

	long long min;
	if (n > k)min = k;
	else min = n;

	if (min > n % k)min = n % k;

	if (min > k - (n % k))min = k - (n % k);


	cout << min << endl;
	return 0;
}



//BBBBBBBBBBBBBBBBB
//int main() {
//	int n, m;
//	cin >> n >> m;
//	vector<int> a(n);
//	int sum = 0;
//	for (int i = 0;i < n;i++) {
//		cin >> a[i];
//		sum += a[i];
//	}
//	sort(a.rbegin(), a.rend());
//
//	if (a[m - 1] >= ((double)sum / (4 * m)))cout << "Yes" << endl;
//	else cout << "No" << endl;
//	return 0;
//}




//AAAAAAAAAAAAAAAAAAA
//int main() {
//	int x, y, z;
//	cin >> x >> y >> z;
//
//	cout << z << " " << x << " " << y << endl;
//
//
//	return 0;
//}

Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String a = s.next();
		char[] ar = a.toCharArray();
		loop: for (int i = 0;i < ar.length;i++) {
			int y = 0;
			for (int m = 0;m < ar.length;m++) {
				if(ar[i] == ar[m]) {
					y += 1;
				}
				if(m == ar.length-1) {
					if(y % 2 == 1) {
						System.out.println("No");
						return;
						//break loop;
					}
				}
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<queue>
#include<string>

using namespace std;

int W, H;
char t[25][25], s[25][25];
pair<int, int>pd;
int answer[25];
pair<int, int>alpha;

const int dx[] = {1,0,-1,0}, dy[]={0,-1,0,1}; //上下左右への移動

void bfs(int x, int y){

	queue<pair<int, int> >Q;
	Q.push(pair<int, int>(x,y));
	int cnt = 0;
	answer[cnt] = 0;
	while(!Q.empty()){
		pair<int, int> cur =  Q.front();

		Q.pop();
		
		
		for(int i = 0; i < 4; ++i){
			if(s[cur.first + dx[i]][cur.second + dy[i]] == 1){
				Q.push(pair<int, int>(cur.first + dx[i], cur.second + dy[i]));
				s[cur.first + dx[i]][cur.second + dy[i]] = 2;
				++answer[cnt];
			}
		}
		
	}
	cout << answer[cnt] + 1 << endl;
	cnt++;
	
}

int main(){
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			s[i][j] = 0;
		}
	}
	while(cin >> W >> H && W != 0){
		for(int i = 0; i < H; ++i){
			for(int j = 0; j < W; ++j){
				cin >> t[i][j];
				//cout << t[i][j]; // 入力の確認
				if(t[i][j] == '@'){
					alpha.first = i ;
					alpha.second = j;
					//cout << alpha.first; //確認用
				}else if(t[i][j] == '.'){
					s[i][j] = 1;
				}
			}
			//cout << endl; //入力の確認
			
		}
		bfs(alpha.first, alpha.second);
		for(int i = 0; i < H; ++i){
			for(int j = 0; j < W; ++j){
				s[i][j] = 0;
			}
		}
	}
	
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n,w,a,b;
  cin >> n >> w;
  vector<pair<ll,ll>> wv(n);
  for(ll i=0;i<n;i++){
    cin >> a >> b;
    wv.at(i) = make_pair(a,b);
  }
  vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
  for(ll i=0;i<n;i++){
    for(ll j=0;j<=w;j++){
      if(j<wv.at(i).first) dp.at(i+1).at(j) = dp.at(i).at(j);
      else{
        dp.at(i+1).at(j) = max(dp.at(i).at(j),dp.at(i).at(j-wv.at(i).first)+wv.at(i).second);
      }
    }
  }
  cout << dp.at(n).at(w) << endl;
}
      
                         
  





Measured memory_bytes: 80256
n = gets.to_i
k = gets.to_i
values = []

combinations = [true, false].repeated_combination(n).to_a

combinations.each do |combi|
  value = 1
  combi.each do |bool|
    if bool
      value *= 2
    else
      value += k
    end
  end
  values.push(value)
end

puts values.min

Measured memory_bytes: 1788
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#include<algorithm>
#include<memory.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N = 1e6 + 5, M = 1e9 + 7;
int n, a[N];
char op[N];
ll sm[N];
int main() {
	//	freopen("in.txt", "r", stdin);
		scanf("%d", &n);
		op[0] = '+';
		scanf("%d", &a[0]);
		sm[0] = a[0];
		for (int i = 1;i < n;i++)scanf(" %c%d", &op[i], &a[i]),sm[i]+=sm[i-1]+a[i];
		ll best = 0,pos=0,all=0;
		for (int i = n - 1;i >= 0;i--) {
			if (op[i] == '+')pos += a[i];
			else {
				best = max(best - a[i] + pos, -a[i] - pos + all);
				all += pos + a[i];
				pos = 0;
			}
		}
		best += pos;
		cout << best << endl;
}


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

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

struct Query {
  i64 u, d, c;
};

i64 n, m, q;
vector<vector<i64>> g;
int main() {
  cin >> n >> m;
  init_n(g, n + 1);
  for (i64 i = 0; i < m; ++i) {
    i64 a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cin >> q;
  vector<Query> qs;
  for (i64 i = 0; i < q; ++i) {
    i64 v, d, c;
    cin >> v >> d >> c;
    qs.push_back({ v, d, c });
  }

  vector<i64> ds(n + 1, -1), cs(n + 1);
  while (!qs.empty()) {
    auto q = qs.back();
    qs.pop_back();
    if (ds[q.u] >= q.d) continue;
    ds[q.u] = q.d;
    if (cs[q.u] == 0) cs[q.u] = q.c;
    queue<pair<i64, i64>> que;
    que.emplace(q.u, q.d);
    while (!que.empty()) {
      auto p = que.front();
      que.pop();
      i64 u, du; tie(u, du) = p;
      i64 dv = du - 1;
      if (dv >= 0) { 
        for (i64 v : g[u]) {
          if (ds[v] < dv) {
            ds[v] = dv;
            que.emplace(v, dv);
          }
          if (cs[v] == 0) cs[v] = q.c;
        }
      }
    }
  }
  for (i64 i = 1; i <= n; ++i) cout << cs[i] << '\n';
  return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans=0;
	cin >>n;
	VI h(n);
	rep(i,n) cin >>h[i];
	
	ll sm = accumulate(all(h), 0LL);
	int lg = *max_element(all(h));
	
	if(lg < sm - lg) cout <<"Yes\n";
	else cout <<"No\n";
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	int n; cin >> n;
	set<vector<int>> s;
	rep(i, n) {
		VI a(3); rep(j, 3)cin >> a[j];
		SORT(a);
		s.insert(a);
	}
	cout << n - sz(s) << endl;
}


Measured memory_bytes: 3244
n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n+1):
    a.append(3+2*a[-1])
    p.append(1+2*p[-1])
def f(l,x):
    if l==0:return int(x>=1)
    if x<=1+a[l-1]:
        return  f(l-1,x-1)
    else:return p[l-1]+1+f(l-1,x-2-a[l-1])
print(f(n,x))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    pair<int, int> pr[n];
    rep(i, 0, n) {
        int a, b;
        cin >> a >> b;
        pr[i] = {a, b};
    }

    sort(pr, pr + n);

    ll ans = 0;
    int num = 0;
    rep(i, 0, n) {
        rep(j, 0, pr[i].second) {
            ans += pr[i].first;
            num++;
            if (num == m) {
                cout << ans << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    cin >> n;
    vector<LL> l(n);
    LL ans=0;
    for(LL i=0; i<n; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    for(LL i=0; i<n; i++){
        for(LL j=i+1; j<n; j++){
            for(LL k=j+1; k<n; k++){
                if(l[i]==l[j] || l[j]==l[k]){
                    continue;
                }
                if(l[i]+l[j]>l[k]){
                    //cout << l[i] << " " << l[j] << " " << l[k] << endl;
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String X = sc.next();
    StringBuilder A = new StringBuilder();
    for (int i = 0; i < X.length(); i += 2) {
      A.append(X.charAt(i));
    }
    System.out.println(A);
  }
}


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

namespace AtCorderStudy
{
    class Program
    {
        static void Main(string[] args)
        {
            var BTCRate = 380000.0;
            var JPY = "JPY";
            var BTC = "BTC";
            var N = int.Parse(Console.ReadLine());
            var xs = new double[N];
            var us = new string[N];
            double sum = 0;
            for (int i = 0; i < N; i++)
            {
                var r = Console.ReadLine().Split(' ');
                var x = double.Parse(r[0]);
                var u = r[1];
                if(u==JPY)
                {
                    sum += x;
                }
                else if(u == BTC)
                {
                    sum += x * BTCRate;
                }
                //xs[i] = double.Parse(r[0]);
                //us[i] = r[1];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    int q;
    cin >> q;

    deque<char> ans;
    for (auto c : s) ans.push_back(c);

    bool r = false;
    for (int i=0; i<q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            r = !r;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            if ((!r && f==1) || (r && f==2)) {
                ans.push_front(c);
            } else {
                ans.push_back(c);
            }
        }
    }

    if(r) {
        while(!ans.empty()) {
            putchar(ans.back());
            ans.pop_back();
        }
    }
    while(!ans.empty()) {
        putchar(ans.front());
        ans.pop_front();
    }
    cout << endl;

}

Measured memory_bytes: 960
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const long long int  mx=1e9+7  ;
ll sum[200005];
int main()
{
 
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 
 int n,k;
 cin>>n>>k;
 
 sum[0]=0;
 
 for(int i=1;i<=n+1;i++)
 sum[i]=sum[i-1]+i;
 
 ll minsum,maxsum,ans=0;
 
 for(int i=k;i<=n+1;i++)
 {
    minsum = sum[i-1];
    
    maxsum = sum[n]-sum[n-i];
    
    ans =ans + (maxsum - minsum +1);
    
    ans %=mx;
 }
 
 cout<<ans%mx<<endl;
 
 return 0;
}


Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i =0;i<n;i++)
	cin >> v[i];
	vector<int> even,odd;
	for(int i =0;i<n;++i)
	{
		if(i%2)odd.push_back(v[i]);
		else even.push_back(v[i]);
	}
	sort(odd.begin(),odd.end());
	sort(even.begin(),even.end());

	vector<pair<int,int>>  ODD,EVEN;
	int l = 1;
	for(int i = 0;i<odd.size()-1;i++)
	{
		if(odd[i]!=odd[i+1])
		{
			ODD.push_back(make_pair(l,odd[i]));
			l = 1;
		}
		else
		{
			l++;
		}
	}
	ODD.push_back(make_pair(l,odd.back()));
	l=1;
	for(int i = 0;i<even.size()-1;i++)
	{
		if(even[i]!=even[i+1])
		{
			EVEN.push_back(make_pair(l,even[i]));
			l = 1;
		}
		else
		{
			l++;
		}
	}
	EVEN.push_back(make_pair(l,even.back()));
	sort(ODD.begin(),ODD.end(),greater<>());
	sort(EVEN.begin(),EVEN.end(),greater<>());

	if(ODD[0].second!=EVEN[0].second)
	{
		//cout<<E[0].first<<endl;
		cout<<n-ODD[0].first-EVEN[0].first<<endl;
		return 0;
	}
	if(ODD.size()==1&&EVEN.size()==1)
	{
		cout<<n/2<<endl;
		return 0;
	}
	if(ODD.size()==1)
	{
		cout<<n-EVEN[1].first<<endl;
		return 0;
	}
	if(EVEN.size()==1)
	{
		cout<<n-ODD[1].first<<endl;
		return 0;
	}
	cout<<min(n-EVEN[0].first-ODD[1].first,n-ODD[0].first-EVEN[1].first);
	return 0;
}

Measured memory_bytes: 2168
#!/usr/bin/env python3

import sys

line = input()
data = line.split('/')
#print(data)
if int(data[1]) < 4:
    print('Heisei')
    sys.exit(0)
elif 4 < int(data[1]):
    print('TBD')
    sys.exit(0)
if int(data[2]) <= 30:
    print('Heisei')
    sys.exit(0)
print('TBD')


Measured memory_bytes: 2940
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() -> i64 {
    input! {
        L : i64,
        R : i64,
    }
    if R - L > 3000 {
        return 0;
    }
    let mut res: i64 = 2019;
    for i in L..R+1 {
        for j in L..R+1 {
            if i == j {
                continue;
            }
            let t:i64 = (i * j) % 2019;
            res =
            if res > t {
                t
            } else {
                res
            };
        }
    }
    return res;
}


fn main() {
    println!("{}", solve());
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
  int N, Y;
  cin >> N >> Y;
  
  for (int x=0; x<=N; x++) {
    for (int y=0; y<=N-x; y++) {
      int z = N - x - y;
      if (10000 * x + 5000 * y + 1000 * z == Y) {
        cout << x << ' ' << y << ' ' << z << endl;
        return 0;
      }
    }
  }
  
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int N = scan.nextInt();
      	String s = scan.next();
      	int counterW = 0;
      	for(int i = 0; i < N; i++){
        	if(s.substring(i, i+1).contains(".")){
            	counterW++;
            }
        }
        int pointer = counterW;
      	int ans = counterW;
      	for(int i =0; i < N; i++){
        	if(s.substring(i, i+1).contains(".")){
            	pointer--;
            }
          	else{
            	pointer++;
            }
          	ans = Math.min(ans, pointer);
        }
      	System.out.print(ans);
    }
 
}

Measured memory_bytes: 41504
import sys
import math

input = sys.stdin.readline

def main():
    N, H = map(int, input().split())
    katana = []
    for _ in range(N):
        a, b = map(int, input().split())
        katana.append([a, 1])
        katana.append([b, 0])
    
    katana.sort(key=lambda x: x[0])
    nage = 0; ans = 0
    while True:
        tmp = katana.pop()
        nage += tmp[0]*(tmp[1] == 0)
        ans += (tmp[1] == 0)
        if nage >= H:
            print(ans)
            return
        if tmp[1] == 1:
            attack = tmp[0]
            break

    ans += math.ceil((H - nage)/attack)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 32920
n=input()
print(n+': ',end='')
n=int(n);d=2
while n%d==0 and n>3:
    print(d,end=' ')
    n//=d
d+=1
m=n//d
while m>=d:
    if(n%d==0):
        print(d,end=' ')
        n=m
    else:d+=2
    m=n//d
print(n)

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

int main() {
	
	int n;
	cin >> n;
	map<int, int> a;
	set<int> occ;
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		a[x]++;
		occ.insert(x);
	}
	
	int c = 0;
	for (set<int>::iterator x=occ.begin(); x!=occ.end(); x++) {
		int nu = *x;
		c = max(c, a[nu-1] + a[nu] + a[nu+1]);
		c = max(c, a[nu-2] + a[nu-1] + a[nu]);
		c = max(c, a[nu] + a[nu+1] + a[nu+2]);
	}
	cout << c << endl;
	
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  if(n*a > b) cout << b << endl;
  else cout << n*a << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
int main() {
	int A, B;
	char op;
	cin >> A >> op >> B;
	if (op == '+') {
		cout << A + B << "\n";
	}
	else {
		cout << A - B << "\n";
	}

	return 0;
}

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

ll beki(ll a, ll b) {
  if (b == 0) return 1;
  ll ret = beki(a, b / 2);
  ret = ret * ret % MOD;
  if (b & 1) ret = ret * a % MOD;
  return ret;
}

int main() {
  ll N;
  cin >> N;
  map<P, ll> mp;
  ll abzero = 0;
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      abzero++;
      continue;
    }
    ll g = gcd(a, b);
    mp[make_pair(a / g, b / g)]++;
  }
  ll ans = 1;
  set<P> visited;
  for (const auto& [k, _] : mp) {
    if (visited.count(k)) continue;
    ll nl = 0, nr = 0;
    P l1 = k;
    P l2 = make_pair(-k.first, -k.second);
    P r1 = make_pair(k.second, -k.first);
    P r2 = make_pair(-k.second, k.first);
    visited.insert(l1);
    visited.insert(l2);
    visited.insert(r1);
    visited.insert(r2);
    nl = mp[l1] + mp[l2];
    nr = mp[r1] + mp[r2];
    ans = (ans * (beki(2, nl) + beki(2, nr) - 1) % MOD) % MOD;
  }
  ans = (ans + abzero + MOD - 1) % MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 103392
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y>a.y;
        return max(x,-x)>max(a.x,-a.x);

    }

};
vector<long long> v[211111];
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
int o[211133];
int l[211112];
long long j[211113];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<long long> s;

//priority_queue<P> q;
queue<P> q;
string r;
//char r[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p,p1;
//v.resize(unique(v.begin(),v.end())-v.begin());
/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();



int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&o[t]);
        if(o[t]==o[t-1]) continue;
        l[t]=v[o[t]].size();
        v[o[t]].push_back(0);
    }
    j[0]=1;
    for(int t=1;t<=a;t++)
    if(o[t]!=o[t-1])
    {
        x=0;
        if(l[t]>0) x=v[o[t]][l[t]-1];
        j[t]=(x+j[t-1])%mod;
        //if(l[t]>0)
        //printf("@%lld %d %d\n",v[o[t]][l[t]-1],l[t],v[o[t]].size());
        if(l[t]>=1)
        v[o[t]][l[t]]=(v[o[t]][l[t]-1]+j[t-1])%mod;
        else v[o[t]][l[t]]=j[t-1];
        //printf("%lld %lld %lld\n",v[o[t]][l[t]],v[o[t]][l[t]-1],j[t-1]);
    }
    else j[t]=j[t-1];
    //for(int t=1;t<=a;t++)
     //   printf("%lld ",j[t]);
    printf("%lld",j[a]);
}



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

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;

	int r = n % 100;

	int q = n / 100;


    int count_5 = r / 5;
    int count_4 = (r % 5) / 4;
    int count_3 = ((r % 5) % 4) / 3;
    int count_2 = (((r % 5) % 4) % 3) / 2;
    int count_1 = ((((r % 5) % 4) % 3) % 2);

    //cout << count_5 <<" "<<count_4 <<" "<<count_3 <<" " << count_2<<" "<<count_1 <<"\n";

    int k = (count_1 * 101) + (count_2 * 102) + (count_3 * 103) + (count_4 * 104) + (count_5 * 105);

    if(k <= n){
        printf("1\n");
    }
    else{
        printf("0\n");
    }

}


Measured memory_bytes: 256
N = int(input())

t = [0]
x = [0]
y = [0]

f = 0 #NGの場合のフラグ

for count in range(N):
    i = list(map(int,input().split()))
    t.append(i[0])
    x.append(i[1])
    y.append(i[2])

n = 0

for i in range(1,N+1):    
    tdiff = t[i] - t[i-1] #時間の差であり、かつ動ける最大距離を表す
    ddiff = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) #t[i-1]の時からの距離の差

    #print(f'tdiff = {tdiff}')
    #print(f'ddiff = {ddiff}')

    if tdiff >= ddiff and (tdiff - ddiff) % 2 == 0: #まず最短距離で移動したときに移動できるか(=遠すぎないか)を検証する。移動できるのならば、あとは偶数ならその場で+1,-1を繰り返せばOKということになる。
        continue
    else:
        f = 1
        break

if f == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 11888
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;


int main(void){
  int n;
  cin>>n;
  long double x1,y1,x2,y2,x3,y3;
  for(int i=0;i<n;i++){
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    long double a,b,c,d,px,py,R,det;
    a=x3-x1;
    b=y3-y1;
    c=x2-x1;
    d=y2-y1;
    det=a*d-b*c;
    px=(a*a*d+b*b*d-b*c*c-b*d*d)/(2*det);
    py=(-1*c*a*a-c*b*b+a*c*c+a*d*d)/(2*det);
    R=sqrt(px*px+py*py);
    printf("%.3Lf %.3Lf %.3Lf\n",round((px+x1)*1000)/1000.0,round((py+y1)*1000)/1000.0,round(R*1000)/1000.0);
  }
  return 0;
}



Measured memory_bytes: 3316
N, M = map(int, input().split())
submits = [input().split() for _ in range(M)]

temp = {}
acs = set()
for no, result in submits:
  if result == 'AC':
    temp[no] = temp.get(no, 0)
    acs.add(no)
  else:
    if no not in acs:
      temp[no] = temp.get(no, 0) + 1
      
print(len(acs), sum([temp[no] for no in acs]))


Measured memory_bytes: 44864
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

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


#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define two pair<int,int>
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

signed main(){
  //input_from_file;
  int n,W; cin>>n>>W;
  int dp[n+1][W+1];
  memset(dp,0,sizeof dp);
  vector<int> w(n+1);
  vector<int> v(n+1);
  for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
  //for(int i=1;i<=W;i++) dp[0][i] = -1*oo;
  for(int i=1;i<=n;i++)
  for(int j=1;j<=W;j++){
   dp[i][j] = dp[i-1][j];
   if(j >= w[i]) dp[i][j] = max(dp[i-1][j-w[i]]+v[i],dp[i][j]);
  }
  cout<<dp[n][W]<<endl;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 998244353;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
	cerr << '{';
	__print(x.first);
	cerr << ',';
	__print(x.second);
	cerr << '}';
}
template <typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", ";
	_print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
	cerr << "[" << #x << "] = ["; \
	_print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------
#define N 405
int arr[N];
int pref[N];
int dp[N][N];
int solve(int l,int r){
    if(l>=r){
        return 0;
    }
    if(dp[l][r]>-1){
        return dp[l][r];
    }

    int ans=1e18;
    for(int p=l;p<r;p++){
        int temp;
        temp = solve(l,p) + solve(p+1,r) + (pref[p]-pref[l-1]) + (pref[r]-pref[p]);
        ans = min(ans,temp);
    }
    return dp[l][r] = ans;

}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n;
    cin>>n;
    pref[0]=0;
    Fo(i,1,n+1) {
        cin>>arr[i];
        pref[i] = pref[i-1] + arr[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(1,n);

}

Measured memory_bytes: 4968
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int q;
    cin>>q;
    vector<int>vec;
    for (auto i=0;i<q;++i) {
        int t;
        cin>>t;
        switch(t){
        case 0:
            cin>>t;
            vec.push_back(t);
            break;
        case 1:
            cin>>t;
            cout<<vec[t]<<"\n";
            break;
        default:
            vec.pop_back();
        }
    }
}


Measured memory_bytes: 3820
#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;}

void resolve() {
    int n,k;
    cin >> n >> k;
    int ans = 1;
    REP(i,0,n) {
        if (ans < k) ans *= 2;
        else ans += k;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int count = 0;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        if (i == 0) {
            cout << s[i];
        } else if (i == s.length() - 1) {
            cout << count;
            cout << s[i] << endl;
        } else {
            ++count;
        }
    }
    return 0;
}

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

char a[55][55];
bool flag=true;
int main() {
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>a[i];
	}
	
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]=='#'){
				if(a[i+1][j]=='#'||a[i-1][j]=='#'||
				a[i][j+1]=='#'||a[i][j-1]=='#');
				else flag=false;
			}
			
		}
	}
	
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
int main(){
  vector<vector<int> > fri(100001);
  int N,M;
  cin>>N>>M;
  int cost[100001],sign[100001];
  for(int i=1;i<=N;i++){
    cost[i]=99999999;
    sign[i]=-1;
  }
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    fri[a].emplace_back(b);
    fri[b].emplace_back(a);
  }
  cost[1]=0;
  sign[1]=1;
  queue<int> que;
  que.push(1);
  while(!que.empty()){
    int x=que.front();
    que.pop();
    for(int i=0;i<fri[x].size();i++){
      if(cost[fri[x][i]]>cost[x]+1){
        int y=fri[x][i];
        cost[y]=cost[x]+1;
        sign[y]=x;
        que.push(y);
      }
    }
  }
  int judge=0;
  for(int i=1;i<=N;i++){
    if(sign[i]==-1) judge++;
  }
  if(judge==0){
    cout<<"Yes"<<endl;
    for(int i=2;i<=N;i++){
      cout<<sign[i]<<endl;
    }
  }
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 10732
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int partition(vector<int>&a, int p, int r) {
	int x = a[r];
	int i = p-1;
	for (size_t j = p; j < r; j++)
	{
		if(a[j] <= x) {
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i+1], a[r]);
	return i+1;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int q = partition(a, 0, n-1);
	for (size_t i = 0; i < n; i++)
	{
		if(i) cout << " ";
		if(q == i) cout << "[";
		cout << a[i];
		if(q == i) cout << "]";
		// if(i == 0) {
		// 	if(i == q) {
		// 		cout << "[" << a[i] << "]";
		// 	} else {
		// 		cout << a[i];
		// 	}
		// 	continue;
		// }
		// if(i == q) {
		// 	cout << " " << "[" << a[i] << "]";
		// } else {
		// 	cout << " " << a[i];
		// }
	}
	cout << endl;
}



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

using namespace std;
vector<int> to[200005];
vector<int> ans;
void dfs(int v,int p=-1){
  for(int u:to[v]){
    if(u==p){
      continue;
    }
    else{
      ans[u]+=ans[v];
    }
    dfs(u,v);
  }
}
  
int main(){
  int n,q;
  cin >> n >> q;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  for(int i=0;i<q;i++){
    int p,x;
    cin >> p >> x;
    --p;
    ans[p]+=x;
  }
  dfs(0);
  for(int i=0;i<n;i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 23424
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	if(n%10==3)cout<<"bon";
	else if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon";
	else cout<<"hon"; 
	return 0;
}



Measured memory_bytes: 3656
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/15/20 19:44:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr int INV = 100;

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

  int n; cin>>n;
  vector<int> A(n), B(n);
  for (auto& a:A) cin>>a;
  for (auto& b:B) cin>>b;

  auto solve = [&]() -> ll {
    ll ans = (1ull<<52)-2;
    for (int i = 51; i >= 1; i--) {
      ans &= ~(1ull<<i);
      vector<vector<bool>> dp(51, vector<bool>(51, false));
      for (int i = 0; i <= 50; i++) {
        dp[i][i] = true;
        for (int m = 1; m <= i; m++) {
          if ((ans&(1ull<<m)) == 0) continue;
          dp[i][i%m] = true;
        }
        for (int j = 0; j < i; j++) {
          if (!dp[i][j]) continue;
          for (int k = 0; k < j; k++) {
            if (dp[j][k])
              dp[i][k] = true;
          }
        }
      }
      bool ok = true;
      for (int i = 0; i < n; i++) {
        ok &= dp[A[i]][B[i]];
      }
      if (!ok) {
        if (i == 51)
          return -1;
        ans |= 1ull<<i;
      }
    }
    return ans;
  };
  cout << solve() << endl;

  return 0;
}


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

int main(){
    while (true){
        int a, b;
        string op;
        cin >> a >> op >> b;
        if (op == "?") break;
        if (op == "+") cout << a+b << endl;
        if (op == "-") cout << a-b << endl;
        if (op == "*") cout << a*b << endl;
        if (op == "/") cout << a/b << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3116
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long m = 0;
        long[] array = new long[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextLong();
            if (m < array[i]) {
                m = array[i];
            }
        }
        long ans = 1;
        for (int i = 0; i < n; i++) {
            ans = lcm(ans, array[i]);
        }
        System.out.println(ans);
    }
    
    public static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
    public static long lcm(long a, long b) {
        return a/gcd(a,b)*b;
    }
}


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

int area(int d) {
        int sum=0;
        for(int i=0;i<600;i+=d){
                sum += d*i*i;
        }
        return sum;
}

int main(void){
        int d;
        while(cin >> d) {
        cout << area(d) << endl;
        }
        return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
const int MAX_N = 1000001;
 
const int N = 1000001;
int eulerPhi(int n) {
  static int lookup = 0, p[N], f[N];
  if (!lookup) {
    REP(i,N) p[i] = 1, f[i] = i;
    for (int i = 2; i < N; ++i) {
      if (p[i]) {
        f[i] -= f[i] / i;
        for (int j = i+i; j < N; j+=i)
          p[j] = 0, f[j] -= f[j] / i;
      }
    }
    lookup = 1;
  }
  return f[n];
}
 
int main(){
  static ll ans[MAX_N] = {};
  ans[1] = 2, ans[2] = 3;
  for(int i = 3; i < MAX_N; i++){
    ans[i] = ans[i - 1] + eulerPhi(i);
  }
  int T;
  cin>>T;
  while(T--){
    int n; cin>>n;
    cout<<ans[n]<<endl;
  }
  return 0;
}


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

namespace ConsoleApp11
{
    class Class20
    {
        static void Main()
        {
            int c = char.Parse(Console.ReadLine());
            c += 1;
            Console.WriteLine((char)c);
        }
    }
}


Measured memory_bytes: 13140
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function segTree(n){
  var l = n.length, u = l-1, x = 2, i, v;
  while(u)u >>= 1, x <<= 1;
  v = this.seg = Array(x-1).fill(0);
  this.l = x = (x >> 1) - 1;
  for(i = 0; i < l; i++)v[i+x] = n[i];
  for(i = x-1; i >= 0; i--)v[i] = segSolve(v[i+i+1],v[i+1<<1]);
}
function segSolve(a,b){
  return Math.max(a,b);
}
segTree.prototype={
  get:function(l,r){//[l,r)
    if(l >= r)return 0;
    var v = this.seg;
    return q(l,r,0,this.l+1,0);
    function q(l,r,x,y,i){
      if(l === x && r === y)return v[i];
      var m = x+y >> 1;
      if(m < r)if(l < m)return segSolve(q(l,m,x,m,i+i+1),q(m,r,m,y,i+1<<1));
      else return q(l,r,m,y,i+1<<1);
      return q(l,r,x,m,i+i+1);
    }
  },
  update:function(x,i){
    var v = this.seg;
    i += this.l;
    v[i] = x;
    for(i = i-1>>1; i >= 0; i = i-1>>1){
      v[i] = segSolve(v[i+i+1],v[i+1<<1]);
    }
  },
}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var q = next();
  var ans = xArray(0,q);
  var inf = 1e9;
  var lseg = new segTree(Array(2e5+1).fill().map((a,i)=>i));
  var rseg = new segTree(Array(2e5+1).fill().map((a,i)=>i));
  for(var i = 0; i < q; i++){
    var n = next();
    var l = [], r = [];
    for(var j = 0; j < n; j++){
      var [k,ll,rr] = nexts(3);
      if(ll === rr || k === n)ans[i] += ll;
      else if(ll > rr){
        ll -= rr;
        ans[i] += rr;
        l.push([k,ll]);
      }else{
        rr -= ll;
        ans[i] += ll;
        r.push([n-k,rr]);
      }
    }
    l.sort((a,b)=>b[1]-a[1]);
    r.sort((a,b)=>b[1]-a[1]);
    var lset = new Set(), rset = new Set();
    for(var j = 0; j < l.length; j++){
      var [u,v] = l[j];
      var id = lseg.get(0,u);
      if(id >= 0){
        lset.add(id);
        lseg.update(-1,id);
        ans[i] += v;
      }
    }
    for(var j = 0; j < r.length; j++){
      var [u,v] = r[j];
      var id = rseg.get(0,u);
      if(id >= 0){
        rset.add(id);
        rseg.update(-1,id);
        ans[i] += v;
      }
    }
    for(var j of lset)lseg.update(j,j);
    for(var j of rset)rseg.update(j,j);
  }
  return ans.join("\n");
}

Measured memory_bytes: 129548