akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
template<typename T,typename U> ostream& operator<< (ostream& out, const pair<T,U>& val){return out << "(" << val.F << ", " << val.S << ")";}
template<class T> ostream& operator<< (ostream& out, const vector<T>& val){out << "{";rep(i,SZ(val)) out << (i?", ":"") << val[i];return out << "}";}
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int h,w,c;
int in[8][8];
int ans;
void dfs(int de, int p[8][8]){
  int np[8][8];
  rep(k,6){
    if(de==4 && k!=c) continue;
    rep(i,8)rep(j,8) np[i][j]=p[i][j];
    bool vis[8][8]={};
    queue<PI> q;
    q.push(mp(0,0));
    int tans=0;
    int s=np[0][0];
    while(!q.empty()){
      int cx=q.front().F;
      int cy=q.front().S;
      q.pop();
      if(vis[cx][cy]) continue;
      vis[cx][cy] = true;
      np[cx][cy]=k;
      ++tans;
      rep(i,4){
        int nx=cx+dx[i];
        int ny=cy+dy[i];
        if(min(nx,ny)<0 || nx>=h || ny>=w || s!=np[nx][ny])
          continue;
        q.push(mp(nx,ny));
      }
    }
    if(de<4) dfs(de+1,np);
    else{
      queue<PI> q;
      bool vis[8][8]={};      
      q.push(mp(0,0));
      int tans=0;
      while(!q.empty()){
        int cx=q.front().F;
        int cy=q.front().S;
        q.pop();
        if(vis[cx][cy]) continue;
        vis[cx][cy] = true;
        ++tans;
        rep(i,4){
          int nx=cx+dx[i];
          int ny=cy+dy[i];
          if(min(nx,ny)<0 || nx>=h || ny>=w)
            continue;
          if(np[nx][ny]!=np[0][0]) continue;
          q.push(mp(nx,ny));
        }
      }
      ans=max(ans,tans);
    }
  }
}

void solve(){
  --c;
  rep(i,h)rep(j,w){
    cin >> in[i][j];
    --in[i][j];
  }
  ans = 0;
  dfs(0,in);
  cout << ans << endl;
}

int main(int argc, char *argv[])
{
  while(cin >> h >> w >> c && h) solve();
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int yama[10];
	for(int i=0;i<10;i++){
		cin>>yama[i];
	}
	sort(yama,yama+10);
	cout<<yama[9]<<endl<<yama[8]<<endl<<yama[7]<<endl;
	return 0;
}	


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

int main()
{
  int n, m, i;
  cin  >> n >> m;
  int max = 0;
  int min = 1000000000;
  int l[100000];
  int r[100000];
  for (i = 0; i < m; i++) {
    cin >> l[i] >> r[i];
    if (max < l[i])
      max = l[i];
    if (min > r[i])
      min = r[i];
  }
  if (min - max + 1 > 0)
    cout << min - max + 1<< endl;
  else
    cout << '0' << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d", &a,&b);
    if(a>=13)
    {
        printf("%d\n", b);
    }
    else if(a>=6 && a<=12)
    {
        printf("%d\n", b/2);
    }
    else if(a>=0 && a<=5)
    {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

int main() {
  vi a(100001,0);
  rep(i, 100000){
    a.at(i) = i*i;
  }
  int b;
  cin >> b;
  cout << a.at(sqrt(b));
}

Measured memory_bytes: 3688
#include <iostream>

struct {
  auto &operator>>(int &x) {
    char c;
    do
      c = std::cin.rdbuf()->sbumpc();
    while (!isdigit(c));
    for (x = 0; isdigit(c); c = std::cin.rdbuf()->sbumpc())
      x = x * 10 + (c ^ 48);
    return *this;
  }
} io;

const int MAX_N = 200000;
const int MAX_M = 262144;

long long d[MAX_M * 2 + 1];
int M, h[MAX_N + 1], a[MAX_N + 1];

inline void maintain(int k) { d[k] = std::max(d[k << 1], d[k << 1 | 1]); }

inline void modify(int k, long long v) {
  d[k += M] = v;
  for (k >>= 1; k; k >>= 1) maintain(k);
}

inline long long query(int s, int t) {
  if (s > t) return 0;
  long long ret = 0;
  for (s += M - 1, t += M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
    if (~s & 1) ret = std::max(ret, d[s ^ 1]);
    if (t & 1) ret = std::max(ret, d[t ^ 1]);
  }
  return ret;
}

int main() {
  int n;
  io >> n;
  for (int i = 1; i <= n; ++i) io >> h[i];
  for (int i = 1; i <= n; ++i) io >> a[i];
  for (M = 1; M < n + 2;) M <<= 1;
  for (int i = 1; i <= n; ++i) modify(h[i], query(1, h[i] - 1) + a[i]);
  std::cout << query(1, n);
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static long[] tree = new long[400000];

	static long max(int pos, int l, int r, int min, int max) {
		long ret = 0;
		if (l == min && r == max) return tree[pos];
		int m = (l + r) / 2;
		if (min < m) {
			ret = Math.max(ret, max(pos * 2 + 1, l, m, min, Math.min(m, max)));
		}
		if (m < max) {
			ret = Math.max(ret, max(pos * 2 + 2, m, r, Math.max(m, min), max));
		}
		return ret;
	}

	static void set(int pos, int l, int r, int index, long v) {
		tree[pos] = Math.max(tree[pos], v);
		if (l == r - 1) return;
		int m = (l + r) / 2;
		if (index < m) {
			set(pos * 2 + 1, l, m, index, v);
		} else {
			set(pos * 2 + 2, m, r, index, v);
		}
	}

	public static void main(String[] args) {
		int N = sc.nextInt();
		int size = 1;
		while (size <= N) {
			size *= 2;
		}
		for (int i = 0; i < N; ++i) {
			int x = sc.nextInt();
			long max = max(0, 0, size, 0, x);
			set(0, 0, size, x, max + x);
		}
		System.out.println((long) N * (N + 1) / 2 - tree[0]);
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> b(n+1);
    b[0] = b[n] = 1e9;
    for(int i = 1; i < n; i++){
        cin >> b[i];
        ans += min(b[i-1], b[i]);
    }
    cout << ans + b[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# 59

T = input()
P = input()
t=[]
A = []
#print(len(P),len(T))
if len(P)==1:
    K=len(T)
else:
    K = len(T)-(len(P)-1)
    #print(K)
p = len(P)
for i in range(K):
    t = T[i:p]
    #print(t)
    p += 1
    if t.count(P)>0:
        print(i)


Measured memory_bytes: 5584
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int n,a,b;
	cin>>n>>a>>b;
	cout<<(n-a+1)*(n-b+1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m; cin >> n >> m;
    vector<vector<pair<ll, ll>>> prf(n, vector<pair<ll, ll>>(0));

    rep(i, m){
        ll p, y;
        cin >> p >> y;
        p--;
        prf[p].push_back(make_pair(y, i));
    }
    vector<pair<ll, ll>> city(m);
    rep(i, n){
        if(prf[i].size() >= 2) sort(all(prf[i]));
        rep(j, prf[i].size()){
            city[prf[i][j].second] = make_pair(i+1, j+1);
        }
    }

    rep(i, m) cout << setfill('0') << setw(6) << city[i].first << setfill('0') << setw(6) << city[i].second << endl; 
}

Measured memory_bytes: 8576
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int32_t main(){_
    //freopen("input","r",stdin);
	int a,b,c;
	cin >> a >> b >> c;
	int ans = 0;
	if(a % 2 == b % 2 && b % 2 == c % 2)
	{
		ans += (max({a,b,c}) - a) / 2;
		ans += (max({a,b,c}) - b) / 2;
		ans += (max({a,b,c}) - c) / 2;
	}
	else
	{
		if(a % 2 == c % 2) {
			a++;
			c++;
		}
		else if(b % 2 == c % 2)
		{
			b++;
			c++;
		}
		else
		{
			b++;
			a++;
		}
		ans++;
		ans += (max({a,b,c}) - a) / 2;
		ans += (max({a,b,c}) - b) / 2;
		ans += (max({a,b,c}) - c) / 2;
	}
	rc(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define int long long

  

int32_t main()
{
  string s;
  cin>>s;
  int l= 0,r =s.size()-1,ans=0;

  while(l<r){
    if(s[l]!=s[r]) ans++;

    l++;
    r--;
    
  }

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


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] A = sc.next().toCharArray();
		char[] B = sc.next().toCharArray();

		if (A.length > B.length) {
			System.out.println("GREATER");
			return;
		} else if (A.length < B.length) {
			System.out.println("LESS");
			return;
		}

		for (int i = 0; i < A.length; i++) {
			if (A[i] < B[i]) {
				System.out.println("LESS");
				return;
			} else if (A[i] > B[i]) {
				System.out.println("GREATER");
				return;
			}
		}

		System.out.println("EQUAL");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b, int[] c) throws IOException {
			if (a.length != b.length || b.length != c.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
				c[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> V(N);
    priority_queue<double, vector<double>, greater<double> > P;
    for (int i = 0; i < N; i++) {
        cin >> V[i];
        P.push((double)V[i]);
    }
    while (true) {
        double a = P.top();
        P.pop();
        double b = P.top();
        P.pop();
        if (P.empty()) {
            printf("%lf\n", (a+b)/2);
            return 0;
        }
        P.push((a+b)/2);
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
for i in range(N):
    A_list[i] = A_list[i] - (i + 1)

soretedAlist = sorted(A_list)

#print(soretedAlist)
#print(5//2)
#print(soretedAlist[N//2])
result =0
for a in soretedAlist:
    result += abs(a - soretedAlist[N//2])
print(result)

Measured memory_bytes: 26832
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans = min(b,d) - max(a,c);
    cout << (ans < 0 ? 0 : ans) << endl;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; ll k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());

    /*
    k番目の数字としてあり得るものを二分探索で求める
    
    ある数字未満の配列同士の組み合わせの個数がk個未満の場合
    　leftを中間地点にすすめる
    ある数字未満の配列同士の組み合わせの個数がk個以上の場合
    　rightを中間地点まですすめる
    */

    // 二分探索をするときの初期値
    ll l = -INF, r = INF;
    // 二分探索開始
    while(l+1<r){
        ll x = (l+r)/2; // 中間位置
        // ラムダ式で関数にまとめる
        bool ok = [&]{  // [&] これをつけることで関数の外の変数にアクセス可能になる
            // x未満の数の個数を格納するための変数tot
            ll tot = 0;
            rep(i,n){
                if(a[i]<0){
                    int l=-1, r=n;
                    while(l+1<r){
                        int c = (l+r)/2;
                        if(a[c]*a[i]<x) r=c; else l=c;
                    }
                    tot += n-r;
                }else{
                    int l=-1, r=n;
                    // いま選択されている配列番号とのペアでどの番号まで、かけ合わせた数字がx未満として成立するかを求めている
                    while(l+1<r){
                        int c = (l+r)/2;
                        if(a[c]*a[i]<x) l=c; else r = c;
                    }
                    tot += r;
                }
                if(a[i]*a[i]<x) tot--;
            }
            tot /= 2;
            return tot<k;
        }();    // () 定義し終わったあとで関数呼び出しを行っているという意味

        if(ok) l=x; else r=x;
    }
    cout << l << endl;
    return 0;
}

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

typedef long long ll;

int N;
vector<int> H, A, D, S;

typedef struct{
    int turn, ad;
}Enemy;

bool operator < (const Enemy& l, const Enemy& r){
    return l.turn * r.ad > r.turn * l.ad;
}

int solve(){
    ll damage = 0;
    vector<bool> ignore(N, false);
    
    for(int i=1; i<=N; i++){
        if(S[i] > S[0])
            damage += max(0, A[i]-D[0]);
        if(D[i] >= A[0]){
            if(A[i] > D[0])
               return -1;
            else
                ignore[i] = true;
        }
    }
    
    vector<Enemy> enemies;
    for(int i=1; i<=N; i++) if(!ignore[i]){
        int turn = (H[i]+A[0]-D[i]-1) / (A[0]-D[i]);
        Enemy enemy({turn, max(0, A[i]-D[0])});
        enemies.push_back(enemy);
    }
    sort(enemies.begin(), enemies.end());
    
    ll sd = 0;
    for(int i=0; i<enemies.size(); i++){
        sd += enemies[i].ad;
        damage += sd * enemies[i].turn;
        damage -= enemies[i].ad;
        if(damage >= H[0])
            return -1;
    }
    return damage;
}

int main(){
    cin >> N;
    
    H.resize(N+1); A.resize(N+1); D.resize(N+1), S.resize(N+1);
    for(int i=0; i<=N; i++)
        cin >> H[i] >> A[i] >> D[i] >> S[i];
    
    cout << solve() << endl;
    
    return 0;
}

Measured memory_bytes: 4100
#include<iostream>
using namespace std;
int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        if(h==0 && w==0)
            break;
        else
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
            cout<<"#";
            }
            cout<<endl;
        }
         cout<<endl;

    }
    return 0;
}



Measured memory_bytes: 3084
use proconio::input;

fn main() {
    input! { n: usize, q: usize }

    let mut t = FenwickTree::new(n);
    for i in 0..n {
        input! { a: u64 }
        t.add(i, a);
    }

    for _ in 0..q {
        input! { f: usize };
        if f == 1 {
            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
            input! { p: usize, x: u64 }
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    n: usize,
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};
impl<T: Copy + Integer + AddAssign> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            n,
            v: vec![zero(); n],
        }
    }

    fn add(&mut self, i: usize, v: T) {
        let mut i = i + 1;
        while i <= self.n {
            self.v[i - 1] += v;
            i += i & i.wrapping_neg();
        }
    }

    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    #[inline]
    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= i & i.wrapping_neg();
        }
        v
    }
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> v(n+m);
  ll c = 2;
  for (ll i = 0; i < n; ++i) {
    v[i] = c;
    c += 2;
  }

  c = 1;
  for (ll i = n; i < n+m; ++i) {
    v[i] = c;
    c += 2;
  }

  ll ans = 0;
  for (ll i = 0; i < n+m; ++i) {
    for (ll j = 0; j < n+m; ++j) {
      if (i == j) continue;
      if ((v[i]+v[j]) % 2 == 0) {
        ++ans;
      }
    }
  }

  cout << ans/2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int gcd(int , int);

int main()
{
  int x, y,d;

  scanf("%d %d",&x,&y);

  d = gcd(x,y);
  printf("%d\n",d);

  return 0;
}

int gcd(int x, int y)
{
  int r,temp;
  
  if(x < y)
  {
    temp = y;
    y = x;
    x = temp;
  }

  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
    return x;
}



Measured memory_bytes: 2072
n = int(input())
h = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]


class Bucket:
    def __init__(self, a, k, func=max, one=-10**18):
        self.n = len(a)
        self.k = k
        self.func = func
        self.one = one

        self.a = a[:]
        self.b = []
        for i in range(self.n // self.k):
            s = self.one
            for j in range(i * self.k, i * self.k + self.k):
                s = func(s, self.a[j])
            self.b.append(s)
        s = self.one
        for i in range(self.n // self.k * self.k, self.n):
            s = self.func(s, self.a[i])
        self.b.append(s)

    def get(self, index):
        s = self.one
        j = index // self.k
        for i in range(j):
            s = self.func(s, self.b[i])
        for i in range(j * self.k, index + 1):
            s = self.func(s, self.a[i])
        return s

    def update(self, index, x):
        self.a[index] = self.func(x, self.a[index])
        self.b[index//self.k] = self.func(self.b[index//self.k], x)


buc = Bucket([0] * (n+1), max(10, int(n**0.5)))

for i in range(n):
    j = buc.get(h[i])
    buc.update(h[i], j + a[i])

print(buc.get(n))


Measured memory_bytes: 122064
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
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; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in(string(argv[0]) + ".txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int a, b, c;
    cin >> a >> b >> c;

    bool is = false;
    if (a==b) {is = true;}
    if (a==c) {is = true;}
    if (b==c) {is = true;}
    if (a == b && b==c) {is = false;}

    if (is) cout << "Yes";
    else cout << "No";


    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int main(void){
    int A, B, N, x;
    cin >> A >> B;
    N = B - A;
    x = 0;
    for (int i = -1; i < N; i++) {
        if ((A / 10000 == A % 10) && (A % 10000 / 1000 == A % 100 / 10)) {
            x++;
        }
        A++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main ()
{
	long long a,b;
	scanf("%lld%lld",&a,&b);
	long long c=(a*b)/(__gcd(a,b));
	printf("%lld",c);
	return 0;
}


Measured memory_bytes: 128
l = list(map(str, input().split()))
S = []

for i in range(len(l)):
    S.append(l[i])
    if l[i]=="+":
        S.pop()
        v1 = S.pop()
        v2 = S.pop()
        x = int(v2) + int(v1)
        S.append(x)
        
    if l[i]=="-":
        S.pop()
        v1 = S.pop()
        v2 = S.pop()
        x = int(v2) - int(v1)
        S.append(x)
        
    if l[i]=="*":
        S.pop()
        v1 = S.pop()
        v2 = S.pop()
        x = int(v2) * int(v1)
        S.append(x)


print(S[0])
    


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll w,a,b;
    cin>>w>>a>>b;
    ll x1=a,x2=a+w,y1=b,y2=b+w;
    if (y2<=x1)
        cout<<x1-y2<<endl;
    else if (x2<=y1)
        cout<<y1-x2<<endl;
    else
        cout<<"0\n";
}

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

//00:15

string s;
int p;

int num(){
	int x = 0;
	while( '0' <= s[p] && s[p] <= '9' ){
		x = x * 10 + s[p++] - '0';
	}
	return x;
}
int dfs(){
	if( s[p] == '[' && s[p+1] != '[' ){
		p++;
		int ret = (num()+1)/2;
		p++;
		return ret;
	}else{
		p++;
		vector<int> v;
		while( s[p] != ']' ){
			v.push_back(dfs());
		}
		p++;
		sort(v.begin(),v.end());
		int ans = 0;
		for(int i = 0 ; i < (v.size()+1)/2 ; i++)
			ans += v[i];
		return ans;
	}
}
int main(){
	int n;
	cin >> n;
	while(n--){
		cin >> s;
		s += "~~";
		p = 0;
		cout << dfs() << endl;
	}
}

Measured memory_bytes: 1280
import sys
input = sys.stdin.readline
Q, H, S, D = map(int, input().split())
N = int(input())
res = 0
for x in range(1, 3):
  q = Q * (8 // x)
  h = H * (4 // x)
  s = S * (2 // x)
  d = D
  if x == 1: res += (N // 2) * min(q, h, s, d)
  if x == 2: res += N * min(q, h, s)
  N = N % 2
print(res)

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    int64_t ans = 0;
    int64_t p = 1;
    for (auto i : irange(0L, n)) {
        ans += (a[i] - 1) / p;
        if (a[i] == p) {
            p = a[i] + 1;
        } else {
            p = max(2L, p);
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int arr[200005], pos[200005];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        pos[arr[i]] = i;
    }
    set <int> s;
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        int l = 0, r = n + 1;
        if (s.size() > 0) {
            auto x = s.lower_bound(pos[i]);
            if (x == s.end()) {
                x = --s.end();
            }
            if (*x < pos[i]) {
                l = *x;
            } else {
                r = *x;
                if (x != s.begin()) {
                    l = *(--x);
                }
            }
        }
        res += 1LL * i * (r - pos[i]) * (pos[i] - l);
        s.insert(pos[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11264
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if((c + b - 1) / b <= (a + d - 1) / d){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define INF 0x3f3f3f3f
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define MOD 998244353
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

ll dp[105][10][4];
int len;
int a[105];

int k;

inline int read() {
    int ret = 0, sgn = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if(ch == '-') sgn = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        ret = ret*10 + ch - '0';
        ch = getchar();
    }
    return ret*sgn;
}

ll dfs(int pos, int pre ,int limit, int lead, int kk)
{
    ll sum = 0;
    if(pos > len) return (kk == 0);

    if(!limit && dp[pos][pre][kk] != -1 && !lead) return dp[pos][pre][kk];

    int res = limit ? a[len - pos + 1] : 9;

    for(int i = 0; i <= res; i++)
    {
        if(kk == 0 && i != 0) continue;
        if(i != 0)
            sum += dfs(pos + 1, i, limit && (i == res), lead && !i, kk - 1);
        else
            sum += dfs(pos + 1, i, limit && (i == res), lead && !i, kk);

    }

    return (!limit && !lead) ? dp[pos][pre][kk] = sum : sum;
}

ll part(string s)
{
    len = s.length();
    for(int i = len; i >= 1; i--)
        a[i] = s[len - i] - '0';

    memset(dp, -1, sizeof dp);

    return dfs(1, 0, 1, 1, k);
}

int main()
{
    //NOS
    string s;
    cin >> s;
    k = read();
    ll ans = part(s);
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
n=gets.to_i
as=gets.split.map(&:to_i).sort.reverse
a=0
b=0
i=0
while i<n-1
  if as[i]==as[i+1]
    if a==0
      a=as[i]
    elsif b==0
      b=as[i]
    end
    i+=1
  end
  break if a>0 && b>0
  i+=1
end
puts a*b


Measured memory_bytes: 10112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    private static long[][] dp;
    private static long calculate(int current, int w, int[][] arr){
        if(w == 0) return 0;
        if(w < 0) return Integer.MIN_VALUE;
        if(current >= arr.length) return 0;
        if(dp[current][w] != -1) return dp[current][w];
        long x = calculate(current + 1, w, arr);
        long y = calculate(current + 1, w - arr[current][0], arr);
        if(y != Integer.MIN_VALUE) y += arr[current][1];
        dp[current][w] = Math.max(x, y);
        return Math.max(x, y);
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        // code goes here
        int[] in = nextIntArray(br, 2);
        int n = in[0];
        int w = in[1];
        int[][] arr = new int[n][2];
        for(int i = 0; i < n; i++){
            arr[i] = nextIntArray(br, 2);
        }
        dp = new long[n][w + 1];
        for(int i = 0; i < n; i++){
            Arrays.fill(dp[i], -1);
        }
        sb.append(calculate(0, w, arr));
        System.out.print(sb.toString());
    }

    private static int nextInt(BufferedReader br) throws IOException{
        return Integer.parseInt(br.readLine());
    }

    private static int[] nextIntArray(BufferedReader br, int n) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        return arr;
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 139048
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

struct Edge{
    int from, to, cost;
};

const int MAX_V = 100;
int d[MAX_V];

int main(){
    int V, E;
    std::cin >> V >> E;

    std::vector<Edge> G;
    REP(i, E){
        int from, to;
        std::cin >> from >> to;

        G.push_back({from, to, -1});
    }
    
    bool f = false;
    REP(i, V){
        REP(j, E){
            Edge &e = G[j];
            if(d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                if(i == V-1){f = true;}
            }
        }
    }

    if(f){puts("1");}
    else{puts("0");}
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] strArr = br.readLine().split(" ");
		int[] arr = new int[n];
		for(int i = 0;i < n;i++){
			arr[i] = Integer.parseInt(strArr[i]);
		}

		System.out.println(toString(arr));
		for(int i = 1;i < n;i++){
			int v = arr[i];
			int j = i - 1;
			while(j >= 0 && arr[j] > v){
				arr[j + 1] = arr[j];
				j--;
			}
			arr[j + 1] = v;
			System.out.println(toString(arr));
		}

	}

	static String toString(int[] arr){
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < arr.length - 1;i++){
			sb.append(arr[i]);
			sb.append(" ");
		}
		sb.append(arr[arr.length -1]);
		return sb.toString();
	}
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

vector<Vec> ans(100, Vec(100, 0));

int main(void){
	ll a, b;
	cin >> a >> b;
	REP(i, 50, 100){
		fill(all(ans[i]), 1);
	}
	a--; b--;

	ll x = 0, y = 0;
	while(b){
		ans[x][y] = 1;
		if(y < 98) y += 2;
		else{
			y = 0;
			x += 2;
		}
		b--;
	}
	x = 99, y = 0;
	while(a){
		ans[x][y] = 0;
		if(y < 98) y += 2;
		else{
			y = 0;
			x -= 2;
		}
		a--;
	}
	
	cosp(100); co(100);
	rep(i, 100){
		rep(j, 100){
			if(ans[i][j] == 0) cout << '.';
			else cout << '#';
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 384
//AtCoder 085
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;

int main(){
	std::ios::sync_with_stdio(false);
	lld t=1;	//cin>>t;
	while(t--){
		string s;
		cin>>s;
		s[3]='8';
		cout<<s;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    cin>>n;
    int count=0;
    for(int i=1;i<n/2+1;i++) {
        if(i!=(n-i))
        count++;
    }
    cout<<count<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
#include <string.h>
#define mem(x,b) memset(x,b,sizeof(x))
#define mp(a,b) make_pair(a,b)
#define debug(a) cout<<a<<endl
#define maxn 200005
using namespace std;
typedef long long ll;
typedef double db;
const int mod=1e9+7;
int s[maxn];
int main()
{
    int n;scanf("%d",&n);
    n=n%10;
    if(n==3){
    	puts("bon");
    }else if(n==0||n==1||n==6||n==8){
    	puts("pon");
    }else{
    	puts("hon");
    }
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define ll long long
#define uint unsignextd long long
#define db double
#define ls x << 1
#define rs x << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 500010 , mod = 1e9 + 7;
int n, nxt[N], next2[N];
char s[N];
bool is(int x, int *nxt)
{
    return nxt[x] && x % (x - nxt[x]) == 0;
}
 
int main()
{
    scanf("%s",s + 1);
    n = strlen(s + 1);
    int j = 0;
    rep(i, 2, n)
    {
        while(j && s[j + 1] != s[i]) j = nxt[j];
        nxt[i] = s[j + 1] == s[i] ? ++ j : j;
    }
    if(!is(n, nxt)) printf("1\n1\n");
    else if(nxt[n] == n - 1) printf("%d\n1\n",n);
    else
    {
        reverse(s + 1, s + 1 + n);
        j = 0;
        rep(i, 2, n)
	    {
	        while(j && s[j + 1] != s[i]) j = next2[j];
	        next2[i] = (s[j + 1] == s[i] ? ++ j : j);
	    }
        int ans = 0;
        rep(i, 1, n - 1) 
        	if(!is(i, nxt) && !is(n - i, next2)) ans ++;
        printf("2\n%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 4736
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;++i) {
			h[i]=sc.nextInt();
		}
		long cost[]=new long[n];
		Arrays.fill(cost, 1000000000L);
		cost[0]=0;
		for(int i=1;i<=k&&i<n;++i) {
			cost[i]=Math.abs(h[i]-h[0]);
		}
		for(int i=2;i<n;++i) {
			for(int j=1;j<=k&&i-j>=0;++j)
			cost[i]=Math.min(cost[i],cost[i-j]+Math.abs(h[i-j]-h[i]));
		}
		
		System.out.println(cost[n-1]);
	}
}


Measured memory_bytes: 50440
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

c = [0]*(n+1)
ans = 0
for i in range(n):
  if b[i]+c[i] > a[i]:
    if c[i]>=a[i]:
      ans = ans + a[i]
      c[i+1] = b[i]
    else:
      ans = ans + a[i]
      c[i+1] = b[i]+c[i]-a[i]
  else:
    ans = ans + b[i] + c[i]
if c[n]>a[n]:
  ans = ans + a[n]
else:
  ans = ans + c[n]
print(ans)



Measured memory_bytes: 19004
# 座標上の任意の2点を選んだとき、座標0からそのうちの1点に移動し、
# さらに別の1点に移動すれば、その2点間の座標はすべて通過したことになる
# よって、i番目の座標とi+(k-1)番目の座標を選択し、
# 座標0と近い方の座標との距離と2点間の距離の合計が最小となるようなiを選択すればよい

n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = float('inf')
for i in range(n-k+1):
    dis = min(abs(x[i]) + abs(x[i] - x[i+k-1]), abs(x[i+k-1]) + abs(x[i+k-1] - x[i]))
    ans = min(ans, dis)
print(ans)

Measured memory_bytes: 14252
from decimal import Decimal
n = int(input())
nn = int(pow(n,1/5)) + 1
for i in range(-200,200):
    cheak = i ** 5 - n
    ans = float(pow(Decimal(abs(cheak)), Decimal("0.2")))

    if type(ans) is float:

        if ans.is_integer():
            if cheak < 0:
                b = -1 * ans
            else:
                b = ans
            print(i,int(b))
            break

Measured memory_bytes: 77972
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    P ab[M];
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab, ab+M);

    int ans = 0;
    int now = 0;
    REP(i, M) {
        int l = ab[i].second;
        int r = ab[i].first;
        if (l >= now) {
            ans++;
            now = r;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
cou1 = 0
cou2 = 0
lis = list(map(int,input().split()))
for i in range(n):
  if lis[i] % 2 == 1:
    cou1 += 1
  else:
    cou2 += 1
if cou1 % 2 == 1:
  print("NO")
  exit()
print("YES")

Measured memory_bytes: 14108
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int h, n;
    cin >> h >> n;
    int sum = 0;
    rep(i, n) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

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

  vi a, b;
  rep(i, n)
  {
    ll _a;
    cin >> _a;
    a.push_back(_a);
  }

  rep(i, m)
  {
    ll _b;
    cin >> _b;
    b.push_back(_b);
  }

  int ans = 0;

  ll a_k = 0;
  int a_index = -1;

  ll b_k = 0;
  int b_index = -1;

  // b読める分だけ読む
  while(b_index + 1 < b.size() && b_k + b[b_index + 1] <= k) {
    b_index++;
    b_k += b[b_index];
  }

  ans = b_index + 1;

  for (int i = 0; i < n; i++)
  {
    a_index++;
    a_k += a[a_index];

    // bを減らす
    while (a_k + b_k > k && b_index >= 0)
    {
      b_k -= b[b_index];
      b_index--;
    }

    if (a_k + b_k <= k)
    {
      ans = max(ans, a_index + b_index + 2);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 5500