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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  sort(A.rbegin(), A.rend());
  A.push_back(0);

  long long x = 0, y = 0, flag = 0;

  for (int i = 0; i < N; i++) {
    if (!flag && A.at(i) == A.at(i + 1)) {
      x = A.at(i), flag++, i++;
      continue;
    }
    if (flag && A.at(i) == A.at(i + 1)) {
      y = A.at(i);
      break;
    }
  }

  cout << x * y << "\n";
}

Measured memory_bytes: 1024
# B - Papers, Please
def main():
    N, *A = map(int, open(0).read().split())
    is_legal = all(i % 3 == 0 or i % 5 == 0 for i in A if i % 2 == 0)
    print("APPROVED" if is_legal else "DENIED")


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  ll n, k;

  cin >> n >> k;

  if(k >= 2 * n)cout << n << '\n';
  else if(k > n and k < 2*n)cout << min(n, k - n) << '\n';
  else {
    ll d = __gcd(n, k);
    n = n % k;

    if(k >= 2 * n)cout << n << '\n';
    else if(k > n and k < 2*n)cout << min(n, k - n) << '\n';
  }

  return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

struct UnionFind {
	vector<int> elems;
	UnionFind(int n):elems(n){
        init();
	}
    void init(){
        for(size_t i = 0; i < elems.size(); i++){
            elems[i] = -1;
        }
    }
	bool same(int a, int b){
		return parent(a) == parent(b);
	}
	void unite(int a, int b){
        int pa = parent(a), pb = parent(b);
		if(pa == pb){ return; }
		int sum = - (getSum(pa) + getSum(pb));
		elems[pa] = pb;
		elems[pb] = sum;
	}
	int getSum(int a){
        return - elems[parent(a)];
	}
	int parent(int a){
        return elems[a] < 0 ? a : (elems[a] = parent(elems[a]));
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    // vector<int> xs(m), ys(m), zs(m);
    UnionFind uf(n);
    for(int i = 0; i < m; i++){
        // cin >> xs[i] >> ys[i] >> zs[i];
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        uf.unite(x, y);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(uf.parent(i) == i){
            ans++;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1536
unittest
{
	assert( [ "2" ].solve == "b" );
	assert( [ "27" ].solve == "aa" );
	assert( [ "123456789" ].solve == "jjddja" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	n--;
	auto ans = "";
	while( 0 <= n )
	{
		ans ~= cast( char )( 'a' + n % 26 );
		n = n / 26 - 1;
	}
	return ans.retro.array;
}


Measured memory_bytes: 2816
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
hs = [[0]*w for _ in range(h)]
ws = [[0]*w for _ in range(h)]
for y in range(h):
    for x in range(w):
        if s[y][x] == ".":
            if 1<=x<w and ws[y][x-1]:
                ws[y][x] = ws[y][x-1]
                continue
            if x<w and s[y][x]==".":
                for x_ in range(x, w):
                    if s[y][x_] == ".": 
                        ws[y][x] += 1
                    else:
                        break
for x in range(w):
    for y in range(h):
        if s[y][x] == ".":
            if 1<=y<h and hs[y-1][x]:
                hs[y][x] = hs[y-1][x]
                continue
            if y<h and s[y][x]==".":
                for y_ in range(y, h):
                    if s[y_][x] == ".": 
                        hs[y][x] += 1
                    else:
                        break
ans = hs[0][0] + ws[0][0] -1 
for i in range(h):
    for j in range(w):
        ans = max(ans, hs[i][j] + ws[i][j] -1)
print(ans)

Measured memory_bytes: 123480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<ll> A(2005);
map<ll,ll> mp1,mp2;
ll N;
ll dfs(bool f, ll id, ll w, ll z){
    if(id == N){
        return abs(w-z);
    }
    if(mp1.count(id)){
        if(f==0){
            return mp1[id];
        }else{
            return mp2[id];
        }
    }
    ll MM = 0;
    ll mm = 1e18;
    REP(i,id,N){
        ll tmp = dfs(!f,i+1,z,A[i]);
        cmax(MM, tmp);
        cmin(mm, tmp);
    }
    mp1[id] = MM;
    mp2[id] = mm;
    if(f==0){
        return MM;
    }else{
        return mm;
    }
}

int main(){
    ll W,Z;
    cin >> N >> W >> Z;
    rep(i,N){
        cin >> A[i];
    }
    cout << dfs(0,0,W,Z) << endl;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int> 
#define pb emplace_back
#define all(x) (x).begin(), (x).end()
#define deb(x) cout << #x << " - " << x << endl;
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;
using namespace std;

int main(){
    IOS;
  	int n,m; cin>>n>>m;
    ll sum=(n*(n-1))/2+(m*(m-1))/2;
  	cout<<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)

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  
  vector<int> b(m);
  REP(i, m)
    cin >> b.at(i);
  
  int a[n][m];
  REP(i, n) {
    REP(j, m)
      cin >> a[i][j];
  }
  
  int count = 0;
  REP(i, n) {
    int tmp = 0;
    REP(j, m) {
      tmp += a[i][j] * b.at(j);
    }
    if (tmp + c > 0)
      ++count;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if(a + b == c + d)
	{
		printf("Balanced\n");
	}
	else if(a + b < c + d)
	{
		printf("Right\n");
	}
	else
	{
		printf("Left\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;

int main()
{
    
    string a; 
    cin>>a;
    ll c=0, len=a.size(); 
    vector<int> vc(len);
    for (int  i= 0 ; i < len; i++)
    {
        if (a[i]=='B')
        c++;
        vc[i]=c;
    }
    ll ans=0;
    for(int i=len-1; i>0; i--)
    {
        if(a[i]=='W')
        ans+=vc[i];
    }
    cout<<ans<<nl;
}

Measured memory_bytes: 4428
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

bool isPal(string& str, int l, int r){
	if(l > r)
		return false;

	if(l == r)
		return true;

	while(l < r){
		if(str[l] != str[r])
			return false;
		l++;
		r--;
	}

	return true;
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("error.txt", "w", stderr);
// #endif
	crap;

	string str;
	cin>>str;
	int n = str.length();

	int x = (n-1)/2;
	int y = (n+3)/2;

	bool val = isPal(str, 0, n-1) and isPal(str,0,x-1) and isPal(str,y-1,n-1);
	cout << (val ? "Yes": "No") << endl;


	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

int main() {
	string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}


Measured memory_bytes: 3580
n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(n):
    b.extend([a[i], a[i]+1, a[i]-1])

b.sort()
cnt = 1
max_cnt = 0
for i in range(len(b)-1):
    if b[i] == b[i+1]:
        cnt += 1
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 1

print(max_cnt)

Measured memory_bytes: 17576
using System;
using System.Collections.Generic;
using System.Linq;

public class S
{



    public static void Main()
	{
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        var bridge = new long[M,2];
        for(long i = 0; i < M; i++){
            input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            bridge[i,0] = input[0];
            bridge[i,1] = input[1];
        }
        solver(N,M,bridge);
        //solver(6, 5, new long[,]{{2,3},{1,2},{5,6},{3,4},{4,5}});
    }

    public static void solver(long N, long M, long[,] bridge){

        long Useless = (N*(N-1))/2;
        long curX,curY;
        var uf = new UfTree(N);
        var answers = new long[M];

        for(long i = M-1; i >=0; i--){
            answers[i] = Useless;
            curX = bridge[i,0]-1;
            curY = bridge[i,1]-1;
            if(uf.isSameTree(curX, curY)){
                continue;
            }else{
                Useless -= (long)((long)uf.getSize(uf.getRoot(curX)) * (long)uf.getSize(uf.getRoot(curY)));
                uf.unite(curX, curY);
            }   

        }

        foreach(var tgt in answers){
            Console.WriteLine(tgt);
        }


    }

    class UfTree{
        public long[] parents{get;set;}
        public long[] size{get;set;} //sizeはrootのみが最新のものを保持する

        public UfTree(long n){
            parents = new long[n];
			size = new long[n];
            for(long i = 0; i < n; i++){
                parents[i] = i;
                size[i] = 1;
            } 
        }

        public long getRoot(long x){
            if(parents[x] == x){
                return x;
            }else{
                parents[x] = getRoot(parents[x]);
                return parents[x];
            }
        }

        public long unite(long x, long y){
            var rx = getRoot(x);
            var ry = getRoot(y);
            if(rx == ry){
                return rx;
            } else{
                var sx = getSize(rx);
                var sy = getSize(ry);
                if(sx > sy){
                    size[rx] = sx+sy;
                    parents[ry] = rx;
                    return rx;
                }else{
                    size[ry] = sx+sy;
                    parents[rx] = ry;
                    return ry;
                }
            }
            
        }

        public long getSize(long x){
            return size[getRoot(x)];
        }

        

        public bool isSameTree(long x, long y){
            return getRoot(x) == getRoot(y);
        }

    }

}

Measured memory_bytes: 20032
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var st = Console.ReadLine().Split();
        var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (Console.ReadLine() == st[0]) ab[0]--;
        else ab[1]--;

        Console.WriteLine(string.Join(" ", ab));
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 13396
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999

ll N,ans=0,candi=0,h1=0,h2=0;

int main(){
  cin >>N;
  cout << (N*(N-1))/2;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        x: usize,
        n: usize,
    }
    if n == 0 {
        println!("{}", x);
        return;
    }

    input! {
        mut p: [usize; n],
    }
    p.sort();
    for i in 0..101 {
        if x >= i && p.contains(&(x - i)) == false {
            println!("{}", x - i);
            return;
        } else {
            if p.contains(&(x + i)) == false {
                println!("{}", x + i);
                return;
            }
        }
    }
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;


ll gcd(ll a,ll b){
    if(a<b) gcd(b,a);//a>bとなる
    ll r;
    while((r=a%b)){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll N,X;cin>>N>>X;
    vector<ll>x(N);
    REP(i,N) cin>>x[i];
    vector<ll>sub(N);
    REP(i,N) sub[i] = x[i] - X;
    ll ans;
    if (N==1) {
        cout<<abs(sub[0]);
        return 0;
    }
    ans = gcd(sub[0],sub[1]);
    REP(i,N) ans = gcd(ans,sub[i]);
    cout<<abs(ans)<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int i,j,k,l,m,a,b;
	vector< vector<int> > s;
	s.resize(9);
	for (i = 0; i < 9; i++) {
		s[i].resize(101);
	}
	for (i = 0; i < 9; i++) {
		for (j = 0; j < 101; j++) {
			s[i][j] = 0;
		}
	}
	for (i = 0; i < 10; i++) {
		s[0][i] += 1;
		s[8][45 - i] += 1;
	}
	for (i = 0; i < 9; i++) {
		for (j = i + 1; j < 10; j++) {
			s[1][i + j] += 1;
			s[7][45 - i - j] += 1;
		}
	}
	for (i = 0; i < 8; i++) {
		for (j = i + 1; j < 9; j++) {
			for (k = j + 1; k < 10; k++) {
				s[2][i + j + k] += 1;
				s[6][45 - i - j - k] += 1;
			}
		}
	}
	for (i = 0; i < 7; i++) {
		for (j = i + 1; j < 8; j++) {
			for (k = j + 1; k < 9; k++) {
				for (l = k + 1; l < 10; l++) {
					s[3][i + j + k + l] += 1;
					s[5][45 - i - j - k - l] += 1;
				}
			}
		}
	}
	for (i = 0; i < 6; i++) {
		for (j = i + 1; j < 7; j++) {
			for (k = j + 1; k < 8; k++) {
				for (l = k + 1; l < 9; l++) {
					for (m = l + 1; m < 10; m++) {
						s[4][i + j + k + l + m] += 1;
					}
				}
			}
		}
	}
	while (cin >> a >> b) {
		if (a == 0 && b == 0)break;
		cout << s[a - 1][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n, k;
  while(cin >> n >> k){
    if(n == 0 && k == 0)break;
    int res = 0;
    rep(i, (1 << 10)){
      int num = 0;
      int sum = 0;
      rep(j, 10){
        if((i >> j) % 2 == 1){
          num++;
          sum += j;
        }
      }
      if(num == n && sum == k)res++;
    }
    cout << res << endl;
  }
	return 0;
}



Measured memory_bytes: 3080
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}



fn main() {
    input! {
        n: usize,
        p: [i32; n],
    }
    let mut res = 0;
    for i in 1..n-1 {
        if p[i-1] < p[i] && p[i] < p[i+1] {
            res = res + 1;
        }
        if p[i-1] > p[i] && p[i] > p[i+1] {
            res = res + 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long lint;
int main(){
    int n;
    lint baum[2*100000+1];
    baum[0]=0;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        lint val;
        scanf("%lld",&val);
        baum[i]=baum[i+n]=val;
    }
    lint ans=0;
    for(int i=1;i<=2*n;i++){
        baum[i]+=baum[i-1];
    }

    for(int i=1;i<=n;i++){
        int lb=i-1,ub=i+n-1;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            lint val=baum[mid]-baum[i-1];
            int pos=lower_bound(baum+mid+1,baum+i+n,baum[mid]+val)-baum;
            if(pos==i+n||baum[i+n-1]-baum[pos]<val)ub=mid;
            else lb=mid;
        }
        ans=max(ans,baum[lb]-baum[i-1]);
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

string i2s(int x)
{
    string s = to_string(x);
    while (s.size() != 4) {
        s = '0' + s;
    }
    return s;
}

int x[10][10];

int get_num(const string& s)
{
    int r = 0;
    for (int i = 0; i < 5; i++) {
        int c = s[i] - '0';
        r = x[r][c];
    }
    return r;
}

bool error(string& s)
{
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j <= 9; j++) {
            int v = s[i] - '0';
            if (v == j) continue;
            s[i] = (j + '0');
            if (get_num(s) == 0) {
                return 1;
            }
            s[i] = (v + '0');
        }
    }
    
    for (int i = 0; i < 4; i++) {
        if (s[i] == s[i + 1]) continue;
        swap(s[i], s[i + 1]);
        if (get_num(s) == 0) {
            return 1;
        }
        swap(s[i], s[i + 1]);
    }        
    return 0;
}

int main()
{
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> x[i][j];
        }
    }
    
    int cnt = 0;
    for (int i = 0; i <= 9999; i++) {
        auto s = i2s(i);
        int r = 0;
        for (int j = 0; j < 4; j++) {
            int c = s[j] - '0';
            r = x[r][c];
        }              
        s += (r + '0');
        cnt += error(s);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
int main(void   ){
    int n;
    cin>>n;
    int ans=1;
    while(ans<=n){
        ans*=2;
    }
    cout<<ans/2<<endl;
    return 0;
}


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

#define N 11

using namespace std;

bool parse(string x, bool vars[N]) {
    int nest = 0;
    switch (x[0]) {
        case 'T':
            return true;
        case 'F':
            return false;
        case '-':
            return !parse(x.substr(1), vars);
        case '(':
            break;
        default:
            return vars[x[0]-'a'];
    }
    x = x.substr(1, x.length()-2);
    for (int i=0; i<(int)x.length(); i++) {
        if (x[i] == '(') {
            nest++;
            continue;
        }
        if (x[i] == ')') {
            nest--;
            continue;
        }
        if (nest > 0) {
            continue;
        }
        if (x[i] == '+') {
            return parse(x.substr(0, i), vars) || parse(x.substr(i+1), vars);
        }
        if (x[i] == '*') {
            return parse(x.substr(0, i), vars) && parse(x.substr(i+1), vars);
        }
        if (x.substr(i, 2) == "->") {
            return (!parse(x.substr(0, i), vars)) || parse(x.substr(i+2), vars);
        }
    }
    while (true) {
        cout << "tsu_ra_i" << endl;
    }
}

bool is_equal(string x, string y) {
    bool vars[N];
    for (int i=0; i<(1<<N); i++) {
        for (int j=0; j<N; j++) {
            vars[j] = i&(1<<j);
        }
        if (parse(x, vars) != parse(y, vars)) {
            return false;
        }
    }
    return true;
}

int main() {
    string line, x, y;
    while (true) {
        cin >> line;
        if (line == "#") {
            return 0;
        }
        for (int i=0; i<(int)line.length(); i++) {
            if (line[i] == '=') {
                x = line.substr(0, i);
                y = line.substr(i+1);
                break;
            }
        }
        if (is_equal(x, y)) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
}

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

using namespace std;

typedef long long ll;
const int Nmax = 1e5 + 5, Mod = 1e9 + 7;

int coef, n, i, sum[Nmax], a[Nmax];
ll ans = 0;

int power(int a, int b)
{
    int ans = 1;
    while(b)
    {
        if(b&1) ans = (ll) ans * a % Mod;
        a = (ll) a * a % Mod; b >>= 1;
    }
    return ans;
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

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

    for(i=1; i<=n; ++i)
    {
        sum[i] = sum[i-1] + power(i, Mod-2);
        if(sum[i] >= Mod) sum[i] -= Mod;
    }

    for(i=1; i<=n; ++i)
    {
        coef = sum[i] + sum[n-i+1] - 1;
        ans += (ll) coef * a[i];
        ans %= Mod;
    }

    for(i=1; i<=n; ++i) ans *= i, ans %= Mod;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
# Q2
S=str(input())
#print(S)

K='keyence'
#print(len('keyence'))
ans=0

'''
print('first=',S[0:6])
print('last=',S[len(S)-7:])
if S[0:7]==K:
    ans=1
if S[len(S)-7:]==K:
    ans=1
'''

for i in range(7+1):
#    print(S[0:i]+S[len(S)-7+i:])
    if S[0:i]+S[len(S)-7+i:]==K:
        ans=1

        
if ans==1:    
    print('YES')
else:
    print('NO')


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

int main() {
  int N; cin >>N;
  vector<double> x(N);
  vector<string> u(N);
  for(int i = 0; i < N; ++i){
    cin >> x[i] >> u[i];
  }
  double ans = 0;
  for(int i = 0; i < N; ++i){
    if(u[i] == "BTC"){
      x[i] *= 380000.0;
      ans += x[i];
    } else {
      ans += x[i];
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(void){
	int A,B,MAX;
	scanf("%d %d",&A,&B);
	if(A + B > A - B) MAX = A + B; else MAX = A - B;
	if(MAX < A * B) MAX = A * B;
	printf("%d\n",MAX);
	return 0;
}

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

#define MOD (1000000007)

typedef long long Int;

using namespace std;

Int cum[41][100001];
Int seg[1 << 18];

Int lcm(Int x, Int y)
{
	return (x / __gcd(x, y) * y);
}

void update(int k, int x)
{
	k += (1 << 17) - 1;
	seg[k] = x;
	while (k){
		k = (k - 1) / 2;
		seg[k] = lcm(seg[k * 2 + 1], seg[k * 2 + 2]);
	}
}

Int getLCM(int a, int b, int k = 0, int l = 0, int r = 1 << 17)
{
	if (b <= l || r <= a) return (1);
	if (a <= l && r <= b) return (seg[k]);

	Int lch = getLCM(a, b, k * 2 + 1, l, (l + r) / 2),
		rch = getLCM(a, b, k * 2 + 2, (l + r) / 2, r);

	return (lcm(lch, rch));
}

int main()
{
	int N, Q;
	int P[100001];

	scanf("%d %d", &N, &Q);

	for (int i = 1; i <= N; i++){
		scanf("%d", P + i);
	}

	for (int i = 0; i < 1 << 18; i++) seg[i] = 1;

	bool vis[100001];
	memset(vis, 0, sizeof(vis));
	for (int i = 1; i <= N; i++){
		vector<int> keep;
		int x = i;
		int sum = 0;
		while (!vis[x]){
			keep.push_back(x);
			vis[x] = true;
			sum += x;
			x = P[x];
		}
		for (int j = 0; j < keep.size(); j++){
			cum[keep.size()][keep[j]] = sum;
			update(keep[j], keep.size());
		}
	}

	for (int i = 1; i <= 40; i++){
		for (int j = 1; j <= N; j++){
			cum[i][j] += cum[i][j - 1];
		}
	}

	for (int i = 0; i < Q; i++){
		int l, r;
		scanf("%d %d", &l, &r);
		Int ct = getLCM(l, r + 1);
		Int ret = 0;
		for (int j = 1; j <= 40; j++){
			Int tmp = (cum[j][r] - cum[j][l - 1]) % MOD;
			tmp = (tmp * ((ct / j) % MOD)) % MOD;
			ret = (ret + tmp) % MOD;
		}
		printf("%lld\n", ret);
	}

	return (0);
}

Measured memory_bytes: 35784
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RDR.ARR;
	A.sort();

	writeln(A[$-1] - A[0]);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
l_list = list(map(int, input().split()))
l_combo = itertools.combinations(l_list, 3)
ans = 0
for i in l_combo:
    if i[0] + i[1] > i[2] and i[1]+i[2] > i[0] and i[0] + i[2] > i[1] and i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
        ans += 1

print(ans)


Measured memory_bytes: 27268
type dice = {
  one : int ;
  two : int ;
  three : int ;
  four : int ;
  five : int ;
  six : int };;

let roll dir dice  =
  match dir with
    "W" -> {dice with one = dice.three;
                      three = dice.six;
                      six = dice.four;
                      four = dice.one}
  | "E" -> {dice with one = dice.four;
                      four = dice.six;
                      six = dice.three;
                      three = dice.one}
  | "S" -> {dice with one = dice.five;
                      two = dice.one;
                      six = dice.two;
                      five = dice.six}
  | "N" -> {dice with one = dice.two;
                      two = dice.six;
                      six = dice.five;
                      five = dice.one}
  | _ -> dice ;;

let spin dir dice = match dir with
    "L" -> {dice with two = dice.three;
                      three = dice.five;
                      five = dice.four;
                      four = dice.two}
  | "R" -> {dice with two = dice.four;
                      four = dice.five;
                      five = dice.three;
                      three = dice.two}
  | _ -> dice ;;

 
let top_is_eq_to m dice =
  let w = roll "W" dice in
  let e = roll "E" dice in
  let n = roll "N" dice in
  let s = roll "S" dice in
  if m = dice.one then dice
  else if m = w.one then w
  else if m = e.one then e
  else if m = n.one then n
  else if m = s.one then s
  else roll "W" w ;;

let front_is_eq_to m dice =
  let l = spin "L" dice in
  let r = spin "R" dice in
  if m = dice.two then dice
  else if m = l.two then l
  else if m = r.two then r
  else spin "L" l ;;

let () =
  let as_ = Array.init 6 (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let dice = {one = as_.(0); two = as_.(1); three = as_.(2); four = as_.(3); five = as_.(4); six = as_.(5)} in
  let n = Scanf.scanf "%d\n" (fun a -> a) in
  let rec loop i = 
    if i = 0 then ()
    else let top, front = Scanf.scanf "%d %d\n" (fun a b -> a, b) in
         ((top_is_eq_to top dice) |> front_is_eq_to front).three |> Printf.printf "%d\n";
         loop (i-1)
  in
  loop n ;;



Measured memory_bytes: 2332
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(int *a, int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]


int main (void)
{
	int n,i,a[210000]={0},max=1,k=0;
  char s[420000][12];
  a[0]=1;
	
	scanf("%d", &n);
	for(i=0; i<n;i++){
		scanf("%s", s[i]);
}
  qsort(s,n,sizeof(s[0]),cmp_s);
  //strcpy(c[0],s[0]);
  for(i=1;i<n;i++){
  if(strcmp(s[i],s[i-1])==0){
  a[k]++;
    
  }
    else{
      k++;
      a[k]++;
      //strcpy(c[k],s[i]);
    }
  }
  max=a[0];
  for(i=0;i<=k;i++){
  if(a[i]>max){
  max=a[i];
  }
  }
  for(i=0;i<n;i++){
  if(strcmp(s[i],s[i+max-1])==0){
  printf("%s\n",s[i]);
  }
  }
  
return 0;
}


Measured memory_bytes: 7040
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		while(scan.hasNext()){
			int n = scan.nextInt();
			int cnt = 0;
			boolean isPrime = true;
			if(n <= 1){
				System.out.printf("%d\n", cnt);
			} else if(n == 2){
				cnt++;
				System.out.printf("%d\n", cnt);
			} else if(n == 3){
				cnt += 2;
				System.out.printf("%d\n", cnt);
			} else{
				cnt++;
				for(int i = 3; i <= n; i += 2){
					for(int j = 3; j <= Math.sqrt(i); j += 2){
						if(i % j == 0){
							isPrime = false;
							break;
						}
					}
					if(isPrime){
						cnt++;
					} else{
						isPrime = true;
					}
				}
				System.out.printf("%d\n", cnt);

			}
		}
	}
}

Measured memory_bytes: 27176
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); 
        long x = sc.nextLong();
        boolean ok = true;
        for(long i = -1000; i <= 1000 && ok; ++i) {
            for(long j = -1000; j <= 1000 && ok; ++j){
                if(i * i * i * i * i - j * j * j * j * j == x){
                    System.out.println(i + " " + j);
                    ok = false;
                }
            }
        }
    }    
}

Measured memory_bytes: 27228
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int PrimeNum(int x){
	int i,cnt=0;
	
	if(x>1){
		if(x==2)return 1;
		if(x<2 || x%2==0) return 0;
		
		i=3;
		
		while( i<=sqrt(x) ){
			if(x%i==0)return 0;
			i +=2;
		}
		
	}
	return 1;
	
}
int 
main(){
	int x[10000],n,i,cnt=0;	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
		cnt += PrimeNum(x[i]);
	}
	
	printf("%d\n",cnt);
 return 0;
}


Measured memory_bytes: 2060
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)


func main() {
	scanner := bufio.NewScanner(os.Stdin)

	inputs := strToInts(scanLine(scanner))
	d, n := inputs[0], inputs[1]

	if n == 100 {
		n++
	}

	result := int64(math.Pow(100.0, float64(d))) * int64(n)
	fmt.Print(result)
}

func scanLine(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func strToInts(line string) []int {
	strSlice := strings.Split(line, " ")

	var intSlice []int
	for _, str := range strSlice {
		intValue, _ := strconv.Atoi(str)
		intSlice = append(intSlice, intValue)
	}

	return intSlice
}

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

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    int N = S.size();
    vector<char> s(N);
    for (int i=0; i<N; i++) {
        s[i] = S[i];
    }
    if (N<=K) {
        cout << S << endl;
        exit(0);
    }
    else {
        for (int i=0; i<K; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
    int n ;
    cin >> n ;
    int x = n/500 ;
    //cout << x ;
    n -= (x*500) ;
    x *= 1000 ;
    n/=5 ;
    x += (n*5) ;
    cout << x ;
}

int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


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

int n, k, mod, C[333][333], f[333][333], g[333][333];

template<class T1,class T2> void U(T1 &x,T2 y){
	x=(x+y)%mod;
}

int main(){
	cin>>n>>k>>mod;
	for (int i=0;i<=n;++i){
		C[i][0]=1;
		for (int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for (int i=0;i<=k;++i){
		f[1][i]=1;
		g[1][i]=i+1;
	}
	for (int i=2;i<=n+1;++i){
		for (int j=0;j<=k;++j){
			for (int i1=1;i1<i;++i1){
				int i2=i-i1;
				if (j) U(f[i][j],(ll)C[i-2][i1-1]*f[i1][j]%mod*g[i2][j-1]);
			}
			g[i][j]=f[i][j];
			if (j) U(g[i][j],g[i][j-1]);
		}
	}
	cout<<f[n+1][k]<<endl;
}

Measured memory_bytes: 1408
n = int(input())
b = [int(i) for i in input().split()] 

a = [0 for _ in range(n)]

for i in range(n):
    if i == 0:
        a[0] = b[0]
    elif i == n-1:
        a[n-1] = b[n-2]
    else:
        a[i] = min(b[i-1],b[i])
print(sum(a))

Measured memory_bytes: 3064
#include<stdio.h>

typedef struct Card{
  char mark;
  int number;
} card;

int main(){
  int num,i,j,min,flag,check=0;
  card CA_1[36],CA_2[36],CA_3[36],tmp;
  scanf("%d",&num);
  for(i=0;i<num;i++)scanf(" %c%d",&CA_1[i].mark,&CA_1[i].number);
  for(i=0;i<num;i++)CA_2[i]=CA_1[i];

  /*BubbleSort*/
  flag=1;
  while(flag){
    flag=0;
    for(j=num-1;j>=1;j--){
      if(CA_1[j].number<CA_1[j-1].number){
        tmp=CA_1[j];
        CA_1[j]=CA_1[j-1];
        CA_1[j-1]=tmp;
        flag=1;
      }
    }
  }

  /*BubblePrint*/
  for(i=0;i<num-1;i++)printf("%c%d ",CA_1[i].mark,CA_1[i].number);
  printf("%c%d\n",CA_1[i].mark,CA_1[i].number);
  puts("Stable");

  /*SelectionSort*/
  for(i=0;i<num-1;i++){
    min=i;
    for(j=i;j<num;j++){
      if(CA_2[j].number<CA_2[min].number){
        min=j;
      }
    }
    if(CA_2[i].number!=CA_2[min].number){
      tmp=CA_2[i];
      CA_2[i]=CA_2[min];
      CA_2[min]=tmp;
    }
  }

  /*SelectionPrint*/
  for(i=0;i<num-1;i++)printf("%c%d ",CA_2[i].mark,CA_2[i].number);
  printf("%c%d\n",CA_2[i].mark,CA_2[i].number);
  for(i=0;i<=num-1;i++){
    if(CA_2[i].number==CA_1[i].number&&CA_2[i].mark!=CA_1[i].mark){
      check=1;
    }
  }
  if(check==1)puts("Not stable");
  else puts("Stable");
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;
#define div 1000000007

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int prime[1001];

//素因数分解
void prime_factorization(int n){
    int a = 2, res;
    
    while(n >= a * a){
        if(n % a == 0){
            res = a;
            //resをグローバルな配列に代入すれば記録できる。
            prime[res]++;
            n /= a;
        }else{
            a++;
        }
    }
    //ラス1の素因数
    res = n;
    prime[res]++;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    rep(i, n + 1)   prime[i] = 1;
    //printArray(prime, n + 1);
    FOR_RE(i, n, 0){
        prime_factorization(i);
    }
    //cout << no << endl;
    //prime_factorization(no);
    //printArray(prime, n + 1);
    
    ll res = 1;
    FOR_EQ(i, 2, n){
        res *= prime[i];
        res %= div;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
from math import atan, degrees

a, b, x = map(int, (input().split()))
s = x / a

if s == a * b / 2:
    print(degrees(atan(b/a)))
elif s > a * b / 2:
    print(degrees(atan(2 * (a * b - s) / (a**2))))
else:
    print(degrees(atan(b**2 / (2 * s))))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
bool greate(pair<string ,int> &a,pair<string ,int> &b)
{
	if(a.first!=b.first)
	{
		return a.first<b.first;
	}
	else
	return b.second<a.second;
}

int main()
{FAST
int n,k;
cin>>n;
string s;
vector<pair<string ,int> >v,x;
FOR(i,n)
{  cin>>s>>k;
  v.pb(mp(s,k))	;
  x.pb(mp(s,k))	;
}

sort(x.begin(),x.end(),greate);

FOR(j,n)
{  
   FOR(i,n)
 {  
 if(v[i].first==x[j].first&&v[i].second==x[j].second)
 {
 	cout<<i+1<<endl;
 	break;
 }
 
 }
}


}






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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        v[a]++;
    }

    int ret = 1;
    const int mod = 1000000007;
    if (N % 2 == 0) {
        for (int i = 1; i <= N; i += 2) {
            if (v[i] != 2) ret = 0;
        }
    } else {
        for (int i = 2; i <= N - 1; i += 2) {
            if (v[i] != 2) ret = 0;
        }
        if (v[0] != 1) ret = 0;
    }
    for (int i = 0; i < N / 2; i++)
        ret = ret * 2 % mod;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int x;
    cin >> x;
    for (int i = 1; ; i++) {
        x -= i;
        if (x <= 0) {
            cout << i << endl;
            return 0;
        }
    }
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string word;
  char W;
  int length, acgt, A;
  A = 0;
  
  cin >> word;
  length = word.size();
  
  for(int i = 0;i < length;i++){
    for(int j = 0;j < length - i;j++){
    W = word.at(i + j);
      if(W == 'A' || W == 'C' || W == 'G' || W == 'T'){
      acgt++;
      }
      else{
      break;
      }
    }
    
    if(A < acgt){
    A = acgt;
    }
    acgt = 0;
  }
  
  cout << A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 3005;

int n,t,dp[N][N];
pii a[N];

int rec(int i,int t)
{
    if(i == n)return 0;
    if(t<=0)return 0;
    if(dp[i][t]!=-1)return dp[i][t];
    dp[i][t] = max(rec(i+1,t),a[i].ss+rec(i+1,t-a[i].ff));
    return dp[i][t];
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        memset(dp,-1,sizeof(dp));
        cin>>n>>t;
        for(int i=0;i<n;i++)cin>>a[i].ff>>a[i].ss;
        sort(a,a+n);
        cout<<rec(0,t)<<endl;
    }
    return 0;
}


Measured memory_bytes: 71040
import itertools

N = int(input())
P = tuple(list(map(int,input().split())))
Q = tuple(list(map(int,input().split())))

p = set(P)
a = 0
b = 0
n = itertools.permutations(p)
ln = []
for v in n:
   ln.append(v)
if P == Q:
  print(0)
else:
  for i in range(0,len(ln)):
    if ln[i] == P:
      a = i+1
    elif ln[i] == Q:
      b = i+1
  print(abs(a-b))

Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j;

int main(){
   ll N;
   cin>>N;
   V h(N);
   rep(i,N)cin>>h[i];
   V cost(N);
   rep(i,N){
      if(i==0)cost[i]=0;
      else if(i==1)cost[i]=abs(h[i]-h[i-1]);
      else{
         cost[i]=min(abs(h[i]-h[i-1])+cost[i-1],abs(h[i]-h[i-2])+cost[i-2]);
      }
   }
   cout<<cost[N-1]<<endl;
}


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

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    V a(n); rep(i,n) cin >> a[i];
    set<int> s; rep(i,n) s.insert(a[i]);
    if (s.size() == n)
    {
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 10368