akhauriyash/Code-Regression huggingface dataset:
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807


signed main()
{
  string xyz ="";
int x=0,y=0,z=0,w=0,i=0,j=0,n=0;
std::vector<int> v;
rep(i,10){
std::cin >> x;
v.push_back(x);
  }
  sort(rall(v));
rep(i,3){
  std::cout << v[i] << '\n';
}
}



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  string s; std::cin >> s;
  sort(rng(s));
  std::cout << (s == "abc" ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  bool ok = true;
  for(int i=0;i<S.size();++i) {
    if(i%2==0) {
      if(S[i]=='L') ok = false;
    }
    else {
      if(S[i]=='R') ok = false;
    }
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3624
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])


Measured memory_bytes: 147512
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int n;
	cin >> n;

	ld res = 0;
	while(n--) {
		ld x;
		cin >> x;
		res += 1.0/x;
	}

	cout << setprecision(16) << 1.0/res;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 384
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double x, h;
  while (cin >> x >> h, x) {
    cout << prec(8) << x * x + x * hypot(h, x / 2) * 2 << endl;
  }
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    vector< int > a(3);
    cin >> a;

    whole(sort, a);

    cout << (a[0] != a[2] && (a[0] == a[1] || a[1] == a[2]) ? "Yes" : "No") << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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 int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;

  int d,t,s;
  cin >> d >> t >> s;

  Yes( d / s + (d % s > 0) <= t );


  return 0;
}

Measured memory_bytes: 3648
N,K=map(int,input().split())
point=[tuple(map(int,input().split())) for i in range(N)]
point.sort(key=lambda x:x[0])
ans=float('inf')
for i in range(1+N-K):
    for j in range(i+K,N+1):
        x=point[j-1][0]-point[i][0]
        now=point[i:j]
        now.sort(key=lambda x:x[1])
        for k in range(j-i-K+1):
            ans=min(x*(now[k+K-1][1]-now[k][1]),ans)
print(ans)


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

int main() {
  ll N, P;
  cin >> N >> P;
  if (N == 1) {
    cout << P << endl;
    return 0;
  }
  ll ret = 1, M = sqrt(P);
  for (int i = 2; i <= M; i++) {
    int cnt = 0;
    while (P % i == 0) {
      P /= i;
      cnt++;
    }
    if (cnt >= N) {
      ret *= pow(i, (cnt / N));
    }
  }
  cout << ret << endl;
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int abs(int a,int b){
	return (a>b)?a:b;
}
int main(){
	fast_io
	string s; cin>>s;
	int ans=700;
	rep(i,3){
		if(s[i]=='o') ans+=100;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

struct st{int a,b,c,d;};
int a[1000][1000];
int dx[]{0,0,1,-1},dy[]{1,-1,0,0};
int main(){
	int h,w;cin>>h>>w;
	rep(i,h)rep(j,w)scanf("%d",&a[i][j]);
	vector<st>v;
	rep(i,h)rep(j,w){
		if(a[i][j]%2){
			rep(k,4){
				int nx=i+dx[k],ny=j+dy[k];
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&a[nx][ny]%2){
					v.push_back({i,j,nx,ny});a[i][j]--;a[nx][ny]++;goto G;
				}
			}
			rep(k,4){
				int nx=i+dx[k],ny=j+dy[k];
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&nx*w+ny>i*w+j){
					v.push_back({i,j,nx,ny});a[i][j]--;a[nx][ny]++;goto G;
				}
			}
			G:;
		}
	}
	cout<<v.size()<<endl;
	for(auto s:v){
		cout<<s.a+1<<' '<<s.b+1<<' '<<s.c+1<<' '<<s.d+1<<endl;
	}
	//~ cout<<"-----------"<<endl;
	//~ rep(i,h){
		//~ rep(j,w){
			//~ cout<<a[i][j]%2<<' ';
		//~ }
		//~ cout<<endl;
	//~ }
}

Measured memory_bytes: 6128
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,p) for(int i=(a);i<(p);i++)
#define rrep(i,a,p) for(int i=(p)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

int a[4][4] = {
	{ 0,1,2,3 },
	{ 1,0,3,2 },
	{ 2,3,0,1 },
	{ 3,2,1,0 }
};
int b[4][4] = {
	{ 1,1,1,1 },
	{ 1,-1,1,-1 },
	{ 1,-1,-1,1 },
	{ 1,1,-1,-1 }
};
signed main() {
	for (int n; cin >> n&&n;) {
		rep(i, 0, n) {
			int p[4], q[4];
			rep(j, 0, 4)cin >> p[j];
			rep(j, 0, 4)cin >> q[j];

			int ans[4] = {};
			rep(j, 0, 4)rep(k, 0, 4) {
				ans[a[j][k]] += b[j][k] * p[j] * q[k];
			}
			cout << ans[0] << " " << ans[1] << " " << ans[2] << " " << ans[3] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
fun main() {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val wCounts = IntArray(n) { 0 }
    val eCounts = IntArray(n) { 0 }

    for (i in 0 until n) {
        if (s[i] == 'W') {
            wCounts[i] = if (i == 0 ) 1 else wCounts[i - 1] + 1
            eCounts[i] = if (i == 0 ) 0 else eCounts[i - 1]
        } else if (s[i] == 'E') {
            wCounts[i] = if (i == 0 ) 0 else wCounts[i - 1]
            eCounts[i] = if (i == 0 ) 1 else eCounts[i - 1] + 1
        }
    }

    var answer = n
    for (i in 0 until n) {
        val wCount = if (i == 0) 0 else wCounts[i - 1]
        val eCount = eCounts[n - 1] - eCounts[i]
        val tmp = wCount + eCount

        if (tmp < answer) {
            answer = tmp
        }
    }
    print(answer)
}

Measured memory_bytes: 42420
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;


ll A,B,C, ans;



int main() {

	cin >>  A>>B>>C;

	cout << max(ll(0), C - (A - B)) << endl;
	
	



	return 0;
}


Measured memory_bytes: 256
N = int(input())
D = list()
for _ in range(N):
    D.append(tuple(map(int, input().split())))

count_max = 0
for d in D:
    if d[0] == d[1]:
        count_max += 1
    else:
        count_max = 0

    if count_max >= 3:
        print('Yes')
        exit()
else:
    print('No')


Measured memory_bytes: 62500
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;

ll _gcd(ll a, ll b)
{
    if (a == b)
    {
        return a;
    }
    //
    ll a_ = min(a, b);
    ll b_ = max(a, b);
    return _gcd(a_, b_ - a_);
}
ll _lcm(ll a, ll b)
{
    return a * b / _gcd(a, b);
}

//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    //cout << lcm(A, B);
    cout << _lcm(A, B);
    return 0;
}

Measured memory_bytes: 3632
package main

import(
	"fmt"
)

func main(){
	var n int
	fmt.Scan(&n)
	s := make([]string, n)
	for i:=0; i<n; i++ {
		var tmp string
		fmt.Scan(&tmp)
		s[i] = tmp
	}
	resultMap := make(map[string]int)
	for _,v := range s {
		resultMap[v] ++
	}
	fmt.Printf("AC x %d\n", resultMap["AC"])
	fmt.Printf("WA x %d\n", resultMap["WA"])
	fmt.Printf("TLE x %d\n", resultMap["TLE"])
	fmt.Printf("RE x %d\n", resultMap["RE"])
}


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

int main() {
    string s;
    int n;
    int ans = 0;
    
    cin >> s;
    n = s.length();
    
    /*for (int i = 0; i < n; i++) {
        for (int ii = (i - 1); ii >= 0; ii--) {
            if (s[ii] == '9') {
                continue;
            }
            else if (s[ii] != s[i]) {
                s[ii] = s[i] = '9';
                ans += 2;
            }
        }
    }*/
    
    int r = 0;
    int b = 0;
    
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') {
            r++;
        }
        else {
            b++;
        }
    }
    
    ans = n - abs(r - b);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string a;
  cin >> a;
  REP(i, a.size()){
    if(a[i] == '1'){
      a[i] = '9';
    }else if(a[i] == '9'){
      a[i] = '1';
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	string str, sto, stt;
	bool aaa = true;
	cin >> str;
	int n = str.length();

	sto = str.substr(0, ((n - 1) / 2));
	stt = str.substr(((n + 3) / 2) - 1, n - ((n + 3) / 2) + 1);

	for (int i = 0; i < (int)sto.length(); i++) {
		if (sto[i] != sto[sto.length() - i - 1]) {
			aaa = false;
		}
	}

	for (int i = 0; i < (int)stt.length(); i++) {
		if (stt[i] != stt[stt.length() - i - 1]) {
			aaa = false;
		}
	}

	for (int i = 0; i < (int)str.length(); i++) {
		if (str[i] != str[str.length() - i - 1]) {
			aaa = false;
		}
	}
	
	if (aaa) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll cnt = 0;
int N, H, tmpA, tmpB, tmp;
vi a, b;

void solve(){
    while(H > 0){
        // cout << H << endl;

        tmpA = a[a.size()-1];
        if(b.empty())
            tmpB = 0;
        else
            tmpB = b[b.size()-1];

        // cout << tmpA << " " << tmpB << endl;

        if(tmpB >= tmpA){
            H -= tmpB;
            b.pop_back();
            cnt += 1;
        } else {
            tmp =(H+tmpA-1)/tmpA;
            // cout << tmp << endl;
            cnt += tmp;
            H = 0;
        }

        // cout << cnt << endl;
    }

    cout << cnt << endl;
}

int main(){
    cin >> N >> H;
    a.resize(N);
    b.resize(N);
 
    rep(i, N){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    solve();
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<string> board(2);
    rep(i, 2) {
        cin >> board[i];
    }

    vector<int> v;  // v[i] : 0のとき縦(解説のX)、1のとき横(解説のY)
    rep(j, n) {
        if(board[0][j] == board[1][j]) {
            v.push_back(0);    
        }
        else {
            v.push_back(1);
            j++;
        }
    }

    ll ans;
    if(v[0] == 0) {
        ans = 3LL;
    }
    else {
        ans = 6LL;   
    }

    rep(i, v.size()-1) {
        if(v[i] == 0 && v[i+1] == 0) {
            ans *= 2LL;
        }
        else if(v[i] == 1 && v[i+1] == 0) {
            ans *= 1LL;
        }
        else if(v[i] == 0 && v[i+1] == 1) {
            ans *= 2LL;
        }
        else if(v[i] == 1 && v[i+1] == 1) {
            ans *= 3LL;
        }
        ans %= mod;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] H = new int[N];
        boolean[] top = new boolean[N];

        for(int i = 0 ; i < N ; i++){
            H[i] = sc.nextInt();
            top[i] = true;
        }
        
        for(int i = 0 ; i < M ; i++){
            int A = sc.nextInt() -1;
            int B = sc.nextInt() -1;
            
            if(H[A] <= H[B]){
                top[A] = false;
            }
            if(H[A] >= H[B]){
                top[B] = false;
            }
        }

        int ans = 0;
        for(int i = 0 ; i < N ; i++){
            if(top[i]){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 59832
#include <iostream>
#include <queue>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

struct edge {
  int a, b, d;
  bool operator<(const edge e) const {
    return d > e.d;
  }
};

class UnionFind {
  vector<int> a;
public:
  UnionFind(int n) { REP(i, 0, n) a.push_back(i); }
  int find(int i) { return a[i] == i ? i : (a[i] = find(a[i])); }
  bool unite(int i, int j) {
    if(find(i) == find(j)) return false;
    a[find(i)] = find(j);
    return true;
  }
};

int N;
pii X[100000], Y[100000];

int main(void) {
  cin >> N;
  REP(i, 0, N) {
    cin >> X[i].fi >> Y[i].fi;
    X[i].se = i;
    Y[i].se = i;
  }

  sort(X, X + N);
  sort(Y, Y + N);

  priority_queue<edge> q;
  REP(i, 0, N - 1) {
    q.push((edge) { X[i].se, X[i + 1].se, X[i + 1].fi - X[i].fi });
    q.push((edge) { Y[i].se, Y[i + 1].se, Y[i + 1].fi - Y[i].fi });
  }

  UnionFind uf(N);
  ll ans = 0;
  while(q.size()) {
    edge e = q.top();
    q.pop();
    if(uf.unite(e.a, e.b)) ans += e.d;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6516
#include<iostream>
#include<string>
using namespace std;
int main() {
	int h, m, s, x, y;
	cin >> x;
	s = x % 60;
	h = x / 3600;
	y = x / 60;
	m = y % 60;
	cout << h << ":" << m << ":" << s << endl;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	ll n;
	cin >> n;

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

	ll res = 0;
	vector<pair<ll, ll>> bit(61);
	for (int i = 0; i < 61; i++) {
		ll x, y;
		x = y = 0;
		for (int j = 0; j < n; j++) {
			if ((1LL << i) & a[j])
				x++;
			else
				y++;
		}

		res += (((x * y) % INF) * ((1LL << i) % INF)) % INF;
		res %= INF;
	}


	cout << res << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    char a; cin >> a;
    a++;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(c) (c).begin(), (c).end() 
using namespace std;

#define MAX_DAY 100000
#define STOP 20

double dp[MAX_DAY + 1][STOP];
double p[STOP];
double ans[MAX_DAY];

int main()
{	
	int n;
	double sum = 0.;

	p[1] = 1.;
	for(int i = 2; i < STOP; i++)
		p[i] = p[i - 1] / 2.;
	dp[1][1] = 1.;
	for(int i = 1; i <= MAX_DAY; i++) {
		sum += dp[i][1];
		dp[i + 1][2] += dp[i][1]; // get
		for(int j = 2; j < STOP; j++) {
			if(dp[i][j]) {
				sum += dp[i][j] * p[j];
				dp[i + 1][1] += dp[i][j] * (1. - p[j]); // miss
			 	dp[i + 1][j + 1] += dp[i][j] * p[j];	// get
			}
		}
		ans[i] = sum;
	}
	while(cin >> n, n)
		printf("%.8f\n", ans[n]);

	return 0;
}

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

int main() {
    int N;
    string s;
    string ans = "Three";
    cin >> N;
    for(int i = 0;i<N ; i++) {
      cin >> s;
      if(s=="Y"){
        ans = "Four";
        break;
      }
    }
  
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3536
import random
D = int(input())
C = input().split()
C = [int(c) for c in C]
S = []
for i in range(D):
  s = input().split()
  s = [int(j) for j in s]
  S.append(s)
T = [1] * D
def value():
  M = 0
  last = [0] * 26
  for d in range(1,D+1):
    N = 0
    t = T[d-1]
    last[t-1] = d
    #print(last)
    for j in range(26):
      N = N + C[j]*(d-last[j])
    M = M + S[d-1][t-1] - N
  return(M)
Vmax = value()
Q = []
for i in range(10):
  Q.append([random.randint(1,D), random.randint(1,26)])
for i in range(10):
  Tprev = T
  T[Q[i][0]-1] = Q[i][1]
  V = value()
  if V > Vmax:
    Vmax = V
  else:
    T = Tprev
  #print(Vmax)
#print(T)
for t in T:
  print(t)

Measured memory_bytes: 9916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 610;
const ll INF = 2e9+10;

int a, b;
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    //ios_base::sync_with_stdio(false);

    cin >> a >> b;
    cout << 6 - a - b <<endl;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    sort(A.begin(), A.end());

    cout << abs(A[0] - A[N - 1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#define fs first
#define sc second
using namespace std;
const int maxn = 1e5+10;
using pii = pair<int,int>;

int N,M;
int nums[100];
int main(){
    memset(nums,-1,sizeof nums);
    cin>>N>>M;
    while(M--){
        int a,b;
        cin>>a>>b;
        if(nums[a]!=-1 && nums[a]!= b){
            puts("-1");
            return 0;
        }
        nums[a] = b;
    }
    if(N>1 && nums[1] == 0){
        puts("-1");
        return 0;
    }
    if(N>1 && nums[1] == -1){
        cout<<1;
        for(int i =2;i<=N;i++){
            if(nums[i]!=-1) cout<<nums[i];
            else cout<<0;
        }
    }else{
        for(int i = 1;i<=N;i++){
            if(nums[i]!=-1) cout<<nums[i];
            else cout<<0;
        }
    }

    cout<<endl;
    return 0;
}

Measured memory_bytes: 888
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
    }
    println!("{}",
        if a % 2 != 0 && b % 2 != 0 {"Yes"} else {"No" });
}


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

const double EPS = 1e-6;

struct Point{
    double x, y, c;
};

vector<pair<double, double>> intersection(double x1, double y1, double r1, double x2, double y2, double r2){
    /*
    if (r1 < r2){
        swap(x1, x2);
        swap(y1, y2);
        swap(r1, r2);
    }
    */

    double ab = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    double abb = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);

    if (-EPS < (r1 - r2) * (r1 - r2) - abb || abb - ((r1 + r2) * (r1 + r2)) > -EPS)
        return {};
    
    double ad = (r1 * r1 - r2 * r2 + ab * ab) / (2 * ab);
    double x0 = x1 + (x2 - x1) * ad / ab;
    double y0 = y1 + (y2 - y1) * ad / ab;
    double n_x = -(y2 - y1), n_y = x2 - x1;
    double norm = sqrt((n_x * n_x) + (n_y * n_y));
    double cd = sqrt((r1 * r1) - (ad * ad));

    return {{x0 + n_x * cd / norm, y0 + n_y * cd / norm}, {x0 - n_x * cd / norm, y0 - n_y * cd / norm}};
}

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

    int n, k;
    cin >> n >> k;

    vector<Point> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].x >> a[i].y >> a[i].c;

    auto C = [&](double mid){
        vector<double> r(n);
        for (int i = 0; i < n; i++)
            r[i] = mid / a[i].c;

        vector<pair<double, double>> center;
        for (int i = 0; i < n; i++){
            center.push_back({a[i].x, a[i].y});
            for (int j = i + 1; j < n; j++){
                auto v = intersection(a[i].x, a[i].y, r[i], a[j].x, a[j].y, r[j]);

                for (auto k: v)
                    center.push_back(k);
            }
        }
        
        for (auto c: center){
            int cnt = 0;
            for (auto i: a){
                if (mid - i.c * sqrt((c.first - i.x) * (c.first - i.x) + (c.second - i.y) * (c.second - i.y))  > -EPS)
                    cnt += 1;
            }

            if (cnt >= k)
                return true;
        }

        return false;

    };

    double lb = 0.0, ub = 1e9;
    for (int i = 0; i < 100; i++){
        double mid = (lb + ub) / 2;
        if (C(mid))
            ub = mid;
        else
            lb = mid;
    }

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define All(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    string s;
    cin >> s;
    int count = 0;

    int size = s.size();

    rep(i,size){
        if(s[i] != s[size - 1 - i]){
            count++;
            s[size - 1 - i] = s[i];
        }
    }

    cout << count << endl;

    return 0;
}

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

using namespace std;

int main() {
    int n, x = 0;
  	cin >> n;
  	int a[n];
  	for (int i = 0; i < n; i++) {
    	cin >> a[i];
      	x ^= a[i];
    }
  	for (int i = 0; i < n; i++) {
    	cout << (x ^ a[i]) << " ";
    }
  	cout << endl;
  	return 0;
}


Measured memory_bytes: 4300
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int ans=1;
	for(int i=1;i<=sqrt(M);i++){
		if(M%i==0){
			if(M/i>=N)ans=max(ans,i);
			if(i>=N)ans=max(ans,M/i);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;

int main(){

    int i,n,count;
    string s,a,b;  
    cin >> n;
    cin >> s;

    i = 0;
    count = 0;
    while(count < n){
        if(s[i]==s[i+n/2]){
            count++;
        }
        else{
            break;
        }
        i++;
    }

    if(count == n/2){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    printf("\n");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long dp[100010];
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;}
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  long long n, k;
  cin >> n >> k;
  long long a[n];
  rep(i,n)
    cin >> a[i];
  long long ans = INF;
  rep(i,(1<<n)){
    if(bitset<64>(i).count()==k){
      int bit[30];
      rep(j,n)
        bit[j] = (i/(1<<j))%2;
      bool flag = true;
      long long tmp=0, pre = 0;
      rep(j,n){
        if(bit[j]==0)
          chmax(tmp, a[j]);
        if(bit[j]==1){
          if(flag){
            chmax(tmp, a[j]);
            flag = false;
          } else{
            if(a[j]<=tmp){
              tmp++;
              pre += tmp-a[j];
            } else {
              tmp = a[j];
            }
          }
        }
      }
      chmin(ans,pre);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N, M; cin >> N >> M;
    vector<tuple<int, int, int>> v(M); // 市　年　番号
    for (int i = 0; i < M; i++) {
        int P, Y; cin >> P >> Y;
        v[i] = make_tuple(P, Y, i);
    }

    sort(v.begin(), v.end());

    vector<tuple<int, int, int>> id(M); // 番号　市　出来た順
    int cnt = 1;
    id[0] = make_tuple(get<2>(v[0]), get<0>(v[0]), 1);
    for (int i = 1; i < M; i++) {
        if (get<0>(v[i]) == get<0>(v[i-1])) cnt++;
        else cnt = 1;
        id[i] = make_tuple(get<2>(v[i]), get<0>(v[i]), cnt);
    }

    sort(id.begin(), id.end());

    for (int i = 0; i < M; i++) {
        string s = to_string(1000000000000 + (long long)get<1>(id[i]) * 1000000 + get<2>(id[i]));
        for (int i = 1; i <= 12; i++) cout << s[i];
        cout << '\n';
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 5556
import math
import sys
N,Y=[int(x) for x in input().split()]

s = Y%5000//1000
for i in range(s,N+1,5):
    y = Y - i*1000
    n = N - i
    upper = n*10000
    if upper < y:
        print(-1,-1,-1)
        sys.exit()
    j = (upper - y) // 5000
    k = n - j
    if k >=0:
        print(k,j,i)
        sys.exit()
print(-1,-1,-1)


Measured memory_bytes: 3060
#include <iostream>
#include <map>
int main(){
  int n,m,t,i;std::cin>>n>>m;
  long long s=0;
  std::map<int,long long> h;
  while(std::cin>>t)++h[t];
  while(m>0){
    if((--h.end())->second==0){h.erase(--h.end());}
    else{
      i=(--h.end())->first;
      ++h[i/2];
      --h[i];
      --m;
    }
  }
  for(auto&& i:h)s+=i.first*i.second;
  std::cout<<s<<"\n";
}
    

Measured memory_bytes: 6528
using System;
 
namespace A___Harmony
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            if ((a + b) % 2 == 0)
            {
                Console.WriteLine ((a + b) / 2);
            }
            else
            {
                Console.WriteLine ("IMPOSSIBLE");
            }
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();

        if(n>=10){
            System.out.println(r);
        }else{
            System.out.println((100*(10-n))+r);
        }

    }
}

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

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

using namespace std;

int main() {
  int nums[3][3] = {0};
  bool numsCheck[3][3] = {false};

  rep(i, 3) {
    rep(j, 3) {
      cin >> nums[i][j];
    }
  }

  int n;
  cin >> n;
  rep(i, n) {
    int num;
    cin >> num;
    rep(j, 3) {
      rep(k, 3) {
        if (nums[j][k] == num)
          numsCheck[j][k] = true;
      }
    }
  }

  rep(i, 3) {
    bool result = true;
    rep(j, 3) {
      if (numsCheck[i][j] != true) {
        result = false;
        break;
      }
    }
    if (result) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  rep(i, 3) {
    bool result = true;
    rep(j, 3) {
      if (numsCheck[j][i] != true) {
        result = false;
        break;
      }
    }
    if (result) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  if (numsCheck[0][0] && numsCheck[1][1] && numsCheck[2][2]) {
    cout << "Yes" << endl;
  } else if (numsCheck[0][2] && numsCheck[1][1] && numsCheck[2][0]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main() {
int A,B;
cin >> A >> B;
if(A==B){
    cout <<"Draw"; return 0;
}
if(A==2 || B==1){
    cout << "Bob"; return 0;
}
if(B==2 || A==1){
    cout << "Alice"; return 0;
}
if(A>B){
    cout << "Alice"; return 0;
}
else{
    cout << "Bob"; return 0;
}
return 0;
}

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

int n,q,dat[1000000],r;
int N;

void init(int n){
  N=1;
  while(1){
    if(N >= n) return;
    N *= 2;
  }
}

void update(int i,int x){
  i += N-1;
  dat[i] = x;

  while(i>0){
    i=(i-1)/2;
    dat[i] = min(dat[i*2+1],dat[i*2+2]);
  }
}

int find(int s,int t,int k,int l,int r){
  if( t < l || r < s) return MAX;
  if(s <= l && r <= t) return dat[k];
  else{
    int vl = find(s,t,k*2+1,l,(l+r)/2);
    int vr = find(s,t,k*2+2,(l+r)/2+1,r);
    return min(vl,vr);
  }
}

int main(){
  scanf("%d %d",&n,&q);
  init(n);
  for(int i=0;i<2*N-1;i++) dat[i] = MAX;

  int x,y;
  for(int i=0;i<q;i++){
    scanf("%d %d %d",&r,&x,&y);
    if(r == 0){
      update(x,y);
    }
    else{
      printf("%d\n",find(x,y,0,0,N-1));
    }
  }
  return 0;
}



Measured memory_bytes: 4248
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 1005
struct node{
	int to;
	int id;
	node(int a,int b){
		to=a;
		id=b;
	}
	node(){}
};
int n,m;
int tot;
int vis[maxn];
int bh[maxn][maxn][3];
vector<node> e[maxn];
int u[maxn*maxn*2];
int v[maxn*maxn*2];
void dfs(int root,int fa,int b,int f){
	vis[root]=tot;
	bh[fa][root][f]=b;
	int len=e[root].size();
	for(int i=0;i<len;i++){
		if(vis[e[root][i].to]!=tot)
		dfs(e[root][i].to,fa,b,f);
	}
}
void s(int now){
	tot++;
	vis[now]=tot;
	int len=e[now].size();
//	cout<<now<<" "<<len<<endl; 
	for(int i=0;i<len;i++){
		if(vis[e[now][i].to]!=tot)
		dfs(e[now][i].to,now,e[now][i].id,0);
	}
	reverse(e[now].begin(),e[now].end());
	tot++;
	vis[now]=tot;
//	int len=e[now].size();
	for(int i=0;i<len;i++){
		if(vis[e[now][i].to]!=tot)
		dfs(e[now][i].to,now,e[now][i].id,1);
	}	
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u[i],&v[i]);
		e[u[i]].push_back(node(v[i],i));
	}
	for(int i=1;i<=n;i++){
		s(i);
	}
	for(int i=1;i<=m;i++){
		if((bh[u[i]][v[i]][0]!=i||bh[u[i]][v[i]][1]!=i) ^ 0 ^ (bh[v[i]][u[i]][0]!=0)){
			puts("diff");
		}
		else{
			puts("same");
		}
	}
}

Measured memory_bytes: 22272
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> a;
    rep(i,n){
        rep(j,i)a.emplace_back(j+1,i+1);
    }
    int m = a.size();
    vector<vector<int>> v(m);
    vector<int> cnt(m);
    map<pair<int,int>,int> mp;
    rep(i,m)mp[a[i]]=i;
    rep(i,n){
        int x[n-1];
        rep(j,n-1)cin>>x[j];
        rep(j,n-2){
            v[mp[minmax(i+1,x[j])]].push_back(mp[minmax(i+1,x[j+1])]);
            cnt[mp[minmax(i+1,x[j+1])]]++;
        }
    }
    queue<int> q;
    rep(i,m){
        if(!cnt[i])q.push(i);
    }
    vector<int> ans;
    while(q.size()){
        int x = q.front();q.pop();
        ans.push_back(x);
        for(auto e:v[x]){
            if(--cnt[e]==0)q.push(e);
        }
    }
    if(ans.size()!=m){
        cout<<-1<<endl;
        return 0;
    }
    int sum = 1;
    vector<int> used(n+1);
    for(auto e : ans){
        if(used[a[e].first]||used[a[e].second]){
            ++sum;
            rep(i,n+1)used[i]=0;
        }
        used[a[e].first]=used[a[e].second]=1;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 70636
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
if 0 in A:
    print(sum([abs(x) for x in A]))
    exit()
minus = [x for x in A if x < 0]
if len(minus) % 2 == 0:
    print(sum([abs(x) for x in A]))
else:
    absolute = sorted([abs(x) for x in A])
    print(sum(absolute) - 2 * absolute[0])


Measured memory_bytes: 14332
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9


int main() {
    int N, cnt2 = 0, cnt4 = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a % 4 == 0)cnt4++;
        else if (a % 2 == 0)cnt2++;
    }

    bool ok = true;
    int n = N - cnt2 - cnt4;
    if (n + (bool)cnt2 > cnt4 + 1)ok = false;

    cout << ((ok) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

from collections import deque
N = INT()
A = LI()
A.sort()

while True:
    mod = A[0]
    flg = True
    ans = A[0]
    tmp = deque([A[0]])
    
    if ans == 1:
        print(ans)
        break
    
    for i in range(1, len(A)):
        A[i] %= mod

        if A[i] != 0 and flg:
            flg = False
        
        if A[i] == 0:
            continue
        tmp.append(A[i])
        
    if flg:
        print(ans)
        break
    
    A = sorted(tmp)

Measured memory_bytes: 91532
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> ans(q), a(n);
    char pre=s[0];
    int c = 0;
    rrep(i,n-1){
        if(pre =='A'&& s[i]=='C')a[i] = ++c;
        else a[i] = c;
        pre=s[i];
    }

    rep(i,q){
        int l,r;
        cin >> l>>r;
        --l;--r;
        ans[i] = a[r] - a[l];
    }
    rep(i,q){
        cout << ans[i]<<endl;
    }
    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  string B[n];
  for(int i=0;i<n;i++) cin >> B[i];
  int m;
  cin >> m;
  string C[m];
  for(int i=0;i<m;i++)cin >> C[i];
  int A=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int k=0;k<n;k++){if(B[i]==B[k]) sum++;}
    for(int l=0;l<m;l++){if(B[i]==C[l]) sum--;} 
    A=max(A,sum);
  }
   cout << A <<endl;
  }
  

Measured memory_bytes: 3632
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
n = ni()
ans = [0]*n
def f(x,y,z):
    return x**2 + y**2+ z**2 +x*y+y*z+z*x
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            s = f(x,y,z)
            if  s<=n:
                ans[s-1] +=1
for i in range(n):
    print(ans[i])


Measured memory_bytes: 9460
n=gets.to_i
a=gets.split.map &:to_i
lcm=a[0].lcm(a[1])
for i in 2..n-1 do
  lcm=lcm.lcm(a[i])
end
lcm-=1; ans=0
n.times do|i|
  ans+=lcm%a[i]
end
puts ans


Measured memory_bytes: 11428
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
class union_find{
  int n;
  vector<int> par,rk,size;
  public:
  union_find(int max_n){
    n = max_n+1;
    for(int i=0;i<=n;i++){
      par.emplace_back(i);
      rk.emplace_back(0);
      size.emplace_back(1);
    }
  }
  int root(int x){
    vector<int> nodes;
    while(x!=par[x]){
      nodes.emplace_back(x);
      x = par[x];
    }
    for(auto v:nodes){
      par[v] = x;
    }
    return x;
  }
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x==y) return;
    if(rk[x]<rk[y]){
      par[x] = y;
      size[y] += size[x];
    }else{
      par[y] = x;
      if(rk[x]==rk[y]) rk[x]++;
      size[x] += size[y];
    }
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int treesize(int x){
    return size[root(x)];
  }
};
signed main(){
  init_io();
  ll n,m,ans=0;
  cin >> n >> m;
  vector<ll> a(m),b(m);
  union_find uf(n);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    uf.unite(a[i],b[i]);
  }
  for(int i=0;i<n;i++){
    ans = max(ans,(ll)uf.treesize(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 8960