akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;

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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif
    ll T1, T2, A1, A2, B1, B2;
    cin>>T1>>T2>>A1>>A2>>B1>>B2;
    ll yol1 = T1*A1 + T2*A2;
    ll yol2 = T1*B1 + T2*B2;
    if(yol1 == yol2){
        cout<<"infinity"<<endl;
        return 0;
    }
    if(yol1 < yol2){
        swap(A1,B1);
        swap(A2, B2);
        swap(yol1, yol2);
    }

    if(A1 > B1){
        cout<<0<<endl;
        return 0;
    }

    ll cnt = 0;
    ll val = yol1 - yol2;
    ll yuk = T1*(B1 - A1);
    cnt = (yuk + val - 1)/val;
    cout<<2*cnt - 1 + (yuk % val != 0 ? 0 : 1)<<endl;
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF LLONG_MAX

int main()
{
    fastio;

    ll n , m, x, y, maxlength;
    vector<ll> indegree(100005);
    vector<ll> adj[100005];
    queue<ll> q;
    vector<ll> dp(100005);

    cin >> n >> m;

    for(ll i = 1 ; i <= m ; i++)
    {
        cin >> x >> y;
        indegree[y]++;
        adj[x].push_back(y);
    }

    for( ll i = 1 ; i <= n ; i++)
    {
        if(indegree[i] == 0 )
        {
            q.push(i);
            dp[i]= 0;
        }
    }

    while(!q.empty())
    {
        ll h = q.front();
        q.pop();
        for( auto u:adj[h])
        {
            indegree[u]--;
            if(indegree[u]== 0) q.push(u);
            dp[u] = max( dp[u] , dp[h]+1);
        }
    }

    maxlength = *max_element(dp.begin()+1 , dp.begin()+n+1);
    cout << maxlength;

    return 0;
}

Measured memory_bytes: 7296
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int hoge = sc.nextInt();
        int[] array = new int[hoge];
        int sum = 0;
        for(int i = 0; i < hoge; i++){
            array[i] = sc.nextInt();
        }
        for(int i = 0; i < hoge; i++){
            for(int j = i + 1; j < hoge; j++){
                sum += array[i] * array[j];
            }
        }
        System.out.println(sum);
    }   
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	//	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// Data :
type Data struct {
	k, v int
}

// Datas :
type Datas []Data

func (p Datas) Len() int {
	return len(p)
}

func (p Datas) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas) Less(i, j int) bool {
	return p[i].k < p[j].k
}

// Datas2 :
type Datas2 []Data2

// Data2 :
type Data2 struct {
	k, i, j, xy int
}

func (p Datas2) Len() int {
	return len(p)
}

func (p Datas2) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas2) Less(i, j int) bool {
	return p[i].k < p[j].k
}

type node struct {
	x, y int
}

// UnionFind高速
type UnionFind struct {
	par []int
	r   []int
}

func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	u.r = make([]int, N)
	for i := 0; i < N; i++ {
		u.par[i] = i
		u.r[i] = 1
	}
	return u
}

func (p *UnionFind) root(x int) int {
	if p.par[x] == x {
		return x
	}
	return p.root(p.par[x])
}

func (p *UnionFind) unite(x, y int) {
	x = p.root(x)
	y = p.root(y)
	if p.r[x] < p.r[y] {
		p.par[x] = y
	} else {
		p.par[y] = x
		if p.r[x] == p.r[y] {
			p.r[x]++
		}
	}
}

func (p *UnionFind) same(x, y int) bool {
	return p.root(x) == p.root(y)
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	x := make(Datas, N)
	y := make(Datas, N)
	n := make([]node, N)
	for i := 0; i < N; i++ {
		a, b := getInt(), getInt()
		x[i] = Data{a, i}
		y[i] = Data{b, i}
		n[i] = node{a, b}
	}
	sort.Sort(x)
	sort.Sort(y)
	out(N)
	out("x=", x)
	out("y=", y)
	out(n)
	// diff
	d := make(Datas2, (N-1)*2)
	for i := 1; i < N; i++ {
		d[(i-1)*2] = Data2{x[i].k - x[i-1].k, x[i].v, x[i-1].v, 0}
		d[(i-1)*2+1] = Data2{y[i].k - y[i-1].k, y[i].v, y[i-1].v, 1}
	}
	sort.Sort(d)
	out(d)

	cnt := 0
	ans := 0
	u := newUnionFind(N)
	for _, v := range d {
		if u.same(v.i, v.j) == false {
			ans += v.k
			u.unite(v.i, v.j)
			cnt++
		}
		if cnt == N-1 {
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 15744
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans_l = 0
rest = A[0]
for i in range(N):
    tmp = B[i]
    if rest < B[i]:
        ans_l += rest
        tmp -= rest
        if A[i+1] < tmp:
            ans_l += A[i+1]
            rest = 0
        else:
            ans_l += tmp
            rest = A[i+1] - tmp
    else:
        ans_l += B[i]
        rest = A[i+1]
ans_r = 0
A_r = A[::-1]
B_r = B[::-1]
rest = A_r[0]
for i in range(N):
    tmp = B_r[i]
    if rest < B_r[i]:
        ans_r += rest
        tmp -= rest
        if A_r[i+1] < tmp:
            ans_r += A_r[i+1]
            rest = 0
        else:
            ans_r += tmp
            rest = A_r[i+1] - tmp
    else:
        ans_r += B_r[i]
        rest = A_r[i+1]
print(max(ans_r, ans_l))


Measured memory_bytes: 18624
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ind(n); 
    
    out(n*6.28318530717958623200);
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
struct Unionfind{
  vector<int> parents;
  int m;
  Unionfind(int n):parents(n,-1){
    m = n;
  }

  int find(int x){
    if(parents.at(x) < 0){
      return x;
    }else{
      parents.at(x) = find(parents.at(x));
      return parents.at(x);
    }
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);

    if(x==y) return;
    if(parents.at(x) > parents.at(x))swap(x,y);
    parents.at(x) += parents.at(y);
    parents.at(y) = x;
  }

  int size(int x){
    return -parents.at(find(x));
  }

  bool same(int x,int y){
    return find(x) ==find(y);
  }

  vector<int> members(int x){
    int root = find(x);
    vector<int> A;
    for(int i=0;i<m;i++){
      if(find(i) ==root ){
        A.push_back(i);
      }
    }
    return A;
  }
};

int main() {
  int n,m;
  cin >> n >> m;
  vector<pp> AB(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    --a;--b;
    AB.at(i) = make_pair(a,b);
  }
  int ans = 0;
  rep(i,m){
    Unionfind uf(n);
    rep(j,m){
      if(j == i) continue;
      uf.unite(AB.at(j).first,AB.at(j).second);
    }
    if(!uf.same(AB.at(i).first,AB.at(i).second)){
      ++ ans;
    }
  }
  cout << ans << endl;
}

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


def main():
    from itertools import accumulate

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

    nums = list()
    now = 1
    count = 0

    # See:
    # https://www.youtube.com/watch?v=FRzpDCx17vw
    # 1と0が連続していくつ続いているかを数える
    # 一つの配列で管理
    for si in s:
        if si == str(now):
            count += 1
        else:
            nums.append(count)
            now = 1 - now  # 0と1を切り替える
            count = 1

    # 端部の処理
    if count != 0:
        nums.append(count)

    # 1-0-1-0-1の形になっている必要がある
    if len(nums) % 2 == 0:
        nums.append(0)

    add = 2 * k + 1

    # 累積和
    summed = list(accumulate([0] + nums))

    tmp = 0
    ans = 0

    # 偶数番目に着目
    for i in range(0, len(nums), 2):
        left = i
        right = min(i + add, len(nums))
        tmp = summed[right] - summed[left]

        ans = max(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9380
#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;
  set<int> st;
  
  rep(i,n){
    int d;
    cin >> d;
    st.insert(d);
  }
  
  cout << st.size() << endl;
  
}
  
  


Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	P := sc.nextIntSlice(N)
	Q := sc.nextIntSlice(N)
	nums := []int{}
	for i := 1; i <= N; i++ {
		nums = append(nums, i)
	}
	a := permutations(nums, N, P)
	b := permutations(nums, N, Q)

	fmt.Fprintln(wtr, abs(a-b))
	wtr.Flush()
}

func permutations(nums []int, n int, target []int) int {
	var arr []int
	seen := make(map[int]bool)
	count := 0
	var res int

	var search func(next int)
	search = func(next int) {
		arr = append(arr, next)
		seen[next] = true
		if len(arr) >= n {
			count++
			all := true
			for i := 0; i < n; i++ {
				if arr[i] != target[i] {
					all = false
				}
			}
			if all {
				res = count
			}
			return
		}
		for _, next := range nums {
			if seen[next] {
				continue
			}
			search(next)
			arr = arr[:len(arr)-1]
			seen[next] = false
		}
	}
	for _, v := range nums {
		search(v)
		arr = arr[:len(arr)-1]
		seen[v] = false
	}

	return res
}


Measured memory_bytes: 640
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    vector<ll> x (N);
    vector<ll> y (N);
    vector<ll> ax (N);
    vector<ll> ay (N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
        ax[i] = x[i];
        ay[i] = y[i];
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll ans = 1LL*(x[N-1]-x[0])*(y[N-1]-y[0]);
    for(int x1 = 0; x1 < N; x1++){
        for(int x2 = x1+1; x2 < N; x2++){
            for(int y1 = 0; y1 < N; y1++){
                for(int y2 = y1+1; y2 < N; y2++){
                    ll fx = x[x1];
                    ll sx = x[x2];
                    ll fy = y[y1];
                    ll sy = y[y2];
                    int num = 0;
                    for(int i = 0; i < N; i++){
                        if(fx <= ax[i] && ax[i] <= sx && fy <= ay[i] && ay[i] <= sy){
                            num++;
                        }
                    }
                    if(num>=K){
                        ans = min(ans, 1LL*(sx-fx)*(sy-fy));
                    }   
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    int comp;
    union_find(int size) : data(size, -1), comp(size) {}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
            comp--;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : (data[x] = root(data[x]));
    }
    int size(int x) {
        return -data[root(x)];
    }
    int components() { return comp; }
};

signed main() {
    int N, M;
    cin >> N >> M;
    vector<pii> e(M);
    cin >> e;
    union_find uf(N);
    int ans = N * (N - 1) / 2;
    vector<int> ans_vec(M);
    REPR(i, M - 1) {
        int a, b;
        tie(a, b) = e[i];
        a--, b--;
        if (uf.same(a, b)) {
            ans_vec[i] = ans;
            continue;
        }
        int dec = uf.size(a) * uf.size(b);
        uf.unite(a, b);
        ans_vec[i] = ans;
        ans -= dec;
    }
    cout << ans_vec << endl;
    return (0^_^0);
}



Measured memory_bytes: 4480
N,Y=map(int,input().split())
for i in range(N+1):
  if 10000*i>Y:
    break
  for j in range(N+1-i):
    k=N-i-j
    S = 10000*i + 5000*j + 1000*k
    if k<0 or S>Y:
      continue
    elif S == Y:
      print(i,j,k)
      exit()
print(-1,-1,-1)


Measured memory_bytes: 65780
#include<bits/stdc++.h>
using namespace std;
bool f;
bool e[26][26];
void dfs(int x,int d){
  //cout << x << ":" << d << endl;
  if(d>26) {
    f=false;
    return;
  }
  if(!f) return;
  for(int i=0;i<26;i++){
    if(e[x][i]) dfs(i,d+1);
  }
}
int main(){
  int n;
  while(cin>>n,n){
    int i,j,k;
    vector<string> v;
    string s;
    memset(e,false,sizeof(e));
    for(i=0;i<n;i++){
      cin >> s;
      v.push_back(s);
    }
    f=true;
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
	if(v[i].find(v[j])==0&&v[i].size()>v[j].size()) f=false;
	int x=min(v[i].size(),v[j].size());
	for(k=0;k<x;k++){
	  if(v[i][k]==v[j][k]) continue;
	  e[v[i][k]-'a'][v[j][k]-'a']=true;
	  break;
	}
      }
    }
    for(i=0;i<26;i++){
      dfs(i,0);
    }
    if(f) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <iostream>
#define INFTY 200000000
using namespace std;

int main(void){
    int n;
    int m[100][100];
    int p[101];

    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &p[i]);
        scanf("%d", &p[i + 1]);
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i > j)
                m[i][j] = INFTY;
            if(i == j) 
                m[i][j] = 0;
        }
    }
    
    for(int i = 0; i <= n - 2; i++){
        m[i][i + 1] = p[i] * p[i + 1] * p[i + 2];
    }

    for(int k = 2; k <= n - 1; k++){
        for(int i = 0; i + k <= n - 1; i++){
            m[i][i + k] = INFTY;
            for(int t = 0; t + 1 <= k; t++){
                m[i][i + k] = min(m[i][i + t] + m[i + t + 1][i + k] + p[i] * p[i + t + 1] * p[i + k + 1], m[i][i + k]);
            }
        }
    }

    printf("%d\n", m[0][n - 1]);

}



Measured memory_bytes: 3220
from collections import defaultdict
from operator import itemgetter

def solve(N, X, D):
    if D < 0:
        D = -D
        X = -X
    elif D == 0:
        if X == 0:
            return 1
        return N + 1

    s = defaultdict(list)
    for k in range(N+1):
        p = k * X % D
        q = k * X // D
        a = k * (k - 1) // 2
        b = (N - 1) * k - a + 1
        s[p].append((a + q, b + q))

    ans = 0
    for v in s.values():
        if not v: continue
        v.sort()
        a, b = v[0]
        for x, y in v[1:]:
            if b < x:
                ans += b - a
                a, b = x, y
            else:
                b = max(b, y)
        ans += b - a
    return ans


if __name__ == "__main__":
    N, X, D = map(int, input().split())
    print(solve(N, X, D))


Measured memory_bytes: 72136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,M; cin>>N>>M;
    int64_t K; cin>>K;
    vector<int64_t> A(N),B(M);
    rep(n,0,N) cin>>A.at(n);
    rep(m,0,M) cin>>B.at(m);

    vector<int64_t> sumA(N+1,0),sumB(M+1,0);
    rep(n,0,N) sumA.at(n+1)=sumA.at(n)+A.at(n);
    rep(m,0,M) sumB.at(m+1)=sumB.at(m)+B.at(m);

    int ans=0;
    rep(i,0,N+1){
        if(sumA.at(i)>K) break;

        int _ans=i;
        int64_t rem=K-sumA.at(i);
        auto itr=upper_bound(ToEnd(sumB),rem);
        int idx=distance(sumB.begin(),itr);
        _ans+=idx-1;

        ans=max(ans,_ans);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
const int T=55440;
 
int dp[33][T];
 
signed main(){
  int n;
  while(cin>>n,n){
    int d[n],t[n];
    int q[111][33];
    for(int i=0;i<n;i++){
      cin>>d[i]>>t[i];
      for(int j=0;j<d[i];j++) cin>>q[i][j];
    }
    //puts("OK");
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
      //cout<<d[i]<<" "<<t[i]<<endl;
      if(__gcd(d[i],T)==1){
	for(int j=0;j<d[i];j++){
	  //cout<<q[i][j]<<endl;
	  dp[d[i]][j]+=q[i][(t[i]+j)%d[i]];
	}
	continue;
      }
      for(int j=0;j<T;j++){
	dp[0][j]+=q[i][(t[i]+j)%d[i]];
      }
    }
    //for(int i=0;i<T;i++) cout<<dp[0][i]<<endl;
    int ans=0;
    for(int i=0;i<T;i++) ans=max(ans,dp[0][i]);
    for(int i=1;i<=24;i++){
      if(__gcd(i,T)==1){
	int tmp=0;
	for(int j=0;j<i;j++) tmp=max(tmp,dp[i][j]);
	ans+=tmp;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

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

    return 0;
}



Measured memory_bytes: 3116
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define INF (1000000000)
#define MOD (1000000007)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef pair<int, int> PII;


int array[100];

int main()
{
	int n, a, b, c, x;
	while (scanf("%d %d %d %d %d", &n, &a, &b, &c, &x), n + a + b + x + x){
		for (int i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		int t = -1;
//		bool stop[100] = {false};
		int cnt = 0;
		while (t < 10000 && cnt < n){
			if (array[cnt] == x){
//				stop[cnt] = true;
				cnt++;
			}
			x = (a * x + b) % c;
			t++;
		}
		
		if (cnt == n){
			printf("%d\n", t);
		}
		else {
			puts("-1");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1196
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
#include <chrono>
#include<unordered_map>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 510;

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

int N;

bool ok(int x, int y, int k)
{
	return x + dx[k] >= 0 && x + dx[k] < N && y + dy[k] >= 0 && y + dy[k] < N;
}

int d[MR][MR];
bool done[MR][MR];

void fix(PII p)
{
	deque<PII> Q;
	Q.push_back(p);

	while (!Q.empty())
	{
		auto akt = Q.front(); Q.pop_front();
		if (!done[akt.first][akt.second])
		{
			REP(k, 4)
				if (ok(akt.first, akt.second, k) && d[akt.first + dx[k]][akt.second + dy[k]] > d[akt.first][akt.second] + 1)
				{
					Q.push_back(MP(akt.first + dx[k], akt.second + dy[k]));
					d[akt.first + dx[k]][akt.second + dy[k]] = d[akt.first][akt.second] + 1;
				}
		}
		else
		{
			REP(k, 4)
				if (ok(akt.first, akt.second, k) && d[akt.first + dx[k]][akt.second + dy[k]] > d[akt.first][akt.second])
				{
					Q.push_front(MP(akt.first + dx[k], akt.second + dy[k]));
					d[akt.first + dx[k]][akt.second + dy[k]] = d[akt.first][akt.second];
				}
		}
	}
}

int main()
{
	LL res = 0;

	scanf("%d", &N);
	REP(i, N)REP(j, N)
		d[i][j] = min(i, min(j, min(N - i - 1, N - j - 1)));

	REP(xxx, N*N)
	{
		int P;
		scanf("%d", &P); P--;
		int r = P / N, c = P % N;
		res += d[r][c];
		done[r][c] = 1;
		fix(MP(r, c));
	}

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

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

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

using namespace std;

int main()
{
    int i;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='A' && s[i+1]=='B' ||s[i]=='B' &&s[i+1]=='A')
        {
            cout<<"Yes"<<endl;
            break;
        }
        else if(s[i]=='B' && s[i+1]=='B' || s[i]=='A' &&s[i+1]=='A')
        {
            continue;
        }
        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++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int h,n;
    cin >> h >> n;
    int a;
    rep(i,n){
        cin >> a;
        h -= a;
        if(h<=0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

/*************************************************************************/

ll dfs(int v, int par, VL &a, VVI &g, bool &good) {
    if (SIZE(g[v]) == 1) {
        return a[v];
    }

    ll pairs = 0, sum = 0;
    for (int u : g[v]) if (u != par) {
        ll fromSon = dfs(u, v, a, g, good);
        
        ll b = (sum - fromSon) / 2;
        b = max(b, 0LL);
        b = min(b, pairs);
        
        pairs = min(fromSon + b, sum - b);
        sum += fromSon;
    }
    
    ll x = 2 * a[v] - sum;
    ll y = a[v] - x;
    
    good = good && (x >= 0) && (y >= 0) && (y <= pairs);

    return x;
}

bool solve(int n, VL &a, VVI &g) {
    if (n == 2) {
        return a[0] == a[1];
    }
    
    int root = 0;
    while (g[root].size() == 1) root++;
    
    bool good = true;
    if (dfs(root, -1, a, g, good) > 0) {
        good = false;
    }
    
    return good;
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VL a(n);
    FOR(i,0,n-1) {
        cin >> a[i];
    }
    
    VVI g(n);
    FOR(_,1,n-1) {
        int u, v;
        cin >> u >> v; u--; v--;
        
        g[u].pb(v);
        g[v].pb(u);
    }
    
    cout << (solve(n, a, g) ? "YES" : "NO");

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 14464
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n+1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  map<int, int> table;
  for (int i = 1; i <= n; i++) {
    int tmp = table[a[i] + i];
    table[a[i] + i] = tmp+1;
  }

  ll result = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = i - a[i];
    result += table[tmp];
  }

  cout << result << endl;
}


Measured memory_bytes: 21848
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

// "aab$baabaa"
//z=x100031021
// i=5
// L,R = 5,5 -> 5,8 -> 5,7
// i=6
// k=1

// "aaaaaa"
//z=x54321
// i=1
// L,R = 1,6 -> 1,5
// i=2
// k=1
// L,R = 2,6

// "aabaab"
//z=x10310
// i=3
// L,R = 3,6 -> 3,5
// i=4
// k=1
// L,R = 2,6

func getZarray(s string) *[]int {
	z := make([]int, len(s))
	z[0] = -1
	l, r := 0, 0
	for i := 0; i < len(s); i++ {
		if r < i {
			l, r = i, i
			for r < len(s) && s[r-l] == s[r] {
				r++
			}
			z[i] = r - l
			r--
		} else {
			k := i - l
			if z[k] < r-i+1 {
				z[i] = z[k]
			} else {
				l = i
				for r < len(s) && s[r-l] == s[r] {
					r++
				}
				z[i] = r - l
				r--
			}
		}
	}
	return &z
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := nextString()
	var z *[]int
	ans := 0
	for i := 0; i < n; i++ {
		debugf("%v\n", z)
		z = getZarray(s[i:])
		for j := range *z {
			k := (*z)[j]
			if k > j {
				k = j
			}
			if k > ans {
				ans = k
			}
		}
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 9744
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
    LL n;
    cin >> n;
    LL p10 = 1;
    LL cur = 0;
    for(LL g = 0; g < 200; g++){
        if(g % 9 == 0 && g != 0) p10 *= 10;
        if(p10 + cur <= n){
            cur += p10;
        } else {
            cout << g << endl;
            break;
        }
    }
}


Measured memory_bytes: 764
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

s=get_nsp.sort.join("")
t=get_nsp.sort{|x,y| y<=>x}.join("")
puts yn_judge(s<t)

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int H, N;
  cin >> H >> N;
  vector<int> q(N);
  for(int i = 0; i < N; i++) {
    cin >> q.at(i);
  }
  sort(q.begin(), q.end());
  int w = 0;
  for(int i = 0; i < N; i++) {
    w = w + q.at(i);
  }
  if(H <= w) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

const int MAX = 3e5 + 5;
int n, k, p[MAX];
double t[MAX];

int main() {
	scanf("%d%d", &n, &k);

	for(int i = 1; i <= n; i++) {
		scanf("%d", &p[i]);

		t[i] = p[i] * (p[i] + 1) / 2;
		t[i] /= p[i];
		t[i] += t[i - 1]; 
	}

	double ans = 0;
	for(int i = 1; i + k - 1 <= n; i++)
		ans = max(ans, t[i + k - 1] - t[i - 1]);

	printf("%.7lf\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(void){
    int n,m,x;
    cin >> n >> m >> x;
    int A[n+1],B[n+1]={};
    for(int i=0;i<m;i++){
        cin >> A[i];
        B[A[i]] = 1;
    }
    int p=0,q=0;
    for(int i=x;i<n+1;i++){
        if(B[i]==1){
            p++;
        }
    }
    for(int i=x;i>0;i--){
        if(B[i]==1){
            q++;
        }
    }
    cout << min(p,q) << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int a, b;
    cin >> a >> b;
    int res{};
    for( int i = a; i <= b; ++i )
    {
        string tmp = to_string( i );
        if( equal( rbegin( tmp ), rend( tmp ), ALL( tmp ) ) )
        {
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
p = p[:x]
q = q[:y]
l = p + q + r
l.sort(reverse = True)
print(sum(l[:x+y]))

Measured memory_bytes: 29548
#include<iostream>
#include <cstdlib>
#include<list>
#include<string>
#include<stack>
using namespace std;
int main() {
	int n, m, data[200002] = {0}; cin >> n >> m;
	for (int i = 0; i <m; i++)
	{
		int a, b;
		cin >> a>>b;
		data[a]++; data[b]++;
	}
	for (int i = 0; i < n; i++)
	{
		if (data[i] % 2 == 1) {
			cout << "NO"; return 0;
		}
	}
	cout << "YES";
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
#include <climits>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  int INF = INT_MAX;
  // ll mod = 998244353;
  // lld PI = 3.141592653;







  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
      int n;
      cin>>n;
      ll ans = 0;
      for (int a = 1; a<=n;a++){
        ans+= (n-1)/a;
      }
      cout<<ans<<"\n";

}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
ld dp[302][302][302];
int n;
ld ds(int a, int b, int c) {
	if(a+b+c == 0) {return 0;}
	if(a < 0 || b < 0 || c < 0) {return 0;}
	if(dp[a][b][c] != 0) {return dp[a][b][c];}
	ld pa=a,pb=b,pc=c;
	ld pz = n-(a+b+c);
	pa /=n;
	pb /=n;
	pc /=n;
	pz /=n;
	ld ret = 1+(pa*ds(a-1,b,c))+(pb*ds(a+1,b-1,c))+(pc*ds(a,b+1,c-1));
	return dp[a][b][c] = ret/(1-pz);
}
int main() {
	scanf("%d ",&n);
	int q[3];
	memset(q,0,sizeof(q));
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++) {
		int t;
		scanf("%d ",&t);
		t--;if(t>=0) {q[t]++;}
	}
	cout << setprecision(15) << ds(q[0],q[1],q[2]) << '\n';
}


Measured memory_bytes: 430720
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;
	
	scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
	
	if ((x - r) >= 0 && (y - r) >= 0 && (x + r) <= W && (y + r) <= H){
		printf("Yes");
	} else {
		printf("No");
	}
	
	printf("\n");
	
	return 0;
}




Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int a[100000];

int main() {
    int n;
    cin >> n;
    rep(i, n)cin >> a[i];
    sort(a, a + n);
    int cur = a[0];
    int mn = cur;
    int pre = cur;
    while(1) {
        rep(i, n) {
            if (mn > a[i] % pre && a[i] % pre) {
                pre = a[i] % pre;
            }
        }
        if(cur == pre || pre < 2) {
            cout << pre << endl;
            return 0;
        }else{
            cur = pre;
        }
    }
}



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

int main(){
    string a,b;
    cin >> a >> b;
    if(a.size()>b.size()){
        cout << "GREATER" << endl;
        goto Exit;
    }else if(a.size()<b.size()){
        cout << "LESS" << endl;
        goto Exit;
    }else{
        rp(i,a.size()){
            if(a.at(i)-'0'>b.at(i)-'0'){
                cout << "GREATER" << endl;
                goto Exit;
            }else if(a.at(i)-'0'<b.at(i)-'0'){
                cout << "LESS" << endl;
                goto Exit;
            }else if(a.at(i)-'0'==b.at(i)-'0'){
                continue;
            }
        }
    }
    cout << "EQUAL" << endl;
    
Exit:
    ;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}


const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

void solve(){
     int n;cin >> n;
     vector<ll>a(n);
     for(int i = 0;i<n;i++) cin >> a[i];
     vector<ll>r(n);
     vector<ll>l(n);
     for(int i = 0;i<n;i++)
        if(i==0) l[i] = 0;
        else l[i] = gcd(a[i-1],l[i-1]);
     for(int i = n-1;i>=0;i--)
        if(i==n-1) r[i] = 0;
        else r[i] = gcd(r[i+1],a[i+1]);
     ll maxi = 0;
     for(int i = 0;i<n;i++){
        maxi = max(gcd(l[i],r[i]),maxi);
     }
     cout << maxi;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 5528
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <regex>
#include <string>
#include <stack>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

char S[3][120];
int i[3];

int solve(int p) {
	if (S[p][i[p]] == '\0')
		return p;
	else {
		int p_new = (S[p][i[p]] - 'a');
		i[p]++;
		solve(p_new);
	}

}

int main()
{
	scanf("%s%s%s", S[0], S[1], S[2]);

	char ans;
	ans = 'A' + solve(0);
	printf("%c\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n>>k;

	char ar[n+1];
	cin>>ar;

	ar[k-1]=ar[k-1]+32;
	cout<<ar;
	return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
M = 10**9+7

pp = [None]*n
v = 1
for i in range(n):
    pp[i] = v
    v *= 2
    v %= M

a.sort()
a = a[::-1]
ans = 0
ans += a[0]*(pow(2, 0, M))*pow(2, n-1,M)
for i in range(1,n):
    num = a[i]
    ans += num*(pp[i] + i*pp[i-1])*pp[n-i-1]
    ans %= M
ans *= pow(2,n,M)
ans %= M
print(ans)

Measured memory_bytes: 26024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

int main()
{
	std::vector<int> vec(10);
	for (int i = 0; i < 10; ++i) {
		std::cin >> vec[i];
	}
	std::sort(vec.begin(), vec.end(), std::greater<int>());
	for (int i = 0; i < 3; ++i) {
		std::cout << vec[i] << std::endl;
	}
	return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<pair<int, int>> a(1<<n);
  for (int i = 0; i < (1<<n); ++i) {
    cin >> a[i].first;
    a[i].second = 0;
  }

  auto join = [&](auto l, auto r) {
    pair<int, int> ret;
    ret.first = max(l.first, r.first);
    if (ret.first == l.first) ret.second = max(l.second, r.first);
    else ret.second = max(l.first, r.second);
    return ret;   
  };

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < (1<<n); ++j) {
      if ((j>>i)&1) {
        a[j] = join(a[j], a[j ^ (1<<i)]);
      }
    } 
  }

  int ans = 0;
  for (int i = 1; i < (1<<n); ++i) {
    ans = max(ans, a[i].first + a[i].second);
    cout << ans << '\n';
  }
}



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

int distance(int a, int b, int c, int d){
    int e = abs(a - b);
    int f = abs(c - d);
    return e + f;
}

int main()
{
	int n, m;
	cin >> n >> m;
	int a[n], b[n];
	for(int i = 0; i < n; ++i)
	    cin >> a[i] >> b[i];
	int c[m], d[m];
	for(int j = 0; j < m; ++j)
	    cin >> c[j] >> d[j];
	
	int dis[n][m];
	for(int i = 0; i < n; ++i){
	    for(int j = 0; j < m; ++j){
	        dis[i][j] = distance(a[i], c[j], b[i], d[j]);
	    }
	}
	
	int pre;
	for(int i = 0; i < n; ++i){
	    pre = 0;
	    for(int j = 1; j < m; ++j){
	        if(dis[i][pre] > dis[i][j])
	            pre = j;
	    }
	    cout << pre+1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
int main( )
{
  LL n=read( ),a=read( ),b=read( );
  if(a>b) {puts("0");return 0;}
  if(n==1) {printf("%d",a==b);return 0;}
  else printf("%lld",(b-a)*(n-2)+1);
  return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigInteger[] num = new BigInteger[n];
		BigInteger tmp = BigInteger.ONE;
		for(int i = 0; i < n; i++) {
			num[i] = new BigInteger(sc.next());
			tmp = tmp.divide(tmp.gcd(num[i]));
			tmp = tmp.multiply(num[i]);
		}
		tmp = tmp.subtract(BigInteger.ONE);
		BigInteger ans = BigInteger.ZERO;
		for(int i = 0; i < n; i++) {
			ans = ans.add(tmp.mod(num[i]));
		}
		System.out.println(ans.toString());
	}
}

Measured memory_bytes: 50420
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string a;
    cin >> a;
    if(a[0] == '7' || a[1] == '7' || a[2] == '7'){
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    
    cout << endl;
}


Measured memory_bytes: 3616
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)


Measured memory_bytes: 5596