akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    int H, W;
    int ans = 0;
    cin >> H >> W;
    vector<vector<char>> S(W, vchar(H));
    vvint distance(W, vint(H));

    rep(y, H)
    {
        rep(x, W)
        {
            cin >> S[x][y];
        }
    }
    rep(y, H)
    {
        rep(x, W)
        {
            if (S[x][y] == '#')
            {
                continue;
            }
            pair<int, int> start = {x, y};
        //    vector<vector<bool>> arrived(W + 1, vector<bool>(H + 1));
            rep(Y, H)
            {
                rep(X, W)
                {
                    distance[X][Y] = -1;
                }
            }
            distance[x][y] = 0;
            queue<pair<int, int>> q;
            q.push(start);
            while (!q.empty())
            {
                pair<int, int> now = q.front();
                int nowx = now.first;
                int nowy = now.second;
                int dis = distance[nowx][nowy];
           //     arrived[nowx][nowy] = true;
                q.pop();
                rep(k, 4)
                {
                    if ((nowx + dx[k] < W and nowx + dx[k] >= 0 and nowy + dy[k] < H and nowy + dy[k] >= 0 and S[nowx + dx[k]][nowy + dy[k]] == '.') and distance[nowx + dx[k]][nowy + dy[k]] == -1)
                    {
                        q.push({nowx + dx[k], nowy + dy[k]});
                        distance[nowx + dx[k]][nowy + dy[k]] = dis + 1;
                    }
                }
            } //この時点で最短経路は出てる
            rep(s, W)
            {
                rep(t, H)
                {
                    ans = max(distance[s][t], ans);
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = 998244353;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = 105;
string s;
char tmp[maxn];

int read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  return true;
}

map<string, int> mem;

int rec(const string &s) {
  if (mem.count(s)) {
    return mem[s];
  }
  auto &cur = mem[s];
  cur = 0;
  if (s.empty()) {
    return cur = 1;
  }
  {
    string ps = s;
    ps.resize(sz(s) - 1);
    if (s[sz(s) - 1] == '0') {
      add(cur, rec(ps));
    } else {
      add(cur, mul(2, rec(ps)));
    }
  }
  for (int p = 1; 2 * p <= sz(s); p++) {
    for (int k = 2; k * p <= sz(s); k++) {
      string ps = s;
      ps.resize(sz(s) - k * p);
      string t(p, '1');
      for (int i = 0; i < k * p; i++) {
        if (s[sz(s) - k * p + i] == '0') {
          t[i % p] = '0';
        }
      }
      add(cur, mul(rec(ps), rec(t)));
    }
  }
  return cur;
}

void solve() {
  printf("%d\n", rec(s));
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007


bool chekeven(string x)
{
    int len=x.size();
    for(int i=0;i<len/2;i++)
    {
        if(x[i]!=x[i+len/2]){
            return false;
        }
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin>>str;
    str.pop_back();
    for(int i=str.size()-1;i>=1;i--)
    {
        if(chekeven(str)&&str.size()%2==0){
            cout<<str.size()<<endl;
            break;
        }
       str.pop_back();
    }


}


Measured memory_bytes: 3604
using System;

namespace AIZUJudge {
    class calcHugeNumber {
        static void Main(string[] args) {
            string size = Console.ReadLine();
            if (string.IsNullOrEmpty(size)) {
                return;
            }
            int size_Set = int.Parse(size);

            for (int iter = 0; iter < size_Set; iter++) {
                Bigint[] data = new Bigint[2];
                for (int i = 0; i < 2; i++) {
                    data[i] = new Bigint(Console.ReadLine());
                }
                if (data[0].num_digit == 0 || data[1].num_digit == 0) {
                    continue;
                }
                if (data[0].num_digit > 80 || data[1].num_digit > 80) {
                    Console.WriteLine("overflow");
                    continue;
                }
                if (data[0].num_digit < data[1].num_digit) {
                    Bigint tempo = data[0];
                    data[0] = data[1];
                    data[1] = tempo;
                }

                Bigint solution = calcNum.calcSum(data[0], data[1]);

                if (solution.num_digit > 80) {
                    Console.WriteLine("overflow");
                    continue;
                }
                string sum = solution.ToString();
                Console.WriteLine(sum);
            }
       }
    }
    public class Bigint{
        public int[] digit;
        public int num_digit;
        const int MAXLENGTH = 81;

        public Bigint(string data) {
            num_digit = data.Length;
            digit = new int[MAXLENGTH];
            for (int i = 0; i < MAXLENGTH; i++) {
                if (MAXLENGTH > num_digit && i >= num_digit) break;
                digit[i] = int.Parse(data.Substring(num_digit - i - 1, 1));
			}
        }

        public void setNumDigit(int num){
            num_digit = num;
        }

        public override string ToString(){
            string solution = "";
            for (int i = num_digit-1; i >= 0; i--) {
                string subSolution = digit[i].ToString();
                solution += subSolution.Substring(subSolution.Length - 1, 1);
			}
            if (digit[num_digit-1] >= 10) {
                solution = "1" + solution;
            }
            return solution;
        }
    }
    public class calcNum {
        public static Bigint calcSum(Bigint a, Bigint b) {
            Bigint solution = new Bigint("");
            bool isCarry = false;
            int Maxlength = a.num_digit;

            for (int i = 0; i < Maxlength; i++) {
                solution.digit[i] = a.digit[i]+b.digit[i];

                if (isCarry == true) {
                    solution.digit[i]++;
                    isCarry = false;
                }

                if (solution.digit[i] >= 10) {
                    isCarry = true;
                    continue;
                }
            }
            if (solution.digit[Maxlength - 1] >= 10) {
                solution.digit[Maxlength] = 1;
                solution.setNumDigit(a.num_digit+1);
            }else solution.setNumDigit(a.num_digit);
            return solution;
        }
    }
}

Measured memory_bytes: 9292
//ihdignite

#include <bits/stdc++.h>

using namespace std;

const int mxN=1e3, di[4]={1, 0, -1, 0}, dj[4]={0, 1, 0, -1};
int h, w, d[mxN][mxN], ans;
string a[mxN];
queue<array<int, 2>> qu;

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

	cin >> h >> w;
	memset(d, 0x3f, sizeof(d));
	for(int i=0; i<h; ++i) {
		cin >> a[i];
		for(int j=0; j<w; ++j) {
			if(a[i][j]=='#') {
				qu.push({i, j});
				d[i][j]=0;
			}
		}
	}
	while(!qu.empty()) {
		array<int, 2> u=qu.front();
		qu.pop();
		ans=max(ans, d[u[0]][u[1]]);
		for(int k=0; k<4; ++k) {
			int ni=u[0]+di[k], nj=u[1]+dj[k];
			if(ni>=0&&ni<h&&nj>=0&&nj<w&&d[ni][nj]>1e9) {
				d[ni][nj]=d[u[0]][u[1]]+1;
				qu.push(array<int, 2>{ni, nj});
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 13456
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		Set<Integer> set = new TreeSet<>();
		for (int i = 0; i < N; i++) {
			set.add(scanner.nextInt());
		}
		List<Integer> list = new ArrayList<>(set);
		int count = 0;
		for (int i = 0; i < list.size(); i++) {
			if (i == 0) {
				continue;
			}
			count += list.get(i) - list.get(i-1);
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    string s; cin >> s;
    ll n = s.size();
    vl cnt(2,0);
    rep(i,n){
        cnt[i&1] += '1' - s[i];
    }
    cout << min(cnt[0]+n/2-cnt[1], cnt[1]+(n+1)/2-cnt[0]) << endl;
}

Measured memory_bytes: 512
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
int size(T)(in T s) { return cast(int)s.length; }

class RangeSumQuery2 {
    // root縺ｮindex縺ｯ1
    int N;
    int orgN;
    long[] V, L;
    this(int N) {
        import core.bitop;
        this.orgN = N;
        this.N = 1 << (bsr(N - 1) + 1);
        this.V = new long[2 * this.N];
        this.L = new long[2 * this.N];
    }
    /* [s, t)縺ｫ荳讒倥↓x繧貞刈邂・*/
    void add(long x, int s, int t) { return add(x, s, t, 0, N, 1); }
    void add(long x, int s, int t, int a, int b, int k) {
        if (t <= a || b <= s) return;
        if (s <= a && b <= t) {
            L[k] += x;
            return;
        }
        if (s < b || a < t) {
            V[k] += (min(t, b) - max(s, a)) * x;
            if (b - a == 1) return;
            int m = (a + b) / 2;
            add(x, s, t, a, m, k * 2);
            add(x, s, t, m, b, k * 2 + 1);
        }
    }
    /* [s, t)縺ｮ蜥・*/
    long query(int s, int t) const { return query(s, t, 0, N, 1); }
    long query(int s, int t, int a, int b, int k) const {
        if (t <= a || b <= s) return 0;
        if (s <= a && b <= t) return V[k] + L[k] * (b - a);
        int m = (a + b) / 2;
        return (min(t, b) - max(s, a)) * L[k] +
            query(s, t, a, m, k * 2) +
            query(s, t, m, b, k * 2 + 1);
    }
    string dump() const {
        auto buf = appender!string();
        buf.put("RSQ2[");
        for (int i = 0; i < orgN; i++) {
            buf.put(format("%4d", this.query(i, i + 1)));
        }
        buf.put("]");
        return buf.data;
    }
};

void main() {
    int N, M; readf("%d %d\n", &N, &M);
    auto L = new int[N];
    auto R = new int[N];
    foreach (i; 0 .. N) {
        int l, r; readf("%d %d\n", &l, &r);
        L[i] = l;
        R[i] = r;
    }
    auto I = iota(0, N, 1).array.sort!((i, j) => R[i] - L[i] < R[j] - L[j]).array;
    int i = 0;
    long base = N;
    auto rsq = new RangeSumQuery2(M + 1);
    for (int t = 1; t <= M; t++) {
        long count = base;
        for (int x = t; x <= M; x += t) {
            count += rsq.query(x, x + 1);
        }
        while (i < N && R[I[i]] - L[I[i]] + 1 == t) {
            base--;
            rsq.add(1, L[I[i]], R[I[i]] + 1);
            i++;
        }
        writeln(count);
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using lint = long long;
using ulint = unsigned long long;


vector<pair<long long, long long> > prime_factorize(long long N)
{
    vector<pair<long long, long long> > res;
    for(long long a = 2; a * a <= N; ++a){
        if(N % a != 0) continue;
        long long ex = 0;

        while(N % a == 0){
            ++ex;
            N /= a;
        }

        res.push_back({a, ex});
    }

    if(N != 1) res.push_back({N, 1});
    return res;
}
int main(void)
{
    
    lint N;
    cin >> N;

    vector<pair<lint, lint> > prime = prime_factorize(N);

    
    int c = 1;
    lint cnt = 0;

    for(int i = 0; i < prime.size();i++){
        int n_p = prime[i].second;
        for(int j = 1; n_p >= j; j++){
            cnt++;
            n_p -= j;
        }
    }
    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    
    bool rev = false;

    deque<char> deq;

    for(char c:s)deq.push_back(c);

    for(int i = 0;i < q;i++){
        int t;
        cin >> t;
        if(t == 1){
            if(rev == false)rev = true;
            else rev = false;
        }
        if(t == 2){
            int f;
            cin >> f;
            char c;
            cin >> c;
            if(f == 1){
                if(rev == false)deq.push_front(c);//s = c + s;
                else deq.push_back(c);//s = s + c;
            }
            else{
                if(rev == false)deq.push_back(c);//s = s + c;
                else deq.push_front(c);//s = c + s;
            }
        }
    }


    string ans = "";
    for(int i = 0;i < deq.size();i++){
        ans += deq[i];
    }

    if(rev)reverse(ans.begin(),ans.end());

    cout << ans << endl;
}


Measured memory_bytes: 1540
#include <bits/stdc++.h>
using namespace std;
int main(){
 vector<vector<int>> kuku(9, vector<int> (9));
  for (int i=0; i<9; i++){
   for (int j=0; j<9; j++)
     kuku.at(i).at(j) = (i+1)*(j+1);
  }

 int N;
 cin >>N;
  
 int count = 0;
  
 for (int i=0; i<9; i++){
   for (int j=0; j<9; j++){
    if (N == kuku.at(i).at(j))
      count++;
   }
  }

  if (count>0)
    cout << "Yes" <<endl;
  else
    cout << "No" <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    string s;
    cin>>s;
    s[0]='2';
    s[1]='0';
    s[2]='1';
    s[3]='8';
    cout<<s;
    system ("pause"); 
    return 0;
}

Measured memory_bytes: 504
#include <cstdlib>
#include <iostream>
#include <stack>
#include <sstream>
#include <string>
#include <list>

typedef std::list<std::string> TList;
TList SplitString(std::string S)
{
    TList List;
    std::istringstream Input(S);
    std::string s;
    while(getline(Input, s, ' ')){
        List.push_back(s);
    }
    return List;
}
TList GetInputStrings(std::istream& Input)
{
    TList List;
    std::string s;
    while(std::getline(Input, s, ' ')){
        List.push_back(s);
    }
    return List;
}
int Rpn(const TList& List)
{
    std::stack<int> Stack;
    for(TList::const_iterator It = List.begin();
        It != List.end();
        ++It)
    {
        switch((*It)[0]){
        case '+':{
            int a = Stack.top(); Stack.pop();
            int b = Stack.top(); Stack.pop();
            Stack.push(b + a);
            break;
        }
        case '-':{
            int a = Stack.top(); Stack.pop();
            int b = Stack.top(); Stack.pop();
            Stack.push(b - a);
            break;
        }
        case '*':{
            int a = Stack.top(); Stack.pop();
            int b = Stack.top(); Stack.pop();
            Stack.push(b * a);
            break;
        }
        default:{
            Stack.push(std::atoi(It->c_str()));
            break;
        }
    }
    }
    return Stack.top();
}
int main()
{
    TList List = GetInputStrings(std::cin);
    std::cout << Rpn(List) << std::endl;
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <deque>
#include <array>
#include <cmath>

using namespace std;

int main()
{
  string str;

  cin >> str;

  if (str[2] == str[3] && str[4] == str[5])
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    let mut input = buffer.lines();
    let num_snukes = input
        .next()
        .unwrap()
        .split_whitespace()
        .next()
        .unwrap()
        .parse()
        .unwrap();
    input.next();
    let snacks = input
        .step_by(2)
        .flat_map(|s| s.split_whitespace().map(|w| w.parse::<usize>().unwrap()));
    let mut snukes = vec![false; num_snukes];
    for snack in snacks {
        snukes[snack - 1] = true;
    }
    let num_victims = snukes.into_iter().filter(|has_snack| !has_snack).count();
    println!("{}", num_victims);
}


Measured memory_bytes: 2136
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

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

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const int UnionFindTree_MAX_V = 100000;
struct UnionFindTree{
	int par[UnionFindTree_MAX_V+10],r[UnionFindTree_MAX_V+10];
	void init(int n = UnionFindTree_MAX_V){
		for(int i = 0 ; i < n+10 ; i ++){
			par[i] = i;
			r[i] = 0;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		if(r[x] < r[y]){
			par[x] = y;
		}
		else {
			par[y] = x;
			if(r[x] == r[y]){
				r[x] ++;
			}
		}
	}
}uf;

int main(){
	static int n,h;
	static int a[100010],b[100010],c[100010],d[100010];
	scanf("%d%d",&n,&h);
	rep1(i,n)scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	
	static int e[100010],f[100010];
	rep1(i,n){
		if(c[i] == 0)e[i] = h+a[i];
		else e[i] = h-c[i];
		if(d[i] == 0)f[i] = h+b[i];
		else f[i] = h-d[i];
	}
	uf.init();
	static int cnt[2][402] = {};
	rep1(i,n){
		cnt[0][e[i]] ++;
		cnt[1][f[i]] --;
		uf.unit(e[i],f[i]+500);
	}
	rep(i,h){
		if(cnt[0][i] > 0){
			cnt[1][2*h-i] += cnt[0][i];
			if(cnt[1][2*h-i]>0){
				puts("NO");
				return 0;
			}
			cnt[0][i] = 0;
			uf.unit(i,2*h-i+500);
		}
	}
	rep(i,h){
		if(cnt[1][i] < 0){
			cnt[0][2*h-i] += cnt[1][i];
			if(cnt[0][2*h-i]<0){
				puts("NO");
				return 0;
			}
			cnt[1][i] = 0;
			uf.unit(2*h-i,i+500);
		}
	}
	
	static int siz[1002] = {},CNT[1002] = {};
	rep(i,1002){
		siz[uf.find(i)] ++;
		if(h < i && i <= 2*h)CNT[uf.find(i)] += cnt[0][i];
	}
	rep(i,1002){
		if(siz[i] > 1 && CNT[i] <= 0){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}



Measured memory_bytes: 3456
N = int(input())
f = True
for h in range(1,3501):
  for n in range(1,3501):
    w_ = (-(h+n)/(h*n) + 4/N)
    if w_ > 0:
      w = (1/w_)
      if w%1 < 10E-8:
        print(h,n,int(w))
        f = False
        break
  if not f:
    break

Measured memory_bytes: 41052
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n;
    cin >> n;
    vector<int> A(n), B(n);
    for (auto &&i : A) scanf("%d", &i);
    for (auto &&i : B) scanf("%d", &i);
    auto dp = make_v(n, 1 << n, INF<int>), dp2 = dp;
    auto cnt = make_v(1 << n, 0);
    for (int i = 0; i < 1 << n; i++) {
        for (int j = 0; j < n; j++) {
            dp2[j][i] = 0;
            if ((i >> j) & 1)continue;
            for (int k = j + 1; k < n; k++) {
                if ((i >> k) & 1)dp2[j][i]++;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        dp[i][1 << i] = 0;
    }
    for (int i = 0; i < 1 << n; ++i) {
        cnt[i] = __builtin_popcount(i)-1;
    }
    for (int i = 0; i < 1 << n; i++) {
        int used = 0;
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) used++;
        }
        for (int j = 0; j < n; j++) {
            if (dp[j][i] == INF<int>)continue;
            int val = 0;
            if (used % 2 != j % 2) val = A[j];
            else val = B[j];
            for (int k = 0; k < n; k++) {
                if ((i >> k) & 1)continue;
                int c = 0;
                if (used % 2 == k % 2)c = A[k];
                else c = B[k];
                if (val > c)continue;
                dp[k][i | (1 << k)] = min(dp[k][i | (1 << k)], dp[j][i] + dp2[k][i]);
            }
        }
    }
    int ans = INF<int>;
    for (int i = 0; i < n; ++i) {
        ans = min(ans, dp[i].back());
    }
    if(ans == INF<int>){
        puts("-1");
    }else {
        cout << ans << "\n";
    }
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

typedef long long ll;

using namespace std;

const int L = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = (1LL << 61);

int n;
vector <int> a;
ll ans;
unordered_map <int, int> m;

ll bin_pow(ll n, ll m) {
    if (m == 0) return 1;
    if (m & 1) {
        ll pr = bin_pow(n, m - 1);
        return pr * n % MOD;
    }
    else {
        ll half = bin_pow(n, m / 2);
        return half * half % MOD;
    }
}

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

    cin >> n;
    a.resize(n);
    for (int &i : a) cin >> i;
    
    for (int i = 0; i < n; ++i) {
        int cur = a[i];
        for (int j = 2; j * j <= cur; ++j) {
            if (cur % j == 0) {
                int cnt = 0;
                while (cur % j == 0) {cur /= j; ++cnt;}
                m[j] = max(m[j], cnt);
            }
        }
        if (cur > 1) {
            m[cur] = max(m[cur], 1);
        }
    }
    
    for (int i = 0; i < n; ++i) {
        ll cur = 1;
        vector <pair <int, int>> v;
        for (int j = 2; j * j <= a[i]; ++j) {
            if (a[i] % j == 0) {
                v.push_back({j, 0});
                while (a[i] % j == 0) {
                    a[i] /= j;
                    ++v.back().second;
                }
            }
        }
        if (a[i] > 1) v.push_back({a[i], 1});
        for (auto j : v) m[j.first] -= j.second;
        for (auto j : m) {
            cur *= bin_pow(j.first, j.second);
            cur %= MOD;
        }
        for (auto j : v) m[j.first] += j.second;
        ans += cur;
        ans %= MOD;
    }
    cout << ans;

    return 0;
}
/// ACTUAL CODE STARTS HERE:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


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

int main(){

  int a, b, c;
  cin >> a >> b >> c;
  set<int> s = {10*a+b+c, a+10*b+c, a+b+10*c};
  int ans = 0;
  for(auto v: s){
    ans = max(ans, v);
  }
  cout << ans << endl;

}


Measured memory_bytes: 384
//
//  main.cpp
//  ABC_066_B
//
//  Created by Joe Mori on 2020/05/30.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>
#include<string>
int main() {
    std::string str;
    std::cin>>str;
    if(str.length()%2==1){
        str.erase(str.length()-1,1);
    }else str.erase(str.length()-2,2);
    while(true){
//        std::cout<<str<<std::endl;
//        std::cout<<str.substr(str.length()/2)<<" "<<str.substr(0,str.length()/2)<<std::endl;
        if(str.substr(str.length()/2)==str.substr(0,str.length()/2)){
            std::cout<<str.length()<<std::endl;
            break;
        }else{
            str.erase(str.length()-2,2);
        }
    }
    return 0;
}



Measured memory_bytes: 256
n,k=map(int,input().split())
P=list(map(int,input().split()))
S=[0]*(n+1)
for i in range(n):
   S[i+1]=S[i]+P[i]
ans=0
for i in range(n-k+1):
   ans=max(ans,S[i+k]-S[i])
print((ans+k)/2)

Measured memory_bytes: 71792
n = input()
a = map(int, raw_input().strip().split())

yes = 1
if n == 1:
    print "Yes"
    exit()

for i in xrange(n - 1, 0, -1):
    if a[i] < a[i - 1]:
        if a[i] < (a[i - 1] - 1):
            yes = 0
            break
        else:
            a[i - 1] -= 1

if yes:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 42348
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    int n,m;
    cin >>n >> m;
    int minn=0,maxn=n;
    int a,b;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        if(a>b)
            swap(a,b);
        minn=max(minn,a);
        maxn=min(maxn,b);
        //cout <<minn << maxn << endl;
    }
    cout << max(maxn-minn+1,0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
typedef vector<P> G;
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}
// !CAUTION! number ツづ債有ツ猟敖青板暗按湘」
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
G convex_cut(const G& p, const L& l) {
  G Q;
  for (int i = 0; i < p.size(); ++i) {
    P A = curr(p, i), B = next(p, i);
    if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
    if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspoint(L(A, B), l));
  }
  return Q;
}

int main()
{
	int n;
	while(scanf("%d",&n),n)
	{
		G g,ng;
		g.pb(P(0,0)); g.pb(P(10000,0));
		g.pb(P(10000,10000)); g.pb(P(0,10000));
		
		int x[50],y[50];
		rep(i,n)scanf("%d%d",x+i,y+i);
		rep(i,n)
		{
			ng=convex_cut(g,L(P(x[i],y[i]),P(x[(i+1)%n],y[(i+1)%n])));
			if(ng.empty())
			{
				puts("0"); goto END;
			}
			g=ng;
		}
		puts("1"); END:;
	}
	return 0;
}

Measured memory_bytes: 0
n = int(raw_input())
d = {}
for _ in range(n-1):
  v,u = map(int, raw_input().split())
  if v in d:
    d[v].append(u)
  else:
    d[v] = [u]

  if u in d:
    d[u].append(v)
  else:
    d[u] = [v]

# -1: not yet, 0: fennec, 1: sunuke
visited = [-1] * (n+1)
visited[1] = 0
visited[n] = 1

# 0 == fennec, 1 == sunuke
q = [(1,1), (n,n)]

# 0: fennec
# 1: sunuke
count = [1,1]

while len(q) > 0:
  cur, prev = q.pop(0)

  for v in d[cur]:
    if v == prev: continue
    if visited[v] != -1: continue

    chara = visited[prev]
    visited[v] = chara
    count[chara] += 1

    q.append([v, cur])


if count[0] > count[1]:
  print 'Fennec'
else:
  print 'Snuke'

# TLE
# while len(q) > 0:
#   cur, prev, sunuke = q.pop(0)
#   # print cur,prev,sunuke

#   if visited[cur]:
#     continue

#   visited[cur] = True
#   if sunuke:
#     count_s += 1
#   else:
#     count_f += 1

#   for v in d[cur]:
#     q.append([v, cur, sunuke])

# if count_f > count_s:
#   print 'Fennec'
# else:
#   print 'Snuke'

Measured memory_bytes: 29516
#include <bits/stdc++.h>
using namespace std;
void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int k = (max(a, b) + min(a, b)) / (min(a, b) + 1);
    int l = 0, r = a;
    while (l < r) {
        int na = (l + r + 1) / 2;
        int nb = max(0, (na - 1) / k);
        if (b >= nb && b - nb <= 1LL * (a - na + 1) * k)
            l = na;
        else
            r = na - 1;
    }
    string s;
    l += max(0, (l - 1) / k);
    for (int i = --c; i < d; ++i) {
        if (i < l)
            s += "AB"[i % (k + 1) == k];
        else
            s += "BA"[(a + b - i - 1) % (k + 1) == k];
    }
    cout << s << "\n";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while (T--)
        solve();
    return 0;
}


Measured memory_bytes: 384
a, b, c, x, y = [int(i) for i in input().split()]

ans = float("inf")
max_ab = max(x, y) * 2
# abピザをi(=2n)枚買うと想定
for i in range(0, max_ab+1, 2):
    rest_x = max(0, x - i//2)
    rest_y = max(0, y - i//2)
    cost = c*i + a*rest_x + b*rest_y
    ans = min(ans, cost)

print(ans)


Measured memory_bytes: 39408
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N  = parseInt(arg[0].split(" ")[0]);
    const Q  = arg[0].split(" ")[1];
    const S  = arg[1];
    //const lr = arg.split("\n").slice(2, N + 1);
    let dp = new Array(N).fill(0);
    let cnt = 0;
    
    for(let i in dp) {
        if(S.charAt(i) === "A" && S.charAt(parseInt(i)+1) === "C") {
            cnt++;
        }
        
        dp[parseInt(i)+1] = cnt;
    }

    for(let i=0; i<Q; i++) {
        let lr = arg[i+2].split(" ");
        let l = lr[0];
        let r = lr[1];
        
        console.log(dp[r-1]-dp[l-1]);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 38796
#include <stdio.h>

#define MAX 10000

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}

int main(){
  int A[MAX+1],H,i;

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: ",i);
    printf("key = %d, ",A[i]);
    if(parent(i)>=1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i)<=H){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i)<=H){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }

  return 0;
}







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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> a(N), sum(N + 1), good(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
		good[i + 1] = good[i] + max(a[i], 0ll);
	}
	ll res = 0;
	for (int i = 0; i <= N - K; i++) {
		res = max(res, good[N] - good[i + K] + good[i] - good[0]);
		res = max(res, good[N] - good[i + K] + good[i] - good[0] + sum[i + K] - sum[i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <utility>
#include <queue>
#include <numeric>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
int n, m;
vector<int> ans;
vec2int g;
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  cin >> n >> m;
  ans = vecint(n, -1);
  ans[0] = 0;
  g = vector<vector<int>>(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vecint seen(n, 0);
  queue<int> q;
  q.push(0);

  while (!q.empty()) {
    int j = q.front();
    q.pop();
    seen[j] = 1;
    REPe(e, g[j]) {
      if (seen[e]) continue;
      ans[e] = j;
      seen[e] = 1;
      q.push(e);
    }
  }
  REP(i, n) {
    if (!seen[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  REP(i, n) {
    if (i == 0) continue;
    cout << ans[i] + 1 << endl;
  }
}


Measured memory_bytes: 10532
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll ma=0;
    ll mai=0;
    for (int i = 0; i < n; i++)
    {
        ll tempa;
        cin >> tempa;
        a.push_back(tempa);
        if(ma<abs(tempa)){
            mai=i;
            ma=abs(tempa);
        }
    }
    cout<<2*n-2<<"\n";
    if(a[mai]>=0){
        for(int i=0;i<n;i++){
            if(i==mai)continue;
            cout<<mai+1<<" "<<i+1<<"\n";
        }
        for(int i=0;i<n-1;i++){
            cout<<i+1<<" "<<i+2<<"\n";
        }
    }
    else{
        for(int i=0;i<n;i++){
            if(i==mai)continue;
            cout<<mai+1<<" "<<i+1<<"\n";
        }
        for(int i=0;i<n-1;i++){
            cout<<n-i<<" "<<n-i-1<<"\n";
        }  
    }
}



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

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        B.at(i) = A.at(i);
    }
    sort(B.begin(), B.end(), greater<int>());

    for (int i = 0; i < N; i++) {
        if (B.at(0) != A.at(i)) cout << B.at(0) << endl;
        else cout << B.at(1) << endl;
    }
}

Measured memory_bytes: 4808
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<vector>
#include<string>
using namespace std;

int a[10][10];
signed main() {
	int h, w; cin >> h >> w;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				a[j][k] = min(a[j][k], a[j][i] + a[i][k]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int n; cin >> n;
			if (n != -1)ans += a[n][1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# Segment Tree


class Segment:
    def __init__(self, N, init_val):
        self.N0 = 2 ** (N - 1).bit_length()
        # 0-indexedで管理
        self.dat = [identity_element] * (2 * self.N0)
        # 値を代入
        for i in range(N):
            self.dat[i + self.N0 - 1] = init_val[i]
        # 構築
        for i in range(self.N0 - 2, -1, -1):
            self.dat[i] = segfunc(self.dat[2 * i + 1], self.dat[2 * i + 2])

    # k番目の要素の値をxに変更
    def update(self, k, x):
        k += self.N0 - 1
        self.dat[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.dat[k] = segfunc(self.dat[2 * k + 1], self.dat[2 * k + 2])

    # 区間[l,r)の最小値を求める
    def query(self, l, r):
        L = l + self.N0
        R = r + self.N0
        s = identity_element
        # 区間を列挙しながら最小値を求める
        while L < R:
            if R & 1:
                R -= 1
                s = segfunc(s, self.dat[R - 1])
            if L & 1:
                s = segfunc(s, self.dat[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return s

# segfunc : min, +, *, xor, gcd など
# identity_element : 単位元(min:inf, 和:0, 積:1, xor:0, gcd:0)


def segfunc(x, y):
    return min(x, y)  # 変える


identity_element = 2 ** 31 - 1  # 変える


def compress(arr):
    *XS, = set(arr)
    XS.sort()
    return {e: i for i, e in enumerate(XS)}


n, q = map(int, input().split())
s, t, x = [0] * n, [0] * n, [0] * n
for i in range(n):
    s[i], t[i], x[i] = map(int, input().split())
    s[i] -= x[i]
    t[i] -= x[i]
    s[i] = max(s[i], 0)
    t[i] = max(t[i], 0)

d = [int(input()) for i in range(q)]

com = compress(s + t + d)
k = len(com) + 1

for i in range(n):
    s[i] = com[s[i]]
    t[i] = com[t[i]]

for i in range(q):
    d[i] = com[d[i]]
INF = 1 << 30
a = [INF] * k
b = [[] for i in range(k)]
c = [[] for i in range(k)]
seg = Segment(n, [INF] * n)
for i in range(n):
    b[s[i]].append(i)
    c[t[i]].append(i)

for i in range(k):
    for j in b[i]:
        seg.update(j, x[j])
    for j in c[i]:
        seg.update(j, INF)
    a[i] = seg.query(0, n)

for i in d:
    print(-1 if a[i] == INF else a[i])


Measured memory_bytes: 248632
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nt = readln.split.to!(int[]);
    auto N = nt[0];
    auto T = nt[1];
    int[2][] cts;
    cts.length = N;
    foreach (i; 0..N) {
        auto ct = readln.split.to!(int[]);
        cts[i] = [ct[0], ct[1]];
    }
    sort!"a[0] < b[0]"(cts);
    foreach (ct; cts) {
        if (ct[1] <= T) {
            writeln(ct[0]);
            return;
        }
    }
    writeln("TLE");
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
input = sys.stdin.readline
mod = 998244353
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
def main():
    n,s = map(int,input().split())
    a = list(map(int, input().split()))
    dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
    dp[0][0] = pow(2,n,mod)
    MODINV2 = mod_inv(2,mod)
    ans = 0
    for i in range(n):
        for j in range(s,-1,-1):
            if j-a[i] < 0:
                continue
            dp[i+1][j] += dp[i][j-a[i]]*MODINV2
            dp[i+1][j] %= mod
        for j in range(s,-1,-1):
            if j == s:
                ans += dp[i+1][j]
                ans %= mod
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= mod
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 148508
W, H, x, y = map(float,input().split())

#長方形の重心を求める
gx = W / 2.0
gy = H / 2.0

# x,yが重心と一致する場合は複数ある
split = 0

if x == gx and y == gy:
    split = 1

print(W*H/2.0,split)


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

int main(){
      int n,k;cin >> n >> k;
      int ans = 0;
      for(int i = 0;i < n;i++){
            int t;cin >> t;
            ans += min(t * 2,abs(t - k) * 2);
      }
      cout << ans;
}

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) r *= m; m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

int N;
bool a[21][21];
modint dp[1<<22];
bool flag[1<<22];

modint solve(bitset<21>f) {
  if(flag[f.to_ulong()]) return dp[f.to_ulong()];
  flag[f.to_ulong()] = true;
  if(f.count()==0) return dp[f.to_ulong()] = modint(1);

  modint ret(0);
  int mi = N-f.count();
  for(int fi=0; fi<21; fi++) {
    if(f[fi]==0) continue;
    if(!a[mi][fi]) continue;
    bitset<21> fnew = f;
    fnew[fi] = 0;
    ret += solve(fnew);
  }
  return dp[f.to_ulong()] = ret;
}

signed main() {
  cin >> N;
  for(int i=0; i<N; i++) for(int j=0; j<N; j++) cin >> a[i][j];
  bitset<21> f((1<<N)-1);
  cout << solve(f) << endl;
}

Measured memory_bytes: 37120
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int f, s;
  f = a * b;
  s = c * d;
  if(f < s) {
    cout << s << endl;
  } else {
    cout << f << endl;
  }
  return 0;
}


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

using namespace std;

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "yes"
#define FALSE__ "no"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int main()
{
	int n, sum = 0;
	int s[100];
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		sum += s[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	sort(s, s+n);
	rep(i, n) {
		if (s[i] % 10 != 0) {
			cout << sum-s[i] << endl;
			return 0;
		}
	}
	cout << 0 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    int n,k;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    if((n+1)/2 < k) puts("NO");
    else puts("YES");
    return 0;
}

Measured memory_bytes: 256
import fractions


def main():
    N = int(input())
    A = list(map(int, input().split()))

    gcd_ans = []
 
    l = [0] * N
    r =[0] * N
    for i in range(N-1):
        l[i+1] = fractions.gcd(l[i],A[i])
        r[i+1] = fractions.gcd(r[i],A[N-1-i])
    r.reverse()
 
    for i in range(N):
        gcd_ans.append(fractions.gcd(l[i],r[i]))
 
    print(max(gcd_ans))


main()

Measured memory_bytes: 89952
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long sum = 0;
        for (int i = 0; i < N; i++) {
            sum += sc.nextInt();
        }

        sum -= N;
        System.out.println(sum);
        sc.close();

    }
}


Measured memory_bytes: 25896