akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define lld long long int 

//-4%3=-1
        lld n,w;
        lld wt[101],val[101],dp[101][100001];
        
lld fun(lld i,lld w)
{
    if(i<=0||w<=0)
    return 0;
    if(dp[i][w]==-1)
    {
        if(wt[i]<=w)
        return dp[i][w]=max(val[i]+fun(i-1,w-wt[i]),fun(i-1,w));
        else
        return dp[i][w]=fun(i-1,w);
    }
    else
    return dp[i][w];
    
}
    


int main() {
	// your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t;
    //cin>>t;
    t=1;
    while(t--)
    {

        cin>>n>>w;
        for(int i=1;i<=n;i++)
        cin>>wt[i]>>val[i];
        memset(dp,-1,sizeof(dp));
        cout<<fun(n,w);
    }
}



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

int main() {
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class B
{
	public static void Main(string[] args)
	{
        string[] inputNK = Console.ReadLine().Split(' ');
        string[] inputL = Console.ReadLine().Split(' ');

        int K = int.Parse(inputNK[1]);

        List<int> L = new List<int>();

        for(int i = 0; i < inputL.Length; i++)
        {
            L.Add( int.Parse(inputL[i]) );
        }

        L.Sort();


        int length = 0;

        for(int i = 0;i < K; i++)
        {
            length += L[L.Count - i - 1];
        }

        Console.WriteLine(length);



	}
}


Measured memory_bytes: 13140
n=int(input())
march="MARCH"
c=[0 for _ in range(5)]
for i in range(n):
    s=str(input())
    for j in range(5):
        if s[0]==march[j]:
            c[j]+=1

ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=c[i]*c[j]*c[k]
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for (int i = 0; i < N; i ++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; i += 2) {
    Alice += a.at(i);
  }
  for (int i = 1; i < N; i += 2) {
    Bob += a.at(i);
  }
  int ans = Alice - Bob;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import collections
s = []
t = []
ans = 0

n = int(input())
for _ in range(n):
    s.append(input())
m = int(input())
for _ in range(m):
    t.append(input())

x = collections.Counter(s)
y = collections.Counter(t)

for i in x:
    t = x[i] - y[i]
    ans = max(t, ans)

print(ans)

Measured memory_bytes: 3316
package main

import (
	"fmt"
	"time"
)

func main() {
	var D string
	fmt.Scan(&D)
	layout := "2006/01/02"
	t, _ := time.Parse(layout, D)
	t1, _ := time.Parse(layout, "2019/05/01")
	diff := t.Sub(t1)
	if diff >= 0 {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}


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

typedef long long ll;
ll a, b, c;

int main() {
	scanf("%lld%lld%lld", &a, &b, &c);
	if((b&1) && (c&1) && (a&1)) {
		if(a > b) swap(a, b);
		if(b > c) swap(b, c);
		if(a > b) swap(a, b);
		printf("%lld\n", b*a);
	}
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiWayIf #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Char
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Ord
import Data.Maybe
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [c] <- getLine
    putStrLn $ if isUpper c then "A" else "a"



Measured memory_bytes: 3760
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long int ll;

int main() {

	/*ll N;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	sort(A.begin(), A.end(), greater<ll>());

	ll ans = 0;
	for (int i = 0; i < A.size(); ++i) {
		ll pr;
		for (int j = 0;; ++j) {
			if ((1ull << j) > A[i]) {
				pr = (1ull << j) - A[i];
				break;
			}
		}

		ll ok = A.size();
		ll ng = i;
		while (ok - ng > 1) {
			ll mid = (ok + ng) / 2;
			if (A[mid] < pr) ok = mid;
			else if (A[mid] > pr) ng = mid;
			else {
				A.erase(A.begin() + mid);
				++ans;
				break;
			}
		}

	}

	cout << ans << endl;*/

	ll N;
	cin >> N;
	vector<ll> A(N);
	map<ll, ll, greater<ll>> um;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		um[A[i]] += 1;
	}

	ll ans = 0;
	for (int i = 0; i < N && !um.empty(); ++i) {
		ll val = um.begin()->first;
		um[val]--;
		if (um[val] == 0) um.erase(val);

		ll pr;
		for (int j = 0;; ++j) {
			if ((1ull << j) > val) {
				pr = (1ull << j) - val;
				break;
			}
		}

		if (um.count(pr)) {
			++ans;
			um[pr]--;
			if (um[pr] == 0) um.erase(pr);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 14336
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())

if a < b:
    b1 = w*t + b
    a1 = v*t + a
    if a1 >= b1:
        flag = 1
    else:
        flag = 0
elif a > b:
    b1 = -w*t + b
    a1 = -v*t + a
    if a1 <= b1:
        flag = 1
    else:
        flag = 0
if flag == 0:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 9204
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val bt: BTree = Empty

  (0 until n).foldLeft[BTree](bt){(t, _) =>
    val op: Array[String] = io.StdIn.readLine().split(" ")
    op match {
      case Array("print") => t.show; t
      case Array("insert", x) => t.insert(x.toInt)
      case Array("find", x) => {
        val key: Int = x.toInt
        println(if (t.find(key)) "yes" else "no")
        t
      }
      case _ => throw new Error("Unknown operation")
    }
  }

  trait BTree {
    def insert(x: Int): BTree
    def preorder: List[Int]
    def inorder: List[Int]
    def show: Unit = {
      println(" " + this.inorder.mkString(" "))
      println(" " + this.preorder.mkString(" "))
    }
    def find(x: Int): Boolean
  }
  object Empty extends BTree {
    def insert(x: Int): BTree = new Node(x, Empty, Empty)
    def preorder: List[Int] = Nil
    def inorder: List[Int] = Nil
    def find(x: Int): Boolean = false
  }
  class Node(v: Int, l: BTree, r: BTree) extends BTree {
    def insert(x: Int): BTree =
      if (x < v) new Node(v, l.insert(x), r)
      else new Node(v, l, r.insert(x))
    def preorder: List[Int] = v :: (l.preorder ::: r.preorder)
    def inorder: List[Int]  = l.inorder ::: (v :: r.inorder)
    def find(x: Int): Boolean =
      if (x == v) true
      else if (x < v) l.find(x)
      else r.find(x)
  }
}


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

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

    if(a==5){
        if((b==5 && c==7) || (b==7 && c==5)){
            cout << "YES\n";
        }
        else{
        cout << "NO\n";
        }   
    }
    else if(a==7){
        if(b==5 && c==5){
            cout << "YES\n";
        }
        else{
        cout << "NO\n";
        }
    }
    else{
        cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ma1 = [1]*n
ma2 = [0]*n
mi2 = [0]*n

if n ==0:
    if a[0]==1:
        print(1)
        exit()
    else:
        print(-1)
        exit()

for i in range(1,n):
    ma1[i]=ma1[i-1]*2-a[i]
    if ma1[i]<0:
        print(-1)
        exit()
if n == 1:
    if a[0]==1:
        print(-1)
        exit()
    if a[0]==0:
        if a[1]==1:
            print(2)
            exit()
        elif a[1]==2:
            print(3)
            exit()
        else:
            print(-1)
            exit()

ma2[n-1]=a[n]
ma2[n-2]=ma2[n-1]
mi2[n-1]=a[n]
mi2[n-2]=mi2[n-1]//2 + mi2[n-1]%2
if n!=2:
    for i in range(2,n):
        ma2[n-1-i]=min(ma2[n-i]+a[n-i+1],2**(n-i)-a[n-i])
        mi2[n-1-i]=(mi2[n-i]+a[n-i+1])//2 + (mi2[n-i]+a[n-i+1])%2
        if mi2[n-1-i]>ma2[n-1-i]:
            print(-1)
            exit()
ma2 = [1]+ma2
ans = 0
for i in range(n):
    ans += min(ma1[i],ma2[i])
ans +=sum(a)

print(ans)


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    freopen ("in.txt", "r", stdin);
#endif
}

void add(ll &dest, const ll val){
    dest += val;
    if (dest>=MOD) dest -= MOD;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
  //  freopen ("in.txt", "r", stdin);
    string s;cin>>s;
    ll dp[2][13];
    for(int i=0;i<13;++i) dp[0][i]=0;
    if (s[0]!='?') dp[0][(s[0]-'0')%13]=1;
    else{
        for(int i=0;i<10;++i) dp[0][i]=1;
    }
    int idx=1;
    for(int i=1;i<s.size();++i){
        memset(dp[idx],0,sizeof(dp[idx]));
        if (s[i]!='?') {
            int y = s[i] - '0';
            for (int j = 0; j < 13; ++j) {
                add(dp[idx][(10 * j + y) % 13],dp[1 - idx][j]);
            }
        }else{
            for(int y=0;y<10;++y) {
                for (int j = 0; j < 13; ++j) {
                    add(dp[idx][(10 * j + y) % 13],dp[1 - idx][j]);
                }
            }
        }
        idx = 1-idx;
    }
    cout << dp[1-idx][5];
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main(){
	ll N;
	cin >> N;
	ll A[N],B[N];
	ll sumA=0,sumB=0;
	for(ll i=0;i<N;i++){
		cin >> A[i];
		sumA += A[i]; 
	}
	for(ll i=0;i<N;i++){
		cin >> B[i];
		sumB += B[i];
	}
	if(sumA<sumB){
		cout << -1 << endl;
		return 0;
	}
	ll sa=0,yoyuu[N];
	for(ll i=0;i<N;i++){
		yoyuu[i] = 0;
	}
	ll count=0;
	for(ll i=0;i<N;i++){
		if(A[i]<B[i]){
			count++;
			sa = sa + B[i]-A[i];
		}else{
			yoyuu[i] = A[i]-B[i];
		}
	}
	sort(yoyuu,yoyuu+N);
	reverse(yoyuu,yoyuu+N);

	ll j=0;
	for(ll i=0;i<N;i++){
		if(sa>0){
			j++;
			sa = sa - yoyuu[i];
		}else{
			break;
		}
	}
	cout << j+count << endl;
}



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

int N;
vector<int> A, B, C;

int main(void) {
	cin >> N;
	A.resize(N);
	B.resize(N);
	C.resize(N);

	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) cin >> C[i];

	sort(A.begin(), A.end());
	sort(C.begin(), C.end());

	long long res = 0;
	for (int i = 0; i < N; i++) {
		long long low = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
		long long up = C.end() - upper_bound(C.begin(), C.end(), B[i]);
		res += low * up;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1408
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
L = [i+1 for i in range(N)]
R = [i+1 for i in range(N)]
A,B = 0,0
for i in range(N-1):
    A *= N-i
    B *= N-i
    A += L.index(P[i])
    B += R.index(Q[i])
    L[L.index(P[i])] = 100
    R[R.index(Q[i])] = 100
    L.sort()
    R.sort()
print(abs(A-B))


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
 
int main() {
 
 
    int N; cin >> N;
    vector<ll> A(N);

    ll sum = 0;
    ll ans = 1e18;
 
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
 
    ll aray = A[0];
    ll snuke = sum - A[0];
 
    for (int i = 1; i < N; i++) {
        ans = min(ans, abs(aray-snuke));
        aray += A[i];
        snuke -= A[i];
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1792
X = int(input())

num = 0
for i in range(1, X + 1):
    if i**2 < X:
        num = i

ans = 1
for i in range(1, num + 1):
    for j in range(2, num + 1):
        x = i**j
        if x > X:
            break

        if ans < x:
            ans = x

print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
int main() {
	long N;
	cin >> N;
	vector<long long>A(N);
	long long ans = 0;
	for (long i = 0; i < N; i++) {
		cin >> A.at(i);
		ans += A.at(i);
	}
	if (ans % 10 != 0) {
		cout << ans << endl;
		return 0;
	}
	sort(A.begin(), A.end());
	for (long i = 0; i < N; i++) {
		if (A.at(i) % 10 != 0) {
			cout << ans - A.at(i) << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    W,a,b = inputMap()
    tmp1 = abs((a+W) - b)
    tmp2 = abs(a-(b+W))
    
    if b <= (a+W) and b >= a:
        print(0)
        sys.exit()
    if b+W <= (a+W) and b+W >= a:
        print(0)
        sys.exit()
    print(min(tmp1,tmp2))
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 39408
#include <stdio.h>

int main(){

  int i, j, n, q, output;
  int S[10000], T[500];
  output = 0;

  scanf("%d", &n);
  for( i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for( i = 0; i < q; i++){
    scanf("%d", &T[i]);
  }

  for( i = 0; i < q; i++){
    for( j = 0; j < n; j++){
      if( S[j] == T[i] ){
        output++;
        j = j + n;
      }
    }
  }

  printf("%d\n", output);

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
//#include <string>
using namespace std;
int main(){
    
    int a;
    cin>>a;
    int in[a];
    int sum=0;
    for(int i=0;i<a;i++){
        cin>>in[i];
        sum++;
    }
    
    for(int j=sum-1;j>=0;j--){
        if(j==0)cout<<in[j]<<endl;
        else cout<<in[j]<<' ';
    }
    
    
    return 0;

}


Measured memory_bytes: 3092
#include <cstdio>

int N, P, C;

int main() {
	scanf("%d%d", &N, &P);
	for (int i = 1, x; i <= N; ++i) scanf("%d", &x), C += x & 1;
	if (!C) printf("%lld\n", P ? 0ll : 1ll << N);
	else printf("%lld\n", 1ll << (N - 1));
	return 0;
}

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

using namespace std;

#define ops cout<<"ops"<<endl;
#define freopens freopen("cowpatibility.in", "r", stdin);freopen("cowpatibility.out", "w", stdout);
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define DIM 3007
#define DIMM 100007
#define INF 1000000000007.0
#define X (ll)(1<<32)
#define eps 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007

const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n;
ll a[DIM],dp[DIM][DIM];

int main()
{
    //ops;
    //freopens;
    fast;
    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

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

    for(int l=1;l<=n;l++){
     for(int s=1;s<=(n-l+1);s++){
      dp[s][l]=max((a[s+l-1]-dp[s][l-1]),(a[s]-dp[s+1][l-1]));
     }
    }
    cout<<dp[1][n]<<endl;
    return 0;
}


Measured memory_bytes: 70016
#include <iostream>
#include <vector>

int main() {
    int n, m; std::cin >> n >> m;
    std::vector<std::pair<bool, bool>> l(n, std::pair<bool, bool>(false, false));
    for (int i = 0; i < m; i++) {
        int a, b; std::cin >> a >> b; a--; b--;
        if (a == 0) {
            l[b].first = true;
        }
        if (b == n-1)
        {
            l[a].second = true;
        }
    }

    for (const auto& ll: l) {
        if (ll.first && ll.second) {
            std::cout << "POSSIBLE" << std::endl;
            return 0;
        }
    }
    std::cout << "IMPOSSIBLE" << std::endl;
    return 0;
}

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

inline int ToDigit(char ch) {
  return static_cast<int>(ch - '0');
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, k;
  string s;
  cin >> n >> k >> s;

  vector<int> nums;
  int now = 1;
  int count = 0;
  rep(i, n) {
    if (ToDigit(s[i]) == now) {
      count++; 
    } else {
      now = 1 - now;
      nums.push_back(count);
      count = 1;
    }
  }
  if (count != 0) nums.push_back(count);
  if (nums.size() % 2 == 0) nums.push_back(0);

  vector<int> sums(nums.size()+1);
  rep(i, nums.size()) {
    sums[i+1] = sums[i] + nums[i];
  }

  const int range = 2 * k + 1;
  int ans = 0;
  for (int i = 0; i < nums.size(); i+=2) {
    int left = i;
    int right = min(i + range, (int)nums.size());
    ans = max(ans, sums[right] - sums[left]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int a[N];
int main()
{
	int n; scanf("%d", &n);
	for (int i = 0, x; i < n; i++) scanf("%d", a+i);
	long long sum = 1000;
	for (int i = 0; i+1 < n; i++) {
		if (a[i] < a[i+1]) sum += (sum/a[i])*(a[i+1]-a[i]);
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 3808
from collections import defaultdict
is_init = True
while True:
  n = int(input())
  if n == 0:
    break
  
  if is_init:
    is_init = False
  else:
    print()

  result = defaultdict(list)
  scores = set()
  for _ in range(n):
    name, w, l, d = input().split()
    score = int(w) * 3 + int(d)
    result[score].append(name)
    scores.add(score)
  
  scores = sorted(list(scores), reverse=True)
  for score in scores:
    for name in result[score]:
      print(name, score, sep=",")


Measured memory_bytes: 5992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class C
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine().Trim());
        int[] p_i = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();

        int answer = 0;
        int minValue = 0;
        for (int i = 0; i < N; i++)
        {
            if (minValue == 0)
            {
                minValue = p_i[i];
                answer++;
                continue;
            }

            if (minValue > p_i[i])
            {
                minValue = p_i[i];
                answer++;
                continue;
            }
        }
        Console.WriteLine(answer.ToString());
    }
}

Measured memory_bytes: 34012
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var [r,c,k] = nexts(3);
  var a = xArray("new Map()",r+1);
  for(var i = 0; i < k; i++){
    var [u,v,w] = nexts(3);
    a[u].set(v,w);
  }
  var dp = xArray(0,c+1,4);
  for(var y = 1; y <= r; y++){
    var dp2 = xArray(0,c+1,4), b;
    for(var x = 1; x <= c; x++){
      dp2[x][0] = Math.max(dp[x][3], dp2[x-1][0]);
      if(b=a[y].get(x))for(var i = 1; i <= 3; i++){
        dp2[x][i] = Math.max(dp[x][3]+b, dp2[x-1][i-1]+b, dp2[x-1][i]);
      }else for(var i = 1; i <= 3; i++){
        dp2[x][i] = Math.max(dp[x][3], dp2[x-1][i]);
      }
    }
    dp = dp2;
  }
  return dp[c][3];
}

Measured memory_bytes: 112396
#include<stdio.h>
#define MAX 10000
#define NIL -1
struct Node{
int p, l, r;
};
struct Node T[MAX];
int n;
void preParse(int u){
if(u == NIL) return;
printf(" %d",u);
preParse(T[u].l);
preParse(T[u].r);
}
void inParse(int u){
if(u == NIL) return;
inParse(T[u].l);
printf(" %d",u);
inParse(T[u].r);
}
void postParse(int u){
if(u == NIL) return;
postParse(T[u].l);
postParse(T[u].r);
printf(" %d",u);
}
int main(){
int i, v, l, r, root;
scanf("%d", &n);
for(i = 0; i < n; i++){
T[i].p = NIL;
}
for(i = 0; i < n; i++){
scanf("%d %d %d", &v, &l, &r);
T[v].l = l;
T[v].r = r;
if(l != NIL) T[l].p = v;
if(r != NIL) T[r].p = v;
}
for(i = 0; i < n; i++) if(T[i].p == NIL) root = i;
printf("Preorder\n");
preParse(root);
printf("\n");
printf("Inorder\n");
inParse(root);
printf("\n");
printf("Postorder\n");
postParse(root);
printf("\n");
return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int N;
long long A[2005];
long long dp[2005][2005];
int main()
{
    cin >> N;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        dp[(i - 1 + N) % N][(i + 1) % N] = A[i];
    }
    for(int len = 2; len <= N; len++) {
        for(int a = 0; a < N; a++) {
            int b = (a + len) % N;
            if(dp[a][b] == -1) continue;
            if(len % 2 == 0) {
                if(A[a] > A[b]) {
                    dp[(a - 1 + N) % N][b] = max(dp[(a - 1 + N) % N][b], dp[a][b]);
                } else {
                    dp[a][(b + 1) % N] = max(dp[a][(b + 1) % N], dp[a][b]);
                }
            } else {
                dp[(a - 1 + N) % N][b] = max(dp[(a - 1 + N) % N][b], dp[a][b] + A[a]);
                dp[a][(b + 1) % N] = max(dp[a][(b + 1) % N], dp[a][b] + A[b]);
            }
        }
    }
    long long maxv = 0;
    for(int i = 0; i < N; i++) {
        maxv = max(maxv, dp[i][(i + 1) % N]);
    }
    cout << maxv << endl;
    return (0);
}



Measured memory_bytes: 34508
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

bool foo(string& s, int& i, int S) {
	char c = s[i];
	i++;
	if (c == 'T') return true;
	if (c == 'F') return false;
	if (c >= 'a' && c <= 'k') return S & (1 << (c - 'a'));
	if (c == '-') return !foo(s, i, S);
	bool x = foo(s, i, S);
	c = s[i];
	i++;
	if (c == '-') i++;
	bool y = foo(s, i, S);
	i++;
	if (c == '*') return x && y;
	if (c == '+') return x || y;
	if (c == '-') return !x || y;
}

int main() {
	for (;;) {
		string s; cin >> s;
		if (s == "#") break;
		int i = s.find('=');
		string s1 = s.substr(0, i), s2 = s.substr(i + 1);
		bool flag = true;
		for (int S = 0; S < (1 << 11); S++) {
			int i1 = 0, i2 = 0;
			bool x1 = foo(s1, i1, S), x2 = foo(s2, i2, S);
			if ((x1 && !x2) || (!x1 && x2)) flag = false;
		}
		cout << (flag ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> to(N + 1, -1);
    vector<int> tmp;
    tmp.assign(2e5 + 1, -1);
    for (int i = N - 1; i >= 0; --i) {
        if (tmp[A[i]] != -1) {
            to[i] = tmp[A[i]];
        }

        tmp[A[i]] = i;
    }

    vector<int> fst(2e5 + 1, -1);
    rep(i, N) {
        if (fst[A[i]] == -1) {
            fst[A[i]] = i;
        }
    }

    vector<int> frontToNextFront(N + 1);
    vector<int> shortcut(N + 1, -1);
    shortcut[N] = N;
    for (int i = N - 1; i >= 0; --i) {
        if (to[i] != -1) {
            shortcut[i] = shortcut[to[i] + 1];
        }
        else {
            shortcut[i] = i;
        }
    }
    for (int i = N - 1; i >= 0; --i) {
        frontToNextFront[i] = shortcut[fst[A[i]] + 1];
    }
    frontToNextFront[N] = shortcut[0];

    int beforeLoop = -1;
    int loopSize = -1;
    tmp.assign(N + 1, -1);
    vector<int> history;
    for (int i = 0, front = N; ; ++i) {
        if (tmp[front] != -1) {
            beforeLoop = tmp[front];
            loopSize = i - tmp[front];

            break;
        }

        history.push_back(front);
        
        tmp[front] = i;
        front = frontToNextFront[front];
    }
    assert(beforeLoop == 0);

    int lastPrev = history[(K - 1) % loopSize];

    vector<int> ans;

    int current = lastPrev == N ? 0 : fst[A[lastPrev]] + 1;

    for (; ; ) {
        while (to[current] != -1) {
            current = to[current] + 1;
        }

        if (current == N) {
            break;
        }

        ans.push_back(A[current]);
        current = current + 1;
    }
    
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << (i == ans.size() - 1 ? "\n" : " ");
    }
}

Measured memory_bytes: 7924
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;


const int N_MAX = 3005;
const int T_MAX = 3005;
const int A_MAX = 3005;
int n, t;
vector<P> Dish;
ll dp[N_MAX][T_MAX+A_MAX];

int main(){
    cin >> n >> t;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        Dish.emplace_back(a, b);
    }
    sort(Dish.begin(), Dish.end());

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < t+A_MAX; j++){
            ll A = Dish[i-1].first, B = Dish[i-1].second;
            if (j-A < t && j-A >= 0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-A]+B);
            else dp[i][j] = dp[i-1][j];
        }
    }
    ll ans = 0;
    for(int i = 1; i <= t+A_MAX; i++){
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 144792
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep1(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define PI acos(-1.0)
#define LONG_LONG_MAX 1LL<<62
#define LONG_LONG_MIN -LONG_LONG_MIN - 1
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

const int maxn = 1e5 + 10;
int s_pos;
string s, t;
vector<int> a[26];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> s;
    cin >> t;
    s_pos = -1;
    bool is_first = true;
    for (int i = 0; i < s.size(); ++i) {
        int id = s[i] - 'a';
        if (is_first && s[i] == t[0]) {
            is_first = false;
            s_pos = i;
        }
        a[id].pb(i);
    }
    ll ans = s_pos+1;
    ll idx = s_pos;
    ll now = 1;
    bool flag = true;
    if (s_pos == -1) {
        cout << -1 << endl;
        return 0;
    }
//    cout << ans << " " << idx << " " << now << '\n';
    while (true) {
        if (now == t.size()) break;
        int id = t[now] - 'a';
        auto ite = upper_bound(a[id].begin(), a[id].end(), idx);
        int nxt;
        if (ite != a[id].end()) nxt = *ite;
        if (ite == a[id].end() && idx == -1) {
            flag = false;
//            cout << "yes" << '\n';
            break;
        } else if (ite == a[id].end()) {
            ans += s.size() - idx - 1;
//            cout << " : " << ans << endl;
            idx = -1;
        } else {
//            cout << "in" << endl;
            ans += nxt - idx;
//            cout << ans << " " << idx << " " << nxt << endl;
            idx = nxt;
            ++now;
        }
    }
    if (flag) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N, A, B;
    cin >> N >> A >> B;
    string s;
    cin >> s;
    int ac=0, acab=0;
    REP(i, s.size()){
        if(s[i] == 'c') puts("No");
        else if(s[i] == 'a'){
            if(ac < A+B){
                puts("Yes");
                ac++;
            }else{
                puts("No");
            }
        }else{
            if(ac < A+B && acab < B){
                puts("Yes");
                ac++;
                acab++;
            }else{
                puts("No");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		System.out.println((a==b&&b!=c || a==c&&b!=c || c==b&&b!=a)? "Yes":"No");
	}
}

Measured memory_bytes: 22612
using System;

namespace A___Task_Scheduling_Problem
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = new int[3];
            for (var i = 0; i < 3; i++)
            {
                a[i] = int.Parse (input[i]);
            }
            Array.Sort (a);
            var ans = 0;
            for (var i = 1; i < 3; i++)
            {
                ans += a[i] - a[i - 1];
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 11220
#include <cstdio>
#include <cstring>
#define MAX_S 100002
using namespace std;

char s[MAX_S];
int sum;

int main() {
  scanf("%s", s);
  int l = 0, r = strlen(s) - 1;
  for(;l < r;) {
    if(s[l] != s[r])  {
      if(s[l] == 'x' || s[r] == 'x') {
        sum++;
	if(s[l] == 'x') l++;
	else r--;
      }
      else {printf("-1\n");return 0;}
    }
    else l++, r--;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

//　非負整数A,Bの最大公約数を返す〈ユークリッドの互除法〉
ll GCD(ll a, ll b) {
	if(a % b == 0){
		return b;
	} else {
		return GCD(b, a % b);
	}
}

// 非負整数A,Bno最小公倍数を返す関数
ll LCM(ll a, ll b) {
	return a * b / GCD(a, b);
}


int main(){
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll R = B - A + 1;
	ll divC = B / C - (A - 1) / C;
	ll divD = B / D - (A - 1) / D;
	ll ans = R - (divC + divD - (B / LCM(C, D) - (A - 1) / LCM(C, D)));
	cout << ans << endl;
}

//532105071133627368 AC
//

Measured memory_bytes: 256
w, a, b = map(int,input().split())
a1,a2 = a, a+w
b1,b2 = b, b+w
c1 = b1 - a2
c2 = a1 - b2
#print(c1, c2)
if c1 < 0 and c2 >= 0:
  print(c2)
elif c2 < 0 and c1 >= 0:
  print(c1)
elif c1 < 0 and c2 < 0:
  print(0)


Measured memory_bytes: 3060
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
-- import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

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

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

mkStartEnd :: Int -> (Int, Int)
mkStartEnd i = (digitToInt $ head s, digitToInt $ last s) where
  s = show i

inverse :: (Int, Int) -> (Int, Int)
inverse (a, b) = (b, a)

solve :: Int -> Int -> (Int, Int, Int)
solve n y = case poss of
    [] -> (-1, -1, -1)
    ts -> head ts
  where
  poss  = do
    man <- [0..n]
    gosen <- [0.. n - man]
    let sen = n - man - gosen
        total = 10000 * man + 5000 * gosen + 1000 * sen
    guard $ total == y
    pure (man, gosen, sen)

main :: IO ()
main =
  readTuple2 >>= putStrLn . (\(a, b, c) -> unwords $ show <$> [a, b, c]) . uncurry solve




Measured memory_bytes: 636
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MOD = 998244353;
ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    int s = 0;
    REP(i, N) {
        cin >> a[i];
        s += a[i];
    }
    vector<vector<ll>> dp1(N + 1, vector<ll>(s + 1, 0));
    auto dp2 = dp1;
    dp1[0][0] = 1, dp2[0][0] = 1;
    REP(i, N) {
        REP(j, s + 1) {
            dp1[i + 1][j] += dp1[i][j] * 2;
            dp1[i + 1][j] %= MOD;
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= MOD;
            if (j - a[i] < 0) {
                continue;
            }
            dp1[i + 1][j] += dp1[i][j - a[i]];
            dp1[i + 1][j] %= MOD;
            dp2[i + 1][j] += dp2[i][j - a[i]];
            dp2[i + 1][j] %= MOD;
        }
    }
    ll res = modpow(3, N);
    REP(j, s + 1) {
        if (2 * j < s) {
            continue;
        }
        res -= dp1[N][j] * 3;
        res %= MOD;
        if (res < 0) {
            res += MOD;
        }
    }
    if (s % 2 == 0) {
        res += dp2[N][s / 2] * 3;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 423104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ara[100005];
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)cin>>ara[i];
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        int val=ara[i]-ara[i-1];
        ans+=min(val*a,b);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long n,num[100005],b[100005],ss;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&num[i],&b[i]);
	}
	for(int i=n;i>0;i--)
	{
		bool p=false;
		if((ss+num[i])%b[i]==0)p=true;
		ss+=b[i]-((ss+num[i])%b[i]);
		if(p)ss-=b[i];
		
	}
	printf("%lld",ss);
}


Measured memory_bytes: 1792
#define FNAME ""

#include <bits/stdc++.h>

#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;

template <class T> T sqr(const T &a) {return a * a;}

const int MAXN = 1e5 + 100;
int a[MAXN];

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

#ifdef LOCAL
    freopen(FNAME".in", "r", stdin);
    freopen(FNAME".out", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    forn(i, n) {
        scanf("%d", &a[i]);
    }
    int cur = 0;
    while (1) {
        LL sum = 0;
        forn(i, n) sum += a[i];

        if (n % 2 != sum % 2) {
            puts(cur == 0 ? "First" : "Second");
            return 0;
        }
        int cnt =0 ;
        forn(i, n) {
            if (a[i] % 2) cnt++;
            if (a[i] == 1) {
                puts(cur == 1 ? "First" : "Second");        
                return 0;
            }
        }
        if (cnt > 1) {
            puts(cur == 1 ? "First" : "Second");        
            return 0;
        }
        if (a[0] % 2) a[0]--;
        int g = a[0];
        forab(i, 1, n) {
            if (a[i] % 2) a[i]--;
            g = __gcd(g, a[i]);
        }
        assert(g > 1);
        forn(i, n) a[i] /= g;
        cur = 1 - cur;
    }
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int l=max(a,c),r=min(b,d);
	int ans=0;
	if(l<=r)
		ans=r-l;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    lint a, b, c;
    cin >> a >> b >> c;

    if(c - a - b < 0LL){
        cout << "No" << endl;
    }else if(4LL * a * b < (c - a - b) * (c - a - b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long ll;

int main() {

    ll n;
    cin>>n;
    string s;
    cin>>s;
    
    ll r = 0, g = 0, b = 0;
    
    for (ll i = 0; i < n; i++) 
        if (s[i] == 'R')
            r++;
        else if (s[i] == 'G')
            g++;
        else b++;
        
    
    ll sum = 1ll * r * g * b;
    
    for (ll len = 1; len <= n; len++){ 
        for (ll i = 0; i <= n - len; i++) {
            ll j = i + len;
            ll k = i + 2 * len;
            if (k > n-1)
                continue;
            if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k])
                sum--;
        }   
    }
    
    cout<<sum<<"\n";
     
   
    return 0;
}

Measured memory_bytes: 3192
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] read = ReadLine().Split(' ');
//        int read_leng = read.Length;
//        int[] readR = new int[mochinum];
        long a = long.Parse(read[0]);
        long b = long.Parse(read[1]);
        long c = long.Parse(read[2]);
//        int d = int.Parse(read[3]);
        long ans=0;
        if(a == 0){
            ans++;
            a++;
        }
        long min = a/c;
        if(a % c > 0){
            min++;
        }
        long max = b/c;
//        WriteLine($"{ans} {max} {min}");
        WriteLine(ans+max-min+1);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif


namespace Solver{
using namespace std;

struct Problem{
    int n,k;
    vector<vector<int>> bb_,ww_;
    Problem(LL n, LL k):n(n),k(k),bb_ (4*k+2,vector<int>(4*k+2)),ww_ (4*k+2,vector<int>(4*k+2)){};

    void solve(){
        int b=0,w=0;
        auto bb = [&](int x, int y) -> auto& {return bb_[x+1][y+1];};
        auto ww = [&](int x, int y) -> auto& {return ww_[x+1][y+1];};
        for(int i=0; i<n; ++i){
            int x,y;
            char c;
            cin >> x >> y >> c;
            x%=(2*k);y%=(2*k);
            if(c=='B'){
                bb(x,y)+=1;
                bb((x+2*k)%(4*k),(y)%(4*k))+=1;
                bb((x)%(4*k),(y+2*k)%(4*k))+=1;
                bb((x+2*k)%(4*k),(y+2*k)%(4*k))+=1;
                b++;
            }else{
                ww(x,y)+=1;
                ww((x+2*k)%(4*k),(y)%(4*k))+=1;
                ww((x)%(4*k),(y+2*k)%(4*k))+=1;
                ww((x+2*k)%(4*k),(y+2*k)%(4*k))+=1;
                w++;
            }
        }
        for(int i=0; i<2*k+2; ++i){
            DBG(bb_[i],ww_[i])
        }
        for(int i=1; i<4*k; ++i){
            for(int j=0; j<4*k; ++j){
                bb(i,j)+=bb(i-1,j);
                ww(i,j)+=ww(i-1,j);
            }
        }
        for(int i=0; i<4*k; ++i){
            for(int j=1; j<4*k; ++j){
                bb(i,j)+=bb(i,j-1);
                ww(i,j)+=ww(i,j-1);
            }
        }
        DBG(n)
        for(int i=0; i<2*k+2; ++i){
            DBG(bb_[i],ww_[i])
        }
        int ans = -INF;
        for(int i=0; i<k; ++i){
            for(int j=0; j<2*k; ++j){
                int cb=bb(i+k-1,j+k-1)-bb(i-1,j+k-1)-bb(i+k-1,j-1)+bb(i-1,j-1);
                cb+=bb(i+2*k-1,j+2*k-1)-bb(i+k-1,j+2*k-1)-bb(i+2*k-1,j+k-1)+bb(i+k-1,j+k-1);
                int cw=ww(i+k-1,j+k-1)-ww(i-1,j+k-1)-ww(i+k-1,j-1)+ww(i-1,j-1);
                cw+=ww(i+2*k-1,j+2*k-1)-ww(i+k-1,j+2*k-1)-ww(i+2*k-1,j+k-1)+ww(i+k-1,j+k-1);
                int tmp = cw+(b-cb);
                DBG(i,j,cb,cw,tmp)
                ans =max(ans,tmp);
            }
        }
        cout << ans <<"\n";
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0,k;
    std::cin >> n >> k;
    Solver::Problem p(n,k);
    p.solve();
    return 0;
}



Measured memory_bytes: 125696