akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    xyp = [list(map(int, input().split())) for _ in [0]*n]
    d = []

    def calc(seq):
        m = len(seq)
        dp = [[0] for _ in [0]*1]  # 使った回数、前のやつ
        for i in range(m):
            dp2 = [[10**15]*(i+2) for _ in [0]*(i+2)]
            for j in range(i+1):
                for k in range(i+1):
                    dp2[j][k] = min(dp2[j][k], dp[j][k])
                    temp = dp[j][k]
                    if k == 0:
                        for l in range(k, i+1):
                            temp += min(abs(seq[l][0]), seq[i]
                                        [0]-seq[l][0])*seq[l][1]
                    else:
                        for l in range(k, i+1):
                            temp += min(abs(seq[l][0]), seq[l]
                                        [0]-seq[k-1][0], seq[i][0]-seq[l][0])*seq[l][1]
                    dp2[j+1][i+1] = min(dp2[j+1][i+1], temp)
            dp = dp2
        for i in range(m+1):
            for l in range(m):
                dp[i][0] += abs(seq[l][0])*seq[l][1]
            for k in range(1, m+1):
                for l in range(k, m):
                    dp[i][k] += min(abs(seq[l][0]), seq[l]
                                    [0]-seq[k-1][0])*seq[l][1]
        for i in range(m+1):
            dp[i] = min(dp[i])
        dp += [0]*(n-m)
        return dp

    xyp.sort()
    for i in range(2**n):
        x_list, y_list = [], []
        for j in range(n):
            x, y, p = xyp[j]
            if i & 1:
                x_list.append([x, p])
            else:
                y_list.append([y, p])
            i >>= 1
        y_list.sort()
        d.append([calc(x_list), calc(y_list)])

    ans = [10**15]*(n+1)
    for x, y in d:
        for i in range(n+1):
            for j in range(n-i+1):
                ans[i+j] = min(ans[i+j], x[i]+y[j])
    for i in ans:
        print(i)


main()


Measured memory_bytes: 115144
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,k,p,ans;
int ca[12][6]={{4,2,0,9,7},{1,10,8,6,4},{9,7,5,3,1},{6,4,2,0,9},{3,1,10,8,6},{0,9,7,5,3},{8,6,4,2,0},{5,3,1,10,8},{2,0,9,7,5},{10,8,6,4,2},{7,5,3,1,10}};
int main(){
    scanf("%d%d",&n,&k);
	n-=2,p=n%11,n/=11;
    ans=n*5;
    for(int i=0;i<p;i++)
    	for(int j=0;j<5;j++)
    		if(ca[i][j]==k) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
<?php

$R = 6378.1;

while (true) {
	list($a, $b, $c, $d) = explode(' ', trim(fgets(STDIN)));
	if ($a == -1 && $b == -1 && $c == -1 && $d == -1) {
		break;
	}

	$theta1 = (90 - $a) * 2 * pi() / 360;
	$phi1 = $b * 2 * pi() / 360;
	$theta2 = (90 - $c) * 2 * pi() / 360;
	$phi2 = $d * 2 * pi() / 360;

	$x1 = $R * sin($theta1) * cos($phi1);
	$y1 = $R * sin($theta1) * sin($phi1);
	$z1 = $R * cos($theta1);

	$x2 = $R * sin($theta2) * cos($phi2);
	$y2 = $R * sin($theta2) * sin($phi2);
	$z2 = $R * cos($theta2);

	$C = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2) + pow($z1 - $z2, 2));

	$theta = 2 * asin($C / (2 * $R));

	$d = round($R * $theta);

	echo "$d\n";

}

Measured memory_bytes: 6736
import java.util.Scanner;

//Hanafuda Shuffle
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int r = sc.nextInt();
			if((n|r)==0)break;
			int[] a = new int[n];
			for(int i=1;i<=n;i++)a[n-i]=i;
			while(r--!=0){
				int p = sc.nextInt()-1;
				int c = sc.nextInt();
				int[] t = new int[p];
				for(int i=0;i<p;i++)t[i]=a[i];
				for(int i=0;i<c;i++)a[i]=a[i+p];
				for(int i=0;i<p;i++)a[i+c]=t[i];
			}
			System.out.println(a[0]);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
#define INF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,k,n) for(int i=(k);(i)<(n);(i)++)
#define REP(i,n) for(int i = 0;(i)<(n);(i)++)
#define REPR(i,n) for(inti = n; i >= 0; i--)

int f(int n) {
	if (n % 2 == 0) {
		return n / 2;
	}
	else {
		return 3 * n + 1;
	}
}

int main() {
	int s;
	cin >> s;
	vector<int> a(1);
	a[0] = s;
	int i = 1;
	do {
		a.push_back(f(a[i - 1]));
		i++;
	} while (find(a.begin(), a.end() - 1, a[i - 1]) == a.end() - 1);
	cout << i;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll N, M;
  cin >> N >> M;
  vll A(N);

  ll sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  ll count = 0;
  rep(i, N) {
    if (A[i] < double(sum) / double((4 * M))) {
      continue;
    }
    count++;
  }

  if (count >= M) {
    COUT("Yes");
  } else {
    COUT("No");
  }

  return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a == b && a != c && b != c)
        printf("Yes\n");
    else if(a == c && a != b && c != b)
        printf("Yes\n");
    else if(b == c && a != b && a != c)
        printf("Yes\n");
    else printf("No\n");

    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


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

    bool easy = true;
    REP(i, S.size()) {
        if ((i+1)%2==0) {
            if(S[i]=='R') {
                easy = false;
                break;
            }
        } else {
            if(S[i]=='L') {
                // print(i, "-===");
                easy = false;
                break;
            }

        }
    }

    if(easy) {
        print("Yes");
    } else {
        print("No");
    }
    
    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n, m, r; cin >> n;
    map<string, int> s;
    rep(i,n) {
        string str;
        cin >> str;
        if(s.find(str) == s.end()) {
            s.insert(make_pair(str, 1));
        }
        else {
            ++s[str];
        }
    }
    int maxi = -1;
    for(auto p : s) {
        string str;
        int i; 
        tie(str, i) = p;
        chmax(maxi, i);
    }
    vec<string> ss;
    for(auto p :s) {
        string str;
        int i; 
        tie(str, i) = p;
        if(i == maxi) {
            ss.push_back(str);
        }
    }

    sort(all(ss));
    for(auto str : ss) cout << str << '\n';

}

Measured memory_bytes: 25584
N = int(input())
A = list(map(int, input().split()))
ans = A[0]
if 0 in A:
  print(0)
else:
  for i in range(1,N):
    ans *= A[i]
    if ans <= 10**18:
      continue
    else:
      ans = -1
      break
  print(ans)

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

int main(){
    string s; cin >> s;
    int N=s.size();
    vector<int> a(N+1,0);
    for(int i=0;i<N;i++){
        if(s[i]=='<'){
            a[i+1]=max(a[i+1],a[i]+1);
        }
    }
    for(int i=N;i>=0;i--){
        if(s[i-1]=='>'){
            a[i-1]=max(a[i-1],a[i]+1);
        }
    }
    long long sum=0;
    for(int i=0;i<=N;i++){
        //cout << a[i] << " ";
        sum+=a[i];
    }
    //cout << endl;
    cout << sum << endl;
}

Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
const int Max = 5e5+5;
int K,ans[Max],arra[Max],sum,cnt,mp[Max];
struct Query
{
    int index,l,r;

};

bool cmp(Query a,Query b)
{
    if(a.l/K!=b.l/K)
    {
        return a.l/K<b.l/K;
    }
    else if((a.l/K)&1)
        return a.r<b.r;
    return a.r>b.r;

}
Query query[Max];
void add(int index)
{
    if(!mp[index])
    {
        cnt++;
    }
    mp[index]++;
}
void del(int index)
{
    mp[index]--;
    if(!mp[index])
    {
        cnt--;
    }
}

void MO(int n,int q)
{
    K=sqrt(n);
    sort(query,query+q,cmp);
    int st=0,en=-1;
    cnt=0;
    for(int i=0; i<q; i++)
    {
        int l=query[i].l-1;
        int r=query[i].r-1;
        int idx=query[i].index;



        while(st>l)
        {
            st--;
            add(arra[st]);
        }
        while(st<l)
        {
            del(arra[st]);
            st++;
        }
        while(en<r)
        {
            en++;
            add(arra[en]);
        }
        while(en>r)
        {
            del(arra[en]);
            en--;
        }
        ans[idx]=cnt;
    }
    for(int i=0; i<q; i++)
        printf("%d\n",ans[i]);

}



int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=0; i<n; i++)
    {
        cin>>arra[i];
    }

    for(int i=0; i<q; i++)
    {
        cin>>query[i].l>>query[i].r;
        query[i].index=i;

    }
    MO(n,q);







}


Measured memory_bytes: 15424
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int cnt_s[26] = {0}, cnt_t[26] = {0};
    string s, t;
    cin >> s >> t;
    int n = s.size(); 
    for(int i = 0; i < n; ++i) {
        cnt_s[s[i] - 'a']++;
        cnt_t[t[i] - 'a']++;
    }
    sort(cnt_t, cnt_t + 26);
    sort(cnt_s, cnt_s + 26);
    for(int i = 0; i < 26; ++i) {
        if(cnt_t[i] != cnt_s[i]) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << "\n";
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;

typedef LL FTYPE;
struct edge{
    FTYPE flow;
    int to,rev;
};
typedef vector<edge> E;
typedef vector<E> Graph;
#define pb push_back
void addedge(Graph&g,int from,int to,FTYPE f){
    int x=g[from].size();
    int y=g[to].size();
    g[from].pb(edge{f,to,y});
    g[to].pb(edge{(FTYPE)0,from,x});
}

vector<int> bfs(Graph& G,int s){
    int N = G.size();
    queue<int> que;
    vector<int> dist(N,-1);
    dist[s] = 0;
    que.push(s);
    for(;!que.empty();que.pop()){
        auto v=que.front();
        for(auto& e : G[v])
            if(e.flow>0&&dist[e.to]==-1){
                dist[e.to] = dist[v] + 1;
                que.push(e.to);
        }
    }
    return dist;
}

FTYPE maxflow(Graph& G,int s,int t){
    FTYPE res=0;
    int N = G.size();
    while(true){
        auto dist = bfs(G,s);
        if(dist[t] < 0)break;
        vector<unsigned> iter(N,0);
        std::function<FTYPE(int,FTYPE)> dfs=[&](int v,FTYPE f){
            if(v==s)return f;
            for(auto &i = iter[v]; i < G[v].size(); i++){
                edge &e = G[v][i];
                edge &re = G[e.to][e.rev];
                if(re.flow>0 && dist[v] >dist[e.to]){
                    FTYPE d=dfs(e.to,min(f,re.flow));
                    if(d>0){e.flow+=d;re.flow-=d;return d;}
                }
            }
            return (FTYPE)0;
        };
        FTYPE f;
        while((f=dfs(t,114514))> 0)res+=f;
    }
    return res;
}

int main(){
    int N;
    cin>>N;
    int a[200];
    Graph g(N+2);
    REP(i,N){
        cin>>a[i];
        if(a[i]<0){
           addedge(g,0,i+1,-a[i]);
        }else{
           addedge(g,i+1,N+1,a[i]);
        }
        for(int j=2;j*(i+1)<=N;j++){
           addedge(g,(i+1),j*(i+1),1e15);
        }
    }
    LL now=maxflow(g,0,N+1);
    LL ans=0;
    REP(i,N){
        if(a[i]>0)ans+=a[i];
    }
    cout<<ans-now<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [m,n] <- getl $ wrds toInt
  unless (m == 0 && n == 0) $ do
    solve m <$> replicateM n (getl toInt) >>= print
    main
    
solve :: Int -> [Int] -> Int
solve m xs = search m xs 0 (sum xs)

search :: Int -> [Int] -> Int -> Int -> Int
search m xs nw gw
  | nw + 1 == gw = gw
  | isStore w m xs = search m xs nw w
  | otherwise = search m xs w gw
  where
    w = (nw + gw) `div` 2

isStore :: Int -> Int -> [Int] -> Bool
isStore w 0 xs
  | null xs = True
  | otherwise = False
isStore w m xs = isStore w (m-1) ys
  where
    ys = store w 0 xs

store :: Int -> Int -> [Int] -> [Int]
store w l [] = []
store w l (x:xs)
  | w >= (l+x) = store w (l+x) xs
  | otherwise = (x:xs)

toInt :: String -> Int
toInt s = read s

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

int main()
{
    ll n;
    cin>>n;
    ll ans=10000000000000;
    for (int i = 1; i <= sqrt(n); i++)
    {
        if(n%i==0){
            ans=min(ans,i - 1 + n/i - 1);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int M = int.Parse(s[1]);

        int maxLeft = int.MinValue;
        int minRight = int.MaxValue;

        for (int i = 0; i < M; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            int L = int.Parse(input[0]);
            int R = int.Parse(input[1]);
            if (L > maxLeft)
                maxLeft = L;
            if (R < minRight)
                minRight = R;
        }
        if (minRight < maxLeft)
            Console.WriteLine(0);
        else
            Console.WriteLine(minRight - maxLeft + 1);
    }
}

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

int N;
string S;

int main(){
    cin >> N;
    int ac = 0, tle = 0, re = 0, wa = 0;
    for(int i = 0; i < N; ++i){
        cin >> S;
        if(S == "AC") ++ac;
        else if(S == "WA") ++wa;
        else if(S == "RE") ++re;
        else ++tle;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for (int i = (int)a; i >= (int)b; i--)
#define f first
#define s second

int n, ans = 1e9;
string str;

int main() {
	cin >> str;
	n = str.length();
	FOR(i, 0, n-2) {
		if (str[i] != str[i+1]) ans = min(ans, max(i+1, n-i-1));
	}
	cout << (ans == 1e9 ? n : ans);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
 
#define EPS (1e-10)
#define equal(a,b) (fabs((a)-(b)) < EPS)
 
class Point {
  public:
 
  double x,y;
   
  Point (double x = 0, double y = 0) : x(x),y(y) {}
  
  Point operator + (Point p) {
    return Point( x+p.x , y+p.y );
  }
  Point operator - (Point p) {
    return Point( x-p.x , y-p.y );
  }
  Point operator * (double a) {
    return Point( a*x , a*y );
  }
  
  double abs() {
    return sqrt(norm());
  }
  double norm() {
    return x*x+y*y;
  }
  
  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  
  bool operator == (const Point &p) const {
    return equal( x,p.x )&& equal( y,p.y );
  }
};
 
typedef Point Vector;
  
double dot(Vector a,Vector b) {
  return a.x*b.x + a.y*b.y;
}
  
double cross(Vector a,Vector b) {
  return a.x*b.y - b.x*a.y;
}
 
Vector rotation(Vector vec,double si,double co){
  Vector res;
  res.x = vec.x*co - vec.y*si;
  res.y = vec.x*si + vec.y*co;
  return res;
}
 
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
  
int ccw( Point p0 , Point p1 , Point p2 ) {
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if( cross(a,b) > EPS ) return COUNTER_CLOCKWISE;
  if( cross(a,b) < -EPS ) return CLOCKWISE;
  if( dot(a,b) < -EPS ) return ONLINE_BACK;
  if( a.norm() < b.norm() ) return ONLINE_FRONT;
  return ON_SEGMENT;
}
 
class Segment{
    public:
    Point p1, p2;
    Segment(Point s = Point(), Point t = Point()): p1(s), p2(t){}
};
typedef Segment Line;
 
Point getCrossPointLL(Line l1,Line l2){
  Point p1=l1.p1,p2=l1.p2;
  Point q1=l2.p1,q2=l2.p2;
  Point res;
  res= p1+(p2-p1)*( cross(q2-q1,q1-p1)/cross(q2-q1,p2-p1) );
  return res;
}
 
double calcArea(vector<Point> &po){
  int size=po.size();
  if(size<3)return 0.0;
  double res=0.0;
  for(int i=1;i+1<size;i++){
    res+=fabs(cross(po[i]-po[0],po[i+1]-po[0]));
  }
  return res*0.5;
}
 
double cutC(vector<Point> &t,Line li){
  int n=t.size();
  vector<Point> u;
  int A[200];
  
  for(int i=0;i<n;i++)A[i]=ccw(li.p1,li.p2,t[i]);
  
  for(int i=0;i<n;i++){
    if(A[i]!=CLOCKWISE)u.push_back(t[i]);
    int j=(i+1)%n;
    if(A[i]==COUNTER_CLOCKWISE
       &&A[j]==CLOCKWISE)
      u.push_back( getCrossPointLL(Line(t[i],t[j]),li));
    else if(A[j]==COUNTER_CLOCKWISE
            &&A[i]==CLOCKWISE)
      u.push_back( getCrossPointLL(Line(t[i],t[j]),li));
  }
   
  return calcArea(u);
}
 
 
int n,m;
double d,V;
vector<Point> G;
 
 
int main(){
  cin>>n;
  G.resize(n);
  for(int i=0;i<n;i++)cin>>G[i].x>>G[i].y;
  Segment se;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>se.p1.x>>se.p1.y>>se.p2.x>>se.p2.y;
    printf("%.10f\n",cutC(G,se));
  }
  return 0;
}

Measured memory_bytes: 1256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc123_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());
            int c = Convert.ToInt32(Console.ReadLine());
            int d = Convert.ToInt32(Console.ReadLine());
            int e = Convert.ToInt32(Console.ReadLine());
            int k = Convert.ToInt32(Console.ReadLine());

            if (e - a > k)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }

            Console.Read();
        }
    }
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> s(n);
    ll ans = 1e18;
    for(int i = 0;i < n;i ++){
        ll a;
        cin >> a;
        if(i==0)s[0]=a;
        else s[i] = s[i-1] + a;
    }
    for(int i = 0;i < n-1;i ++){
        if(abs((s[n-1]-s[i])-s[i])<ans) ans = abs((s[n-1]-s[i])-s[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	long long int x;
	long long int ans;
	cin>>x;
	int y = x % 11;
	if(y > 6){
		ans = (x / 11) * 2 + 2;
	}
	else if(y > 0) ans = (x / 11) * 2 + 1;
	else ans = (x / 11)*2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
import math
def d(x,y):
    return math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2)
ans = 0
xy = [list(map(int,input().split())) for i in range(N)]
for i in range(N-1):
    for j in range(i,N):
        ans += 2*d(xy[i],xy[j])/N
print(ans)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
int main(){
	fast;
	ll a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1);
	return 0;
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(3*n);
    rep(i, 3*n) cin >> a[i];
    sort(all(a));
    ll sum = 0;
    for(ll i=n; i<3*n; i+=2) sum += a[i];
    cout << sum << endl;
}

Measured memory_bytes: 5488
#include <iostream>

using namespace std;

int main() {
  string s; cin >> s;
  int n = s.length();

  int ans = n, tmp;
  // 01010101...
  tmp = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && s[i] != '0') { tmp++; }
    if (i % 2 == 1 && s[i] != '1') { tmp++; }
  }
  ans = min(ans, tmp);

  // 10101010...
  tmp = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 1 && s[i] != '0') { tmp++; }
    if (i % 2 == 0 && s[i] != '1') { tmp++; }
  }
  ans = min(ans, tmp);

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  int aa=0, bb=0, cc=0;
  char c;
  char win;
  
  c=A[aa];
  aa++;
  
  while (true) {
    if (c=='a') {
      if (aa>A.size()-1) {
        win='A';
        break;
      }
      else {
        c=A[aa];
        aa++;
      }
    }
    else if (c=='b') {
      if (bb>B.size()-1) {
        win='B';
        break;
      }
      else {
        c=B[bb];
        bb++;
      }
    }
    else if (c=='c') {
      if (cc>C.size()-1) {
        win='C';
        break;
      }
      else {
        c=C[cc];
        cc++;
      }
    }
  }
  cout << win << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	cout << n * 800 - (n / 15 * 200) << endl;
}


Measured memory_bytes: 256
let rec read rect loz =
  try let l =read_line ()
                |> Str.split (Str.regexp_string ",")
             |> List.map int_of_string |> List.nth in
      let (x,y,z) = (l 0,l 1,l 2) in
      if x = y then read rect (loz+1)
      else if x*x + y*y = z*z then read (rect+1) loz
      else read rect loz
  with End_of_file -> (rect, loz);;

let () =
  let (rect, loz) = read 0 0 in
  print_endline (string_of_int rect);
  print_endline (string_of_int loz);;

Measured memory_bytes: 2216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x[101],y[101],z,h[101],w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;

int main(void){
    cin>>n;
    rep(i,n)cin>>x[i]>>y[i]>>h[i];
    if(n==1){ps(x[0]);ps(" ");ps(y[0])ps(" ")p(h[0]);return 0;}
    rep(i,101)rep(j,101){
        rep(k,0,n)if(h[k]>0)z=abs(x[k]-i)+abs(y[k]-j)+h[k];
        flag=1;
        rep(k,0,n){
            if(h[k]!=max(0LL,z-abs(x[k]-i)-abs(y[k]-j))){flag=0;break;}
        }
        if(flag){
            ps(i);ps(" ");ps(j)ps(" ")p(z);
            break;
        }
    }
    return 0;
}


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

#define int long long

signed main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; ++i) cin >> v[i];
  int ans = 0;
  for(int i=0; i<n-1; ++i) {
    if(v[i]==v[i+1]) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

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


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

    int N, K;
    cin >> N >> K;

    int ans = 0;
    REP(i, N) {
        int x;
        cin >> x;
        ans += 2*min(x, K-x);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 998244353 
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cout<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}


ll dp[100005][3];
ll arr[100005][3];
int main(){
      sync;
      ll n;
      cin>>n;
      for(ll i=1; i<=n; i++){
            cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
      }
      dp[1][0]=arr[1][0];
      dp[1][1]=arr[1][1];
      dp[1][2]=arr[1][2];
      for(ll i=2; i<=n; i++){
            dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
      }

      cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;
} 



Measured memory_bytes: 4992
N=int(input())
str_list = [input() for _ in range(N)]
AC=WA=TLE=RE=0
for i in range(N):
  if(str_list[i]=="AC"):
    AC+=1
  if(str_list[i]=="TLE"):
    TLE+=1
  if(str_list[i]=="WA"):
    WA+=1
  if(str_list[i]=="RE"):
    RE+=1
print('AC x '+str(AC))
print('WA x '+str(WA))
print('TLE x '+str(TLE))
print('RE x '+str(RE))
  

Measured memory_bytes: 16048
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans = 0;
  rep(i,n-2) {
    if ((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2])) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pin;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;


#define ff(i, a, b) for ( ll i=a; i<(b); i++)
#define ffd(i, a, b) for ( ll i=a; i<= b; i++)
#define fr(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ffr(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl "\n"
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int maxn = 2e5 + 5 ;
const int mod = 1000000007;
const ll INF = 1e18;
const int MX = 2000000001; //check the limits, dummy

pair < int , string > s[200] ;
int main() {
	ios_base::sync_with_stdio(0) ,cin.tie(0);
  ll t, qr, n, ar, hb, k, l, m, r,  x = 0, y = 0, ans = 0, temp = 0, res = 0 ;
  cin >> n >> m ;
  ff(i, 0, m)  cin >> x ,ans += x ;
  if ( ans > n) cout <<-1 ;
  else cout << n - ans ;
}

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

int main() {
	string s; cin >> s;
	int64_t n = s.size();
	auto sa = suffix_array(s);
	int64_t ans = n * (n + 1) / 2;
	for(int64_t i : lcp_array(s, sa)) {
		ans -= i;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 15664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string N;
	cin>>N;
	int c=count(N.begin(),N.end(),'x');
	if(c>=8) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

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

int main() {
	int A[9], B[9], C, i, j,ans=0;

	cin >> C;
	for (j = 0; j <= 8; j++) {
		for (i = 0; i <= 8; i++) {
			A[j] = j + 1;
			B[i] = i + 1;
			if (ans == C)
				break;
			ans = A[j] * B[i];
		}
	}
	if (ans == C)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


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

    REP(i,0,SZ(S)) {
        S[i] = (S[i] - 'A' + N) % 26 + 'A';
    }
    _PR(S);

    return 0;
}

/*



*/

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

int main()
{
	int n; cin >> n;
    vector<ll> v(n);
    ll ans = 1;
    rep(i, n){
        cin >> v[i];
        if(v[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, n) ans *= v[i];
    if(ans <= (ll)1e18 && ans > 0)cout << ans << endl;
    else cout <<-1 << endl;
    system("pause");
}


Measured memory_bytes: 3996
s1 = 0
s2 = 0
sum = 0
ans = 0

N = gets.chomp.to_i
tar = gets.chomp.split(" ").map(&:to_i)

for i in 0..tar.length-1 do #make sum
    sum = sum + tar[i]
end
for i in 0..tar.length-2 do
    s1 = s1 + tar[i]
    s2 = sum - s1
    if i == 0
        if s1 >= s2
            ans = s1 - s2
        elsif s2 >= s1
            ans = s2 - s1
        end
    else
        if s1 >= s2
            if ans > s1 - s2
                ans = s1 - s2
            end
        elsif s2 >= s1
            if ans > s2 - s1 
                ans = s2 - s1
            end
        end
    end
end
puts ans

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

int main() {
  string s;
  cin >> s;
  bool t=false;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])t=true;
  t ? cout << "Bad" : cout << "Good";
  cout << endl;
}


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

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int N = Integer.parseInt(str);
			int[] score = new int[N];
			int total = 0;
			for(int i =0;i<N;i++) {
				str = br.readLine();
				int s = Integer.parseInt(str);
				total += s;
				score[i] = s;
			}
			Arrays.sort(score);
			for(int i = 0;i < N;i++) {
				if(total % 10 != 0) {
					System.out.println(total);
					break;
				}else {
					if(score[i] % 10 != 0) {
						total -= score[i];
					}
				}
				if(i==N-1) {
					System.out.println(0);
				}
			}
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#define int long long
using namespace std;
typedef tuple<int, int, int> T;

int x, y, z;
int a[100000], b[100000], c[100000];
T t[100000];
int sa[100001];
int sb[100001];

void setting() {
	priority_queue<int, vector<int>, greater<int> > que;
	int ssum = 0;
	
	for (int i = 0; i < x + y + z; i++) {
		que.push(get<1>(t[i])); ssum += get<1>(t[i]);
		while (que.size() > x - 1) { ssum -= que.top(); que.pop(); }
		sa[i] = ssum;
	}
	
	ssum = 0;
	while (!que.empty()) { que.pop(); }
	
	for (int i = x + y + z - 1; i >= 0; i--) {
		que.push(get<2>(t[i])); ssum += get<2>(t[i]);
		while (que.size() > y) { ssum -= que.top(); que.pop(); }
		sb[i] = ssum;
	}
}

signed main() {
	cin >> x >> y >> z;
	for (int i = 0; i < x + y + z; i++) cin >> a[i] >> b[i] >> c[i];
	for (int i = 0; i < x + y + z; i++) {
		t[i] = T(a[i] - b[i], a[i] - c[i], b[i] - c[i]);
	}
	sort(t, t + x + y + z, greater<T>());
	setting();
	
	int ans = -1145141919810893;
	for (int i = x - 1; i < x + z; i++) {
		//a[i] + (a[0]～a[i-1]の中での上位X-1個) + (b[i+1]～b[x+y+z-1]の中での上位Y個)を計算
		ans = max(ans, get<1>(t[i]) + (i < 0 ? 0 : sa[i - 1]) + sb[i + 1]);
	}
	
	for (int i = 0; i < x + y + z; i++) {
		ans += c[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7416
s = input()
n = len(s)
final = [0] * len(s)
i = 0

while i < n:
    start = i
    char1 = s[i]
    i += 1
    while i < n and char1 == s[i]:
        i += 1
    if char1 == "L":
        num = i - start
        if num % 2 == 0:
            final[start] += num // 2
            final[start - 1] += num // 2
        else:
            final[start] += num // 2 + 1
            final[start - 1] += num // 2
    else:
        num = i - start
        if num % 2 == 0:
            final[i] += num // 2
            final[i - 1] += num // 2
        else:
            final[i] += num // 2
            final[i - 1] += num // 2 + 1
           
print(" ".join(list(map(str , final))))



Measured memory_bytes: 10484
#include <iostream>
#include <algorithm>
#include <string>
#include<vector>
using namespace std;


int main(void) 
{
	int Size = 0;
	cin >> Size;
	int Data[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	cout << Data[Size - 1] << endl;

	return 0;
}

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

std::array<int, 1000001> numbers;

constexpr auto PRIME = 0;
constexpr auto NOT_PRIME = 1;

int solve(int x)
{
    for (auto i = x; i < numbers.size(); ++i)
    {
        if (numbers[i] == PRIME)
        {
            return i;
        }
    }

    return 0;
}

int main()
{
    for (auto n = 2; n < numbers.size(); ++n)
    {
        if (numbers[n] == PRIME)
        {
            auto k = 2;
            while (n * k < numbers.size())
            {
                numbers[n * k] = NOT_PRIME;
                ++k;
            }
        }
    }

    int x;
    std::cin >> x;
    std::cout << solve(x) << std::endl;

    return 0;
}


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

const int mx = 2e5+5;
int n, k;
int a[mx], w[mx];
pair<int, int> dp[mx];

vector<int> Find(int p) {
    vector<int> ans;
    while (p < n+1) {
        if (dp[p].first)
            ans.push_back(dp[p].first);
        p = dp[p].second;
    }
    if (ans.empty()) ans.push_back(-1);
    return ans;
}

void debug() {
    for (int i = 1; i <= n; i++) {
        for (auto x : Find(i))
            cout << x << ' ';
        cout << '\n';
    }
    for (int i = 1; i <= n; i++) {
        cout << dp[i].first << ' ' << dp[i].second << '\n';
    }

    for (int i = 1; i <= n; i++) {
        //cout << pre[i] << '\n';
    }
}

int pre[mx];
int precalc() {
    pre[n+1] = -1;
    for (int i = n; i >= 1; i--) {
        if (dp[i].first == 0)
            pre[i] = pre[dp[i].second];
        else pre[i] = dp[i].first;
    }
}

int FindNext(int x) {
    return pre[w[x]+1];
}

signed main()
{
    cin >> n >> k;

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

    for (int i = n; i >= 1; i--) {
        if (w[a[i]] == 0) {
            dp[i] = {a[i], i+1};
        }
        else {
            dp[i] = {0, w[a[i]]+1};
        }
        w[a[i]] = i;
    }

    int first = Find(1)[0];

    vector<int> all;

    int x = first;

    precalc();

    do {
        all.push_back(x);
        if (x == -1) x = first;
        else x = FindNext(x);
    } while (x != first);

    if (k == 1) {
        for (auto x : Find(1))
            cout << x << ' ';
        return 0;
    }

    x = all[(k-2) % all.size()];

    for (auto i : Find(w[max(x, 0ll)]+1))
        if (i != -1)
            cout << i << ' ';
}


Measured memory_bytes: 14548
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
//#include "Header.h"
int main()
{
	static ll x, y, z, k, a[1010], b[1010], c[1010];
	vector<ll> mix,cake;
	ll i, j;
	cin >> x >> y >> z >> k;
	for (i = 0; i < x; i++)
	{
		cin >> a[i];
	}
	for (i = 0; i < y; i++)
	{
		cin >> b[i];
	}
	for (i = 0; i < z; i++)
	{
		cin >> c[i];
	}
	for (i = 0; i < x; i++)
	{
		for (j = 0; j < y; j++)
		{
			mix.push_back(a[i] + b[j]);
			//printf(":%d", a[i] + b[j]);
		}
	}
	sort(mix.begin(), mix.end(), greater<ll>());
	for (i = 0; i < min((int)mix.size(),10000); i++)
	{
		for (j = 0; j < z; j++)
		{
			cake.push_back(mix[i] + c[j]);
		}
	}
	sort(cake.begin(), cake.end(), greater<ll>());
	/*
	for (i = 0; i < cake.size(); i++)
	{
		printf("%d\n", cake[i]);
	}
	*/
	for (i = 0; i < k; i++)
	{
		cout << cake[i] << endl;
	}
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int arr[n+2],dp[n+2];
    memset(dp,0,sizeof(dp));
    arr[0]=0;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        if(i==1)
            dp[i]=abs(arr[i]);
        else
            dp[i]=abs(arr[i]-arr[i-1]);
    }

    dp[0]=0;
    arr[0]=0;
    arr[n+1]=0;
    dp[n+1]=abs(arr[n]);
    for(int i=1;i<=n+1;i++)
        dp[i]+=dp[i-1];
    for(int i=1;i<=n;i++)
    {
        long long int pre=0,ans=dp[n+1];
        ans-=abs(arr[i]-arr[i-1]);
        ans-=abs(arr[i]-arr[i+1]);
        ans+=abs(arr[i-1]-arr[i+1]);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2816
// Your day breaks, your mind aches
// You find that all the words of kindness linger on
// When she no longer needs you
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define debug(x) cout << #x << " = " << x << endl
#define For(i,a,b) for (int i = a; i < b; i++)
#define roF(i,a,b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

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

const int N = 1e6;
const ll INF = 1e18;
const ld EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll a, ll b) { return uniform_int_distribution<ll> (a, b) (rng); }

int main() {
	fastio;
	ll n;
	cin >> n;
	if (n & 1) cout << 0 << endl;
	else {
		ll ans = 0;
		ll aux = 10LL;
		while (aux <= n) {
			ans += n / aux;
			aux *= 5LL;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
vector<int> v;

void init()
{
}

void solve()
{
    int ans = 0;
    REP(i, N){
        if(i+1 == v[i]){
            ans++;
            if(i != N-1) swap(v[i], v[i+1]);
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    v.resize(N);
    REP(i, N) cin >> v[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 640
#include <bits/stdc++.h>
/**  I'm Klaus, NicKlaus :v **/
using namespace std;
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define LOG2(X) ((unsigned) (8*sizeof(int) - __builtin_clz((X)) - 1))
ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int v[2004][2004];
int v2[2004][2004];
int h[2004][2004];
int h2[2004][2004];
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	#ifdef LOCAL_JUDGE
		//freopen("in_out/in.txt", "rt", stdin);
		//freopen("int_out/out.txt", "wt", stdout);
	#endif
	ms(v,0);
	ms(v2,0);
	ms(h,0);
	ms(h2,0);
	int n, m;
	cin>>n>>m;
	vector<string> a(n);
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if(a[i-1][j-1] == '.'){
				v[i][j] = v[i][j-1]+1;
			}else{
				v[i][j] = 0;
			}
		}
	}
	for(int i=1; i<=m; i++){
		for(int j=1; j<=n; j++){
			if(a[j-1][i-1] == '.'){
				h[j][i] = h[j-1][i]+1;
			}else{
				h[j][i] = 0;
			}
		}
	}
	for(int i=n; i>0; i--){
		for(int j=m; j>0; j--){
			if(a[i-1][j-1] == '.'){
				v2[i][j] = v2[i][j+1]+1;
			}else{
				v2[i][j] = 0;
			}
		}
	}
	for(int i=m; i>0; i--){
		for(int j=n; j>0; j--){
			if(a[j-1][i-1] == '.'){
				h2[j][i] = h2[j+1][i]+1;
			}else{
				h2[j][i] = 0;
			}
		}
	}
	int ans = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if(a[i-1][j-1] == '.')ans = max(ans, v[i][j] + v2[i][j] + h[i][j] + h2[i][j]-3);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int levenshtein_dintance(string const& s,string const& t){
  size_t n = s.size();
  size_t m = t.size();
  constexpr int INF = (1<<28);
  vector<vector<int>> dp (n+1,vector<int>(m+1,INF));
  dp[0][0] = 0;
  for(size_t i=1;i<n;++i)dp[i][0] = dp[i-1][0]+1;
  for(size_t j=1;j<m;++j)dp[0][j] = dp[0][j-1]+1;
  for(size_t i=0;i<n;++i){
    for(size_t j=0;j<m;++j){
      dp[i+1][j+1] = min({dp[i+1][j]+1,dp[i][j+1]+1,dp[i][j]+(s[i]!=t[j])});
    }
  }
  return dp[n][m];
}

main(){

  string s,t;
  cin>>s>>t;

  int ans = levenshtein_dintance(s,t);

  cout<<(ans)<<endl;


}


Measured memory_bytes: 6816