akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I=ll(A);I<ll(B);++I)
#define out(a) cout<<fixed<<setprecision((a))

int main(){
	int n;
	cin >> n;
	vector<double> x(n),y(n);
	FOR(i,0,n)cin>>x[i];
	FOR(i,0,n)cin>>y[i];
	double d1=0,d2=0,d3=0,dm=0;
	FOR(i,0,n){
		d1 += abs(x[i]-y[i]);
		d2 += pow(abs(x[i]-y[i]),2);
		d3 += pow(abs(x[i]-y[i]),3);
		dm = max(dm,abs(x[i]-y[i]));
	}
	d2 = pow(d2,1.0/2.0);
	d3 = pow(d3,1.0/3.0);
	out(10) << d1 << endl;
	out(10) << d2 << endl;
	out(10) << d3 << endl;
	out(10) << dm << endl;
}


Measured memory_bytes: 3456
import java.util.Scanner

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    var nowMax = 0
    var secondMax = 0
    var maxCounter = 0
    var maxPosition_ifUnique = 0
    for(i in 0 until N) {
        val tmp = sc.nextInt()
        if (tmp > nowMax) {
            secondMax = nowMax
            nowMax = tmp
            maxCounter = 1
            maxPosition_ifUnique = i
        }else if(tmp == nowMax) {
            maxCounter++
            maxPosition_ifUnique = 0
        }else if(tmp > secondMax){
            secondMax = tmp
        }
    }
    if(maxCounter == 1){
        for(i in 0 until maxPosition_ifUnique){
            println(nowMax)
        }
        println(secondMax)
        for(i in maxPosition_ifUnique + 1 until N){
            println(nowMax)
        }
    }else{
        for(i in 0 until N){
            println(nowMax)
        }
    }
}

Measured memory_bytes: 70384
sx, sy, tx, ty = map(int, input().split())
nx = tx - sx
ny = ty - sy
s = ''
s += 'R' * nx + 'U' * ny
s += 'L' * nx + 'D' * ny
s += 'D' + 'R' * (nx + 1) + 'U' * (ny + 1) + 'L'
s += 'U' + 'L' * (nx + 1) + 'D' * (ny + 1) + 'R'
print(s)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

bool binsearch(int p, int ary[], int first, int last){
    int mid = (first+last)/2;
    if(last < first) return false;
    if(p == ary[mid]) return true;
    else if(p > ary[mid]) return binsearch(p, ary, mid+1, last);
    else return binsearch(p, ary, first, mid-1);
}

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

    int cnt = 0;
    for(int i=0; i<t; i++){
        if(binsearch(T[i], N, 0, n-1)) cnt++;
    }
    cout << cnt;
    cout << endl;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a, int b) {
  int c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
int lcm(int a, int b) {
  int c = gcd(a, b);
  a /= c;
  return a * b;
}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI = acos(-1.0);

using namespace std;

// #define int long long

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x != y) {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }

  bool isSame(int x, int y) { return root(x) == root(y); }

  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

  int size(int x) { return -data[root(x)]; }
};

signed main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  // cin高速化

  int n, m;
  int count = 0;
  cin >> n >> m;

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

  UnionFind uf(n);

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    uf.unite(x - 1, y - 1);
  }

  for (int i = 0; i < n; i++) {
    if (uf.isSame(i, a[i] - 1))
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
#include"iostream"
using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < 1000000001; i++)
	{
		if (a <= i && i <= b && (i - a < k || b - i < k))cout << i << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int K, N;

	cin >> N >> K;

	vint H(N);

	int sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	sort(all(H));

	int ans = 0;
	for (int i = 0; i < N - K; i++) {
		ans += H[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
#define MAX_N 200010
#define int long long

int bit[MAX_N], n, a[MAX_N], ma, b[MAX_N];

int sum(int i){
	int s = 0;
	
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i , int x){
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}
}

signed main(){
	int ans = 0;
	map<int,int> ma;
	cin>>n;
	
	for(int i = 0; i < n; i++){
		scanf("%d", &b[i]);
		b[i]++;
		a[i] = b[i];
	}
	sort(b,b+n);
	for(int i = 0; i < n; i++)
		ma[b[i]] = i+1;
	for(int i = 0; i < n; i++)
		a[i] = ma[a[i]];
	
	for(int i = 0; i < n; i++){
		ans += i - sum(a[i]);
		add(a[i],1);
	}
	cout<<ans<<endl;
	return 0;
}


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

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

	if (n < 10) {
		cout << n << endl;
		return 0;
	}

	int keta = 0;
	{
		int t = n;
		while (t != 0) {
			t /= 10;
			++keta;
		}
	}

	int ret = 0;
	if (keta % 2 == 1) {
		ret += n - static_cast<int>(pow(10, keta - 1)) + 1;
		keta -= 2;
	}
	else {
		keta -= 1;
	}

	while (keta != 1) {
		ret += static_cast<int>(pow(10, keta)) - static_cast<int>(pow(10, keta - 1));
		keta -= 2;
	}
	ret += 9;

	cout << ret << endl;

	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N), P(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    int a, b;
    rep(i, N) A[i] = i + 1;
    auto check = [&](vector<int> B) -> bool {
        rep(i, N) {
            if(A[i] != B[i]) return false;
        }
        return true;
    };
    sort(A.begin(), A.end());
    int cnt = 1;
    do {
        if(check(P)) a = cnt;
        if(check(Q)) b = cnt;
        ++cnt;
    } while(next_permutation(A.begin(), A.end()));
    cout << abs(a - b) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
vector<vector<int>> pr(10, vector<int>(10,0));
int n;

//inputします
void input() {
    cin >> n;
}

//ライブラリ置き場

//main
int main() {
    input();
    i64 ans = 0;
    ff(i, 1, n + 1) {
        string num = to_string(i);
        int fr = num[0]-'0';
        int bk = num[num.size() - 1]-'0';
        //cout << fr << " " << bk << endl;
        if (bk == 0)continue;
        ans += pr[bk][fr]*2;
        if (fr == bk)ans++;
        pr[fr][bk]++;
    }
    cout << ans << endl;
    return 0;
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "CPU time: " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;
/*}}}*/


void solve(){

    int n,d;
    cin >> n >> d;

    if(n < 10){
        cout << d+100*(10 - n) << "\n";
    }else cout << d << "\n";

    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

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

int main(){
  long long a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
}
 


Measured memory_bytes: 3584
#define _GLIBCXX_DEBUG
#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++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define from1(obj) obj.begin() + 1, obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbp(p) cerr << #p << ":(" << p.first << ", " << p.second << ") "
#define dbpl(p) cerr << #p << ":(" << p.first << ", " << p.second << ")\n"
#define dbt3(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ") "
#define dbt3l(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ")\n"
#define dbt4(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ") "
#define dbt4l(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ")\n"
#define dbv(vec) cerr << #vec << ":{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"
#define dbvv(vv) cerr << #vv << ":{\n"; for (auto vec : vv) { cerr << "{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"; } cerr << "}\n"
#define dbm(map) cerr << #map << ":{ "; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "}\n"
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pil = pair<int, ll> ; using pll = pair<ll, ll>; using pli = pair<ll, int>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mll = map<ll, ll>; using mli = map<ll, int>;

int main() {
	int N, M; cin >> N >> M;
	vector<int> A(N); rep(i, N) cin >> A[i];
	int sum = accumulate(all(A), 0);
	sort(all(A), greater<int>());
	bool f = A[M - 1] * 4 * M >= sum;
	Yn(f);
}

Measured memory_bytes: 256
/*AOJ-ITP-2-1*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		
		if(a < -1000 || a > 1000 || b < -1000 || b >1000){System.exit(1);}
		
		if(a > b){
			System.out.println("a > b");
		}else if(a < b){
			System.out.println("a < b");
		}else if(a == b){
			System.out.println("a == b");
		}
	}
}

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

using namespace std;
typedef long long ll;

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#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 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[3300][3300];
const int mod = 998244353;
void add(int &x,int y){
	y = (y%mod +mod)%mod;
	x = (x+y)%mod;
}
signed main(){
	int a,b,c,d;cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	
	for(int i = a;i <= c;i++)for(int j = b;j <= d;j++){
		if(i == a && j == b)continue;
		// dp[i][j] = dp[i-1][j]*j + dp[i][j-1]*i -dp[i-1][j-1]*(i-1)*(j-1);
		add(dp[i][j],dp[i-1][j]*j);
		add(dp[i][j],dp[i][j-1]*i);
		int tmp = dp[i-1][j-1]*(i-1)%mod;
		tmp = (tmp*(j-1))%mod;
		add(dp[i][j],-tmp);
	}
	cout << dp[c][d] << endl;
	return 0;
}

Measured memory_bytes: 80980
class MaxHeap
  attr_accessor :nodes
  def initialize(defalut = [])
    @nodes = defalut
  end

  def pop
    popped = nodes.shift
    return popped if nodes.empty?

    nodes.unshift(nodes.pop)

    tmp_index = 0
    while (tmp_index * 2 + 1) < nodes.size
      left_child_index = tmp_index * 2 + 1
      right_child_index = tmp_index * 2 + 2

      if right_child_index >= nodes.size
        if nodes[tmp_index] < nodes[left_child_index]
          swap(tmp_index, left_child_index)
          tmp_index = left_child_index
        else
          break
        end
      else
        max_child_index = if nodes[left_child_index] > nodes[right_child_index]
                            left_child_index
                          else
                            right_child_index
                          end
        if nodes[tmp_index] < nodes[max_child_index]
          swap(tmp_index, max_child_index)
          tmp_index = max_child_index
        else
          break
        end
      end
    end
    popped
  end

  def push(node)
    tmp_index = nodes.size
    while tmp_index > 0 do
      parent_index = (tmp_index - 1) / 2

      if @nodes[parent_index] && @nodes[parent_index] < node
        swap(parent_index, tmp_index)
        tmp_index = parent_index
      else
        break
      end
    end

    @nodes[tmp_index] = node
  end

  private

  def swap(index, other_index)
    nodes[index], nodes[other_index] = nodes[other_index], nodes[index]
  end
end

class PriorityQueue
  attr_accessor :heap

  def initialize(direction, default = nil)
    case direction
    when :max
      @heap = MaxHeap.new(default)
    else
      ArgumentError
    end
  end

  def dequeue
    heap.pop
  end

  def enqueue(e)
    heap.push(e)
  end
end


N, M = gets.split.map(&:to_i)
array = gets.split.map(&:to_i).sort!.reverse!
priority_queue = PriorityQueue.new(:max, array)

M.times do
  max = priority_queue.dequeue
  priority_queue.enqueue(max / 2)
end


puts priority_queue.heap.nodes.inject(:+)


Measured memory_bytes: 11136
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    long long ans = 0;
    for(int i=1; i<n; ++i){
        int b = max(0, a[i-1] + a[i] - x);
        ans += b;
        if(b <= a[i]){
            a[i] -= b;
        }
        else{
            a[i-1] -= b - a[i];
            a[i] = 0;
        }
    }
    cout << ans << endl;

    return 0;
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if ((b - a) == (c - b))printf("YES\n");
  else printf("NO\n");
}


Measured memory_bytes: 256
S = input()
N = len(S)
orig = list(S)

ans1 = 0
ans2 = 0

for i in range(int((N+1)/2)):
    if orig[2*i] != '1':
        ans1 = ans1 + 1

for i in range(int(N/2)):
    if orig[2*i+1] != '0':
        ans1 = ans1 + 1

for i in range(int((N+1)/2)):
    if orig[2*i] != '0':
        ans2 = ans2 + 1

for i in range(int(N/2)):
    if orig[2*i+1] != '1':
        ans2 = ans2 + 1

if ans1 > ans2:
    print(ans2)
else:
    print(ans1)


Measured memory_bytes: 3956
#include<stdio.h>

int main(void){
	int i,tate,yoko,a,b,temp ;
	int array[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30} ;
	
	scanf("%d %d",&tate,&yoko);
	
	for(i=0; i<yoko; i++){
		scanf("%d,%d",&a,&b);
		a--;//for array index
		b--;//for array index
		temp = array[a] ;//swap values
		array[a] = array[b] ;
		array[b] = temp ;
	}
	
	for(i=0; i<tate; i++){
		printf("%d\n",array[i]);
	}
	
	return 0 ;
}

Measured memory_bytes: 592
import java.util.*;

 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int R;
		if(n == 0) {
			R = m*(m-1)/2;
		}
		else if(m == 0) {
			R = n*(n-1)/2;
		}
		else {
			
			R = m*(m-1)/2+n*(n-1)/2;
		}
		System.out.println(R);
	}
}

Measured memory_bytes: 21844
N, K = map(int, input().split())


def tell_power_number(number):
    i = 0
    while number * (2 ** i) < K:
        i += 1
    return i


ans = 0
if N <= K - 1:
    for k in range(1, N + 1):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
else:
    for k in range(1, K):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
    ans += (N - K + 1) / N

print(ans)

Measured memory_bytes: 39280
import sys
readline = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10**6)

#n = int(input())
n,*a = [int(i) for i in readline().split()]
s = read().split()

dx = {"AB":0,"BC":1,"AC":2}
ans = ["Yes"]

def dfs(i):
    if i==n:
        print(*ans,sep="\n")
        exit()
    x = dx[s[i]]
    y = (x+1)%3
    for j in [x,y]:
        if a[j]:
            ans.append("ABC"[x+y-j])
            a[j] -= 1
            a[x+y-j] += 1
            dfs(i+1)
            ans.pop()    
            a[j] += 1
            a[x+y-j] -= 1

dfs(0)
print("No")


Measured memory_bytes: 117420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N, T;
    cin >> N >> T;

    int cnt = 1, mi = INT_MAX, ma = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        mi = min(mi, A);
        if (mi != A) {
            if (ma == A - mi)
                cnt++;
            else if (ma < A - mi) {
                ma = A - mi;
                cnt = 1;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
const int MAX_N = 1e5;

ll par[MAX_N]; // 親
ll size_list[MAX_N]; // iを親とするグループのサイズ
ll depth[MAX_N]; // 木の深さ
ll M,N;
ll A[MAX_N], B[MAX_N];


// n要素の初期化
void init(ll n){
	REP(i,n){
		par[i] = i;
		depth[i] = 0;
	}
}

// 木の根を求める
ll find(ll x){
	if (par[x]==x){
		return x;
	}
	else{
		return par[x] = find(par[x]);
	}
}

// xとyの属する集合を併合
void unit(ll x, ll y){
	x = find(x);
	y = find(y);
	if (x==y) return;
	
	if (depth[x]<depth[y]){ // xよりyが深いなら
		size_list[y] += size_list[par[x]];
		par[x] = y; // xの親はy
	}
	else{
		size_list[x] += size_list[par[y]];
		par[y] = x;
		if (depth[x]==depth[y]) depth[x]++;
	}
}

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

// xのグループの大きさ
ll size(ll x){
	return size_list[par[x]];
}
 
int main() {
	// 入力
	cin >> N>>M;
	REP(i,M){
		cin>>A[i]>>B[i];A[i]--;B[i]--;
	}
	
	// 解法
	REP(i,MAX_N) size_list[i] = -1;
	ll ans[M]; // i番目までの橋を壊した時の不全さ
	ans[M-1] = N*(N-1)/2; // 橋が0本の時->不便さ=島の全組み合わせ
	init(N); // Union-Find木を初期化
	for (ll i = M-1; i >= 1; --i){ // 後ろから橋を追加
		// REP(j,N) printf("par[%lld]=%lld\n", j, par[j]);
		// printf("size %lld %lld\n", size(A[i]), size(B[i]));
		if (same(A[i], B[i])){ // もともと島A[i]と島B[i]が連結しているなら
			ans[i-1] = ans[i]; // iの橋を追加しても不便さ変化なし
		}
		else{
			// Aのグループ x Bのグループだけ不便さが減る
			ans[i-1] = ans[i] - size(A[i]) * size(B[i]);
		}
		// printf("i*%lld, %lld->%lld\n", i, A[i], B[i]);
		// printf("i=%lld same(%lld,%lld)=%lld, ans=%lld\n\n", 
		// 	i-1, A[i-1], B[i-1], same(A[i], B[i]), ans[i-1]);
		unit(A[i],B[i]); // 島A[j]と島B[j]を結合
	}
	REP(i,M){
		printf("%lld\n", ans[i]);
	}
}

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

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var a = inputArray[0];
			var b = inputArray[1];
			var c = inputArray[2];



			//答えの出力
			var ans = getAns(a,b,c);
			Console.WriteLine(ans);

		}

		private static string getAns(long a,long b,long c) {

			if (a == b) {
				if (b == c) {
					return "No";
				}
				return "Yes";
			}
			else {
				if (a == c | b==c) {
					return "Yes";
				}
				return "No";
			}

		
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	int N,D; cin>>N>>D;
	double dis = 0;
	int cnt = 0;
	vector<vector<int>>VVI(N,vector<int>(D,0));
	rep(i,N){
		rep(t,D){
			cin>>VVI[i][t];
		}
	}
	for(int j = 0; j < N - 1; j++){
		for(int q = j + 1; q < N; q++){
      dis = 0;
			for(int a = 0; a < D; a++){
				dis += abs(VVI[j][a] - VVI[q][a]) * abs(VVI[j][a] - VVI[q][a]);

			}

			dis = pow(dis,0.5);

			if(ceil(dis) == floor(dis))cnt++;

		}
	}
	
	cout<<cnt<<endl;
}


Measured memory_bytes: 384
/*
  GCD and LCM
*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int n,m;

int gi() {
  int x=0,o=1; char ch=getchar();
  while(ch!='-' && (ch<'0' || ch>'9')) ch=getchar();
  if(ch=='-') o=-1,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return o*x;
}

int gcd(int x, int y) {
  return y?gcd(y,x%y):x;
}

int main() {
  while(scanf("%d%d", &n, &m)!=EOF) {
    int g=gcd(n,m);
    printf("%d %d\n", g,n/g*m);
  }
  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(a); sll(b); sll(c);
	LL ans = min(b/a, c);
	pll(ans); nl;
}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	if (n == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	vector<int> res;
	while (n)
	{
		if (n % 2 == 0)res.insert(res.begin(), 0);
		else
		{
			res.insert(res.begin(), 1);
			--n;
		}

		n /= -2;
	}
	for (int x : res)cout << x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Nekan "BOMBER"
#define duo pair<int,int>
#define fi first
#define se second
#define pb push_back
const int MOD=1e9+7;
long long MODED(long long a,long long b) {return (a+b)%MOD;}
using namespace std;


const int N=5e5+5;
int h,w,m;
int H[N],W[N],HH[N],Hs[N];
pair<int,int> B[N];
vector<int> A[N];



void xuly()
{
    cin>>h>>w;
    cin>>m;
    for (int i=1;i<=m;i++)
    {
        cin>>H[i]>>W[i];
        Hs[H[i]]++;
        A[W[i]].push_back(H[i]);
        B[W[i]].first++;
        B[W[i]].second=W[i];
    }
    sort(B+1,B+1+w);
    B[0].first=-1;

    //for (int i=1;i<=m;i++) cout<<B[i].first<<" "<<B[i].second<<'\n';
    int Count=0;
    for (int i=w;i>=1;i--)
    {
        Count++;
        //cout<<B[i].first<<" "<<B[i].second<<'\n';
        for (int j=0;j<A[B[i].second].size();j++) HH[A[B[i].second][j]]++;
        if (B[i].first>B[i-1].first) break;
    }
    int ans=0,start=B[w].first;
    //cout<<start<<'\n';
    for (int i=1;i<=h;i++)
    {
        //cout<<i<<" "<<Hs[i]<<" "<<HH[i]<<'\n';
        int t=Hs[i]+start-(HH[i]==Count);
        ans=max(ans,t);
    }
    cout<<ans;
}



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


Measured memory_bytes: 31712
#include <iostream>

using namespace std;

int main() {
    int a,b,c,d,e,k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    string result = (e-a <= k ? "Yay!" : ":(");
    cout << result <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
  int n;
  int a = 1;
  int i;
  int c = 0;
  int bre = 0;
  int g;
  cin >> g;
  while((scanf("%d",&n)) == 1){
    if(n == a){
      a++;
      c++;
    }else{
      bre++;
    }
  }
  if(c == 0){
    cout << -1 << endl;
  }else{
    cout << bre << endl;
  }
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int N; cin>>N;
  int rem;
  while(N>0){
    rem=N%10; N/=10;
    if(rem==7) {cout<<"Yes"; return 0;}
  }
  cout<<"No";
  return 0;
}


Measured memory_bytes: 3552
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [tuple(map(int, input().split())) for i in range(M)]

total = sum(T)
for i in range(M):
    p, x = PX[i][0], PX[i][1]
    print(total - (T[p - 1] - x))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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

void mod(ll &val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    cout << 1 - N << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  vector<ll> a(N); REP(i, N) cin >> a[i];

  ll ans = LLINF;
  for (int i = -100; i <= 100; i++) {
    ll cost = 0;
    REP(j, N) cost += (a[j] - i)*(a[j] - i);
    ans = min(ans, cost);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if(a<=x&&x<=a+b)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ans = 0;
        if(N==1) ans = 1;
        else{
            long[] L = new long[87];
            L[0] = 2L;
            L[1] = 1L;
            for(int i=2;i<=N;i++){
                L[i] = L[i-1]+L[i-2];
            }
            ans = L[N];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	int x,y;
	cin>>x>>y;
	int b=(y-2*x)/2;
	int a=x-b;
	if(a+b==x && 2*a + 4*b==y && a>=0 && b>=0)
		cout<<"Yes";
	else
		cout<<"No";
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3632
<?php
  fscanf(STDIN,'%d%d',$N,$X);
  $m=[];
  $sum=0;
  for ($i=0; $i <$N ; $i++) {
    // code...
    $m[]=trim(fgets(STDIN));
  }
  sort($m);
  for ($i=0; $i <$N ; $i++) {
    // code...
    $sum+=$m[$i];
  }
  $nokori=$X-$sum;
  $P= floor($nokori/$m[0]);
  echo count($m)+$P;

 ?>


Measured memory_bytes: 3576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        int count = 0;
        int maxCount = 0;
        int start = sc.nextInt();
        for(int i = 0; i < n - 1; i++) {
          int value = sc.nextInt();
          if (start >= value) {
            count++;
          } else {
            if (count > maxCount) {
              maxCount = count;
            }
            count = 0;
          }
          start = value;
        }
        if (count > maxCount) {
              maxCount = count;
        }
    
		// 出力
		System.out.println(maxCount);
	}
}

Measured memory_bytes: 50856
function Main(arg) {
 
    var N = arg.split("\n")[0].split(" ")[0]-0;
    var K = arg.split("\n")[0].split(" ")[1]-0;

    var h = arg.split("\n")[1].split(" ").map(v => v - 0);

    var ans = h.filter(val => val >= K).length;

    console.log(ans);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28620
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define inf 0x3f3f3f3f
#define cases(yjq) for (int cas = 1; cas <= (int)yjq; ++cas)
using namespace std;
const int N = 1e5;
int n;
int a[N + 10];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	int ans = 0;
	for(int i=1;i<=n;++i)	ans ^= a[i];
	if(ans == 0)	puts("Yes");
	else puts("No");
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, T, A;
  scanf("%d%d%d", &n, &T, &A);
  int best_i = -1;
  double best = 1e300;
  for (int i = 0; i < n; ++i) {
    double x;
    scanf("%lf", &x);
    double cur = abs(T - 6e-3 * x - A);
    if (best > cur) {
      best = cur;
      best_i = i;
    }
  }
  printf("%d\n", best_i + 1);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(i) ((i)&(-i))
#define ls (p << 1)
#define rs (p << 1 | 1)
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MAXN = 2 * 1e5 + 15;
ll suma[MAXN], sumb[MAXN];
int main() {
#ifdef CitricAcid
    freopen ("input.txt", "rt", stdin);
#endif

    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        suma[i] = suma[i - 1] + x;
    }
    for(int i = 1; i <= m; i++) {
        int x;
        scanf("%d", &x);
        sumb[i] = sumb[i - 1] + x;
    }
    int res = 0;
    sumb[m + 1] = (1ll << 60);
    for(int i = 0; i <= n; i++) {
        if(suma[i] > k) break;
        res = max(res, int(upper_bound(sumb, sumb + m + 1, k - suma[i]) - sumb - 1) + i);
    }
    printf("%d\n", res);


#ifdef CitricAcid
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
/*
# author : CitricAcid
# date : 2020/07/29
*/

Measured memory_bytes: 6936
"use strict";

const main = arg => {
    arg = arg.split("\n")[0].split("");
    let answer = "";
    
    const dfs = (i, exp) => {
        if (i === arg.length - 1) {
          exp = exp + arg[i];
          
          if (eval(exp) === 7) {
            answer = (exp + '=7');
          }
          
          return;
        } else {
          dfs(i + 1, exp + arg[i] + '+');
          dfs(i + 1, exp + arg[i] + '-');
        }
    }
    
    dfs(0, "");
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll s,w ;
	cin >> s >> w ;
	cout << (w>=s?"unsafe":"safe") << endl ;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define MAXN 100005
int n,i,ans,a[MAXN],s[MAXN],s2[MAXN];
inline int max(int x,int y){return x>y?x:y;}
inline int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void print(int x)
{
    if (x<0)
        putchar('-'),x=-x;
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}
signed main(void)
{
	read(n);
	for (i=1;i<=n;i++)
	{
		read(a[i]);
		s[i]=gcd(s[i-1],a[i]);
	}
	for (i=n;i>0;i--)
		s2[i]=gcd(s2[i+1],a[i]);
	for (i=1;i<=n;i++)
		ans=max(ans,gcd(s[i-1],s2[i+1]));
	print(ans);
	return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n;

    cin >> n;

    deque<int> dq(n);

    for(int i = 0; i < n; i++)
    {
        cin >> dq[i];
    }

    sort(dq.begin(), dq.end(), greater<int>());

    ll sum = dq[0];
    n -= 2;
    int i = 1;

    while(n > 0)
    {
        if(n > 1)
        {
            n -= 2;
            sum += 2 * dq[i];
            i++;
        }
        else
        {
            n--;
            sum += dq[i];
        }
    }

    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 4432
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)[:X]
Q = sorted(list(map(int, input().split())), reverse=True)[:Y]
R = sorted(list(map(int, input().split())),  reverse=True)

ans = sum(P) + sum(Q)
idxp = -1
idxq = -1

for ri in range(C):
    r = R[ri]
    if idxp >= -X and idxq >= -Y:
        if P[idxp] <= Q[idxq] and P[idxp] < R[ri]:
            ans += R[ri] - P[idxp]
            idxp -= 1
        elif Q[idxq] <= P[idxp] and Q[idxq] < R[ri]:
            ans += R[ri] - Q[idxq]
            idxq -= 1
    elif idxp >= -X:
        if P[idxp] < R[ri]:
            ans += R[ri] - P[idxp]
            idxp -= 1
    elif idxq >= -Y:
        if Q[idxq] < R[ri]:
            ans += R[ri] - Q[idxq]
            idxq -= 1

print(ans)


Measured memory_bytes: 105444
abcd = list(input())

op = ["+", "+", "+", ""]

for i in "+-":
    op[0] = i
    for j in "+-":
        op[1] = j
        for k in "+-":
            op[2] = k
            expression = "".join(l+m for l, m in zip(abcd, op))
            if eval(expression) == 7:
                print(expression+"=7")
                quit()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){

	string str;
	map<char,int> list;
	int flag[4]={0,0,0,0};
	int ans;

	list['N'] = 0;
	list['W'] = 1;
	list['S'] = 2;
	list['E'] = 3;

	cin>>str;

	for(int i=0;i<str.size();i++){
		flag[list[str.at(i)]]++;
	}

	ans = (flag[0]>0) - (flag[2]>0) + (flag[1]>0)*10 - (flag[3]>0)*10;

	ans == 0 ? cout<<"Yes"<<endl : cout<<"No"<<endl;

	return 0;

}

Measured memory_bytes: 256
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        dist = 0
        for k in range(d):
            dist += (x[i][k] - x[j][k]) ** 2
        for k in range (200):
            if dist == k**2:
                ans += 1
print(ans)

Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#define N 200007
#define int long long

using namespace std;

int n,k;
int a[N];

int ck(int mid){
	int tot=0;
	for(int i=1;i<=n;i++){
		if(a[i]%mid==0)
			tot+=a[i]/mid-1;
		else tot+=a[i]/mid;
	}
	if(tot>k)return false;
	else return true;
}

signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	int l=0,r=1e9;
	while(r-l>1){
		int mid=(r+l)>>1;
		if(ck(mid)) r=mid;
		else l=mid;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m;
 	cin >> m>>n;
 	string x;
 	cin >> x;
 	for (int i = 0; i < m; i++){
 		if(i+1==n){
 			x[i]+=32;
 			cout << x[i];
 		}else{
 			cout << x[i];
 		}
 	}
 	cout <<  endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int a, b, c, d, s_ans, e_ans;

    std::cin >> a >> b >> c >> d;

    if(a < c){
        s_ans = c;
    }
    else{
        s_ans = a;
    }

    if(b < d){
        e_ans = b;
    }
    else{
        e_ans = d;
    }

    if(e_ans - s_ans < 0){
        std::cout << 0;

        return 0;
    }

    std::cout << e_ans - s_ans;
    
    return 0;
}

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


ans = 0

def dfs(x, flags):
  if x <= N:
    global ans
    if flags == 7:
      ans += 1
  if x >= N:
    return
  dfs(x * 10 + 7, flags | 4)
  dfs(x * 10 + 5, flags | 2)
  dfs(x * 10 + 3, flags | 1)

ans = 0
dfs(0, 0)
print(ans)


Measured memory_bytes: 2940