akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i++)
#define re0(i, n) for (rint i = 0; i < (int) n; i++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template <class T> inline void read(T &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = getchar());
	if (f) x = -x;
}
namespace {
    const int mo = 1e9 + 7;
    inline int add(int x, int y) { x += y; return x >= mo ? x - mo : x; }
    inline int sub(int x, int y) { x -= y; return x < 0 ? x + mo : x; }
    inline int mul(int x, int y) { return (lo) x * y % mo; }
    inline int power(int a, int k = mo - 2) {
		int ans = 1;
		for (; k; k >>= 1, a = mul(a, a))
			if (k & 1) ans = mul(ans, a);
		return ans;
    }
	inline void U(int &x, int y) { x = add(x, y); } 
}

const int N = 1e6 + 233;
int n, a[N], sum[N];

inline int F(int n) {
	return sum[n];
}

int main(void) {
	read(n);
	rep (i, n) read(a[i]);
	int t = 1;
	rep (i, n - 1) t = mul(t, i);
	sum[0] = 0;
	rep (i, n) sum[i] = add(sum[i - 1], power(mul(i, i + 1)));
	int ans = 0;
	for (int i = 1; i <= n - 1; i++) {
		int j = n;
		int val = mul(t, power(j - i));
		// if (j != n) val = mul(val, power(j - i + 1));
		ans = add(ans, mul(a[j] - a[i], val));
	}
	for (int j = 1; j <= n - 1; j++) {
		int val = 0;
		val = sub(F(j - 1), F(n - 1 - j));
		ans = add(ans, mul(a[j], mul(t, val)));
	}
	cout << ans << "\n";
}


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

using namespace std;
typedef long long ll;
const int MAXN = 100010;
const ll INF = 1e16;
struct edge {
  int to;
  ll cost;
};

int n;
vector<edge> graph[MAXN];
ll dist[MAXN];
bool visited[MAXN];
int x[MAXN], y[MAXN];
int q, k;

void dfs(int cur, int parent, ll cost) {
  if (parent == -1) {
    dist[cur] = 0;
  } else {
    dist[cur] = dist[parent] + cost;
  }
  visited[cur] = true;
  for (int i=0;i<graph[cur].size();i++) {
    edge& next = graph[cur][i];
    if (!visited[next.to]) {
      dfs(next.to, cur, next.cost);
    }
  }
}

void solve() {
  for (int i=0;i<n;i++) {
    dist[i] = INF;
  }
  dist[k] = 0;
  dfs(k, -1, 0);
  for (int i=0;i<q;i++) {
    cout << (dist[x[i]] + dist[y[i]]) << endl;
  }
}

int main() {
  int a, b;
  ll c;
  cin >> n;
  for (int i=0;i<n-1;i++) {
    cin >> a >> b >> c;
    a--;b--;
    graph[a].push_back((edge){b, c});
    graph[b].push_back((edge){a, c});
  }
  cin >> q >> k;
  k--;
  for (int i=0;i<q;i++) {
    cin >> x[i] >> y[i];
    x[i]--;y[i]--;
  }
  solve();
}


Measured memory_bytes: 15232
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

//bool flag = __builtin_add_overflow(a , b , &tmp);
//bool flag = __builtin_mul_overflow(a , b , &tmp);
//bool flag3= __builtin_sub_overflow(a , b , &tmp);

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 10004, MAXM = 102, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n;
    cin >> n;
    vector<int> arr(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i];
    }

    int cnt = 0;
    vector<int> ans(n + 1);
    for (int i = n; i >= 1; --i) {
        int sum = 0;
        for (int j = i + i; j <= n; j += i) {
            sum += ans[j];
        }
        if (arr[i]) {
            if (sum % 2 == 0) {
                ans[i] = 1;
                ++cnt;
            }
        } else {
            if (sum & 1) {
                ans [i] = 1;
                ++cnt;
            }
        }
    }

    cout << cnt << '\n';
    for (int i = 1; i <= n; ++i) {
        if (ans[i]) {
            cout << i << ' ';
        }
    }
    cout << '\n';


    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int N=100;
int a[N];
int main()
{
	int n,maxx,ans=1;cin>>n>>maxx;
	for(int i=1,x;i<n;i++)
	  cin>>x,ans+=maxx<=x,
	  maxx=max(maxx,x);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 100010;
int N;
vector<int> A;
ll sum[MAX_N];
int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < A.size(); i++){
    sum[i + 1] += sum[i] + A[i];
  }
  int res = N;
  int tmp = 0;
  for (int i = 1; i <= N-1; i++){
    if (2 * sum[i] < A[i]){
      tmp = i;
    }
  }
  cout << res - tmp << endl;

  return 0;
}


Measured memory_bytes: 1408
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int w = saori.saori_hayami();
		if(a > w){
			System.out.println("safe");
		} else {
			System.out.println("unsafe");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32396
let () =
  let a,b = Scanf.scanf "%s %s " (fun a b -> a,b) in
  let a = Big_int.big_int_of_string a in
  let b = Big_int.big_int_of_string b in

  Printf.printf "%s\n" @@
  if Big_int.gt_big_int a b then "GREATER" else if Big_int.lt_big_int a b then "LESS" else "EQUAL"



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

using ll = long long;

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

  rep(i,K){cout << "ACL";}
  cout << endl;
}

Measured memory_bytes: 3488
/* The journey is what brings us pleasure, not the destination <3 */

#include<bits/stdc++.h>

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define mxx 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

int tc;


void solve()
{
    vector<ll>v;
    ll n,x,ans=0;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>x;
        v.push_back(x);
    }
    sort(all(v));
    deque< pair<ll,ll> > dq;
    ans+=v[n-1];
    dq.push_back({v[n-1],v[n-2]});
    dq.push_back({v[n-1],v[n-2]});
    for(int i=n-3; i>=0; i--){
        pair<ll,ll>pr,pr1,pr2;
        pr=dq.front(); dq.pop_front();
        ans+=min(pr.first,pr.second);
        pr1={v[i],pr.first};
        pr2={v[i],pr.second};
        dq.push_back(pr1);
        dq.push_back(pr2);
    }
    cout<<ans<<endl;
}

int main()
{

    _fastIO;

    //cin>>tc;while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 8216
<?php
fscanf(STDIN,'%d',$n);
$array=str_split($n);
if ($array[0]==1) {
  // code...
  echo 9;
}else {
  echo 1;
}
if ($array[1]==1) {
  // code...
  echo 9;
}else {
  echo 1;
}
if ($array[2]==1) {
  // code...
  echo 9;
}else {
  echo 1;
}

 ?>


Measured memory_bytes: 3576
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    int a,b,c,d,e,k,ans;
    cin>>a>>b>>c>>d>>e>>k;
    ans=max({a,b,c,d,e})-min({a,b,c,d,e});
    if(ans<=k){
        cout<<"Yay!"<<endl;
    }
    
    else if(ans>k){
        cout<<":("<<endl;
    }
    
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=1e5+5;
const int mod=1e9;
const double pi=acos(-1.0);
ll f;
string s,ss;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    cin>>ss;
    for(int i=0;i<s.size();i++){
        if(s[i]!=ss[i]){
            f=1;
            break;
        }
    }
    if(f==0 && ss.size()>s.size()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

    int n;
    cin >> n;
	int count4 = 0;
	int count2 = 0;
	int count = 0;
	REP(i, n) {
		ll tmp;
		cin >> tmp;
		if (tmp % 4 == 0) {
			count4++;
		}
		else if (tmp % 2 == 0) {
			count2++;
		}
		else {
			count++;
		}
	}

    if((count > count4 + 1) || (count2 > 0 && count4+1 == count)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

int bubbleSort(vector<int>& A, int N){
  int sw=0;
 // core code of bubbleSort
  for(int i = 0 ; i < N - 1 ; i++){// After the last smallest N - 1 elements are in their right place, the numbers are sorted!
      for (int j = N - 1 ; j >= i + 1; j --){//start from the last element！
          if (A[j] < A[j-1]){
              swap(A[j], A[j-1]);
              sw++;
          }
      }
  }
 // core code of bubbleSort!
  for(int k = 0; k < N; k++){
   if (k == (N-1)) cout<<A[k]<<endl;
   else cout<<A[k]<<" ";
  }
  return sw;
}

int main(){
 int N;
 vector<int> A(100);
 cin>>N;
 for(int i =0; i <N; i++) cin>>A[i];

 int sw = bubbleSort(A,N);
 cout<<sw<<endl;
}


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

using namespace std;
typedef long long ll;
#define sz(x) (ll)((x).size())
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
vector<ll> pw2(51,1);

int main(){
	rep1(i,50) pw2[i]=2*pw2[i-1];
	ll N,M; cin>>N>>M;
    ll ans=0,cnt2=0; 
	vector<ll> p(M);
    vector<ll> lamp[10];
    vector<ll> swi(10);
    rep(i,M){
        ll x; cin>>x;
        rep(j,x){
            ll y; cin>>y;
            lamp[i].pb(y);
        }
    }
    rep(i,M)cin>>p[i];

    rep(i,pw2[N]){
        ll tmp=i;
        rrep(j,N){
            swi[j]=tmp/pw2[j];
            tmp%=pw2[j];
        }
        //swi[0]~swi[N-1]
        rep(j,M){
            ll cnt=0;
            rep(k,sz(lamp[j])){
                if(swi[lamp[j][k]-1]==1) cnt++;
            }
            if(cnt%2==p[j]) cnt2++;
        }
        if(cnt2==M) ans++;

        cnt2=0;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;
const int MAX_N = 100010;

int main(void){
  int n;
  double t, a;
  vector<double> x;
  cin >> n;
  cin >> t >> a;
  x.resize(n);
  cin >> x[0];
  int res = 0;
  for(int i = 1;i < n;++i){
    cin >> x[i];
    if(abs((t - x[i]*0.006) - a) < abs((t - x[res]*0.006) - a))
      res = i;
  }
  cout << res + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
typedef pair<double, double> P;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
const double EPS = 1e-10;

// 内積 |a||b|cosθ
double dot(Point a, Point b){
	// return a.real() * b.real() + a.imag() * b.imag();
	return (conj(a) * b).real();
}
// 外積、符号付面積の２倍　|a||b|sinθ
double cross(Point a, Point b){
	// return a.real() * b.imag() - a.imag() * b.real();
	return (conj(a) * b).imag();
}
// 点の位置関係　2点a,bから見た点cの位置関係
int ccw(Point a, Point b, Point c){
    // COUNTER_CLOCKWISE
    if(cross(b - a, c - a) > EPS) return 1;
    // CLOCKWISE
    if(cross(b - a, c - a) < -EPS) return -1;
    // ONLINE_BACK
    if(dot(b - a, c - a) < -EPS) return 2;
    // ONLINE_FRONT
    if(abs(b - a) + EPS < abs(c - a)) return -2;
    // ON_SEGMENT
    return 0;
}
// 線分の交差判定
bool is_cross(Line a, Line b){
    if(ccw(a.first, a.second, b.first) * ccw(a.first, a.second, b.second) <= 0 && ccw(b.first, b.second, a.first) * ccw(b.first, b.second, a.second) <= 0){
        return true;
    }
    return false;
}
// 直線の交点
Point cross_point(Line a, Line b){
    double d1 = cross(b.second - b.first, b.first - a.first);
    double d2 = cross(b.second - b.first, a.second - a.first);
    return a.first + (a.second - a.first) * d1 / d2;
}

int main(){
    int ts;
    cin >> ts;
    rep(it, 0, ts){
        double xa, ya, xb, yb;
        cin >> xa >> ya >> xb >> yb;
        Point a = {xa, ya};
        Point b = {xb, yb};
        Line h = {a, b};
        int n;
        cin >> n;
        vector<Line> ls; 
        vector<int> owner(n), l(n);
        rep(i, 0, n){
            double xs, ys, xt, yt;
            cin >> xs >> ys >> xt >> yt >> owner[i] >> l[i];
            Point s = {xs, ys};
            Point t = {xt, yt};
            ls.push_back({s, t});
        }
        vector<pair<P, int> > crossPnt;
        rep(i, 0, n){
            if(is_cross(h, ls[i])){
                Point tmp = cross_point(h, ls[i]);
                int tmpl = l[i];
                if(owner[i] == 0) tmpl = (tmpl + 1) % 2;
                crossPnt.push_back({P(tmp.real(), tmp.imag()), tmpl});
            }
        }
        int ans = 0;
        sort(crossPnt.begin(), crossPnt.end());
        rep(i, 1, crossPnt.size()){
            if(crossPnt[i - 1].second != crossPnt[i].second){
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int cnt[10];
int main() {
    int n, x;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);
        cnt[x % 4]++;
    }
    cnt[2] %= 2;
    if (cnt[1] + cnt[2] + cnt[3] <= cnt[0] + 1) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

using namespace std;

int main()
{
    char s;
    int value = 700;
    for (int i = 0; i < 3; i++)
    {
        cin >> s;
        // cout << s << endl;
        if (s == 'o')
        {
            value += 100;
        }
    }
    cout << value << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int m = stdin.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = stdin.nextInt() - 1;
            b[i] = stdin.nextInt() - 1;
        }
        
        int ans = 0;
        for (int skip = 0; skip < m; skip++) {
            UnionFind uf = new UnionFind(n);
            for (int i = 0; i < m; i++) {
                if (i != skip) {
                    uf.union(a[i], b[i]);
                }
            }
            
            long c = IntStream.range(0, n).map(uf::find).boxed().collect(Collectors.toSet()).size();
            if (c > 1) {
                ans++;
            }
        }
        
        System.out.println(ans);
    }
    
    private static class UnionFind {
        private int[] parent;
        
        public UnionFind(int n) {
            parent = IntStream.range(0, n).toArray();
        }
        
        public int find(int x) {
            if (x == parent[x]) {
                return x;
            } else {
                parent[x] = find(parent[x]);
                return parent[x];
            }
        }
        
        public void union(int x, int y) {
            x = find(x);
            y = find(y);
            if (x != y) {
                parent[x] = y;
            }
        }
    }
}

Measured memory_bytes: 27220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	vector <int> v(n);
	forn(i,n) cin>>v[i];
	sort(all(v));
	int ans = 0;
	for(int i=n-1;i>=0;i--)
	{
	    int g = v[i];
	    if(i<n-1 && v[i+1]==g) continue;
	    if(i==0){ ans++; continue; }
	    bool ok=1;
	    for(int j=1;j<=sqrt(g);j++)
	    {
	        if(g%j==0)
	        {
	            auto it = lower_bound(v.begin(),v.begin()+i,j);
	            if(it!=v.begin()+i && *it==j){ ok=0; break; }
	            it = lower_bound(v.begin(),v.begin()+i,g/j);
	            if(it!=v.begin()+i && *it==g/j){ ok=0; break; }
	        }
	    }
	    if(ok) ans++;
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3996
#include <cstdio>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <iostream>
#include <bitset>
using namespace std;
 
int n;
const int maxn = 1e4+1;
bitset<maxn> vis;

int main()
{
    vis.reset();
    vis[0] = 1;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        int s;
        scanf("%d", &s);
        vis = vis | (vis<<s);
    }
    for (int i = maxn-1; i >= 0; --i)
    {
        if (vis[i] == 1 && i % 10 != 0)
        {
            printf("%d\n", i);
            return 0;
        }
    }
    puts("0");
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, m;
	cin >> n;
	VI a(n); rep(i, n)cin >> a[i];
	cin >> m;
	VI b(m); rep(i, m)cin >> b[i];
	puts(a < b ? "1" : "0");
}


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

int main(){

    int N;
    cin>>N;
    vector<int>vec(N);
    for(int n=0;n<N;n++)cin>>vec[n];
    sort(vec.begin(), vec.end());
    int ans=0, sc=0;
    for(int i=0;i<N-1;i++){
        int tmp = min(vec[N-1]-vec[i], vec[i]);
        if(sc<tmp){
            sc=tmp;
            ans=i;
        }
    }
    cout<<vec[N-1]<<" "<<vec[ans]<<endl;
    
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;

class Solution {
	final int SIZE = 20;
	int[] dr = { 0, 1, 0, -1 };
	int[] dc = { 1, 0, -1, 0 };
	int w;
	int h;
	int[][] graph = new int[SIZE][SIZE];
	int ans;
	int sr;
	int sc;

	void compute() {
		Scanner scanner = new Scanner(new BufferedInputStream(System.in));
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if (w == 0 && h == 0) {
				break;
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					graph[i][j] = scanner.nextInt();
					if (graph[i][j] == 2) {
						sr = i;
						sc = j;
					}
				}
			}
			ans = 11;
			dfs(sr, sc, 0);
			if (ans <= 10) {
				System.out.println(ans);
			} else {
				System.out.println(-1);
			}
		}
		scanner.close();
	}

	void dfs(int r, int c, int step) {
		if (step == 10) {
			return;
		}
		for (int direction = 0; direction < 4; direction++) {
			int nr = r;
			int nc = c;
			int cnt = 0;
			while (nr >= 0 && nr < h && nc >= 0 && nc < w && graph[nr][nc] != 1) {
				if (graph[nr][nc] == 3) {
					ans = Math.min(ans, step + 1);
					return;
				}
				nr += dr[direction];
				nc += dc[direction];
				cnt++;
			}
			if (nr >= 0 && nr < h && nc >= 0 && nc < w && graph[nr][nc] == 1 && cnt > 1) {
				graph[nr][nc] = 0;
				dfs(nr - dr[direction], nc - dc[direction], step + 1);
				graph[nr][nc] = 1;
			}
		}
	}
}

public class Main {
	public static void main(String args[]) {
		Solution solution = new Solution();
		solution.compute();
	}
}



Measured memory_bytes: 43344
N,Y=map(int,input().split())
answer=-1,-1,-1
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y#多分起こりうる１０００円札の数
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            #左：お札は正の数
            #左：起こりうる１０００円札の数のときにY円になるかどうか
            answer=x,y,z
print(*answer)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
//for(i=0; i<N; i++) cin >> a[i];


ll h[MAX*3]={}, w[MAX*3]={};

int main(void) {
  ll i, j, k;
  
  ll H, W, M;
  cin >> H >> W >> M;
  
  vector<ll> a(H), b(W);
  for(i=0; i<M; i++) {
    cin >> h[i] >> w[i];
    h[i]--; w[i]--;
    a[h[i]]++;
    b[w[i]]++;
  }
  
  ll ma=0, mb=0;
  for(i=0; i<H; i++) chmax(ma, a[i]);
  for(i=0; i<W; i++) chmax(mb, b[i]);
  
  ll A=0, B=0;
  for(i=0; i<H; i++) if(a[i]==ma) A++;
  for(i=0; i<W; i++) if(b[i]==mb) B++;
  
  
  ll c=0;
  for(i=0; i<M; i++) if(a[h[i]]+b[w[i]]==ma+mb) c++;
  
  pt(ma+mb-(c==A*B));
  
  
}




Measured memory_bytes: 12744
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;

vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
set<ll> st;
map<ll, ll> mp;

int main()
{
	string s;
	ll ans = 0;
	cin >> s;
	ll cnt = pow(2, s.size()-1);
	while (cnt--)
	{
		vector<ll> v;
		ll a = cnt*2+1;
		ll b = 0;
		while (a > 0)
		{
			if (a & 1)
			{
				if(b<s.size())v.push_back(b);
			}
			b++;
			a >>= 1;
		}
		vector<ll> sub, sum;
		REP(i, v.size() - 1) sub.push_back(v[i + 1] - v[i]);
		REP(i, v.size())
		{
			sum.push_back(atoll(s.substr(v[i], (i >= sub.size() ? s.size() - v[i] : sub[i])).c_str()));
		}
		if(sum.size()!=1) ans += accumulate(ALL(sum), 0);
		else ans += sum[0];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math
a,b,C=map(int,input().split())
c = math.radians(C)
x = a**2+b**2-2*a*b*math.cos(c)

S = a*b*math.sin(c)/2
L = a+b+math.sqrt(x)
h = (2*S)/a
print(f'{S:.08f}')
print(f'{L:.08f}')
print(f'{h:.08f}')


Measured memory_bytes: 5720
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] XY = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int X = XY[0];
            int Y = XY[1];
            int turu = 0;
            int kame = 0;
            for (int i = 0; i <= X; i++)
            {
                turu = i * 2;
                kame = (X - i) * 4;
                if(turu + kame == Y)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 28304
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
    ll t;
    cin >> t;
    REP(tt, t){
        ll n, ans = 0;
        cin >> n;
        vector<P> x, y;
        REP(i, n){
            ll c, a, b;
            cin >> c >> a >> b;
            ll no = min(a, b);
            //cout << a << " " << b << " " << no << "!!!!" << endl;
            ans += no;
            a -= no;
            b -= no;
            if (a > 0) x.push_back(P(c, -a));
            else if(b > 0) y.push_back(P(n - c, -b));
        }
        sort(ALL(x));
        sort(ALL(y));
        priority_queue<ll, vector<ll>, greater<ll>> q;
        ll a1 = 0, a2 = 0, a1n = 0, a2n = 0;
        REP(i,x.size()){
            ll pos = x[i].first, v = x[i].second * -1;
            //cout << pos << " !! " <<v<< endl;
            a1 += v;
            a1n++;
            q.push(v);
            if(a1n > pos){
                a1n--;
                a1 -= q.top();
                q.pop();
            }
        }
        while (!q.empty()) q.pop();
        REP(i,y.size()){
            ll pos = y[i].first, v = y[i].second * -1;
          //  cout << pos << " ! " << v << endl;
            a2 += v;
            a2n++;
            q.push(v);
            if(a2n > pos){
                a2n--;
                a2 -= q.top();
                q.pop();
            }
        }
        cout << ans + a1 + a2 << endl;
    }
}

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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

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

bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}

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

    for(int i = 1;; i++) {
        if(i * i > n) {
            cout << (i - 1) * (i - 1) << endl;
            break;
        }
    }

    return 0;
}

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

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

typedef long long LL;
const int N=200010;
int n,q,a,b,X[N];
int delta[N];
LL sumd[N],f[N];

struct SegmentTree
{
    LL mnv[N<<2];int leaf;
    void build()
    {
        for(leaf=1;leaf<=(n+2);leaf<<=1);
        for(int i=1;i<=leaf+n;i++) mnv[i]=INT64_MAX/3;
    }
    void modify(int k,LL x)
    {
        mnv[leaf+k]=min(mnv[leaf+k],x);
        for(int i=(leaf+k)>>1;i;i>>=1)
            mnv[i]=min(mnv[i<<1],mnv[i<<1|1]);
    }
    LL qmin(int l,int r)
    {
        LL res=INT64_MAX/3;
        for(l=leaf+l-1,r=leaf+r+1;l^r^1;l>>=1,r>>=1)
        {
            if(~l&1) res=min(res,mnv[l^1]);
            if(r&1) res=min(res,mnv[r^1]);
        }
        return res;
    }
}t1,t2;

LL solve(int a,int b)
{
    X[0]=a;
    for(int i=1;i<=q;i++)
    {
        delta[i]=abs(X[i]-X[i-1]);
        sumd[i]=sumd[i-1]+delta[i];
    }
    f[1]=abs(b-X[1]);
    t1.build();t2.build();
    t1.modify(X[0],f[1]-sumd[1]-X[0]);
    t2.modify(X[0],f[1]-sumd[1]+X[0]);
    for(int i=2;i<=q;i++)
    {
        f[i]=t1.qmin(1,X[i])+X[i]+sumd[i-1];
        f[i]=min(f[i],t2.qmin(X[i],n)-X[i]+sumd[i-1]);
        t1.modify(X[i-1],f[i]-sumd[i]-X[i-1]);
        t2.modify(X[i-1],f[i]-sumd[i]+X[i-1]);
    }
    LL ans=INT64_MAX/3;
    for(int i=0;i<=q;i++) ans=min(ans,f[i]+sumd[q]-sumd[i]);
    return ans;
}

int main()
{
    n=read();q=read();a=read();b=read();
    for(int i=1;i<=q;i++) X[i]=read();
    LL ans=min(solve(a,b),solve(b,a));
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
int main() {
    long long n, m, in, s = 0, ans = 0; cin >> n >> m;
    unordered_map<long long, long long> h;
    ++h[0];
    for (int i = 0; i < n; ++i) {
        cin >> in;
        s = (s + in) % m;
        ++h[s];
    }
    for (auto i : h) {
        ans += i.second*(i.second - 1) / 2;
    }
    cout << ans << endl;
}

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

const int MOD = 1E9 + 9;
const ll INF = ll(1e18) + 1;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while (l + 1 < r) {
    ll x = (l + r) / 2;
    bool ok = [&] {
      ll tot = 0;
      rep(i, n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (l + 1 < r) {
            int c = (l + r) / 2;
            if (a[c] * a[i] < x)
              r = c;
            else
              l = c;
          }
          tot += n - r;
        } else {
          int l = -1, r = n;
          while (l + 1 < r) {
            int c = (l + r) / 2;
            if (a[c] * a[i] < x)
              l = c;
            else
              r = c;
          }
          tot += r;
        }
        if (a[i] * a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok)
      l = x;
    else
      r = x;
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  char s[101];
  scanf("%s", s);

  int counter = 0;
  while (s[counter] != '\0') {
    counter++;
  }

  printf("%c%d%c\n", s[0], counter - 2, s[counter - 1]);

  return 0;
}

Measured memory_bytes: 128
import math
N = int(input())
towns = []
dist = 0
for i in range(N):
	towns.append(list(map(int, input().split())))

for i in range(N-1):
  for j in range(i+1, N):
    dist += math.sqrt((towns[j][0] - towns[i][0])**2 + (towns[j][1] - towns[i][1])**2)

print(dist * 2 / N)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max(a * c, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3644
import math


def main():
    ret = 0
    n, m = map(int, input().split())
    for i in range(1, int(math.sqrt(m)) + 1):
        if m % i == 0 and n * i <= m:
            ret = max([ret, i])
        if m % i == 0:
            j = m //i
            if n * j <= m:
                ret = max([ret, j])
    print(ret)
main()


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

using namespace std;
#define int long long
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define all(o) o.begin(), o.end()
const int maxn = 1e6 + 10;
int a[maxn], b[maxn];
main(){
	int n;
	cin >> n;
	int sum = 0;
	int ans = 0;
	for(int i=0; i<n; i++)
		cin >> a[i] >> b[i];
	reverse(a, a + n);
	reverse(b, b + n);
	for(int i=0; i<n; i++){
		int x = a[i], y = b[i];
		x += sum;
		if(x % y == 0) continue;
		int t = y - (x % y);
		sum += t;
	}
	cout << sum << endl;

}

Measured memory_bytes: 1792
#ABC161B
import sys
N, M = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
A.sort(reverse=True)
S = sum(A)
for a in A[:M]:
    if a/S - 1/(4*M) <0:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 3060
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N,T,S;
	scanf("%d %d %d",&N,&T,&S);

	int dp[T+1];
	for(int i = 0; i <= T; i++)dp[i] = 0;

	int value,cost;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&value,&cost);

		for(int time = T; time-cost >= 0; time--){
			if(time-cost < S && S < time){
				//Do nothing
			}else{
				dp[time] = max(dp[time],dp[time-cost]+value);
			}
		}

		for(int time = 1; time <= T; time++){
			dp[time] = max(dp[time],dp[time-1]);
		}
	}

	printf("%d\n",dp[T]);

	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

string ans;

void dfs(const vector< vector<int> > &next, const vector<int> &groups, int now, int need) {
    for(int j=0; j<26; j++) {
        if(next[j][now] == -1) {
            ans.push_back('a' + j);
            return;
        }
        if(groups[next[j][now] + 1] < need) {
            ans.push_back('a' + j);
            dfs(next, groups, next[j][now], need-1);
            return;
        }
    }
}

int main(void) {
    string A;
    cin >> A;
    A.insert(0, "_");
    int N = A.size();

    vector< vector<int> > next(26, vector<int>(N, -1));
    for(int i=N-1; i; i--) {
        for(int j=0; j<26; j++) {
            next[j][i-1] = next[j][i];
        }
        next[A[i]-'a'][i-1] = i;
    }

    set<char> st;
    vector<int> groups(N);
    for(int i=N-1; i; i--) {
        st.insert(A[i]);
        if(st.size() == 26) {
            groups[i] = 1;
            st.clear();
        }
    }
    for(int i=N-1; i; i--) {
        groups[i-1] += groups[i];
    }

    dfs(next, groups, 0, groups[0]);

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


Measured memory_bytes: 21764
#include<bits/stdc++.h>
using namespace std;
map<string, int >verdict;
int main()
{

    int n;
    cin>>n;
    string s;
    for(int i = 1; i<=n; i++)
    {
        cin>>s;
        if(s=="AC")
            verdict["AC"]++;
        else  if(s=="TLE")
            verdict["TLE"]++;
        else  if(s=="WA")
            verdict["WA"]++;
        else  if(s=="RE")
            verdict["RE"]++;
    }
    cout<<"AC x "<<verdict["AC"]<<endl;
    cout<<"WA x "<<verdict["WA"]<<endl;
    cout<<"TLE x "<<verdict["TLE"]<<endl;
    cout<<"RE x "<<verdict["RE"]<<endl;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);

		int a=0;
		int n=scan.nextInt();
		int val[]=new int[n];

		int kai=0;
		
		
		if(n>=1 && n<=100) {
		for(int i=0;i<n;i++){
			a=scan.nextInt();
			if(a>=0 && a<=1000) {
			val[i]=a;
			}
			else {
				
			}
		}
		
		int max=val[0];
		int min=val[0];

		for(int j=1;j<val.length;j++){
			
			if(min>val[j]) {
				min=val[j];
			}
			
			max=Math.max(max, val[j]);
			
		}

		kai=max-min;
		System.out.println(kai);

	}else{
		
	}
		
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
 using namespace std;
 int main() {
 long long A, B;
 cin >> A >> B;
 if(A % 2 != B % 2) {
 cout << "IMPOSSIBLE" << endl;
 } else {
cout << (A + B) / 2 << endl;
 }
 return 0;
 }

Measured memory_bytes: 256
N = int(input())
L = []
t = 0
for i in range(N):
    D = [int(i) for i in input().split()]
    if D[0] == D[1]:
        L.append(i)
        if len(L) >= 3:
            if L[-2] == i-1 and L[-3] == i-2:
                print('Yes')
                t = 1
                break

if t == 0:
    print('No')

Measured memory_bytes: 9200
// ABC 119

using System;
using System.Linq;

class Program
{
    static int a;
    static int b;
    static long[] t;
    static long[] s;
    static long[] xq;

    static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        int q = input[2];
        s = new long[a];
        t = new long[b];
        for (int i = 0; i < a; i++)
            s[i] = long.Parse(Console.ReadLine());
        for (int i = 0; i < b; i++)
            t[i] = long.Parse(Console.ReadLine());
        xq = new long[q];
        for (int i = 0; i < q; i++)
            xq[i] = long.Parse(Console.ReadLine());

        foreach (var x in xq)
        {
            long ans = long.MaxValue;
            int tx = ts(x);
            int sy = ss(x);
            try { ans = Math.Min(ans, Math.Max(t[tx + 1], s[sy + 1]) - x); }
            catch { }
            try { ans = Math.Min(ans, x - Math.Min(t[tx], s[sy])); }
            catch { }
            try { ans = Math.Min(ans, 2 * (x - t[tx]) + s[sy + 1] - x); }
            catch { }
            try { ans = Math.Min(ans, 2 * (x - s[sy]) + t[tx + 1] - x); }
            catch { }
            try { ans = Math.Min(ans, 2 * (t[tx + 1] - x) + x - s[sy]); }
            catch { }
            try { ans = Math.Min(ans, 2 * (s[sy + 1] - x) + x - t[tx]); }
            catch { }
            Console.WriteLine(ans);
        }
    }

    static int ss(long x)
    {
        if (s[0] > x) return -1;
        int l = 0;
        int r = a - 1;
        while (r - l > 1)
        {
            int m = (l + r) / 2;
            if (s[m] > x)
            {
                r = m - 1;
                continue;
            }
            l = m;
        }
        if (s[l] <= x && x < s[r])
            return l;
        return r;
    }

    static int ts(long x)
    {
        if (t[0] > x) return -1;
        int l = 0;
        int r = b - 1;
        while (r - l > 1)
        {
            int m = (l + r) / 2;
            if (t[m] > x)
            {
                r = m - 1;
                continue;
            }
            l = m;
        }
        if (t[l] <= x && x < t[r])
            return l;
        return r;
    }
}

Measured memory_bytes: 20804
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  long long N, M;
  cin >> N >> M;
  
  if(N * 2 >= M){
    cout << M / 2 << endl;
    return 0;
  }
  
  cout << (M - 2 * N) / 4 + N << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin>>s;
	bool flg=false;
	vll P;
	int cnt=0;
	rep(i, s.size()){
		if (s[i]=='<' && flg==false){
			cnt++;
		}else if(s[i]=='>' && flg){
			cnt++;
		}else if(s[i]=='>' && flg==false){
			P.pb(cnt);
			cnt = 1;
			flg = true;
		}else if(s[i]=='<' && flg){
			P.pb(cnt);
			cnt = 1;
			flg = false;
		}
	}
	if (cnt!=0) P.pb(cnt);

	ll now = 0, ans = 0;
	rep(i, P.size()){
		if (i%2==0){
			ans += (P[i]-1)*P[i]/2;
			now = P[i];
		}else{
			ans += max(now, P[i]);
			ans += (P[i]-1)*P[i]/2;
		}
	}
	if (P.size()%2 == 1){
		ans += now;
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b.at(i);
  sort(all(b));
  cout<<b.at(a-1)-b.at(0);
}

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

using namespace std;

typedef long long int ll;

const int N = (int) 3e3 + 10;
const int mod = (int) 1e9 + 7;

int n;
string s;
int memo[N][N];

int dp(int at, int below, int above) {
    if(below < 0 || above < 0) return 0;
    if(at == n) return 1;
    int &ans = memo[at][below];
    if(ans != -1) return ans;
    ans = 0;
    char op = s[at - 1];
    if(op == '<') {
        ans += dp(at + 1, below, above - 1);
        ans += dp(at, below + 1, above - 1);
        ans %= mod;
        // for(int i = 0, nabove = above - 1, nbelow = below; i < above; ++i, --nabove, ++nbelow) {
        //     ans += dp(at + 1, nbelow, nabove);
        //     ans %= mod;
        // }
    } else {
        // for(int i = 0, nabove = above - 1, nbelow = below; i < above; ++i, --nabove, ++nbelow) {
        //     ans += dp(at + 1, nbelow, nabove);
        //     ans %= mod;
        // }
        ans += dp(at + 1, below - 1, above);
        ans += dp(at, below - 1, above + 1);
        ans %= mod;
    }
    return ans;
}

void solve() {
    cin >> n >> s;
    int ans = 0;
    memset(memo, -1, sizeof(memo));
    for(int i = 1; i <= n; ++i) {
        int below = i - 1;
        int above = n - 1 - below;
        ans += dp(1, below, above);
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

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

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

  int ans = 0;
  while(1){
    if(x > y) break;
    ans++;
    x *= 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
x, n = gets.split.map(&:to_i)
pp = gets.split.map(&:to_i)

i = 0
loop do
    if !pp.include?(x - i)
        p x - i
        break
    end

    if !pp.include?(x + i)
        p x + i
        break
    end

    i += 1
end

Measured memory_bytes: 14336
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[320000], a[330020], b[330000];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	vec.resize(n);
	rep(i, n - 1) {
		LL x, y;
		cin >> x >> y;
		x--, y--;
		vec[x].push_back(Edge{ y,0 });
		vec[y].push_back(Edge{ x,0 });
	}
	priority_queue<Pll, vector<Pll>, greater<Pll>>pq;
	cin >> k;
	rep(i, n)dp[i] = INF;
	rep(i, k) {
		LL x, y;
		cin >> x >> y;
		x--;
		pq.push(Pll(y, x));
		dp[x] = y;
	}
	while (!pq.empty()) {
		Pll now = pq.top();
		pq.pop();
		LL v = now.second, cost = now.first;
		rep(i, vec[v].size()) {
			LL u = vec[v][i].to;
			if (dp[u] == INF) {
				dp[u] = cost + 1;
				pq.push(Pll(dp[u],u));
			}
			else {
				if (abs(dp[v] - dp[u]) == 1) {}
				else {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	rep(i, n) {
		cout << dp[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 14448