akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int payment = Integer.parseInt(scanner.nextLine().split(" ")[0]);
		List<String> dislikes = Arrays.stream(scanner.nextLine().split(" ")).sorted().collect(Collectors.toList());

		while(!isAcceptable(payment, dislikes)) {
			payment++;
		}

		System.out.println(payment);
	}

	private static boolean isAcceptable(int payment, List<String> dislikes) {
		return !Arrays.stream(Integer.toString(payment).split("")).anyMatch(dislikes::contains);
	}
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;

  if (b % a == 0)
    ans = a + b;
  else
    ans = b - a;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    vi t(0);
    int ans = 0;
    REP(i, 5)
    {
        int temp;
        cin >> temp;
        if (temp % 10 == 0)
            ans += temp;
        else
            t.push_back(temp);
    }

    if (t.size() > 0)
    {
        REP(i, t.size() - 1)
        {
            if (t[i] % 10 < t[i + 1] % 10)
            {
                swap(t[i], t[i + 1]);
            }
        }

        ans += t[t.size() - 1];
        t.pop_back();

        REP(i, t.size())
        {
            ans += t[i] + (10 - (t[i] % 10));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
a,b,q=map(int,input().split())
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
x=[int(input()) for i in range(q)]

from bisect import bisect

for i in range(q):
    y=bisect(s,x[i])
    z=bisect(t,x[i])
    k=([0] if y==0 else [a-1] if y==a else [y-1,y])
    l=([0] if z==0 else [b-1] if z==b else [z-1,z])
    mi=100000000000000
    for n in k:
        for m in l:
            if abs(s[n]-x[i])>abs(t[m]-x[i]):
                sub1,sub2=t[m],s[n]
            else:
                sub1,sub2=s[n],t[m]
            mi=min(mi,abs(sub1-x[i])+abs(sub2-sub1))
    print(mi)

Measured memory_bytes: 16148
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    i64 A, B, N;
    cin >> A >> B >> N;
    
    auto f = [&](i64 x) -> i64 {
        return (A*x / B) - (A * (x / B));
    };

    i64 m = 1, M = N;
    while(M - m > 2){
        i64 c = (2*m + M) / 3;
        i64 d = (m + 2*M) / 3;

        if(f(c) < f(d)) m = c; 
        else M = d;

        //cout << m << " " << M << endl;
    }
    i64 res1 = 0, res2 = 0;
    //for(i64 n = 1; n <= sqrt(N); n++) res1 = max(res1, f(n));
    for(i64 n = N - sqrt(n); n <= N; n++) res2 =max(res2, f(n));

    if(N == 1) cout << f(1) << endl;
    else cout << max({f(m), f(m+1), f(M), res2}) << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 100005

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

int p[N], n, col[N], k;
bool u[N];
queue <pii> Q;
vector <int> v[N];

int fnd(int q){
    if (q == p[q]) return q;
    p[q] = fnd(p[q]);
    return p[q];
}

void unite(int a, int b){
    a = fnd(a); b = fnd(b);
    p[a] = b;
}

void bfs(){
    Q.push({1, 0}); col[1] = 0; u[1] = 1;
    while (!Q.empty()){
        int nod = Q.front().fi, cul = Q.front().se;
        Q.pop();
        for (auto it: v[nod]){
            if (u[it]) continue;
            if (fnd(nod) == fnd(it)) Q.push({it, cul}), col[it] = cul;
            else Q.push({it, 1-cul}), col[it] = 1 - cul;
            u[it] = 1;
        }
    }
}

int main(){
    cin >> n;
    for (int i=1; i<=n; i++) p[i] = i;
    for (int i=1, x, y, z; i<n; i++){
        cin >> x >> y >> z;
        v[x].push_back(y);
        v[y].push_back(x);
        if (z & 1) continue;
        else unite(x, y);
    }
    bfs();
    for (int i=1; i<=n; i++) cout << col[fnd(i)] << '\n';
    return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
int main()
{
	int n;
	cin>>n;
	map<lld,int>mp;
	for(int i=0;i<n;i++)
	{
		lld a;
		cin>>a;
		mp[a]++;
		
	}
	int ct=0;
	map<lld,int>::iterator it;
	for(it=mp.begin();it!=mp.end();it++)
	{
		if((it->second)%2!=0)
		ct++;
	}
	cout<<ct<<"\n";
}

Measured memory_bytes: 6528
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
                x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def nums(self,x):
        return abs(self.parents[self.find(x)])

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, Q = map(int, input().split())
uf = UnionFind(N)
for i in range(Q):
    com,x,y = map(int, input().split())
    if com==0:
        uf.union(x,y)
    if com==1:
        print(int(uf.same(x,y)))


Measured memory_bytes: 5788
from math import sqrt
n = int(input())
ans = 0
for i in range(2, 1 + int(sqrt(n))):
    c = 0
    while n % i == 0:
        n //= i
        c += 1
    ans += int((-1 + sqrt(1 + 8 * c)) / 2)
if n != 1:
    ans += 1
print(ans)


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <ctime>
#include <unordered_set>
#include <string>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <string.h>
#include <limits.h>
#include <stack>
#include <functional>
#include <queue>
#include <numeric>
#include <bitset>
#include <iterator>
#include <algorithm>
#include <sstream>
 
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back	
#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("arquivoentrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);	
#define eps 1e-9
#define pi 3.14159265359
 
using namespace std;
typedef vector<int> vi;
 
const int maxn = 2e5 + 10;
long long k;
typedef unsigned long long ull;
typedef long long ll;

using namespace std;
 
const int MAX = 1e2 + 10;

int n; 

int arr[MAX], v[MAX];
signed main (){
	
	//~ in
	
	cin >> n ;
	for(int i = 0 ;i < n;i++) {
		cin >> v[i];
	}
	
	arr[v[0]]++;
	
	int ans = 0;
	for(int  i = 1 ;i < n;i++){
		arr[v[i]]++;
		if (v[i] != v[i-1])
		  ans += arr[v[i-1]] / 2, arr[v[i-1]] = 0;
	}
	
	for(int i = 0 ; i< n;i++)	
		if ( arr[v[i]] ) ans += arr[v[i]] / 2, arr[v[i]] = 0;
		
	cout << ans << '\n';
	return 0;
}
 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n;
ll a[100010];
ll solve(){
  ll res=0;
  sort(a,a+n);
  if(n%2){
    int k=(n-1)/2;
    rep(i,k-1){
      res-=2*a[i];
    }
    rep1(i,n-k-2){
      res+=2*a[i+k+1];
    }
    int m=max(-a[k-1]-a[k]+2*a[k+1],-2*a[k-1]+a[k]+a[k+1]);
    res+=m;
  }
  else{
    int k=n/2;
    rep(i,k-1){
      res-=2*a[i];
    }
    res-=a[k-1];
    rep1(i,n-k-1){
      res+=2*a[i+k];
    }
    res+=a[k];
  }
  return res;
}
int main(){
  cin>>n;
  rep(i,n) cin>>a[i];
  ll res=solve();
  prin(res);

  
  

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    Vec x(n);
    Vec y(n);
    vector<P> p;
    rep(i,n){
        cin>>x[i]>>y[i];
        p.emplace_back(x[i],y[i]);
    }
//    VV diffx(50,Vec(50));
//    VV diffy(50,Vec(50));
//
//    rep(j,n)rep(i,j){
//            diffx[i][j]=x[j]-x[i];
//            diffy[i][j]=y[j]-y[i];
//    }
    sort(ALL(p));

    ll ans= 100;
    if(n==1){
        cout<<1<<endl;
        return  0;
    }

    rep(j,n)rep(i,j){
            ll dx = x[j]-x[i];
            ll dy  = y[j]-y[i];
            ll tmp = n;
            rep(i,n){
                if(binary_search(ALL(p),mp(dx+x[i],dy+y[i]))){
                    tmp--;
                }
            }
            ans = min(tmp,ans);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll K,N;
    cin >> N >> K;
    ld sum = 0;
    REPS(i,N){
        ld Ka = K,ia = i;
        ll cou = ceil(log2(Ka) - log2(ia));
        chmax(cou,(ll)0);
        ll l = (1 << cou);
        sum += (ld)1/(ld)l;
    }
    cout << sum/(ld)N << "\n";
}

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

#ifdef DEBUG
#include "debug.h"
#endif

using namespace std;

#define mp make_pair
#define mt make_tuple
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(a) ((int)(a).size())
#define make_unique(a) (a).resize(unique(all((x))) - (x).begin())

typedef long long ll;

template<typename T> inline bool mmin(T& a, const T &b) { return b < a ? (a = b, true) : false; }
template<typename T> inline bool mmax(T& a, const T &b) { return b > a ? (a = b, true) : false; }

const int maxn = 101000;
vector<int> g[maxn];
bool used[maxn];
map<pair<int, int>, int> sum;
vector<pair<int, int> > val[maxn];

void dfs(int v) {
    if (used[v]) {
        return;
    }
    used[v] = true;
    int a = val[v][0].first;
    int b = val[v][0].second;
    for (int u : g[v]) {
        int s = sum[{v, u}];
        //cout << s << '\n';
        val[u].push_back({-1 * a, s - b});
        dfs(u);
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    memset(used, 0, sizeof(used));
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b, s;
        cin >> a >> b >> s;
        a--, b--;
        sum[{a, b}] = s;
        sum[{b, a}] = s;
       /// cout << sum[{a, b}] << '\n';
        //cout << s << '\n';
        g[a].push_back(b);
        g[b].push_back(a);
    }
    /*for (auto &it : sum) {
        cout << it.second << ' ';
    }*/
    //cout << '\n';
    val[0].push_back({1, 0});
    dfs(0);
    
    /*for (int v = 0; v < n; v++) {
        for (auto x : val[v]) {
            cout << x.first << ' ' << x.second << ":";
        }
        cout << '\n';
    }*/

    int l = 1, r = 1e9;
    for (int v = 0; v < n; v++) {
        int a = val[v][0].first;
        int b = val[v][0].second;
        if (a == 1) {
            l = max(l, 1 - b);
        } else {
            r = min(r, b - 1);
        }
    }
    //cout << l << ' ' << r << '\n';
    if (r < l) {
        cout << "0\n";
        return 0;
    }
    int x = -1;
    for (int v = 0; v < n; v++) {
        for (int i = 0; i < sz(val[v]) - 1; i++) {
            int a1 = val[v][i].first, b1 = val[v][i].second;
            int a2 = val[v][i + 1].first, b2 = val[v][i + 1].second;
            if (a1 == a2) {
                if (b1 != b2) {
                    cout << "0\n";
                    return 0;
                }
            } else {
                if (abs(b1 - b2) % 2 != 0) {
                    cout << "0\n";
                    return 0;
                }
                int cur = (b2- b1) / (a1 - a2);
                if (x == -1) {
                    x = cur;
                } else if (x != cur) {
                    cout << "0\n";
                    return 0;
                }
            }
        }
    }

    if (x == -1) {
        cout << r - l + 1 << '\n';
    } else if (x >= l && x <= r) {
        cout << "1\n";
    } else {
        cout << "0\n";
    }

    return 0;
}

Measured memory_bytes: 34816
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);
//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		int H=sc.nextInt();int W=sc.nextInt();
		int v[][]=new int[H][W];
		String tmp;
		int ctn=0;
		for(int a=0;a<H;a++) {
			tmp=sc.next();
			for(int b=0;b<W;b++) {
				v[a][b]=tmp.charAt(b);
				if(v[a][b]==46) {
					ctn++;
				}
			}
		}
		int sx=0;int sy=0;
		int gx=H-1;int gy=W-1;
		//# 35 . 46
		Queue<Integer> q1=new ArrayDeque<>();
		Queue<Integer> q2=new ArrayDeque<>();
		Queue<Integer> q3=new ArrayDeque<>();
		q1.add(sx);q2.add(sy);q3.add(0);
		v[sx][sy]=35;
		int x,y,i;
		int ans=0;
		boolean aa=true;
		while(q1.peek()!=null) {
			x=q1.poll();
			y=q2.poll();
			i=q3.poll()+1;
			//p("FIRST"+"      "+x+" "+y);
				for(int b=0;b<4;b++) {
				//	p("b"+b);
					if(x+a1[b]>=0&&y+b1[b]>=0) {
						if(x+a1[b]<H&&y+b1[b]<W) {
						if(v[x+a1[b]][y+b1[b]]==46) {
							q1.add(x+a1[b]);
							q2.add(y+b1[b]);
							q3.add(i);
							v[x+a1[b]][y+b1[b]]=35;
							if(gx==x+a1[b]&&gy==y+b1[b]) {
							//	p("GOT GOAL"+"        "+i);
								ans=i;
								aa=false;
								break;
							}
						}
						}
					}
				}
			
		}
		if(aa)p(-1);
		else p(ctn-ans-1);
		
		
		
	}	
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; i < (i64)(n); ++i)
#define WHOLE(x) std::begin(x), std::end(x)
#define LEN(a) int((a).size())

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

template <typename T>
using V = std::vector<T>;
template <typename T>
vector<T> make_vec(size_t n, T a) {
  return vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename T>
istream &operator>>(istream &is, vector<T> &a) {
  for (auto &x : a) is >> x;
  return is;
}
template <typename Container>
ostream &pprint(const Container &a, string_view sep = " ",
                string_view ends = "\n", ostream *os = nullptr) {
  if (os == nullptr) os = &cout;
  auto b = std::begin(a), e = std::end(a);
  for (auto it = std::begin(a); it != e; ++it) {
    if (it != b) *os << sep;
    *os << *it;
  }
  return *os << ends;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
  return pprint(a, ", ", "", &(os << "[")) << "]";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &a) {
  return os << "(" << a.first << ", " << a.second << ")";
}

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const i64 INF = 1e15;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  i64 pp = -INF, np = -INF, pn = -INF, nn = -INF;
  i64 ans = -INF;
  REP(i, N) {
    i64 x, y;
    cin >> x >> y;
    if (pp != -INF) {
      chmax(ans, pp + -x - y);
    }
    if (np != -INF) {
      chmax(ans, np + x - y);
    }
    if (pn != -INF) {
      chmax(ans, pn + -x + y);
    }
    if (nn != -INF) {
      chmax(ans, nn + x + y);
    }
    chmax(pp, x + y);
    chmax(np, -x + y);
    chmax(pn, x - y);
    chmax(nn, -x - y);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

ll dp[100010][2];

const int MOD = 1e9 + 7;

int main() {
    string L;
    cin >> L;

    // dp[i][same]:=上からi桁目まで見て、(a+b(a xor b)?=L)==sameなものの場合の数

    dp[0][1] = 1;
    int N = L.size();
    FOR(i, 1, N + 1) {
        if(L[i - 1] == '1') {
            dp[i][1] = (dp[i][1] + (dp[i - 1][1] * 2) % MOD) % MOD;
            dp[i][0] = (dp[i][0] + dp[i - 1][1]) % MOD;
        } else {
            dp[i][1] = (dp[i][1] + dp[i - 1][1]) % MOD;
        }
        dp[i][0] = (dp[i][0] + ((dp[i - 1][0] * 3) % MOD)) % MOD;
    }
    cout << (dp[N][0] + dp[N][1])%MOD << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
inline int toi(string s){
	int rt=0;
	for(int i=0;i<s.size();i++) rt=rt*10+(int)(s[i]-'0');
	return rt;
}
int main(){
	int i,j;
	long long n,m;
	cin>>n>>m;
	if(n>m) swap(n,m);
	if(n==1){
		if(m==1) cout<<1<<endl;
		else if(m==2) cout<<0<<endl;
		else{
			cout<<m-2<<endl;
		}
		return 0;
	}
	if(n==2){
		cout<<0<<endl;
		return 0;
	}
	cout<<(long long)((long long)(n-2)*(long long)(m-2))<<endl;
	return 0;
}


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

using Hash = __int128;

const Hash A = 1e9 + 7;
const Hash B = 1e12l + 39;
const Hash C = 1e6l + 3;
const Hash MOD = 1e18l + 9;
int main(){
    string w;
    cin >> w;
    int n = w.size();
    vector<Hash> h(n + 1);
    vector<Hash> powA(n + 1);
    map<char, Hash> dict;
    dict['a'] = B;
    for (char x = 'a'; x != 'z'; x++){
        dict[x + 1] = ((dict[x] * C)%MOD + B) % MOD;
    }
    powA[0] = 1;
    for (int i = 0; i < n; i++){
        h[i + 1] = (h[i] * A + dict[w[i]]) % MOD;
        powA[i + 1] = (powA[i] * A) % MOD;
    }
    auto getHash = [&](int l, int r) {
        return ((h[r] - (h[l] * powA[r - l]) % MOD) % MOD + MOD) % MOD;
    };

    vector<int> ok(n + 1, 1);
    for (int i = 1; i < n; i++){
        //s[0:i)
        Hash oh = getHash(0, i);
        for (int j = 1; (j + 1) * i <= n; j++){
            Hash nh = getHash(j * i, (j + 1) * i);
            if (oh == nh){
                ok[(j + 1) * i] = 0;
            }
            else{
                break;
            }
        }
    }
    for (int i = 1; i <= n; i++){
        //s[n-i:n)
        Hash oh = getHash(n - i, n);
        for (int j = 1; n - (j + 1) * i >= 0; j++){
            Hash nh = getHash(n - (j + 1) * i, n - j * i);
            if (oh == nh){
                ok[n - (j + 1) * i] = 0;
            }
            else{
                break;
            }
        }
    }
    int cnt=accumulate(ok.begin(),ok.end(),0);
    if(ok[0]){
        cout<<1<<endl;
        cout<<1<<endl;
    }
    else if(cnt==0){
        cout<<n<<endl;
        cout<<1<<endl;
    }
    else{
        cout<<2<<endl;
        cout<<cnt<<endl;
    }

    return 0;
}

Measured memory_bytes: 18436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
const ll INF = 1001001001;

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> B(m);
  vector<vector<int>> A(n,vector<int>(m));
  rep(i,m)cin >> B[i];
  rep(i,n)rep(j,m)cin >> A[i][j];
  ll cnt = 0;
  int tot = 0;
  rep(i,n){
    cnt = 0;
    rep(j,m){
    cnt += A[i][j]*B[j];
  }
  cnt += c;
  if(cnt>0)tot++;
}
cout << tot << endl;
return 0;  
}


Measured memory_bytes: 3604
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int lis[10001];
int main(){
    for(int i=2;i<=10000;i++){
        int flg=1;
        for(int j=2;j<=10000;j++){
            if(i%j==0&&i!=j)flg=0;
        }
        lis[i]=flg;
    }
    while(1){
        int a;
        cin>>a;
        if(a==0)break;
        for(int i=a;;a--){
            if(lis[a]&&lis[a-2]){
                cout<<a-2<<' '<<a<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int x = 0;
        int y = 0;
        while(true){
            x = sc.nextInt();
            y = sc.nextInt();
            if(x == 0 && y == 0){
                break;
            }
            if(x > y){
                int temp = 0;
                temp = x;
                x = y;
                y = temp;
            }
            System.out.println(x + " " + y);
        }
    }
}


Measured memory_bytes: 37036
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A[100000];
int B[100000];

int main()
{
	int N;
	ll ans = 0;

	cin >> N;
	rep(i, N) cin >> A[i] >> B[i];

	rrep(i, N) {
		if ((A[i] + ans) % B[i] == 0) continue;
		ans += B[i] - (A[i] + ans) % B[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static long N;
    static int M;
    static int A;
    static long B;
    static long C;
    static int[][] map;
    static int min = 9999999;
    static int[] moto = new int[3];

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

        String s = scanner.nextLine();
        String t = scanner.nextLine();

        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            int ok = 0;
            for (int j = 0; j < s.length(); j++) {
//                System.out.println(" ==  " + s.charAt(i));
                if(s.charAt(j) == (t.charAt((i + j) % s.length()))) {
                    ok++;
//                    System.out.println(s.charAt(i));
                }
            }
            if(ok == s.length()){
                ans = 1;
                break;
            }
        }

        if(ans == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }



    }




}



Measured memory_bytes: 22228
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int count = 0;
    int len = S.size() / 2;
    int l = S.size() - 1;
    for (int i=0; i < len; i++) {
        if (S[i] != S[l - i]) {
            count += 1;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int H, W, T, a[1009][1009], dp[1009][1009];
int main() {
	while (scanf("%d%d%d", &H, &W, &T), H) {
		for (int i = 0; i <= H; i++) {
			for (int j = 0; j <= W; j++) {
				if(i < H && j < W) scanf("%d", &a[i][j]);
				dp[i][j] = 0;
			}
		}
		dp[0][0] = T - 1;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				dp[i + 1][j] += (dp[i][j] - a[i][j] + 1) >> 1;
				dp[i][j + 1] += (dp[i][j] + a[i][j]) >> 1;
			}
		}
		int cx = 0, cy = 0;
		while (cx < H && cy < W) {
			if ((dp[cx][cy] ^ a[cx][cy]) & 1) cy++;
			else cx++;
			T >>= 1;
		}
		printf("%d %d\n", cx + 1, cy + 1);
	}
	return 0;
}

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

int main() {
    int N, approved;
    cin >> N;
    int A[N] = {};
    approved = true;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A[i] = a;
        if(a%2==0){
            if(a%3==0){
                continue;
            } else if(a%5==0){
                continue;
            } else{
                approved = false;
                break;
            }
        }
    };
    if(approved){
        cout << "APPROVED";
    } else {
        cout << "DENIED";
    };
}

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

using namespace std;

int main(void){

 long long n, ans;
 
 cin >> n;
 
 if(n%2 == 0){
   ans = (n/2) - 1;
 }else{
   ans = n/2;
 }
 
 cout << ans << endl;
 
 return 0;
}
   


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <cstring>
using namespace std;
int a,b,n;
pair<int,int> p[40];
int dp[18][18];
int f(int x,int y){
  if(dp[x][y]) return dp[x][y];
  if(x==a&&y==b){
    dp[x][y]=1;return 1;
  }
  else if(x>a||y>b) return 0;
  for(int i=0;i<n;++i) if(x==p[i].first&&y==p[i].second) return 0;
  dp[x][y]=f(x+1,y)+f(x,y+1);return dp[x][y];
}

int main(){
  int x,y,A;
  while(cin>>a>>b,a||b){
    cin>>n;
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;++i){
      cin>>x>>y;
      pair<int,int> q(x,y);
      p[i]=q;
    }
    A=f(1,1);
    cout<<A<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdio>
const int MAXN = 55;
int A[MAXN];
int N;

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  std::sort(A, A+N);
  double ret = A[0];
  for (int i = 1; i < N; ++i) {
    ret = (A[i] + ret) / 2.0;
  }
  printf("%.9f\n", ret);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(int n,int k, int s){
	int dp[k+1][n+1][s+1];
	for(int a = 0; a < k+1; a++){
		for(int b = 0; b < n+1; b++){
			for(int c = 0; c < s+1; c++)dp[a][b][c] = 0;
		}
	}

	for(int i = 1; i <= n; i++){
		dp[1][i][i] = 1;
	}

	for(int i = 2; i <= k; i++){
		for(int k = 1; k <= n; k++){
			for(int a = 1; a <= k-1; a++){
				for(int p = k; p <= s; p++){
					dp[i][k][p] += dp[i-1][a][p-k];
				}
			}
		}
	}

	int ans;

	ans = 0;
	for(int i = 0; i <= n; i++)ans += dp[k][i][s];

	printf("%d\n",ans);

}

int main(){

	int n,k,s;

	while(true){
		scanf("%d %d %d",&n,&k,&s);
		if(n == 0 && k == 0 && s == 0)break;

		func(n,k,s);
	}

    return 0;
}

Measured memory_bytes: 2660
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 200005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;

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

  mint ret = 0;
  mint mn = 0, mx = 0;
  rep(i,K-1){
    mn += i;
    mx += N-i;
  }
  REP(i,K,N+2){
    mn += i-1;
    mx += N-i+1;
    //cout << i << " " << mn << " " << mx << endl;
    ret += mx - (mn-1);
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 6236
#include <stdio.h>
int main()
{
    int n,i,d;
    scanf("%d",&n);
    char s[100];
    scanf(" %s",s);
    scanf("%d",&d);
    d--;
    for(i=0;i<n;i++)
    {
        if(s[i]!=s[d])
        {
            s[i]='*';
        }
    }
    printf("%s\n",s);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		cost[1] = Math.abs(h[0] - h[1]);
		int tmp1;
		int tmp2;
		for(int i=2;i<n;i++) {
			tmp1 = Math.abs(h[i-1] - h[i]) + cost[i-1];
		    tmp2 = Math.abs(h[i-2] - h[i]) + cost[i-2];
		    cost[i] = Math.min(tmp1, tmp2);
		}
		
		System.out.println(cost[n-1]);
		

	}

}


Measured memory_bytes: 59020
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n, d;
	cin>>n>>d;
	long long x, y;
	long long ans=0;
	for (int i=1; i<=n; i++) {
		cin>>x>>y;
		if (sqrt(x*x+y*y)<=d*1.0) {
			ans++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    ll a,b;
    cin>>a>>b;
    ll ans=a/__gcd(a,b)*b;
    OUT(ans);
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var hp = long.Parse(Console.ReadLine());
        var cnt = 0;
        double sum = 0;

        while(hp > 1)
        {
            hp = hp / 2;
            cnt++;
            sum += Math.Pow(2, cnt);
        }
        Console.Write(hp + sum);
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n,a=0;
	cin >> n;
	int h[100001];
	for (int i = 0;i < n;i++) {
		cin >> h[i];
	}
	for (int i = 0;i < n;i++) {
		if (a > h[i]) {
			cout << "No" << endl;
			return 0;
		}
		a = max(a, h[i] - 1);
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
#coding:utf-8
n = int(input())
a = list(map(int, input().split()))
brick = []

#1が書いてあるレンガがない場合は解答なし
if 1 not in a:
    print('-1')
    exit()
else:
    num = 1
    for i in a:
        if i == num:
            brick.append(i)
            num += 1
#print(brick)
print(n-len(brick))

Measured memory_bytes: 26268
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;
LL sum1[100001], sum2[100001];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		int a;
		cin >> a;
		sum1[i] = sum1[i - 1] + a;
		sum2[i] = sum2[i - 1] + max(a, 0);
	}
	LL ans = 0;
	for (int i = 1; i + K - 1 <= N; i++) {
		ans = max(ans, sum2[i - 1] + max(sum1[i + K - 1] - sum1[i - 1], 0LL) + sum2[N] - sum2[i + K - 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
n,k = map(int, input().split())

klist =[0]*k

for i in range(0,k):
    a = int(input())
    if a ==1:
        temp = int(input())
        klist[i] = [temp]
    else:
      	tlist= list(map(int, input().split())) 
      	klist[i]=tlist


unil = set(sum(klist,[]))
treat =  len(set(unil))
res = n - treat
print(res)

Measured memory_bytes: 9208
// https://atcoder.jp/contests/dp/tasks/dp_e

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w, i1, i2;
    cin >> n >> w;
    vector<ll> dp(w + 1);
    REP(i, n) {
        cin >> i1 >> i2;
        for (ll k = w; k >= i1; k--) {
            dp[k] = max(dp[k], dp[k - i1] + i2);
        }
    }
    cout << *max_element(ALL(dp)) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1e9 + 7)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

void solve() {

	int N, M;
	cin >> N >> M;

	vector<P> m(M);

	REP(i, M) {
		cin >> m[i].scd >> m[i].fst;
	}

	sort(ALL(m));

	vector<bool> brg(N, false);

	REP(i, M) {
		bool flag = true;
		for (int j = m[i].scd; j < m[i].fst; j++) {
			if (brg[j] == true) {
				flag = false;
				break;
			}
		}
		if (flag) {
			brg[m[i].fst - 1] = true;
		}
	}

	out(count(ALL(brg), true));



	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int T1, T2, TS;
  T1 = A * 60 + B;
  T2 = C * 60 + D;
  TS = T2 - T1;
  cout << TS - E << endl;
}


Measured memory_bytes: 3620
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

p = [int(x) for x in input().split()]
ans = 10**9

if x not in p:
    ans = x
else:
    for i in range(1, 101):
        minus = x-i
        plus = x+i
        if minus not in p:
            ans = minus
            break
        elif plus not in p:
            ans = plus
            break
print(ans)

Measured memory_bytes: 9200
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	n := scanInt()
	ans := 0
	mn := math.MaxInt64
	for i := 0; i < n; i++ {
		s := scanInt()
		ans += s
		if s%10 != 0 {
			mn = min(mn, s)
		}
	}

	if ans%10 != 0 {
		fmt.Println(ans)
	} else if mn == math.MaxInt64 {
		fmt.Println(0)
	} else {
		fmt.Println(ans - mn)
	}
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var N, H, W int
	fmt.Scan(&N, &H, &W)

	count := 0
	for i := 0; i < N; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if H <= a && W <= b {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    speed_up;
    int n, m, cnt = 0;
    cin>>n>>m;
    int a[m+1] = {};
    int i, j;
    i = n;
    while(i--)
    {
        int k;
        cin>>k;
        while(k--)
        {
            cin>>j;
            a[j]++;
        }
    }
    for(i = 1; i<=m; i++)
    {
        if(a[i] == n)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;

}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


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

	int A, B, H, M;
	cin >> A >> B >> H >> M;
	double pi = 3.14159265358979323846;
	double m = (double)(60 * H + M);
	double rB = 2 * pi * m / 60.0;
	double rA = 2 * pi * m / (12.0 * 60.0);
	double ax = ((double)A) * cos(rA);
	double ay = ((double)A) * sin(rA);
	double bx = ((double)B) * cos(rB);
	double by = ((double)B) * sin(rB);
	double l = sqrt((ax - bx)*(ax - bx) + (ay - by) * (ay - by));
	cout << setprecision(18) << l << endl;
	return(0);
}


Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2!=0){
        cout<<"Borys"<<endl;
    }
    else{
        cout<<"Alice"<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int N, i;
    int list[] = {1, 2, 4, 8, 16, 32, 64, 128};
    scanf("%d", &N);

    for ( i = 0; i < 8; i++ ){
        if ( list[i] > N ){
            break;
        }
    }

    printf("%d\n", list[i-1]);

    return 0;
}

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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int N, M;
vll x, y, z;

int main() {

    cin >> N >> M;
    REP(i, N) {
        ll a, b, c; cin >> a >> b >> c;
        x.push_back(a);
        y.push_back(b);
        z.push_back(c);
    }

    ll ans = 0;
    REP(i, 8) {
        ll d = i;
        ll c = i/4 == 1 ? -1 : 1; i %= 4;
        ll b = i/2 == 1 ? -1 : 1; i %= 2;
        ll a = i   == 1 ? -1 : 1;
        i = d;


        vll xx = x; REP(j, N) xx[j] *= a;
        vll yy = y; REP(j, N) yy[j] *= b;
        vll zz = z; REP(j, N) zz[j] *= c;

        vll s(N);
        REP(j, N) s[j] = xx[j] + yy[j] + zz[j];
        sort(s.begin(), s.end(), greater<ll>());

//        REP(j, M) cout << s[j] << " "; cout << endl;
        ll tmp = 0;
        REP(j, M) tmp += s[j];
        ans = max(tmp, ans);
    }

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


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a[100];
  int n, temp, flag = 1, count = 0;
  int i, j;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  while(flag == 1) {
    flag = 0;
    for(j = n - 1; j > 0; j--){
      if(a[j] < a[j-1]) {
	temp = a[j];
	a[j] = a[j-1];
	a[j-1] = temp;
	flag = 1;
	count++;
      }
    }
  }

  for(i = 0; i < n; i++) {
    printf("%d", a[i]);
    if(i < n - 1) printf(" ");
  }
  printf("\n");
  printf("%d\n", count);

  return 0;
  
}

Measured memory_bytes: 604
import heapq

#input
N, M = map(int, input().split())
A = list(map(int, input().split()))

#output
A2 = [-a for a in A]
heapq.heapify(A2)

for i in range(M):
    temp_min = A2[0] + 1
    heapq.heappushpop(A2, temp_min//2)

print(-sum(A2))

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

#define LOOP(i,n) for(int i = 0; i < n; ++i)

int main(void)
{
  int k, s;
  cin >> k >> s;
  
  int cnt = 0;
  LOOP(i,k+1) 
  {
    LOOP(j,k+1) 
    {
      if ((0 <= s - i - j) && (s - i - j <= k)) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int N;
	int *u;
	int *u_rank;
}union_find;

union_find *make_union_find(int N){
	int i;
	union_find *uf = (union_find *)malloc(sizeof(union_find));
	uf->N = N;
	uf->u = (int *)malloc(sizeof(int) * N);
	uf->u_rank = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		uf->u[i] = i;
		uf->u_rank[i] = 1;
	}
	return uf;
}

int root_uf(int x, union_find *uf){
	int *u = uf->u;
	if(u[x] == x){
		return x;
	}
	else{
		u[x] = root_uf(u[x], uf);
		return u[x];
	}
}

void combine_uf(int x, int y, union_find *uf){
	int x_root = root_uf(x, uf);
	int y_root = root_uf(y, uf);
	int *u = uf->u;
	int *u_rank = uf->u_rank;
	if(x_root == y_root){
		return;
	}
	else if(u_rank[x_root] < u_rank[y_root]){
		u[x_root] = y_root;
		u_rank[y_root] += u_rank[x_root];
		u_rank[x_root] = 0;
	}
	else{
		u[y_root] = x_root;
		u_rank[x_root] += u_rank[y_root];
		u_rank[y_root] = 0;
	}
}

//xとyが同じ集合に属していれば1を,そうでなければ0を返す
int is_same_union_uf(int x, int y, union_find *uf){
	if(root_uf(x, uf) == root_uf(y, uf)){
		return 1;
	}
	else{
		return 0;
	}
}

//xが属する集合の要素数を返す
int rank_uf(int x, union_find *uf){
	return uf->u_rank[root_uf(x, uf)];
}

int main(){
	int N, M, K, L, r, i, j;
	scanf("%d%d", &N, &M);
	union_find *uf = make_union_find(N + M);
	for(i = 0; i < N; i++){
		scanf("%d", &K);
		for(j = 0; j < K; j++){
			scanf("%d", &L);
			L--;
			combine_uf(i, N + L, uf);
		}
	}
	r = root_uf(0, uf);
	for(i = 0; i < N; i++){
		if(root_uf(i, uf) != r){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int s[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<s[n-1]<<endl;
	return 0; 
} 

Measured memory_bytes: 256