akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int a = scanner.nextInt();
        int p = scanner.nextInt() + a * 3;
        writer.println(p / 2);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

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

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

int main()
{
	int A, B, C, D;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	
	while(true)
	{
		C -= B;
		if(C <= 0)
		{
			printf("Yes");
			break;
		}
		
		A -= D;
		if(A <= 0)
		{
			printf("No");
			break;
		}
	}
}


Measured memory_bytes: 3824
#include <stdio.h>

int main(void) {
	int n, x;
	int count = 0;
	int num1, num2, num3;

	while (1) {
		num1 = 1;
		num2 = 2;
		count = 0;
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)break;

		while (1) {
			if (num1 == n)break;
			num3 = x - num1 - num2;

			if (num1 < num2&&num2 < num3&&num3 <= n && num1 + num2 + num3 == x) {
				count++;
			}

			num2++;

			if (num2 > num3) {
				num1++;
				num2 = num1 + 1;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}


Measured memory_bytes: 2664
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[101],b[101],d[201][201],n;
main(){
	while(cin>>n,n){
		r(i,201)r(j,201)d[i][j]=1e8;
		r(i,n)cin>>a[i];
		r(i,n)cin>>b[i];
		r(i,n){
			if(a[i]==1){
				if(i>0&&a[i-1]==1)d[i][i-1]=0;
				if(i+1<n&&a[i+1]==1)d[i][i+1]=0;
			}
			if(a[i]==2){
				d[i][i-1]=0;
			}
			else{
				int j=i;
				if(j+2<n)d[i][j+100+2]=1;
				if(j+1<n)d[i][j+100+1]=1;
				d[i][j+100]=1;
			}
		}
		r(i,n){
			if(b[i]==1){
				if(i>0&&b[i-1]==1)d[i+100][i+100-1]=0;
				if(i+1<n&&b[i+1]==1)d[i+100][i+100+1]=0;
			}
			if(b[i]==2){
				d[i+100][i+100-1]=0;
			}
			else{
				int j=i;
				if(j+2<n)d[i+100][j+2]=1;
				if(j+1<n)d[i+100][j+1]=1;
				d[i+100][j]=1;
			}
		}
		r(k,201)r(i,201)r(j,201)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		int ans1=1e8,ans2=1e8,ans;
		if(b[n-1]!=2)ans1=min(d[0][n+100-1],d[100][n+100-1]);
		if(a[n-1]!=2)ans2=min(d[0][n-1],d[100][n-1]);
		ans=min(ans1,ans2);
		if(ans==1e8)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int w,h;
int si,sj;
int gi,gj;
VVI board;
const int INF = 1e9;
int dfs(int ci,int cj, VVI board,int turn){
  //cout << ci << " " << cj <<" " << turn << endl;
  if(turn == 10) return INF;
  int res = INF;
  rep(dir,4){
    int ni = ci, nj = cj;
    if(ci + dy[dir] < 0 || cj + dx[dir] < 0 || ci + dy[dir] >= h || cj + dx[dir] >= w || board[ci + dy[dir]][cj + dx[dir]] == 1) continue;
    while(true){
      ni += dy[dir];
      nj += dx[dir];
      if(ni < 0 || nj < 0 || ni >= h || nj >= w) break;
      if(board[ni][nj] == 3){

        res = min(res,turn + 1);
        break;
      }
      if(board[ni][nj] == 1){
        board[ni][nj] = 0;
        //cout <<  ci << " " << cj << "-> " << ni-dy[dir]<< " , "<< nj-dx[dir] << endl;
        res = min(res,dfs(ni-dy[dir],nj-dx[dir],board,turn+1));
        board[ni][nj] = 1;
        break;
      }
    }
  }
  return res;
}

void solve(VVI&board){
  rep(i,h)rep(j,w){
    if(board[i][j] == 2) si = i, sj = j;
    if(board[i][j] == 3) gi = i, gj = j;
  }
  int ans = dfs(si,sj,board,0);
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  while(true){
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    VVI board(h,VI(w));
    rep(i,h)rep(j,w) cin >> board[i][j];
    solve(board);
  }

  return 0;
}



Measured memory_bytes: 3092
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();

		double ans1 = r * r * Math.PI;
		double ans2 = 2 * r * Math.PI;
		System.out.printf("%.6f ", ans1);
		System.out.printf("%.6f", ans2);
	}
}

Measured memory_bytes: 28224
N, x = map(int, input().split())
A = list(map(int, input().split()))


cnt = 0
if A[0] > x:
    cnt += A[0] - x
    A[0] = x

for i in range(N - 1):
    sm = A[i] + A[i+1]
    if sm > x:
        diff = sm - x
        A[i+1] -= diff
        cnt += diff

print(cnt)


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

int N, Q;
long long int A[100005], X[100005];
long long int S[100005];

long long int L[100005];

vector<long long int >V;

int ORDER(long long int X, long long int val) {

	long long int W;
	if (X > val) { W = X - val; }
	else { W = val - X; }

	auto it1 = upper_bound(V.begin(), V.end(), X + W);
	auto it2 = lower_bound(V.begin(), V.end(), X - W);

	int num = it1 - it2;

	it1--;
	
	if (((*it1)-X) != (X-(*it2))) { return num; }
	else {
		
		if (val < X) { return num - 1; }
	}
	return num;
}

int POSSIBLE(long long int X,int M) {


	if (X > V[M-1]) { return -1; }

	if (ORDER(X, V[M-1]) >= N - M + 1) { return 1; }
	
	return -1;
	
}

int BINARY(long long int X) {

	int left, med, right;
	left = 1; right = N;
	
	while (right-left>1) {

		//cout << "left= " << left << "  right= " << right << endl;
		med = (right + left) / 2;

		if (POSSIBLE(X, med) == 1) {
			right= med;
		}
		else {
			left = med;
		}
	}
	//cout << "left= " << left << "  right= " << right << endl;
	return right;
}

int main(void) {

	cin >> N >> Q;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]);
	}

	for (int i = 1; i <= Q; i++) {
		cin >> X[i];
	}

	S[1] = A[1]; S[2] = A[2];

	for (int i = 3; i <= N; i++) {
		S[i] =A[i]+S[i - 2];
	}

	for (int i = N; i >= 1; i--) {
		L[i] = A[i] + L[i + 1];
	}


	long long int ans;

	for (int i = 1; i <= Q; i++) {

		int M = BINARY(X[i]);
		//cout << X[i] << "  " << BINARY(X[i]) << endl;
		if (M<=N/2+1) {
			ans = L[N/ 2+1];
		}
		else {
			ans = L[M] + S[M -(N-M+1)- 1];
		}

		cout << ans << endl;

	}


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

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<pair<ll, int>> A(N);
  rep(i, N) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(all(A), greater<pair<ll, int>>());
  vector<vector<ll>> dp(N+1, vector<ll>(N+1));
  rep(i, N+1) rep(j, N+1) {
    if(i) dp[i][j] = max(dp[i-1][j] + A[i+j-1].first * abs(i-1-A[i+j-1].second), dp[i][j]);
    if(j) dp[i][j] = max(dp[i][j-1] + A[i+j-1].first * abs(N-j-A[i+j-1].second), dp[i][j]);
  }
  ll mx = 0;
  rep(i, N+1) mx = max(dp[i][N-i], mx);
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 34672
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <queue>
#include <climits>
using namespace std;


#define MOD 1000000007
using ll = long long;

bool operator<(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	return a.first < b.first;
}

int grid[510][510];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M, Q; cin >> N >> M >> Q;
	for (int i = 0; i < M; ++i) {
		int L, R; cin >> L >> R;
		grid[L][R]++;
	}

	for (int i = 0; i <= N; ++i) {
		for (int j = 1; j <= N; ++j) {
			grid[i][j] += grid[i][j-1];
		}
	}
	for (int i=1; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) {
			grid[i][j] += grid[i-1][j];
		}
	}


	for (int i = 0; i < Q; ++i) {
		int p, q; cin >> p >> q;
		
		cout << grid[q][q] - grid[p-1][q] - grid[q][p-1] + grid[p-1][p-1] << endl;

		//cout << grid[q][q] << " " << grid[p-1][q] << " " << grid[q][p-1] << " " << grid[p-1][p-1] << endl;
	}
	int a; cin >> a;
	return 0;
}

Measured memory_bytes: 1920
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <random>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <limits>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <array>
#include <list>
#include <map>
#include <set>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define MP(x, y) make_pair((x),(y))
#define FI first
#define SE second
#define LOWB(x) (x & (-x))
#define UNIQUE(a) sort(ALL(a)), (a).erase(unique(ALL(a)), (a).end())
#define HEIGHT(n) (sizeof(int) * 8 - __builtin_clz(n)) //height of range n segment tree
#define INF 1e9
#define INF_LL 4e18
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
/*-----------------------------------*/

ll solve(ll a, ll b) {
  ll res = a + b;
  if (a > b) swap(a, b);
  if (b % a == 0) {
    ll k = b / a;
    res += (2l * k - 1) * a;
    return res;
  } else {
    ll k = b / a;
    res += 2l * k * a;
    ll nxta = b % a, nxtb = a;
    res += solve(nxta, nxtb);
    res -= (nxta + nxtb);
    return res;
  }
}

int main() {
  ll n, x;
  while (cin >> n >> x) {
    cout << solve(x, n-x) << endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;

mt19937 mt(736);

template<class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;


void Dijkstra(const vector<string> &field, vector<vector<int>> &ans)
{
	minheap<pair<int, pair<int, int>>> pq;

	for (int y = 0; y < (int) field.size(); y++)
		for (int x = 0; x < (int) field[y].size(); x++)
			if (field[y][x] == '#')
				pq.emplace(0, pair<int, int>{x, y});

	auto check = [&](int x, int y) {
		return 0 <= y && y < (int) field.size() && 0 <= x && x < (int) field[y].size() && ans[y][x] == -1;
	};

	while (!pq.empty())
	{
		int v, x, y;
		auto it = pq.top();
		pq.pop();

		v = it.first;
		x = it.second.first;
		y = it.second.second;

		if (!check(x, y))
			continue;

		ans[y][x] = v;

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

		for (int i = 0; i < 4; i++)
			if (check(x + dx[i], y + dy[i]))
				pq.emplace(v + 1, pair<int, int>{x + dx[i], y + dy[i]});
	}
}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int h, w;

	cin >> h >> w;

	vector<string> field(h);

	for (auto &row : field)
		cin >> row;


	vector<vector<int>> ans(h, vector<int>(w, -1));

	Dijkstra(field, ans);

	int num = 0;

	for (const auto &row : ans)
		num = max(num, *max_element(row.begin(), row.end()));

	cout << num << endl;
}


void gen(ostream &cout = std::cout)
{
	const int h = 1000, w = 1000;

	cout << h << ' ' << w << endl;

	uniform_int_distribution<int> uid(0, 1);

	for (int y = 0; y < h; y++)
	{
		for (int x = 0; x < w; x++)
			cout << (uid(mt) == 0 ? '#' : '.');
		cout << endl;
	}
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");
	stringstream ss;

	gen(ss);

	solve(ss);

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


Measured memory_bytes: 31468
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int h,a;
	cin >> h >> a;
	cout << (h+a-1) / a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char grid[1000][1000];
int steps[1000][1000];
queue<pair<int,int> > q;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	cin>>n>>m>>k;
	pair<int,int> stt;
	memset(steps,0x3f,sizeof(steps));
	for(int i=0;i<n;i++){
		scanf("%s",grid[i]);
		for(int j=0;j<m;j++){
			if(grid[i][j]=='S'){
				stt=make_pair(i,j);
			}
		}
	}
	steps[stt.first][stt.second]=0;
	q.push(stt);
	while(!q.empty()){
		stt=q.front();
		q.pop();
		if(steps[stt.first][stt.second]>=k)
			continue;
		for(int i=0;i<4;i++){
			int nx=stt.first+dx[i];
			int ny=stt.second+dy[i];
			if(nx>=0&&nx<n&&ny>=0&&ny<m){
				if(steps[nx][ny]>=1e9&&grid[nx][ny]!='#')
				{
					q.push(make_pair(nx,ny));
					steps[nx][ny]=steps[stt.first][stt.second]+1;
				}
			}
		}
	}
	int res=1e9;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(steps[i][j]<=k){
				int xx=min(min(i,j),min(n-i-1,m-j-1));
				res=min(res,(xx+k-1)/k+1);
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 8412
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c=map(int,input().split())
    L=[int(input())for _ in range(n)]
    INF=10**9
    def dfs(cur,aa,bb,cc):
        if cur==n:
            return abs(aa-a)+abs(bb-b)+abs(cc-c)-30 if aa*bb*cc>0 else INF
        ret0=dfs(cur+1,aa,bb,cc)
        ret1=dfs(cur+1,aa+L[cur],bb,cc)+10
        ret2=dfs(cur+1,aa,bb+L[cur],cc)+10
        ret3=dfs(cur+1,aa,bb,cc+L[cur])+10
        return min(ret0,ret1,ret2,ret3)
    print(dfs(0,0,0,0))

if __name__=='__main__':
    main()

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

int main(){
  int n;
  int check = 0;
  char c;
  cin >> n;
  vector<int> ans(0);
  for (int i = 0; i < n; i++) {
    cin >> c;
    ans.push_back(c - '0');
  }
  while(ans.size() > 1){
    n = ans.size();
    if(n % 2 == 0 && check == 0){
      for(int i = 0; i < n/2; i++){
        ans.at(i) = abs(ans.at(i*2) - ans.at(i*2 + 1));
      }
      ans.erase(ans.begin() + n/2, ans.end());
      check = 1;
    }
    else{
      for(int i = 0; i < n - 1; i++){
        ans.at(i) = abs(ans.at(i) - ans.at(i+1));
      }
      ans.pop_back();
      check = 0;
    }
  }
  cout << ans.at(0) << endl;
}


Measured memory_bytes: 6552
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define MX 500009 
#define INF 100000000009
using namespace std;
 
int main(){
    string s;
    int n;
    cin>>n>>s;
    rep(i,s.size()){
        int k=s[i]-'A';
        k+=n;
        k%=26;
        s[i]=k+'A';
    }
    cout<<s;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll a, b, n;
  cin >> a >> b >> n;
  cout << a * min(n, b - 1) / b << endl;
}

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

int main()
{
  int n = 0;
  int a[300],b[300];
  while(n < 300)
  {
    cin >> a[n] >> b[n];
    if(a[n] == 0 && b[n] ==0)break;
    n ++;
  }
  for(int i = 0; i <= n; i++)
  {
    for(int j = 0; j < a[i];j++)
    {
      for(int k = 0 ; k < b[i] ; k++)
      {
        if(j!=0 && j!= (a[i]-1) && k!=0 && k!=(b[i]-1))cout << '.';
        else cout << '#';
      }
      cout <<endl;
    }
    if(i < n)cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner (System.in);
		String s = sc.next();
		String ans = s.replace("2017","2018");
		System.out.println(ans);
		// your code goes here
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }
    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main(){
    int n,m;
    cin >> n >> m;
    int s[n],t[m];
    REP(i,n){
        cin >> s[i];
    }
    REP(i,m){
        cin >> t[i];
    }
    Mint<> dp[n + 1][m + 1];
    for(int i = 0; i <= n; i++){
        dp[i][0] = 1;
    }
    for(int j = 0; j <= m; j++){
        dp[0][j] = 1;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1];
            else dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j];
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int N;
  cin >> N;
  vector<int> a(N,0);
  froop1(0,N){
    cin >> a.at(i);
  }
  int count = 0;
  for(int i = 0;i < N;i += 2){
    if(a.at(i) % 2 != 0) count++;
  }
  cout << count << endl;
return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i, N) cin >> s[i];
  int M;
  cin >> M;
  vector<string> t(M);
  rep(i, M) cin >> t[i];
  
  int ans=0;
  int curr=0;
  
  rep(i, N) {
    curr=0;
    rep(j, N) {
      if (s[i] == s[j]) curr++;
    }
    rep(j, M) {
      if (s[i] == t[j]) curr--;
    }
    if (ans<curr) ans=curr;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

void warshall_floyd(int n, vector<vector<ll>>& dist) {
  rep(i, n) rep(j, n) rep(k, n) {
    dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<vector<ll>> A(n, vector<ll>(n));
  rep(i, n) rep(j, n) cin >> A[i][j];
  vector<vector<ll>> copyA(n, vector<ll>(n));
  rep(i, n) copy(all(A[i]), begin(copyA[i]));
  warshall_floyd(n, copyA);
  bool ok = true;
  rep(i, n) rep(j, n) {
    if(A[i][j] != copyA[i][j]) ok = false;
  }
  if(!ok) cout << -1 << "\n";
  else {
    priority_queue<pair<ll, pair<int, int>>,
                   vector<pair<ll, pair<int, int>>>,
                   greater<pair<ll, pair<int, int>>>> q;
    ll ans = 0;
    rep(i, n) REP(j, i+1, n) q.push(make_pair(A[i][j], make_pair(i, j)));
    vector<vector<ll>> D(n, vector<ll>(n, longinf));
    rep(i, n) D[i][i] = 0;
    while(!q.empty()) {
      auto ele = q.top(); q.pop();
      ll cost = ele.first;
      int i = ele.second.first;
      int j = ele.second.second;
      bool ok = false;
      rep(k, n) {
        if(k != i && k != j &&
           D[i][k]+D[k][j] == cost) ok = true;
      }
      if(!ok) ans += cost;
      D[i][j] = A[i][j];
      D[j][i] = A[i][j];
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 5916
N = int(input())
S = list(input())

def main():
    min_index = 0
    min_num = 0
    curr = 0
    for i in range(N):
        if S[i] == "E":
            curr -= 1
        else:
            curr += 1
        if min_num > curr:
            min_index = i
        min_num = min(min_num, curr)
    
    left = S[:min_index]
    right = S[min_index + 1:] # excludes the leader.
    ans = left.count("W") + right.count("E")
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){
    cout << "Yes" << endl;
}
void no(){
    cout << "No" << endl;
}
//-----------------------------------------

string str(int x){
    string res = TS(x) ;
    while(SZ(res)!=6){
        res = "0" + res ;
    }
    return res ;
}

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m ;
    cin >> n >> m ;
    vector<tuple<int,int,int>> vec(m) ;
    REP(i,m){
        int a, b ;
        cin >> a >> b ;
        vec[i] = MT(b,a-1,i) ;
    }
    sort(ALL(vec)) ;
    vint cnt(n,1) ;
    vector<pii> ans(m) ;
    REP(i,m){
        int q, w, e ;
        q = get<0>(vec[i]) ;
        w = get<1>(vec[i]) ;
        e = get<2>(vec[i]) ;
        ans[e] = MP(w,cnt[w]) ;
        cnt[w]++ ;
    }
    REP(i,m){
        cout << str(ans[i].FI+1) <<str(ans[i].SE) <<endl ;
    }

    

    return 0;
}



Measured memory_bytes: 3840
const stdin=require("fs").readFileSync("/dev/stdin", "utf8");
const argv=stdin.split("\n");
const round=Number(argv[0]);
const cards=argv[1].split(/\s+/).map(a=>Number(a));
 
const sortedCards=cards.sort((a,b)=>a-b).reverse();//cardを降順に並べ替え
 
const alice=sortedCards.reduce((sum,a,idx)=>(sum+((idx%2)==0 ? a : 0)),0);//偶数枚目を合計
const bob=sortedCards.reduce((sum,a,idx)=>(sum+((idx%2)==1 ? a : 0)),0);//奇数枚目を合計
 
console.log(alice-bob);

Measured memory_bytes: 29572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t K, A, B;
  cin >> K >> A >> B;
  int64_t bis = 1;
  int64_t ans = 0;
  if(A >= B-1){
    ans = K+1;
  }
  else{
    int64_t x = A - 1;
    if(x >= K){
      ans = K+1;
    }
    else{
      int64_t y = K - x;
      if(y %2 == 0){
        ans = A + (y/2)*(B-A);
      }
      else{
        ans = A + ((y-1)/2)*(B-A) + 1;
      }
    }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define PI 3.14159265358979323846

int main(void) {
	
	int N;
	scanf("%d", &N);

	if (N % 2 == 0) {
		printf("%f", (double)1/ 2);
	}
	else {
		printf("%f", (double) (N / 2 + 1) / N);
	}

	return 0;
}


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

int main(){
  long long int X,Y;
  cin>>X>>Y;
  int sum=1;
  for(int i=0;i<100;i++){
    if(Y<X*2)break;
    sum++;
    X=X*2;
  }
  cout<<sum<<endl; 
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    ll a, b, k;
    cin >> a >> b>> k;
    if(a >= k) {
        cout << a-k << ' ' << b <<endl;
    }
    else if((b-(k-a)) >= 0) {
        cout << 0 << ' ' << b-(k-a) << endl;
    }
    else cout << 0 << ' ' << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int aa=0,bb=0;
    int n;
    cin>>n;
    int i;
    for(i=1 ; i<=n ; i++){
        int x;
        cin>>x;
        if(i%2){
            a[x]++;
            if(a[x]>a[aa])aa=x;
        }
        else{
            b[x]++;
            if(b[x]>b[bb])bb=x;
        }
    }
    if(aa!=bb)
    cout<<(n-a[aa]-b[bb]);
    else{
        int aaa=0;
        int bbb=0;
        for(i=1 ; i<=1e5 ; i++){
            if(a[i]>a[aaa] && i!=aa)aaa=i;
        }
        for(i=1 ; i<=1e5 ; i++){
            if(b[i]>b[bbb] && i!=bb)bbb=i;
        }
        cout<<min(n-a[aaa]-b[bb],n-a[aa]-b[bbb]);
    }
    return 0;
}


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

int main()
{
    long long int a,b,c,d,w=0,x=0,y=0,z=0;
    cin >> a >> b >> c >> d;
    
    w=a*c;
    x=a*d;
    y=b*c;
    z=b*d;
    
    if(w>=x && w>=y && w>=z)
    {
        cout << w;
    }
    else if(x>=w && x>=y && x>=z)
    {
        cout << x;
        
    }
      else if(y>=w && y>=x && y>=z)
    {
        cout << y;
        
    }
      else if(z>=w && z>=y && z>=x)
    {
        cout << z;
        
    }
    
    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    string s;cin>>s;
    int ans=1;;
    rep(i,n){
        if(i){
            if(s[i]==s[i-1]&&s[i]=='x')break;
            ans++;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3348
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    K = int(rl())
    
    ans = []
    for si in s:
        if si == 'a':
            ans.append('a')
            continue
        cnt = ord('z') - ord(si) + 1
        if cnt <= K:
            ans.append('a')
            K -= cnt
        else:
            ans.append(si)
    
    ans[-1] = chr(ord('a') + (ord(ans[-1]) - ord('a') + K % 26) % 26)
    print(''.join(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int main(){
//	freopen("loan.in","r",stdin);
//	freopen("loan.out","w",stdout);
	int n,sum=0,ma=999999;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<ma) sum++;
		ma=min(ma,a[i]);
	}
	cout<<sum;
}

Measured memory_bytes: 1024
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
      	int a=sc.nextInt();
        int b=sc.nextInt();
  		double a1=(double)a/0.08;
        double b1=(double)b/0.1;
  		int a2=(int)Math.ceil(a1);
        int b2=(int)Math.ceil(b1);
  		int ans=0;
  		
  		if(a2==b2){
        	ans=a2;
        }else if(a2<b2){
          if(Math.floor(b2*0.08)==(double)a){
          	ans=b2;
          }else{
          	ans=-1;
          }
        }else{
          if(Math.floor(a2*0.1)==(double)b){
          	ans=a2;
          }else{
          	ans=-1;
          }
        }
  		
    
 	

    	System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static int ans;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] arrayA = new int[m];
		int[] arrayB = new int[m];
		for(int i=0;i<m;i++) {
			arrayA[i]=sc.nextInt();
			arrayB[i]=sc.nextInt();
		}
		sc.close();

		UnionFind uf = new UnionFind(n);
		for(int i=0;i<m;i++) {
			uf.join(arrayA[i]-1,arrayB[i]-1);
		}

        Set<Integer> set = new HashSet<>();
        for(int i=0; i<n; i++) {
            set.add(uf.root(i));
        }
        System.out.println(set.size() -1);
	}

	static class UnionFind {
		int[] p;
		int n;
		UnionFind(int n) {
			this.n = n;
			p = new int[n];

			for(int i=0; i<n; i++){
				p[i] = i;
			}
		}

		int root(int a) {
			if(p[a] == a) {
				return a;
			}

			int res =  root(p[a]);
			p[a] = res;

			return res;
		}

		void join(int a ,int b) {
			p[root(a)] = p[root(b)];
			}
		}

	}

Measured memory_bytes: 60000
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

set<pair<int,int> > se;

int32_t main(){
	int n,m,pos,t;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>pos>>t;
		se.insert({pos,t});
	}
	string s;
	for(int i=0;;i++){
		s = to_string(i);
		if(s.length()>n){
			break;
		}
		if(s.length()<n){
			continue;
		}
		for(auto x: se){
			unless(s[x.first-1]==('0'+x.second)){
				goto fin;
			}
		}
		cout<<s;
		return 0;
		fin:1;
	}
	cout<<-1;
}


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

int main()
{
	int N;
	int K;
	int x;
	int dist = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> x;
		dist += min(2 * x, (K - x) * 2);
	}
	cout << dist << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 60;

//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() {
    ll n;
    cin >> n;
    ll f=0,ans=0;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        ans+=max(0LL,f-a);
        f=max(f,a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
vector<vector<bool>> White(1000, vector<bool>(1000, false));
vector<vector<int>> Steps(1000, vector<int>(1000, -1));
queue<pair<int, int>> Que;
int H, W;

void addToQue(int x, int y, int s)
{
  if (x < 0 || y < 0 || x >= W || y >= H)
    return;
  if (White.at(y).at(x) && Steps.at(y).at(x) == -1)
  {
    White.at(y).at(x) = false;
    Steps.at(y).at(x) = s;
    Que.push(make_pair(x, y));
  }
}

int main()
{
  char c;
  cin >> H >> W;
  for (int y = 0; y < H; y++)
  {
    for (int x = 0; x < W; x++)
    {
      cin >> c;
      White.at(y).at(x) = (c == '.');
      if (c == '#')
      {
        Que.push(make_pair(x, y));
        Steps.at(y).at(x) = 0;
      }
    }
  }

  int x, y, cnt = 0, step;
  pair<int, int> cur;
  while (!Que.empty())
  {
    cur = Que.front();
    x = cur.first;
    y = cur.second;
    Que.pop();
    step = Steps.at(y).at(x);
    addToQue(x + 1, y, step + 1);
    addToQue(x - 1, y, step + 1);
    addToQue(x, y + 1, step + 1);
    addToQue(x, y - 1, step + 1);
  }

  int maxs = -1;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      maxs = max(maxs, Steps.at(i).at(j));
    }
  }
  cout << maxs << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n,tmp,result=0;
    cin >> n;
    FOR(i,1,n+1){
        tmp = 1;
        FOR(j, 2, i+1)
        {
            if(i%j==0){
                tmp++;
            }
        }
        //cout <<i<<" "<< tmp << endl;
        if(tmp==8&&i%2==1){
            result++;
        }
        
    }
    cout << result << endl;
}


Measured memory_bytes: 256
//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;  typedef long long ll;
inline int qr(){
	int ret=0,f=0,c=getchar();
	while(!isdigit(c))f|=c==45,c=getchar();
	while(isdigit(c)) ret=ret*10+c-48,c=getchar();
	return f?-ret:ret;
}

int main(){
	ll x,cur=100;
	cin>>x;
	for(int t=1;;++t){
		cur*=1.01;
		if(cur>=x){
			cout<<t<<endl;
			return 0;
		}
	}
	return 0;
}


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

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

    int ans = 0;
    for(int i=0; i<n; i++){
        if(a[i]-d > 0){
            ans += a[i]-d;
        }
    }
    if(ans == 0){
        cout << "kusoge" << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 1000000000 + 7;
const ll INF = 1e+9;
const ld PI = acos((long double)(-1));

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x) << endl;
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define eb(e) emplace_back(e)
#define EPS 0.00000001

int main() {
    FAST;

    int a;
    cin >> a;
    print(a + a * a + a * a * a);
}


Measured memory_bytes: 3648
#include <iostream>
#include<bits/stdc++.h>
const int N=1e5+5;
const int M=1e7;
using namespace std;
int a[N];
int main()
{
    long long n,m,i,k,x,v,p,s,l,j;
    cin >> n >> m;
    cin >> v >> p;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    l=n-p-1;
    j=0;
    while(j<l){
        k=(l+j)/2;
        x=a[k]+m;
        if(a[n-p]>x){
                j=k+1;
        continue;}
        s=0;
        for(i=k+1;i<=n-p;i++)
            s=s+x-a[i];
        if((p+k)*m+s<m*v) j=k+1;
        else l=k-1;
    }
    if(j+2>n-p-1) j=n-p-3;
    for(k=j+2;k>=0;k--){
        x=a[k]+m;
        if(a[n-p]>x) break;
        s=0;
        for(i=k+1;i<=n-p;i++)
            s=s+x-a[i];
        if((p+k)*m+s<m*v) break;
    }
    cout<<n-k-1;
    return 0;
}


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

struct Data {
	using type = int;
	type val, lazy;

	static type id() { return INT_MAX; }
	static type op(const type& l, const type & r) { return min(l, r); }

	Data(type v) : val(v), lazy(-1) {}
	void update(type a) { lazy = a; }
	type get() { return lazy == -1 ? val : lazy; }
	void push(Data& l, Data& r) {
		if (lazy == -1) return;
		val = lazy;
		l.lazy = lazy;
		r.lazy = lazy;
	}
};

template <typename M>
class LazySegmentTree {
	using T = typename M::type;
	const int n;
	vector<M> data;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void suc(int l, int r, int node, int lb, int ub, T val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			data[node].update(val);
			return;
		}
		data[node].push(data[node * 2], data[node * 2 + 1]);
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = M::op(data[node * 2].get(), data[node * 2 + 1].get());
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return M::id();
		if (l <= lb && ub <= r) return data[node].get();
		data[node].push(data[node * 2], data[node * 2 + 1]);
		int c = (lb + ub) / 2;
		return M::op(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub));
	}
public:
	LazySegmentTree(int n_) : n(size(n_)), data(n * 2, M::id()) {}
	void init(const vector<T>& data_) {
		for (int i = 0; i < (int)data_.size(); i++)
			data[i + n] = data_[i];
		for (int i = n - 1; i >= 0; i--)
			data[i] = M::op(data[i * 2], data[i * 2 + 1]);
	}
	void update(int l, int r, T val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	LazySegmentTree<Data> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}

Measured memory_bytes: 4916
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] p = new long[n], q = new long[n];
			IntStream.range(0, n).forEach(i -> {
				long x = scanner.nextLong(), y = scanner.nextLong();
				p[i] = x + y;
				q[i] = x - y;
			});
			System.out
					.println(Math.max(Math.abs(Arrays.stream(p).max().getAsLong() - Arrays.stream(p).min().getAsLong()),
							Math.abs(Arrays.stream(q).max().getAsLong() - Arrays.stream(q).min().getAsLong())));
		}
	}
}


Measured memory_bytes: 63776
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

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


	int N;
	cin >> N;
	int A[10000];
	rep(i, N) cin >> A[i];

	int P[1000000] = {};

	rep(i, N) {
		int sq = sqrt(A[i]);
		int tmp = A[i];
		map<int, int> p;
		for (int j = 2; j <= sq; j++) {
			while (tmp % j == 0) {
				p[j]++;
				tmp /= j;
			}
		}
		if (tmp != 1) p[tmp]++;

		for (auto pr : p) {
			chmax(P[pr.first], pr.second);
		}
	}

	ll lcm = 1;
	rep1(i, 999999) {
		rep(j, P[i]) {
			lcm *= i;
			lcm %= mod;
		}
	}

	ll kari = 0;
	rep(i, N) {
		kari += modpow(A[i], mod - 2);
	}
	kari %= mod;

	co(lcm* kari% mod);



	Would you please return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  int k;
  cin >> k;

  int keta_total = s.size();

  // dp[i][non_zero][enough] :=
  // 左からi桁目まで決まっていて、非ゼロがnon_zero個使われているときのパターン数
  // enoughが1な場合はなんでも、0な場合は既にギリギリ
  int dp[110][4][2];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;

  for (int cur_keta = 0; cur_keta < keta_total; cur_keta++) {
    for (int nzero = 0; nzero < 4; nzero++) {
      int cur_num = s[cur_keta] - '0';  // nの現在の桁の数
      for (int enough = 0; enough < 2; enough++) {
        for (int num = 0; num < 10; num++) {
          int next_keta = cur_keta + 1;
          int next_nzero = nzero;
          int next_enough = enough;

          if (num != 0) next_nzero++;
          if (next_nzero > k) continue;
          if (!enough) {
            if (num > cur_num) continue;
            if (num < cur_num) {
              next_enough = 1;
            }
          }

          dp[next_keta][next_nzero][next_enough] += dp[cur_keta][nzero][enough];
        }
      }
    }
  }

  ll ans = dp[keta_total][k][0] + dp[keta_total][k][1];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256