akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
priority_queue<ll> pq1;
ll bias1, bias2;
priority_queue<ll,vector<ll>,greater<ll> > pq2;
ll res;

void push(ll a, ll b, ll l) {
    if (l==-1) {
        pq1.push(a+bias1); pq2.push(a-bias2);
        return;
    }
    bias1 += b-a; bias2 += l;
    if (a<=pq1.top()-bias1) {
        res += pq1.top()-bias1-a;
        pq2.push(pq1.top()-bias1-bias2);
        pq1.pop();
        pq1.push(a+bias1);
        pq1.push(a+bias1);
    }
    else if (a<=pq2.top()+bias2) {
        pq1.push(a+bias1);
        pq2.push(a-bias2);
    }
    else {
        res += a-pq2.top()-bias2;
        pq1.push(pq2.top()+bias1+bias2);
        pq2.pop();
        pq2.push(a-bias2);
        pq2.push(a-bias2);
    }
}

int main() {
    int i;
    scanf("%d",&n);
    ll l = -1;
    for (i=0;i<n;i++) {
        ll a, b;
        scanf("%lld%lld",&a,&b);
        push(a,b,l);
        l = b-a;
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

vector<int> Input(const int n)
{
	vector<int> W;
	for(int i = 0; i < n; i++){
		int w;
		cin >> w;
		W.push_back(w);
	}
	return W;
}

bool IsAllLoaded(int P, vector<int> W, int k)
{
	int TrackIndex = 0;
	int CurrentSum = 0;
	int i = 0;
	for(i = 0; i < W.size(); i++){
		if(W[i] > P){
			return false;
		}
		if(CurrentSum + W[i] > P){
			TrackIndex++;
			if(TrackIndex == k){
				return false;
			}
			CurrentSum = 0;
		}
		CurrentSum += W[i];
	}
	return true;
}

int Calc(vector<int> W, int k)
{
	int Sum = accumulate(W.begin(), W.end(), 0 );
	int P = (Sum + k - 1) / k;
	while(!IsAllLoaded(P, W, k)){
		P++;
	}
	return P;
}

int main()
{
	int n, k; //n:???????????° k:?????????????????°  
	cin >> n >> k;
	vector<int> W = Input(n);
	int P = Calc(W, k); //P:??????????????????????????????????????????????????§????????????????°????
	cout << P << endl;
	return 0;
}

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

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

    vector<long long int> l(n);
    for(int i=0; i<n; i++){
        cin >> l[i];
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(l[i] == l[j]
                || l[i] == l[k]
                || l[j] == l[k]) continue;

                if(l[i] < l[j] + l[k]
                && l[j] < l[i] + l[k]
                && l[k] < l[i] + l[j]) ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

/**
 * DFSによる解法
 *
 * @author kou
 *
 */
public class Main {

    static boolean[] isConnected;

    static List<Set<Integer>> edgeList = new ArrayList<Set<Integer>>();

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());

        for (int i = 0; i < n; i++) {
            edgeList.add(new HashSet<Integer>());
        }
        isConnected = new boolean[n];

        int[] a = new int[m];
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = Integer.parseInt(scan.next());
            b[i] = Integer.parseInt(scan.next());
            a[i]--;
            b[i]--;
            edgeList.get(a[i]).add(b[i]);
            edgeList.get(b[i]).add(a[i]);
        }
        scan.close();

        int ans = 0;
        for (int i = 0; i < m; i++) {
            edgeList.get(a[i]).remove(b[i]);
            edgeList.get(b[i]).remove(a[i]);

            Arrays.fill(isConnected, false);
            dfs(0);
            for (int j = 0; j < n; j++) {
                if (!isConnected[j]) {
                    ans++;
                    break;
                }
            }

            edgeList.get(a[i]).add(b[i]);
            edgeList.get(b[i]).add(a[i]);
        }

        System.out.println(ans);
    }

    private static void dfs(int i) {
        isConnected[i] = true;

        for (int node : edgeList.get(i)) {
            if (!isConnected[node]) {
                dfs(node);
            }
        }
    }

}


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

#define ll long long

vector <int> v[10];

int search(int l,int ind)
{
    for(int i=0;i<v[ind].size();i++)
    {
        if(v[ind][i]>l)
            return v[ind][i]; 
    }
    return -1;
}
int main()
{
    int n,k,l,i,j,p,cnt=0;
    string s;
    cin>>n>>s;

    int fi[10],la[10];

    for(i=0;i<10;i++)
        fi[i]=9999999;
    for(i=0;i<10;i++)
        la[i]=-1;

    for(i=0;i<n;i++)
    {
        k = s[i]-'0';
        v[k].push_back(i);
        fi[k] = min(fi[k],i);
        la[k] = max(la[k],i);
    }    

    for(i=0;i<10;i++)
    {
        if(fi[i]==9999999)
            continue;
        
        l = fi[i];

        for(j=0;j<10;j++)
        {
            p = search(l,j);
            if(p!=-1)
            {
                for(k=0;k<10;k++)
                {
                    if(la[k]>p)
                        cnt++;
                }
            }
        }
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int n,m;
  ll l;
  cin>>n>>m>>l;

//———————ワーシャルフロイド法　O(N^3)—————————————————

  vector<vector<ll>> dist(n,vector<ll>(n,INF));
  rep(i,n){
    dist[i][i]=0;
  }

  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    dist[a-1][b-1]=c;
    dist[b-1][a-1]=c;
  }

  rep(i,n){
    rep(j,n){
      rep(k,n){
        dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
        dist[k][j]=dist[j][k];
      }
    }
  }  

//———————ワーシャルフロイド法　O(N^3)—————————————————

  vector<vector<ll>> ans(n,vector<ll>(n,INF));
  rep(i,n){
    ans[i][i]=0;
  }

  rep(i,n){
    rep(j,n){
      if(i>=j) continue;
      if(dist[i][j]<=l) {
        ans[i][j]=1;
        ans[j][i]=1;
      }
    }
  }

  rep(i,n){
    rep(j,n){
      rep(k,n){
        ans[j][k]=min(ans[j][k],ans[j][i]+ans[i][k]);
        ans[k][j]=ans[j][k];
      }
    }
  }

  int q;
  cin>>q;
  rep(i,q){
    int s,t;
    cin>>s>>t;
    s--;t--;
    if(ans[s][t]==INF) cout << -1 << endl;
    else cout << ans[s][t]-1 << endl;
  }



}

Measured memory_bytes: 4784
x=int(input())
a=[]
for i in range(0,500):
  a.append(i**5)
for i in range(0,len(a)):
  for j in range(0,len(a)):
    if(a[i]-a[j]==x):
      print(i,j)
      break
    elif(a[i]+a[j]==x):
      if(i>j):
        print(i,-j)
      else:
        print(j,-i)
      break
  else:
    continue
  break

Measured memory_bytes: 9200
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  int n;
  cin >> n;
  int A[n];
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> A[i];
    while(true){
      if(A[i] % 2 == 0){
        ans ++;
        A[i] /= 2;
      }else break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    unsigned long power = 1;
    unsigned long pow = 1;
    for(int i=0; i<9; i++){
        pow*=10;
    }
    pow+=7;
    for(int i=1; i<=N; i++){
        power=(i*power)%pow;
    }
    cout << power << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n, l;
  cin >> n >> l;
  cin.ignore();

  int sum;
  sum = n * l + (n * (n - 1)) / 2;

  int i;

  // いきなり正の場合
  if(l - 1 >= 0){
    cout << sum - l << endl;
    return 0;
  } else if(l + n - 1 <= 0){ // 最後まで負
    cout << sum - (l + n - 1) << endl;
    return 0;
  } else { // 途中から正負が変わる場合 -> 必ず0がいる
    i = 1 - l;
    cout << sum << endl;
  }
  return 0;
}   
    


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 1001

void Ics(char *X, char *Y)
{
   int c[N][N];
   int m, n, i, j;

   m = strlen(X);
   n = strlen(Y);

   for ( i = 0; i <= m; i++ ) {
      c[i][0] = 0;
   }
   for ( j = 1; j <= n; j++ ) {
      c[0][j] =0;
   }

   for ( i = 1; i <= m; i++ ) {
      for ( j = 1; j <=n; j++ ) {
         if ( X[ i - 1 ] == Y[ j - 1] ) {
            c[ i ][ j ] = c[ i - 1 ][ j - 1 ] + 1;
         } else if ( c[ i - 1 ][ j ] >= c[ i ][ j - 1 ] ){
            c[ i ][ j ] = c[ i - 1 ][ j ];
         } else {
            c[ i ][ j ] = c[ i ][ j - 1 ];
         }
      }
   }
   printf("%d\n", c[ m ][ n ]);
}
     
int main()
{
   int n, i;
   char X[N], Y[N];

   scanf("%d", &n);
   for ( i = 0; i < n; i++ ) {
      scanf("%s%s", X, Y);
      Ics(X, Y);
   }
   return 0;
}

Measured memory_bytes: 5708
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, S):
    fusioned = S[0]
    for s in S:
        if fusioned[-1] != s:
            fusioned += s
    print(len(fusioned))


if __name__ == '__main__':
    N = int(input())
    S = input()
    solve(N, S)


Measured memory_bytes: 9264
import scala.io.StdIn

object Main {
	def main(args: Array[String]): Unit ={
		val N = StdIn.readLine.toInt

		val wordList = (1 to N).foldLeft(Seq.empty[String]){ (list, num) =>
			val addStr = StdIn.readLine
			list :+ addStr
		}

		val distinctFlg = wordList.length == wordList.distinct.length
		lazy val result = wordList.foldLeft((true, wordList(0).head) ){ (tuple, str) =>
			( tuple._1 && tuple._2 == str.head, str.last )
		}
		println(if(distinctFlg && result._1 ) "Yes" else "No")
	}
}

Measured memory_bytes: 27328
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <vector>
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const int inf = 1e9 + 7;
const long long INF = 1e18 + 7;
const int maxn = 2e5 + 7;

string s;

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	for (int i = 0; i < s.size(); i++){
		if (s[i] != ',')
			cout << s[i];
		else
			cout << ' ';
	}
	return 0;
} 

Measured memory_bytes: 256
import scala.io.StdIn.{readLine, readInt}

object Main extends App {
  val length = readInt()
  var inputs = readLine().split(" ").map(_.toInt)
  var nSwapped = 0

  def swap[T](array: Array[T], l: Int, r: Int) {
    val left = array(l)
    array(l) = array(r)
    array(r) = left
  }

  for (i <- 0 until length) {
    for {
      j <- length - 1 until i by -1
      if inputs(j) < inputs(j - 1)
    } {
      swap(inputs, j, j - 1)
      nSwapped += 1
    }
  }

  println(inputs.mkString(" "))
  println(nSwapped)
}

Measured memory_bytes: 44268
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long x = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        long countA = a == 0 ? -1 : (a - 1) / x;
        Long countB = b / x;
        long result = countB - countA;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23380
N = int(input())
ans = "Yes"
X = 0
Y = 0
T = 0
for _ in range(N):
    t,x,y = map(int, input().split())
    dt = t-T
    d = abs(X-x)+abs(Y-y)-dt
    if d > 0 or d%2 == 1:
        ans = "No"
    T = t
    X = x
    Y = y

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  long long kazu,dasu;
  cin >> kazu >>dasu;
  vector <long long> bann(dasu);
  vector <string> dou(dasu);
  for(long long i = 0;i <= dasu - 1;i++){
    cin >> bann[i] >> dou[i];
  }
  vector<long long> ok(kazu);
  for(long long i = 0;i <= kazu - 1;i++){
    ok[i] = 0;
  }
 long long pena = 0;
  vector<long long> saisyo(kazu);
  for(int i = 0;i <= kazu - 1;i++){
    saisyo[i] = -1;
  }
  for(long long i = 0;i <= dasu - 1;i++){
    if(dou[i] == "AC" && ok[bann[i] - 1] == 0){
      ok[bann[i] - 1] = 1;
      saisyo[bann[i] - 1] = i;
    }
  }
  for(int i = 0;i <= dasu - 1;i++){
  if(dou[i] == "WA" && ok[bann[i] - 1] == 1 && i < saisyo[bann[i] - 1]){
  	pena++;
  }
  }
  long long kotae = 0;
  for(long long i = 0;i <= kazu - 1;i++){
    if(ok[i] == 1){
      kotae++;
    }
  }
  cout << kotae << " " << pena << endl;
  return 0;
}

Measured memory_bytes: 8064
from collections import deque
n = int(input())
G = [[0]*n for _ in range(n)]
for _ in range(n):
    u, k, *V = map(int, input().split())
    if k == 0:
        continue
    else:
        for v in V:
            G[u-1][v-1] = 1



def bfs(u=0):
    Q = deque([])
    color = ['White']*n
    d = [-1]*n

    d[0] = 0
    Q.append(u)
    while Q:
        u = Q.popleft()
        for v in range(n):
            if G[u][v] == 1 and color[v] == 'White':
                if d[v] != -1:
                    continue
                color[v] = 'Gray'
                d[v] = d[u] + 1
                Q.append(v)
        color[u] = 'Black'

    return d

D = bfs()
for i in range(n):
    print('{} {}'.format(i+1, D[i]))



Measured memory_bytes: 6076
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    d = [inf for _ in range(N)]
    d[0] = 0
    edges = []
    for _ in range(M):
        a, b, c = LI_()
        c += 1
        edges.append((a, b, -c))
    for _ in range(N-1):
        for edge in edges:
            fr, to, cost = edge
            if d[to] > d[fr] + cost:
                d[to] = d[fr] + cost
    neg = [False for _ in range(N)]
    for _ in range(N):
        for edge in edges:
            fr, to, cost = edge
            if neg[fr] == True:
                neg[to] = True
            if d[to] > d[fr] + cost:
                neg[to] = True
    if neg[N-1]:
        print('inf')
    else:
        print(-d[N-1])

main()



Measured memory_bytes: 5840
N, M, X, Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

for z in range(X+1,Y+1):
    t = 1
    for p in range(N):
        if x[p] >= z:
            t = 0
            break
    for q in range(M):
        if y[q] < z:
            t = 0
            break
    if t == 1:
        print("No War")
        exit(0)
print("War")

Measured memory_bytes: 3064
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
ll n, c, k;
ll a[maxn];
void solve() {
    cin >> n >> c >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int i = 0;
    int res = 0;
    while(i < n) {
        ll t = a[i] + k;
        int tc = 0;
        while(i < n && a[i] <= t && tc < c) {
            //cout << a[i] << endl;
            i++;tc++;
        }
        //cout << i << " " << tc << endl;
        res++;
    }
    cout << res << endl;
}
int main() {
   // freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1024
import sys,collections as cl,bisect as bs
import itertools
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = 10 ** 15
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return "".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

def warshall_floyd(n,d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N,M,r = m()

R = l()

di = [[Max for i in range(N)] for j in range(N)]

for i in range(N):
    di[i][i] = 0

for i in range(M):
    a,b,c = m()
    a -= 1
    b -= 1
    di[a][b] = c
    di[b][a] = c


di = warshall_floyd(N,di)

Ma = Max


te = list(itertools.permutations(R))
for i in range(len(te)):
    co = 0
    RR = te[i]
    for j in range(r-1):
        co += di[RR[j]-1][RR[j+1]-1]
    Ma = min(co,Ma)
print(Ma)












Measured memory_bytes: 48620
s = input() #sys.stdin.readlineは最後が改行

count = 0
ans=len(s)
tmp=0
for cc in list(set(s)):

    for i in range(len(s)):
        if s[i]==cc:
            tmp = max(tmp,count)
            count = 0
        else:
            count+=1

    tmp = max(tmp,count)

    ans = min(ans,tmp)
    tmp=0
    count=0

print(ans)


Measured memory_bytes: 3060
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val M = sc.nextInt
    val x = Math.pow(2, M).toInt
    val a = (1900 * M + (N-M) * 100) * x
    println(a)
  }
}

Measured memory_bytes: 25928
#include<bits/stdc++.h>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;typedef pair<int,int> pii;inline int inn() { int x,ch;while((ch=gc)<'0'||ch>'9');x=ch^'0';while((ch=gc)>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^'0');return x; }
int a[2010];bitset<2010*2010> dp; int main() { int n=inn(),s=0;rep(i,1,n) a[i]=inn(),s+=a[i];dp.set(0);rep(i,1,n) dp|=(dp<<a[i]);rep(i,(s+1)/2,s) if(dp[i]) return !printf("%d\n",i);return 0; }

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
using ll=long long int; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
typedef vector<int> vi;
ll INFLL=(ll)2e18, MOD=1'000'000'007;
const int INF=0x3f3fffff ;
/////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vi> adj; vi vis; vi level;
// int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
int dx8[]={-1,1,2,2,1,-1,-2,-2}, dy8[]={2,2,1,-1,-2,-2,-1,1};
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
inline bool ispow2(ll x){ return x && (!(x&(x-1)));}
inline ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}


/////////////////// MAIN STARTS //////////////////////////////////
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
// random_device rd; mt19937 genr(rd());

#ifdef DEBUG
  auto tStart = chrono::system_clock::now(); //freopen("op.txt","w",stdout);
#endif

int n; cin>>n;
cout<< (n/2)*(n-n/2) <<'\n'; 

#ifdef DEBUG
  auto diff=chrono::system_clock::now()-tStart;
  cerr<<"\nExecution time: "<<chrono::duration<dd,milli>(diff).count()<<" ms.\n";
#endif
return 0;
}


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

int main(void) {
  int A, B;
  cin >> A >> B;
  if(A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B /2 << endl;
  } else {
    cout << 0 << endl;
  }
    
}

Measured memory_bytes: 256
S = gets.chomp

sum = 0

queue = [ [S] ]
until queue.empty?
  q = queue.shift
  sum += q.map(&:to_i).inject(&:+)
  
  s = q.pop
  (1..s.size-1).each do |i|
    queue << [*q, s[0, i], s[i..-1]]
  end
end
puts sum

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

int main()
{
  int n;
  scanf("%d",&n);
  vector<pair<int,int> > X(2*n+2);
  for(int i=0;i<n;i++){
    int L,R;
    scanf("%d%d",&L,&R);
    X[2*i]=make_pair(L,1);
    X[2*i+1]=make_pair(R,-1);
  }
  X[2*n]=make_pair(0,1);
  X[2*n+1]=make_pair(0,-1);
  sort(X.begin(),X.end());
  long long ans=0ll;
  int nl=n+1,nr=0;
  for(int i=0;i+1<X.size();i++){
    if(X[i].second==1){
      nl--;
    }
    else{
      nr++;
    }
    int T=(X[i+1].first-X[i].first);
    ans+=(long long)T*min(nl,nr)*2ll;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1792
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)          cout<<#x<<" "<<x<<endl
#define ar 				array
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool compare(pair<int, int>&a, pair<int, int>&b)
{
	return a.first < b.first;
}
int cb(int number)
{
	return (int)log2(number) + 1;
}
int32_t main()
{
	Raghav();
	int n;
	cin >> n;
	vi a(n + 1);
	int curr = 1000;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i < n; i++)
	{
		if (a[i] < a[i + 1])
		{
			int stocks = curr / a[i];
			curr += stocks * (a[i + 1] - a[i]);
			//cout << curr << endl;
		}
	}
	cout << curr;
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int s;
int a[1000010];


int solve(){
	int v = s;
	rep(i, 1, 1000010){
		if(a[v]) return i;
		a[v] = i;
		if(v%2 == 0) v/=2;
		else v = 3*v+1;
	}
	return -1;
}


signed main(){
	cin >> s;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter

def solve():
    N = int(input())

    def getPrimeFactors(x):
        anss = []
        while x%2 == 0:
            anss.append(2)
            x //= 2
        for d in range(3, int(x**0.5)+1, 2):
            while x%d == 0:
                anss.append(d)
                x //= d
        if x != 1:
            anss.append(x)
        return anss

    PFs = getPrimeFactors(N)
    cnt = Counter(PFs)

    ans = 0
    for p, e in cnt.items():
        for i in range(1, 50):
            if e >= i:
                ans += 1
                e -= i

    print(ans)


solve()


Measured memory_bytes: 9720
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
   int n;
   cin >> n;
   vector<int> a(n);
   vector<int> t(100001);
   for(int i = 0;i < n;i++){
       cin >> a[i];
       t[a[i]]++;
   }
   int ans = 0;
   for(int i = 1;i <= 100000;i++){
       t[i] += t[i - 1];
       if(t[i] == n / 2)ans++;
   }
   cout << ans << endl;
   
}


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

#define ll long long
#define mod 1000000007
#define pb push_back


int main()
{
  ll a;
  cin>>a;
  ll b[a],y=0;
  for(ll i=0;i<a;i++)
  {
    cin>>b[i];
    if(b[i]%2==0)
    {
      if(b[i]%3==0||b[i]%5==0)
      {
        continue;
      }
      else
      {
        y=1;
      }
    }
  }
  if(y==0)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,C;
    cin >> A>>B>>C;
    vector<int>vec(200000,0);
    for(int k=0;k<=C;k++){
      for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            ++vec.at(500*i+100*j+50*k);
          }
        }
    }
   int X;
    cin >>X;
  cout <<vec.at(X)<<endl;
} 

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
const int N = (int) 2*1e5+5;

int n;
long long len;
int a[N];
long long jump[N][70], gap[N][70];
int rem[N];

int main(){
    iostream::sync_with_stdio(0);

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

    for(int i=n;i>=1;i--)
        jump[i][0] = rem[a[i]],
        rem[a[i]] = i;
    for(int i=n;i>=1;i--)
        if (jump[i][0] == 0)
            jump[i][0] = rem[a[i]],
            gap [i][0] = 1;

    #define nxt(x) ((x) == n ? 1 : (x)+1)

    for(int k=1;k<70;k++)
        for(int i=1;i<=n;i++)
            jump[i][k] = jump[nxt(jump[i][k-1])][k-1],
            gap [i][k] = gap[i][k-1] + gap[nxt(jump[i][k-1])][k-1] + (jump[i][k-1] == n),
            gap [i][k] = min(gap[i][k], (long long) 1e18);
    long long tmp = len;
    int cur = 1;
    while(len > 1){
        for(int _=69;_>=0;_--){
            if (len > gap[cur][_] + (jump[cur][_] == n)){
                len -= gap[cur][_] + (jump[cur][_] == n);
                cur = nxt(jump[cur][_]);
                break;
            }
        }
        //cout << cur << ' ' << len << endl;
    }
    //for(int i=1;i<=n;i++)   cout << jump[i][0] << ' ' << gap[i][0] << endl;
    //cout << jump[1][2] << endl;

    assert(len == 1);
    vector <int> st;
    map<int,int> mp;
    for(int i=cur;i<=n;i++){
        if (mp[a[i]] == 0){
            st.push_back(a[i]);
            mp[a[i]] = 1;
        }
        else{
            while(st.back() != a[i])   mp[st.back()] = 0, st.pop_back();
            st.pop_back();
            mp[a[i]] = 0;
        }
    }
    for(auto v: st) cout << v << ' ';

    // cout << "asd" << endl;
    // st.clear();
    // mp.clear();
    // for(int i=1;i<=tmp;i++){
    //     for(int j=1;j<=n;j++){
    //         if (mp[a[j]] == 0){
    //             st.push_back(a[j]);
    //             mp[a[j]] = 1;
    //         }
    //         else{
    //             while(st.back() != a[j])   mp[st.back()] = 0, st.pop_back();
    //             st.pop_back();
    //             mp[a[j]] = 0;
    //         }
    //         if (st.size() == 0) cout << j << ' ' << tmp+1-i << endl;
    //         //for(auto v: st) cout << v << ' '; cout << endl;
    //     }
    // }
}


Measured memory_bytes: 232052
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=0;i<n;i++)

const int MAX = 1e5 + 10;

int main(){
	ll n,k; cin>>n>>k;
	
	ll a[MAX];  rep(i,0,n) cin>>a[i];
	
	ll cnt[50]={0};
	
	rep(i,0,n){
	    ll t = a[i];
	    int j=0;
	    while(t > 0){
	        if(t%2 == 1) cnt[j]++;
	        j++;
	        t /= 2;
	    }
	}
	
	ll j=0; ll p=1;
	while(p<=k){
	    p *= 2; j++;
	}
	ll ans=0;
	while(j>=0){
	   if(n - cnt[j] > cnt[j]){
	       if(ans + p <= k) ans += p;
	   } 
	   p /= 2;
	   j--;
	}
	ll sum=0;
	rep(i,0,n) sum += a[i]^ans;
	cout<<sum;
	
}	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) max_element(all(v))
#define minv(v) min_element(all(v))
#define bclock auto start=high_resolution_clock::now(); 
#define eclock auto stop = high_resolution_clock::now(); 
#define calctime auto duration=duration_cast<milliseconds>(stop-start); cout<<"\nTime "<<duration.count()<<endl;
using namespace std;
using namespace std::chrono;
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
int main() {
   IOS
   int n,ans=0;
   cin>>n;
   int a[n+1];
   for(int i=1;i<=n;i++)
		cin>>a[i];
   int b[n+1];
   for(int i=1;i<=n;i++)
		cin>>b[i];
   int c[n+1];
   for(int i=1;i<n;i++)
		cin>>c[i];
   for(int i=1;i<=n;i++) {
		if(i>1 && a[i]-a[i-1]==1)
			ans+=(c[a[i-1]]+b[a[i]]);
		else
			ans+=b[a[i]];		
   }
   cout<<ans;
   
   return 0;
}


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

#define EPS (1e-7)
#define INF (1e9 + 5)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, M;
ll A[5005];
ll B[5005][300];
ll Point[5005];
ll field[5005][5005];
int main() {
    //cout.precision(10);
    cin >> N >> M;
    for(int i = 2; i <= N; i++) {
        cin >> A[i];
        Point[i] = Point[i - 1] + A[i];
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= M; j++) {
            cin >> B[i][j];
            B[0][j] = INF;
            B[N + 1][j] = INF;
        }
    }
    for(int ticket = 1; ticket <= M; ticket++) {
        for(int shop = 1; shop <= N; shop++) {
            int before = shop - 1;
            int after = shop + 1;
            while(B[before][ticket] <= B[shop][ticket]) before--;
            before++;
            while(B[after][ticket] < B[shop][ticket]) after++;
            //cout << ticket << " " << shop << " " << before << " " << after << endl;
            ll val = B[shop][ticket];
            field[before][shop] += val;
            field[before][after] -= val;
            field[shop + 1][shop] -= val;
            field[shop + 1][after] += val;
        }
    }
    /*
    cout << endl;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            cout << field[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
    */
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            field[i][j] += field[i][j - 1];
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            field[i][j] += field[i - 1][j];
        }
    }
    ll ans = 0;
    for(int i = 1; i <= N; i++) {
        for(int j = i; j <= N; j++) {
            ll now = field[i][j] - (Point[j] - Point[i]);
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    /*
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            cout << field[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 207744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a*b > c*d) {
    cout << a * b << endl;
  } else if (a*b < c * d) {
    cout << c*d << endl;
  } else {
    cout << a*b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<typename T>
struct edge {
    int to;
    T cost;
    edge(int to, T cost) : to(to), cost(cost){}
};
int main() {
    int N;
    scanf("%d", &N);
    vector<edge<ll> > tree[N];
    rep(i, N-1){
        int a,b,c;
        scanf("%d%d%d", &a, &b, &c);
        a--; b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
    int Q, K;
    scanf("%d%d", &Q, &K);
    K--;
    stack<edge<ll> > s;
    s.push({K, 0});
    ll depth[N];
    rep(i, N) depth[i] = -1;
    while(!s.empty()){
        edge<ll> from = s.top();
        s.pop();
        depth[from.to] = from.cost;
        for(const edge<ll> &to : tree[from.to]){
            if(depth[to.to] == -1) s.push({to.to, to.cost + from.cost});
        }
    }
    rep(i, Q){
        int x, y;
        scanf("%d%d", &x, &y);
        x--, y--;
        printf("%lld\n", depth[x] + depth[y]);
    }
 
    return 0;
}

Measured memory_bytes: 10736
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

#include <chrono>

struct Timer{
    chrono::system_clock::time_point start_t;
    void start(){
        start_t = chrono::system_clock::now();
    }
    double now(){
        chrono::system_clock::time_point now_t = chrono::system_clock::now();
        return chrono::duration_cast<std::chrono::milliseconds>(now_t - start_t).count() / 1000.0;
    }
} timer;

unsigned long xor128(void){
    static unsigned long x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned long t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

ll rand(ll x){
    return xor128() % x;
}
ll rand(ll x, ll y){
    return x + (xor128() % (y - x));
}

int n, m = 26;
VI c;
VVI s;

int calc_score(VI t){
    VI last(m, -1);
    int ret = 0;
    REP(i,n){
        ret += s[i][t[i]];
        last[t[i]] = i;
        REP(j,m) ret -= c[j] * (i - last[j]);
    }
    return ret;
}

void output(VI t){
    REP(i,t.size()) printf("%d\n", t[i] + 1);
}

int main(void){
    cin >> n;
    c.assign(m, 0);
    REP(i,m) c[i] = in();
    s.assign(n, VI(m));
    REP(i,n) REP(j,m) s[i][j] = in();

    VI t(n);
    REP(i,n){
        t[i] = max_element(ALL(s[i])) - s[i].begin();
    }

    int score = calc_score(t);

    REP(_,1000){
        VI tt(t);
        int i = rand(n);
        tt[i] = (tt[i] + rand(m - 1)) % m;
        int score_next = calc_score(tt);
        if (score_next > score){
            t = tt;
            score = score_next;
        }
    }

    output(t);

    return 0;
}


Measured memory_bytes: 3844
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
            
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }     
signed main()
{   jaldi
    int n;
    cin>>n;
    bool x=false;
    int a[n],i,count=0,s=1;
    for(i=0;i<n;i++)
    {   cin>>a[i];
        if(a[i]==1)
        x=true;
    }
    if(!x)
    cout<<-1;
    else
    {   for(i=0;i<n;i++)
        {   if(a[i]==s)
            s++;
            else
            count++;
        }
        cout<<count;
    }
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int N;
int Array[100005];
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> Array[i];
}

void Solve()
{
    int sign = 0, cnt = 1;
    for(int i = 1; i < N; i++)
    {
        if(Array[i] == Array[i + 1])
            continue;
        if(Array[i] > Array[i + 1])
        {
            if(sign == -1)
            {
                ++cnt;
                sign = 0;
            }
            else
                if(sign == 0)
                    sign = 1;
        }
        if(Array[i] < Array[i + 1])
        {
            if(sign == 1)
            {
                ++cnt;
                sign = 0;
            }
            else
                if(sign == 0)
                    sign = -1;
        }
    }
    cout << cnt << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 640
import math
A, B = map(int, input().split())
 
max_val = int(math.ceil(A / 0.07))
min_val = int(math.floor(B / 0.11))
 
for i in range(min_val, max_val + 1):
    if int(i * 0.08) > A or int(i * 0.1) > B:
        break
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(i)
        exit(0)
print(-1)

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

int n_path = 0;
bool done[9] = { false };
bool path[9][9];

void recursion( int pos, int n ) {
    
    bool is_all_done = true;
    
    done[pos] = true;
    
    for ( int i = 1; i <= n; i++ ) {
        if ( !done[i] ) { is_all_done = false; }
    }
    
    if ( is_all_done ) {
        n_path++;
        done[pos] = false;
        return;
    }
    
    for ( int i = 1; i <= n; i++ ) {
        if ( path[pos][i] && !done[i] ) {
            recursion( i, n );
        }
    }
    
    done[pos] = false;
    return;
}


int main() {
    
    int N, M;
    
    cin >> N;
    cin >> M;
    
    for ( int i = 1; i <= N; i++ ) {
    for ( int j = 1; j <= N; j++ ) {
        path[i][j] = false;
    }
    }
    
    for ( int i = 0; i < M; i++ ) {
        int a, b;
        cin >> a;
        cin >> b;
        
        path[a][b] = true;
        path[b][a] = true;
    }
    
    recursion( 1, N );
    
    cout << n_path << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * 3 for i in range(n+1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i][j] + s[i][k], dp[i+1][k])

print(max(dp[n]))


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



signed main() {
int n,m;
cin>>n>>m;
int ans[n][m],s[n],t[m];
for(int i=0;i<n;i++)cin>>s[i];
for(int i=0;i<m;i++)cin>>t[i];
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        ans[i][j]=0;
        if(i!=0)ans[i][j]=(ans[i][j]+ans[i-1][j])%MAX;
        if(j!=0)ans[i][j]=(ans[i][j]+ans[i][j-1])%MAX;
        
        if(s[i]==t[j]){
            ans[i][j]++;
        }else{
            if(i!=0&&j!=0)ans[i][j]=(ans[i][j]+MAX-ans[i-1][j-1])%MAX;
        }
    }
}
cout<<(ans[n-1][m-1]+1)%MAX;


 
   

      return 0;

}


Measured memory_bytes: 31488
N = int(input())
S = [0] * 100
c74, c24, c14, c4, c2 = 0, 0, 0, 0, 0
for i in range(2, N + 1):
    a = i
    for j in range(2, i + 1):
        while a % j == 0:
            a //= j 
            S[j] += 1
            if S[j] == 74:
                c74 += 1
            if S[j] == 24:
                c24 += 1
            if S[j] == 14:
                c14 += 1
            if S[j] == 4:
                c4 += 1
            if S[j] == 2:
                c2 += 1
        if a == 1:
            break
ans = c74 + c24 * (c2 - 1) + c14 * (c4 - 1) + c4 * (c4 - 1) * (c2 - 2)  // 2
print(ans)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2)
    {
        int tmp = 0;
        for (int j = 1; j <= i; j++)
        {
            if (!(i % j))
            {
                tmp++;
            }
        }
        if (tmp == 8)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
/*
ll power(ll m,ll n){
    ll res=1;
    if(n>0){
        res=power(m,n/2);
        cout<<res<<" "<<m<<" "<<n<<endl;
        if(n%2==0)res=(res*res)%INF;
        else res=(((res*res)%INF)*m)%INF;
    }
    return res;
}*/
ll power(ll m,ll n){
    ll res;
    if(n==0)return 1;
    res=power(m*m%INF,n/2);
    //cout<<res<<" "<<m<<" "<<n<<endl;
    if(n%2==1) res=res*m%INF;
    return res;
}
int main(void){
    ll n,m;
    cin>>m>>n;
    cout<<power(m,n)<<endl;
    return 0;
}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin >> s;
	if(s[0] == s[1] && s[1] == s[2]) cout << "Yes\n";
	else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
//
// ABC178 B - Product Max
//

/*
a,b,c,d の絶対値が大きいため、x や yの値を全通り試すとTLE(実行時間超過)の不正解になってしまいます。
ここでは、候補を絞ることで実行時間に間に合うようにする方法を紹介します。
x×yは y を定数としたとき、 x の一次関数になります。
一次関数の性質より、x がある範囲の中を動くとき、
必ず、x が範囲の左端にあるときと右端にあるときの少なくとも一方で x×y は最大になります。
（グラフを書いてみると分かりやすいです。）
これは y がどんな値のときでも成り立つため、x=a のケースと x=bのケースだけ考えれば良いです。
今度は xを定数とすると、同様に、 y=c のケースと y=dのケースだけ考えれば良いことがわかります。
したがって (x,y)が (a,c),(a,d),(b,c),(b,d) のケースだけを考えれば良くなり、
a×c,a×d,b×c,b×dの最大値を出力すれば正解できます。
また、a,b,c,dの絶対値が最大で 109 であるため、答えは最大で 1018 になります。
32 ビット整数型（C++であればint型）に収まらないため、64 ビット整数型（C++であればlong long型）などを使うと良いです。
*/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    // 標準入力から値を受け取る。
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    // x * y の最大値を求める
    // ４パターンのうちの最大→最大値
    long long val_max = 0;
    val_max = max(max(a * c, a * d), max(b * c, b * d));

    // 標準出力に結果を出力する。
    cout << val_max << endl;

    // 戻り値
    return (0);
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N;

int p[55], q[55];

int IS(void) {

	for (int i = 1; i < N; i++) {
		if (q[i] > q[i + 1]) { return -1; }
	}

	return 1;

}

int main(void) {

	cin >> N;

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

	for (int i = 1; i <= N; i++) {
		q[i] = p[i];
	}

	string ans = "NO";

	if (IS() == 1) { ans = "YES"; }
	

	for (int i = 1; i <= N; i++) {
		for (int j = i+1; j <= N; j++) {

			for (int k = 1; k <= N; k++) { q[k] = p[k]; }

			q[i] = p[j]; q[j] = p[i];

			/*cout << endl;
			for (int k = 1; k <= N; k++) {
				cout << "q[" << k << "]= " << q[k] << endl;
			}*/

			if (IS() == 1) { ans = "YES"; }

		}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256