akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, arr[100005], coun[100005];
set<pi> s;
set<int> pos;

int main() {
	fastio; cin >> n;
	if (n == 2) {cout << -1; return 0;}
	FOR(i, 1, n) {
		cin >> arr[i];
		coun[arr[i]]++;
	}
	FOR(i, 1, n) {
		s.insert(pi(coun[i], i));
		pos.insert(i);
	}
	int no = -1;
	while (n) {
		if (n == 3) {
			vector<int> a, v; a.clear(); v.clear();
			for(auto it:pos) a.pb(it);
			do {
				bool ok = true; int nn = no;
				for(auto it:a) {
					if (nn == it) {ok = false; break;}
					nn = arr[it];
				}
				if (ok) {
					if (v.empty()) v = a;
					else v = min(v, a);
				}
			} while (next_permutation(a.begin(), a.end()));
			for(auto it:v) cout << it << " ";
			return 0;
		}
		pi t = *(--s.end());
		int a = t.f, b = t.s;
		int cur = 0;
		if (a == n-1) cur = b;
		else {
			for (auto it:pos) {
				if (it != no) {
					cur = it;
					break;
				}
			}
		}
		cout << cur << " ";
		pos.erase(cur); s.erase(pi(coun[cur], cur));
		no = arr[cur]; n--;
		if (pos.find(no) != pos.end()) {
			s.erase(pi(coun[no], no));
			--coun[no];
			s.insert(pi(coun[no], no));
		}
	}
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;  // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

int main() {
  bool a[100005];
  int b[100005];
  REP(i, 100001) { a[i] = IsPrime(i); }
  FOR(i, 3, 100001) {
    b[i] = b[i - 1];
    if (i % 2 != 0 && a[i] && a[(i + 1) / 2]) b[i] += 1;
  }
  int q;
  cin >> q;
  int l[100005];
  int r[100005];
  REP(i, q) { cin >> l[i] >> r[i]; }
  REP(i, q) { cout << b[r[i]] - b[l[i] - 1] << endl; }
}

Measured memory_bytes: 1920
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define REP(i, n) REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n) for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n) std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n) std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2) ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A) (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2) (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2) (((p1)>(p2))?(p1):(p2))
#define GETSTR(p)           do{ fgets((p), sizeof(p), stdin); } while(0)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0;      } while(0)
#define GETI1(buf,p1)       do{ GETSTR(buf); sscanf((buf), "%d", &(p1));                    } while(0)
#define GETI2(buf,p1,p2)    do{ GETSTR(buf); sscanf((buf), "%d%d ", &(p1),&(p2));           } while(0)
#define GETI3(buf,p1,p2,p3) do{ GETSTR(buf); sscanf((buf), "%d%d%d ", &(p1),&(p2),&(p3));   } while(0)

#ifdef _DEBUG
#define pf printf
#else
#define pf(...) /* */
#endif

typedef long long ll;
typedef unsigned long long ull;

map <int, int> h;

int main(void){
    int result;
    char buf[1024];

    while(fgets((buf), sizeof(buf), stdin)){
        int p,q;
        sscanf((buf), "%d%d ", &p,&q);
        pf("DEBUG1: %d,%d\n", p,q);

        h.clear();
        h.insert(make_pair(p,0));
        p *= 10;

        int i = 0;
        while(p != 0){
            int d,m;
            d = p/q;
            m = p%q;
            printf("%d", d);
            if(h.find(m) != h.end()) break;

            i++;
            h.insert(make_pair(m, i));
            p = m * 10;
        }
        printf("\n");
        if(p != 0){
            int m = p%q;
            int k = h[m];
            pf("DEBUG2: %d %d\n", i, h[m]);
            REP(j, i+1){
                if(j < k){
                    printf(" ");
                } else {
                    printf("^");
                }
            }
            printf("\n");
        }

    }

    return 0;
}

Measured memory_bytes: 1208
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	static class Subset {
		Long money;
		Long number;
		
		Subset(Long money, Long number){
			this.money = money;
			this.number = number;
		}

		public Long getMoney() {
			return money;
		}

		public void setMoney(Long money) {
			this.money = money;
		}

		public Long getNumber() {
			return number;
		}

		public void setNumber(Long number) {
			this.number = number;
		}
		
	}
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		
		List<Subset> list = new ArrayList<Subset>();
		for(int i=0; i<n; i++) {
			Subset ss = new Subset(sc.nextLong(), sc.nextLong());
			list.add(ss);
		}
		
		Collections.sort(list, new Comparator<Subset>() {
            public int compare(Subset o1, Subset o2) {
                return (o1.getMoney()).compareTo(o2.getMoney());
            }
        });
		long nokori = 0;
		long sum = 0;
		long cnt = 0;
		int i=0;
		for(; i<list.size(); i++) {
			cnt += list.get(i).getNumber();
			if(cnt>=m) {
				break;
			}else {
				continue;
			}
		}
		for(int p=0; p<i; p++) {
			sum += list.get(p).getMoney()*list.get(p).getNumber();
		}
		nokori = list.get(i).getNumber() - (cnt - m);
		sum += nokori*list.get(i).getMoney();
		System.out.println(sum);
	}
}


Measured memory_bytes: 92212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 998244353;

int main(){
  int h, w;
  cin >> h >> w;
  int cnt = 0;

  rep(i,h) rep(j,w) {
    char c;
    cin >> c;
    if (c == '#') cnt++;
  }
  if (cnt == h + w - 1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
} 

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn=100000,mod=1000000007;
const ll inf=0x3f3f3f3f3f3f3f3f;
int n,m,s,t,ans; queue<int> q;
struct hnode{
	int id; ll v;
	bool operator<(const hnode &t)const{
		return v>t.v;
	}
};
struct edge{int to,len;};
priority_queue<hnode> hp;
struct graph{
	vector<edge> g[maxn+10]; ll dis[maxn+10]; int dz[maxn+10],f[maxn+10];
	vector<edge> z[maxn+10];
	void add(int u,int v,int w){
		g[u].push_back((edge){v,w});
		g[v].push_back((edge){u,w});
	}
	void dijkstra(int s){
		for(int i=1;i<=n;++i) dis[i]=i==s?0:inf;
		hp.push((hnode){s,0});
		for(;!hp.empty();){
			hnode x=hp.top(); hp.pop(); if(x.v>dis[x.id]) continue;
			for(int i=0;i<g[x.id].size();++i){
				edge e=g[x.id][i];
				if(x.v+e.len<dis[e.to]){
					dis[e.to]=x.v+e.len; hp.push((hnode){e.to,dis[e.to]});
				}
			}
		}
	}
	void addeg(int u,int v,int w){z[u].push_back((edge){v,w}); ++dz[v];}
	void buildnew(){
		for(int i=1;i<=n;++i)
			for(int j=0;j<g[i].size();++j){
				edge e=g[i][j]; if(dis[i]+e.len==dis[e.to]) addeg(i,e.to,e.len);
			}
	}
	void topsort(int s){
		f[s]=1; for(int i=1;i<=n;++i) if(!dz[i]) q.push(i);
		for(;!q.empty();q.pop()){
			int x=q.front();
			for(int i=0;i<z[x].size();++i){
				int e=z[x][i].to; (f[e]+=f[x])%=mod;
				if(!--dz[e]) q.push(e);
			}
		}
	}
}g,rg;
int main(){
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=1;i<=m;++i){
		int l,r,w; scanf("%d%d%d",&l,&r,&w);
		g.add(l,r,w); rg.add(l,r,w);
	}
	g.dijkstra(s); rg.dijkstra(t); 
	g.buildnew(); rg.buildnew(); 
	ll d=g.dis[t];
	g.topsort(s); rg.topsort(t); ans=1ll*g.f[t]*rg.f[s]%mod;
	for(int i=1;i<=n;++i){
		for(int j=0;j<g.g[i].size();++j){
			edge e=g.g[i][j];
			if(g.dis[i]+e.len+rg.dis[e.to]==d&&g.dis[i]*2<d&&g.dis[e.to]*2>d){
				ll now=1ll*g.f[i]*rg.f[e.to]%mod;
				ans-=1ll*now*now%mod;
				ans=(ans+mod)%mod;
			}
		}
		if(g.dis[i]+rg.dis[i]==d&&g.dis[i]*2==d){
			ll now=1ll*g.f[i]*rg.f[i]%mod;
			ans-=1ll*now*now%mod;
			ans=(ans+mod)%mod;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 31612
using static System.Console;

public class Hello
{
    public static void Main()
    {
        string l = ReadLine();
        bool b = false;
        if (l[0] == l[1] && l[2] == l[3]) b = true;
        if (l[0] == l[2] && l[1] == l[3]) b = true;
        if (l[0] == l[3] && l[2] == l[1]) b = true;
      	if (l[0] == l[1] && l[1] == l[2] && l[2] == l[3]) b =false;

        if (b) WriteLine("Yes");
        else WriteLine("No");

    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;

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

	reverse(x.begin(),x.end());

	int pop_count_x = 0;
	for(int i = 0;i < n;i++){
		if(x[i] == '1')pop_count_x++;
	}


	ll mod_x_plus = 0;
	ll mod_x_minus = 0;
	ll now_plus = 1;
	ll now_minus = 1;
	vector<ll> mod_2pow_plus(n,0);
	vector<ll> mod_2pow_minus(n,0);

	for(int i = 0;i < n;i++){
		if(pop_count_x != 1)now_minus %= (pop_count_x - 1);
		now_plus %= (pop_count_x + 1);
		if(x[i] == '1'){
			mod_x_minus += now_minus;
			mod_x_plus += now_plus;
		}
		mod_2pow_minus[i] = now_minus;
		mod_2pow_plus[i] = now_plus;
		if(pop_count_x != 1)now_minus *= 2;
		now_plus *= 2;
	}

	vector<int> ans(n);
	for(int i = 0;i < n;i++){
		ll now_x;
		if(x[i] == '0'){
			now_x = (mod_x_plus + mod_2pow_plus[i]) % (pop_count_x + 1);
		}
		else{
			if(pop_count_x == 1){
				ans[i] = 0;
				continue;
			}
			now_x = (mod_x_minus - mod_2pow_minus[i] + pop_count_x - 1) % (pop_count_x - 1);
		}

		int cnt = 1;

		while(now_x > 0){
			ll tmp = now_x;
			int pop_cnt = 0;
			while(tmp > 0){
				if(tmp % 2 == 1)pop_cnt++;
				tmp /= 2;
			}
			now_x = now_x % pop_cnt;
			cnt++;
		}
		ans[i] = cnt;
	}

	for(int i = n - 1;i >= 0;i--){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 7552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            StringTokenizer st = new StringTokenizer(br.readLine());
            int N = Integer.valueOf(st.nextToken());
            int M = Integer.valueOf(st.nextToken());
            Map<String, String> map = new HashMap<String, String>();
            String[][] data = new String[M][2];
            String[] a = new String[M];
            for (int i = 0; i < M; i++) {
                st = new StringTokenizer(br.readLine());
                String p = st.nextToken();
                String y = st.nextToken();

                String p0 = "000000" + p;
                String y0 = "000000000" + y;

                String tempp = p0.substring(p0.length() - 6, p0.length());
                String tempy = y0.substring(y0.length() - 10, y0.length());
                data[i][0] = tempp;
                data[i][1] = tempy;
                a[i] = tempp + "_" + tempy;
            }
            Arrays.sort(a);
            int index = 1;
            String t = a[0].split("_")[0];
            for (int i = 0; i < M; i++) {
                String[] temps = a[i].split("_");
                if (t.equals(temps[0])) {
                    map.put(a[i], "" + index);
                    index++;
                } else {
                    t = temps[0];
                    index = 1;
                    map.put(a[i], "" + index);
                    index++;
                }
            }
            for (int i = 0; i < M; i++) {
                String num = map.get(data[i][0] + "_" + data[i][1]);
                num = "000000000" + num;
                num = num.substring(num.length() - 6, num.length());
                System.out.println(data[i][0] + "" + num);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}

Measured memory_bytes: 136332
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,bool directed>
struct Dinic{
  struct edge {
    int to;
    T cap;
    int rev;
    edge(){}
    edge(int to,T cap,int rev):to(to),cap(cap),rev(rev){}
  };

  vector< vector<edge> > G;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int n):G(n),level(n),iter(n){}

  int add_edge(int from,int to,T cap){
    G[from].emplace_back(to,cap,G[to].size());
    G[to].emplace_back(from,directed?0:cap,G[from].size()-1);
    return G[to].back().rev;
  }

  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.emplace(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.emplace(e.to);
        }
      }
    }
  }

  T dfs(int v,int t,T f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        T d=dfs(e.to,t,min(f,e.cap));
        if(d==0) continue;
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
    return 0;
  }

  T flow(int s,int t,T lim){
    T fl=0;
    while(1){
      bfs(s);
      if(level[t]<0||lim==0) break;
      fill(iter.begin(),iter.end(),0);

      while(1){
        T f=dfs(s,t,lim);
        if(f==0) break;
        fl+=f;
        lim-=f;
      }
    }
    return fl;
  }

  T flow(int s,int t){
    return flow(s,t,numeric_limits<T>::max()/2);
  }

  T cut(int s,int t,int x,int a){
    static_assert(directed, "must be directed");
    auto &e=G[x][a];
    int y=e.to;
    T cr=G[y][e.rev].cap;
    if(cr==0) return e.cap=0;
    e.cap=G[y][e.rev].cap=0;
    T cap=cr-flow(x,y,cr);
    if(x!=s&&cap!=0) flow(x,s,cap);
    if(t!=y&&cap!=0) flow(t,y,cap);
    return cap;
  }

  T link(int s,int t,int x,int a,T f){
    auto &e=G[x][a];
    e.cap+=f;
    return flow(s,t,f);
  }
};

//INSERT ABOVE HERE
signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(int i=0;i<h;i++) cin>>st[i];

  auto idx=[&](int i,int j,int k){return h+w+(i*w+j)*2+k;};

  const int INF = 1e5;
  Dinic<int, true> G(h*w*2+h+w);
  int S=-1,T=-1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(st[i][j]=='.') continue;
      if(st[i][j]=='S') S=idx(i,j,1);
      if(st[i][j]=='T') T=idx(i,j,0);
      G.add_edge(idx(i,j,0),idx(i,j,1),1);
      G.add_edge(idx(i,j,1),0+i,INF);
      G.add_edge(idx(i,j,1),h+j,INF);
      G.add_edge(0+i,idx(i,j,0),INF);
      G.add_edge(h+j,idx(i,j,0),INF);
    }
  }

  assert(~S);
  assert(~T);
  int ans=G.flow(S,T);
  if(ans>=INF) ans=-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2816
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N;
  std::cin >> N;
  std::vector<i32> p(N);

  for (usize i = 0; i < N; i++) {
    std::cin >> p[i];
  }

  bool f = true;
  for (usize i = 0; i + 1 < N; i++) {
    if (p[i] > p[i + 1]) {
      f = false;
      break;
    }
  }

  if (f) {
    std::cout << "YES" << std::endl;
    return;
  }

  for (usize i = 0; i < N; i++) {
    for (usize j = i + 1; j < N; j++) {
      if (p[i] <= p[j]) continue;

      std::vector<i32> a = p;
      std::swap(a[i], a[j]);

      bool flag = true;
      for (usize k = 0; k + 1 < N; k++) {
        for (usize t = k + 1; t < N; t++) {
          if (a[k] > a[t]) {
            flag = false;
            break;
          }
        }
      }

      if (flag) {
        std::cout << "YES" << std::endl;
        return;
      }
    }
  }

  std::cout << "NO" << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


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

static const int days_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool isLeap(int year) {
	if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
		return true;
	return false;
}

int main() {
	while(1) {
		int y1, m1, d1, y2, m2, d2;
		cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;

		if(y1 == -1 && m1 == -1 && d1 == -1 && y2 == -1 && m2 == -1 && d2 == -1)
			break;

		int accume = 0;
		for(int year = y1; year <= y2; year++) {
			if(isLeap(year))
				accume += 366;
			else
				accume += 365;
		}
		for(int month = 0; month < m1 - 1; month++) {
			accume -= days_month[month];
			if(month == 1 && isLeap(y1))
				accume--;
		}
		for(int month = m2; month < 12; month++) {
			accume -= days_month[month];
			if(month == 1 && isLeap(y2))
				accume--;
		}
		for(int day = 1; day < d1; day++) {
			accume--;
		}
		for(int day = d2; day <= days_month[m2 - 1] + (m2 == 2 && isLeap(y2) ? 1 : 0); day++) {
			accume--;
		}

		cout << accume << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>     
      using namespace std;  
      typedef long long  ll;
      typedef pair<ll,ll> pll;  
      #define pb(x) push_back(x)     
      typedef unsigned long long  ull;     
      #define mem(A, X) memset(A, X, sizeof A)
      #define ford(i,l,u) for(ll (i)=(ll)(l);(i)>=(ll)(u);--(i))
      #define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
      #define fori(i,l,u) for(ll (i)=(ll)(l);(i)<=(ll)(u);++(i))    
      typedef pair<int,int> pii;
      #define sec second
      #define fir first  
    
      const ll mod=1e9+7; 
      const ll maxn=1e5+10; 
        
      int main()
      {
           std::ios::sync_with_stdio(false); 
          // freopen("in.txt","r",stdin); 
           ll n,m; 
           while(cin>>n>>m)
           {
            if(2l*n>=m)  cout<<m/2<<endl;
            else cout<<n+(m-2*n)/4<<endl; 
           }

        return 0;
      }

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    int n;
    cin >> n;
    cout << "ABC" << std::setfill('0') << std::setw(3) << n << endl;
    return 0;
}


Measured memory_bytes: 888
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}
using namespace std;

const int INF=1<<30;

const int maxn=100000+10;

int a[maxn];
int c[2][maxn],id1[maxn],id2[maxn];

inline int cmp1(int a,int b){
	return c[0][a] > c[0][b];	
}
inline int cmp2(int a,int b){
	return c[1][a] > c[1][b];	
}

int main()
{
	int n,V=0;cin>>n;
	rep(i,1,n) 
	{
		a[i]=read();
		V=max(V,a[i]);
		++c[i&1][a[i]];
	}
	
	rep(i,1,V) id1[i]=i,id2[i]=i;
	sort(id1+1,id1+V+1,cmp1);
	sort(id2+1,id2+V+1,cmp2);

//		for(int j=1;j<=10;++j) printf("%d ",id2[j]);
//		puts("");	
	
	int ans=0;
	if(id1[1]!=id2[1]){
		ans+=n-c[0][id1[1]]-c[1][id2[1]];	
	}
	else {
		int M=max(c[0][id1[1]]+c[1][id2[2]],c[0][id1[2]]+c[1][id2[1]]);
		ans+=n-M;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 2176
import numpy as np
from functools import lru_cache

N,K = map(int,input().split())
A = np.array(input().split(),dtype=np.int64)

bit_cnt = [((A>>k)&1).sum() for k in range(50)]

@lru_cache(maxsize = 10**6)
def F(K,k = 49):
  # K以下、k-bit目まで見た(inclusive)の和、最大値
  if k == -1:
    return 0
  bit = 1<<k
  # k-bitを使う
  x = 0
  if K >= bit:
    x = ((N-bit_cnt[k])<<k) + F(K-bit,k-1)
  # k-bitを使わない
  y = (bit_cnt[k]<<k) + F(min(K,bit-1),k-1)
  return max(x,y)

answer = F(K)
print(answer)


Measured memory_bytes: 25980
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t = 0, s = 0, n;
	scanf("%d",&n);
	while(1){
		++s;
		t+=s;
		if(t >= n){
			t -= n;
			break;
		}
	}
	for(int i=1; i<=s; i++)if(i!=t)
		printf("%d\n",i);
	return 0;
}


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

AB.sort(key=lambda i : i[1])

is_ok = True
spend = 0
for a, b in AB:
    spend += a
    if spend > b:
        is_ok = False
        break


if is_ok:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 88152
#include<stdio.h>

int main(){
  int n;
  while(1){
    scanf("%d",&n);
    if(n==-1)break;
    
    int ans = 0;
    if(n<10){
      ans = 1150;
    }else if(n<20){
      ans = 1150 + (n-10)*125;
    }else if(n<30){
      ans = 1150 + 125*10 + (n-20)*140;
    }else{
      ans = 1150 + 125*10 + 140*10 + 160*(n-30);
    }
    printf("%d\n",4280-ans);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;

int main() {
		string str;
		int i;
		getline(cin, str);
		for (i = 0; i < str.length();i++){
		if (islower(str[i])) {
			str[i] = toupper(str[i]);
		}
		else if(isupper(str[i]) ){
			str[i] = tolower(str[i]);
		}
		cout << str[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3156
#include<stdio.h>
int main(){
    int N,A[100000],i;
    unsigned int H,sum=0;

    scanf("%d %d",&H,&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        sum=sum+A[i];
    }
    
    if(H<=sum){
        printf("Yes");
    }
    if(H>sum){
        printf("No");
    }
    printf("\n");

    return 0;
    
}

Measured memory_bytes: 512
def cookies_divide(num_of_per,A):
  
  if (A[0] == A[1] == A[2] and A[0]%2 + A[1]%2 + A[2]%2 == 0):
    return (-1,A)
  
  if(A[0]%2 + A[1]%2 + A[2]%2 > 0):
    return (0,A)
  
  R = [0 for i in range(num_of_per)]
  R[0] = A[1]//2 + A[2]//2
  R[1] = A[0]//2 + A[2]//2
  R[2] = A[0]//2 + A[1]//2
  return (1,R)

if(__name__== '__main__'):
  count = 0
  A = list(map(int,input().split()))
  while True:
    return_code, A = cookies_divide(3,A)
    if return_code < 0:
      print(return_code)
      break;
    
    if return_code == 0:
      print(count)
      break;
    
    count += return_code

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

using namespace std;
#define FILE "dealing"
#define up(i,j,n) for(int i=j;i<=n;i++)
#define ll long long
#define db double 
#define ull unsigned int
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back

int read(){
	int f=1,x=0,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return f*x;
}

const int maxn=100010,limit=100000,inf=100000000,mod=1e9+7;
int add(int a,int b){return (a+=b)>=mod?a-mod:a;}
int sub(int a,int b){return (a-=b)<  0?a+mod:a;}
int mul(int a,int b){return 1LL*a*b%mod;}
int fac[maxn],inv[maxn];

int main(){
	//freopen(FILE".in","r",stdin);
	//freopen(FILE".out","w",stdout);
	int ans=1;
	int a,b,n,m;
	fac[0]=1;
	up(i,1,limit)fac[i]=mul(fac[i-1],i);
	cin>>a>>b;
	if(a<b)swap(a,b);
	if(a-b>1){
		printf("0\n");
		return 0;
	}
	if(a==b)ans=mul(fac[a],mul(fac[b],2));
	else ans=mul(fac[a],fac[b]);
	cout<<ans;
	return 0;
}






Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int main(void){
	int i,ls,lt,dif = 0,j,temp;
	char s[1010],t[1010];
	cin >> s;
	cin >> t;
	for (i=0;i<1010;i++) {
		if (t[i] == '\0') {
			lt = i;
			break;
		}
	}
	for (i=0;i<1010;i++) {
		if (s[i] == '\0') {
			ls = i;
			break;
		}
	}
//cout << ls << '\n';
//cout << lt << '\n';
	for (i=0;i<=ls-lt;i++) {
		//s[i:i+lt]とtの編集距離
//cout << s[i] << '\n';
		temp = 0;
		for (j=0;j<lt;j++) {
			if (s[i+j] == t[j]) {
				temp++;
			}
		}
//cout << temp << '\n';
		if (dif < temp) {
			dif = temp;
		}
	}
	cout << lt - dif << '\n';
}


Measured memory_bytes: 3572
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if i != 0:
        if A[i] == A[i-1] + 1:
            ans += C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    cin >> n;
    vector<ll> zv(n);
    vector<ll> wv(n);
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        zv[i] = x + y;
        wv[i] = x - y;
    }
    ll ans = max(*max_element(zv.begin(), zv.end()) - *min_element(zv.begin(), zv.end()),
                 *max_element(wv.begin(), wv.end()) - *min_element(wv.begin(), wv.end()));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6404
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
double fert[128][128];
double dp[128][128];
int main(){
    int n,m;
    while(scanf("%d%d",&n,&m),(n|m)){
        memset(dp,0,sizeof(dp));
        rep(i,n)rep(j,n)scanf("%lf",&fert[i][j]);
        rep(i,m){
            rep(j,n){
                if(i == 0)dp[i][j] = 1.0;
                else{
                    rep(k,n){
                        dp[i][j] = max(dp[i][j],dp[i-1][k] * fert[k][j]);                    
                    }
                }
            }
        }
        double res = -1.0;
        rep(i,n){
            res = max(res,dp[m-1][i]);
        }  
        printf("%.2lf\n",res);
    }
    return 0;
}

Measured memory_bytes: 1480
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int N = s.length();
        char[] c = s.toCharArray();
        if (c[0]=='0' || c[N-2]=='0' || c[N-1]=='1') {
            System.out.println(-1);
            return;
        }
        int NN = N-1;
        for (int i=0;i<NN/2;i++) {
            if (c[i]!=c[NN-1-i]) {
                System.out.println(-1);
                return;
            }
        }

        int parent = 0;
        for (int i=0;i<N-1;i++) {
            System.out.println((parent+1)+" "+(i+2));
            if (c[i]=='1') {
                parent=i+1;
            }
        }
    }
}

Measured memory_bytes: 41268
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


using Graph = vector<vector<int>>;



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m; cin >> n >> m;
    vector<bool> oks(100010,true);
    vector<int>  ans(100010,0);
    rep(i,m){
        int a; cin >> a;
        oks[a] = false;
    }
    
    for (int now = 0; now < 100010; now++) {
        if(now==0) ans[now] = ((oks[now])?1:0);
        if(now==1) ans[now] = ((oks[now])?1:0);
        if(now>=2){
            if(oks[now]==false) continue;
            ans[now] = ans[now-1] + ans[now-2];
            ans[now] %= MOD;
        }
    }
    
    cout << ans[n] << endl;
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>

int main(){

int a,b,c,d;
d = 0;
scanf("%d %d %d",&a,&b,&c);

if(b < a){
d = a;
a = b;
b = d;
}
if(c < b){
d = b;
b = c;
c = d;
}
if(c < a){
d = a;
a = c;
c = d;
}
if(b < a){
d = a;
a = b;
b = d;
}

printf("%d %d %d\n",a,b,c);

return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	ll h, w;
	cin >> h >> w;
	ll ans = h * w;
	ans = (ans % 2 ? (ans / 2) + 1 : ans / 2);
	if(min(h, w) == 1) ans = 1;
	cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int a[200010],b[200010];
int n,m,j;
int book;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)  cin>>a[i];
	cin>>m;
	for(int i=1;i<=m;i++)  cin>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	int bookl=0,bookr=0;
	int pol,por;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b[1])
		{
			bookl=1;
			pol=i;
			break;
		}
	}
	for(int i=1;i<=n;i++)
	{
    	if(a[i]==b[m])
		{
			bookr=1;
			por=i;
			while(a[por]==b[m]&&por<=n)
			{
				por++;
			}
		}
	}
	por--;
	if(bookl==0||bookr==0)
	{
		cout<<"NO";
		return 0;
	}
	int poa=pol;
	int pob=1;
	while(1)
	{
		if(a[poa]==b[pob])
		{
			poa++;
			pob++;
		}
		else{
			poa++;
		}
		if(pob>m){
			book=1;
			break;
		}		
		if(poa>por)   break;

	}
 	if(book==1)
	{
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
}

Measured memory_bytes: 1792
h, w = map(int, input().split())
A = []
A.append([0] * (w + 2))
for i in range(h):
    A.append([0] + list(input()) + [0])
A.append([0] * (w + 2))

for i in range(h + 2):
    for j in range(w + 2):
        if A[i][j] == '.':
            A[i][j] = 0
            
for i in range(h + 2):
    for j in range(w + 2):
        if A[i][j] == '#':
            if A[i-1][j-1] != '#':
                A[i-1][j-1] += 1
            if A[i-1][j] != '#':
                A[i-1][j] += 1
            if A[i-1][j+1] != '#':
                A[i-1][j+1] += 1
            if A[i][j-1] != '#':
                A[i][j-1] += 1
            if A[i][j+1] != '#':
                A[i][j+1] += 1
            if A[i+1][j-1] != '#':
                A[i+1][j-1] += 1
            if A[i+1][j] != '#':
                A[i+1][j] += 1
            if A[i+1][j+1] != '#':
                A[i+1][j+1] += 1
                
for i in range(1, h + 1):
    print(''.join(map(str, A[i][1:w+1])))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
const int INT_INF = 1e9;
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


void solve() {
	int A, B; cin >> A >> B;
	if (A == 1)A += 13;
	if (B == 1)B += 13;
	if (A > B)print("Alice");
	else if (A == B)print("Draw");
	else print("Bob");
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
def koi(i,o):    
    for t in range(i):
        if t==0 or t==i-1:
            for y in range(o):
                print("#",end="")
            print()
        else:
            for x in range(o):
                if x==0 or x==o-1:
                    print("#",end="")
                else:
                    print(".",end="")
            print()    
while True:
    x,y=map(int,input().split())
    if x==0 and y==0:
        break
    koi(x,y)
    print()


Measured memory_bytes: 7004
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll k;
    cin >> k;

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

    int p[60];
    for (int l = 0; l < 60; l++) {
        ll m = 1LL << l;
        int c = 0;
        for (int i = 0; i < n; i++) {
            c += (a[i] & m) > 0;
        }
        p[l] = c;
    }

    function<ll(ll, int, int)> f = [&](ll t, int h, int b) {
        ll s = 0, s1 = 0;
        for (int l = h - 1; l >= 0; l--) {
            ll m = 1LL << l;
            ll c = p[l];
            if (c < n - c && (t ^ m) <= k) {
                if (b) s1 = max(s1, f(t, l, 0) + s + (c << l));
                t ^= m;
                s += (n - c) << l;
            } else {
                s += c << l;
            }
        }
        return max(s, s1);
    };

    cout << f(0, 60, 1) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	cout<<n*n*n;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b, c;
	int i, ans;
	
	scanf("%d %d %d", &a, &b, &c);
	
	ans = 0;
	for (i = a; i <= b; i++) if (c % i == 0) ans++;
	
	printf("%d\n", ans);
	return 0;
}

/*
a <= i <= b???i??§c???????????????????????°????????????????????????
*/

Measured memory_bytes: 596
x,y = map(int,input().split())

ans=0

if x==1:
  ans +=300000
elif x==2:
  ans +=200000
elif x==3:
  ans +=100000
if y==1:
  ans +=300000
elif y==2:
  ans +=200000
elif y==3:
  ans +=100000

if x==1 and y==1:
  print(1000000)
else:
  print(ans)

Measured memory_bytes: 3064
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(3)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
pll p[200010];
priority_queue<pll,vector<pll>,greater<pll> > q;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
#endif
	int n;ll d,a;cin>>n>>d>>a;
	for(int i=1;i<=n;i++) cin>>p[i].first>>p[i].second;
	sort(p+1,p+1+n);
	ll sum=0,res=0;
	for(int i=1;i<=n;i++){
		while(!q.empty() and q.top().first<p[i].first){
			sum-=q.top().second;
			q.pop();
		}
		ll temp=max(0LL,(ll)ceil(1.0*(p[i].second-sum)/a));
		res+=temp;
		q.push(make_pair(p[i].first+2*d,temp*a));
		sum+=temp*a;
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 9456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.ExceptionServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var XYT = ReadInts();
            var kosuu = 0;
            for (int i = 1; i <= 1000; i++)
            {
                kosuu += XYT[1];
                if (kosuu >= XYT[0])
                {
                    WriteLine(i * XYT[2]);
                    return;
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long A, long long B)
{
    if (13 <= A)
    {
        cout << B << endl;
    }
    else if (6 <= A && A <= 12)
    {
        cout << B / 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


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

int main() {
  int n,c1=0,c2=0,c3=0,c4=0;
  string s,t;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    t=s;
    if(t=="AC"){
      c1++;
    }
    else if(t=="WA"){
      c2++;
    }
    else if(t=="TLE"){
      c3++;
    }
    else{
      c4++;
    }
  }
  cout << "AC x " << c1 << endl;
  cout << "WA x " << c2 << endl;
  cout << "TLE x " << c3 << endl;
  cout << "RE x " << c4 << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<sstream>
#include<iomanip>

using namespace std;

#define INF 999999999

int dp[2][5001][2];//[before/after][Aのもの][いまAのか]
int co[10000];

int main(){
	int ans, N, i, j;
	cin >> N;
	for(i=0;i<N-1;i++) cin >> co[i];
	for(i=0;i<2;i++){
		for(j=0;j<=5001;j++){
			dp[i][j][0] = INF;
			dp[i][j][1] = INF;
		}
	}
	dp[0][1][1] = 0;
	dp[0][1][0] = INF;
	for(i=2;i<=N;i++){//i:いくつめまで確定しているか
		for(j=1;j<=5000&&j<=i;j++){
			dp[1][j][0] = min(dp[0][j][0], dp[0][j][1] + co[i-2]);
			dp[1][j][1] = min(dp[0][j-1][1], dp[0][j-1][0] + co[i-2]);
			//cout << i << " " << j << endl;
			//cout << "dp[" << i << "][" << j << "][1]=" << dp[i][j][1] << endl;
		}
		for(j=1;j<=5000&&j<=i;j++){
			swap(dp[0][j][1], dp[1][j][1]);
			swap(dp[0][j][0], dp[1][j][0]);
		}
	}
	
	ans = min(dp[0][N/2][0], dp[0][N/2][1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1276
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		String s = sc.nextLine();
		
		int max = 0;
		for(int i=1; i< s.length(); i++) {
			int tmp = 0;
			String x = s.substring(0, i);
			String y = s.substring(i);
			
			Set<String> xList = new HashSet<>(Arrays.asList(x.split("")));
			Set<String> yList = new HashSet<>(Arrays.asList(y.split("")));
			
			for(String a : xList) {
				if(yList.contains(a))
					tmp++;
					
			}
			if(max < tmp)
				max = tmp;
		}
		
		System.out.println(max);
	}
		
}


Measured memory_bytes: 23380