akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N;
        double[] A;

        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            A = new double[N];
            for (int i = 0; i < N; ++i) A[i] = in.nextInt();
            double ans = 0;
            for (int i = 0; i < N; ++i) ans += 1/A[i];
            out.println(1/ans);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x,y,z;
  cin >> x >> y >> z;

  swap(x,y);
  swap(x,z);

  cout << x << " " << y << " " << z << endl;

  return 0;
}


Measured memory_bytes: 888
import numpy as np


def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]


n, d = map(int, input().split())

num = list(range(1, n+1))
aji = list(range(d, d+n))

aji.pop(aji.index(getNearestValue(aji, 0)))

print(sum(aji))

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

typedef vector<int> vi;

typedef long long ll;
struct RollingHash {
	static const ll mo0 = 1000000007, mo1 = 1000000009;
	static ll mul0, mul1;
	static const ll add0 = 1000010007, add1 = 1003333331;
	static vector<ll> pmo[2];
	vector<int> s; int l; vector<ll> hash_[2];
	void init(vector<int> s) {
		this->s = s; l = s.size(); int i, j;
		hash_[0] = hash_[1] = vector<ll>(1, 0);
		if (!mul0) mul0 = 10009 + (((ll)&mul0) >> 5) % 259, mul1 = 10007 + (((ll)&mul1) >> 5) % 257;
		if (pmo[0].empty()) pmo[0].push_back(1), pmo[1].push_back(1);
		for (int i = 0; i < l; i++) hash_[0].push_back((hash_[0].back()*mul0 + add0 + s[i]) % mo0);
		for (int i = 0; i < l; i++) hash_[1].push_back((hash_[1].back()*mul1 + add1 + s[i]) % mo1);
	}
	pair<ll, ll> hash(int l, int r) { // s[l..r]
		if (l>r) return make_pair(0, 0);
		while (pmo[0].size()<r + 2)
			pmo[0].push_back(pmo[0].back()*mul0%mo0), pmo[1].push_back(pmo[1].back()*mul1%mo1);
		return make_pair((hash_[0][r + 1] + (mo0 - hash_[0][l] * pmo[0][r + 1 - l] % mo0)) % mo0,
			(hash_[1][r + 1] + (mo1 - hash_[1][l] * pmo[1][r + 1 - l] % mo1)) % mo1);
	}
};
vector<ll> RollingHash::pmo[2]; ll RollingHash::mul0, RollingHash::mul1;

int main()
{
	string T, P;
	cin >> T >> P;

	if (T.length() < P.length()) return 0;

	RollingHash HashT, HashP;

	vi VT(T.length());
	rep(i, 0, T.length()) VT[i] = T[i] - 'a';
	HashT.init(VT);

	vi VP(P.length());
	rep(i, 0, P.length()) VP[i] = P[i] - 'a';
	HashP.init(VP);

	rep(i, 0, T.length() - P.length() + 1)
	{
		auto t = HashT.hash(i, i + P.length() - 1);
		auto p = HashP.hash(0, P.length() - 1);
		//if (t == p) cout << T.substr(i, P.length()) << endl;
		if (t == p) cout << i << endl;
	}
}

Measured memory_bytes: 49304
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdlib>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n,m,p;

  while(1){
    cin>>n>>m>>p;
    if(n==0&&m==0&&p==0)break;

    int sum=0,point;

    for(int i=1;i<=n;i++){
      int x;
      cin>>x;
      sum+=x;
      if(i==m)point=x;
    }
    int per=(100-p);
    sum=sum*per;
    if(debug)cout<<"sum:"<<sum<<" "<<"point:"<<point<<"   "<<"per:"<<per<<endl;
    if(point==0)cout<<0<<endl;
    else cout<<sum/point<<endl;
  }

  return 0;  
}

Measured memory_bytes: 2960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 50;
int n;
ll a[maxn];
map<ll, ll> mp;
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a, a + n);
    ll gcd = a[0];
    for(int i = 1;i < n;i++){
        gcd = __gcd(gcd, a[i]);
    }
    bool ok = true;
    for(int i = 0;i < n;i++){
        ll now = a[i];
        ll sq = sqrt(a[i]);
        for(ll j = 2;j <= sq;j++){
            if(now % j == 0LL){
                if(mp[j] || mp[now / j]){
                    ok = false;
                    break;
                }
                mp[j] = 1;
                mp[now / j] = 1;
            }
        }
        mp[now] = 1;
        
    }
    if(ok) cout << "pairwise coprime\n";
    else if(gcd == 1LL) cout << "setwise coprime\n";
    else cout << "not coprime\n";
    return 0;
}

Measured memory_bytes: 73724
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <random>
#include <chrono>

using namespace std;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define per(i, a, n) for (int i = n - 1; i >= a; --i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef int64_t i64;
typedef uint64_t ui64;
typedef pair<int, int> pi;

struct custom_hash {
    static ui64 splitmix64(ui64 x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(ui64 x) const {
        static const ui64 FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T, class U>
inline ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
template <class T, class U>
inline istream& operator>>(istream& os, pair<T, U>& p) {
    os >> p.first >> p.second;
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
    if (v.empty())
        return os;
    if (v.begin() != v.end())
        os << v.front();
    for (auto it = ++v.begin(); it != v.end(); ++it)
        os << ' ' << *it;
    return os;
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
    for (auto& i : v)
        is >> i;
    return is;
}

template <class T, size_t N>
inline istream& operator>>(istream& is, array<T, N>& a) {
    for (auto& i : a)
        is >> i;
    return is;
}

inline void Solve(istream& is, ostream& os) {
    int n, _;
    is >> n >> _;
    string s;
    while (n--) {
        is >> s;
        os << s << '\n' << s << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << setprecision(20) << fixed;
    Solve(cin, cout);
    return 0;
}


Measured memory_bytes: 256
N,M=list(map(int,input().split()))
ans=0
l=[]
for i in range(M):
   a,b=(map(int,input().split()))
   l.append((a,b))
l.sort(key=lambda x:x[1])
cut=-1
for i,j in l:
   if cut>=i:
      continue
   else:
      ans+=1
      cut=j-1
print(ans)

Measured memory_bytes: 23844
//Gvs Akhil (Vicennial)
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int N=1000006;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T> T power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
int v[N],f[N];
int32_t main(){
	sync;
	int n; cin>>n;
	rep(i,1,n+1) cin>>v[i],f[i]=v[i]+f[i-1];
	int mini=LLINF;
	rep(i,1,n){
		int a=f[i],b=f[n]-f[i];
		mini=min(mini,abs(a-b));
	}
	cout<<mini;
}



Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

void solve() {
  int a[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> a[i][j];
    }
  }
  int tmp[10][10];
  for (int i = 0; i < 1 << 10; i++) {
    memset(tmp, 0, sizeof(tmp));
    for (int j = 0; j < 10; j++) {
      if (i >> j & 1) tmp[0][j] = 1;
    }
    for (int j = 0; j + 1 < 10; j++) {
      for (int k = 0; k < 10; k++) {
        int sum = tmp[j][k];
        for (int l = 0; l < 4; l++) {
          int ny = j + dy[l], nx = k + dx[l];
          if (ny >= 0 && ny < 10 && nx >= 0 && nx < 10) sum += tmp[ny][nx];
        }
        if ((sum + a[j][k]) % 2 == 0) continue;
        tmp[j + 1][k] = 1;
      }
    }
    int tmp2[10][10];
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        tmp2[j][k] = tmp[j][k];
        for (int l = 0; l < 4; l++) {
          int ny = j + dy[l], nx = k + dx[l];
          if (ny >= 0 && ny < 10 && nx >= 0 && nx < 10) (tmp2[j][k] += tmp[ny][nx]) %= 2;
        }
      }
    }
    bool ng = false;
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        ng |= tmp2[j][k] != a[j][k];
      }
    }
    if (ng) continue;
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        cout << tmp[j][k] << " \n"[k + 1 == 10];
      }
    }
    return;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V< P<ll, ll> > hp(n);
    for (int i = 0; i < n; i++) cin >> hp[i].first >> hp[i].second;
    sort(ALL(hp), [&](P<ll, ll> i, P<ll, ll> j) {
        return i.first + i.second < j.first + j.second;
    });
    vll dp(n + 2, HIGHINF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = n; j > 0; j--) {
            if (dp[j - 1] <= hp[i].first) {
                chmin(dp[j], dp[j - 1] + hp[i].second);
            }
        }
    }
    // DEBUG_VLL(dp)
    for (int i = 1; i <= n + 1; i++) {
        if (dp[i] == HIGHINF) {
            cout << i - 1 << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3768
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
 
    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
 
            int N = in.nextInt();
            for (int i = 0; i < N; i++) {
                long A = in.nextLong();
                long B = in.nextLong();
 
                long a = Math.min(A, B);
                long b = Math.max(A, B);
 
                long ans = 2L * (a - 1) + przedzial(a, b);
 
                out.println(ans);
            }
        }
 
        private long przedzial(long a, long b) {
            if (a == b || a + 1 == b) {
                return 0;
            }
 
            return 1L + szukaj(a + 1, b - 2, a * b);
        }
 
        private long szukaj(long a, long b, long LIMIT) {
            if (a > b) return 0;
            if (a == b) {
                return a * b < LIMIT ? 1 : 0;
            }
            long lo = a, hi = b;
            while (lo + 1 < hi) {
                long m = lo + (hi - lo) / 2;
                if (m * m >= LIMIT) {
                    hi = m;
                } else {
                    lo = m;
                }
            }
            long ans1 = 1 + 2L * (lo - 1 - a + 1);
            long ans2 = 0;
            if (lo * (lo + 1) < LIMIT) {
                ans2 = 2L * (lo - a + 1);
            }
            return Math.max(ans1, ans2);
        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

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

using ll = long long;
using ull = unsigned long long;
const ll INF = 4e18;
const ll MOD = 1e9+7;

int a[13] = {};
bool used[24] = {};

int f(int n) {
  if (n == 13) {
    int ans = 24;
    int cnt = 1;
    for (int i = 1; i <= 24; i++) {
      if (used[i%24] == 0) cnt++;
      else {
        ans = min(ans, cnt);
        cnt = 1;
      }
    }
    return ans;
  }

  if (n == 0)
    if (a[0] != 0) return 0;
    else {used[0] = 1; return f(n+1);}
  if (n == 12)
    if (a[12] > 1) return 0;
    else {used[12] = a[12]; return f(n+1);}

  if (a[n] >= 3) return 0;
  else if (a[n] == 2) {
    used[n] = used[24-n] = 1;
    return f(n+1);
  } else if (a[n] == 1) {
    int ans = 0;
    used[n] = 1;
    ans = max(ans, f(n+1));
    used[n] = 0;
    used[24-n] = 1;
    ans = max(ans, f(n+1));
    used[24-n] = 0;
    return ans;
  } else {
    return f(n+1);
  }
}

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

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    a[d]++;
  }
  cout << f(0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	ll N;
  	cin>>N;
  
  	int a[N];
  	rep(i,N) cin>>a[i];
  	int count=0;
  
  	rep(i,N) if(a[i]%2==1 &&(i+1)%2==1) count++;
  	
  	
  	
  
  	cout<<count<<endl;
}

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

t_list = [0]
x_list = [0]
y_list = [0]

for i in range(n):
    t,x,y = map(int,input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)
    
for i in range(1,n+1):
    t_margin = t_list[i] - t_list[i-1]
    x_margin = abs(x_list[i] - x_list[i-1])
    y_margin = abs(y_list[i] - y_list[i-1])
    t_temp = t_margin%2
    xy_temp = (x_margin+y_margin)%2
    if (t_temp != xy_temp) or (t_margin < x_margin + y_margin):
        print("No")
        break
else:
    print("Yes")

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

int main(){
    int max = 1e9+10;
    vector<int> A;
    string ans = "YES";
    int N;
    cin >> N;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        A.push_back(x);
    }
    std::sort(A.begin(), A.end());
    for (int i=0; i<N-1; i++) {
        if (A[i]==A[i+1]) {
            ans = "NO";
        }
    }

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


Measured memory_bytes: 1400
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct lazysegtree{
	function<T(T,T)>calcfn,lazycalcfn;
	function<T(T,T,unsigned int)>updatefn;
	int n;
	T defvalue,lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	lazysegtree(int n_=0,T defvalue_=0,
		function<T(T,T)>calcfn_=[](T a,T b){return a+b;},
		function<T(T,T)>lazycalcfn_=[](T a,T b){return a+b;},
		function<T(T,T,unsigned int)>updatefn_=[](T a,T b,unsigned int width){return a+b*width;},
		T lazydefvalue_=0
	):defvalue(defvalue_),lazydefvalue(lazydefvalue_),
		calcfn(calcfn_),lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
		lazy.assign(2*n-1,lazydefvalue);
		lazyflag.assign(2*n-1,false);
	}
	void copy(vector<T>v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
	}
	void eval(int i,int l,int r)
	{
		if(lazyflag[i])
		{
			dat[i]=updatefn(dat[i],lazy[i],r-l);
			if(r-l>1)
			{
				lazy[2*i+1]=lazycalcfn(lazy[2*i+1],lazy[i]);
				lazy[2*i+2]=lazycalcfn(lazy[2*i+2],lazy[i]);
				lazyflag[2*i+1]=lazyflag[2*i+2]=true;
			}
			lazy[i]=lazydefvalue;
			lazyflag[i]=false;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=lazycalcfn(lazy[k],x);
			lazyflag[k]=true;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=calcfn(dat[2*k+1],dat[2*k+2]);
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return defvalue;
		else if(a<=l&&r<=b)return dat[k];
		else return calcfn(
			query(a,b,2*k+1,l,(l+r)/2),
			query(a,b,2*k+2,(l+r)/2,r)
		);
	}
};
main()
{
	int n,q;cin>>n>>q;
	lazysegtree<int>S(n,2147483647,[](int a,int b){return a==2147483647?b:a;},[](int a,int b){return b;},[](int a,int b,unsigned int c){return b;});
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c)
		{
			int s;cin>>s;
			cout<<S.query(s,s+1)<<endl;
		}
		else
		{
			int s,t,x;cin>>s>>t>>x;
			S.update(s,t+1,x);
		}
	}
}


Measured memory_bytes: 4952
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(i64, N, M);
    priority_queue<i64> pq;

    rep(i, N) {
        var(i64, a);
        pq.emplace(a);
    }

    rep(i, M) {
        i64 x = pq.top(); pq.pop();
        pq.push(x / 2);
    }

    i64 sum = 0;
    rep(i, N) {
        sum += pq.top(); pq.pop();
    }

    print(sum);


    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N;
vector<Int> A;

Int used[200010][100];
Int mem[200010][100];
Int dfs(Int idx, Int passed, Int num){
  if(idx >= N) return num < N/2? -INF: 0;
  if(num + (N - idx + 1) / 2 < N/2) return -INF;
  if(used[idx][passed]++) return mem[idx][passed];
  Int a = dfs(idx + 2, passed, num + 1) + A[idx];
  Int b = dfs(idx + 1, passed + 1, num);
  Int res = max(a, b);
  return mem[idx][passed] = res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>N;
  A.resize(N);
  cin>>A;

  Int ans = dfs(0, 0, 0);
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 321924
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;

int main(){
    int N;
    cin>>N;
    vector<int>X(N);
    int sum=0,mini=100*100*100;
    int maxi=0;
    rep(i,N){
        cin>>X[i];
        maxi=max(maxi,X[i]);
    }
    rep(i,maxi+1){
        rep(j,N){
            sum+=(X[j]-i)*(X[j]-i);
        }
        mini=min(mini,sum);
        sum=0;
    }
    cout<<mini<<endl;

    return 0;
}

Measured memory_bytes: 3588
N = int(input())
A = [int(input()) for _ in range(N)]

now = 2
ans = 0
for i, a in enumerate(A):
    if i == 0:
        ans += a - 1
    else:
        if a > now:
            ans += (a - 1) // now
        elif a == now:
            now = a + 1
print(ans)


Measured memory_bytes: 7120
#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
template<class T> il T Max(T a,T b){return a>b?a:b;}
template<class T> il T Min(T a,T b){return a<b?a:b;}
int a,b,c;
int main(){
    a=rd(),b=rd(),c=rd(),rt(Max(c-(a-b),0));
    return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
    while(!isdigit(c=gc())&&c!='-');
    int f=c=='-'?c=gc(),1:0,x=c^48;
    while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
    return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

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

#define int long long
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define fs first
#define sc second
#define mpr make_pair
#define iter iterator
#define all(X) X.begin(),X.end()
#define sau(X) sort(all(X)),X.resize(unique(all(X))-X.begin())
#define exist(X,ele) binary_search(all(X),ele)
#define y0 I_love_Ryougi_Shiki_0
#define y1 I_love_Ryougi_Shiki_1

template<typename T1,typename T2>
ostream& operator << (ostream& out,const pair<T1,T2>& X)
{
	out<<"{"<<X.fs<<","<<X.sc<<"}";
	return out;
}

template<typename T>
ostream& operator << (ostream& out,const vector<T>& X)
{
	for(auto i:X) out<<i<<" ";
	return out;
}

template<typename T>
inline void cmin(T& x,T y)
{
	if(!(x<y)) x=y;
}

template<typename T>
inline void cmax(T& x,T y)
{
	if(x<y) x=y;
}

const int inf=5000000000000000ll;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

int N;
int px[555*555],py[555*555];
bool a[555][555];
int d[555][555];

bool vis[555][555];
vector<pii> vq;

void upd(int x,int y)
{
	vector<bool> to(4,false);
	for(int RDi=0;RDi<4;RDi++)
	{
		int nx=x+dx[RDi],ny=y+dy[RDi];
		if(nx<0 || nx>=N || ny<0 || ny>=N) continue;
		
		if(d[nx][ny]>d[x][y]+a[nx][ny])
		{
			d[nx][ny]=d[x][y]+a[nx][ny];
			to[RDi]=true;
		}
	}
	for(int RDi=0;RDi<4;RDi++)
	{
		int nx=x+dx[RDi],ny=y+dy[RDi];
		if(nx<0 || nx>=N || ny<0 || ny>=N) continue;
		
		if(!to[RDi] || vis[nx][ny]) continue;
		vis[nx][ny]=true;
		vq.pb(mpr(nx,ny));
		upd(nx,ny);
	}
}

main()
{
	ios::sync_with_stdio(false);
	
	cin>>N;
	for(int i=0;i<N*N;i++)
	{
		int t; cin>>t;
		px[i]=(t-1)/N;
		py[i]=(t-1)%N;
	}
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			a[i][j]=true;
			d[i][j]=min(min(i,j),min(N-1-i,N-1-j))+1;
		}
	}
	int ans=0;
	for(int t=0;t<N*N;t++)
	{
		int x=px[t],y=py[t];
		ans+=d[x][y]-1;
		
		d[x][y]--;
		a[x][y]=false;
		vis[x][y]=true;
		vq.pb(mpr(x,y));
		upd(x,y);
		for(auto i:vq) vis[i.fs][i.sc]=false;
		vq.clear();
		
//		cout<<"{"<<x<<","<<y<<"} "<<ans<<endl;
//		for(int i=0;i<N;i++)
//		{
//			for(int j=0;j<N;j++)
//			{
//				cout<<setw(3)<<left<<d[i][j];
//			}
//			cout<<endl;
//		}
//		cout<<endl;
	}
	cout<<ans<<endl;
	
	return 0;
}






















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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n, mis = 0;
	cin >> n;
	
	for (int i = 1; i <= n; ++i) {
		int tmp;
		cin >> tmp;
		if (tmp != i) ++mis;
	}
	
	if (mis <= 2) cout << "YES\n";
	else cout << "NO\n";
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



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

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int,int64_t>> edges[100000];
    for(int i=0;i<m;++i){
        int l, r, c;
        cin >> l >> r >> c;
        edges[l-1].emplace_back(r-1, c);
    }
    for(int i=1;i<n;++i) edges[i].emplace_back(i-1, 0);

    priority_queue<pair<int64_t,int>> q;
    q.emplace(0, 0);
    bool checked[100000] = {0};
    while(!q.empty()){
        auto t = q.top();
        q.pop();
        if(checked[t.second]) continue;
        checked[t.second] = true;
        if(t.second == n-1){
            cout << (-t.first) << endl;
            return 0;
        }
        for(auto to : edges[t.second]){
            if(checked[to.first]) continue;
            q.emplace(t.first-to.second, to.first);
        }
    }
    cout << -1 << endl;

    return 0;
}

/*

*/


Measured memory_bytes: 9588
#include <iostream>
#include <vector>

using namespace std;

int binarySearch(int x, vector<int> &s)
{
	int min, max, mid;
	min = 0;
	max = s.size();
	while (min < max)
	{
		mid = (max + min) / 2;
		if (s[mid] == x)
		{
			return 1;
		}
		else if (x < s[mid])
		{
			max = mid;
		}
		else
		{
			min = mid + 1;
		}
	}
	return 0;
}

int main()
{
	int n;
	cin >> n;
	vector<int> s(n);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	int q;
	cin >> q;
	vector<int> t(n);
	for (int i = 0; i < q; i++)
	{
		cin >> t[i];
	}
	int count = 0;
	for (int i = 0; i < q; i++)
	{
		count += binarySearch(t[i], s);
	}
	cout << count << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

inline double prod(int x1, int y1, int x2, int y2) {
  return x1 * y2 - x2 * y1;
}

int main() {
  int N;
  int count = 1;
  while (cin >> N) {
    if (N == 0) break;
    double area = 0;
    int x0, y0;
    cin >> x0 >> y0;
    int x1, y1;
    cin >> x1 >> y1;
    int x2, y2;
    for (int i = 0; i < N-2; i++) {
      cin >> x2 >> y2;
      area += prod(x2-x0, y2-y0, x1-x0, y1-y0);
      x1 = x2; y1 = y2;
    }
    printf("%d %.1f\n", count, fabs(0.5 * area));
    count++;
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%2019;
        a=a*a%2019;
        x>>=1;
    }
    return res;
}
int main(){
    string s;cin>>s;
    int n=(int)s.size();
    vector<ll> dp(n+1,0),cnt(2019,0);
    for(int i=0;i<n;i++){
        dp[i+1]=(dp[i]+(ll)(s[n-1-i]-'0')*power(10,i))%2019;
        cnt[dp[i+1]]++;
    }
    cnt[0]++;
    ll ans=0;
    for(int i=0;i<2019;i++){
        ans+=cnt[i]*(cnt[i]-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  
const int N = 3e5 + 5;
map<pair<int,int>, int> dict;
int h, w, m;
int x[N], y[N];

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
	cin >> h >> w >> m;
	vector<pair<int,int>> v(m);    
	for(int i=0;i<m;i++)
	{
		cin >> v[i].first >> v[i].second;
		x[v[i].first]++;
		y[v[i].second]++;
		dict[{v[i].first, v[i].second}] = 1LL;
	}
	int mx_x = *max_element(x+1, x+h+1);
	int mx_y = *max_element(y+1, y+w+1);
	vector<int> X, Y;
	for(int i=1;i<=h;i++) if(x[i] == mx_x) X.pb(i);
	for(int i=1;i<=w;i++) if(y[i] == mx_y) Y.pb(i);
	int ans = 0;
	for(int i:X)
	{
		for(int j:Y)
		{
			int z = 0;
			if(dict.find({i, j}) != dict.end()) z = 1;
			ans = max(ans, x[i] + y[j] - z);
			if(z == 0)
			{
				cout << ans << "\n";
				return 0;
			}
		}
	}
	// for(int i=1;i<=h;i++)
	// {
	// 	for(int j=1;j<=w;j++)
	// 	{
	// 		int z = 0;
	// 		if(dict.find({i, j}) != dict.end()) z = 1;
	// 		ans = max(ans, x[i] + y[j] - z);
	// 	}
	// }
	cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 39712
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int h = s / 3600;
        int m = s % 3600 / 60;
        s = s % 60;
        System.out.println(h + ":" + m + ":" + s);

    }
}


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

int main() {
    int n;
    cin >> n;
    if (n <1200) {
        cout << "ABC" << endl;
    }
    else if (n < 2800) {
        cout << "ARC" << endl;
    }
    else cout << "AGC" << endl;
}


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

using namespace std;

int main(){
	int h,w,n;
	cin>>h>>w>>n;
	int sum=0,count=0;
	while(sum<n){
		sum+=max(h,w);
		if(w>h){
			h--;
		}
		else{
			w--;
		}
		count++;
	}
	cout<<count;
}

Measured memory_bytes: 256
n, sum = gets.split.map(&:to_i)
x_answer = -1
y_answer = -1
z_answer = -1

(0..n).each do |x|
  (0..n-x).each do |y|
    z = n - x - y
    next unless x + y + z == n
    if sum == 10000*x + 5000*y + 1000*z
      x_answer = x
      y_answer = y
      z_answer = z
    end
  end
end

print "#{x_answer} #{y_answer} #{z_answer}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(void){
    long long int q,h,s,d,n,ans=0,k;
    cin>>q>>h>>s>>d>>n;
    n*=4;
    vector<pair<int,int>> list(4);
    list[0]=make_pair(8*q,1);
    list[1]=make_pair(4*h,2);
    list[2]=make_pair(2*s,4);
    list[3]=make_pair(d,8);
    sort(list.begin(),list.end());
    for(i=0;i<4;i++){
        k=n/list[i].second;
        n=n%list[i].second;
        if(list[i].second==1)ans+=k*q;
        if(list[i].second==2)ans+=k*h;
        if(list[i].second==4)ans+=k*s;
        if(list[i].second==8)ans+=k*d;
    }
    cout<<ans<<endl;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N, K;
	cin >> N >> K;
	vector<int>s;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		s.push_back(a);
	}
	sort(s.begin(), s.end(),greater<int>());
	int ab = 10000000010;
	for (int i = 0; i + K-1 < N; i++) {
		ab = min(ab, s[i] - s[i + K-1]);
	}
	cout << ab;
}

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

using namespace std;

int main()
{
    int n,m,a[10004];
    cin>>n>>m;
    int sum =0;
    for(int i=0; i<m; i++)cin>>a[i];
    for(int i=0; i<m; i++)sum += a[i];
    if(sum>n)cout<<-1<<endl;
    else cout<<n-sum<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>


using namespace std;

int enzan(int a,int b,int c){
	if(c==0){return a+b;}
	return a-b;
}
int main() {
	string s;
	cin>>s;

	string admi = "+-";
	int n=0;
	for(int i=0;i<2;++i){
		int j=enzan(s[0]-'0',s[1]-'0',i);
		for(int k=0;k<2;++k){
			int l=enzan(j,s[2]-'0',k);
			for(int m=0;m<2;++m){
				n=enzan(l,s[3]-'0',m);
				if(n==7){
					cout<<s[0]<<admi[i]<<s[1]<<admi[k]<<s[2]<<admi[m]<<s[3]
					<<"=7"<<endl;
					break;
				}
			}
		if(n==7)break;
		}
	if(n==7)break;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>

using namespace std;

int main(int argc, char const* argv[]) {
	uint64_t x;

	cin >> x;

	uint64_t c = 0;
	uint64_t m = 100;

	while (m < x) {
		m += m / 100;
		c++;
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0,c - (a - b));
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, X;
    cin >> N >> X;
    vll A(N);
    rep(i, N)cin >> A[i];

    ll ans = 0;
    if(A[0] > X) {
        ans += A[0] - X;
        A[0] = X;
    }

    rep(i, N - 1) {
        ll d = A[i] + A[i + 1] - X;
        if(d > 0) {
            ans += d;
            A[i + 1] -= d;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>

using namespace std;

int main(){
  string S; cin >> S;
  int length = (int)S.length();
  
  if(S.at(0) != 'A'){
    cout << "WA" << endl;
  }else{
    int cnt = 0;
    int idx; 
    for (int i = 2; i < length - 1; ++i){
      if(S.at(i) == 'C'){
        cnt++;
        idx = i;
      }
    }
    if(cnt != 1){
      cout << "WA" << endl;
    }else{
      S.erase(S.begin());
      S.erase(S.begin() + idx - 1);
      string S2 = S;
      transform(S.begin(),S.end(),S.begin(),::tolower);
      if(S != S2) cout << "WA" << endl;
      else cout << "AC" << endl;
    }
  }
}


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

int main()
{
	long long a, b, x;
	scanf("%lld%lld%lld", &a, &b, &x);
	if (!a)
		printf("%lld\n", b / x + 1);
	else
		printf("%lld\n", b / x - (a - 1) / x);

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val d = (0 until n).map { sc.next().toInt() }
    println(problem143b(n, d))
}

fun problem143b(n: Int, d: List<Int>): Int {
    var ans = 0
    for (i in 0 until n) {
        for (j in i until n) {
            if (i != j) {
                ans += d[i] * d[j]
            }
        }
    }
    return ans
}

Measured memory_bytes: 31392
//
//  main.cpp
//  Atcoder(Oct.6ABC)
//
//  Created by Hajime Sakamoto on 2018/10/06.
//  Copyright © 2018 Hajime Sakamoto. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    int N;
    int A,B;
    
    cin>>N;
    
    
    if (N==1){
    std::cout << "Hello World\n";
    return 0;
    }
    
    else if (N==2){
        cin>>A>>B;
        cout<<A+B<<endl;
        return 0;
        
    }
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

struct st{int left,height;};
int solveMaxRectangle(vector<int> v){
	v.pb(0);
	int maxi = 0;
	stack<st> stk;
	rep(i,v.size()){
		int left = i;
		while( stk.size()>0 && stk.top().height>=v[i] ){
			int w = i - stk.top().left;
			maxi = max(maxi,w*stk.top().height);
			left = stk.top().left;
			stk.pop();
		}
		stk.push(st{left,v[i]});
	}
	return maxi;
}


int main(){
	int h,w;
	cin>>h>>w;
	
	vector<vector<int>> v(h,vector<int>(w));
	rep(i,h) rep(j,w) cin>>v[i][j];
	rep(i,h) rep(j,w) v[i][j] = !v[i][j];
	
	static int dp[1500][1500];
	rep(i,1500)rep(j,1500)dp[i][j]=0;
	
	rep(i,w)dp[0][i] = v[0][i];
	for(int i=1;i<h;i++){
		rep(j,w){
			if(v[i][j]!=0)dp[i][j] = dp[i-1][j]+v[i][j];
		}
	}
 
	int ans = 0;
	rep(i,h){
		vector<int> v(dp[i],dp[i]+1500);
		ans = max(ans,solveMaxRectangle(v));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 19440