akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,M;
vint g[100010];
int dp[100010];
bool used[100010];
int dfs(int now){
    used[now]=true;
    if(dp[now])return dp[now];
    for(auto e:g[now]){
        chmax(dp[now],dfs(e)+1);
    }
    return dp[now];
}

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N>>M;
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].pb(b);
    }
    rep(i,0,N)if(!used[i])dfs(i);
    int ans=0;
    rep(i,0,N)chmax(ans,dp[i]);
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int a,b,c;
    cin >> a >> b >>c;
    int r = c / (7*a + b);
    int d = c % (7*a + b);
    if (d == 0) cout << r * 7 << endl;
    else{
        if (d <= 6 * a)  cout << (r * 7) + (d + a - 1) / a << endl;
        else cout << (r+1) * 7 << endl;
    }

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int ans[4][3][10]={};
    for(int i=0;i<n;i++){
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        ans[b-1][f-1][r-1]+=v;
    }
    for(int a=0;a<4;a++){
        for(int b=0;b<3;b++){
            for(int c=0;c<10;c++){
                cout<<" "<<ans[a][b][c];
            }
            cout<<endl;
        }
        if(a<3){
            int l=0;
            while(l<20){
            cout<<"#";
            l++;
            }
        cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const int INFTY = 1e6;

static const int NUMMAX = 300;


int main(){

  int N, A;
  vector< pair<int, int> > student;

  cin >> N;

  REP(i, N){
    cin >> A;
    student.push_back(make_pair(A, i+1));
  }

  sort( student.begin(), student.end() );

  REP(i, N){
    cout << student[i].second;
    if( i == N ) cout << endl;
    else cout << " ";
  }

  return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;

int main(){
    list<long long> b;
    // vector<long long> a;
    long long n,tmp;
    cin >> n;
    for(long long i = 0; i<n;i++){
        cin >> tmp;
        if(i%2 == 0){
            b.push_front(tmp);
        } else {
            b.push_back(tmp);
        }
    }
    if(n%2 == 0)
        reverse(b.begin(),b.end());
    for(auto it = b.begin();it!= b.end();it++){
        if(it == b.begin()){
            cout << *it;
        }else{
            cout << ' ' << *it;
        }
    }
    cout << endl; 
    return 0;
}


Measured memory_bytes: 8448
int main()
{
    int a,b,n;
    while(~scanf("%d",&n))
    {
        if(n==1)
            printf("Hello World\n");
        if(n>1)
        {
            scanf("%d%d",&a,&b);
            printf("%d\n",a+b);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cassert>
#include <vector>
#include <sstream>
#include <cmath>
#include <stdio.h>

using namespace std;

//-------------------------------------------------------------------------
// geometric library

namespace geometry {

#define EPS 1E-10 ///< 0とみなすサイズ。適当

	struct point {
		double x;
		double y;

		point& operator += (const point& rhs) { x += rhs.x; y += rhs.y; return *this; }
		point& operator -= (const point& rhs) { x -= rhs.x; y -= rhs.y; return *this; }
		point& operator /= (double factor) { x /= factor; y /= factor; return *this; }
		point& operator *= (double factor) { x *= factor; y *= factor; return *this; }
		bool operator == (const point& rhs) const { return (std::abs(x - rhs.x) < EPS) && (std::abs(y - rhs.y) < EPS); }
		bool operator != (const point& rhs) const { return !(*this == rhs); }
		bool operator <= (const point& rhs) const { return x < rhs.x || (x == rhs.x && y <= rhs.y); }
		bool operator >= (const point& rhs) const { return x > rhs.x || (x == rhs.x && y >= rhs.y); }
		bool operator < (const point& rhs) const { return !(*this >= rhs); }
		bool operator > (const point& rhs) const { return !(*this <= rhs); }
		double arg() const { return atan2(y, x); }
		double norm() const { return sqrt(x * x + y * y); }
	};

	typedef point vec;

	point operator + (const point& p1, const point& p2)
	{
		point p(p1);
		p += p2;
		return p;
	}

	point operator / (const point& p1, double factor)
	{
		point p(p1);
		p /= factor;
		return p;
	}

	point operator * (const point& p1, double factor)
	{
		point p(p1);
		p *= factor;
		return p;
	}

	point operator * (double factor, const point& p1)
	{
		point p(p1);
		p *= factor;
		return p;
	}

	point operator - (const point& p1, const point& p2)
	{
		point p(p1);
		p -= p2;
		return p;
	}

	std::istream& operator >> (std::istream& is, point& p)
	{
		is >> p.x >> p.y;
		return is;
	}

	double inner_product(const point& p1, const point& p2)
	{
		return p1.x * p2.x + p1.y * p2.y;
	}

} // namespace geometry


//-------------------------------------------------------------------------
// solution

using namespace geometry;

// 直線p1-p2についてpqと対称な点prを求める
point get_symmetric_point(const point& p1, const point& p2, const point& pq) {
	vec unit_vec = (p2 - p1) / (p2 - p1).norm();

	// pm: pq-prの中点
	point pm = p1 + (inner_product(pq - p1, p2 - p1) / (p2 - p1).norm()) * unit_vec;

	return pm + (pm - pq);
}

int main(void) {
	point p1, p2, pq;
	string line;

	while (getline(cin, line)) {
		replace(line.begin(), line.end(), ',', ' ');
		istringstream ss(line);
		ss >> p1 >> p2 >> pq;

		point pr = get_symmetric_point(p1, p2, pq);

		printf("%f %f\n", pr.x, pr.y);
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int i=1;
		for(;;) {
			if(n<=Math.pow(3, i)) {
				break;
			}
			i++;
		}
		System.out.println(i);
		
		sc.close();
	}

}



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

using namespace std;

int main(){
	int N;
	cin >> N;
	
	vector<int> v(N),c(N);
	
	for(int i=0;i<N;i++){
		cin >> v[i];
	}
	for(int i=0;i<N;i++){
		cin >> c[i];
	}
	
	
	vector<int> s(N);
	int ans = 0;
	
	for(int i=0;i<N;i++){
		s[i] = v[i] - c[i];
		
		if(s[i] < 0) s[i] = 0;
		
		ans += s[i];
		
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder20170211 {
	class Program {
		static void Main(string[] args) {
			var input = Console.ReadLine().Split(' ');

			var s = Convert.ToDecimal(input[0]);
			var c = Convert.ToDecimal(input[1]);

			var scc = 0m;

			if(s * 2 <= c) {
				scc = s;

				scc += Math.Floor((c - s * 2) / 4);
			}
			else {
				scc = Math.Floor(c / 2);
				//s -= scc;

				//scc += Math.Floor(s / 2);
			}
			Console.WriteLine(scc);
			//Console.ReadLine();
		}
	}
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define endl '\n'
#define IO; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    string s,t;
    cin>>s>>t;
    if(t.length()==s.length()+1 && s==t.substr(0,s.length()))
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

const int N_MAX=100, M_MAX=100;
char p[N_MAX+1][M_MAX+1];

int main(){
	char x,y;
	cin >> x >> y;
	if(x > y){
		cout << '>' << endl;
	}else if(x == y){
		cout << '=' << endl;
	}else{
		cout << '<' << endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iomanip>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

map<char, int> m;
vector<int> ap;

bool check(string s) {
	rep(i, s.size()/2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

int main()
{
	int x_num = 0,sum = 0;
	string str,s="";
	cin >> str;
	ap.resize(str.size());

	rep(i, str.size()) {
		if (str[i] != 'x') {
			m[str[i]]++;
			s += str[i];
		}
		else x_num++;
	}

	if (s.size() == 0) {
		cout << 0 << endl;
		return 0;
	}

	int ki = 0;
	for (char c = 'a'; c <= 'z'; c++) {
		if (m[c] % 2 != 0) {
			ki++;
			sum += m[c] / 2 + m[c] % 2;
		}
		else {
			sum += m[c] / 2;
		}
	}

	if (ki >= 2 || !check(s)) {
		cout << -1 << endl;
		return 0;
	}

	int i = 0,out_rx = 0,out_lx = 0;
	while (str[i] == 'x') {
		i++;
		out_rx++;
	}

	int rx = 0,lx = 0,sum1 = 0,sum2 = 0,k=0,ans = 0;
	for (; i < str.size(); i++) {
		if (str[i] == 'x') rx++;
		else {
			sum1++;
			ap[k++] = rx;
			rx = 0;
			if (sum1 >= sum) {
				break;
			}
		}
	}
	
	i = str.size() - 1;
	while (str[i] == 'x') {
		i--;
		out_lx++;
	}

	k = 0;
	for (; i >= 0; i--) {
		if (str[i] == 'x') lx++;
		else {
			sum2++;
			ans += abs(ap[k++] - lx);
			lx = 0;
			if (sum2 >= sum) {
				break;
			}
		}
	}

	cout << abs(out_rx - out_lx) + ans  << endl;
	return 0; 
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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 int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int R, G; cin >> R >> G;
  cout << 2 * G - R << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<utility>
#include<tuple>
#include<cmath>

using namespace std;
typedef long long ll;

int main(){
    int a,b;cin >> a >> b;
    if(a <= 9 && b <= 9){
        cout << a*b << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
 
int main(void){
    string s;
    cin >> s;
    rep(i, s.size() - 1){
        if(s[i] != s[i + 1]){
            cout << "Yes" << endl; 
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);++i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
int n=1000,m=1000;
char a[1000][1000];
int nums[1000][1000],MOD=1e9+7;

int dpp(int i,int j) {
	if (i==n or j==m) return 0;
	if (nums[i][j]>-1) return nums[i][j];
	nums[i][j]=dpp(i+1,j)+dpp(i,j+1);
	nums[i][j]%=MOD;
	return nums[i][j];
}


int main () {
	cin >> n >> m;
	fop (i,0,n) {
		fop (j,0,m) {
			cin >> a[i][j];
			nums[i][j]=-1;
			if (i==n-1 and j==m-1) nums[i][j]=1;
			if (a[i][j]=='#') nums[i][j]=0;
		}
	}
	cout << dpp(0,0);
}

Measured memory_bytes: 5248
/*#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
*/
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
int N, M, K;
int id;
// 深さ優先探索
vector<int> cc_id;   // どの連結成分か
vector<int> cc_num;  // 連結成分のサイズ
void dfs(const Graph &G, int v, int &cnt) {
    cc_id[v] = id;
    cnt++;
    for (auto e : G[v]) {
        if (cc_id[e.to] == -1) {
            dfs(G, e.to, cnt);
        }
    }
}
int main() {
    cin >> N >> M >> K;
    Graph G(N);  // グラフとして考える
    vector<int> A(M), B(M);
    REP(i, M) {
        cin >> A.at(i) >> B.at(i);
        A[i]--, B[i]--;
        G[A[i]].push_back({B[i]});
        G[B[i]].push_back({A[i]});
    }
    vector<int> C(K), D(K);
    REP(i, K) {
        cin >> C.at(i) >> D.at(i);
        C[i]--, D[i]--;
    }
    // どの連結成分に属し、サイズがいくつなのかを求める
    cc_id.assign(N, -1);  // 初期化
    id = 0;
    REP(i, N) {
        if (cc_id[i] == -1) {
            int cnt = 0;
            dfs(G, i, cnt);
            cc_num.push_back(cnt);
            id++;
        }
    }
    vector<int> ans(N);
    REP(i, N) { ans[i] = cc_num[cc_id[i]] - 1 - (int)G[i].size(); }
    REP(i, K) {  // 同じ連結成分にあるブロック関係を引く
        if (cc_id[C[i]] == cc_id[D[i]]) {
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }
    REP(i, (int)ans.size()) {
        cout << ans[i];
        if (i != (int)ans.size() - 1) cout << " ";
    }
    cout << endl;
    return 0;
}


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


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    // + - + - ...
    ll total = 0, cnt_1 = 0;
    rep(i, n) {
        total += a[i];
        if (i % 2 == 0) {
            if (total <= 0) {
                cnt_1 += (-total) + 1;
                total = 1;
            }
        } else {
            if (total >= 0) {
                cnt_1 += total + 1;
                total = -1;
            }
        }
    }

    // - + - + ...
    total = 0;
    ll cnt_2 = 0;
    rep(i, n) {
        total += a[i];
        if (i % 2 == 1) {
            if (total <= 0) {
                cnt_2 += (-total) + 1;
                total = 1;
            }
        } else {
            if (total >= 0) {
                cnt_2 += total + 1;
                total = -1;
            }
        }
    }

    ll ans = min(cnt_1, cnt_2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4056
use std::collections::HashSet;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse::<usize>().unwrap());
    let h = itr.next().unwrap();
    let w = itr.next().unwrap();

    for _ in 0..h {
        let mut s = String::new();
        stdin().read_line(&mut s).ok();
        print!("{}{}", s, s);
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>

int main(){
	char test[8];
	int count=0;
	scanf("%s",test);
	int len=strlen(test);
	for(int i = 0, j=len-1; i<len, j>=0; i++, j--){
		if(test[i]==test[j]){
			count++;
		}
	}
	
	if(count == len){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=LLINF;
    for(int ab=0;ab<=2*max(x,y);ab+=2){
        int i=max(x-ab/2,0);
        int j=max(y-ab/2,0);
        // cout<<ab<<" "<<i<<" "<<j<<endl;
        ll cost=a*i+b*j+c*ab;
        chmin(ans,cost);
    }
    fin(ans);
}



Measured memory_bytes: 256
import java.io.*;
import java.math.*;

class Main{
    public static void main(String[] args) throws IOException
    {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        int[] data1 = makeint(br);
        int n = data1[0];
        int[] data2 = makeint(br);
        long minimum = data2[0], maximum = data2[0], sum = data2[0];

        for(int i = 1; i < n; i++){
            minimum = Math.min(minimum, data2[i]);
            maximum = Math.max(maximum, data2[i]);
            sum += data2[i];
        }
        System.out.println(minimum + " " + maximum + " " + sum);
    }

    public static int[] makeint(BufferedReader br) throws IOException
    {
        String[] str = br.readLine().split(" ");
        int n = str.length;
        int[] a = new int[n];
        for(int i = 0; i < n; i++){ a[i] = Integer.parseInt(str[i]); }
        return a;
    }
}


Measured memory_bytes: 28832
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 2e5+17;
LL dp[MAXN],ocr[26+3];
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    string str;
    cin>>str;
    dp[0] = 1;
    ocr[str[0]-'a']++;
    for (int i = 1; i < str.length(); ++i)
    {
    	dp[i] = dp[i-1]+i-ocr[str[i]-'a'];
    	ocr[str[i]-'a']++;
    }
    cout<<dp[str.length()-1]<<endl;
    return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
    #define ll long long
    using namespace std;

    int main()
    {
       int  n;
       cin>>n;
       vector<ll> a;
       a.resize(100);
       a[0]=2;
       a[1]=1;
       int i,j,k;
       for(i=2;i<=n;i++){
           a[i]=a[i-1]+a[i-2];
       }
       cout<<a[n];
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	while(cin>>str,str!="#"){
		int ans=-1;
		for(int i=0,now=2,num=0;i<str.size();i++){
			if(str[i]>103&&str[i]<113||str[i]==117||str[i]==121)num=1;
			else num=0;
			if(now!=1&&num==1){
				ans++;
				now=1;
			}
			else if(now!=0&&num==0){
				ans++;
				now=0;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1184
import math

D,G=map(int,input().split())
pc = [list(map(int,input().split()))for i in range(D)]
digits = '0'+str(D)+'b'

minpn = float('INF')

for i in range(2**D):
  maxIndex = -1
  s = list(format(i, digits))
  point = 0
  pcounter = 0
  for j in range(D):
    if s[j]=='1':
      #increce the c and (the p)*100*(j+1)
      point += pc[j][1]
      point += pc[j][0]*100*(j+1)
      pcounter += pc[j][0]
    else:
      maxIndex=j
  remainingP = G - point
  if  remainingP <= 0:
    minpn = min(pcounter, minpn)
  else:
    if 100*(maxIndex+1)*(pc[maxIndex][0]-1)>=remainingP:
      pcounter+=math.ceil(remainingP/(100*(maxIndex+1)))
      minpn = min(pcounter, minpn)

print(minpn)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int matrixA[][] = new int[n][m];
		int matrixB[] = new int[m];
		int matrixC[] = new int[n];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++)
				matrixA[i][j] = sc.nextInt();
		}

		for (int i = 0; i < m; i++)
			matrixB[i] = sc.nextInt();

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++)
				matrixC[i] += matrixA[i][j] * matrixB[j];
		}

		for (int i = 0; i < n; i++)
			System.out.println(matrixC[i]);

	}

}

Measured memory_bytes: 40588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	ll a, b; cin >> a >> b;
	if(a == b){
		cout << 1 << endl;
		return 0;
	}
	int diff = 63 - __builtin_clzll(a ^ b);
	a &= (1ll << diff+1) - 1;
	b &= (1ll << diff+1) - 1;
	
	for(ll i = b ^ 1ll << diff; i; i -= i & -i) b |= i - 1;
	ll c = a ^ 1ll << diff;
	ll ans = (1ll << diff+1) - a;
	if(c > b) ans -= c - b - 1;
	cout << ans << endl;
	
	return 0;
}

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

bool flag[51];
int M,T,P,R;

bool check(){
	for(int i=1;i<=T;i++)
		if(flag[i])
			return true;
	return false;
}

int main(void){
	while(cin >> M >> T >> P >> R,M|T|P|R){
		for(int i=1;i<=T;i++)
			flag[i]=true;
		int cor[51]={0};
		int time[51]={0};
		int pe[51][11]={0};
		int m,t,p,j;
		for(int i=0;i<R;i++){
			cin >> m >> t >> p >> j;
			if(j){
				pe[t][p]++;
			}else{
				cor[t]++;
				time[t]+=m;
				time[t]+=pe[t][p]*20;
			}
		}
		int o=0;
		while(check()){
			cout << (o? ",":"");
			o++;
			int correct=0,less=INF;
			for(int i=T;i>=1;i--){
				if(!flag[i])
					continue;
				if(cor[i]>correct)
					correct=cor[i],less=time[i];
				else if(correct==cor[i]&&less>time[i])
					less=time[i];
			}
			int d=0;
			for(int i=T;i>=1;i--){
				if(!flag[i])
					continue;
				if(correct==cor[i]&&time[i]==less)
					cout << (d?"=":"") << i,d++,flag[i]=false;
			}
		}
		cout << endl;
	}
	return 0;
}

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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
 
namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) {int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) {  for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0;}
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void gp (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::gp;
 
void scan() {
	return;
}
 
template<class T, typename... Args>
void scan(T &a, Args&&... args) {
	gi(a);
	scan(args...);
	return;
}

template<typename T>
void scann(T a, T b) {
	for (auto it = a; it != b; ++it)
		scan(*it);
}
 
template<typename T>
void scerr(T a, T b) {
	for (auto it = a; it != b; ++it)
		cerr << *it << " ";
	cerr << '\n';
}

void print() {
	return;
}
 
template<class T, typename... Args>
void print(T a, Args... args) {
	gp(a);
	pc(' ');
	print(args...);
	return;
}
 
void cer() {
	return;
}
 
template<class T, typename... Args>
void cer(T a, Args... args) {
	cerr << " " << a;
	cer(args...);
	return;
}
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, ll> mll;
 
const int N = 3e5 + 5;
const int MM = 4e6 + 5;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 3;
const ll INF = 1e15;

void data() {
	#ifdef PC
		freopen("e.in", "r", stdin);
		freopen("e.out", "w", stdout);
	#endif
}

ll n, a[N], ans;
mll was;

int main() {
	data();
	scan(n);
	scann(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) {
		ans += was[i - a[i]];
		was[a[i] + i]++;
	}
	print(ans);
}	


Measured memory_bytes: 29472
#include<iostream>
#include<string>
#include<cmath>
#define value( x ) cout<< "value of "<< #x << " is "<< x<<endl;
long long max( long long x, long long y) {if(x>y) return x;else return y;}
using namespace std;
int main()
{
	
   long long x, a, b;
   cin>>x>>a>>b;
   if(abs(x-a)>abs(x-b))cout<<"B";else cout<<"A";
return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int a[n], v;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    
    for(int k=0;k<n;k++)
    {
        cout << a[k];
        if(k!=n-1) cout << " ";
    }
    cout << endl;
    

    for(int i=1;i<n;i++)
    {
        v = a[i];
        int j = i-1;
        while(j>=0 && a[j]>v)
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        for(int k=0;k<n;k++)
        {
            cout << a[k];
            if(k!=n-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


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

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

int n,m;
int p[100000];
vector<vector<LL>> v;
unordered_map<string,int> mp;
int s[100000];
int ret[100000];

int main(){
  cin>>n>>m;
  v.resize(n);
  int pin;
  LL l;
  REP(i,m){
    cin>>pin>>l;
    pin--;
    v[pin].push_back(l);
    mp[to_string(pin)+" "+to_string(l)]=i;
  }
  REP(i,n){
    sort(v[i].begin(),v[i].end());
    REP(j,v[i].size()){
      s[mp[to_string(i)+" "+to_string(v[i][j])]] = i+1;
      ret[mp[to_string(i)+" "+to_string(v[i][j])]] = j+1;
    }
  }
  REP(i,m){
    printf("%06d%06d\n",s[i],ret[i]);
  }
  return 0;
}



Measured memory_bytes: 19620
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int t;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
	if(a==0)cout<<1;
	if(b==0)cout<<2;
	if(c==0)cout<<3;if(d==0)cout<<4;if(e==0)cout<<5;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3612
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::string s, std::string t){
    for(int i = 0; i < n; ++i)
        cout << s[i] << t[i];
    cout << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


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

const int MOD = (int) 1e9 + 7;
const int N = 305;
long long f[N][N][N]; // length, inqueue, connected

int main() {
    int n, m; cin >> n >> m;
    f[0][0][1] = 1;
    for (int l = 0; l < m; ++l) {
        for (int q = 0; q <= n; ++q) {
            for (int c = 0; c <= n; ++c) if (f[l][q][c] > 0) {
                long long cur = f[l][q][c];
                // Add new vertex
                (f[l + 1][q + 1][c] += (n - q - c) * cur) %= MOD;
                // Add old vertex
                (f[l + 1][q][c] += q * cur) %= MOD;
                // Connect
                (f[l + 1][0][q + c] += c * cur) %= MOD;
            }
        }
    }
    cout << f[m][0][n] << endl;
    return 0;
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 1e5 + 10, mod = 1e9 + 7;
int fact[N], invfact[N];
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (((ll) x) * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}
void pre(){
	fact[0] = invfact[0] = 1;
	for(int i = 1;i < N; i++) fact[i] = mul(i, fact[i - 1]);
	invfact[N - 1] = inv(fact[N - 1]);
	for(int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);
	assert(invfact[1] == 1);
}

inline int C(int n, int k){
	if(n < k || k < 0) return 0;
	return mul(fact[n], mul(invfact[k], invfact[n - k]));
}
int x[N];
int inverse[N], H[N], H2[N];
int main(){
	pre();
	int n; sd(n);

	for(int i = 1; i <= n + 1; i++){
		if(i <= n) sd(x[i]);
		inverse[i] = inv(i);
		H[i] = add(H[i - 1], inverse[i]);
		H2[i] = add(H2[i - 1], mul(inverse[i], inv(i + 1)));
	}
	int ans = 0;
	for(int i = 1; i < n; i++){
		ans = add(ans, mul(x[n] - x[i], inverse[n - i]));
		// xi - xj
		ans = add(ans, mul(x[i], H2[i - 1]));
		ans = add(ans, mul(sub(0, x[i]), H2[n - 1 - i]));
	}
	printf("%d\n", mul(ans, fact[n - 1]));
}

Measured memory_bytes: 2560
// ABC142 A

#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

using namespace std;

int main() {
  
  int n; cin >> n;
  int odd = (n + 1) / 2;
  printf("%.10lf", 1.0 * odd / n);

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int r, D, x;
    cin >> r >> D >> x;

    ll ans = x;
    for (int i = 1; i <= 10; i++) {
        ans = ans * r - D;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	int num = 0;
	cin >> s;
	if (s[0] == 'o') num++;
	if (s[1] == 'o') num++;
	if (s[2] == 'o') num++;
	cout << 700 + num * 100 << endl;
}


Measured memory_bytes: 764
def calc(arr, flag)
  (1...arr.size).each{|i| arr[i] += arr[i-1] }
  if flag
    arr.each{ |v| $list[v].nil? ? $list[v] = 1 : $list[v] += 1 }
  else arr.each{ |v| $list[v].nil? ? next : $res += $list[v] }
  end
end
loop do
  $n, $m = gets.split.map(&:to_i)
  break if $n == 0
  $list = {}
  $res = 0
  l = $n.times.map{ gets.to_i }
  k = $m.times.map{ gets.to_i }
  (0...$n).each{|i| calc(l[i..-1], true) }
  (0...$m).each{|i| calc(k[i..-1], false) }
  p $res
end

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

int main(void) {
  int N, X[100];
  int count;
  long long int mini = 0;
  
  cin>>N;
  for (int i=0; i<N; i++) {
    cin >> X[i];
  }
  
  for (int j=1; j<=100; j++) {
    count=0;
    for (int k=0; k<N; k++) {
      count += (X[k] - j) * (X[k] - j);
    }
    if (j == 1) {
      mini = count;
    } else if (mini > count) {
      mini = count;
    }
  }
  cout << mini;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n);rep(i,n) cin>>a[i];
    vector<ll> cumsum(n+1,0);
    rep(i,n) cumsum[i+1] = cumsum[i] + a[i];
    ll res = 1e+15;
    repr(i,2,n-1) {
        // max,min
        vector<pair<ll,ll>> pl,pr;
        auto it = upper_bound(begin(cumsum), end(cumsum), cumsum[i]/2);
        int cur = int(it-cumsum.begin());
        if(cur != i) {
            pl.emplace_back(cumsum[cur],cumsum[i]-cumsum[cur]);
        }
        cur--;
        if (cur != 0) {
            pl.emplace_back(cumsum[i]-cumsum[cur],cumsum[cur]);
        }
        it = upper_bound(begin(cumsum), end(cumsum),
         cumsum[i] + (cumsum[n]-cumsum[i])/2);
        cur = int(it-cumsum.begin());
        if(cur != n) {
            pr.emplace_back(cumsum[cur]-cumsum[i],cumsum[n]-cumsum[cur]);
        }
        cur--;
        if (cur != i) {
            pr.emplace_back(cumsum[n]-cumsum[cur],cumsum[cur]-cumsum[i]);
        }
        for(auto x:pr) {
            for(auto y:pl) {
                chmin(res,max(x.first,y.first)-min(x.second,y.second));
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  string A,B;
  cin >> A >> B;
  
  if(A == "H" && B == "H"){
    cout << "H" << endl;
}

  if(A == "H" && B == "D"){
    cout << "D" << endl;
}
  
 if(A == "D" && B == "H"){
    cout << "D" << endl;
}
  
  if(A == "D" && B == "D"){
    cout << "H" << endl;
}
}

Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]
dp = [[0]*n for _ in range(2)]
dp[0][0] = a[0][0]
dp[1][0] = a[0][0] + a[1][0]
for i in range(1,n):
    dp[0][i] = dp[0][i-1] + a[0][i]
    dp[1][i] = max(dp[0][i], dp[1][i-1]) + a[1][i]
print(dp[1][n-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define For(i,l,r)for(res i=(l),_=(r);i<=_;++i)
#define Dor(i,l,r)for(res i=(r),_=(l);i>=_;--i)
#define Sor(i,l,r)for(res i=(l),_=(r);i<_;++i)
#define ll long long
#define fz(a,b)memset(a,b,sizeof a)
#define N 200001
#define M 1000000007
int main() {
	int a,b,c;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
}


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

if K % 7 == 0:
    L = 9 * K // 7
else:
    L = 9 * K

ans = -1
n = 10
for i in range(1, L):
    surplus = n % L
    if surplus == 1:
        ans = i
        break
    n = 10 * surplus
print(ans)

Measured memory_bytes: 9036
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n; vector<ll>a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	vector<ll>pref(n), suf(n);
	for (ll i = 0; i < n; i++) {
		pref[i] = max(a[i], (i ? pref[i - 1] : 0));
	}
	for (ll i = n - 1; i >= 0; i--) {
		suf[i] = max(a[i] , (n - 1 - i ? suf[i + 1] : 0));
	}
	for (ll i = 0; i < n; i++) {
		ll kek = max((i ? pref[i - 1] : 0), (n - i - 1  ? suf[i + 1] : 0));
		cout << kek << '\n';
	}


	return 0;
}
/*

*/

Measured memory_bytes: 6272
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    x: [i32; n],
  }
  let ans = (1 .. 101).map(|i| x.iter().map(|&a| (a-i).pow(2)).sum::<i32>()).min().unwrap();

  puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

// 動作環境 : C++14 AOJ
int main(){
    vector<pair<ll, ll>> A;
    while(true){
        ll H, W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        A.pb(make_pair(H, W));
    }

    rep(i, 0, A.size()){
        rep(y, 0, A[i].first){
            cout << string(A[i].second, '#') << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<complex>

using namespace std;

#define EPS 1e-5
#define EQ(a,b) (std::abs((a)-(b))<EPS)

typedef vector<complex<double> > P;

#define LEN(a,b) (std::abs((b)-(a)))
#define ANG(a,b,c) (((((b)-(a))*conj((c)-(b))).imag())<0?-1:1)

int main(){
  int n;
  while(cin>>n,n){
    int m; cin >> m;
    P org(m);
    P rev;
    for(int i=0;i<m;i++)
      cin >> org[i].real() >> org[i].imag();
    rev=org;
    reverse(rev.begin(),rev.end());
    
    for(int k=0;k<n;k++){
      bool f=true,r=true;
      int mm; cin >> mm;
      if(mm!=m){
	for(int i=0;i<mm;i++){
	  int x;
	  cin >> x >> x;
	}
	continue;
      }
      P tmp(m);
      for(int i=0;i<m;i++)
	cin >> tmp[i].real() >> tmp[i].imag();

      for(int i=1;i<m;i++){
	if(f){
	  if(!EQ(LEN(org[i-1],org[i]),LEN(tmp[i-1],tmp[i]))) f=false;
	  if(i>1&&(ANG(org[i-2],org[i-1],org[i])!=ANG(tmp[i-2],tmp[i-1],tmp[i])))
	    f=false;
	}
	if(r){
	  if(!EQ(LEN(rev[i-1],rev[i]),LEN(tmp[i-1],tmp[i]))) r=false;
	  if(i>1&&(ANG(rev[i-2],rev[i-1],rev[i])!=ANG(tmp[i-2],tmp[i-1],tmp[i])))
	    r=false;
	}
	if(!r && !f) break;
      }
      if(r || f) cout << k+1 << endl;
    }

    cout << "+++++" << endl;
  }
  return 0;
}

Measured memory_bytes: 0