akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;



int main()
{
	long long l, r;
	cin >> l >> r;
	if (l%2019 == 0 || r%2019 == 0 || r-l+1>=2019)
	{
		cout << 0 << endl;
		exit(0);
	}
	l %= 2019;
	r %= 2019;
	int ans = 2019;
	for (int i = l; i <= r; i++)
		for (int j = i + 1; j <= r; j++)
			ans = min(ans, i*j % 2019);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
sentence = list(a)
word = list(b)

def ref(a, b, flag):
    if a != b:
        flag = False
    return flag

result = 0

for i in range(len(sentence)):
    flag = True
    k = 0
    while flag == True:
        if k < len(word):
            if i+k < len(sentence):
                flag = ref(sentence[i+k], word[k], flag)
            else:
                flag = ref(sentence[i+k-len(sentence)], word[k], flag)
            k += 1
        else:
            result = 1
            break

if result == 1:
    print("Yes")
else:
    print('No')


Measured memory_bytes: 5568
#include <stdio.h>

int main(){
	int n,i,f;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&f);
		a[f-1]=i+1;
	}
	for(i=0;i<n;i++){
		printf("%d ",a[i]);
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    string s,t; cin>>s>>t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

b = [0] * 41
for a in A:
    for k in range(41):
        if a & (1 << k):
            b[k] += 1

x = 0
for k in range(40, -1, -1):
    if x + (1 << k) > K:
        continue
    if b[k] < (N + 1) // 2:
        x += (1 << k)

ans = 0
for a in A:
    ans += x ^ a
print(ans)


Measured memory_bytes: 14248
#include<bits/stdc++.h>
using namespace std;
const int N=100007;
long long A[N],W[N];
int main(){
  int n,w;
  cin>>n>>w;
  long long dp[n+1][w+1];
  for(int i=0;i<n;++i)
    cin>>W[i]>>A[i];
  for(int i=0;i<=n;++i){
    for(int j=0;j<=w;++j){
      if(i==0||j==0)
        dp[i][j]=0;
      else if(j>=W[i-1])
        dp[i][j]=max(dp[i-1][j],A[i-1]+dp[i-1][j-W[i-1]]);
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  cout<<dp[n][w];
}


Measured memory_bytes: 79104
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int x; readV(x);

  auto m = 1;
  foreach (b; 2..x.nsqrt+1)
    foreach (p; 2..10) {
      auto c = b^^p;
      if (c > x) break;
      m = max(m, c);
    }

  writeln(m);
}

pure T nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.range, core.bitop;
  if (n <= 1) return n;
  T m = T(1) << (n.bsr/2+1);
  return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}


Measured memory_bytes: 256
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it  
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//x = xDegrees*3.14159265 / 180;
//ef1tn=(( (n / 2)*( (n / 2) + 1) / 2) * 2);
//of1tn=(n * (n + 1) / 2 - 2 * ((n / 2) * (n / 2 + 1) / 2));
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int n, k;
vector<int>arr;
int dp[100005];
int sol(int idx){
	if (idx == n - 1)
		return 0;
	int &ret = dp[idx];
	if (~ret)
		return ret;
	ret = oo;
	for (int i = 1; i <= min(k, n - idx - 1); i++){
		ret = min(ret, sol(idx + i) + abs(arr[idx] - arr[idx + i]));
	}
	return ret;
}
int main(){
	K_K();
	cin >> n >> k;
	arr.resize(n);
	clr(dp, -1);
	for (auto &it : arr)
		cin >> it;
	cout << sol(0);
}

Measured memory_bytes: 5760
class Restrant
   attr_accessor :num, :name, :score
end

n = gets.to_i
rests = []

for i in 0..n-1 do
  rest = Restrant.new
  m = gets.chomp.split(" ")
  rest.num = (i+1).to_s
  rest.name = m[0].to_s
  rest.score = m[1].to_i
  rests.push(rest)
end

rests.sort! do |a, b|
  (a.name <=> b.name).nonzero? ||
    (b.score <=> a.score)
end
nums = rests.map { |b| b.num.to_i }

nums.each do |i|
  puts i
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b){swap(a,b);}
    if(b<c){swap(b,c);}
    if(a<b){swap(a,b);}
    cout<<c<<" "<<b<<" "<<a<<endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    priority_queue<int> q;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        a[i]=x;
        q.push(x);
    }
    int l=q.top();
    q.pop();
    int s=q.top();
    for(int i=0;i<n;i++)
    {
        if(a[i]!=l)
            cout<<l<<endl;
        else
            cout<<s<<endl;

    }
    return 0;
}


Measured memory_bytes: 3316
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int ans=0;
    for(auto ch:s)if(ch=='1') ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 3572
#include <cstdio>

int main()
{
	int N, last, cur;
	scanf("%d %d", &N, &last);

	int ans = 0;
	int step = 0;

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

		if (cur <= last)
		{
			++step;
		}
		else
		{
			if (ans < step)
			{
				ans = step;
			}
			step = 0;
		}
		last = cur;
	}
	if (ans < step)
	{
		ans = step;
	}
	printf("%d\n", ans);
}


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

using namespace std;

const int N = 303;
double dp[N][N][N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n, a, x = 0, y = 0, z = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 3) {
      x++;
    } else if (a == 2) {
      y++;
    } else {
      z++;
    }
  }

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        double e = n * 1.0;
        if (i > 0) e += i * dp[i - 1][j + 1][k];
        if (j > 0) e += j * dp[i][j - 1][k + 1];
        if (k > 0) e += k * dp[i][j][k - 1];
        if (i + j + k > 0) dp[i][j][k] = e / (i + j + k);
      }
    }
  }
  cout << fixed << setprecision(10) << dp[x][y][z] << '\n';
  return 0;
}

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

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

	lglg a, b; cin >> a >> b;
	lglg gcd = __gcd(a, b);

	lglg result = 1;
	for (lglg i=2; i*i<=gcd; ++i) {
		lglg done = 0;
		while (gcd%i == 0) {
			done = 1;
			gcd /= i;
		}
		result += done;
	}
	if (gcd > 1) ++result;
	cout << result;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;

int main () {
    int a, b, c;
    read(a), read(b), read(c);
    write(b * (c / a)), EL;
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;

	while (op != '?') {
		if (op == '+') {
			cout << a + b << endl;
			cin >> a >> op >> b;
		}
		else if (op == '-') {
			cout << a - b << endl;
			cin >> a >> op >> b;
		}
		else if (op == '*') {
			cout << a * b << endl;
			cin >> a >> op >> b;
		}
		else if (op == '/') {
			cout << a / b << endl;
			cin >> a >> op >> b;
		}
	}

	return 0;
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int ans = abs(A-B) + abs(B-C) + abs(C-A) - max({abs(A-B),abs(B-C),abs(C-A)});
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

#define SIZE 1000000
int A[SIZE], H;

int parent(int x) { return x / 2; }
int left(int x) { return x * 2; }
int right(int x) { return x * 2 + 1; }

void maxHeapify(int x)
{
	int l = left(x), r = right(x), max;

	if (l <= H&&A[l] > A[x]) max = l;
	else max = x;
	if (r <= H&&A[r] > A[max]) max = r;

	if (max != x) {
		int cmp = A[max];
		A[max] = A[x];
		A[x] = cmp;
		maxHeapify(max);
	}
}

int main()
{
	scanf("%d", &H);

	for (int i = 1; i <= H; i++)
		scanf("%d", &A[i]);

	for (int i = H / 2; i > 0; i--)
		maxHeapify(i);

	for (int i = 1; i <= H; i++)
		printf(" %d", A[i]);
	printf("\n");

	return 0;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector< int > ev[100100];
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    if(M - x >= 0) ev[M - x].emplace_back(y);
  }
  long long ret = 0;
  priority_queue< int > que;
  for(int i = M; i >= 0; i--) {
    for(auto &p : ev[i]) que.emplace(p);
    if(que.size()) {
      ret += que.top();
      que.pop();
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 5632
package main

import (
	"fmt"
)

func min(nums ...int) int {
	min := nums[0]
	for _, v := range nums {
		if v < min {
			min = v
		}
	}
	return min
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	fmt.Println(min(a, b) + min(c, d))
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
struct ans{int y1,x1,y2,x2;};
int main(){
    int h,w;cin>>h>>w;
    int a[510][510];
    int n=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    vector<ans> res;
    for(int i=0;i<h;i++){
        if(i%2){
            for(int j=w-1;j>=1;j--){
                if(a[i][j]%2){
                    res.push_back({i,j,i,j-1});  
                    a[i][j-1]++;
                }
            }
            if(i<h-1&&a[i][0]%2){
                res.push_back({i,0,i+1,0});
                a[i+1][0]++;
            }
        }else{
            for(int j=0;j<w-1;j++){
                if(a[i][j]%2){
                    res.push_back({i,j,i,j+1});
                    a[i][j+1]++;
                }
            }
            if(i<h-1&&a[i][w-1]%2){
                res.push_back({i,w-1,i+1,w-1});
                a[i+1][w-1]++;
            }
        }
    }
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++){
        cout<<res[i].y1+1<<" "<<res[i].x1+1<<" "<<res[i].y2+1<<" "<<res[i].x2+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 5232
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
const int INF = 10000000;

string replaceAll(string s, string from, string to){
    vector<int> all;
    string tmp = s, tmp_space = s;

    string::size_type pos = tmp.find(from);
    while(pos != string::npos){
        all.emplace_back(pos);
        pos = tmp.find(from, pos + from.size());
    }
    if(all.empty()) return "0";

    //string space(from.size(), ' ');
    rep(j,all.size()){
        tmp.replace(all[j] + (to.size() - from.size()) * j, from.size(), to);
        //tmp_space.replace(all[j] + (from.size() - to.size()) * j, from.size(), space);
    }
    //if(tmp_space.find(to) != string::npos) return "0";

    return tmp;
}

int bfs(int n, string s, string t, pair<string, string> p[11], int cnt){
    queue<pair<string,int>> q;
    q.push(make_pair(s,0));

    while(not q.empty()){
        pair<string, int> u = q.front(); q.pop();
        if(u.first == t) return u.second;
        if(u.first.size() > 10) continue;

        string tmp;
        rep(i,n){
            tmp = replaceAll(u.first, p[i].first, p[i].second);
            if(tmp == "0" || u.first == tmp) continue;
            q.push(make_pair(tmp, u.second + 1));
        }
    }
    return -1;
}

int main(){
    int n;
    while(cin >> n,n){
        pair<string, string> p[11];
        rep(i,n){
            string a, b;
            cin >> a >> b;
            p[i] = make_pair(a,b);
        }
        string s, t;
        cin >> s >> t;
        cout << bfs(n,s,t,p,0) << endl;
        //int tmp = dfs(n,s,t,p,0);
        //cout << (tmp == INF ? -1 : tmp) << endl;
    }
}

Measured memory_bytes: 4268
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] a = new long[N];
        long sum = 0;
        
        for(int i=0; i<N; i++) {
            a[i] = Long.parseLong(sc.next());
            sum += a[i];
        }
        long sunuke = a[0];
        long araiguma = sum-a[0];
        long min = sa(sunuke, araiguma);
        for(int i=1; i<N-1; i++) {
            sunuke += a[i];
            araiguma -= a[i];
            if(min > sa(sunuke, araiguma)) min = sa(sunuke, araiguma);
        }
        System.out.println(min);
    }   
    //差の絶対値
    static long sa(long a, long c) {
        if(a <= c) return c-a;
        else return a-c;
    }
}


Measured memory_bytes: 58368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

 
int main() {

    vector<int> x(5);
    rep(i,5)    cin >> x[i];

    rep(i,5) {
        if(x[i] == 0) {
            cout<<i+1<<endl;
            return 0;
        }
    }

 return 0;
}

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

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    char c;
    cin>>c;
    cout<<char(c+1);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  int N;
  int hoge = 0;
  string S;
  cin >> N >> S;
  int ret = 0;
  for (int i = 0; N > i; i++){
    if(S.at(i) == 'I'){
      ret++;
      if(ret > hoge){
        hoge = ret;
      };
    }else{
      ret--;
    }
  }
  cout << hoge << endl;
}

Measured memory_bytes: 256
// Problem : A - Repeat ACL
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	string s="ACL";
	int n;
	cin >> n;
	while(n--)
		cout << s;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

struct SieveOfEratosthenes {
    vector<bool> is_prime;
    vector<ll> primes;

    SieveOfEratosthenes(ll V) {
        is_prime = vector<bool>(V + 1, true);
        primes = vector<ll>();
        for (ll i = 2; i <= V; i ++) {
            if (is_prime[i]) {
                primes.push_back(i);
                for (ll j = i * i; j <= V; j += i) {
                    is_prime[j] = false;
                }
            }
        }
    }

    vector<pll> factorize(ll x) {
        if (x == 1) {
            return {pll(1, 1)};
        }
        auto result = vector<pll>();
        for (auto p : primes) {
            ll exp = 0;
            while (x % p == 0) {
                exp++;
                x = x / p;
            }
            if (exp > 0) {
                result.push_back(pll(p, exp));
            }
            if (p * p > x) {
                break;
            }
        }
        if (x > 1) {
            result.push_back(pll(x, 1));
        }
        return result;
    }
};

ll gcd(ll a, ll b) {
    // gcd(x, 0) = x
    // gcd(a, b) = gcd(b, r)
    while (b != 0) {
        ll r = a % b;
        a = b;
        b = r;
    }
    return a;
}

string solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    if (all_of(A.begin(), A.end(), [&](const ll x) { return x == 1; })) {
        return "pairwise coprime";
    }

    auto sieve = SieveOfEratosthenes(*max_element(A.begin(), A.end()));
    auto used_primes = unordered_set<ll>();

    ll gcd_all = A[0];
    for (int i = 1; i < N; i++) {
        gcd_all = gcd(gcd_all, A[i]);
    }

    if (gcd_all != 1) {
        return "not coprime";
    }

    for (auto x : A) {
        if (x == 1) {
            continue;
        }
        auto factors = sieve.factorize(x);
        for (auto [p, e] : factors) {
            if (used_primes.find(p) != used_primes.end()) {
                return "setwise coprime";
            }
            used_primes.insert(p);
        }
    }

    return "pairwise coprime";
}

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

    cout << solve() << endl;

    return 0;
}

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

ll n;

ll npot[64], ppot[64];
bitset<64> ans;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    
    for (int i = 0; i <= 50; ++i) {
		if (i % 2) {
			npot[i] = -(1ll << i);
			if (i > 2) npot[i] += npot[i - 2];
		} else {
			ppot[i] = (1ll << i);
			if (i > 1) ppot[i] += ppot[i - 2];
		}
	}
	
	if (!n) {
		cout << 0;
		return 0;
	}
	
	ll cur;
	if (n > 0) {
		int pow;
		for (int i = 0; i < 64; i++) {
			if (ppot[i] >= n) {
				pow = i;
				break;
			}
		} 
		cur = (1ll << pow);
		ans[pow] = 1;
	} else {
		int pow;
		for (int i = 0; i < 64; i++) {
			if (npot[i] <= n) {
				pow = i;
				break;
			}
		} 
		cur = -(1ll << pow);
		ans[pow] = 1;
	}
	
	ll target = n - cur;
	// sorta bsearch
	for (int i = 60; i > 0; --i) {
		ll change = (1ll << i);
		if (i % 2) change *= -1;
		
		if ((change < 0 && target > 0) || (change > 0 && target < 0)) continue;
		
		if (change < 0) {
			if (cur + change + ppot[i - 1] < n) continue;
			else {
				ans[i] = 1;
				cur += change;
			}
		} else {
			if (cur + change + npot[i - 1] > n) continue;
			else {
				ans[i] = 1;
				cur += change;
			}
		}
		target = n - cur;
	}
	if (cur != n) ans[0] = 1;
	
	
	bool found = false;
	for (int i = 63; i >= 0; --i) {
		if (found || ans[i]) {
			if (ans[i]) {
				cout << 1;
				found = true;
			} else cout << 0;
		}
	}
	
    return 0;
}


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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << "\t|";
  __f(comma + 1, args...);
}
 

#define print(x) for(auto it : x) cout<< it << " "; cout << endl;
typedef long long ll;
typedef unsigned long long ull;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<int>());
    ull ans = (ull) v[0];
    for (int i = 1; i <= (n - 2) / 2; i++) {
        ans += 2 * v[i];
    }
    if (n % 2) {
        ans += v[n / 2];
    }
    cout << fixed << ans << '\n';
    return 0;
}


Measured memory_bytes: 4776
n = int(input())
w = list(input() for _ in range(n))
ans = True
w2 = set(w)
if len(w) != len(w2):
    ans = False
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        ans = False
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
a=int(input())
b=input()
s=set()
c=[0 for i in range(10)]
bc=[0 for i in range(10)]
bc[int(b[0])]+=1
for i in range(1,a):
  c[int(b[i])]+=1
for i in range(1,a-1):
  bb=int(b[i])
  c[bb]-=1
  for i in range(10):
    if bc[i]>0:
      for j in range(10):
        if c[j]>0:
          ss=str(i)+str(bb)+str(j)
          if ss  not in s:
            s.add(ss)
  bc[bb]+=1
print(len(list(s)))
          

Measured memory_bytes: 44136
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int[] As = new int[N];
            for (int i = 0; i < N; i++) {
                As[i] = scanner.nextInt();
            }
            int sum = 0;
            int current = 0;
            for (int i = 0; i < N; i++) {
                if (As[i] > current) {
                    sum += As[i] - current;
                }
                current = As[i];
            }
            System.out.println(sum);
        }
    }
}


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

#define M 1000001
#define NIL -1

int T[M];

int h1(int k)
{
	return k % M;
}

int h2(int k)
{
	return (1 + (k % (M-1)));
}

int h(int k, int i)
{
	return (h1(k) + i * h2(k)) % M;
}

int insert(int key)
{
	int i = 0, p;
	while (1) {
		if (i >= M)
			return NIL;
		p = h(key, i++);
		if (NIL == T[p]) {
			T[p] = key;
			return p;
		}
	}
}

int find(int key)
{
	int i = 0, p;
	while (1) {
		if (i >= M)
			return NIL;
		p = h(key, i++);
		if (key == T[p]) {
			return p;
		} else if (NIL == T[p]) {
			return NIL;
		}
	}
}

int get_char(char ch)
{
	switch (ch) {
	case 'A': return 1;
	case 'C': return 2;
	case 'G': return 3;
	case 'T': return 4;
	default: return 0;
	}
}

int get_key(char *cargs)
{
	int key = 0, p = 1;
	while (*cargs != 0) {
		key += p * get_char(*cargs);
		p *= 5;
		cargs++;
	}
	return key;
}

int main(int argc, char *argv[])
{
	int i, n, key;
	char cmd[10], cargs[14];
	memset(T, NIL, sizeof(T));

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", cmd, cargs);
		key = get_key(cargs);

		if (!strcmp(cmd, "insert")) {
			insert(key);
		} else if (!strcmp(cmd, "find")) {
			if (NIL != find(key)) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> data;
  for(int i = 1; i < n + 1; i++){
    int j;
    cin >> j;
    data.push_back(make_pair(j, i));
  }
  sort(data.begin(), data.end());
  for(pair<int, int> x : data){
    int a, b;
    tie(a, b) = x;
    cout << b << endl;
  }

}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int L[2000];
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    sort(L,L+N);
    int ans=0;
    for(int i=2; i<N; i++){
        for(int j=0; j<i; j++){
            for(int k=0; k<j; k++){
                if(L[i]<L[j]+L[k]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;
    int w[N];
    for(int i=0; i < N; i++)
        cin >> w[i];

    int p = (int)(N / 2);

    int f = 0;
    for(int i=0; i < p; i++)
        f += w[i];

    int b = 0;
    for(int i=p; i < N; i++)
        b += w[i];
    
    int sub = abs(f - b);
    if (f < b){
        for(int i=p; i < N; i++){
            f += w[i];
            b -= w[i];
            if(sub < abs(b - f))
                break;
            else
                sub = abs(b - f);
        }
    }
    else{
        for(int i=p-1; i >= 0; i--){
            f -= w[i];
            b += w[i];
            if(sub < abs(b - f))
                break;
            else
                sub = abs(b - f);
        }
    }
    cout << sub << endl;
    
    return 0;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int):
    a = pow(10, N, MOD)
    b = pow(9, N, MOD)
    c = pow(8, N, MOD)
    return (2 * (a - b) - (a - c)) % MOD

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000
#define N 2100

vector<ll> s(N);
vector<ll> t(N);
vector<vector<ll>> dpsum(N,vector<ll>(N,0));

int main(){
    ll n, m; cin >> n >> m;
    FOR(i,1,n) cin >> s[i];
    FOR(i,1,m) cin >> t[i];
    FOR(i,1,n)FOR(j,1,m){
        if (s[i]==t[j]) dpsum[i][j]=(dpsum[i-1][j]+dpsum[i][j-1]+1)%MOD;
        else dpsum[i][j]=(dpsum[i-1][j]+dpsum[i][j-1]+MOD-dpsum[i-1][j-1])%MOD;
    }
    cout << dpsum[n][m]+1 << endl;
}

Measured memory_bytes: 34816
object Main {
    def main(args:Array[String]) {
        val sc = new java.util.Scanner(System.in)
        while (true) {
            var time = sc.nextInt
            if (time == 0) return
            val n = sc.nextInt
            for (i <- 1 to n) {
                val start, end = sc.nextInt
                time -= (end - start)
            }
            println(if (time <= 0) "OK" else time)
        }
    }
}

Measured memory_bytes: 48628
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=2e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
ll arr[MAXN];
ll brr[MAXN];
ll n,k;
bool cmp(ll a,ll b)
{
    return a>b;
}
bool check(ll mid)
{
    ll res=0;
    for(int i=1;i<=n;i++)
    {
        res+=max(0ll,arr[i]-mid/brr[i]);
    }
    return (res>k);
}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    for(int j=1;j<=n;j++)
    {
        cin>>brr[j];
    }
    sort(arr+1,arr+1+n,cmp);
    sort(brr+1,brr+1+n);
    ll l=0,r=1e12;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(check(mid))
        {
            l=mid+1;
        }
        else
        {
            r=mid-1;
        }
    }
    cout<<l<<endl;
    return 0;
}


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

//---------------------------

using VSL = vector<set<ll>>;

int main(){
    ll n,m;
    cin >> n >> m;
    VSL G(n+1);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        G[a].insert(b);
        G[b].insert(a);
    }

    VL perm(n-1);
    rep(i,n-1){
        perm[i] = i + 2;
    }

    ll ans = 0;
    do {
        ll cur = 1;
        bool flag = true;
        rep(i,n-1){
            ll next = perm[i];
            if(G[cur].count(next)){
                cur = next;
            }else{
                flag = false;
                break;
            }
        }
        if(flag) ans++;

        // for(auto x : perm){
        //     cout << x << " ";
        // }
        // cout << endl;
        // if(flag) cout << "Okay" << endl;

    } while (next_permutation(perm.begin(), perm.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans;
void judge(ll m,ll x)
{
    if(!m)return;
    if(n/m==x&&n%m==x)ans+=m;
}
int main()
{
    cin>>n;
    for(ll i=1;i*i<=n;i++)
    if(n%i==0)
    {
        judge(i-1,n/i);
        if(i*i<n)judge(n/i-1,i);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll ans=0;
  for(int i=0;i<60;i++){
    ll cnt[2]={0,0};
    for(int j=0;j<n;j++){
      int val=(a[j]>>i)&0x01;
      cnt[val]++;
    }
    cerr<<(1<<i)<<" : "<<cnt[0]<<" : "<<cnt[1]<<endl;
    ll p=cnt[0]*cnt[1]%mod;
    p*=(1LL<<i)%mod;
    p%=mod;
    ans+=p;
    ans%=mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
use std::io::*;

fn read() -> usize {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
    
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let (a, b) = (read(), read());
  println!("{}", 6 - a - b);
}

Measured memory_bytes: 4352
N = int(input())
Dishes = [list(map(int,input().split())) for _ in range(N)]
Dishes.sort(key=lambda x: x[0]+x[1])
Dishes.reverse()
score = 0
for i in range(N):
    score -= Dishes[i][1]
    if(i%2==0):
        score += Dishes[i][0] + Dishes[i][1]
print(score)

Measured memory_bytes: 31748
use proconio::{input, fastout};

#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::*;

#[fastout]
fn main() {
    input!{
        n: usize,
    }

    fn calc(n: usize, k: usize) -> usize {
        if n % k == 0 {
            calc(n / k, k)
        }
        else {
            n
        }
    }

    let mut ans = 1;

    let mut k = 2;

    while k * k <= n {
        if n % k == 0 {
            if calc(n, k) % k == 1 { ans += 1; }
            let rev = n / k;
            if rev != k {
                if calc(n, rev) % rev == 1 { ans += 1; }
            }
        };
        k += 1;
    }

    let m = n - 1;
    k = 2;

    if n > 2 {ans += 1;};
    while k * k <= m {
        if m % k == 0 {
            if n % k == 1 { ans += 1; }
            let rev = m / k;
            if rev != k {
                if n % rev == 1 { ans += 1; }
            }
        };
        k += 1;
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 2204
n = gets.to_i
a = gets.chomp.split.map &:to_i
a.sort!.reverse!

ans = a[0]
count = 1

a[1..-1].each_with_index do |v|
  break if count >= n - 1 
  ans += v
  count += 1
  break if count >= n - 1
  ans += v
  count += 1
end

p ans


Measured memory_bytes: 31724
import Control.Monad
dist a b c d = abs(a-c)+abs(b-d)
 
main = do
  [n,m] <- map read.words <$> getLine 
  ab <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  cd <- replicateM m $ map read . words <$> getLine :: IO [[Int]]
  mapM ( \[a,b] -> print.snd.minimum.map (\ ([c,d],i) -> (dist a b c d,i)) $ zip cd [1..]) $ ab 

Measured memory_bytes: 1020
from heapq import heapify, heappush, heappop

def main():
    s = ''
    h = []
    heapify(h)
    for _ in range(2000000):
        s = list(input().split())
        if s[0] == 'end':
            break
        if s[0] == 'insert':
            heappush(h, int(s[1]) * -1)
        if s[0] == 'extract':
            print(heappop(h) * -1)

if __name__ == '__main__':
    main()


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

int main() {
  int N;
  int a, b, c, d, e, f;
  cin >> N;
  
  a = N / 1000; // 1000 no kurai
  b = N % 1000; // 100 ika no kurai
  c = b / 100; // 100 no kurai 
  d = b % 100; // 10 ika no kurai
  e = d / 10; // 10 no kurai 
  f = d % 10;  // 1 no kurai

  if (a == c && c == e && e == f){
    cout << "Yes" << endl;
  }
  else if ((a == c && c == e) || (c == e && e == f)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Max 1000005
using namespace std;
char a[Max];
int n;
bool check(int x)
{
	if(a[x]==a[n-x+1]&&a[x]!='d'&&a[x]!='p'&&a[x]!='q'&&a[x]!='b') return 1;
	if(a[x]=='d'&&a[n-x+1]=='b') return 1;
	if(a[x]=='b'&&a[n-x+1]=='d') return 1;
	if(a[x]=='q'&&a[n-x+1]=='p') return 1;
	if(a[x]=='p'&&a[n-x+1]=='q') return 1;
	return 0;
}
int main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=1;i<=(n+1)/2;i++)
		if(!check(i)) puts("No"),exit(0);
	puts("Yes");
}

Measured memory_bytes: 384
n = int(input())
arr = [[int(i) for i in list(input().split())] for j in range(n)]
for i in range(1,n):
	arr[i][0] += max(arr[i-1][1], arr[i-1][2])
	arr[i][2] += max(arr[i-1][1], arr[i-1][0])
	arr[i][1] += max(arr[i-1][0], arr[i-1][2])
print(max(arr[n-1]))

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

typedef long long ll;
template <class T> ll size(const T& x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
#define MOD2 998244353
#define INF 1000000000000000000ll
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

vi ans(2000000, 0);
int r = -1;
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
	while (n % 2 == 0)  
    {  
        //cout << 2 << " ";  
        ans[2]++;
		n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            ans[i]++;  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        r = n;  
}  


void solve()
{
	ll n;
	cin >> n;
	primeFactors(n);
	//cout << "1" << endl;
	//rep(i,0,sqrt(n)+1) cout << primefact[i] << ' '; cout << endl;
	int cnt = 0;
	rep(p,2,sqrt(n)+1){
		ll cnti = ans[p];
		bool f = true;
		if(cnti <= 0) f = false;
		ll i = 1;
		while(f)
		{
			bool s = false;
			if(cnti - i < i+1) s = true;
			cnti -= i;
			cnt++;
			i++;
			if(s) break;
		}
		
	}
	if(r != -1) cnt++;
	cout << cnt << endl;
}

int main()
{
	cin.sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); 
	/*ll t;
	cin >> t;
	while(t--)*/
		solve();
	return 0;	
}


Measured memory_bytes: 18712
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for (auto& e : a) std::cin >> e;

    int M;
    std::cin >> M;
    std::vector<int> b(M);
    for (auto& e : b) std::cin >> e;

    std::cout << (a < b) << std::endl;
}


Measured memory_bytes: 3092
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto abk = readln.split.to!(long[]);
    auto A = abk[0];
    auto B = abk[1];
    auto K = abk[2];
    if (A >= K) {
        A -= K;
    } else {
        K -= A;
        A = 0;
        B = max(0, B - K);
    }
    writeln(A, " ", B);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int left = a+b;
	int right= c+d;
	if(left>right)printf("Left");
	else if(left==right)printf("Balanced");
	else printf("Right");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e5+5;

int dp[maxn], arr[maxn];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	dp[1] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		if (i == 2) {
			dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
		}
		if (i > 2) {
			dp[i] = min(dp[i-2] + abs(arr[i] - arr[i - 2]), dp[i-1] + abs(arr[i] - arr[i - 1]));
		}
	}
	
	cout << dp[n] << "\n";
}

Measured memory_bytes: 5156
S = input()
count = 0
count_h = 0
count_i = 0
frag = 0
for i in range(len(S)-1):
  if S[i] == 'h' and S[i+1] == 'i':
    count = 1
for i in range(len(S)):
  if S[i] == 'h':
    count_h = count_h+1
  elif S[i] == 'i':
    count_i = count_i+1
i = 0
while i < len(S):
  if S[i] != 'h':
    frag = 1
  i = i+2

if count == 1 and len(S)%2 == 0 and count_h == count_i and frag == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int dp[n+1];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using i64 = long long;

constexpr i64 inf = std::numeric_limits<i64>::max();

i64 dp[3030][3030];
i64 a[3030];

i64 rec2(int, int);

i64 rec1(int l, int r) {
    if (r - l == 1) return a[l];
    if (dp[l][r] != inf) return dp[l][r];
    return dp[l][r] = std::max(a[l] + rec2(l + 1, r), a[r - 1] + rec2(l, r - 1));
}

i64 rec2(int l, int r) {
    if (r - l == 1) return -a[l];
    if (dp[l][r] != inf) return dp[l][r];
    return dp[l][r] = std::min(-a[l] + rec1(l + 1, r), -a[r - 1] + rec1(l, r - 1));
}

int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (auto &el : dp) for (auto &e : el) e = inf;

    std::cout << rec1(0, n) << std::endl;

    return 0;
}

Measured memory_bytes: 72192
class Array
	%w( + - * / % ).each do |op|
		define_method op do |other|
			product(other).map{|x, y| x.send(op, y) % 256}.flatten.uniq 
		end
	end
end

n = gets.to_i
var = {}
n.times do
	name, l, u = gets.chomp.split
	var[name] = (l.to_i..u.to_i).to_a
end

gets
stack = []

begin 
	gets.chomp.split.each do |x|
		case x
		when /[+-\/*%]/
			rhs, lhs = stack.pop, stack.pop
			stack << lhs.send(x, rhs)
		when /^\d+$/
			stack << [x.to_i]
		else
			stack << var[x]
		end
	end	
	puts 'correct'
rescue
	puts 'error'
end

Measured memory_bytes: 17124
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v,a1,b1;

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m,j,k,x,y=-1,a,b,sm=0;
	string s;
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> x;
		v.pb(x);
	}
	for(i=0;i<n;i++)
	{
		cin >> x;
		sm+=x;
	}
	b1.pb(0);
	for(i=0;i<n-1;i++)
	{
		cin >> x;
		b1.pb(x);
	}
	for(i=1;i<n;i++)
		if(v[i]==v[i-1]+1)
		{
//			cout << v[i] << " " << b1[v[i]] << endl;
			sm+=b1[v[i-1]];
		}
	cout << sm;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
L = {'U':[], 'R':[], 'D':[], 'L':[]}

for _ in range(N):
    x, y, u = input().split()
    L[u].append((int(x), int(y)))

ans = 10 ** 7

def solve(A):
    global ans
    A.sort()
    s = - 10 ** 6
    t = - 10 ** 6
    for p, q, r in A:
        if p != s:
            if r == 1:
                s = p
                t = q
        elif r == 1:
            t = q
        else:
            ans = min(ans, (q - t) * 5)

solve([(x, y, 1) for x, y in L['U']] + [(x, y, -1) for x, y in L['D']])
solve([(y, x, 1) for x, y in L['R']] + [(y, x, -1) for x, y in L['L']])
solve([(x + y, y - x, 1) for x, y in L['U']] + [(x + y, y - x, -1) for x, y in L['R']])
solve([(y - x, x + y, 1) for x, y in L['R']] + [(y - x, x + y, -1) for x, y in L['D']])
solve([(x + y, x - y, 1) for x, y in L['D']] + [(x + y, x - y, -1) for x, y in L['L']])
solve([(y - x, - x - y, 1) for x, y in L['L']] + [(y - x, - x - y, -1) for x, y in L['U']])

if ans == 10 ** 7:
    print('SAFE')
else:
    print(ans)

Measured memory_bytes: 63856
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class CShoppingStreet {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<vector<int>> F(N, vector<int>(10));
    rep(i, N) {
      rep(j, 10) {
        cin >> F[i][j];
      }
    }
    vector<vector<int>> P(N);
    rep(i, N) {
      rep(j, 11) {
        int k;
        cin >> k;
        P[i].emplace_back(k);
      }
    }
    int ans = -INF;
    rep(i, bpm(2, 10)) {
      if (i == 0) {
        continue;
      }
      int ret = 0;
      rep(j, N) {
        int num = 0;
        rep(k, 10) {
          if ((i >> k) & 1 and F[j][k]) {
            num++;
          }
        }
        ret += P[j][num];
      }
      ans = max(ans, ret);
    }
    cout << ans << endl;
  }
};


signed main() {
  CShoppingStreet solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    MAXl = [A[-1]]
    for i in range(1,N-1):
        MAXl.append(max(MAXl[i-1],A[-i-1]))
    MAXl.reverse()
    count = 0
    profit = 0
    for i in range(N-1):
        p = MAXl[i]-A[i]
        if p == profit:
            count += 1
        elif p > profit:
            profit = p
            count = 1

    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14252