akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    pair = [0, 0]
    dic = defaultdict(int)

    for a in A:
        if dic[a]:
            pair.append(a)
            dic[a] = 0
        else:
            dic[a] = 1

    pair.sort()
    print(pair[-1] * pair[-2])


if __name__ == '__main__':
    main()


Measured memory_bytes: 64536
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e7 + 10;
int a[N], b[N];
int main()
{
	int n,ma = -1,t,ans = 0; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		ma = max(ma, a[i]);
	}
	for (int i = 0; i < n; i++)
	{
		t = a[i];
		for (; t <= ma; t += a[i])
		{
			b[t] ++;
		}
	}
	for (int i = 0; i < n ;i++)
	{
		if (b[a[i]] == 1)
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int A, B, H, M;
    cin >> A >> B >> H >> M;


    double t = (60 * H + M) * 2 * PI;

    cout << fixed << setprecision(10) << sqrt(A * A + B * B - 2 * A * B * cos(t / (12 * 60) - t / 60)) << endl;
}


Measured memory_bytes: 4244
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <assert.h>
#define ll long long
#define ull unsigned long long
using namespace std;

vector<ll> V;
vector<vector<ll>> DP;
vector<ll> P;

ll getSum(int start, int end){
    return P[end + 1] - P[start];
}

ll solve(int start, int end){
    ll& dp= DP[start][end];
    
    if (dp != -1){
        return dp;
    }
    
    int length = end - start + 1;
    if (length == 1){
        return dp = 0;
    }
    if (length == 2){
        return (dp = (V[start] + V[end]));
    }

    ll ans = INT64_MAX;
    for (int i = start; i < end; i++){
        ll tmp = solve(start, i) + solve(i + 1, end);
        ans = min(tmp, ans);
    }
    return dp = ans + getSum(start, end);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    V = vector<ll>(n);
    DP = vector<vector<ll>>(n, vector<ll>(n, -1));
    P = vector<ll>(n + 1);
    for (auto &v : V) cin >> v;

    for (int i = 1; i <= n; i++){
        P[i] = P[i - 1] + V[i -1];
    }

    ll ans = solve(0, n - 1);

    // for (auto a : DP){
    //     cout << endl;
    //     for  (auto x : a){
    //         cout << x << " ";
    //     }
    // }

    // cout << endl << endl;

    cout << ans;
    return 0;
}

Measured memory_bytes: 1536
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 256
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())

DA=T1*A1+T2*A2
DB=T1*B1+T2*B2
dA=T1*A1
dB=T1*B1
F=abs(DA-DB)
f=abs(dA-dB)
if F==0:
	print("infinity")
elif DA>DB:
	if dA>dB:
		print(0)
	else:
		if f%F==0:
			print((int(f//F))*2)
		else:
			print((int(f//F))*2+1)
else:
	if dA<dB:
		print(0)
	else:
		if f%F==0:
			print((int(f//F))*2)
		else:
			print((int(f//F))*2+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>

using namespace std;

#pragma GCC oprimize("Ofast")
#define rep(i,a,b) for(__typeof(b)i=a;i<b;++i)
#define fs first
#define sc second
#define pb emplace_back

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
typedef pair<ll,ll> pl;

ll n,w;
ll mem[110][100010];

vector<pl> l;

ll dp(ll at, ll cw)
{
    if(cw >= w || at == n)return 0;
    if(mem[at][cw]!=-1)return mem[at][cw];
    ll ans = 0;
    if(l[at].fs + cw <= w)ans = max(ans,l[at].sc + dp(at+1,l[at].fs+cw));
    ans = max(ans,dp(at+1,cw));
    return mem[at][cw] = ans;
}


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

    memset(mem,-1,sizeof(mem));

	cin >> n >> w;
	l.resize(n);
	rep(i,0,n)
	{
		cin >> l[i].fs >> l[i].sc;
	}
	cout << dp(0,0);
	return 0;
}


Measured memory_bytes: 86272
N = int(input())
S = []
for _ in range(N):
    S.append(input())

M = int(input())
T = []
for _ in range(M):
    T.append(input())
    
word = set(S+T)

value = [0]
for w in word:
    value.append(S.count(w)-T.count(w))
    
print(max(value))

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
   long long int n, t, m[200000], i, s=0, a;

   scanf("%lld%lld",&n,&t);
   for(i=0;i<n;i++)
      scanf("%lld",&m[i]);

   for(i=0;i<n;i++){
      a=0;
      while((m[i+a]+t>=m[i+a+1])&&(i+a<n-1))
         a++;
      s+=t+(m[i+a]-m[i]);
      i+=a;
   }

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

Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n;
    while( cin >> n, n ) {
        int a;
        int cnt = 0;
        bool flg = true;
        for( int i = 0; i < n; ++i ) {
            cin >> a;
            if( a && a != 1 ) {
                flg = false;

            }
            if( a ) ++cnt;

        }
        if( flg ) cout << "NA";
        else cout << cnt + 1;
        cout << endl;

    }
    return 0;
}



Measured memory_bytes: 3140
n = int(input())
h = [int(i) for i in input().split()]
temp = 0
ans = 0
for i in range(n-1):
	if h[i] >= h[i+1]:
		temp += 1
		if temp > ans:
			ans = temp
		else:
			continue
	else:
		temp = 0
print(str(ans))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(100000);
    for(int i=1; i<=102; i++)
    {
        for(int j=1; j<=102; j++)
        {
            for(int k=1; k<=102; k++)
            {
                
                A.at(i*i+j*j+k*k+i*j+j*k+k*i)++;
            }
        }
    }
    for(int i=1; i<=N; i++)
    {
        cout << A.at(i) << endl;
    }
}

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

int main(int argc, const char * argv[]) {
    int N = 0;
    int value = 0;
    int averagePoint = 0;
    int resultValue = 0;
    int resultValue2 = 0;
    int resultValue3 = 0;
    list<int> list = {};
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> value;
        averagePoint = averagePoint + value;
        list.push_front(value);
    }
    list.sort();
    
    if (averagePoint % N == 0) {
        averagePoint = averagePoint / N;
        for (int i = 0; i < N ; i++) {
            value = list.front();
            list.pop_front();
            resultValue = resultValue + ((value - averagePoint) * (value - averagePoint));
        }
        cout << resultValue;
    }else{
        averagePoint = averagePoint / N;
        int averagePoint2 = averagePoint + 1;
        int averagePoint3 = averagePoint - 1;
        for (int i = 0; i < N ; i++) {
            value = list.front();
            list.pop_front();
            resultValue = resultValue + ((value - averagePoint) * (value - averagePoint));
            resultValue2 = resultValue2 + ((value - averagePoint2) * (value - averagePoint2));
            resultValue3 = resultValue3 + ((value - averagePoint3) * (value - averagePoint3));
        }
        if (resultValue > resultValue2) {
            if (resultValue2 > resultValue3) {
                cout << resultValue3;
            }else{
                cout << resultValue2;
            }
        }else{
            if (resultValue > resultValue3) {
                cout << resultValue3;
            }else{
                cout << resultValue;
            }
        }
    }

    return 0;
}



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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ull = unsigned long long;
template<typename T> void Out(T x) { cout << x << endl; }

ull nC2(ull a) {
  return (a)*(a-1)/2;
}

ull nC3(ull a) {
  return (a)*(a-1)*(a-2)/6;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ull n, nr = 0, ng = 0, nb = 0; string s;
  cin >> n >> s;
  ull choose3 = n * (n-1) * (n-2) / 6;
  rep(i,n) {
    if (s[i] == 'R') nr++;
    if (s[i] == 'G') ng++;
    if (s[i] == 'B') nb++;
  }

  ull res = choose3 - nC3(nr) - nC3(ng) - nC3(nb);
  // cout << "res " << res << endl;
  res =  res - nC2(nr)*(ng + nb) - nC2(ng)*(nr + nb) - nC2(nb)*(ng + nr);
  // cout << "choose2 R: " << nC2(nr) << endl;
  // cout << "choose2 G: " << nC2(ng) << endl;
  // cout << "choose2 B: " << nC2(nb) << endl;
  for (int len = 1; len <= n; len++) {
    for (int i = 0; i + 2*len < n; i++) {
      if (s[i] == s[i + len] || s[i + len] == s[i + 2*len] || s[i] == s[i + 2*len]) {
        continue;
      }
      else res--;
    }
  }
  cout << res << endl;

}


Measured memory_bytes: 3660
#!/usr/bin/env python3
#AGC2 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,l = LI()
a = LI()
tmp = 0
inde = 0
for i in range(1,n):
  if tmp < a[i] + a[i-1]:
    tmp = a[i]+a[i-1]
    inde = i
if tmp < l:
  print('Impossible')
  quit()
print('Possible')
for i in range(1,inde):
  print(i)
for i in range(inde+1,n)[::-1]:
  print(i)
print(inde)


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

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

Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			int n = scanner.nextInt();
			Map<Dimesion, Integer> map = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				IntStream.rangeClosed(0, 2).filter(j -> (a - j > 0) && (a - j <= h - 2)).forEach(
						j -> IntStream.rangeClosed(0, 2).filter(k -> (b - k > 0) && (b - k <= w - 2)).forEach(k -> {
							Dimesion key = new Dimesion(a - j, b - k);
							map.put(key, map.getOrDefault(key, 0) + 1);
						}));
			});
			long[] results = new long[10];
			map.values().forEach(value -> results[value]++);
			results[0] = (h - 2L) * (w - 2L) - map.size();
			Arrays.stream(results).forEach(System.out::println);
		}
	}

	/**
	 * Mapのキーとなるクラス
	 */
	private static class Dimesion {
		int x;
		int y;

		Dimesion(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Dimesion other = (Dimesion) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}
	}
}


Measured memory_bytes: 206024
#include<stdio.h>
int main(void)
{
	int n,k,d[10001],a,b,i,j;
	scanf("%d %d", &n, &k);
	for(i=0; i<k; i++)
	scanf("%d", &d[i]);
	for(i=n; i<100000; i++)
	{
		a=i;
		while(a>0)
		{
			b=0;
			for(j=0; j<k; j++)
			{
				if(a%10==d[j])
				break;
				if(j==k-1)
				b=1;
			}
			if(b==0)
			break;
			a/=10;
		}
		if(a==0)
		break;
	}
	printf("%d\n", i);
	
	return 0;
}

Measured memory_bytes: 128
// @snippet<sh19910711/contest:headers.cpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

// @snippet<sh19910711/contest:solution/interface.cpp>
namespace solution {
    class ISolution {
    public:
        virtual void init() {};
        virtual bool input() { return false; };
        virtual void output() {};
        virtual int run() = 0;
    };
}

// @snippet<sh19910711/contest:solution/solution.cpp>
namespace solution {
    using namespace std;
    const int SIZE = 501;
    int n;
    int A[SIZE];
    class Solution: public ISolution {
    public:
        bool input() {
            if ( ! ( cin >> n ) )
                return false;
            for ( int i = 0; i < n; ++ i )
                cin >> A[i];
            return true;
        }
        void solve() {
            int D[4];
            fill( D, D+4, 0 );
            sort( A, A+n, greater<int>() );
            long long res = 0;
            for ( int i = 0; i < n; ++ i ) {
                int di = i % 4;
                if ( A[i] <= D[di] )
                    continue;
                res += max( 0, A[i] - D[di] );
                D[di] ++;
            }
            cout << res + 1 << endl;
        }
        int run() {
            while ( init(), input() ) {
                solve();
                output();
            }
            return 0;
        }
    };
}


// @snippet<sh19910711/contest:main.cpp>

int main() {
    return solution::Solution().run();
}

Measured memory_bytes: 1180
//#include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
// using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, Q;
  cin >> N >> Q;
  ll tate = N;
  ll yoko = N;
  ll black = (N - 2) * (N - 2);
  vl a(N + 1, N);
  vl b(N + 1, N);
  ll H = N, W = N;
  REP(i, Q) {
    ll t, x;
    cin >> t >> x;
    if (t == 1) {
      if (x < W) {
        FOR(i, x, W) b[i] = H;
        W = x;
      }
      black -= b[x] - 2;
    } else {
      if (x < H) {
        FOR(i, x, H) a[i] = W;
        H = x;
      }
      black -= a[x] - 2;
    }
  }
  cout << black << endl;

  return 0;
}


Measured memory_bytes: 6348
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>

#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int,int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;



signed main(){
ll n , m ;
    cin >> n >> m ;
    ll t =  ( (n * ( n- 1 ) )/ 2   );
    ll t2 =  ( (m * ( m- 1 ) )/ 2   );
    cout << t + t2 ;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <set>
#include <queue>
#define N 100010
using namespace std;
int n,m,d[N];
int ne=0,h[N];struct edge{int to,w,x;}e[400010];
inline void ins(int s,int t,int w) {
	e[++ne].to=t;e[ne].w=w;e[ne].x=h[s];h[s]=ne;
}
struct stat {
	int n,d;
	stat(){}
	stat(int a,int b){n=a;d=b;}
	inline bool operator>(const stat& a) const {
		return d!=a.d?d>a.d:n<a.n;
	}
};
set<int> vis[N];
inline int dij(int s,int t) {
	priority_queue<stat,vector<stat>,greater<stat> > q;
	stat u;int v,oo,nd;
	memset(d,33,sizeof(d));oo=*d;
	d[s]=0;q.push(stat(s,0));
	while(!q.empty()) {
		u=q.top();q.pop();
		if(u.d>d[u.n]) continue;
		for(int i=h[u.n];i;i=e[i].x) {
			v=e[i].to;nd=u.d+(vis[u.n].count(e[i].w)?0:1);
			if(nd<d[v]) {
				d[v]=nd;q.push(stat(v,nd));
				vis[v].clear();
			}
			if(nd==d[v]) vis[v].insert(e[i].w);
		}
	}
	return oo==d[t]?-1:d[t];
}
int main() {
	int a,b,c;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;++i) {
		scanf("%d%d%d",&a,&b,&c);
		ins(a,b,c);ins(b,a,c);
	}
	printf("%d",dij(1,n));
	return 0;
}

Measured memory_bytes: 20216
n = int(input())
res = []
for i in range(n):
  s,p = input().split()
  p = 100-int(p)
  l = []
  l.append(s)
  l.append(p)
  l.append(i+1)
  res.append(l)
res = sorted(res,key=lambda res:(res[0],res[1]))
for i in range(n):
  print(res[i][2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	bool b = true;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] == S[i - 1]) {
			b = false;
			break;
		}
	}

	cout << (b ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 3608
n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]
ps.sort(key=lambda x: x[0])

correct, penalty = 0, 0
last_c, is_solved = 1, False
tmp_pen = 0
for ps_i in ps:
  p, s = ps_i
  if (p != last_c):
    tmp_pen = 0
    is_solved = False
    last_c = p
    if (is_solved):
      continue
    elif (s == "WA"):
      tmp_pen += 1
    else:
      correct += 1
      penalty += tmp_pen
      is_solved = True
  else:
    if (is_solved):
      continue
    elif (s == "WA"):
      tmp_pen += 1
    else:
      correct += 1
      penalty += tmp_pen
      is_solved = True
print(correct, penalty)
    

Measured memory_bytes: 27564
#include<stdio.h>

int main()
{
	int zeronum=0,onenum=0,twonum=0;
	int n,now,num,before,i=0;
	scanf("%d",&n);
	num=n;
	while(n)
	{
		scanf("%d",&now);
		if(now%4==0)
		{
			twonum++;
		}
		else if(now%2==0)
		{
			onenum++;
		}
		else
		{
			zeronum++;
		}
		n--;
	}
	for(i=0;i<num;i++)
	{
		if(i==0||before==2)
		{
			if(zeronum!=0)
			{
				zeronum--;
				before=0;
			}
			else if(onenum!=0)
			{
				onenum--;
				before=1;
			}
			else
			{
				twonum--;
				before=2;
			}
			continue;
		}
		else if(before==1)
		{
			if(onenum!=0)
			{
				onenum--;
				before=1;
			}
			else if(twonum!=0)
			{
				twonum--;
				before=2;
			}
			else
			{
				break;
			}
			continue;
		}
		else
		{
			if(twonum!=0)
			{
				twonum--;
				before=2;
			}
			else
			{
				break;
			}
			continue;
		}
	}
	if(num==i)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _010_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            int oddCnt = 0;
            for(int i = 0; i < n; i++)
            {
                if (array[i] % 2 == 1) oddCnt++;
            }
            Console.WriteLine(oddCnt % 2 == 0 ? "YES" : "NO");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 18400
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  string s, t; cin >> s >> t;
  int n = s.size();
  int cnt = 0;
  loop(i,0,n) {
    cnt += s[i]!=t[i];
  }
  cout << cnt << endl;
  return 0;
}


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

  
int main(){
string str;
  cin>>str;
  int sum=0;
  
  for(int i=0;i<str.size();i++){
    if(str.at(i)=='+'){
    sum++;
    }else{
      sum--;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


int prime[10101010];
ll li[10101010];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	ll N;
	cin >> N;
	for (int i = 0; i < 10101010; i++) {
		prime[i] = 1;
		li[i] = 1;
	}

	prime[0] = prime[1] = 0;
	prime[2] = 1;
	for (int i = 2; i < 10101010; i++) {
		if (prime[i] == 1) {
			for (int j = 2 * i; j < 10101010; j+=i) {
				prime[j] = 0;
			}
			for (int j = i; j < 10101010; j += i) {
				int tmp = j;
				ll cnt = 0;
				while (tmp > 0) {
					if (tmp % i == 0) {
						tmp /= i;
						cnt++;
					}
					else break;
				}
				li[j] *= (cnt + 1LL);
			}
		}
	}

	ll ans = 0;
	for (ll i = 1; i <= N; i++) {
		ans += li[i] * i;
	}
	puts(ans);


	return 0;
}

Measured memory_bytes: 121988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
	int n;
	cin>>n;
	double t,a;
	cin>>t>>a;
	vi vec(n);
	REP(i,n){
		cin>>vec[i];
	}
	vector<double> d(n);
	REP(i,n){
		d[i]=abs(t-0.006*vec[i]-a);
	}
	cout<<distance(d.begin(),min_element(all(d)))+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+10;
ll a[N];
ll ans,sum;int n;
struct xxj{
	ll p[100];
	void built(){
    	for(int i=1;i<=n;i++)
    	for(int j=60;j>=0;j--){
        	if((a[i]>>j)&1){
            	if(p[j]==0){p[j]=a[i];break;}
     	    	else a[i]^=p[j];
        	}
    	}
	}
	void cl(){
		for(int i=60;i>=0;i--){
			if(ans+(ans^sum)<(ans^p[i])+(ans^p[i]^sum))ans^=p[i];
		}
	}	
}T;
int main()
{
	scanf("%d",&n);sum=0;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),sum^=a[i];
	for(int i=0;i<60;i++){
		if((sum>>i)&1){
			for(int j=1;j<=n;j++){
				if((a[j]>>i)&1)a[j]^=(1ll<<i);
			}
		}
	}
	T.built();
	T.cl();
	cout<<ans+(sum^ans)<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n, q;
    string s;

    cin >> n >> q >> s;

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

    dp[0] = 0;

    for (int i = 1; i < n; i++)
    {
        dp[i] = dp[i-1];

        if (s[i-1] == 'A' && s[i] == 'C')
            dp[i]++;
    }

    for (int i = 0; i < q; i++)
    {
        int l, r;

        cin >> l >> r;
        l--; r--;

        cout << dp[r] - dp[l] << "\n";
    }

    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int R, C, N; cin >> R >> C >> N;
  stack<int>st;
  vector<vector<pii>>v(4);
  auto f=[&](int x,int y){
    return (x==0 or x==R) or (y==0 or y==C);
  };
  rep(i,0,N){
    int a, b, c, d; cin >> a >> b >> c >> d;
    if(f(a,b)and f(c,d)){
      if(a==0)v[0].emplace_back(b,i);
      else if(b==C)v[1].emplace_back(a,i);
      else if(a==R)v[2].emplace_back(b,i);
      else v[3].emplace_back(a,i);

      if(c==0)v[0].emplace_back(d,i);
      else if(d==C)v[1].emplace_back(c,i);
      else if(c==R)v[2].emplace_back(d,i);
      else v[3].emplace_back(c,i);
    }
  }
  rep(i,0,4)sort(all(v[i]));
  reverse(all(v[2]));
  reverse(all(v[3]));

  rep(i,1,4)v[0].insert(v[0].end(),all(v[i]));

  rep(i,0,v[0].size()){
    if(st.empty())st.push(v[0][i].se);
    else if(st.top()==v[0][i].se)st.pop();
    else st.push(v[0][i].se);
  }

  YES(st.empty());



    return 0;
}


Measured memory_bytes: 4028
// AOJ CGL_3_C Polygon-Point Containment
// 2018.5.3 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } SEG, LINE;

#define INF			1e8
#define EPS			1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)
#define PPeQ(a,b)	(EQ(a.x,b.x)&&EQ(a.y,b.y))

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
PP vmul(PP p1, PP p2) { PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return hypot(p1.x-p2.x, p1.y-p2.y); };
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

// 点が多角形に含まれているかの判定　2:含まれる, 1:辺上にある, 0:含まれない
int containsPolyP(int n, PP *poly, PP p)
{
	int i, f;
	PP a, b, t;
	double c;		// cross(a,b)

	f = 0;
	for (i = 0; i < n; i++) {
		a = vsub(poly[i], p), b = vsub(poly[i+1], p);
		if (EQ((c=cross(a, b)), 0) && dot(a, b) < EPS) return 1;
		if (!EQ(a.y, b.y) && a.y >= b.y) t = a, a = b, b = t, c = -c;
		if (a.y < EPS && EPS < b.y && c > EPS) f = !f;
	}
	return f? 2: 0;
}

PP pp[110];

int main()
{
	int n, q, i;
	PP p;

	n = in();
	for (i = 0; i < n; i++) pp[i].x = in(), pp[i].y = in();
	pp[n] = pp[0];
	q = in();
	while (q--) {
		p.x = in(), p.y = in();
		putchar('0'+ containsPolyP(n, pp, p)), putchar('\n');
	}
	return 0;
}



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

int main(){
    int h, w;
    cin >> h >> w;

    int a[h][3];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < 3; j++){
            a[i][j] = w;
        }
    }

    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        for(int j = 0; j < s.length(); j++){
            if(s[j] == 'W') a[i][0]--;
            if(s[j] == 'B') a[i][1]--;
            if(s[j] == 'R') a[i][2]--;
        }
    }

    int ans = 3000;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= h; j++){
            if(i + j >= h)  continue;
            int k = h-i-j;
            int tmp = 0;
            for(int x = 0; x < i; x++)      tmp += a[x][0];
            for(int x = i; x < i+j; x++)    tmp += a[x][1];
            for(int x = i+j; x < h; x++)    tmp += a[x][2];
            ans = min(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll now = INF, ans, n;
ll q;
int main() {
	cin >> n;
	cin >> q;
	vector<ll> s(n);
	REP(i, n) {
		cin >> s[i];
	}
	s.push_back(INF);
	sort(ALL(s));
	
	REP(i, q) {
		ll a, b;
		cin >> a >> b;
		b++;
		ll i1 = lower_bound(ALL(s), a) - s.begin();
		ll i2 = lower_bound(ALL(s), b) - s.begin();
		cout << i2 - i1 << endl;
	}
}




Measured memory_bytes: 4380
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

// 最小公約数
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}*/

ll n;
ll cnt = 0;

void dfs(ll x) {
	// 今の数字の後ろに3,5,7を加える
	if (x > n) return;
	string s = to_string(x);
	int m = s.size();
	bool used[3] = {};
	rep(i, m) {
		if (s[i] == '3') used[0] = true;
		if (s[i] == '5') used[1] = true;
		if (s[i] == '7') used[2] = true;
	}
	if (used[0] && used[1] && used[2]) cnt++;
	dfs(x * 10 + 3);
	dfs(x * 10 + 5);
	dfs(x * 10 + 7);
}

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

	cin >> n;

	dfs(0);

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<int> v(200000);
	int N, K;
	cin >> N >> K;
	for(int i = 0; i <= 200000; i++) v[i] = 0;
	for(int i = 0; i < N; i++) {
		int t;
		cin >> t;
		v[t]++;
	}
	sort(v.rbegin(), v.rend());
	int ans = 0;
	for(int i = 0; i < K; i++) {
		ans += v[i];
	}
	ans = N - ans;
	cout << ans << endl;
	return 0;
}

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

int main()
{
	char in[100];
	int i;
	
	scanf("%s",in);
	
	
	for(i = 0;in[i];i++)
	in[i] = 'x';
	
	printf("%s\n",in);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N,A,B,C,D,E;
    cin>>N>>A>>B>>C>>D>>E;
    long long  turns,cap;
    cap=min(A,B);
    cap=min(cap,C);
    cap=min(cap,D);
    cap=min(cap,E);
    if(N%cap==0) turns=N/cap;
    else turns=N/cap+1;
    //cout<<turns<<endl;
    cout<<5+turns-1<<endl;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
c=0
p1,p2=p[0],p[1]
for i in range(2,n):
  p3=p[i]
  if (p1<p2<p3 or p1>p2>p3):
    c+=1
  p1=p2
  p2=p3
print(c)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include<set>
#include<map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	
	vector<char> c(N);
	int r_cnt = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> c[i];
		if (c[i] == 'R') ++r_cnt;
	}

	int r=0;
	for (int i = 0; i < r_cnt; ++i)
	{
		if (c[i] == 'R') ++r;
	}

	cout << r_cnt - r << endl;

}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

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

    int* a = new int[n];
    rep(i, n) {
        cin >> a[i];
    }
    int* b = new int[n];
    rep(i, n) {
        cin >> b[i];
    }
    sort(b, b + n);
    int* c = new int[n];
    rep(i, n) {
        cin >> c[i];
    }
    sort(c, c + n);

    int* num = new int[n];
    rep(i, n) {
        num[i] = c + n - upper_bound(c, c + n, b[i]);
    }

    ll* sum = new ll[n + 1];
    sum[n] = 0;
    for(int i = n - 1; i >= 0; i--) {
        sum[i] = sum[i + 1] + num[i];
    }

    ll ans = 0;
    rep(i, n) {
        ans += sum[upper_bound(b, b + n, a[i]) - b];
    }
    cout << ans << endl;
    
    delete[] a;
    delete[] b;
    delete[] c;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 1e5 + 1;

bool is_checked[MAX_N];
int color[MAX_N];
vector<P> graph[MAX_N];

void dfs(int node, int c) {
    color[node] = c;
    is_checked[node] = true;
    for (int i = 0; i < graph[node].size(); i++) {
        if (is_checked[graph[node][i].first]) continue;
        if (graph[node][i].second % 2) dfs(graph[node][i].first, c ^ 1);
        else dfs(graph[node][i].first, c);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int u, v, w;
    for (int i = 0; i < N - 1; i++) {
        cin >> u >> v >> w;
        u--, v--;
        graph[u].push_back(P(v, w));
        graph[v].push_back(P(u, w));
    }
    dfs(0, 0);
    for (int i = 0; i < N; i++) cout << color[i] << endl;
    return 0;
}

Measured memory_bytes: 8448
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num;
        int i = 1;
        
        while (true) {
            num = sc.nextInt();
            if(num == 0) {
                break;
            }
            System.out.println("Case " + i + ": " + num);

            i++;
        }
    }
}


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

int main(){
    int N;
    cin >> N;
    //cout << "N:" << N << endl;
    int c;
    int count = 0;
    for(c=N-1;c>0;c--){
        //cout << "for" << endl;
        int j = 1;
        int yakusu = 0;
        while(j*j<=N-c){
            //cout << "while" << endl;
            if((N-c)%j == 0){
                yakusu++;
                if((N-c)/j != j){
                    yakusu++;
                }
            }
            j++;
        }
        count += yakusu;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x=3;
	int a[3];
	int i;
	for(i=0;i<3;i++)
	cin>>a[i];
	sort(a,a+3);
	for(i=1;i<3;i++){
		if(a[i]==a[i-1])
		x--;
	}
	
	cout<<x<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
scs = [tuple(map(int, input().split())) for _ in range(M)]

if N == 1:
    L, R = 0, 9
elif N == 2:
    L, R = 10, 99
else:
    L, R = 100, 999

for x in range(L, R+1):
    strX = str(x)
    for s, c in scs:
        if strX[s-1] != str(c):
            break
    else:
        print(x)
        break
else:
    print(-1)


Measured memory_bytes: 9064
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int tmp;
	scanf("%d %d %d", &a, &b,&c);

	if (a > b){ tmp = a; a = b; b = tmp; }
	if (b > c){ tmp = b; b = c; c = tmp; }
	if (a > b){ tmp = a; a = b; b = tmp; }
	
	printf("%d %d %d\n", a, b,c);

	return 0;
}

Measured memory_bytes: 596
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>
#include <tuple>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b){
	if(a<b){
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b){
	if(a>b){
		a = b;
		return true;
	}
	return false;
}
template<typename T>
std::vector<T> vec(int len, T elem) {return std::vector<T>(len, elem);}
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i] <<std:: endl;
		else std::cout << da[i] << ' ';
	}
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int n,m;

int li[50][50];

void bfs(vector<vector<int>> &da, Pii now, bitset<50> &out){
	queue<Pii> q;
	vector<int> used(n,-1);
	q.push(mapa(now.first,-1));
	while(!q.empty()){
		int look = q.front().first;
		q.pop();
		rip(i,da[look].size(),0){
			if(used[da[look][i]] == -1){
				used[da[look][i]] = look;
				q.push(mapa(da[look][i], look));
			}
		}
	}
	int me = now.second;
	while(me != now.first){
		out[li[me][used[me]]] = 1;
		me = used[me];
	}
	return;
}

int main(){
	cin >> n;
	vector<vector<int>> da(n,vector<int>(0));
	rip(i,n-1,0){
		int a,b; cin >> a >> b;
		a--;b--;
		da[a].push_back(b);
		da[b].push_back(a);
		li[a][b] = i;
		li[b][a] = i;
	}
	cin >> m;
	vector<Pii> query(m);
	rip(i,m,0) cin >> query[i].first >> query[i].second;
	rip(i,m,0){
		query[i].first--;query[i].second--;
	}
	vector<bitset<50>> mul(m);
	rip(i,m,0) bfs(da, query[i], mul[i]);
	vector<bitset<50>> dp(1 << m);
	vector<ll> cnt(1 << m);
	vector<ll> power(n+1);
	ll ans = 0;
	//rip(i,m,0) cout << mul[i] << endl;
	rip(i, 1 << m ,1){
		int ok = 1;
		int co = 0;
		rip(j,m,0){
			if(i&ok){
				co ++;
				dp[i] |= mul[j];
			}
			ok <<= 1;
		}
		//if(co==0) dp[i].flip();
		cnt[i] = (ll)1 << dp[i].count();
		cnt[i]--;
		cnt[i] *= (ll)1 << (n-1-dp[i].count());
		///cout << cnt[i] << endl;
		if(co%2){
			ans += cnt[i];
		}
		else{
			ans -= cnt[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 16640
from collections import deque
import sys

n = int(input())
deq = deque([])

for i in range(n):
    cmd = sys.stdin.readline().strip().split()
    if cmd[0] == "deleteFirst":
        deq.popleft()
    elif cmd[0] == "deleteLast":
        deq.pop()
    else:
        x = int(cmd[1])
        if cmd[0] == "insert":
            deq.appendleft(x)
        elif cmd[0] == "delete":
            if x not in deq: continue
            deq.remove(x)
print(*deq)



Measured memory_bytes: 46056