akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		
		int num = scan.nextInt();
		
		for(int i = 0; i < num+1; i++) {
			int x = scan.nextInt();
			list.add(x);
		}
		
		Collections.sort(list);
		
		HashSet<Integer> set = new HashSet<>();
		for(int i = 0; i < list.size()-1; i++) {
			set.add(list.get(i+1) - list.get(i));
		}
		
		int g=0;
		for (int x : set) {
			g=gcd(g, x);
		}
		
		System.out.println(g);
	}
	static int gcd(int x,int y)
	{
		return y>0?gcd(y,x%y):x;
	}
}


Measured memory_bytes: 54124
#include <bits/stdc++.h>
#ifdef tester
    #include "stuff/prettyprint.hpp"
#endif
using namespace std;

#define iosx ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(20)
#define hell 1000000007LL
#define INF 1000000000000000LL
#define MOD 1000000007LL
#define hmap unordered_map
#define hset unordered_set
#define PQ priority_queue
#define F first
#define S second
#define lld long double
#define ll long long
#define all(C) begin(C),end(C)
#define tr(C,it,cond) for(auto it = begin(C); cond and it!=end(C); ++it)
#define rep(i,a,b) for(ll i = (a); i < (b); ++(i))
#define pb push_back
#define vi vector<ll>
#define pii pair<ll,ll>
#define exists(V,ele) (V).find((ele)) != (V).end()
#define index(V, ele) distance(V.begin(), find(all(V), ele))
#define whats(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {} template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
#ifdef tester 
    cerr << *it << " = " << a << endl;	err(++it, args...); 
#endif 
}
struct mycmp {
    bool operator() (const pii& a, const pii& b) const {
        return a.S-a.F > b.S - b.F;
    }
};

#define N 100010
ll t,n,k,m,q,d;

// vim cli: !g++ -Dtester sol.cpp ; ./a.out ; rm a.out
int main() { iosx;
    //cin>>t;while(t--){
    cin>>n;
    vi a(3*n), l(3*n, -1), r(3*n, -1);
    multiset<ll> pl,pr;
    
    rep(i,0,3*n)
        cin>>a[i];

    ll s1=0,s2=0;
    rep(i,0,n)
        pl.insert(a[i]), s1+=a[i];
    l[n-1]=s1;
    rep(i,2*n,3*n)
        pr.insert(a[i]), s2+=a[i];
    r[2*n]=s2;

    // update l
    rep(i,n,2*n){
        if (*pl.begin() < a[i])
            s1+=a[i], s1-=*pl.begin(), pl.erase(pl.begin()), pl.insert(a[i]);
        l[i]=s1;
    }

    // update r
    for(int i=2*n-1;i>=n;--i){
        if (*pr.rbegin() > a[i])
            s2+=a[i], s2-=*pr.rbegin(), pr.erase(prev(pr.end())), pr.insert(a[i]);
        r[i]=s2;
    }

    whats(l,r);
    q=-INF;
    rep(i,n-1,2*n)
        q=max(q, l[i]-r[i+1]);
    cout<<q;
    //}
    // whats(t,v);
    return 0;
}

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

typedef long long ll;

int main() {
    ll k, a, b;
    scanf("%lld%lld%lld", &k, &a, &b);
    ll ans = 1;
    if (a + 2 >= b) {
        ans += k;
    } else {
        ll min = std::min(a - 1, k);
        k -= min;
        ans += min;
        if (ans == a) {
            ll t1 = k / 2;
            ll t2 = k % 2;
            ans += t1 * (b - a);
            ans += t2;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

struct Fordfulerson{
  const int INF = 1<<28;
  struct edge{
    int to,cap,rev;
    edge(){};
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){};
  };
  int n;
  vector<vector<edge> > G;
  vector<int> used;

  Fordfulerson(){};
  Fordfulerson(int sz):n(sz),G(n),used(n){}

  void add_edge(int from,int to,int cap){
    G[from].push_back(edge(to,cap,G[to].size()));
    G[to].push_back(edge(from,0,G[from].size()-1));
  }

  int dfs(int v,int t,int f){
    if(v == t) return f;
    used[v] = true;
    for(int i=0;i<(int)G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to] && e.cap > 0){
	int d = dfs(e.to,t,min(f,e.cap));
	if(d > 0){
	  e.cap -= d;
	  G[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }

  int max_flow(int s,int t){
    int flow = 0;
    for(;;){
      fill(used.begin(),used.end(),0);
      int f = dfs(s,t,INF);
      if(f == 0) return flow;
      flow += f;
    }
  }
};

struct SCC{
  int n;
  vector<vector<int> > G,rG,T,C;
  vector<int> vs,used,belong;
  SCC(){};
  SCC(int sz):n(sz),G(sz),rG(sz),used(sz),belong(sz){}

  void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  void dfs(int v){
    used[v] = 1;
    for(int i=0;i<(int)G[v].size();i++){
      if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
  }

  void rdfs(int v,int k){
    used[v] = 1;
    belong[v] = k;
    C[k].push_back(v);
    for(int i=0;i<(int)rG[v].size();i++) {
      if(!used[rG[v][i]]) rdfs(rG[v][i],k);
    }
  }

  int build(){
    fill(used.begin(),used.end(),0);
    vs.clear();
    for(int v=0;v<n;v++){
      if(!used[v]) dfs(v);
    }

    fill(used.begin(),used.end(),0);
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
      if(!used[vs[i]]){
	T.push_back(vector<int>());
	C.push_back(vector<int>());
	rdfs(vs[i],k++);
      }
    }
    return k;
  }

};

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(int n):n(n),r(n,1),p(n){iota(p.begin(),p.end(),0);}
  int find(int x){
    if(x==p[x]) return x;
    return p[x]=find(p[x]);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,m;
  while(cin>>n>>m,n){
    vector<int> x(m),y(m),c(m);
    int ans=0;
    UnionFind uf(n);
    SCC scc(n);
    for(int i=0;i<m;i++){
      cin>>x[i]>>y[i]>>c[i];
      if(c[i]<=0) ans+=c[i];
      else{
	scc.add_edge(x[i],y[i]);
	uf.unite(x[i],y[i]);
      }
    }
    if(uf.r[uf.find(0)]!=n){
      cout<<ans<<endl;
      continue;
    }
    scc.build();
    //cout<<ans<<endl;
    auto b=scc.belong;
    vector<int> v;
    int t=-1;
    for(int i=0;i<m;i++){
      if(c[i]<=0) continue;
      if(b[x[i]]==b[y[i]]){
	v.emplace_back(c[i]);
	continue;
      }
      if(t<0||c[i]<t) t=c[i];
    }
    sort(v.begin(),v.end());
    if(!v.empty()&&(t<0||v[0]+v[1]<t)) t=v[0]+v[1];
    cout<<ans+t<<endl;
  }
  return 0;
}

Measured memory_bytes: 3168
// 2_abc139_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int cnt = 1;
    int ans = 0;
    while(cnt < b){
        cnt += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
int main() {
  long long w,h;
  std::cin >> h >> w;

  if (w == 1 || h == 1) {
    std::cout << 1;
  } else {
    std::cout << w*(h/2) + (h%2)*(w/2+w%2);
  }
  return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
An = list(map(int,input().split()))
a = 1
if 0 in An:
    print("0")
    sys.exit()
else:
    for i in range(N):
        a *= An[i]
        if a > 10**18:
            print("-1")
            sys.exit()
    if a <= 10**18:
        print(a)
        sys.exit()


Measured memory_bytes: 21760
import sys
input = sys.stdin.readline

rl = lambda: list(map(int, input().split()))

x, y, a, b, c = rl()
p = rl()
q = rl()
r = rl()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
res = sum(sorted(p[:x] + q[:y] + r, reverse=True)[:x+y])
print(res)


Measured memory_bytes: 102764
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	stock := map[int]int{}
	for _, l := range as {
		stock[l]++
	}
	pairs := []int{}
	for b, s := range stock {
		if s := s >> 1; s > 0 {
			pairs = append(pairs, b)
			if s>>1 > 0 {
				pairs = append(pairs, b)
			}
		}
	}
	if len(pairs) < 2 {
		fmt.Println(0)
		return
	}
	sort.Sort(sort.Reverse(sort.IntSlice(pairs)))
	fmt.Println(pairs[0] * pairs[1])
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 8716
# Coding is about expressing your feeling and there is always a better way to express your feeling _feelme
import sys,math
#sys.stdin,sys.stdout=open('input.txt','r'),open('output.txt','w')
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# np.set_printoptions(sign=' ',legacy='1.13') # legacy add space at sign position
# sys.setrecursionlimit(500000)


# code here ----->
MAX = 500001

# structure to store queries
class Query:
    def __init__(self, l, r, idx):
        self.l = l
        self.r = r
        self.idx = idx

# updating the bit array
def update(idx, val, bit, n):
    while idx <= n:
        bit[idx] += val
        idx += idx & -idx

# querying the bit array
def query(idx, bit, n):
    summ = 0
    while idx:
        summ += bit[idx]
        idx -= idx & -idx
    return summ

def answeringQueries(arr, n, queries, q):

    bit = [0] * (n + 1)

    last_visit = [-1] * MAX

    ans = [0] * q

    query_counter = 0
    for i in range(n):
        if last_visit[arr[i]] != -1:
            update(last_visit[arr[i]] + 1, -1, bit, n)
        last_visit[arr[i]] = i
        update(i + 1, 1, bit, n)

        while query_counter < q and queries[query_counter].r == i:
            ans[queries[query_counter].idx] =  query(queries[query_counter].r + 1, bit, n) -  query(queries[query_counter].l, bit, n)
            query_counter += 1
    for i in range(q):
        print(ans[i])

if __name__ == "__main__":
    n,q=iia()
    a=iia()
    queries=[]
    for i in range(q):
        aa,bb=iia()
        aa-=1
        bb-=1
        queries.append(Query(aa,bb,i))
    queries.sort(key = lambda x: x.r)
    answeringQueries(a, n, queries, q)


Measured memory_bytes: 182676
N = int(input())
BOX = {}

for i in range(N):
  S = input()
  if S in BOX:
    BOX[S] = (BOX[S] + 1)
  else:
    BOX[S] = 0

MAX = max(BOX.values())
keys = [k for k, v in BOX.items() if v == MAX]
keys = sorted(keys)
for i in range(len(keys)):
  print(keys[i])


Measured memory_bytes: 35640
n = int(input())
aa = [min(8, int(a) // 400) for a in input().split()]
over3200 = aa.count(8)
colors = len(set(aa))
_min = colors - 1 if over3200 and n > over3200 else colors
_max = colors + over3200 - 1 if over3200 else colors
print(_min, _max)


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

const int MAX_N = 1e5 + 10;
long long N;
long long A[MAX_N];

int main () {
	long long m = 0;
	scanf("%ld", &N);

	for (long long i = 0; i < N; ++i) {
		scanf("%ld", &A[i]);
	}

	for (long long i = 0; i < N; ++i) {
		if (A[i] % 2 != 0) ++m;
	}

	if (m % 2 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}


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

    int l,r;
    cin >> l >> r;
    int mod = 2019;
    vector<int> L;
    int i = l;
    int j = r;
    if (r-l+1 >=2019) {
        cout << 0 << "\n";
        return 0;
    }
    for(int i=l; i<=r; ++i){
        L.pb(i%mod);
    }
    vector<int> LL;
    rep(i,L.size()) {
        for(int j=i+1; j<L.size(); ++j) {
            LL.pb(L[i]*L[j]%mod);

        }
    }
    sort(all(LL));
    cout << LL[0] << "\n";
}


Measured memory_bytes: 8684
def f(n):
    return int(n/2) if n%2==0 else 3*n+1

an = int(input())
i = 2
res = []
res.append(an)
while(True):
    am = f(res[-1])
    if am in res:
        print(i)
        break
    res.append(am)
    i += 1


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll a,b,n;
	cin>>a>>b>>n;
	if(n%b==0)
	{
		n--;
		ll ans=(a*n/b)-a*(n/b);
		cout<<max((ll)0,ans)<<endl;
	}
	else
	{
		ll ans1=(a*n/b)-a*(n/b);
		n=(n/b)*b;
		n--;
		ll ans=(a*n/b)-a*(n/b);
		cout<<max((ll)0,max(ans1,ans))<<endl;
	}
}

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,x,m; cin >> n >> x >> m;
	if(n<=200000){
		ll res=x;
		n--;
		ll cur=x*x%m;
		for(int i=0;i<n;i++){
			res+=cur;
			cur=cur*cur%m;
		}
		cout << res << endl;
		return 0;
	}
	ll res=x;
	n--;
	vector<ll> v;
	set<ll> st;
	ll cur=x*x%m;
	while(1){
		if(st.find(cur)!=st.end())break;
		n--;
		res+=cur;
		v.push_back(cur);
		st.insert(cur);
		cur=cur*cur%m;
	}
	bool flag=0;
	ll sum=0;
	ll cnt=0;
	for(ll p:v){
		if(p==cur){
			flag=1;
		}
		if(flag){
			sum+=p;
			cnt++;
		}
	}
	res+=(n/cnt)*sum;
	n%=cnt;
	for(int i=0;i<n;i++){
		res+=cur;
		cur=cur*cur%m;
	}
	// int cnt=0;
	// ll cur=x%m;
	// ll sum=0;
	// while(1){
	// 	if(st.find(cur)!=st.end())break;
	// 	st.insert(cur);
	// 	cnt++;
	// 	sum+=cur;
	// 	cur=cur*cur%m;
	// }
	// n--;
	// ll res=x+(n/cnt)*sum;
	// n%=cnt;
	// for(int i=0;i<n;i++){
	// 	res+=cur;
	// 	cur=cur*cur%m;
	// }
	cout << res << endl;
}

Measured memory_bytes: 5952
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
using namespace std;
#define INF 200000000

int dp[100001];

int main(){
  int n;
  cin>>n;
  int c_6=1;
  vector<int> v;
  v.push_back(1);
  for(int i=1; c_6<100000; i++){
    c_6*=6;
    if(c_6>100000) break;
    v.push_back(c_6);
  }
  
  int c_9=1;
  for(int i=1; c_9<100000; i++){
    c_9*=9;
    if(c_9>100000) break;
    v.push_back(c_9);
  }
  
  sort(v.begin(), v.end(),greater<int>());
  for(int i=0; i<=n; i++) dp[i]=INF;
  
  
  for(int i=0; i<v.size(); i++){
    for(int j=1; j<=n; j++){
      if(j%v[i]==0) dp[j]=min(dp[j],j/v[i]);
      if(j-v[i]>=1) dp[j]=min(dp[j],dp[j-v[i]]+1);
    }
  }
  
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

R, C, k = map(int, input().split())
field = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    r -= 1; c -= 1
    field[r][c] = v

# dp[taken 0 - 2][R][C]
dp = [[-1] * (C + 1) * (R + 1) for _ in range(4)]
dp0 = dp[0]; dp1 = dp[1]; dp2 = dp[2]; dp3 = dp[3]
dp[0][0] = 0
for j in range(C):
    for i in range(R):
        ij = i * C + j
        ij1 = ij + 1
        i1j = ij + C
        item = field[i][j]
        # Use
        if item:
            dp1[ij1] = max(dp1[ij1], dp0[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp0[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp0[ij]) 
        dp0[ij1] = max(dp0[ij1], dp0[ij]) 
        if item:
            dp2[ij1] = max(dp2[ij1], dp1[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp1[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp1[ij]) 
        dp1[ij1] = max(dp1[ij1], dp1[ij]) 
        if item:
            dp3[ij1] = max(dp3[ij1], dp2[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp2[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp2[ij]) 
        dp2[ij1] = max(dp2[ij1], dp2[ij]) 
        dp0[i1j] = max(dp0[i1j], dp3[ij]) 
        dp3[ij1] = max(dp3[ij1], dp3[ij]) 

ans = 0
for i in range(4):
    for j in range(R + 1):
        ans = max(ans, dp[i][j * C + C - 1])
print(ans)

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

using namespace std;

int main() {
   int count, distance, answer = 0;

   cin >> count >> distance;

   for(int i=0; i<count; i++) {
      double x, y;
      cin >> x >> y;
      if(sqrt(x * x + y * y) <= (double)distance)
         answer += 1;
   }

   cout << answer << endl;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll x;
  cin >> x;
  ll ans = (x / 500) * 1000;
  x %= 500;
  ans += (x / 5) * 5;
  cout << ans;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    int n;
    cin >> n;
    int a[n];
    ll ans = 0;
    REP(i,n){
        cin >> a[i];
        ans += a[i];
    }
    ll min1 = LINF;
    ll snuke = 0;
    REP(i,n-1){
        snuke += a[i];
        if(min1>abs(ans-2*snuke)) min1=abs(ans-2*snuke);
    }
    cout << min1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int a;
  cin >> a;
  cout << 3*a*a << endl;
  }

Measured memory_bytes: 256
N = int(input())
S = input()

c_b = 0
c_w = S.count('.')
ans = c_w

for i in range(N):
    if S[i] == '#':
        c_b += 1
    else:
        c_w -= 1
    ans = min(c_b+c_w, ans)

print(ans)


Measured memory_bytes: 3500
#include <stdio.h>

int main( void ) {

	double a, b, c, d, e, f, x, y;

	while ( scanf( "%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f ) != EOF ) {
 
        printf( "%.3lf %.3lf\n", ( c * e - b * f ) / ( a * e - b * d ) + 0.0, ( c * d - a * f ) / ( b * d - a * e ) + 0.0 );

	}

	return 0;

}

Measured memory_bytes: 652
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll a, b, x;
  cin>>a>>b>>x;
  a += (x-a%x)%x;
  b -= b%x;
  cout<<(b-a)/x+1<<endl;
}



Measured memory_bytes: 3644
#include <cstdio>

int f1(int _n){
	if(_n >= 100000){
    	return 90909;
    }else if(_n >= 10000){
    	return (_n - 10000 +1) + 909;
    }else if(_n >= 1000){
    	return 909;
    }else if(_n >= 100){
    	return (_n - 100 +1) + 9;
    }else if(_n >= 10){
    	return 9;
    }else{
    	return _n;
    }
}

int main (void)
{
    int n;
    scanf("%d", &n);
    printf("%d\n", f1(n));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

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

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

    sort(d.begin(), d.end());
    sort(t.begin(), t.end());
    ll j = 0; string ans = "NO";
    rep(i, n) { 
        if (d[i] == t[j]) 
        {
            j++;
        }
        if (j == m) { ans = "YES"; }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

        class Main{
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int n, m, i, j;
	int a[][] = new int[100][100];
	int b[] = new int[100];
	int c[] = new int[100];
	n = scan.nextInt();
	m = scan.nextInt();
	for(i = 0; i < n; i++) {
		for(j = 0; j < m; j++) {
			a[i][j] = scan.nextInt();
		}
	}
	for(j = 0; j < m; j++) {
		b[j] = scan.nextInt();
	}
	for(i = 0; i < n; i++) {
		for(j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
		System.out.println(c[i]);
	}

	}
}

Measured memory_bytes: 40464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    int sz=-1;
    for(int m=1;m*(m+1)<=2*n;m++){
        if(m*(m+1)==2*n){
            sz=m+1;
            break;
        }
    }
    if(sz==-1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes\n"<<sz<<endl;
        vector<int> ans[sz];
        int num=1;
        for(int i=0;i<sz;i++){
            for(int j=i+1;j<sz;j++){
                ans[i].emplace_back(num);
                ans[j].emplace_back(num);
                num++;
            }
        }
        for(int i=0;i<sz;i++){
            cout<<ans[i].size();
            for(auto x:ans[i])cout<<' '<<x;
            cout<<endl;
        }
    }
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 1000+10;
const int oo = 1e9;
int N,M,r0,c0,r1,c1;
char A[maxn][maxn];
int dist[maxn][maxn];

int can(int i,int j){
	if(i < 0 || i >= N || j < 0 || j >= M || A[i][j] == '#')return 0;
	return 1;
}
int dii[] = {-1,0,0,1};
int djj[] = {0,-1,1,0};

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	cin >> r0 >> c0 >> r1 >> c1; r0--; c0--; r1--; c1--;
	forn(i,0,N)forn(j,0,M)cin >> A[i][j];
	forn(i,0,N)forn(j,0,M)dist[i][j] = oo;
	priority_queue<iii,vector<iii>,greater<iii>> pq;
	dist[r0][c0] = 0; pq.push({0,{r0,c0}});
	while(pq.size()){
		auto act = pq.top(); pq.pop();
		int d = act.fi;
		ii u = act.se;
		if(d > dist[u.fi][u.se])continue;
		
		forn(k,0,4){
			ii v;
			v.fi = u.fi+dii[k];
			v.se = u.se+djj[k];
			if(!can(v.fi,v.se))continue;
			if(dist[u.fi][u.se] < dist[v.fi][v.se]){
				dist[v.fi][v.se] = dist[u.fi][u.se];
				pq.push({dist[v.fi][v.se],v});
			}
		}
		
		for(int di = -2; di <= 2; di++){
			for(int dj = -2; dj <= 2; dj++){
				if(!di && !dj)continue;
				ii v;
				v.fi = u.fi+di;
				v.se = u.se+dj;
				if(!can(v.fi,v.se))continue;
				if(dist[u.fi][u.se]+1 < dist[v.fi][v.se]){
					dist[v.fi][v.se] = dist[u.fi][u.se]+1;
					pq.push({dist[v.fi][v.se],v});
				}
			}
		}
	}
	
	int res = dist[r1][c1];
	if(res >= oo){
		res = -1;
	}
	cout << res << '\n';
	
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 8644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

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

    vector<string> vec;

    for (int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        vector<char> chars;
        for (int i = 0; i < tmp.length(); i++) {
            chars.push_back(tmp[i]);
        }
        sort(chars.begin(), chars.end());
        string str(chars.begin(), chars.end());
        vec.push_back(str);
    }

    unordered_map<string, int> mp;

    long sum = 0;
    for (string s : vec) {
        auto it = mp.find(s);
        if (it != mp.end()) {
            sum += mp[s];
            mp[s] = mp[s] + 1;
        } else {
            mp[s] = 1;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 11380
l=list(map(int,input().split()))
l.sort()
a,b,c=l[0],l[1],l[2]
if (c-a)%2==1 and (c-b)%2==1:
  print(1+(2*c-2-a-b)//2)
elif (c-a)%2==0 and (c-b)%2==0:
  print((2*c-a-b)//2)
else:
  print(1+(2*c+1-a-b)//2)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<map>
#include<queue>
#include<bitset>
#define mk make_pair
#define fi first
#define nd second
#define pii pair<int,int>
#define pb push_back
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
inline ll read() {ll x = 0; char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {if(ch == '-') w = -1;
ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
const int N = 1e5 + 6;
int n;
ll x[N], t[N];
ll m, k;
int b[N];
int c[N], tmp[N];
void solve() {
	for(; k; k >>= 1) {
		
		if(k & 1) {
			for(int i = 1;  i <= n; ++i) tmp[i] = t[i];
			for(int i = 1; i <= n; ++i) t[i] = tmp[c[i]];
		}
		for(int i = 1; i <= n; ++i) tmp[i] = c[i];
		for(int i = 1; i <= n; ++i) c[i] = tmp[c[i]];
	}
}
int main() {
	n = read();
	for(int i = 1; i <= n; ++i) x[i] = read(), t[i] = x[i] - x[i - 1], c[i] = i;
	m = read(), k = read();
	for(int i = 1; i <= m; ++i) {
		b[i] = read();
		swap(c[b[i]], c[b[i] + 1]);
	}
	solve();
	ll res = 0;
	for(int i = 1; i <= n; ++i) {
		res += t[i];
		writeln(res);
	}
	return 0;
}

Measured memory_bytes: 3968
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

vector<pair<int, int>> g[maxn];
int dist[maxn];

int dijkstra(int src, int n) {
    memset(dist, 63, sizeof dist);
    set<pair<int, int>> st;

    dist[src] = 0;
    st.insert({0, src});
    while (!st.empty()) {
        auto top = *(st.begin());
        st.erase(st.begin());
        int node_dist = top.first;
        int node = top.second;

        for (auto x : g[node]) {
            auto dest = x.first;
            if (dist[dest] > node_dist + x.second) {
                auto location = st.find({dest, dist[dest]});
                if (location != st.end())
                    st.erase(location);
                dist[dest] = node_dist + x.second;
                st.insert({dist[dest], dest});
            }
        }
    }
    int mn = 0, id = 0;
    for (int i = 0; i < n; i++)
        if (dist[i] > mn) {
            id = i, mn = dist[i];
        }
    return id;
}

void solve() {
    int n;
    cin >> n;

    for (int i = 0; i < n - 1; ++i) {
        int a, b, w;
        cin >> a >> b >> w;

        g[a].push_back({b, w});
        g[b].push_back({a, w});
    }

    int get = dijkstra(0, n);
    int p = dijkstra(get, n);
    cout << dist[p] << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 12672
import math

a,b,x=(int(x) for x in input().split())
if(x>a*a*b/2):
  print(math.degrees(math.atan( float(2*b/a)-float(2*x/a/a/a) )))
else:
  print(math.degrees(math.atan( float((a*b*b)/(2*x)) )))

Measured memory_bytes: 3060
function Main(inp) {
    var input = inp.split("\n");
    input = input[0].split(' ').map(function(n) { return Number(n);});
    var a = input[0];
    var b = input[1];
    console.log(Math.ceil((a + b) / 2));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int n;
vector<int> a;
int main() {
	scanf("%d", &n);
	a.resize(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a.rbegin(), a.rend());

	int cur = 0;
	while(cur < n && cur < a[cur]) cur++;
	cur--;

	int j = cur + 1;
	while(j < n && a[j] > cur) j++;
	if(((j - cur - 1) % 2 == 1) || ((a[cur] - cur - 1) % 2 == 1)) printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  int n = 0;
  while(N!=0){
    N/=K;
    ++n;
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 1000010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll F[MAXN], I[MAXN];
ll A[MAXN];

ll powmod(ll a, ll b){
	ll res=1;
	for (; b; b>>=1, a=a*a%mod) if (b&1) res=res*a%mod;
	return res;
}

ll C(ll n, ll r){
	if (r<0 || r>n) return 0;
	return F[n]*I[r]%mod*I[n-r]%mod;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	F[0]=1;
	for (int i=1; i<MAXN; i++) F[i]=F[i-1]*i%mod;
	I[MAXN-1]=powmod(F[MAXN-1], mod-2);
	for (int i=MAXN-1; i; i--) I[i-1]=I[i]*i%mod;
	
	cin>>n;
	for (int i=1; i<n; i++){
		A[i]=C(i-1, n-i-1)*F[i]%mod;
		A[i]=A[i]*F[n-1-i]%mod;
	}
	for (int i=1; i<n; i++) ans=(ans + i*(A[i]-A[i-1]))%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
	return 0;
}


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

using namespace std;
typedef long long ll;

void sieve(ll n, vector<bool>& out){
    out.resize(n + 1);
    fill(out.begin(), out.end(), true);
    out.at(0) = false;
    out.at(1) = false;
    for(ll i = 2; i <= n; ++i){
        if(out.at(i) == false){ continue; }
        for(ll j = i * 2; j <= n; j += i){
            out.at(j) = false;
        }
    }
}

int main(){
    ll q;
    cin >> q;
    vector<pair<ll, ll>> query(q);
    for(int i = 0; i < q; ++i){
        cin >> query.at(i).first >> query.at(i).second;
    }

    ll maxr = 0;
    for(auto p : query){ maxr = max(maxr, p.second); }

    vector<bool> primes;
    sieve(maxr, primes);

    vector<ll> cs(maxr + 2, 0);
    for(ll i = 0; i <= maxr; ++i){
        cs.at(i + 1) = cs.at(i);
        if(i % 2 == 1 && primes.at(i) && primes.at((i + 1) / 2)){
            cs.at(i + 1) += 1;
        }
    }

    for(auto p : query){
        cout << cs.at(p.second + 1) - cs.at(p.first) << endl;
    }
    return 0;
}


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

using namespace std;

int main () {
  
  int A, B, C, K, m, j, l;

  cin >> A >> B >> C >> K;

  if (A >= B && A >= C) {
    m = A;
    j = B;
    l = C;
  } else if (B >= A && B >= C) {
    m = B;
    j = A;
    l = C;
  } else {
    m = C;
    j = B;
    l = A;
  }

  for (int i = 0; i < K; i++) {
    m = m * 2;
  }

  cout << m + j + l << endl;

  return 0;
}

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

int main() {
  int N;
  int max;
  int min;
  max = 0;
  min = 1000000001;
  cin >> N;
  vector<int> number(N);
  for (int i = 0; i < N; i++) {
    cin >> number.at(i);
    
    if(number.at(i) > max){
      max = number.at(i);
    }
    if(number.at(i) < min){
      min = number.at(i);
    }
  }
  cout << max -min;
  
}


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

int main() {
  int a,b;
  cin >> a >> b;
  float ave = (a + b) / 2.0;
  int _ave = ave;
  if(_ave == ave){
    cout << ave << endl;
  }else{
    cout << _ave + 1 << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int num;
#define MAX_L 10
char v[MAX_L];
int l;

char a[MAX_L];
int n3, n5, n7;
int counts;
void getCounts(int i);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> num;
    while(num > 0){
        v[l++] = num % 10;
        num /= 10;
    }
    int i;
    for(i = 0; i < l / 2; ++i){
        char tmp = v[i];
        v[i] = v[l - 1 - i];
        v[l - 1 - i] = tmp;
    }
    getCounts(0);
    cout << counts << '\n';
    return 0;
}

void getCounts(int i){
    if(i < l){
        counts += n3 > 0 && n5 > 0 && n7 > 0;
    }
    else{
        if(n3 == 0 || n5 == 0 || n7 == 0){
            return;
        }
        int j;
        int tag = 0;
        for(j = 0; j < l; ++j){
            if(a[j] < v[j]){
                tag = 1;
                break;
            }
            else if(a[j] > v[j]){
                tag = -1;
                break;
            }
        }
        counts += tag >= 0;
        return;
    }
    a[i] = 3;
    ++n3;
    getCounts(i + 1);
    --n3;
    a[i] = 5;
    ++n5;
    getCounts(i + 1);
    --n5;
    a[i] = 7;
    ++n7;
    getCounts(i + 1);
    --n7;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [usize;n-1],
    }

    let mut mem = vec![0; n];
    for a in aa {
        mem[a-1]+=1;
    }

    for m in mem {
        puts!("{}\n", m);
    }
}


Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int n;
	cin >> n;
	VI a(n);
	rep(i, 0, n)cin >> a[i];
	int i = 1, p = 0;
	ll ans = 1000;
	while (i < n) {
		while (i < n&&a[i] >= a[i - 1])i++;
		ans += (ans / a[p])*(a[i - 1] - a[p]);
		p = i;
		i++;
	}
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
    map<string, int> cnt;
    rep(i,n) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    for (string s : {"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << cnt[s] << "\n";
    }
	return 0;
}


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

using namespace std;
const int OO = 0x3f3f3f3f;
//const long long OO = (long long) 1e18+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(long long i = a ; i < n ; ++i)
#define lpr(i,a,n) for(long long i = a ; i >= n ; --i)
#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef   long long ll;
typedef   unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

using namespace std;
ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);



int n,m;
vvi adj;
vi mem;


int dp(int v){
    if(adj[v].size()==0) return 0;
    if(mem[v]!=-1) return mem[v];
    int ans = 1;
    for(int nxt : adj[v]) ans = max(ans,1+dp(nxt));
    return mem[v] = ans;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
//#ifndef ONLINE_JUDGE
//   freopen( "output.txt" , "w" , stdout ) ;
//   freopen( "input.txt" , "r" , stdin ) ;
//#endif



    cin >> n >> m;
    adj.resize(n);
    mem.assign(n,-1);
    lp(i,0,m){
        int f,t;
        cin >> f>>t;
        --f; --t;
        adj[f].pb(t);
    }
    int ans = 0;
    lp(i,0,n) ans = max(ans,dp(i));
    cout << ans;


    return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s, t;
	cin >>s >>t;
	int n= sz(s);
	bool ok = true;
	VI ck1(26, -1), ck2(26, -1);
	
	rep(i, n){
		int si = s[i]-'a', ti = t[i] -'a';
		if(ck1[si]>=0 && ck1[si] != ti) ok=false;
		if(ck2[ti]>=0 && ck2[ti] != si) ok=false;
		ck1[si] = ti;
		ck2[ti] = si;
	}
	cout << (ok? "Yes": "No") <<"\n";
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
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<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll x;cin>>x;
    for(int i=1;;i++){
        if(i*(1+i)/2 >= x){
            out(i);
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=10005;
//i_am_noob
int h,n,a[maxn],b[maxn],dp[maxn];

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> h >> n;
	rep(n) cin >> a[i] >> b[i];
	dp[0]=0;
	rep2(i,1,maxn){
		dp[i]=4e18;
		rep1(j,n) dp[i]=min(dp[i],dp[max(0ll,i-a[j])]+b[j]);
	}
	print1(dp[h]);
	return 0;
}

Measured memory_bytes: 384
import sys


def solve(inp):
    N = int(inp.readline().strip())
    S = inp.readline().strip()

    r = 1
    p = S[0]
    for c in list(S):
        if p != c:
            r += 1
        p = c

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


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

int main() {
    string N;
    cin >> N;
    bool ans = false;

    for(int i = 0; i < 3; i++) {
        if(N.at(i) == '7') {
            ans = true;
        }

    }
    if(ans == true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628