akhauriyash/Code-Regression huggingface dataset:
import random
import math

def make_circle(points):
	# Convert to float and randomize order
	shuffled = [(float(x), float(y)) for (x, y) in points]
	random.shuffle(shuffled)
	
	# Progressively add points to circle or recompute circle
	c = None
	for (i, p) in enumerate(shuffled):
		if c is None or not is_in_circle(c, p):
			c = _make_circle_one_point(shuffled[ : i + 1], p)
	return c


# One boundary point known
def _make_circle_one_point(points, p):
	c = (p[0], p[1], 0.0)
	for (i, q) in enumerate(points):
		if not is_in_circle(c, q):
			if c[2] == 0.0:
				c = make_diameter(p, q)
			else:
				c = _make_circle_two_points(points[ : i + 1], p, q)
	return c


# Two boundary points known
def _make_circle_two_points(points, p, q):
	circ = make_diameter(p, q)
	left  = None
	right = None
	px, py = p
	qx, qy = q
	
	# For each point not in the two-point circle
	for r in points:
		if is_in_circle(circ, r):
			continue
		
		# Form a circumcircle and classify it on left or right side
		cross = _cross_product(px, py, qx, qy, r[0], r[1])
		c = make_circumcircle(p, q, r)
		if c is None:
			continue
		elif cross > 0.0 and (left is None or _cross_product(px, py, qx, qy, c[0], c[1]) > _cross_product(px, py, qx, qy, left[0], left[1])):
			left = c
		elif cross < 0.0 and (right is None or _cross_product(px, py, qx, qy, c[0], c[1]) < _cross_product(px, py, qx, qy, right[0], right[1])):
			right = c
	
	# Select which circle to return
	if left is None and right is None:
		return circ
	elif left is None:
		return right
	elif right is None:
		return left
	else:
		return left if (left[2] <= right[2]) else right


def make_diameter(a, b):
	cx = (a[0] + b[0]) / 2.0
	cy = (a[1] + b[1]) / 2.0
	r0 = math.hypot(cx - a[0], cy - a[1])
	r1 = math.hypot(cx - b[0], cy - b[1])
	return (cx, cy, max(r0, r1))


def make_circumcircle(a, b, c):
	# Mathematical algorithm from Wikipedia: Circumscribed circle
	ox = (min(a[0], b[0], c[0]) + max(a[0], b[0], c[0])) / 2.0
	oy = (min(a[1], b[1], c[1]) + max(a[1], b[1], c[1])) / 2.0
	ax = a[0] - ox;  ay = a[1] - oy
	bx = b[0] - ox;  by = b[1] - oy
	cx = c[0] - ox;  cy = c[1] - oy
	d = (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by)) * 2.0
	if d == 0.0:
		return None
	x = ox + ((ax*ax + ay*ay) * (by - cy) + (bx*bx + by*by) * (cy - ay) + (cx*cx + cy*cy) * (ay - by)) / d
	y = oy + ((ax*ax + ay*ay) * (cx - bx) + (bx*bx + by*by) * (ax - cx) + (cx*cx + cy*cy) * (bx - ax)) / d
	ra = math.hypot(x - a[0], y - a[1])
	rb = math.hypot(x - b[0], y - b[1])
	rc = math.hypot(x - c[0], y - c[1])
	return (x, y, max(ra, rb, rc))


_MULTIPLICATIVE_EPSILON = 1 + 1e-14

def is_in_circle(c, p):
	return c is not None and math.hypot(p[0] - c[0], p[1] - c[1]) <= c[2] * _MULTIPLICATIVE_EPSILON


# Returns twice the signed area of the triangle defined by (x0, y0), (x1, y1), (x2, y2).
def _cross_product(x0, y0, x1, y1, x2, y2):
	return (x1 - x0) * (y2 - y0) - (y1 - y0) * (x2 - x0)
  
n = int(input())
points = [list(map(int, input().split())) for _ in range(n)]
print(make_circle(points)[2])

Measured memory_bytes: 4720
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		sc.nextLine();
		String[] info=sc.nextLine().split(" ");
		Double t=Double.valueOf(info[0])*1000;
		Double a=Double.valueOf(info[1])*1000;

		List<Double> input=Arrays.asList(sc.nextLine().split(" "))
				.stream()
				.map(s->Double.valueOf(s))
				.map(s->Math.abs(a-(t-s*6)))
				.collect(Collectors.toList());
		System.out.println(input.indexOf(Collections.min(input))+1);
	}
}

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int N, M;
	cin >> N >> M;
	vector<P> room(M);
	for (int i = 0; i < M; ++i)
	{
		cin >> room[i].first >> room[i].second;
	}
	int cover = 0;
	int ans = 0;
	bool flag = true;
	while (flag)
	{
		flag = false;
		int maxv = 0;
		for (int i = 0; i < M; ++i)
		{
			
			if (room[i].first <= cover + 1 && cover + 1 <= room[i].second)
			{
				maxv = max(maxv, room[i].second);
				flag = true;
			}
		}
		if (flag)
		{
			++ans;
			cover = maxv;
		}
	}
	if (cover == N)
	{
		cout << ans << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll solve(ll row,ll s,vector<vector<ll> > &v,vector<vector<ll> > &dp)
{
    if(dp[row][s]!=(-1))
        return(dp[row][s]);
    ll cost;
    if(s==0)
        cost=v[row][s]+max(solve(row+1,1,v,dp),solve(row+1,2,v,dp));
    else if(s==1)
        cost=v[row][s]+max(solve(row+1,0,v,dp),solve(row+1,2,v,dp));
    else
        cost=v[row][s]+max(solve(row+1,0,v,dp),solve(row+1,1,v,dp));
    dp[row][s]=cost;
    return(dp[row][s]);
}
int main()
{
    ll n;cin>>n;
    vector<vector<ll> > v(n,vector<ll> (3));
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<3;j++)
            cin>>v[i][j];
    }
    vector<vector<ll> > dp(n,vector<ll> (3,-1));
    for(ll i=0;i<3;i++)
    {
        dp[n-1][i]=v[n-1][i];
    }
        //cout<<"yo";
   /* for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<3;j++)
            cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/
   // cout<<solve(0,1,v,dp);
    ll ans=max(solve(0,0,v,dp),solve(0,1,v,dp));
    ans=max(ans,solve(0,2,v,dp));
    cout<<ans;
}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	ll k,x; cin>>k>>x;
	for(int i = 0; i < (2*(k-1))+1; i++){
		cout<<(x-(k-1))+i<<" ";
	}
	
	
	
	
	
	
	
	
	
	
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{	
	string N;
	cin >> N;

	//N円払うためには紙幣をN円以上支払う必要があるが、
	//最小枚数を意識すると、
	//1.各桁の紙幣をぴったり払う
	//2.どこかの桁を1.より1枚多くはらう
	//・この場合、その桁より小さい桁は任意枚数でよい。
	//・最大桁より大きい桁でもよい（最小枚数の条件から、最大+1桁のみ考慮すればよい）。
	//
	//よって、最大+1桁からDPで以下を計算すればよい。
	//1.その桁をぴったり払う
	//2.その桁以上の桁で1枚多く払う

	//dp[0][i] := i桁目をちょうどの枚数で払う場合の紙幣の合計枚数
	//dp[0][i] := i桁目を1枚余分に払う場合の紙幣の合計枚数
	vector<vector<ll>> dp(2, vector<ll>(N.size() + 1, 0));


	//最大+1桁は「0」とみなす。
	dp[1][0] = 1;

	rep(i, N.size())
	{
		ll d = (ll)(N[i] - '0');

		dp[0][i + 1] = min(dp[0][i] + d, dp[1][i] + 10 - d);
		dp[1][i + 1] = min(dp[0][i] + d + 1, dp[1][i] + 9 - d);
	}

	cout << dp[0][N.size()] << endl;

	return 0;
}

Measured memory_bytes: 24836
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;

    ll n,m;
    
    ll ans = 0;
    ll temp;
    
  
    cin >> n>>m;
    vector <vector <ll> > s(m, vector<ll>(n));
    vector <ll> k;
    vector <ll> p;
    rep(i,m){
        cin >> temp;
        k.push_back(temp);

        rep(j,k[i]){
            cin >> temp;
            s[i].push_back(temp);
        }
    }
    rep(i,m){
        cin >> temp;
        p.push_back(temp);
    }
    bool flag = true;
    for (int bit = 0; bit < (1<<n); ++bit)
    {   
        flag = true;
        rep(i,m){
            temp = 0;
            rep(j,s[i].size()){
                if(bit & 1<<(s[i][j]-1))temp++;
            }
            if(!(temp%2==p[i]))flag=false;
        }

        if(flag)ans++;
    }



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

Measured memory_bytes: 3184
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の数
            string inputLinesStr = Console.ReadLine();
            int inputLines = Int32.Parse(inputLinesStr);

            // 全ての入力
            int[] inputNums = new int[inputLines];

            for (int i = 0; i < inputLines; i++)
            {
                inputNums[i] = Int32.Parse(Console.ReadLine());
            }

            // 最大利益を調査
            int maxProfit = Int32.MinValue;
            int minVal = inputNums[0];

            for (int i = 1; i < inputLines; i++)
            {
                maxProfit = System.Math.Max(maxProfit, inputNums[i] - minVal);
                minVal = System.Math.Min(minVal ,inputNums[i]);
            }
            
            //Console.Write("最大利益は ");
            Console.WriteLine(maxProfit);
        }
    }
}


Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
    int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    set<char> st={'A','G','C','T'};
    string s;cin>>s;
    ll n=s.size(), ans = 0;
    for(ll i=0;i<n;i++){
        if(!st.count(s[i]))continue;
        ll j=i;
        while(j<n && st.count(s[j]))j++;
        ans=max(ans , j-i);
        i=j-1;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
ll H1[100000];
int dp[100000];
int main(void){
    cin >> N;
    rep(i,N) scanf("%lld", &H1[i]);

    for(int i=N-2;i>=0;i--){
        if(H1[i+1]<=H1[i]) dp[i] = dp[i+1]+1;
    }
    int res = 0;
    rep(i,N) res = max(res, dp[i]);

    cout << res << endl;



    return 0;
}



Measured memory_bytes: 1408
N, X = map(int, input().split())
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def paty(L, n):
    if L == 0:
        return 0 if n <= 0 else 1
    elif n <= 1 + a[L - 1]:
        return paty(L-1, n-1)
    else:
        return p[L-1] + 1 + paty(L-1, n-2-a[L-1])

print(paty(N, X))


Measured memory_bytes: 3064
import java.util.Scanner;

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

        int minuets = seconds / 60;

        seconds -= (minuets * 60);


        int hours = minuets / 60;

        minuets -= (hours * 60);

        System.out.println(hours + ":" + minuets + ":" + seconds);
    }
}


Measured memory_bytes: 26120
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public: 
    static const int MAXN=2e5+10;
    int N;
    int a[MAXN];
    int b[MAXN];
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N;
        for(int u=0;u<N;u++)cin>>a[u];
        for(int u=0;u<N;u++)cin>>b[u];
        int ans=0;
        for(int k=29;k>=0;k--){
            int t=1<<k;
            for(int u=0;u<N;u++){
                a[u]%=2*t;
                b[u]%=2*t;
            }
            sort(b,b+N);
            ll sum=0;
            for(int u=0;u<N;u++){
                int l=lower_bound(b,b+N,t-a[u])-b;
                int r=lower_bound(b,b+N,2*t-a[u])-b-1;
                if(r>=l)
                sum+=(ll)r-l+1;
                l=lower_bound(b,b+N,3*t-a[u])-b;
                r=lower_bound(b,b+N,4*t-a[u])-b-1;
                if(r>=l)
                sum+=(ll)r-l+1;
            }
            if(sum%2)ans=ans|t;
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int n;
  while(cin>>n, n){
    vector<vector<int> > vec(n, vector<int>(n+1));
    rep(i,n) rep(j,n+1) scanf("%d", &vec[i][j]);

    vector<int> dp(1<<n, INF);
    // mask ?????´????????¢???????????¢????????????
    rep(i,n) dp[1<<i] = vec[i][0];
    repl(mask,1,1<<n){
      if(dp[mask]!=INF){
        rep(j, n) if((mask&(1<<j)) == 0){ // ???????????£??????????????¨??????
          int fast = vec[j][0];
          rep(k, n) if((mask&(1<<k))!=0){
            fast = min(fast, vec[j][k+1]);
          }
          int nmask = mask | (1<<j);
          dp[nmask] = min(dp[nmask], dp[mask] + fast);
        }
      }
    }
    cout << dp[(1<<n)-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3420
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,M = MI()
for i in range(M):
    if N%4==0 and i >= N/4:
        print((-i)%N + 1,3+i)
    elif N%2==0 and 2*i+1 >= N/2:
        print((-i)%N + 1,3+i)
    else:
        print((-i)%N + 1,2+i)


Measured memory_bytes: 74924
#include <iostream>

int main(int argc, char **argv)
{
    int a, b;
    std::cin >> a;
    std::cin >> b;

    if((a * b) % 2 == 0){
        std::cout << "Even" << std::endl;
    }else{
        std::cout << "Odd" << std::endl;
    }
    
    
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	int n,cost_kiji,cost,cal_kiji;
	scanf("%d%d%d%d",&n,&cost_kiji,&cost,&cal_kiji);
	int cal[100];
	rep(i,n) scanf("%d",cal+i);

	sort(cal,cal+n);

	int ans=cal_kiji/cost_kiji;
	int cal_sum=cal_kiji;
	rep(i,n){
		cal_sum+=cal[n-i-1];
		ans=max(ans,cal_sum/(cost_kiji+(i+1)*cost));
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int n;
vi c;

ll dp[222222];

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	MS(dp, -1);
	cin >> n;
	c.resize(n); cin >> c;
	dp[n] = 1;
	map<int, ll> mp;
	for (int i = n - 1; i >= 0; i--)
	{
		if (i > 0 && c[i] == c[i - 1])
		{
			dp[i] = dp[i + 1];
		}
		else
		{
			dp[i] = dp[i + 1] + mp[c[i]];
			dp[i] %= MOD;
			mp[c[i]] += dp[i + 1];
			mp[c[i]] %= MOD;
		}
	}
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 15232
from itertools import accumulate
from collections import Counter
from math import factorial
n = int(input())
a = [0] + list(map(int, input().split()))
b = list(accumulate(a))
c = Counter(b)
d = list(c.values())
ans = 0
for i in d:
    if i >= 2:
        ans += factorial(i) // (factorial(i-2)*2)
print(ans)

Measured memory_bytes: 44968
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,l,r) for(int i=(l);i<(r);i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    

template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}    
// g++ -std=c++11 prac.cpp 

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
    ll x=0,y=0,z=0,n,m=0,k,h,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n >> m;
    VL p = divisor(m);
    rep(i,p.size()){
        if(m/n >= p[i])
            chmax(Max,p[i]);
    }

    cout << Max << endl;
    return 0;
}


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

typedef pair<int,int> P;
bool use[15000000];

int main(){
  int n,m,now;

  for(;;){
    cin >> n >> m;
    if(!n && !m)break;

    now = 0;
    for(int i=0;i<3;i++){
      int num;
      cin >> num;
      for(int j=0;j<num;j++){
	int tmp;
	cin >> tmp;
	now += pow(3,tmp-1)*i;
      }
    }

    int lim = pow(3,n);
    for(int i=0;i<lim;i++)use[i] = false;
    use[now] = true;

    int ans = -1;

    queue<P> q;
    q.push(P(now,0));

    while(q.size()){
      P p = q.front();q.pop();
      int s[3] = {-1,-1,-1};
      now = p.first;
      for(int i=1;i<=n;i++){
	s[now%3] = i;
	now/=3;
      }
     
      if( (s[0]<0 && s[1]<0) || (s[1]<0 && s[2]<0) ){
	ans = p.second;
	break;
      }
      if(p.second>m)break;

      int d1[] = {0,1,1,2},d2[] = {1,0,2,1};

      for(int i=0;i<4;i++){
	if(s[d1[i]]>=0 && (s[d2[i]]<0 || s[d1[i]]>s[d2[i]])){
	  int hoge = pow(3,s[d1[i]]-1);
	  now = p.first - hoge*d1[i] + hoge*d2[i];
	  if(!use[now]){
	    use[now] = true;
	    q.push(P(now,p.second+1));
	  }
	}
      }
    }
    cout << ans << endl;
  }
}

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

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

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


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

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

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


void solve(long long n, long long k){

    auto mpow = [](auto x, i64 y){
     auto z = x;
     decltype(x) val = y & 1 ? x : decltype(x)(1);
     while(z *= z, y >>= 1)
      if(y & 1)
       val *= z;
     return val;
    };


    vector<mint> table(k + 1, 0);
    for(int i = k; i >= 1; --i){
        mint cnt_sum = 0;
        int cnt = 0;
        for(int j = i; j <= k; j += i){
            ++cnt;
            cnt_sum += table[j];
        }
        mint val = mpow(mint(cnt), n);
        table[i] = val - cnt_sum;
    }

    mint ans = 0;
    for(int i = 1; i <= k; ++i)
        ans += mint(i) * table[i];
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int n,a[N],sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n+1;i++) sum+=abs(a[i]-a[i-1]);
	for(int i=1;i<=n;i++)
	{
		int tmp=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]);
		printf("%d\n",tmp);	
	} 
	return 0;
}


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

int main(){
    long int N;
    cin>>N;
    long int A[N-1];
    for (long int i=0;i<N-1;i++){
        cin>>A[i];
    }
    sort(A,A+N-1);
    long int j=1,k=0;
    for (long int i=0;i<N-1;i++){
        if (A[i]!=j){
            cout<<i-k<<endl;
            k=i;
            j+=1;
            while (j!=A[i]){
                if (A[i]!=j){
                    j+=1;
                    cout<<0<<endl;
                }
                if (j>N) break;
            }
        }
    }
    cout<<N-1-k<<endl;
    //cout<<j<<"qqq"<<endl;
    for (long int i=j+1;i<=N;i++){
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 5144
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    X, t = map(int, readline().split())
    print(max(X-t,0))


if __name__ == '__main__':
    main()


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

int main() {
	int i,n,count=0;
	cin>>n;
	char a[n];
	cin>>a;
	for(int i=0;i<n-2;i++)
	{
		if(a[i]=='A' && a[i+1]=='B' && a[i+2]=='C')
		{
			
			count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
x = map(int, input().split())
y = map(int, input().split())

n_vec = zip(x, y)

xy_diff = [abs(xi - yi) for xi, yi in n_vec]

Ma_d = sum(xy_diff)
Eu_d = sum([i ** 2 for i in xy_diff]) ** 0.5
Mi3_d = sum([i ** 3 for i in xy_diff]) ** (1 / 3)
Ch_d = max(xy_diff)

print("{0}\n{1}\n{2}\n{3}".format(Ma_d, Eu_d, Mi3_d, Ch_d))

Measured memory_bytes: 7816
const main = (input) => {
    input = input.split(" ");
    const N = Number(input[0]);
    const A = Number(input[1]);
    const B = Number(input[2]);

    const train = N * A;
    const taxi = B;

    if (train > taxi) {
        console.log(taxi);
    } else if (train == taxi) {
        console.log(train);
    } else if (train < taxi) {
        console.log(train);
    }
};

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

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        ll edges=0,vertices=0;

        for(ll i=1;i<=n;i++)
        {
            vertices+=(i*(n-i+1));
        }

        for(ll i=1;i<n;i++)
        {
            ll x,y;
            cin>>x>>y;

            ll a=min(x,y);
            ll b=max(x,y);

            edges+=(a*(n-b+1));
        }

        cout<<vertices-edges;

    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <map>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
int main(){
    string s;
    int n;
    vector<int> emp;
    map<string,vector<int>> m;
    while(cin>>s){
        cin>>n;
        if(m.find(s)==m.end())m.insert(MP(s,emp));
        m[s].PB(n);
    }
    for(auto u:m){
        sort(u.S.begin(),u.S.end());
        cout<<u.F<<endl<<u.S[0];
        for(int j=1;j<u.S.size();j++)cout<<" "<<u.S[j];
        cout<<endl;
    }
}


Measured memory_bytes: 3128
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()


hands = ''
for i in range(n):
    if t[i] == 'r':
        hands += 'p'
    elif t[i] == 'p':
        hands += 's'
    else:
        hands += 'r'


for i in range(k,n):    
    if hands[i] == hands[i-k]:
        c = 'rsp'
        c = c.replace(hands[i], '')
        if i+k < n:
            c = c.replace(hands[i+k], '')
        if len(c) == 1:
            hands = hands[:i] + c + hands[i+1:]
        else:
            hands = hands[:i] + t[i] + hands[i+1:]

cnt = 0
for i in range(n):
    if (hands[i]=='r')&(t[i]=='s'):
        cnt += r
    elif (hands[i]=='s')&(t[i]=='p'):
        cnt += s
    elif (hands[i]=='p')&(t[i]=='r'):
        cnt += p
print(cnt)

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){long long n;cin>>n;string q;
           while(1){int m=n%26;if(m==0){m=26;n-=26;}
                 char x=96+m;q=x+q;
                    n/=26;if(n==0)break;}
                    cout<<q<<endl;}

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

typedef unsigned long LU;
typedef unsigned long long LLU;
typedef long L;
typedef long long LL;

using namespace std;

#define _inline(f...) f() __attribute__((always_inline)); f
#define WATCH(x) cout << #x" = " << x << '\n';
#define foreach(a) for(auto it : a)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORU(i, a, b) for(size_t i = a; i < b; i++)
#define MAX 2*100000

const int INF = 0x3F3F3F3F;
const int NULO = -1;
const double EPS = 1e-10;

_inline(int cmp)(double x, double y = 0, double tol = EPS){
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

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

	long long n, a, b;
	cin >> n >> a >> b;

	if(a > b) swap(a,b);

	if((b-a-1)%2 == 1)
		cout << (a+b)/2 - a << '\n';
	else{
		long long cnt = 0;
		if(a-1 < (n-b)){
			cnt += a-1;
			if((b - 2 - cnt)%2 == 0)
				cnt++;
			//cout << cnt << '\n';
			cnt += (1 + (b-cnt))/2 - 1;
		}else{
			cnt += n-b;
			//cout << n-a-cnt-1 << '\n';
			if((n-a-cnt-1)%2 == 0)
				cnt++;
			//cout << cnt << ' ' << a+cnt << '\n';
			cnt += (n+a+cnt)/2 - a - cnt;
		}

		cout << cnt << '\n';
	}

	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    string s; cin >> s;
    int res1=0, res2=0;
    rep(i, N){
        if(s[i] == ')'){
            if(res1 <= 0){
                res2++;
            }else{
                res1--;
            }
        }else{
            res1++;
        }
    }
    string str1 = "", str2 = "";
    rep(i, res2) str1.push_back('(');
    rep(i, res1) str2.push_back(')');

    cout << str1 + s + str2 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

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

	vector<int> arr(n);
	rep(i, n){
		cin >> arr.at(i);
	}
	
	int ans = 0;
	while(true){
		bool res = false;
		rep(i, n){
			if(arr.at(i)%2 == 1)
				res = true;
		}

		if(res) break;

		ans++;

		rep(i, n){
			arr.at(i) /= 2;
		}

	}
	cout << ans << endl;
}

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

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

		int n = Integer.parseInt(sc.next());

		String[] city = new String[n];
		int[] point = new int[n];
		ArrayList<Integer> result = new ArrayList<Integer>();

		for (int i = 0; i < n; i++) {
			result.add(1);
		}

		for (int i = 0; i < n; i++) {
			city[i] = sc.next();
			point[i] = Integer.parseInt(sc.next());
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j) {
					continue;
				}
				if (city[i].compareTo(city[j]) < 0) {
					result.set(j, result.get(j) + 1);
				} else if (city[i].compareTo(city[j]) == 0) {
					if (point[i] > point[j]) {
						result.set(j, result.get(j) + 1);
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.println(result.indexOf(i + 1) + 1);
		}
	}
}

Measured memory_bytes: 22612
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // あみだくじ貰ったリストに応じてスワップする。
        int w, n, a, b, i;// w(整数),n(整数),a,bはスワップの横棒(i番目)
        int fdata[] = new int[30];
        w = sc.nextInt();
        n = sc.nextInt();
        // 初期データ確保
        for (i = 0; i < w; i++) {
            fdata[i] = i + 1;
        }
        for (i = 0; i < n; i++) {
            // 来るa1,b1に対する処理
            int swap, index;
            String string = sc.next();
            index = string.indexOf(",");
            a = Integer.parseInt(string.substring(0, index)) - 1;// substring(a,b)b-aまでを返す
            b = Integer.parseInt(string.substring(index + 1)) - 1;// substring(a)aまで以外を返す

            swap = fdata[a];
            fdata[a] = fdata[b];
            fdata[b] = swap;
        }
        for (i = 0; i < w; i++) {
            System.out.println(fdata[i]);
        }
    }
}


Measured memory_bytes: 25832
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
vector<int>adj[100005];
int vis[100006];
void dfs(int node)
{

        vis[node]=1;
        for(int i:adj[node])
        {
            if(vis[i]) continue;
            dfs(i);
        }
}
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int n,m;
     cin>>n>>m;
     for(int i=0; i<m; i++)
     {
         int x,y;
         cin>>x>>y;
         adj[x].pb(y);
         adj[y].pb(x);
     }
     int ans=0;
     for(int i=1; i<=n; i++)
     {
         if(!vis[i])
         {
             ++ans;
             dfs(i);
         }
     }
     cout<<ans-1<<endl;
}




Measured memory_bytes: 9992
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main(){
  int fig[3][3];
  rep(i,3){
    rep(j,3){
      cin >> fig[i][j];
    }
  }
  bool ok=true;
  rep(i,2){
    if(fig[2][i]-fig[1][i]!=fig[2][i+1]-fig[1][i+1]) ok=false;
  }
  rep(i,2){
    if(fig[1][i]-fig[0][i]!=fig[1][i+1]-fig[0][i+1]) ok=false;
  }
  rep(i,2){
    if(fig[i][2]-fig[i][1]!=fig[i+1][2]-fig[i+1][1]) ok=false;
  }
  rep(i,2){
    if(fig[i][1]-fig[i][0]!=fig[i+1][1]-fig[i+1][0]) ok=false;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 1000005 

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

bool isprime(li n)
{
  if (n == 1)
    return false;
  int i = 2;
  while (i*i <= n){
      if (n % i == 0)return false;
      i += 1;
  }
  return true;
}

li lcm(li a,li b)
{
    return ((a*b)/__gcd(a,b));
}

vli v(1000005,0);
void solve()
{
  li n;
  cin>>n;
  cout<<v[n]<<endl;
}
int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    v[0] = 0;
    for(li i=1;i<=1000000;i++)
    {
      if(i%3!=0 && i%5!=0)
      {
        v[i] = v[i-1] + i;
      }
      else
      {
        v[i] = v[i-1];
      }
    }
    solve();
    
    return 0;
}

Measured memory_bytes: 11032
N = int(input())
ans = 0
def sft(s):
    global ans
    if int(s) >= N:
        return ans
    for x in '357':
        if int(s+x) > N:
            break
        sft(s+x)
        if '3' in s+x and '5' in s+x and '7' in s+x:
            #print(s+x)
            ans += 1
    return ans
print(sft('0'))


Measured memory_bytes: 3060
#include <stdio.h>

int main(){

    
    int n, k;
    int i;
    int now = 1;
    
    scanf("%d", &n);
    scanf("%d", &k);

    for(i=0;i<n;i++){
        if (now < k){
            now *= 2;
        }else{
            now += k;
        }
    }

    printf("%d", now);
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
long gcd(long a,long b){
  long c,q;
  if(a<b){
    c=b;
    b=a;
    a=c;
  }
  for(;;){
  if(b==0){
    return a;
  }
  c=a%b;
  a=b;
  b=c;
  
  }
}

int main(){
  int t,a;
  int n;
  long c1,c2,q1,q2,q;
  cin>>n;
  int i;
  c1=1;
  c2=1;
  
  for(i=0;i<n;i++){
    cin>>t>>a;
    q1=(c1-1)/t+1;
    q2=(c2-1)/a+1;
    if(q1<q2){
      q=q2; 
    }else{
      q=q1;
    }
    c1=q*t;
    c2=q*a;

    /*    if(c1>c2){
      c1=(((c1-1)/t)+1)*t;
      c2=c1*a/t;
    }
    if(c1<=c2){
      c2=(((c2-1)/a)+1)*a;
      c1=c2*t/a;
      }*/
    //cout<<"("<<c1<<" "<<c2<<")"<<endl;
  }
  cout<<(c1+c2)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N,M;
    cin >> N >> M;
    vector<pair<int,string>> vec(M);
    for(int i = 0;i < M;i++) {
        int A;
        cin >> A;
        string B;
        cin >> B;
        vec.at(i) = make_pair(A,B);
    }
    vector<bool> cnt(N);
    vector<int> cnt2(N);
    for(int i = 0;i < M;i++) {
        if(vec[i].second == "AC") {
            cnt[vec[i].first - 1] = true;
        }
        else {
            if(cnt[vec[i].first - 1] == false) {
                cnt2[vec[i].first - 1]++;
            }
        }
    }
    int ret1 = 0;
    int ret2 = 0;
    for(int i = 0;i < N;i++) {
        if(cnt[i] == true) {
            ret1++;
            ret2 += cnt2[i];
        }
    }
    cout << ret1 << " " << ret2 << endl;
}

Measured memory_bytes: 6912
//MIPT Cryptozoology
//Room 265
#define _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:128000000")
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <cmath>
#include <ctime>
#include <stack>
#include <bitset>
#include <set>
#include <map>
#include <cassert>
#include <memory.h>
#include <sstream>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define itn int

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

typedef long long li;
typedef long long i64;
typedef long double ld;
typedef vector<int> vi;
typedef pair <int, int> pi;

void solve(bool);

void precalc();

int TESTNUM = 0;
#define FILENAME ""

int main() {
	string s = FILENAME;
#ifdef YA
	//assert(!s.empty());
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//cerr<<FILENAME<<endl;
	//assert (s != "change me please");
	clock_t start = clock();
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen(FILENAME ".in", "r", stdin);
	//freopen(FILENAME ".out", "w", stdout);
	cin.tie(0);
#endif
	cout.sync_with_stdio(0);
	cout.precision(10);
	cout << fixed;
	precalc();
	int t = 1;
	//cin >> t;
	int test_num = 1;
	while (t--) {
		//cout << "Case #" << test_num++ << ": ";
		++TESTNUM;
		solve(true);
	}
#ifdef YAH
	while (true) {
		solve(false);
	}
#endif
#ifdef YA
	cerr << "\n\n\n" << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n\n";
#endif
	return 0;
}

//#define int li

/*int pr[] = { 97, 2011 };
int mods[] = { 1000000007, 1000000009 };

const int C = 100500;
int powers[2][C];*/

//int MOD = 1000000007;

//int c[5010][5010];

template<typename T>
T binpow(T q, T w, T mod) {
	if (!w)
		return 1 % mod;
	if (w & 1)
		return q * 1LL * binpow(q, w - 1, mod) % mod;
	return binpow(q * 1LL * q % mod, w / 2, mod);
}

void precalc() {

	/*for (int w = 0; w < 2; ++w) {
	powers[w][0] = 1;
	for (int j = 1; j < C; ++j) {
	powers[w][j] = (powers[w][j - 1] * 1LL * pr[w]) % mods[w];
	}
	}*/

	/*for (int i = 0; i < 5010; ++i) {
	c[i][i] = c[i][0] = 1;
	for (int j = 1; j < i; ++j) {
	c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
	}
	}*/
}

template<typename T>
T gcd(T q, T w) {
	while (w) {
		q %= w;
		swap(q, w);
	}
	return q;
}
template<typename T>
T lcm(T q, T w) {
	return q / gcd(q, w) * w;
}

inline int nxt(){
	int x;
	cin >> x;
	return x;
}

#define int li

vector<int> a;
vector<vector<int>> g;

bool dfs(int v, int p) {
	bool f = false;
	for (int to : g[v]) {
		if (to == p) {
			continue;
		}
		if (a[to] < a[v]) {
			f |= !dfs(to, v);
		}
	}
	return f;
}

void solve(bool read) {
	int n;
	cin >> n;
	g.resize(n);
	a.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int> res;
	for (int i = 0; i < n; ++i) {
		if (dfs(i, i)) {
			res.push_back(i);
		}
	}
	for (int x : res) {
		cout << x + 1 << " ";
	}

}



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

int main() {
	int N = 0;
	string output;

	cin >> N;
	int *num = new int[N];


	for (int i = 0; i < N; i++) {
		cin >> num[i];
	}

	for (int i = 0; i < N; i++) {
		if (num[i] % 2 == 0) {
			if (num[i] % 3 == 0 || num[i] % 5 == 0) {
				output = "APPROVED";
			}
			else {
				output = "DENIED";
				break;
			}
		}
		else output = "APPROVED";
	}



	cout << output;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  a <- readInt
  b <- readInt
  print $ solve n a b

solve n a b = maximum $ map (\cc -> sum (take (cc + 1) a) + sum (drop cc b)) c
  where
    c = [0 .. n - 1]

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;int main() {long long n, a, b, c, d;cin>>n>>a>>b>>c>>d;for (long long x=0; x<n; x++) if (x*d-c*(n-1-x)>=b-a&&x*c-d*(n-1-x)<=b-a) {puts("YES");return 0;}puts("NO");return 0;}

Measured memory_bytes: 256