akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long [] height = new long[n];
        for (int i = 0; i < n; ++i) {
            height[i] = scanner.nextLong();
        }
        for (int i = 0; i < n - 1; ++i) {
            if (i == 0 || height[i] - 1 >= height[i - 1]) {
                --height[i];
            }
            if (i - 1 >= 0 && height[i] < height[i - 1]) {
                System.out.println("No");
                return;
            }
            //Arrays.stream(height).forEach(System.out::println);
        }
        if (n - 2 >= 0 && height[n - 1] < height[n - 2]) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int result = 180 * (N-2);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, b, c;

  cin >> a >> b >> c;

  cout << min(b / a, c) << endl;

  return 0;
}


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

#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
const int INF = 1e9 + 1;

int main() {
	int N;
	cin >> N;
	vector<double>T(N);
	vector<double>V(N);
	for (int i = 0;i<N;++i) {
		cin >> T[i];
	}
	for (int i = 0;i<N;++i) {
		cin >> V[i];
	}
	int Time = 0;
	for (int i = 0;i<N;++i) {
		Time += T[i];
	}
	vector<double>maxV(2*Time+1, (double)INF);

	int nowT = 0;
	for (int i = 0;i<N;++i) {
		for (int j = 0;j<T[i];++j) {
			int t1 = nowT + j * 2;
			int t2 = nowT + j * 2 + 1;
			maxV[t1] = min(maxV[t1], V[i]);
			maxV[t2] = min(maxV[t2], V[i]);
		}
		nowT += T[i] * 2;
		maxV[nowT] = min(maxV[nowT], V[i]);
	} 
	maxV[0] = 0.0;
	maxV[Time * 2] = 0.0;

	// 前から比較
	REP(ti, 2 * Time + 1) {
		maxV[ti + 1] = min(maxV[ti + 1], maxV[ti] + 0.5);
	}

	// 後ろから比較
	RREP(ti, 2 * Time + 1) {
		maxV[ti] = min(maxV[ti], maxV[ti + 1] + 0.5);
	}

	double ans = 0.0;
	REP(i, 2 * Time + 1) {
		// (上底 + 下底) * 高さ / 2
		ans += (maxV[i] + maxV[i + 1]) * 0.5 / 2.0;
	}

	printf("%.4f\n", ans);
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int D;
   string ans;
   cin>>D;
   if(D==25)ans="Christmas";
   if(D==24)ans="Christmas Eve";
   if(D==23)ans="Christmas Eve Eve";
   if(D==22)ans="Christmas Eve Eve Eve";
   cout<<ans<<endl;
   return 0;
   }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;


int main(){
  int a,b,c;cin>>a>>b>>c;
  int ans = 0;
  while(b && c){
    ans += 2;
    b--;
    c--;
  }
  while(a && c){
    ans++;
    a--;
    c--;
  }
  if(c)ans++;
  while(b){
    b--;
    ans++;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
a = gets.to_i
b = gets.to_s
count_max = 0

for i in (0..a)
  count = 0
  s1 = b[0..i]
  s2 = b[i+1..a]
  uniq_s1 = s1.split("").uniq
  uniq_s1.each do |s|
    count = count + 1 if s2.include?(s)
  end
  count_max = count if count_max < count
end
puts count_max

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

H,W=map(int,input().split())
MAP=[list(input().strip()) for i in range(H)]

ANS=[[-1]*W for i in range(H)]

from collections import deque
QUE=deque()

for i in range(H):
    for j in range(W):

        if MAP[i][j]=="#":
            QUE.append([i,j,0])
            ANS[i][j]=0

while QUE:
    NQUE=deque()
    while QUE:
        x,y,z=QUE.pop()

        for nx,ny in [[x+1,y],[x-1,y],[x,y+1],[x,y-1]]:
            if nx<0 or ny<0 or nx>=H or ny>=W:
                continue

            if ANS[nx][ny]!=-1:
                continue

            NQUE.append([nx,ny,z+1])
            ANS[nx][ny]=z+1

    QUE=NQUE

            
print(max([max(ANS[i]) for i in range(H)]))

Measured memory_bytes: 183644
#include<stdio.h>
int main(void){
    int a[100],n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++){scanf("%d",&a[i]);}
    for (int i = n-1; i >= 0; i--){
        printf("%d",a[i]);
        if (i!=0){printf(" ");}else{printf("\n");}
        
        }
    return 0;
}


Measured memory_bytes: 2020
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int m = (0 > a - b * 2) ? 0 : a - b * 2;
    cout << m << endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!

s=input()
n=len(s)
ans=0
for i in range(1<<(n-1)):
    tmp=0
    for k in range(n):
        j=int(s[k])
        if (((i<<1)>>k)&1==1):
            tmp=tmp*10+j
        else:
            ans+=tmp
            tmp=j
    ans+=tmp
print(ans)

Measured memory_bytes: 41328
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
//N種類ある文字列からどの文字列にも含まれる文字列一覧を取得したい。
$N = $key->A[0];
$n=0;
$ary=array();
foreach($key->X as $r) {
  foreach (count_chars($r[0], 1) as $i => $val) {
     $ary[$n][chr($i)]=$val;
  }
  $n++;
}
$ret = "";
foreach (range('a', 'z') as $char) {
  $ret = $ret . findval($ary,$char,$N);
}

printf("%s\n",$ret);

function findval($ary,$k,$N) {
  $sum=0;
  $min=99;
  foreach($ary as $r) {
    if (isset($r[$k])) {
      $sum++;
      $min=min($min,$r[$k]);
    }
  }
  //$sum == $Nならばすべてに含まれていたはず
  $ret="";
  if ($sum == $N) {
    for($i=0;$i<$min;$i++) {
      $ret = $ret . $k;
    }
  }
  return $ret;
}


Measured memory_bytes: 3956
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;

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

                System.out.print( Math.min(N*A,B) );
        }
}


Measured memory_bytes: 25172
s=input()

flag=True

for i in range(len(s)):
    if s[i]=='R':
        if (i+1)%2==0:
            flag=False
            break
    if s[i]=='L':
        if (i+1)%2!=0:
            flag=False
            break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int head[100001],to[100001],nxt[100001],f[100001],degree[100001]={0},tot=0,n,m;
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
int dfs(int i)
{
	if(head[i]==0)
	{
		f[i]=0;
		return f[i];
	}
	if(f[i]>=0)
		return f[i];
	int k,v;
	for(k=head[i];k;k=nxt[k])
	{
		v=to[k];
		f[i]=max(f[i],dfs(v)+1);
	}
	return f[i];
}
int main()
{
	int i,u,v,maxv=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	memset(f,0xff,sizeof(f));
	for(i=1;i<=n;i++)
		if(degree[i]==0)
			dfs(i);
	for(i=1;i<=n;i++)
		maxv=max(maxv,f[i]);
	printf("%d",maxv);
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
using namespace std;
int inf = 1e9;
int main(){

  vector<int> a(3);
  for(int i=0; i<3; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  for(int i=0; i<2; i++){
    sum += abs(a[i]-a[i+1]);
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque
X,Y,A,B,C = (int(x) for x in input().split())
p = [[int(x), 'r'] for x in input().split()]
q = [[int(x), 'g'] for x in input().split()]
r = [[int(x), 'c'] for x in input().split()]
pqr = p + q + r
pqr.sort(reverse=True)
d = deque(pqr)
rem = X + Y
pickedr = 0
pickedg = 0
pickedc = 0
ans = 0
if len(d) <= rem:
    print(sum([apple[0] for apple in pqr]))
else:
    while pickedr + pickedg + pickedc < rem:
        pop = d.popleft()
        if pop[1] == 'r':
            if pickedr < X:
                ans += pop[0]
                pickedr += 1
        elif pop[1] == 'g':
            if pickedg < Y:
                ans += pop[0]
                pickedg += 1
        else:
            ans += pop[0]
            pickedc += 1
    print(ans)

Measured memory_bytes: 51236
import heapq

n = int(input())
p_L = list(map(int,input().split()))

a = []
heapq.heapify(a)
ans = 0
for i in p_L:
    heapq.heappush(a, i)
    min_num =  a[0]
    #print(max_num,i)
    if i == min_num:
        ans += 1

print(ans)

Measured memory_bytes: 85456
#include <stdio.h>

int main(void) {
    char str[20] = {'\0'};
    int i;
    
    scanf("%s", str);
    
    for(i = 20; i >= 0; i--) {
        if(str[i] != '\0')
            printf("%c", str[i]);
    }
    
    putchar('\n');
    
    return(0);
}

Measured memory_bytes: 520
from collections import deque
N,M,*AB=map(int,open(0).read().split())
to=[[] for _ in range(N)]
for a,b in zip(*[iter(AB)]*2):
  to[a-1].append(b-1)
  to[b-1].append(a-1)
q=deque([0])
r=[None]*N
while q:
  x=q.popleft()
  for i in to[x]:
    if r[i] is None:
      q.append(i)
      r[i]=x+1
print("Yes",*r[1:],sep="\n")

Measured memory_bytes: 56668
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
#define mod 1000000007
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define forr(c, n) for (int i = c; i < n; i++)
#define forli(n) for (lli i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

//FUNCTONS
lli llipower(lli x, lli y)
{
    lli res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (!a)
        return b;
    return gcd(b % a, a);
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
void printvec(vector<T> inp)
{
    for (int i = 0; i < inp.size(); i++)
    {
        cout << inp[i] << " ";
    }
    cout << endl;
}
template <typename T>
T ceildiv(T x, T y) { return 1 + ((x - 1) / y); }
lli modInverse(lli a, lli m)
{
    lli g = gcd(a, m);
    if (g != 1)
        return -1;
    else
        return llipowerp(a, m - 2, m);
}

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a);
    vector<int> q(b);
    vector<int> r(c);
    fori(a) cin >> p[i];
    fori(b) cin >> q[i];
    fori(c) cin >> r[i];

    sortvec(p);
    sortvec(q);
    sortvec(r);
    reverse(p.begin(), p.end());
    reverse(q.begin(), q.end());
    reverse(r.begin(), r.end());
    vector<int> comm;
    fori(x) comm.pb(p[i]);
    fori(y) comm.pb(q[i]);
    sortvec(comm);
    reverse(comm.begin(),comm.end());
    int pc = 0;
    
    int rc = 0;
    int xc = 0;
    int yc = 0;
    lli ans = 0;
    while (1)
    {
        // /cout<<"while "<<xc<<endl;
        if (xc == x+y)
            break;

       if(comm[pc]>r[rc]){
           ans+=comm[pc];
           pc++;
            xc++;
       }
       else{
           ans+=r[rc];
           rc++;
           xc++;
       }
    }

    cout << ans << endl;
}


Measured memory_bytes: 2552
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

vvi data(24, vi(4));
vvi covered(24, vi(24));

int bitnum(int n) {
	int res = 0;
	REP(i, 32) {
		if(n&(1<<i)) {
			res++;
		}
	}
	return res;
}

bool cover(int i, int j) {
	int xd = data[i][0]-data[j][0];
	int yd = data[i][1]-data[j][1];
	int rd = data[i][2]+data[j][2];
	
	return xd*xd+yd*yd < rd*rd;
}

bool exist(int st, int i) {
	return st&(1<<i);
}

int main() {
	int n;
	while(cin >> n, n) {
		vvi data(n, vi(4));
		vvi covered(n, vi(n, 0));

		REP(i, n) {
			REP(j, 4) {
				cin >> data[i][j];
			}
		}

		REP(i, n) {
			REP(j, i) {
				int xd = data[i][0]-data[j][0];
				int yd = data[i][1]-data[j][1];
				int rd = data[i][2]+data[j][2];

				if(xd*xd+yd*yd < rd*rd) {
					covered[j][i] = 1;
				}
			}
		}

		vector<bool> memo(1<<n, false);
		memo[(1<<n)-1] = true;
		stack<int> S;
		S.push((1<<n)-1);
		int ans = 0;
		while(!S.empty()) {
			int st = S.top();
			S.pop();
			int nst;

			REP(i, n) {
				if(!exist(st, i)) {
					continue;
				}
				REP(k, i) {
					if(exist(st, k) && covered[k][i]) {
						goto nexti;
					}
				}
				REP(j, i) {
					if(!exist(st, j) || data[i][3] != data[j][3]) {
						continue;
					}
					REP(k, j) {
						if(exist(st, k) && covered[k][j]) {
							goto nextj;
						}
					}

					nst = st^(1<<i)^(1<<j);
					if(memo[nst]) {
						continue;
					}
					memo[nst] = true;
					ans = max(ans, n-bitnum(nst));
					S.push(nst);

					nextj:;
				}
				nexti:;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

void execDp(vector<double> &dp,const int n,const vector<vector<int>> &edge){
    for(int i = n - 1; i > 0; i--){
        for(const auto x: edge[i]){
            dp[i] += (dp[x] + 1.0)/(double)edge[i].size();
        }
    }
}

double execDpNonChange(const vector<double> &dp,const int n,const vector<vector<int>> &edge,double minch){
    vector<double> tmpdp = dp;
    tmpdp[n] = minch;
    for(int i = n - 1; i > 0; i--){
        auto itr = lower_bound(edge[i].begin(),edge[i].end(),n+1);
        for(auto e = edge[i].begin(); e != itr; e++){
            tmpdp[i] -= dp[*e]/(double)edge[i].size();
            tmpdp[i] += tmpdp[*e]/(double)edge[i].size();
        }
    }
    return tmpdp[1];
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n,m;
    cin >> n >> m;

    vector<list<int>> edge(n+1);

    for(int i = 0; i < m; i++){
        ll a,b;
        cin >> a >> b;
        edge[a].push_back(b);
    }

    vector<vector<int>> edgevec;

    for(const auto &e : edge){
        vector<int> tmpedge;
        for(const auto &ev : e){
            tmpedge.push_back(ev);
        }
        edgevec.push_back(tmpedge);
    }

    for(auto &e : edgevec){
        sort(e.begin(),e.end());
    }

    vector<double> dp(n+1,0);

    execDp(dp,n,edgevec);

    double ans = dp[1];

    for(int i = n-1; i > 0; i--){
        if(edgevec[i].size() > 1){
            double mindp = (double)dp[i];
            for(const auto x: edgevec[i]){
                double chdp = dp[i];
                chdp *= (double)edgevec[i].size();
                chdp -= (dp[x] + 1.0);
                chdp /= (double)(edgevec[i].size() - 1);
                mindp = min(mindp,chdp);
            }
            ans = min(execDpNonChange(dp,i,edgevec,mindp),ans);
        }
    }

    cout << setprecision(17) << fixed;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6656
def pm_table(n):
    """
    素数テーブル
    nのリストを返却する
    :param n:
    """
    res = [1] * (n + 1)
    res[0] = 0
    res[1] = 0

    for i in range(2, n):
        if i ** 2 > n:
            break

        if res[i] == 1:
            for j in range(i * 2, n + 1, i):
                res[j] = 0
    return res


N = 10 ** 5
pm = pm_table(N)

a = [0] * (N + 1)
for i in range(1, N + 1, 2):
    if pm[i] == 1 and pm[(i + 1) // 2] == 1:
        a[i] = 1
s = [0] * (N + 2)
for i in range(N + 1):
    s[i + 1] = s[i] + a[i]

q = int(input())
for i in range(q):
    l,r = [int(_) for _ in input().split()]
    print(s[r+1] - s[l])


Measured memory_bytes: 7892
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  string s; cin >> s;
  ll i=0;
  bool is_unbalance = false;
  while (i<s.size()) {
    if (i-1>=0 && s[i]==s[i-1]) {
      cout << i << ' ' << i+1 << endl;
      is_unbalance = true; break;
    } else if (i-2>=0 && s[i]==s[i-2]) {
      cout << i-1 << ' ' << i+1 << endl;
      is_unbalance = true; break;
    }
    i++;
  }
  if (!is_unbalance) cout << -1 << ' ' << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pb push_back 
#define mp make_pair
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
map < char, int> p;
int main() { fastIO
	string s1;
	cin >> s1;
	int l = 0, r = 0;
	int ans = 0, piv = 0;
	for (char c : s1){
		if (c == 'R')++piv;
		else{
			ans = max(ans, piv);
			piv = 0;
		}
	} ans = max(ans, piv); 
	cout << ans << endl;

	    return 0;	
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;
typedef double R;

int n, m;

const int MK = 550*550;
const R PI = acos((R)-1);
const R EPS = 1e-9;

int k;
R ar[MK];
ll buf[MK], sm[MK];

ll solve(int x, int y) {



	k = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i == x && j == y) continue;
			ar[k] = arg(complex<R>(i-x, j-y));
			ar[k] += EPS;
			k++;
		}
	}
	sort(ar, ar+k);
	for (int i = 0; i < k; i++) {
//		printf("%lf ", ar[i] / PI);
		buf[i] = lower_bound(ar, ar+k, ar[i]+PI+EPS) - ar;
//		printf("%lld\n", buf[i]);
	}// printf("\n");

	sm[0] = 0;
	for (int i = 1; i <= k; i++) {
		sm[i] = sm[i-1] + buf[i-1];
	}

	ll res = 0;//n*m - 1 C 2

	for (int i = 0; i < k; i++) {
		ll l = lower_bound(ar, ar+k, ar[i]+EPS) - ar;
		ll r = lower_bound(ar, ar+k, ar[i]+PI-EPS) - ar;
		res += sm[r]-sm[l];
		res -= (r-l)*r;

		ll l2 = lower_bound(ar, ar+k, ar[i]+PI-EPS) - ar;
		ll r2 = lower_bound(ar, ar+k, ar[i]+PI+EPS) - ar;
		//rr-ll
		res += (r2-l2) * (k-r2);

		res += (k-(r2-l2 + l));
//		printf("%lf %d %lld %lld %d %lld\n", ar[i], k, r2, l2, i, (k-(r2-l2+l)));
	}
//	printf("a\n");
	return res;
}

int main() {
	cin >> n >> m;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
//	printf("%lld %lld\n", solve(x1, y1), solve(x2, y2));
	cout << abs(solve(x1, y1) - solve(x2, y2)) << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 3e3 + 5;

const int inf = 1e15;

int n, dp[N][N][2], a[N];

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    /*for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            for(int k = 0; k <= 1; k++)
                dp[i][j][k] =
        }
    }*/
    for(int i = 1; i <= n; i++) {
        if(n % 2 != 0) {
            dp[i][i][0] = a[i];
            dp[i][i][1] = 0;
        }
        else {
            dp[i][i][0] = 0;
            dp[i][i][1] = -a[i];
        }
    }
    for(int len = 2; len <= n; len++) {
        for(int i = 1; i <= n; i++) {
            int j = i + len - 1, k;
            if(j > n) break;
            if((n - len) % 2 != 0) {//luot thang 2
                k = 1;
                dp[i][j][k] = min(dp[i + 1][j][1 - k] - a[i], dp[i][j - 1][1 - k] - a[j]);
            }
            else {
                k = 0;
                dp[i][j][k] = max(dp[i + 1][j][1 - k] + a[i], dp[i][j - 1][1 - k] + a[j]);
            }
        }
    }
    cout << dp[1][n][0];
}


Measured memory_bytes: 139648
// Problem : D - Chat in a Circle
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;
int a[maxN];
ll sum;
// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	REP(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	sum = a[n - 1];
	int x = n - 2;
	int cnt = 1;
	while (cnt != n - 1) {
		sum += 2 * a[x];
		cnt += 2;
		if (cnt >= n) cnt--, sum -= a[x];
		x--;
		// cout << sum << " " << cnt << endl;
	}
	cout << sum;
	return 0;
}
 


Measured memory_bytes: 4420
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	vi a(4), b(2);
	rep(i, 4) cin>>a[i];
	rep(i, 2) cin>>b[i];
	sort(rall(a));
	int sum = 0;
	rep(i, 3) sum += a[i];
	sum += max(b[0], b[1]);
	cout<<sum<<endl;
}

Measured memory_bytes: 1196
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>

typedef  long long ll;

ll a[81];
ll n, x = 1000, b;
int main()
{
	scanf("%lld", &n);

	for (ll i = 1; i <= n; i++) scanf("%lld", a + i);

	for (ll i = 1; i < n; i++)
		if (a[i + 1] > a[i]) 
		{
			b = x / a[i];
			x %= a[i];
			b *= a[i + 1];
			x += b;
		}

	printf("%lld\n", x);
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll dat[200010];
ll u;
void seginit(ll n){
    for(int i=0;;i++){
        ll y=pow(2,i);
        if(y>=n){
            u=y;
            break;
        }
    }
    fill(dat,dat+2*u,inf);
}
void add(ll n,ll x){
    ll i=n+u-1;
    dat[i]=x;
    while(i>0){
        i=(i-1)/2;
        dat[i]=min(dat[2*i+1],dat[i*2+2]);
    }
}
ll que(ll a,ll b,ll k,ll l,ll r){
    if(a>=r||b<=l)return inf;
    if(a<=l&&b>=r)return dat[k];
    ll m1=que(a,b,2*k+1,l,(l+r)/2);
    ll m2=que(a,b,2*k+2,(l+r)/2,r);
    return min(m1,m2);
}
int main(){
    ll n,x;cin>>n>>x;
    ll a[n];
    int num;ll mi=inf;
    rep(i,0,n){
        cin>>a[i];
        if(a[i]<mi){
            mi=a[i];
            num=i;
        }
    }
    seginit(n);
    ll b[n];
    rep(i,num,n)b[i-num]=a[i];
    rep(i,0,num)b[n+i-num]=a[i];
    rep(i,0,n)add(i,b[i]);
    ll ans=inf;
    rep(i,0,n){
        ll sum=x*i;
        rep(j,0,n){
            ll r=que(max((ll)0,(ll)j-i),(ll)j+1,0,0,u);
            sum+=r;
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    int k=0;
    vector<int> A;
    vector<pair<int,int>> pairs(M);
    for(int i=0;i<N;i++){
        scanf("%d",&k);
        A.push_back(k);
    }
    for(int i=0;i<M;i++){
        scanf("%d",&pairs[i].second);
        scanf("%d",&pairs[i].first);
    }

    sort(pairs.begin(),pairs.end(),greater<pair<int,int>>());
    sort(A.begin(),A.end(),greater<int>());
    long int sum=0;
    int lookA=0;
    int lookJ=0;
    int sumnum=0;
    while(1){
        if(A[lookA]<pairs[lookJ].first){
            for(int i=0;i<pairs[lookJ].second;i++){
                sum+=pairs[lookJ].first;
                sumnum+=1;
                if(sumnum==N){
                    cout<<sum<<endl;
                    break;
                }
            }
            lookJ+=1;
        }else{
            sum+=A[lookA];
            lookA+=1;
            sumnum+=1;
            if(sumnum==N){
                cout<<sum<<endl;
                break;
            }
        }
    if(sumnum==N){
        break;
    }
}
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}


ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))
;
void prac(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
   #endif 
}

int main() 
{
  
  ll n;in(n)
  string s;
  cin>>s;
  vector<ll>dp(n+1,0);
  vector<ll>pref(n+1,0);
  dp[1]=1;
  for(ll i=2;i<=n;i++){
  	 for(ll j=1;j<=i-1;j++){
  	 	pref[j]=pref[j-1]+dp[j];
  	 	pref[j]%=mod;
  	 }
  	 // prllarr(dp,5);
  	 // prllarr(pref,5)
  	 
  	 for(ll j=1;j<=i;j++){
  	 	if(s[i-2]=='>'){
  	 		if(i-1>=j)dp[j]=pref[i-1]-pref[j-1]+mod;
  	 		
  	 	}
  	 	else{

  	 		dp[j]=pref[j-1];
  	 	}
  	 	dp[j]%=mod;
  	 }

  }
   // prllarr(dp,5);
  	//  prllarr(pref,5)
  ll ans=0;
  for(ll i=1;i<=n;i++){
  	ans=(ans+dp[i])%mod;
  }
  out(ans)
}
/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/






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

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(int x, int y){
  if(x % y == 1) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(int x, int y){
  return x * y / gcd(x, y);
}
// n個の最大公約数
ll ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i=1; i<a.size() && res!=1; i++){
    res = gcd(res, a[i]);
  }
  return res;
}
// n個の最小公倍数
ll nlcm(vector<int> a){
  int res;
  res = a[0];
  REP(i, a.size()){
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  while(1){
    int a = n%10;
    int cop = n;
    bool ok = true;
    rep(i,3){
      if(cop % 10 != a) ok = false;
      cop /= 10;
    }
    if(ok){
      cout << n << endl;
      return 0;
    }
    n++;
  }
}






Measured memory_bytes: 256
/*
   О НЕТ! ОНИ ДОГОНЯЮТ!!!
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
   🐹🐹🐹🐹🐹🐹🐹🐹🐹🐹
*/

#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 1e3 + 7;
const int M = 5e3 + 7;

int a[N];
int cur[N][M];
int sz[N];
int w[N];
int mx[N];
vector <int> g[N];

void dfs(int v)
{
    if (g[v].size() == 0)
    {
        a[v] = 0;
        return;
    }
    for (int to : g[v])
    {
        dfs(to);
    }
    int i = 0;
    cur[0][0] = 0;
    for (int to : g[v])
    {
        for (int x = 0; x < M; x++)
        {
            if (x + w[to] < M && cur[i][x] != 1e9)
            {
                cur[i + 1][x + w[to]] = min(cur[i + 1][x + w[to]], cur[i][x] + a[to]);
            }
            if (x + a[to] < M && cur[i][x] != 1e9)
            {
                cur[i + 1][x + a[to]] = min(cur[i + 1][x + a[to]], cur[i][x] + w[to]);
            }
            cur[i][x] = 1e9;
        }
        i++;
    }
    a[v] = 1e9;
    for (int x = 0; x < M; x++)
    {
        if (x <= w[v])
        {
            a[v] = min(a[v], cur[i][x]);
        }
        if (cur[i][x] <= w[v])
        {
            a[v] = min(a[v], x);
        }
        cur[i][x] = 1e9;
    }
    if (a[v] == 1e9)
    {
        cout << "IMPOSSIBLE\n";
        exit(0);
    }
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; i++)
    {
        int p;
        scanf("%d", &p);
        p--;
        g[p].push_back(i);
    }
    for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) cur[i][j] = 1e9;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &w[i]);
    }
    dfs(0);
    cout << "POSSIBLE\n";
}


Measured memory_bytes: 20096
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
    int X,Y; cin >> X >> Y;

    cout << X+Y/2;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author test
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc187_a solver = new abc187_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc187_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            if (in.nextInt() == 1) {
                out.println(0);
            } else {
                out.println(1);
            }
        }

    }
}



Measured memory_bytes: 35716
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c== 'a' || c== 'i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
const int N = int(1e5) + 123;

pair <int, int> a[N];
 
int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++) cin >> a[i].F, a[i].S = i;
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++) if(!(i % 2) && a[i].S % 2) ans++;  
	cout << ans;
}                                   	


Measured memory_bytes: 1024
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7; 
const int N=1e6 + 5;
ll arr[N];
ll dp[N];
ll OO=1e12; 
 
ll n,m,k,cnt,SU,idx,len,MN,MX;
ll l,r,mid;
ll a,b,c,d,s;
vector<ll> vec;
 
ll Solve(int idx){
	
	ll &ret=dp[idx];
	if(idx == n)
		return ret = 0;
	if(idx > n)
	return ret = OO;
	
	if(~ret)
		return ret;
	
	ll x = abs(arr[idx] - arr[idx+1]) + Solve(idx+1);
	ll y = abs(arr[idx] - arr[idx+2]) + Solve(idx+2);
	
	return ret = min(x,y);
}

 
 
 
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>arr[i];
	
	memset(dp,-1,sizeof dp);
	
	cout<<Solve(1)<<endl;
	


	
		
}
 
 


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(a*b==c*d) cout << a*b;
    else cout << max(a*b,c*d);
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, k: i64,
        a: [i64; n],
    }
    let cnt = (n - 2) / (k as usize - 1);
    puts!("{}\n", cnt + 1);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 8572
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#define LL long long
LL N,X;
LL f(LL a,LL b)
{
    if(a==0)return -b;
    return f(b%a,a)+2*a*(b/a);
}
int main()
{
    scanf("%lld%lld",&N,&X);
    printf("%lld",f(X,N-X)+N);
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int a,b,c,ans = 0;
  scanf("%d %d %d",&a,&b,&c);
  for(int i=a;i<=b;i++){
      if(c%i==0) ans++;
  }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2124
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << E;
    else cout << "No" << E;
    //system("pause");
    return 0;
}

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

using namespace std;
const int N = 100010;
int acs[N], was[N];
int n, m;

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i ++)
    {
        int idx;
        string res;
        cin >> idx >> res;
        if(res == "WA" && acs[idx] == 0) was[idx] ++;
        if(res == "AC") acs[idx] ++;
    }
    int cnt_ac = 0;
    int cnt_wa = 0;
    for(int i = 1; i <= n; i ++)
    {
        if(acs[i] > 0) 
        {
            cnt_ac ++;
            cnt_wa += was[i];
        }
    }
    cout << cnt_ac << " " << cnt_wa << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	char a;
	int n;
	int m;
	int judge = 0;
	int counter = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> m;
		if (judge == 1) {
			continue;
		}
		if (a == '(') {
			counter += m;
		} else {
			counter -= m;
			if (counter < 0) {
				judge = 1;
			}
		}
	}

	if (counter != 0) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}

	return 0;
}

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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    int n,k;
    cin >> n >> k;
    int v[10];
    memset(v,0,sizeof v) ;
    while(k--)
    {
        int x;
        cin >> x;
        v[x]++;
    }
    int mn;
    for(int i=0;i<10;i++)
    {
        if(v[i]==0)
        {
            mn=i;
            break;
        }
    }
    vector <int> tk,tk2,ans;
    while(n>0)
    {
        tk.pb(n%10);
        n/=10;
    }
    for(int i=tk.size()-1;i>=0;i--)
    {
        tk2.pb(tk[i]);
    }

    for(int i=0;i<tk2.size();i++)
    {
        if(v[tk2[i]]==0)
        {
            ans.pb(tk2[i]);
        }
        else
        {
            for(int j=tk2[i]+1;j<10;j++)
            {
                if(v[j]==0)
                {
                    ans.pb(j);
                    for(int k=i+1;k<tk2.size();k++)
                    {
                        ans.pb(mn);
                    }
                    for(auto k : ans) cout << k;
                    return 0;
                }
            }
            for(int j=i;j<=tk2.size();j++)
            {
                ans.pb(mn);
            }
            for(auto k : ans) cout << k;
            return 0;

        }
        
    }
    for(auto k : ans) cout << k;

    //---------------------------------
    
    return 0;
}




Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
 
using namespace std;
using sl = signed long;
using sll = signed long long;
using ll = long long;

int main(int argc, char *argv[])
{
	int N, Q;
	sl K;
	cin >> N >> K >> Q;
	//vector<int> A;

	sl *score = new sl[(N+1)];
	memset(score, K, sizeof(score));
	for (int i=1; i<N+1;i++){
		score[i] = K;
	}

	for(int i =0; i<Q ;i++){
		int tmp;
		cin >> tmp;
		score[tmp]++;
	}

	for(int i =1;i<N+1;i++){
		if(score[i]-Q <=0){
			cout <<"No" <<endl;
		}else{
			cout << "Yes" <<endl;
		}
	}

	delete[] score;
	return 0;
}

Measured memory_bytes: 1408
N, M = map(int, raw_input().split())
E = {}
for _ in range(M):
	a, b = map(int, raw_input().split())
	if not a in E: E[a] = set()
	if not b in E: E[b] = set()
	E[a].add(b)
	E[b].add(a)

def numPaths(visited_nodes, start_node):
	if len(visited_nodes) == N-1:
		return 1
	sum = 0
	for adj_node in E[start_node]:
		if not adj_node in visited_nodes:
			visited_nodes.add(start_node)
			sum += numPaths(visited_nodes, adj_node)
			visited_nodes.remove(start_node)
	return sum

print numPaths(set(), 1)

Measured memory_bytes: 2692