akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

int main(){
	IOS();
	ll n;cin>>n;
	cout<<n/3<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
    ll N, L;
    cin >> N >> L;
    vector<ll> apples(N);
    iota(begin(apples), end(apples), L);
    sort(begin(apples), end(apples), [](auto x, auto y) { return abs(x) < abs(y); });
    ll ans = accumulate(next(cbegin(apples)), cend(apples),0LL);

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		TwoAnagrams solver = new TwoAnagrams();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class TwoAnagrams {

		private String sInput;
		private String tInput;
		private String answer;
		private Scanner scanner;

		public TwoAnagrams() {
			scanner = new Scanner(System.in);
		}

		public void readInput() {
			sInput = scanner.nextLine();
			tInput = scanner.nextLine();
		}

		public void solve() {

			String[] sArray = sInput.split("");
			String[] tArray = tInput.split("");

			Arrays.sort(sArray);
			Arrays.sort(tArray,Collections.reverseOrder());

			String s = String.join("", sArray);
			String t = String.join("",tArray);
			if(0 < t.compareTo(s)) {
				answer = "Yes";
			} else {
				answer = "No";
			}
		}

		public void writeOutput() {
			System.out.println(answer);
		}
	}

}


Measured memory_bytes: 23892
n,k = map(int,input().split())
def cmb(n, k, mod, fac, ifac):    
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n):
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

mod = 1000000007
fac, ifac = make_tables(mod, n)

r = n - k
for i in range(k):
    if r+1 >= i+1:
        ans = cmb(k-1, i, mod, fac, ifac)
        ans *= cmb(r+1, i+1, mod, fac, ifac)
        print(ans%mod)
    #ans = (k-1Ci)*(r+1Ci+1)
    else:
        print(0)


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==5 && b==5 && c==7) cout<<"YES";
  else if(a==5 && b==7 && c==5) cout<<"YES";
  else if(a==7 && b==5 && c==5) cout<<"YES";
  else cout<<"NO";
 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

int main(){
    string str;
    int r=0,b=0;
    cin >> str;
    for(int i=0;i<str.size();i++){
        if(str[i]=='0') r++;
        else    b++;
    }
    cout << min(r,b)*2;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>

int n;
int x,y;
int tot;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		tot+=(y-x+1);
	}	
	printf("%d\n",tot);
	return 0;
}

Measured memory_bytes: 128
N,K = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

if K == 1
  p 0
  exit
end

ans = 10**15
[0,1].repeated_permutation(N-1) do |arr|
  next if arr.sum < K-1

  h = a.first
  sum = 0

  1.upto(N-1) do |i|
    if arr[i-1] == 1 # 見える
      if a[i] > h
        h = a[i]
      else
        sum += (h+1 - a[i])
        h += 1
      end
    else
      h = [h,a[i]].max
    end
  end

  ans = [ans,sum].min
end
p ans


Measured memory_bytes: 14848
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        TreeSet<Integer> p = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            p.add(sc.nextInt());
        }
        int[] arr = new int[102];
        for (int i : p) {
            arr[i] = 1;
        }
        int min = Integer.MAX_VALUE;
        int ans = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] == 0) {
                if(min > Math.abs(x - i)) {
                    min = x - i;
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35956
#include <iostream>
using namespace std;
  
int main(){
	int N;
	cin >> N;
	int oddnumbers = 0;
	for(int i = 0; i < N; i++){
		int input;
		cin >> input;
		if(input % 2 == 1){
			oddnumbers++;
		}
	}
	if(oddnumbers % 2 == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder 1234567
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
int h,w;
char c[10][10];
int cnt;
signed main() {
	cin>>h>>w;
	rep(i,h)rep(j,w){
		cin>>c[i][j];
		if(c[i][j]=='#')cnt++;
	}
	if(cnt==h+w-1)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}


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

tmp=0
for ll in range(1,20):
  tmp+=26**ll
  if n<=tmp:
    break

s=chr((n-1)%26+ord("a")) ##一文字目
for i in range(1,ll):
  n-=26**i
  s+=chr((n-1)//(26**i)%26+ord("a")) 

print(s[::-1])


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		ans+=(2*(min(x,abs(k-x))));
	}
	cout<<ans;
	return;
}
int main()
{
	fast;
	int q;
	q=1;
	// cin>>q;
	while(q--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
 vector<int> arr;
 long int sum=0,sum_a=0,sum_b=0;
 int a,b,n,var;
 cin>>n;
 for(int i=0;i<n;i++)
 {
     cin>>var;
     arr.push_back(var);
     sum+=var;
 }
 a=floor((float)sum/n);
 b=ceil((float)sum/n);
 for(int i=0;i<n;i++)
 {
     sum_a+=(a-arr[i])*(a-arr[i]);
     sum_b+=(b-arr[i])*(b-arr[i]);
 }
 cout<<min(sum_a,sum_b);
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
map<string,int>mp;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<'\n';
    cout<<"WA x "<<mp["WA"]<<'\n';
    cout<<"TLE x "<<mp["TLE"]<<'\n';
    cout<<"RE x "<<mp["RE"]<<'\n';




}


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

using namespace std;

#define pb push_back
#define sz(a) ((int)a.size())

const int maxn = 2e5 + 5;

int n;
map<int, vector<int> > has;
int vs[maxn];
int a[maxn];

void trans() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        has[a[i]].pb(i);
    }
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (vs[i]) continue;
        int cur = 0;
        for (int j = 0; j < 32; j++) {
            if ((1 << j) > a[i]) break;
            if (((1 << j) & a[i]) == 0) {
                cur += (1 << j);
            }
        }
        cur += 1;
        if (sz(has[cur]) && has[cur].back() == i) has[cur].pop_back();
        if (sz(has[cur])) {
            vs[has[cur].back()] = 1;
            has[cur].pop_back();
            ans++;
        }
    }
    cout << ans;
}

int main() {
    trans();
    return 0;
}


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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define REP(i,n) FOR(i,0,n)

int N, A, B;

int main() {
  scanf("%d%d%d", &N, &A, &B);

  int sum = 0;
  FOR(i,1,N+1) {
    int buf = i;
    int digit = 0;
    while(buf != 0) {
      digit += buf % 10;
      buf /= 10;
    }
    if (A <= digit && digit <= B) sum += i;
  }

  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int n, k, M;
const int N = 500;
int C[N][N], F[N][N];
int main()
{
    cin >> n >> k >> M;
    for (int i = 0; i <= n; ++ i)
    {
        C[i][0] = C[i][i] = 1;
        for (int j = 1; j < i; ++ j)
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % M;
    }
    for (int i = 0; i <= k; ++ i)
        F[0][i] = 1;
    for (int i = 1; i <= n; ++ i)
        for (int j = 0; j < i; ++ j)
            for (int p = 1, s = F[j][0]; p <= k; ++ p)
            {
                F[i][p] = (F[i][p] + 1ll * s * F[i - j - 1][p] % M * C[i - 1][j]) % M;
                s = (s + F[j][p]) % M;
            }
    cout << F[n][k] << endl;
}


Measured memory_bytes: 1408
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class UnionFindWeighted:
    # Reference:
    # https://note.nkmk.me/python-union-find/
    # https://at274.hatenablog.com/entry/2018/02/03/140504
    # https://qiita.com/drken/items/cce6fc5c579051e64fab
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.weight = [0] * n

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

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

        if rx == ry:
            return

        if self.parents[rx] > self.parents[ry]:
            x, y, rx, ry, w = y, x, ry, rx, -w

        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx
        self.weight[ry] = self.weight[x] - self.weight[y] + w

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

    def diff(self, x, y):
        return self.weight[y] - self.weight[x]


def main():
    N, M, *LRD = map(int, read().split())

    uf = UnionFindWeighted(N)
    for l, r, d in zip(*[iter(LRD)] * 3):
        l -= 1
        r -= 1
        if uf.same(l, r) and uf.diff(l, r) != d:
            print('No')
            return
        else:
            uf.union(l, r, d)

    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 73916
#define T 999
D[T][T],i,j,x,y,a,b,c,R;main(k){scanf("%*d%d%d",&x,&y);for(D[0][0]=9999;~scanf("%d%d%d",&a,&b,&c);)for(i=T;i-->a;)for(j=T;j-->b;)k=D[i-a][j-b]-c,D[i][j]<k?D[i][j]=k:0;for(i=x,j=y;i<T&&j<T;i+=x,j+=y)D[i][j]>R?R=D[i][j]:0;printf("%d\n",R>0?9999-R:-1);}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    string s; cin >> s;
    if(a >= 3200)cout << s << endl;
    else cout << "red" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    int l;
    cin >> l;
    ll a[l];
    rep(i, l) {
        cin >> a[i];
    }
    ll dp[l + 1][5];
    fill(dp[0], dp[l + 1], LINF);
    dp[0][0] = 0;
    for (int i = 0; i < l;i++){
        dp[i + 1][0] = dp[i][0] + a[i];
        dp[i + 1][1] = min(dp[i][0], dp[i][1]) + (a[i] == 0 ? 2 : a[i] % 2);
        dp[i + 1][2] = min({dp[i][0], dp[i][1], dp[i][2]}) + (a[i] % 2 == 0);
        dp[i + 1][3] =
            min({dp[i][0], dp[i][1], dp[i][2], dp[i][3]}) + (a[i] == 0 ? 2 : a[i] % 2);
        dp[i + 1][4] =
            min({dp[i][0], dp[i][1], dp[i][2], dp[i][3], dp[i][4]}) + a[i];
    }
    ll ans = LINF;
    rep(i,5){
        ans = min(ans, dp[l][i]);
    }
    cout << ans << endl;
    return 0;
}

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

int A[20];
int x[20][20];
int y[20][20];

int bitcount(int x)
{
    if (x == 0) return 0;
    return bitcount(x >> 1) + (x & 1);
}

int main(void)
{
    int N;
    cin >> N;

    for(int i=1;i<=N;++i)
    {
        cin >> A[i];
        for(int j=1;j<=A[i];++j)
        {
            cin >> x[i][j] >> y[i][j];
        }
    }

    int ans = 0;
    for(int bits=1;bits<(1<<(N));++bits)
    {
        bool ok = true;
        for(int i=1;i<=N;++i)
        {
            if (!(bits & (1<<(i-1)))) continue;
            for(int j=1;j<=A[i];++j)
            {
                if (((bits >> (x[i][j]-1)) & 1) ^ y[i][j])
                    ok = false;
            }
        }
        if (ok)
        {
            ans = max(ans, bitcount(bits));
        }
    }

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


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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

bool all[100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, K;
  cin >> N >> K;

  ll a;
  for (ll i = 0; i < K; i++) {
    ll d;
    cin >> d;

    for (ll j = 0; j < d; j++) {
      cin >> a;
      all[a - 1] = true;
    }
  }

  ll c = 0;
  for (ll i = 0; i < N; i++) {
    if (!all[i]) {
      c++;
    }
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 3656
inputs = [int(s) for s in input().split()]
k = inputs[0]
x = inputs[1]

n = (k-1)*2+1

for i in range(n):
    if i != n-1:
        print(str(x-k+1+i)+" ", end="")
    else:
        print(str(x-k+1+i)+" ")



Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, x, ans = 0;
  	cin >> a >> b >> c >> x;
  	for (int i = 0; i <= a; i++){
    	for (int j = 0; j <= b; j++){
    		for (int k = 0; k <= c; k++){
    			if (500 * i + 100 * j + 50 * k == x){
                	ans++; 
                }
    		}
    	}
    }
  	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int x[90001];
int y[90001];

int arr[90001]={0,};
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int h,w,d,t;

	cin >> h >> w >> d;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin >> t;
			x[t] = i;
			y[t] = j;
		}
	}

	for(int i=d+1;i<=h*w;i++)
	{
		arr[i] = arr[i-d] + abs(x[i]-x[i-d]) + abs(y[i]-y[i-d]); 
	}

	int q,a,b;

	cin >> q;

	while(q--)
	{
		cin >> a >> b;

		cout << arr[b] - arr[a] << '\n';
	}

	return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
int main(void)
{
	int H;
	int W;
	int i, j,k;

	while (1) {
		scanf("%d", &H);
		scanf("%d", &W);

		if (H == 0 && W == 0) {
			break;
		}
		for (i = 0; i < H; i++) {
			if (i == 0 || i == (H - 1)) {
				for (j = 0; j < W; j++) {
					printf("#");
				}
				printf("\n");
			}
			else {
				printf("#");
				for (k = 0; k != W - 2; k++) {
					printf(".");
				}
				printf("#");
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 1924
Row = int(input())
List = []
for i in range (Row):
  List.append(list(map(str, input().split())))
res = 0
for i in range(Row):
  if List[i][1] == "JPY":
    res += float(List[i][0])
  else:
    res += float(List[i][0])*380000
print(res)

Measured memory_bytes: 9192
n,m = map(int,input().split())
lis = [int(input()) for i in range(m)]
dp = [0 for i in range(n+2)]
lis.append(0)
dp[0] = 1
cou = 0
co = 0
if lis[0] == 1:co += 1
for i in range(n):
  if i+1 != lis[cou]:
    dp[i+1] += dp[i]
    dp[i+1] %= 10 ** 9+7
  else:
    cou +=1
  if i+2 != lis[co]:
    dp[i+2] += dp[i]
    dp[i+2] %= 10 ** 9 + 7
  else:
    co += 1
print(dp[n])

Measured memory_bytes: 7856
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
const int N=2e5+5;
typedef long long lint;
int n,q;

namespace utils{
	inline int nxi(FILE *fd=stdin){
		int x=0;
		char c;
		while(((c=fgetc(fd))>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=fgetc(fd));
		while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
		return f?-x:x;
	}
	template <class T> inline void apx(T &x,const T y){
		x<y?x=y:0;
	}
	template <class T> inline void apn(T &x,const T y){
		x>y?x=y:0;
	}
	template <class T> inline T cabs(const T x){
		return x<0?-x:x;
	}
}
using namespace utils;

namespace T{
	int x,y;
	lint v;
	struct node{
		lint v0,v1,delta;
		//v0: 上升
		inline void getv(const lint v){
			v0+=v,v1+=v,delta+=v;
		}
	}tr[N<<1];

	inline int idx(const int l,const int r){
		return (l+r)|(l!=r);
	}

	inline void upd(const int l,const int r){
		assert(l!=r);
		const int k=idx(l,r),mid=(l+r)>>1;
		const int ls=idx(l,mid),rs=idx(mid+1,r);
		tr[k].v0=std::min(tr[ls].v0,tr[rs].v0);
		tr[k].v1=std::min(tr[ls].v1,tr[rs].v1);
	}

	inline void psh(const int l,const int r){
		assert(l!=r);
		lint &d=tr[idx(l,r)].delta;
		if(!d) return;
		const int mid=(l+r)>>1;
		tr[idx(l,mid)].getv(d);
		tr[idx(mid+1,r)].getv(d);
		d=0;
	}

	void build(const int l,const int r){
		if(l==r){
			tr[idx(l,r)]=(node){(lint)1e12+l,(lint)1e12+(n-r+1),0};
			return;
		}
		const int mid=(l+r)>>1;
		build(l,mid);
		build(mid+1,r);
		upd(l,r);
	}

	void apl_t(const int l,const int r){
		if(l==r){
			const int k=idx(l,r);
			const lint old=tr[k].v0-l;
			if(v<old){
				tr[k]=(node){v+l,v+(n-r+1),0};
			}
			return;
		}
		psh(l,r);
		const int mid=(l+r)>>1;
		if(x<=mid) apl_t(l,mid);
		else apl_t(mid+1,r);
		upd(l,r);
	}

	lint qmin0_t(const int l,const int r){
		if(l>=x&&r<=y) return tr[idx(l,r)].v0;
		psh(l,r);
		const int mid=(l+r)>>1;
		lint ans=1e16;
		if(x<=mid) apn(ans,qmin0_t(l,mid));
		if(y>mid) apn(ans,qmin0_t(mid+1,r));
		return ans;
	}

	lint qmin1_t(const int l,const int r){
		if(l>=x&&r<=y) return tr[idx(l,r)].v1;
		psh(l,r);
		const int mid=(l+r)>>1;
		lint ans=1e16;
		if(x<=mid) apn(ans,qmin1_t(l,mid));
		if(y>mid) apn(ans,qmin1_t(mid+1,r));
		return ans;
	}

	lint qans_t(const int l,const int r){
		if(l==r) return tr[idx(l,r)].v0-l;
		psh(l,r);
		const int mid=(l+r)>>1;
		lint ans=1e16;
		apn(ans,qans_t(l,mid));
		apn(ans,qans_t(mid+1,r));
		return ans;
	}

	inline void apl(const int x,const lint v){
		T::x=x,T::v=v;
		return apl_t(1,n);
	}

	inline lint qmin0(const int x,const int y){
		T::x=x,T::y=y;
		return qmin0_t(1,n);
	}

	inline lint qmin1(const int x,const int y){
		T::x=x,T::y=y;
		return qmin1_t(1,n);
	}
}

int main(){
	n=nxi(),q=nxi();
	int st_a=nxi(),st_b=nxi();
	T::build(1,n);
	int lst=nxi();
	T::apl(st_a,cabs(lst-st_b));
	T::apl(st_b,cabs(lst-st_a));
	for(int i=2; i<=q; ++i){
		const int x=nxi();
		lint res1=T::qmin1(1,x)-(n-x+1);
		lint res2=T::qmin0(x,n)-x;
		T::tr[T::idx(1,n)].getv(cabs(x-lst));
		T::apl(lst,std::min(res1,res2));
		lst=x;
	}
	printf("%lld\n",T::qans_t(1,n));
	return 0;
}


Measured memory_bytes: 9728
#include <cstdlib>
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
	string S;
	int K;
	cin >> S;
	scanf("%d",&K);
	int LN = S.size();
	for (int i = 0; i < LN; ++i)
	{
		if(S[i]!='a'){
			int cn = int('z'-S[i])+1;
			if(cn <= K) {
				K-=cn;
				S[i] = 'a';
			}
		}
	}
	if(K>0){
		K = K%26;
		S[LN-1] = S[LN-1]+K;
		if(S[LN-1]>'z') S[LN-1] = S[LN-1]-26;
	}
	cout << S <<endl;
	return 0;
}

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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define GO(to, a) for (auto to : a)

#define f first
#define s second
#define eb emplace_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()

int main () {
	string s, t;
  int a, b;
  cin >> s >> t >> a >> b;
  string rem;
  cin >> rem;
  if (s == rem) --a;
  if (t == rem) --b;
  cout << a << ' ' << b << '\n';
  return 0;
}

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

int main() {
  int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

  vector<int> x, y;
  int i = 0, j = 0;
  while (100 * A * i <= F) {
    j = 0;
    while (100 * (A * i + B * j) <= F) {
      x.push_back(100 * (A * i + B * j));
      j++;
    }
    i++;
  }
  i = 0;
  while (C * i <= F) {
    j = 0;
    while (C * i + D * j <= F) {
      y.push_back(C * i + D * j);
      j++;
    }
    i++;
  }

  int ans1 = 0, ans2 = 0;
  double conc = -1, full = (100.0 * E) / (E + 100.0);
  for (int i = 0; i < x.size(); i++) {
    for (int j = 0; j < y.size(); j++) {
      if (x[i] != 0 &&
        (100.0 * y[j]) / (x[i] + y[j]) > conc &&
        (100.0 * y[j]) / (x[i] + y[j]) <= full &&
        x[i] + y[j] <= F) {
        conc = (100.0 * y[j]) / (x[i] + y[j]);
        ans1 = x[i];
        ans2 = y[j];
      }
    }
  }

  cout << ans1 + ans2 << " " << ans2 << endl;

  return 0;
}

Measured memory_bytes: 1400
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
l = [str(sorted(str(input()))) for _ in range(n)]
 
d = {}
 
for i in range(n):
  s = l[i]
  # print(s)
  if s in d:
    d[s] += 1
  else:
    d[s] = 1

ans = 0
for x in d.values():
  ans += x*(x-1)/2
print(int(ans))

Measured memory_bytes: 90460
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int cnt = 0;
    rep(p,a+1){
        rep(q,b+1){
            rep(r,c+1){
                if(x == 500*p + 100*q + 50*r) cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <atcoder/dsu>

int main() {
  int N, Q;
  std::cin >> N >> Q;
  atcoder::dsu dsu(N);
  for (int i = 0; i < Q; i++) {
    int type, u, v;
    std::cin >> type >> u >> v;
    if (type == 0) {
      dsu.merge(u,v);
    } else {
      if (dsu.same(u,v)) std::cout << 1 << std::endl;
      else std::cout << 0 << std::endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int a;
  cin>>a;
  string s,c;
  cin>>s>>c;
  for(int i = 0;i<s.size();i++){
    cout << s.at(i) << c.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n;
    cin>>n;
    int v[100][100]={};
    int u,k,vf;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>vf;
            v[i][vf-1]=1;
        }
    }
    for(int c=0;c<n;c++){
        for(int g=0;g<n;g++){
            cout<<v[c][g];
            if(g!=n-1) cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 P = pair<int,int>;
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	SORT(a); SORT(b);
	// 前半の撮りうるmin max
	int fro_m, fro_M;
	if(n%2 == 0){
		fro_m = a[n/2-1];
		fro_M = b[n/2-1];

		int ba_m;
		int ba_M;
		ba_m = a[n/2];
		ba_M = b[n/2];
		int x = fro_m + ba_m;
		int y = fro_M + ba_M;
		cout << y - x + 1 << endl;
	}else {
		fro_m = a[n/2];
		fro_M = b[n/2];
		cout << fro_M - fro_m + 1 << endl;;
	}
}


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

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

	int x, y, mx, mn, z;
	cin >> x >> y >> z;
	mx = max(x,y);
	mn = min(x,y);
	if (mn<=z && mx>=z) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<class T> bool chmax(T& a,T b){ if(a < b) {a = b; return true;} return false;}
template<class T> bool chmin(T& a,T b){ if(a > b) {a = b; return true;} return false;}
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
template<typename T>
string toString( const T &a ){
    ostringstream oss;
    oss << a;
    return oss.str();
};

int M_MAX = 100010;
int N,M,x,y;
int dp[100010];
vector<vector<int>> G;

int rec(int v){
    if(dp[v] != -1) return dp[v];
    int res = 0;
    for(auto nv : G[v]){
        chmax(res,rec(nv) + 1);
    }
    return dp[v] = res;
}


/* 
void toporogical_sort(){
    for(int i = 0; i < v; i++){
        if(!In[i].size()) Q.push(i);
    }
    while(!Q.empty()){
        int t = Q.front(); 
        Q.pop();
        ans.push_back(t);
        for(int i = 0; i < Out[t].size(); i++){
            int nx = Out[t][i];
            int size = In[nx].size();
            for(int j = 0; j < size; j++){
                if(In[nx][j] == t){
                    In[nx].erase(In[nx].begin()+j);
                    break;
                }
            }
            if(!In[nx].size()) Q.push(nx);
        }
    }
}
*/


int main(){
    cin >> N >> M;
    G.assign(N,vector<int>());
    for(int i = 0; i < M; i++){
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }
    for(int i = 0; i < N; i++) dp[i] = -1;
    int res = 0;
    for(int i = 0; i < N; i++) chmax(res,rec(i));
    cout << res << endl;
}

Measured memory_bytes: 8192
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, d;
	cin >> n >> d;
	int asn = 0 ;
	while (n--) {
		int x, y;
		cin >> x >> y;
		asn += (ceil(sqrt(x * x + y * y)) <= d);
	}
	cout << asn << "\n";
	return 0;
}

Measured memory_bytes: 3724
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int H=sc.nextInt();
        int W=sc.nextInt();
        int[][] a=new int[H][W];
        for (int i = 0; i < H; i++) {
            String s=sc.next();
            for (int j = 0; j < W; j++) {
                if(s.charAt(j)=='#')a[i][j]=1;
            }
        }
        int[] t=new int[W];
        for (int i = 0; i < H; i++) {
            int c=0;
            for (int j = 0; j < W; j++) {
                t[j]+=a[i][j];
                c+=a[i][j];
            }
            if(c==0){
                for (int j = 0; j < W; j++) {
                    a[i][j]=2;
                }
            }
        }
        for (int i = 0; i < W; i++) {
            if(t[i]==0){
                for (int j = 0; j < H; j++) {
                    a[j][i]=2;
                }
            }
        }
        for (int i = 0; i <H; i++) {
            int c=0;
            for (int j = 0; j < W; j++) {
                if(a[i][j]==0)out.print(".");
                if(a[i][j]==1)out.print("#");
                c+=a[i][j];
            }
            if(c!=2*W)out.println();
        }
    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))

// #define DEBUG

#ifdef DEBUG
#define dump(...) fprintf(stderr, __VA_ARGS__)
#else
#define dump(...)
#endif

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;

const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}

random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n), d(n);
    rep(i, n){
        char c; cin >> c >> a[i];
        d[i] = (c == 'y' ? 1:0);
    }

    using Elem = tuple<int, int>;
    priority_queue<Elem, vector<Elem>, greater<Elem>> q;
    rep(i, n){
        if(d[i]){
            q.push(Elem(a[i], i));
        }
    }
    vi used(n);
    int res = 0;
    while(q.size()){
        int i;
        tie(ignore, i) = q.top(); q.pop();
        if(used[i]) continue;

        used[i] = true;
        res++;

        auto update = [&](int j){
            if(not d[j] and a[j] >= a[i]) return false;
            if(d[j]) used[j] = true;
            return true;
        };
        rep(j, i + 1, n){
            if(not update(j)) break;
        }
        rrep(j, i, 0){
            if(not update(j)) break;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3244
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), dif(n);
    rep(i, n)cin >> a[i];
    ll ans = 0;
    ll sum = 0;
    rep(i, n){
        cin >> b[i];
        dif[i] = a[i] - b[i];
        if(dif[i] < 0)ans++, sum+=dif[i];
    }
    sort(ALL(dif), greater<ll>());
    if(ans == 0){
        cout << 0;
        return 0;
    }
    rep(i, n){
        if(sum >= 0){
            cout << ans + i;
            return 0;
        }
        sum += dif[i];
    }
    cout << -1;
}

Measured memory_bytes: 2560
S=input()
T=input()
ans=len(T)

if len(T)!=len(S):
    for j in range(len(S)-len(T)+1):
        total=0
        for i in range(len(T)):
            if S[i+j]!=T[i]:
                total+=1
        if ans>=total:
            ans=total
else:
    ans=0
    for j in range(len(T)):
        if T[j]!=S[j]:
            ans+=1

print(ans)

Measured memory_bytes: 9076
import sys, collections, heapq
def input(): return sys.stdin.readline().strip()

class UnionFind():
    """
    https://note.nkmk.me/python-union-find/
    DFSの上位互換と考えて良い
    ２要素x, yがpath-connectedかどうかをlogオーダーで判定する（螺旋本の14.1節参照）
    さらに連結成分の要素数がO(1)で取得可能なように改造してある
    """
    def __init__(self, n):
        """
        要素数をnとして、各ノードを0,1,...,(n-1)の番号で管理する
        parentsは各ノードの属する木の根を表す
        ただし根ノードのparentには(その木のノード数)*(-1)を格納する
        """
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        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, yのそれぞれ属する木Tx, Tyの根同士を繋ぐ
        このとき木の要素数が小さい方を大きい方に繋ぐ（rankではなくsizeを用いる）
        """
        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 size(self, x):
        """
        xの属する木の要素数を返す
        根の親を要素数の(-1)倍で定めておいたおかげでO(1)で取得可能
        """
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """
        xとyがpath-connectedかを判定する
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        """
        xの属する木の要素を列挙する
        """
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """
        連結成分の代表元のリストを返す
        """
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """
        連結成分の個数を返す
        """
        return len(self.roots())

    def all_group_members(self):
         """
         連結成分およびそれぞれの代表元をまとめた辞書を返す
         代表元がキーになってる
         """
         return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        """
        連結成分およびその代表元を出力
        """
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



def main():
    N, M = map(int, input().split())
    hint = []
    for _ in range(M):
        x, y, _ = map(int, input().split())
        hint.append((x - 1, y - 1))

    """
    xが分かればyも分かるので、それを「頂点xと頂点yの間に辺がある」と解釈すれば
    求めるのはグラフの連結成分そのもの。よってUnionFindTreeで終わり。
    """

    tree = UnionFind(N)
    for x, y in hint:
        tree.union(x, y)
    print(tree.group_count())


if __name__ == "__main__":
    main()


Measured memory_bytes: 70748
N = int(input())
X = [[] for _ in range(N)]
z = [0 for _ in range(N)]
w = [0 for _ in range(N)]
for i in range(N):
    X[i] = list(map(int, input().split()))
    z[i] = X[i][0] +X[i][1]
    w[i] = X[i][0] -X[i][1]

ans = max(max(z)-min(z), max(w)-min(w))
print(ans)

Measured memory_bytes: 119364
#!/usr/bin/ruby
# encoding: utf-8

# ABC 110 C

#comment
#文字の種類の数と、それぞれの文字の数との間に全単射が存在すればOK

S = gets.chomp
T = gets.chomp

sa = Array.new(26,0)
ta = Array.new(26,0)

def countKindofLetters(string,array)
  string.chars do |ch|
    array[ch.ord - "a".ord] += 1
  end
  return array
end

#main
src = countKindofLetters(S,sa).sort
dst = countKindofLetters(T,ta).sort

if src == dst 
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define ll long long
#define PI acos(-1)
using namespace std;
const ll N = 1e5+100;
const ll MOD = 1e9+7;

ll n,m,T;
ll X,K,D;
int main()
{
	/*scanf("%d",&T);
	while(T--)
	{
	
	 } 
	 */
	cin >> X >> K >> D;
	if(X > D&&K)	
	{
		ll M = X/D;
		if(M <=K)
		{
			X = X%D;
			K -= M;
		}	
		else
		{
			 X -= K*D;
			 K = 0;
		}
	}
	if(X<-D&&K)
	{
		ll M = abs(X/D);
		if(M <=K)
		{
			X = X%D;
			K -= M;
		}	
		else 
		{
			X += K*D;
			K = 0;
		}
	}
	if(K%2==0)	cout << abs(X) << endl;
	else
	{
		if(X<0)	cout << D+X << endl;
		else cout << D-X << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279


void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int gcd(int a, int b)
{
    int c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}
int main(void){	
	int x, a;
  scanf("%d %d", &x, &a);
  if(x<a)	printf("0");
  else	printf("10");
			
	return 0;
}


Measured memory_bytes: 128
inp = raw_input().split()
N = int(inp[0])
K = int(inp[1])
H = raw_input().split()
H = list(map(int, H))

def must_attack():
	H.sort()
	for i in range(K):
		if len(H) > 0:
			H.pop()
	sum_damage = 0
	for i in H:
		sum_damage += i
	return sum_damage

ans = must_attack()
print(ans)

Measured memory_bytes: 21620
#include <bits/stdc++.h>
using namespace std;
const int MAXN=410;
long long f[MAXN][MAXN],a,s[MAXN];
int n;

int main(){
	memset(f,0x7f,sizeof(f));
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a,s[i]=s[i-1]+a,f[i][i]=0;
	for(int k=1;k<n;++k){
		for(int l=1;l+k<=n;++l){
			for(int i=l;i<l+k;++i){
				f[l][l+k]=min(f[l][l+k],f[l][i]+f[i+1][l+k]+s[l+k]-s[l-1]);
			}
		}
	}
	cout<<f[1][n]<<endl;
	return 0;
}

Measured memory_bytes: 1536
import java.math.*

fun main(args: Array<String>) {
    var (N, H) = readInputLine().split(" ").map { it.toInt() }
    
    val katana = mutableListOf<Int>()
    
    var aMax = 0
    
    for (i in 1..N) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() }
        
        aMax = Math.max(a, aMax)
        katana.add(b)
    }
    
    katana.sortDescending()
    
    var ans = 0
    
    for (k in katana) {
        if (k <= aMax || H <= 0) {
            break
        }
        ans++
        H -= k
    }
    
    if (H <= 0) {
        println(ans)
        return
    }
    
    println(ans + H / aMax + if (H % aMax != 0) 1 else 0)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 57648
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll dp[2100][2100];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	invinit();
	for (int i = 1; i <= num; i++)
	{
		ll now = 0;
		for (int j = 1; j <= i - 1; j++)
		{
			dp[i][j] = (dp[i][j] + now) % mod;
			now += dp[i - 1][j];
			now %= mod;
		}
		for (int j = 1; j <= i - 1; j++)dp[i][j] = (dp[i][j] + com(num - kai + i - 1, num - kai)) % mod;
		for (int j = 0; j <= i; j++)dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
		//for (int j = 0; j <= i; j++)printf("%lld ", dp[i][j]); printf("\n");
	}
	ll s = com(num - 1, kai - 1);
	for (int i = 0; i <= num; i++)s += dp[kai - 1][i], s %= mod;
	for (int i = 0; i < num - kai - 1; i++)s = s * 2 % mod;
	printf("%lld\n", s);
}

Measured memory_bytes: 25472
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n,k;
    int i,j;
    while (scanf("%d%d",&n,&k)!=EOF)
    {
        i=1;
        for (j=0;j<n;j++)
        {
            if (i<k)
                i+=i;
            else
                i+=k;
        }
        printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 256
a = input().rstrip()
b = input().rstrip()
c = input().rstrip()
na = len(a)
nb = len(b)
nc = len(c)
i = j = k = 0
x = a[0]
while True:
    if x == 'a':
        if i == na:
            print('A')
            break
        else:
            x = a[i]
            i += 1
    elif x == 'b':
        if j == nb:
            print('B')
            break
        else:
            x = b[j]
            j += 1
    else:
        if k == nc:
            print('C')
            break
        else:
            x = c[k]
            k += 1

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
int main()
{
    //sync;
    lld n,d;
    cin>>d>>n;
    if(n==100) {
        if(d==0) cout<<101;
        else if(d==1) cout<<(101 * 100);
        else cout<<(101 * 100 * 100);
    }
    else {
        if(d==0) cout<<(n);
        else if(d==1) cout<<(n)*(100);
        else cout<<(n)*(100*100);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >>N;
	string A(N,'G'), B(N,'A'), C(N*2,'N');
	cin >> A >> B;

	for (size_t i = 0; i < N; i++)
	{
		C[2 * i] = A[i];
		C[2 * i + 1] = B[i];
	}
	cout <<C;
}

Measured memory_bytes: 256
#include <stdio.h>

// 入力受付用の変数
#define BUF 200002
char str[BUF];

// 入力された値
#define LIM_N 100001
int N;
int W[LIM_N];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d", &N);

	for (size_t i = 0; i < N; i++) {
		scanf("%d", &W[i]);
	}
}

void solve() {
	int sum = 0;
	for (size_t i = 0; i < N; i++) {
		sum += W[i];
	}

	int min = sum;
	int weight = 0;
	for (size_t i = 0; i < N; i++) {
		weight += W[i];
		int d = (sum - weight) - weight;
		d = d < 0 ? -d : +d;
		min = min < d ? min : d;
	}

	printf("%d\n", min);
}

int main(void) {
	receive_input();

	solve();

	return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun <A : Comparable<A>> maxPriorityQueueOf(a: Collection<A>): java.util.Queue<A> {
        val q = java.util.PriorityQueue<A>(a.count()) { x, y ->
            return@PriorityQueue if (y > x) 1 else -1
        }
        q.addAll(a)
        return q
    }

    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val AB = Array(N) { Pair(sc.next().toInt(), sc.next().toInt()) }
            .sortedBy { it.first }

        val ans = mutableListOf<Int>()
        val maxQ = maxPriorityQueueOf(listOf(0))
        var c = 0
        for (i in 0..N) {
            while (i == N || AB[i].first > c) {
                if (maxQ.isNotEmpty()) {
                    val max = maxQ.first()
                    maxQ.remove(max)
                    ans += max
                }
                c++
                if (c > M) break
            }
            if (c > M || i == N) break
            maxQ.add(AB[i].second)
        }
        pw.println(ans.sum())
    }
}


Measured memory_bytes: 80148