akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,M;
	int[] a,b,c,d;
	public void solve() {
		N = nextInt();
		M = nextInt();
		a = new int[N];
		b = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
			b[i] = nextInt();
		}
		c = new int[M];
		d = new int[M];
		for(int i = 0;i < M;i++){
			c[i] = nextInt();
			d[i] = nextInt();
		}

		for(int i = 0;i < N;i++){
			int min = (int)1e9+7;
			int ans = -1;
			for(int j = 0;j < M;j++){
				if(min > Math.abs(a[i]-c[j]) + Math.abs(b[i]-d[j])){
					min = Math.abs(a[i] - c[j]) + Math.abs(b[i]-d[j]);
					ans = j;
				}
			}

			out.println(ans+1);
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21460
#include<iostream>
using namespace std;
string add(string a, string b)
{
  a=string(a.rbegin(),a.rend());
  b=string(b.rbegin(),b.rend());
  if(a.size()<b.size())a.swap(b);
  a+="0";
  while(a.size()!=b.size())b+="0";
  string r="";
  int digit=0;
  for(int i=0;i<a.size();i++){
    int t=a[i]-'0'+b[i]-'0'+digit;
    if(t>=10){
      t-=10;
      digit=1;
    }else{
      digit=0;
    }
    r.insert(r.begin(),t+'0');
  }
  if(r[0]=='0')r=r.substr(1,r.size()-1);
  return r;
}
int main()
{
  string s;
  int ans;
  while(cin>>s){
    ans=-1;
    for(int i=0;i<10;i++){
      string t=s;
      while(t.find("X")!=string::npos)t[t.find("X")]='0'+i;
      string a,b,c;
      a=t.substr(0,t.find("+"));
      b=t.substr(t.find("+")+1,t.find("=")-t.find("+")-1);
      c=t.substr(t.find("=")+1,t.size()-t.find("=")-1);
      if((a.size()>1&&a[0]=='0') || (b.size()>1&&b[0]=='0') || (c.size()>1&&c[0]=='0'))continue;
      if(add(a,b)==c)ans=i;
    }
    if(ans==-1)puts("NA");
    else cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    ll n;
    cin>>n;
    
    ll p = 1;
    
    int ans = 0;
    while(p*2-1<=n){
        p*=2;
        ans++;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define PP pair<P,P>
using namespace std;

const int mod = 998244353;
// const int mod=1000000007
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// 出力は.xで！！！！

int main(){
  int n,s; cin >> n >> s;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<vector<mint> > dp(3002,vector<mint>(3002,0));
  rep(i,3003) dp[0][i]=0;
  dp[0][0]=1;
  for(int i=1; i<=n; i++){
    rep(j,s+1){
      dp[i][j]+=dp[i-1][j]*2;
      if(j+a[i-1]<=s) dp[i][j+a[i-1]]+=dp[i-1][j];
    }
  }
  cout << dp[n][s].x << endl;
return 0;
}


Measured memory_bytes: 73752
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
    int a,b;
    cin >> a >> b;
    if(a<b) swap(a,b);
    int ans = a*b;
    while(a%b!=0){
        int c = a%b;
        a = b;
        b = c;
    }
    ans /= b;
    cout << ans <<endl;
    return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;

constexpr lli plusScore = (lli)1e6;
constexpr lli D = 365;
constexpr lli asize = 26;
constexpr lli maximumNone = 40;
constexpr lli minimumNone = 5;

array<lli, asize> C;
array<lli, asize> Cnum;

array<array<lli, asize>, D> S;
array<array<lli, asize>, D> Snum;
array<bool, D> needChange;

lli calcScore(const vector<lli>& t) {
	vector<lli> last_open(asize, -1);
	lli score = 0;
	for (int i = 0; i < D; i++) {
		score += S[i][t[i]];
		//if (last_open[t[i]] != -1 && (i - last_open[t[i]]) < minimumNone) {
		//	needChange[i] = true;
		//}
		last_open[t[i]] = i;
		for (int j = 0; j < asize; j++) {
			score -= C[j] * (i - last_open[j]);
		}
		//cout << score << "\n";
	}

	return score;
};

int main() {
	srand((unsigned int)time(NULL));
	chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now();
	cin.tie(0);
	ios::sync_with_stdio(false);
	int devNull;
#define EXAMPLE
#ifdef EXAMPLE
	{
		ifstream ifs("sample2.in");
		ifs >> devNull;
		for (lli& i : C)ifs >> i;
		for (auto& arr : S) {
			for (lli& i : arr) {
				ifs >> i;
			}
		}
		ifs.close();
	}
#elif

	{
		cin >> devNull;
		for (lli& i : C)cin >> i;
		for (auto& arr : S) {
			for (lli& i : arr) {
				cin >> i;
			}
		}
	}
#endif
	for (bool& b : needChange)b = false;
	iota(Cnum.begin(), Cnum.end(), 0);
	sort(Cnum.begin(), Cnum.end(), [&](lli l, lli r) {
		return C[l] < C[r];
	});


	for (lli i = 0; i < D; i++) {
		iota(Snum[i].begin(), Snum[i].end(), 0);
		sort(Snum[i].begin(), Snum[i].end(), [&](lli l, lli r) {
			return S[i][l] < S[i][r];
		});
	}

	vector<lli> T(D);

	for (lli i = 0; i < D; i++) {
		T[i] = Snum[i][0];
	}

	lli beforescore = calcScore(T);
	lli cnt = 0;

	while (chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now().time_since_epoch() - start.time_since_epoch()) < chrono::duration_cast<chrono::milliseconds>(1950ms)) {
		lli changeday = rand() % D;
		vector<lli> tt = T;
		for (lli i = 0; i < asize; i++) {
			tt[changeday] = i;
			
			if (calcScore(T) < calcScore(tt)) {
				if (cnt % 1000 == 0) {
					debug(calcScore(tt));
				}
				T[changeday] = i;
			}
		}
		cnt++;
	}


	for (lli i : T) {
		cout << i + 1 << "\n";
	}
	debug(beforescore + plusScore);
	debug(cnt);
	cout << flush;
	return 0;
}



Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define V vector<int>
#define VLL vector<long long>
#define VV vector<vector<int>>
#define be(x) begin(x),end(x)
#define For(a) for(int i=0;i<a;i++)
#define Forin(a,b) for(int j=a;j<b;j++)
#define len(a) a.size()
#define pb push_back 
#define mp make_pair

ll solve();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    
    /*int t;
    cin>>t;
    while(t--)
    {
        //solve();cout<<"\n";*/
        cout<<solve()<<endl;
    //}
return 0;
}
ll solve()
{
   int n,k,t;
   cin>>n>>k>>t;
   int i=0;
   while(n>0)
   {
       n-=k;
       i++;
   }
   return i*t;
   
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
#include <string>



//const int MAX_N = 55;
int N;

int main(int argc, char **argv) {
    std::cin >> N;

    std::vector<int> ret;

    if (N == 3) {
        ret.push_back(2); ret.push_back(5); ret.push_back(63); 
    } else if (N == 4) {
        ret.push_back(2); ret.push_back(5); ret.push_back(20); ret.push_back(63); 
    } else {
        // N >= 5;
        int current_sum = 0;
        int group_num = N / 4;
        int rest = N % 4;

        for (int i = 0; i < group_num; i++) {
            ret.push_back(6*i + 2);
            ret.push_back(6*i + 3);
            ret.push_back(6*i + 4);
            ret.push_back(6*i + 6);
        }

        if (rest == 3) {
            if (group_num % 2 == 0) {
                ret.push_back(6*group_num + 2);
                ret.push_back(6*group_num + 4);
                ret.push_back(6*group_num + 6);
            } else {
                ret.push_back(6*group_num + 2);
                ret.push_back(6*group_num + 3);
                ret.push_back(6*group_num + 4);
            }
        } else if (rest == 2) {
            if (group_num % 2 == 0) {
                ret.push_back(6*group_num + 2);
                ret.push_back(6*group_num + 4);
            } else {
                ret.push_back(6*group_num + 3);
                ret.push_back(6*group_num + 6);
            }
        } else if (rest == 1) {
            if (group_num % 2 == 0) {
                ret.push_back(6*group_num + 6);
            } else {
                ret.push_back(6*group_num + 3);
            }
        } else {
            if (group_num % 2 != 0) {
                ret.resize(4*(group_num - 1));
                ret.push_back(6*(group_num - 1) + 2);
                ret.push_back(6*(group_num - 1) + 4);
                ret.push_back(6*(group_num - 1) + 6);
                ret.push_back(6*(group_num - 1) + 12);
            }
        }
    }

    for (int i = 0; i < ret.size(); i++) {
        std::cout << ret[i] << " ";
    }

    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 512
//
//  main.cpp
//  Pana2020C
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    long long a,c,b,positive;
    long long left,right;
    cin>>a>>b>>c;
    right=(c-a-b)*(c-a-b);
    left=4*a*b;
    positive=c-a-b;
    if (left<right&&0<positive) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    n -= n/k*k;

    ll ans = min(n, abs(n-k));

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

string s;
int w[300005];
int e[300005];

int main()
{
	int n;
	cin>>n;
	cin>>s;
	
	int l = s.size();
	
	if(s[0]=='W') w[0]=1;
	if(s[l-1]=='E') e[l-1]=1;
	for(int i=1;i<l;i++)
	{
		w[i]=w[i-1];
		if(s[i]=='W') w[i]++;
	}
	for(int i=l-2;i>=0;i--)
	{
		e[i]=e[i+1];
		if(s[i]=='E') e[i]++;
	}
	
	int mi=min(e[1],w[l-2]);
	for(int i=1;i<l-1;i++)
	{
		mi=min(mi,w[i-1]+e[i+1]);
	}
	
	cout<<mi<<endl;
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {

		int x = 0;
		int y = 0;
		int z = 0;
		int[] m = new int[10000];
		int temp_m;
		int count;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for (count = 0; count >= 0; count++) {
			String str = br.readLine();
			int e = Integer.parseInt(str);
			if (e == 0) {
				break;
			}

			m[count] = e;

			for (int tempz = 0; tempz * tempz * tempz <= e; tempz++) {
				z = tempz;
			}

			for (int i = 0; z >= 0; i++) {
				for (int tempy = 0; tempy * tempy <= e - z * z * z; tempy++) {
					y = tempy;
				}
				x = e - z * z * z - y * y;
				// m[i] = x+y+z;
				temp_m = x + y + z;
				if (temp_m < m[count]) {
					m[count] = temp_m;
				}

				z--;
			}
		}
		for (int i = 0; i < count; i++) {
			System.out.println(m[i]);
		}
	}

}



Measured memory_bytes: 28556
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;++i) 
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vlli vector<long long int>
#define pb push_back
#define mp make_pair
#define all(c)  ((c).begin()), ((c).end())
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	int n,h,w;
	cin>>n>>h>>w;
	int a,b;
	int c=0;
	FOR(i,0,n){
		cin>>a>>b;
		if(a>=h&&b>=w){
			c++;
		}
	}
	cout<<c<<"\n";
}


Measured memory_bytes: 256
/* 
Hey there stalker....
 
█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█ 
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀
 
Like what you see?
*/
#include <bits/stdc++.h>
using namespace std;
 
#define fastIO ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define ld long double
#define lli long long int
#define p_b push_back
#define m_p make_pair
#define fs first
#define sc second
#define all(x) x.begin(),x.end()
#define fr(i,a,n) for(lli i=a; i<n; i++)
#define fre(i,a,n) for(lli i=a; i<=n; i++)
const lli mod = 1e9 + 7;
/*****************************************************/
lli w[105],v[105],dp[105][100001]={-1};
lli F(lli n,lli W)
{
    if(n==0 || W==0)
        return 0;
    if(dp[n][W]!=-1)
        return dp[n][W];
    if(w[n]>W)
    {
        return F(n-1,W);
    }
    else
    {
        lli a;
        dp[n][W]=max(F(n-1,W),v[n]+F(n-1,W-w[n]));
        return dp[n][W];
    }
}
int main()
{
    fastIO
    lli i,j,n,we;
    cin>>n>>we;
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    fr(i,0,105)
    {
        fr(j,0,100001)
            dp[i][j]=-1;
    }
    cout<<F(n,we);
    //cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
    return 0; 
} 

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

using namespace std;

int main(){
    int n; cin>>n;
    map<long long,long long> acumulados;
    vector<long long> numbers;
    numbers.resize(n);
    long long suma_total = 0;
    for(int i=0;i<n;i++){
        cin>>numbers[i];
        acumulados[numbers[i]]++;
    }
    for(auto x:acumulados){
        suma_total += (x.second*(x.second-1))/2; 
    }
    for(auto x:numbers){
        long long before = (acumulados[x]-1)*acumulados[x]/2;
        long long after = (acumulados[x]-2)*(acumulados[x]-1)/2; 
        cout << suma_total-before+after << '\n';
    }
    return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N,A,B,C;
	cin>>N>>A>>B>>C;
	int ans=INF;
	VI L(N);
	REP(i,N)cin>>L[i];
	SORT(L);
	do {
    	int a=L[0],b=L[1],c=L[2];
		int i=3,cnt=0;
		
		while(i<N){
			if(abs(C-c)>abs(C-(c+L[i]))+10 && abs(C-c)>10){c+=L[i];cnt+=10;}
			else if(abs(B-b)>abs(B-(b+L[i]))+10 && abs(B-b)>10){b+=L[i];cnt+=10;}
			else if(abs(A-a)>abs(A-(a+L[i]))+10 && abs(A-a)>10){a+=L[i];cnt+=10;}
			i++;
		}
		ans=min(ans,cnt+abs(A-a)+abs(B-b)+abs(C-c));
		
  	} while (std::next_permutation(L.begin(), L.end()));
	
	cout<<ans<<endl;
	
	return 0;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265
#define all(x) x.begin(),x.end()

// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}

int num(int l,int r,int d){
  if (l>r) return 0;
  return ((r-l)/d + 1);
}

int sum(vector<int> x){
  int ret = 0;
  for (auto y:x) ret = (ret+y)%MOD;
  return ret%MOD;
}

void solve()
{ 
  int a;
  cin>>a;
  cout<<a + a*a + a*a*a<<endl;
}


/*
  
*/
signed main(){
  int t = 1;
  // cin>>t;
  while (t--)
  solve();
}
// Check MOD values plox :(


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
struct Info{
    int num,p;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    int n;
    cin >> n;
    vector<vector<Info>> A(n);
    REP(i,n){
        int nn;
        Info inf;
        cin >> nn;
        REP(j,nn){
            cin >> inf.num >> inf.p;
            A[i].push_back(inf);
        }
    }
    int max= 0;
    for(int i=1; i<(1<<n); i++){

        int f[n]={0};
        int cnt= 0;
        int flag=1;
        // cout << i << ":" <<endl;
        for(int j=0; j<n; j++){    
            if(i & (1<<j)){ // j が i に入るかどうか
                f[j]= 1;
                cnt++;
            }
        }
        REP(j,n){
            if(f[j]==1){
                REP(k, A[j].size()){
                    if(f[A[j][k].num-1]==A[j][k].p){
                        f[A[j][k].num-1]= A[j][k].p;
                    } else{
                        flag= 0;
                        break;
                    }
                }
            }
        }
        // cout << endl;
        // cout << flag << endl;
        if(flag && max<=cnt) max= cnt;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
     int k,s,ans=0;
	cin>>k>>s;
	for (int x = 0; x <= k; ++x)
	{
		for (int y = 0;  y<= k; ++y)
		{
			int z = s-x-y;
					if(0<=z and z<=k){
						ans++;
					}
			
		}
	}
cout<<ans;
   return 0;
}


Measured memory_bytes: 3644
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int m = sc.nextInt();
	int[] a = new int[n];
	int[] b = new int[n];
	for(int i = 0; i < n; i++) {
		a[i] = sc.nextInt();
		b[i] = sc.nextInt();
	}
	int[] c = new int[m];
	int[] d = new int[m];
	for(int i = 0; i < m; i++) {
		c[i] = sc.nextInt();
		d[i] = sc.nextInt();
	}
	int tempD = 1000000000;
	int tempP = 0;
	for(int i = 0; i < n; i++) {
		tempD = 1000000000;
		for(int j = 0; j < m; j++) {
			if(Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]) < tempD) {
				tempP = j + 1;
				tempD = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
			}
		}
		System.out.println(tempP);
	}
}
}


Measured memory_bytes: 22728
class F:
    def __init__(self,n,mod):
        self.mod=mod
        self.f=[1]
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return 0 if k>n else self.f[n]*self.i[n-k]*self.i[k]%self.mod
n,k=map(int,input().split())
M=10**9+7
c=F(n,M).comb
for i in range(k):
    print(c(n-k+1,i+1)*c(k-1,i)%M)

Measured memory_bytes: 3444
/*

  The Number of Inversions

*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

long long count = 0;

int main(int argc, char const *argv[]) {

  int i;
  int num;
  scanf("%d",&num);
  int S[num];

  for( i = 0 ; i < num ; i++ ){
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,num);

  printf("%lld\n",count);

  return 0;
}

void merge(int *A, int left, int mid, int right){

  int n1,n2;
  int i,j,k;

  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1],R[n2+1];

  for( i = 0 ; i < n1 ; i++ ){
    L[i] = A[left+i];
  }

  for( i = 0 ; i < n2 ; i++ ){

    R[i] = A[mid+i];
  }

  L[n1] = INT_MAX;
  R[n2] = INT_MAX;

  i = 0;
  j = 0;

  for( k = left ; k < right ; k++ ){

    if( L[i] <= R[j] ){
      A[k] = L[i];
      i++;
    }else{
    
      count += (n1-i);

      A[k] = R[j];
      j++;
    }
  }

}

void mergeSort(int *A, int left, int right){

  int mid;

  if( left+1 < right ){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);

  }

}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
/*
typedef int weight;
struct edge
{
	int from, to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};

typedef vector<edge> Edges;
typedef vector<Edges> Graph;
*/
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


typedef int Weight;
typedef int Flow;

struct Edge {
	int src, dest, rev;
	Flow cap;
	Weight cost;
	bool operator < (const Edge &rhs) const
	{
		return cost > rhs.cost;
	}
	Edge(int s, int d) : src(s), dest(d) { ; }
	Edge(int s, int d, int c) : src(s), dest(d), cost(c) { ; }
	Edge(int s, int d, int r, Flow cp, Weight cst) : src(s), dest(d), rev(r), cap(cp), cost(cst) { ; }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int src, int dest, Flow cap)
{
	g[src].push_back(Edge{ src, dest, (int)g[dest].size(), cap, 0 });
	g[dest].push_back(Edge{ dest, src, (int)g[src].size() - 1, 0, 0 });
}

Flow dfs(Graph &g, vector<bool> &used, int v, int t, Flow f)
{
	if (v == t) return f;
	used[v] = true;
	for (Edge& e : g[v])
	{
		if (!used[e.dest] && e.cap > 0)
		{
			Flow d = dfs(g, used, e.dest, t, min(f, e.cap));
			if (d > 0)
			{
				e.cap -= d;
				g[e.dest][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

Flow ford_fulkerson(Graph &g, int s, int t)
{
	Flow flow = 0;
	for (;;)
	{
		vector<bool> used(g.size(), false);
		Flow f = dfs(g, used, s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	return (a%b ? gcd(a%b, b) : b);
}

int lcm(int a, int b)
{
	return a / gcd(a, b)*b;
}

int main()
{
	int m, n;
	while (cin >> m >> n, m)
	{
		Graph g(m + n + 2);
		REP(i, m) add_edge(g, 0, i + 2, 1);
		REP(i, n) add_edge(g, m + i + 2, 1, 1);
		int blue[501], red[501];
		REP(i, m) cin >> blue[i];
		REP(i, n) cin >> red[i];
		REP(i, m)REP(j, n)
		{
			if (gcd(blue[i], red[j]) > 1) add_edge(g, 2 + i, 2 + m + j, 1);
		}
		cout << ford_fulkerson(g, 0, 1) << endl;
	}
	return 0;
}

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

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, sum = 0;
pair<ll, ll> A[500000] = {}, B[500000] = {}, rui[500000] = {}, dp[100][10] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = true, check2 = false;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {

	//Code Line
	cin >> S;
	for (int i = 0; i < S.size(); i += 2) {
		if (S[i] == 'L')check = false;
	}
	for (int i = 1; i < S.size(); i += 2) {
		if (S[i] == 'R')check = false;
	}
	if (check)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define INF 1e9
#define MAX_V 101
using namespace std;
struct edge{int to, cap, rev;};
typedef map<int,int> M;
M G[MAX_V];
bool used[MAX_V];      //DFS??§?????§??????????????????????????°
void add_edge(int from,int to,int cap){G[from][to]+=cap;}

int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  
  for(M::iterator it=G[v].begin();it!=G[v].end() ;it++){
    int to=it->first;
    int &cap=it->second;
    if(!used[to] && cap > 0){
      int d = dfs(to ,t , min(f,cap));
      if(d > 0){
	cap -= d;
	G[to][v]+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    add_edge(a,b,c);
  }
  cout <<max_flow(0,n-1)<<endl;
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string s;
  cin >> s;
  int Q = nextInt();

  deque<int> deq;
  REP(i, s.size()) deq.push_back(s[i]);
  bool rev = false;
  REP(qi, Q) {
    int T = nextInt();
    if (T == 1) {
      rev = !rev;
    } else if (T == 2) {
      int F = nextInt();
      char ch; cin >> ch;
      if (F == 1) {
        if (!rev) deq.push_front(ch);
        else deq.push_back(ch);
      } else {
        if (!rev) deq.push_back(ch);
        else deq.push_front(ch);
      }
    }
  }

  if (rev) {
    reverse(ALL(deq));
    rev = false;
  }
  REP(i, deq.size()) {
    printf("%c", (char)deq[i]);
  }
  printf("\n");
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 1920
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = ns()
n = len(s)
b = s.count('0')
r = n - b
print(2 * min(b, r))

Measured memory_bytes: 11096
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll a;
  ll ans=0;
  rep(i,n){
    cin >> a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  pri(ans);


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

//snuke
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
  mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { mint res(*this); return res+=a; }
  mint operator-(const mint a) const { mint res(*this); return res-=a; }
  mint operator*(const mint a) const { mint res(*this); return res*=a; }
  mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { mint res(*this); return res/=a; }
}; 
 
vector<ll> inv,fact,invfact;
void mod_build(int n){  
  fact.resize(n+1); inv.resize(n+1); invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1; inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return fact[n]*invfact[n-k]%mod; } }
ll comb(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod; }}
ll modpow(ll n,ll k){
  k%=mod-1; if(k<0)k+=mod-1;
  ll ret=1; while(k){ if(k&1)ret=ret*n%mod; n=n*n%mod; k>>=1; }
  return ret;
}
ll modinv(ll a){ return modpow(a, mod-2); }

vector<int> e[mx];
vector<int> x(mx,1);

int dfs(int n, int p){
  for(auto to:e[n])if(to!=p){
    x[n] += dfs(to,n);
  }
  return x[n];
}

int main() {
  mod_build(mx);
  int n;
  cin >> n;
  rep(i,n-1){
    int a,b; cin >> a >> b; a--; b--;
    e[a].emplace_back(b);
    e[b].emplace_back(a);
  }

  dfs(0,-1);
  mint ans=0;
  rep(i,n)for(auto to:e[i])if(to>i){
    int xe = min(x[to],x[i]);
    ans += (modpow(2,n-xe)-1)*(modpow(2,xe)-1);
  }
  ans += modpow(2,n)-1;  //-1:kara-graph
  ans -= modpow(2,n-1)*n;
  ans *= modinv(modpow(2,n));
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define maxn 200005
using namespace std;

const int mod = 1e9 + 7;

vector<pair<int, int>> v;
int p[maxn], dp[maxn] = {};
int H, W, n;

int power(int a, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) {
            ret = ret * a % mod;
        }
        n >>= 1;
        a = a * a % mod;
    }
    return ret;
}

int C(int x, int y) {
    return p[x] * power(p[x - y] * p[y] % mod, mod - 2) % mod;
}

int cal(pair<int, int> x, pair<int, int> y) {
    int X = y.F - x.F;
    int Y = y.S - x.S;
    return C(X + Y, X);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> H >> W >> n;
    p[0] = 1;
    for(int i = 1; i < maxn; i++) {
        p[i] = p[i - 1] * i % mod;
    }
    for(int i = 0; i < n; i++) {
        int r, c; cin >> r >> c;
        v.emplace_back(r, c);
    }
    dp[1] = 1;
    v.emplace_back(1, 1);
    v.emplace_back(H, W);
    sort(begin(v), end(v));
    for(int i = 1; i < (int)v.size(); i++) {
        dp[i] = cal(v[0], v[i]);
        for(int j = i - 1; j >= 0; j--) {
            if(v[j].S <= v[i].S) {
                dp[i] = (dp[i] - dp[j] * cal(v[j], v[i]) % mod + mod) % mod;
            }
        }
    }
    cout << dp[(int)v.size() - 1] << '\n';
    return 0;
}


Measured memory_bytes: 5328
//dp[??\???][???1????????°][???2????????°][???3????????°]???[???N????????°] = ?????£????????§???
//??¨??????DP??????????????????????????????????????????????????§?????¨??¨?£???£??????????????????????????¨?????§???????????????
//??\??????????????£????????????????????£???????????????????????????????´??????¨??¨?????£??±?????£???????????????
//???????????§???????????£?????§??????????????????????????°????????????????£???£????????????????????¨??????????????°?????????
//?????????????????????????????????????????????????????£??????????????????????£?????????¨????????????????§£?????§?????????
//(??\???????????§??????, ???i????????°??????i??§??¨????£???????????????????????????§??¨?????????, 0????????????????§????)

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

int n, d, x;
int p[10][10];

signed main()
{
	int i, j, k, m;
	
	cin >> n >> d >> x;
	for( i = 0; i < d; i++ ) for( j = 0; j < n; j++ ) cin >> p[i][j];
	
	int ans = x;
	static int dp[11][100001];	//dp[j][k] = ???0???j-1?????§???j???????????£???k????????£???,????????¨????????????????????§???
	for( i = 0; i < d - 1; i++ ){
		//i??\???????????????????????????, i+1??\?????????????????¨??¨?£????.
		//???????????? <= x??¨?????????????????????????????????????????§?????????????????¶??????
		for( j = 0; j <= n; j++ ) for( k = 0; k <= ans; k++ ) dp[j][k] = -100000000;
		
		dp[0][0] = 0;
		for( j = 0; j < n; j++ ){
			for( k = 0; k <= ans; k++ ){
				for( m = 0; k + p[i][j] * m <= ans; m++ ){
					dp[j+1][k + p[i][j] * m] = max(dp[j+1][k + p[i][j] * m], dp[j][k] + (p[i+1][j] - p[i][j]) * m);
				}
			}
		}
		int nextAns = -100000001;
		for( k = 0; k <= ans; k++ )
			nextAns = max(nextAns, dp[n][k] + ans);
		ans = nextAns;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const long long inf = 1e9+7;
const long long mod = 1e9+7;

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

    rep(i,k){
        cout<<"ACL";
    }

    cout<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

#define PI 3.141592653589793238

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
    double a,b,h,m;
    cin>>a>>b>>h>>m;

    double hourAngle = (h + m / 60) / 12;
    hourAngle *= 360;

    double minuteAngle = m / 60;
    minuteAngle *= 360;  

    double angle = minuteAngle - hourAngle;
    if(angle < 0)
      angle *= -1;

    double c = a * a + b * b - 2 * a * b * cos((angle * PI) / 180);
    c = sqrt(c);

    cout<<fixed<<setprecision(10)<<c;

   return 0;
}

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

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

    long long n;
    cin >> n;
    for(long long i = 1; i <= 3500; i++){
        for(long long j = 1; j <= 3500; j++){
            long long  a = n * i * j, b = 4 * i * j - n * i - n * j;
            if(b <= 0) continue;
            if(a % b == 0 and a / b > 0){
                cout << i << " " << j << " " << a / b << endl;
                return 0;
            }
        }
    }


    return 0;
}

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

const int DOWN = 0;
const int UP = 1;

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    vector<long long> nA = A;

    int res = 1<<29;
    for (int iter = 0; iter < 2; ++iter) {
        A = nA;
        int cur = DOWN;
        if (iter == 1) cur = UP;
        int con = 0;
        for (int i = 0; i + 1 < N; ++i) {
            if (cur == DOWN) {
                if (A[i] < A[i+1]) {
                    if (i + 2 < N && A[i+1] > A[i+2] && A[i] > A[i+2]) {
                        ++con;
                        ++i;
                        swap(A[i], A[i+1]);
                        cur = 1 - cur;
                        //cout << iter << ", " << i << ";; " << A[i] << ", " << A[i+1] << endl;
                    }
                    else {
                        ++con;
                        swap(A[i], A[i+1]);
                        //cout << iter << ", " << i << ";; " << A[i] << ", " << A[i+1] << endl;
                    }
                }
            }
            else {
                if (A[i] > A[i+1]) {
                    if (i + 2 < N && A[i+1] < A[i+2] && A[i] < A[i+2]) {
                        ++con;
                        ++i;
                        swap(A[i], A[i+1]);
                        cur = 1 - cur;
                        //cout << iter << ", " << i << ";; " << A[i] << ", " << A[i+1] << endl;
                    }
                    else {
                        ++con;
                        swap(A[i], A[i+1]);
                        //cout << iter << ", " << i << ";; " << A[i] << ", " << A[i+1] << endl;
                    }
                }
            }
            cur = 1 - cur;
        }
        res = min(res, con);
    }
    cout << res << endl;
}



Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define pb push_back
#define mp make_pair
#define M 10e9+7
int main(){
ll a,b;
cin>>a>>b;
for(ll i=10*b;i<=10*b+9;i++){
    ll ans=floor(0.08*i);
    if(a<=ans && ans<a+1){
        cout<<i;
        return 0;
    }
}
cout<<"-1";
}

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

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = 1001001001;

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  vector<int> dp(N);
  for (int i = 0; i < N; ++i) dp.at(i) = INF;
  
  dp.at(0) = 0;
  dp.at(1) = abs(A.at(1) - A.at(0));
  
  for (int i = 2; i < N; i++){
    chmin(dp.at(i), dp.at(i - 1) + abs(A.at(i) - A.at(i - 1)));
    chmin(dp.at(i), dp.at(i - 2) + abs(A.at(i) - A.at(i - 2)));
  }

  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		float result = 0;
		if(n == 1){
		    result = 1; 
		}else if(n%2 == 0){
		    result = (float)1/2;
		}else{
		    result = (float)(n/2 + 1)/n;
		}
		
		// 出力
        System.out.println(result);
	}
}

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

using namespace std;

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

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

ll N, A, B;

void solve() {
    cin >> N >> A >> B;
    ll mn = A * (N-1) + B;
    ll mx = B * (N-1) + A;
    if (A > B || (N == 1 && A != B)) cout << 0 << endl;
    else cout << mx - mn + 1 << endl;
}

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


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

using namespace std;

#define ll long long

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
void solve()
{
   long long a,b,c,d,e,f,g,ans;
   cin>>a>>b>>c>>d;
   e = (b/c)-((a-1)/c);
   f = (b/d)-((a-1)/d);
   long long p = lcm(c,d);
   g = (b/p)-((a-1)/p);
   ans = b-a+1-e-f+g;
   cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3616