akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# CGL_3_A: Polygon - Area


def area(ps):
    p0, p1, *ps = ps
    area = 0.0

    x0, y0 = p0
    x1, y1 = p1
    v1 = (x1-x0, y1-y0)
    for p2 in ps:
        x2, y2 = p2
        v2 = (x2-x0, y2-y0)
        area += cross(v1, v2)
        v1 = v2

    return area / 2


def cross(v0, v1):
    x0, y0 = v0
    x1, y1 = v1
    return x0*y1 - x1*y0


def run():
    n = int(input())
    ps = []
    for _ in range(n):
        x, y = [int(i) for i in input().split()]
        ps.append((x, y))

    print("{:.1f}".format(area(ps)))


def show():
    import matplotlib.pyplot as plt
    n = int(input())
    xs = []
    ys = []
    for _ in range(n):
        x, y = [int(i) for i in input().split()]
        xs.append(x)
        ys.append(y)

    plt.plot(xs, ys)
    plt.show()


if __name__ == '__main__':
    run()



Measured memory_bytes: 5640
#include <iostream>
#include <string>
#include <map>
using namespace std;

map< char, string > toBits;
map< string, char > toChar;

#define INSB( k, s ) (toBits.insert( map<char, string>::value_type(k, s)))
#define INSC( k, s ) (toChar.insert( map<string, char>::value_type(k, s))) 

string ToBits( char ch ) {
	string res = "", tmp = "";
	int num = ch - 'A';

	for( int i = 0; i < 5; ++i ) {
		tmp += (char)((num % 2) + '0' );
		num /= 2;
	}

	for( int i = 4; i >= 0; --i ) {
		res += tmp[ i ];
	}

	return res;
}

void Init() {
	// toBitsの初期化
	INSB( ' ', "11010" ); INSB( '.', "11011" ); INSB( ',', "11100" );
	INSB( '-', "11101" ); INSB( '\'', "11110" ); INSB( '?', "11111" );
	for( char c = 'A'; c <= 'Z'; ++c ) {
		INSB( c, ToBits( c ) );
	}

	// toCharの初期化
	INSC( "101", ' ' );      INSC( "000000", '\'' );  INSC( "000011", ',' );
	INSC( "10010001", '-' ); INSC( "010001", '.' );   INSC( "000001", '?' );
	INSC( "100101", 'A' );   INSC( "10011010", 'B' ); INSC( "0101", 'C' );
	INSC( "0001", 'D' );     INSC( "110", 'E' );      INSC( "01001", 'F' );
	INSC( "10011011", 'G' ); INSC( "010000", 'H' );   INSC( "0111", 'I' );
	INSC( "10011000", 'J' ); INSC( "0110", 'K' );     INSC( "00100", 'L' );
	INSC( "10011001", 'M' ); INSC( "10011110", 'N' ); INSC( "00101", 'O' );
	INSC( "111", 'P' );      INSC( "10011111", 'Q' ); INSC( "1000", 'R' );
	INSC( "00110", 'S' );    INSC( "00111", 'T' );    INSC( "10011100", 'U' );
	INSC( "10011101", 'V' ); INSC( "000010", 'W' );   INSC( "10010010", 'X' );
	INSC( "10010011", 'Y' ); INSC( "10010000", 'Z' );
}

int main() {
	Init();

	string in;
	while( getline( cin, in ) ) {
		string bits = "";
		string tmp = "";

		for( int i = 0; i < in.length(); ++i ) {
			bits += toBits[ in[ i ] ];
		}

		for( int i = 0; i < bits.length(); ++i ) {
			tmp += bits[ i ];
			if( toChar.find( tmp ) != toChar.end() ) {
				cout << toChar[ tmp ];
				tmp = "";
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;
int main(){
    int n;
    cin>>n;
    int a[n];
    rep0(i,n) cin>>a[i];
    bool ok=1;
    rep0(i,n) if(a[i]&1) ok=0;
    if(ok) cout<<"second"<<endl;
    else cout<<"first"<<endl;
    return 0;
}


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

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

const int mod = 1e9 + 7;

int N;
ll K;
ll A[222];

int calc(ll l, ll r) {
    int ret = 0;
    int p = -1;
    for(int i = 60; i >= 0; i--) {
        if((l & (1LL << i)) != (r & (1LL << i))) {
            p = i;
            break;
        }
        if(l & (1LL << i)) ret++;
    }
    if(p == -1) return ret;
    if(l % (1LL << p) == 0) return ret;
    else return ret + 1;
}

map<vector<ll>, vector<pll> > V;

void solve(int m, ll b, int used) {
    ll x = (A[0] - b) / (1LL << m);

    ll rem = K - m - used;
    if(rem < 0) return;
    else {
        vector<ll> D;

        for(int i = 0; i < N - 1; i++) {
            ll p = (A[i] - b) / (1LL << m);
            ll q = (A[i + 1] - b) / (1LL << m);
            D.push_back(q - p);
        }
        ll ed = x;
        ll st = max(0LL, x - rem);
        V[D].push_back({st, ed});
    }
}

int main() {
    scanf("%d %lld", &N, &K);

    for(int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }

    sort(A, A + N);

    for(int i = 0; i <= 60; i++) {
        ll m = (1LL << i);

        vector<ll> R;
        for(int j = 0; j < N; j++) {
            R.push_back(A[j] % m);
        }
        sort(R.begin(), R.end());
        R.resize(unique(R.begin(), R.end()) - R.begin());

        ll la = 0;
        for(int j = 0; j < R.size(); j++) {
            if(A[0] < la) break;
            int b = calc(la, min(A[0], R[j]));
            solve(i, R[j], b);
            la = R[j] + 1;
        }
        if(la <= min(m - 1, A[0])) {
            int b = calc(la, min(m - 1, A[0]));
            solve(i, la, b);
        }
    }

    int ans = 0;
    for(auto it = V.begin(); it != V.end(); it++) {
        vector<pll> tmp = it->second;
        sort(tmp.begin(), tmp.end());

        ll st = 0;
        ll ed = -1;
        for(int i = 0; i < tmp.size(); i++) {
            if(ed < tmp[i].first) {
                ans += (ed - st + 1) % mod;
                ans %= mod;
                st = tmp[i].first;
                ed = tmp[i].second;
            }
            else ed = max(ed, tmp[i].second);
        }
        ans += (ed - st + 1) % mod;
        ans %= mod;
    }

    printf("%d", ans);
}


Measured memory_bytes: 16384
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string>



int main() {
	int N;
	scanf("%d",&N);
	int a[100010];
	int ans[100010] = {};
	for (int i = 0; i <N ;i++) {
		scanf("%d", &a[i]);
		if (a[i]>=1) {
			ans[a[i] - 1]++;
		}
		ans[a[i]]++;
		ans[a[i] + 1]++;
	}
	int b=0;
	for (int i = 0; i < 100010; i++) {
		b = std::max(b,ans[i]);
	}

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

	return 0;
}

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

int main(void)
{	
	int num[5], a, b, c, d, e, i, tmp, flag=0;
	
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	
		num[0] = a;
		num[1] = b;
		num[2] = c;
		num[3] = d;
		num[4] = e;
			
	while(flag==0){
		
		flag = 1;
		for(i=0; i<4; i++){
			if(num[i] < num[i+1]) {
				tmp = num[i];
				num[i] = num[i+1];
				num[i+1] = tmp;
				flag = 0;	
			}
		}
	
	}
	printf("%d %d %d %d %d\n", num[0], num[1], num[2], num[3], num[4]);
	
	

	return 0;
}

Measured memory_bytes: 596
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        h: usize,
        n: usize,
        a: [usize;n],
    }

    let mut sum = 0;
    for i in a{
        sum += i;
    } 

    if sum >= h{
        println!("Yes");
    } else {
        println!("No");
    }

}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100005],da[100005];
int main(){
	int n,k;
	cin>>n>>k;
	fill(dp+2,dp+n+5,1000000000);
	for(int i=1;i<=n;i++)cin>>da[i];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(i+j>n)break;
			dp[i+j]=min(dp[i+j],dp[i]+abs(da[i]-da[i+j]));
		}
	}
	cout<<dp[n]<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
    vector<int> size;//各グループの要素数uf.size[uf.find(1)]みたいな感じでfind経由忘れずに
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
            size[y]+=size[x];
        }else{
            par[y]=x;
            size[x]+=size[y];
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int> x(m),y(m),z(m);
    vector<bool> used(n+1,false);
    UnionFind uf(n+1);
    rep(i,m){
      cin>>x[i]>>y[i]>>z[i];
      uf.unite(x[i],y[i]);
      used[x[i]]=true;
      used[y[i]]=true;
    }
    int ans=0;
    set<int> cnt;
    FOR(i,1,n+1){
      if(!used[i]){
        ans++;
        continue;
      }
      cnt.insert(uf.find(i));
    }
    ans+=len(cnt);
    cout<<ans<<endl;
}

Measured memory_bytes: 2920
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 1e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1000200013;
const int Sz = 501;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, a[N], ans;

int main() {
  #ifdef wws
    freopen("in", "r", stdin);
   // freopen("out", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1;i <= n;i++) cin >> a[i];
  for (int i = 1;i <= n;i++) {
    ans++;
    int pattern = -1;
    int j = i;
   // cout << "i = " << i << endl;
    while(j < n && (pattern == -1 || a[j + 1] == a[j] || (a[j + 1] != a[j] && a[j + 1] > a[j] == pattern))) {
      j++;
      if (a[j] != a[j - 1]) pattern = a[j] > a[j - 1];
    }
    i = j;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
s = input()
st1=[]
st2=[]
st3=[]
n=len(s)
lv = 0
for i in range(n):
	c=s[i]
	if c=='\\':
		lv-=1
		st1.append(i)
	elif c=='/':
		lv+=1
		if len(st1) > 0:
			a = i - st1.pop()
			if len(st2)==0 or st2[len(st2)-1]>=lv:
				st3.append(a)
			else:
				t=0	
				while len(st2)>0 and st2[len(st2)-1]<lv:
					st2.pop()
					t+=st3.pop()
				st3.append(a+t)		
			st2.append(lv)
		else:
			if len(st2) > 0:
				st2.pop()
				st2.append(lv)
				
st=''
total=0
n = len(st3)
st+=str(n)
for i in range(n):
	st+=' '+str(st3[i])
	total+=(st3[i])
print(total)
print(st)



Measured memory_bytes: 6128
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[202020], r[202020];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i <= num; i++)scanf("%lld", &a[i]);
	for (int j = num; j >= 0; j--)r[j] = r[j + 1] + a[j];
	ll ans = 0;
	ll now = 1;
	for (int i = 0; i <= num; i++)
	{
		ans += now;
		if (now < a[i])
		{
			printf("-1\n");
			return 0;
		}
		now -= a[i];
		now = min(now * 2, r[i + 1]);
	}
	printf("%lld\n", ans);
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n; cin >> n;

  cout << n / 3 << endl;
  
  return (0);
}

Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int train = n * a;
        int taxi = b;
        if (train > taxi) {
            System.out.println(taxi);
        } else {
            System.out.println(train);
        }
        sc.close();
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, K; cin >> N >> K;
  vector<ll> h(N); REP(i, N) cin >> h[i];
  sort(all(h));
  ll tmp = pow(10, 10);
  for(int i = 0; i < N - K + 1; ++i) {
    ll res = abs(h[i] - h[i + K - 1]);
    if(tmp > res) tmp = res;
  }
  cout << tmp << endl;
}

Measured memory_bytes: 1024
//g++  7.4.0

#include <bits/stdc++.h>
using namespace std;

int main()
{
   int n;
    cin>>n;
    int a[n];
    int b[n];
    int c[n];
    for(int i =0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        dp[i][0] = a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i]+max(dp[i-1][1],dp[i-1][0]);
    }
    int max = 0;
    if(max<dp[n-1][0])max=dp[n-1][0];
    if(max<dp[n-1][1])max = dp[n-1][1];
    if(max<dp[n-1][2])max = dp[n-1][2];
    cout<<max;
}

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

namespace Aizu
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var aList = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var q = int.Parse(Console.ReadLine());
			var mList = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var mDictionary = new Dictionary<int, bool>();

			foreach(var m in mList)
			{
				if(!mDictionary.ContainsKey(m))
				{
					mDictionary.Add(m, false);
				}
			}

			for(var i = 0; i < Math.Pow(2, aList.Count); i++)
			{
				var sum = 0;

				for(var j = 0; j < aList.Count; j++)
				{
					if(((i >> j) & 1) == 1)
					{
						sum += aList[j];
					}
				}

				if(mDictionary.ContainsKey(sum))
				{
					mDictionary[sum] = true;
				}
			}

			foreach(var value in mList)
			{
				Console.WriteLine(mDictionary[value] ? "yes" : "no");
			}
		}
	}
}



Measured memory_bytes: 18252
if __name__ == '__main__':

	n = int(input())

	s = 100000

	for i in range(n):
		s += int(s*(0.05))
		
		tmp0 = str(s)
		tmp1 = len(tmp0)
		tmp2 = tmp0[0:tmp1-3]
		num = tmp2 + "000"
		if int(s) - int(num) != 0:
			s = int(num) + 1000

	print(s)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

int lcm (int a, int b) { return a * b / gcd (a, b); }

int main() {
    int x;
    cin >> x;
    int b = lcm (360, x);
    cout << b / x << "\n";
}

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

int main(void) {
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define fi first
#define se second
#define pb push_back
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
#define L(i,u) for (int i=head[u]; i!=0; i=edge[i].nxt)
#define abs(a) ((a)>0 ? (a) : -(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef long long ll;
typedef long double ld;
const int N = 202000;


inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=10*x+c-'0'; c=getchar();} x*=f;
}
int n,t[N],x[N],y[N];
int main() {
	read(n); rep(i,1,n) read(t[i]),read(x[i]),read(y[i]);
	bool gg=0; int a=0,b=0;
	rep(i,1,n) {
		int dis=abs(a-x[i])+abs(b-y[i]);
		if (dis>t[i]-t[i-1]||(t[i]-t[i-1]-dis)&1) gg=1;
		a=x[i]; b=y[i];
	}
	if (gg) puts("No"); else puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
# https://atcoder.jp/contests/abc150/tasks/abc150_c
# TODO: try


def generate_pattern(pattern, current, n):
    c = current[:]
    remain = n - len(c)
    if remain > 0:
        for i in range(1, n + 1):
            if i not in c:
                c.append(i)
                generate_pattern(pattern, c, n)
                c.pop()
    else:
        pattern.append(c)


def main():
    n = int(input())
    array_a = [int(s) for s in input().split(" ")]
    array_b = [int(s) for s in input().split(" ")]
    pattern = []
    a = -1
    b = -1
    for i in range(n):
        generate_pattern(pattern, [i + 1], n)
    for i, v in enumerate(pattern):
        if array_a == v:
            a = i
        if array_b == v:
            b = i
        if a != -1 and b != -1:
            break
    print(abs(a - b))


def get_num(array, i, n):
    t = abs(array[i - 1] - (i - 1))
    t = t ** (n - i -1)
    return t


if __name__ == '__main__':
    main()


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

const int MAX = 200000;
int main() {
	int N, count = 0;
	static int a[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> a[i];
	for (int i = 0;i < N;i ++) {
		if (a[a[i] - 1] == i + 1) count ++;
	}
	cout << count / 2;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n;
    cin >> n;
    map<int, int> mp;
    int a[n+1] = {};
    for(int i = 1; i<=n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    bool ok = true;
    bool prime[1000001];
    memset(prime, true, sizeof(prime));
    int N = 1000000;
    for(int i = 2; i*i<=N; i++) {
        if(prime[i]) {
            for(int j = i*i; j<=N; j+=i) {
                prime[j] = false;
            }
        }
    }
    for(int i = 2; i<=N; i++) {
        if(prime[i]) {
            int curr = 0;
            for(int j = i; j<=N; j+=i) {
                curr += mp[j];
            }
            if(curr > 1) {
                ok = false;
                break;
            }
        }
    }
    for(int i = 1; i<=n; i++) {
        if(mp[a[i]] > 1 && a[i] > 1) ok = false;
    }
    if(ok) {
        cout << "pairwise coprime";
        return;
    }
    int g = a[1];
    for(int i = 2; i<=n; i++) {
        g = __gcd(a[i], g);
    }
    if(g == 1) {
        cout << "setwise coprime";
    }
    else {
        cout << "not coprime";
    }
}

int main() {_
    int t = 1;
//    cin >> t;
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 55304
import sys
import numpy as np

MOD = 10 ** 9 + 7

N, *A = map(int, sys.stdin.read().split())
A = np.array(A, dtype=np.int64)

def main():
    answer = 0
    for n in range(60):
        B = (A >> n) & 1
        x = np.count_nonzero(B)
        y = N - x
        x *= y
        x *= pow(2, n, MOD)
        answer += x
    answer %= MOD
    return answer

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

int main(){
	int N,K;
	cin >> N >> K;

	double ans=0;
	for(int i=1;i<=N;i++){
		int x=i;
		int count=0;
		while(x<K){
			x*=2;
			count++;
		}
		//cout << "x:" << x << "count:" << count << endl;
		double y=1;
		for(int j=0;j<count;j++){
			y=y*0.5;
		}
		ans+=y;
		//printf("%.16f\n",ans);
	}
	ans=ans/N;
	printf("%.16f\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	char c;
	cin >> c;
	if (c == 'a')
		cout << "vowel" << endl;
	else if (c == 'e')
		cout << "vowel" << endl;
	else if (c == 'i')
		cout << "vowel" << endl;
	else if (c == 'o')
		cout << "vowel" << endl;
	else if (c == 'u')
		cout << "vowel" << endl;
	else cout << "consonant" << endl;

	return 0;
}

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

using ll = long long;

//constant
const double EPS = 1e-10;
ll MOD = 1000000007;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// ***************************************

const ll inf = 1LL << 60;

struct Mint {
    ll v;
    ll _mod;
    Mint() : v(0) {}
    Mint(signed v, ll _mod = MOD) : v(v), _mod(_mod) {}
    Mint(ll t, ll _mod = MOD) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    Mint pow(ll k) {
        Mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static Mint add_identity() { return Mint(0); }
    static Mint mul_identity() { return Mint(1); }
    Mint inv() { return pow(_mod - 2); }

    Mint& operator+=(Mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    Mint& operator-=(Mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    Mint& operator*=(Mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    Mint& operator/=(Mint a) { return (*this) *= a.inv(); }

    Mint operator+(Mint a) const { return Mint(v) += a; };
    Mint operator-(Mint a) const { return Mint(v) -= a; };
    Mint operator*(Mint a) const { return Mint(v) *= a; };
    Mint operator/(Mint a) const { return Mint(v) /= a; };

    Mint operator-() const { return v ? Mint(_mod - v) : Mint(v); }

    bool operator==(const Mint a) const { return v == a.v; }
    bool operator!=(const Mint a) const { return v != a.v; }
    bool operator<(const Mint a) const { return v < a.v; }
};
ostream& operator<<(ostream& os, Mint m) { return os << m.v; }


int main(void) {
	ll N, P;
	string S;
	
	cin >> N >> P >> S;

    MOD = P;
	vector<ll> md(P, 0);

	ll ans = 0;
	if (P == 2 || P == 5) {
		REP(i, N) {
			if ((S[i] - '0') % P == 0) {
				ans += i + 1;
			}
		}
	}
    else {
        md[0]++;
		Mint num(0, P);
		REP(i, N) {
            num += Mint(S[N - i - 1] - '0')* Mint(10).pow(i);
			md[num.v]++;
		}

        for (auto& x : md) {
            ans += (x * (x - 1) / 2);
        }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
 
int main(){
  int N,p,q,r;
  scanf("%d",&N);
  r=100;
  
  p=(N-N%7)/7;
  
  while(p>=0){
    q=(N-7*p)%4;
    p=p-1;
    if(q<r)
      r=q;
  }
  
  if(r==0){
    puts("Yes");
  } else {
    puts("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = ab[0];
            int b = ab[1];
            if(a>0)
            {
                Console.WriteLine("Positive");
            }
            else if (a<=0 && b>=0)
            {
                Console.WriteLine("Zero");
            }
            else if( (b-a)%2==1)
            {
                Console.WriteLine("Positive");
            }
            else
            {
                Console.WriteLine("Negative");
            }
        }
    }
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 int x,y;
 cin>>x>>y;
 int64_t ans=0;
 if(abs(x)==abs(y)&&x!=y){cout<<1<<endl;return 0;}
 if(abs(x)==abs(y)&&x==y){cout<<0<<endl;return 0;}
 if(abs(x)>abs(y)){
     if(x>0){ans++;}
     ans=ans+abs(x)-abs(y);
     if(y>0){ans++;}
     cout<<ans<<endl;return 0;
 }
 if(abs(x)<abs(y)){
     if(x<0){ans++;}
     ans=ans+abs(y)-abs(x);
     if(y<0){ans++;}
     cout<<ans<<endl;return 0;
 }
 return 0;
}

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

typedef unsigned long long int ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    unordered_map<int,int> mp;
    for (auto& ele : arr) {
        mp[ele]++;
    }
    int q;
    cin >> q;
    //vector<int> a(q), b(q);
    vector<ll> ans;
    int a, b;
    ll sum = accumulate(arr.begin(), arr.end(), 0ll);
    for (int i = 0; i < q; i++) {
        cin >> a >> b;
        if (mp.count(a)) {
            sum += (mp[a] * (b - a));
            mp[b] += mp[a];
            mp.erase(a);
        }
        ans.push_back(sum);
    }
    for (auto& ele : ans) {
        cout << ele << endl;
    }
    return 0;
}



Measured memory_bytes: 7948
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl; 
using namespace std; 

//int _; 

long double a,b;

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> a >> b;
	cout << (long long)(a*b) << endl;	 
	return 0;
}

Measured memory_bytes: 3728
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    rep(i, n)
    {
        cin >> a[i].first;
        a[i].second=i+1;
    }
    sort(ALL(a));
    rep(i,n)cout<<a[i].second<<"\n";
}


Measured memory_bytes: 1664
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var s = ReadLine().ToCharArray();
            s[5] = ' ';
            s[13] = ' ';
            WriteLine(string.Join("", s));
            
        }
    }
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n; cin >> n;
    string s; cin >> s;
    for(int i=0; i<s.length(); i++){
        s[i] = s[i]+n;
        if(int(s[i]>=91)){
            s[i] = s[i]-26;
        }
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

a = []
b = []
c = []

for i in range(n):
    x,y,z = map(int, input().split())
    a.append(x)
    b.append(y)
    c.append(z)

for i in range(n):
    score = 0
    if a.count(a[i]) == 1:
        score += a[i]
    if b.count(b[i]) == 1:
        score += b[i]
    if c.count(c[i]) == 1:
        score += c[i]
    print(score)


Measured memory_bytes: 5620
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

char S[12];
char ans[12];
int seek = 0;

int main() {

	in >> S;

	rep(i, 10)
	{
		if (S[i] == '\0') { break; }
		switch (S[i])
		{
		case '0':
			ans[seek] = '0';
			seek++;
			break;

		case '1':
			ans[seek] = '1';
			seek++;
			break;

		case 'B':
			if (seek == 0)
			{
				ans[seek] = '\0';
			}
			else
			{
				seek--;
				ans[seek] = '\0';
			}
			break;
		}
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);

    let mut m = 0;
    let mut m_x = 0;

    for x in 1..N + 1 {
        let mut k = 0;
        let mut y = x;
        while y >= 2 && y % 2 == 0 {
            y /= 2;
            k += 1;
        }
        if m <= k {
            m = k;
            m_x = x;
        }
    }

    println!("{}", m_x)
}


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

using namespace std;
using ll = long long;
constexpr int INF = 1 << 29;
constexpr int N = 100100;

int main() {
    int n;
    int a[N];
    cin >> n;
    a[0] = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    a[n+1] = 0;

    int sum = 0;
    for (int i = 1; i <= n+1; i++) {
        sum += abs(a[i] - a[i-1]);
    }
    for (int i = 1; i <= n; i++) {
        int dd = abs(a[i+1]-a[i-1]) - (abs(a[i]-a[i-1])+abs(a[i+1]-a[i]));
        printf("%d\n", sum + dd);
    }
    return 0;
}


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

int main(){
  long long  n,c,i,j,cur,ans;
  cin >> n;
  vector<pair<long long, long long>> x(n);
  vector<long long> l(n);
  for(i=0; i<n; i++){
    cin >> x[i].first >> l[i];
  }
  for(i=0; i<n; i++){
    x[i].first+=l[i];
    x[i].second=x[i].first-2*l[i];
  }
  sort(x.begin(),x.end());
  
  cur=-10000000000; ans=0;
  for(i=0; i<n; i++){
    if(x[i].second>=cur){
      cur=x[i].first;
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
#endif
 
	ll n;
	cin>>n;
	vector<ll> a(n+1);
 
	for(int i=1;i<=sqrt(n);i++)
	{
		for(int j=i;j<=sqrt(n);j++)
		{
			for(int k=j;k<=sqrt(n);k++)
			{
				ll temp=i*i+j*j+k*k+i*j+i*k+j*k;
				if(temp>n)
					break;
				map<int,int> mp;
				mp[i]++;
				mp[j]++;
				mp[k]++;
				ll toadd=mp.size();
				if(mp.size()==2)
					toadd=3;
				else if(mp.size()==3)
					toadd=6;
				a[temp]+=toadd;
			}
		}
	}
 
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}
 
	return 0;
}

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

int main(void){
    int N; cin >> N;
    vector<int> P,Q,v;
    int a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        P.push_back(a);
        v.push_back(a);
    }
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        Q.push_back(a);
    }
    sort(v.begin(),v.end());
    int ans1,ans2,judge;
    a = 0;
    do{
        a++;
        judge = 0;
        for (int i = 0; i < N; i++)
        {
            if(v[i] == P[i]) judge++;
        }
        if(judge == N) ans1 = a;
        judge = 0;
        for (int i = 0; i < N; i++)
        {
            if(v[i] == Q[i]) judge++;
        }
        if(judge == N) ans2 = a;
        
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(ans1-ans2) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 200010;
const int INF = 1e9;
					     
int n, a[MAXN], b[MAXN];

int check(int x) {
  REP(i, n) b[i] = (a[i] >= x) ? 1 : 0;
  
  int best = -1, bdist = INF;
  REP(i, n) {
    if ((i > 0 && b[i] == b[i-1]) || (i+1 < n && b[i] == b[i+1])) {
      int cdist = abs(n/2 - i);
      if (cdist < bdist) {
	best = i;
	bdist = cdist;
      }
    }
  }

  if (best == -1) {
    int ret = b[n/2];
    if (((n+1)/2) % 2 == 0) ret ^= 1;
    return ret;
  }

  return b[best];
}

int solve() {
  int lo = 1, hi = 2*n-1, ret = 1;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    if (check(mid)) {
      ret = mid;
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  return ret;
}

int main(void) {
  scanf("%d",&n);
  n = 2*n - 1;
  REP(i, n) scanf("%d",&a[i]);
  printf("%d\n",solve());
  return 0;
}


Measured memory_bytes: 1792
use std::collections::HashSet;
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut h: HashSet<char> = HashSet::new();
    for c in &s.trim().chars().collect::<Vec<char>>() {h.insert(*c);}
    println!("{}", if h.len() == s.trim().len() {"yes"} else {"no"});
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n,ms,i,m;
	cin>>n>>m>>ms;
	ll a[n],b[m];
	for(i=0;i<n;++i)
		cin>>a[i];
	for(i=0;i<m;++i)
		cin>>b[i];
		
	long long sum = 0;
        int x = 0, y = 0;

        while (x < n && sum + a[x] <= ms){
            sum += a[x++];
        }

        int ans = x;
        
        while (y < m && x >= 0) {
            sum += b[y++];
            while (sum > ms && x > 0) {
                sum -= a[--x];
            }

            if (sum <= ms && ans < x + y) {
                ans = x + y;
            }
        }
	cout<<ans<<endl;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

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

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    string s; cin >> s;
    int n = s.size();
    bool flag1 = false, flag2 = false;
    rep(i,n){
        if(s[i] == 'C') flag1 = true;
        if(s[i] == 'F' && flag1) flag2 = true;
    }
    cout << (flag1 && flag2 ? "Yes" : "No") << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>

using namespace std;

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

    double all = 1;

    vector<int> a;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        a.push_back(tmp);
        all *= tmp;
    }

    double sum = 0;
    for(int i = 0; i < n; i++){
        sum += all / (double)a[i];
    }

    printf("%.10lf\n", all / sum);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        // とんでもないコードになってしまったｿﾞｫ...

        Scanner sc = new Scanner(System.in);
        String[] string = sc.next().split("");

        // RRR
        if(string[0].equals("R")){
            if(string[1].equals("R")){
                if(string[2].equals("R")){
                    System.out.println(3);
                }
            }
        }
        // RRS
        if(string[0].equals("R")){
            if(string[1].equals("R")){
                if(string[2].equals("S")){
                    System.out.println(2);
                }
            }
        }
        // RSS
        if(string[0].equals("R")){
            if(string[1].equals("S")){
                if(string[2].equals("S")){
                    System.out.println(1);
                }
            }
        }
        // RSR
        if(string[0].equals("R")){
            if(string[1].equals("S")){
                if(string[2].equals("R")){
                    System.out.println(1);
                }
            }
        }
        // SSS
        if(string[0].equals("S")){
            if(string[1].equals("S")){
                if(string[2].equals("S")){
                    System.out.println(0);
                }
            }
        }
        // SSR
        if(string[0].equals("S")){
            if(string[1].equals("S")){
                if(string[2].equals("R")){
                    System.out.println(1);
                }
            }
        }
        // SRR
        if(string[0].equals("S")){
            if(string[1].equals("R")){
                if(string[2].equals("R")){
                    System.out.println(2);
                }
            }
        }
        // SRS
        if(string[0].equals("S")){
            if(string[1].equals("R")){
                if(string[2].equals("S")){
                    System.out.println(1);
                }
            }
        }


    }
}

Measured memory_bytes: 35564
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			String buf = br.readLine();
			StringTokenizer st = new StringTokenizer(buf);
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			if (a>b) {a=a^b;b=a^b;a=a^b;}
			if (b>c) {b=b^c;c=b^c;b=b^c;}
			if (a>b) {a=a^b;b=a^b;a=a^b;}
			System.out.println(a+" "+b+" "+c);
		} catch (IOException e) {
			System.out.println("IOException!");
		}
	}
}

Measured memory_bytes: 17004
#include <iostream>
#include <stdio.h>
#include <string>
#define llint long long

using namespace std;

llint n;
llint a[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	llint ans = 1;
	for(int i = 2; i <= n; i++){
		if(a[i-1] >= a[i]) ans++;
	}
	cout << ans << endl << n << endl;
	
	return 0;
}


Measured memory_bytes: 3928
import heapq

N, M = map(int, input().split())
A = [-int(x) for x in input().split()]

# 優先度付きキューに変換
heapq.heapify(A)

# 最小値（最大値）の値を半分にしていく
for i in range(M):
    tmp = -heapq.heappop(A) // 2
    heapq.heappush(A, -tmp)

print(-sum(A))


Measured memory_bytes: 14180
#include <algorithm>
#include <cstdio>

using namespace std;

int f[1003], g[1003], a[1003][1003];

void get(int l, int r) {
    int n = r - l + 1;
    if (n <= 2) {
        a[l][r] = f[n];
        return;
    }
    int mid = l + g[n] - 1;
    get(l, mid), get(mid + 1, r);
    for (int i = l; i <= mid; i++)
        for (int j = mid + 1; j <= r; j++) a[i][j] = f[n];
}

int main() {
    int n;
    scanf("%d", &n);
    f[1] = f[2] = 1;
    for (int i = 3; i <= n; i++) {
        f[i] = 1000000000;
        for (int j = 1; j < i; j++) {
            int v = max(f[j], f[i - j]) + 1;
            if (v < f[i]) f[i] = v, g[i] = j;
        }
    }

    get(1, n);
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) printf("%d ", a[i][j]);
        puts("");
    }
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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

    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(ALL(a));

    vector<pair<ll, ll>> p(m);
    ll b, c;
    for (int i = 0; i < m; i++) {
        cin >> b >> c;
        p.push_back(make_pair(b, c));
    }
    sort(ALL(p), [](auto p1, auto p2){return p1.second > p2.second;});

    ll total = 0;
    ll dt = 0;
    auto itr = a.begin();
    for (int i = 0; i < m; i++) {
        auto q = p[i];
        itr = lower_bound(a.begin() + dt, a.end(), q.second);
        ll d = distance(a.begin() + dt, itr);
        total += min(d, q.first) * q.second;
        dt += min(d, q.first);
        if (d == 0) {
            break;
        }
    }

    for (int i = dt; i < n; i++) {
        total += a[i];
    }

    cout << total << endl;
}


Measured memory_bytes: 5688