akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

map<int, bool> memo;
bool win(int my, int op){
	int b = my << 14 | op;
	if(memo.count(b)) return memo[b];
	if(op == 0) return 0;
	
	assert(my);
	
	int any = 0;
	int table = (1 << 14) - 2 ^ my ^ op;
	for(int i = 1; i < 14; i++) if(my >> i & 1){
		
		if(i < 7 && !(table >> i + 1 & 1)) continue;
		if(i > 7 && !(table >> i - 1 & 1)) continue;
		any = 1;
		if(!win(op, my ^ 1 << i)) return memo[b] = 1;
	}
	if(!any) return memo[b] = !win(op, my);
	return memo[b] = 0;
}

bool solve(){
	int my = 0, op = 0;
	rep(i, 6){
		int x; cin >> x;
		my |= 1 << x;
	}
	for(int i = 1; i < 14; i++) if(i != 7 && !(my >> i & 1)) op |= 1 << i;
	return win(my, op);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	while(n--) cout << (solve() ? "yes" : "no") << endl;
	
	return 0;
}


Measured memory_bytes: 3224
N=int(input())
CSF=[list(map(int,input().split())) for i in range(N-1)]

for i in range(N):
    time=0
    for j in range(i,N-1):

        if time<CSF[j][1]:
            time=CSF[j][1]
        x=-((-time)//CSF[j][2])
        time=x*CSF[j][2]
        time+=CSF[j][0]
        #print(x,time)

    print(time)
            

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n=0;
  cin >> n;
  int a[n],d[n],t[n];
  a[0] = 1;
  t[0] = 1;
  d[0] = 0;
  for(int i=1;i<n;i++){
    cin >> a[i];
    t[i] = i+1;
    d[i] = 0;
  }
  // for(int i=0; i<n; i++){
    for(int j=1; j<n; j++){
      //     if(t[i] == a[j]){
      //  d[i] = d[i] + 1;
        //  }
      d[a[j]-1]  = d[a[j]-1] + 1;
    }
    // }

  for(int q=0; q<n; q++){
    cout << d[q] << endl; 
  }
}


Measured memory_bytes: 5968
#include <bits/stdc++.h>
using  namespace std;
int main(){
    string s, t;
  	int check;
    bool flag=false;
    cin >> s >> t;
    for(int i=s.length()-1;i>=0;i--){
      	check = i;
        for(int j=t.length()-1;j>=0;j--){
            if(s[check]==t[j] || s[check]=='?'){
                if(j==0){
                    flag=true;
                    for(int k=0;k<t.length();k++){
                        s[check] = t[k];
                        check++;
                    }
                }
            }else{
             	break; 
            }
            check--;
        }
      	if(flag){
            break;
        }
    }
    if(flag){
        for(int i=0;i<s.length();i++){
            if(s[i]=='?'){
                s[i] = 'a';
            }
        }
      	cout << s << endl;
    }else{
     	cout << "UNRESTORABLE" << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
D_list = list(map(int, input().split()))
M = int(input())
T_list = list(map(int, input().split()))

dic_T = {}
for i in T_list:
    if i in dic_T:
        dic_T[i] += 1
    else:
        dic_T[i] = 1

dic_D = {}
for i in D_list:
    if i in dic_D:
        dic_D[i] += 1
    else:
        dic_D[i] = 1

for i in dic_T:
    if i in dic_D:
        if not dic_T[i] <= dic_D[i]:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')



Measured memory_bytes: 56672
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>

using namespace std;
vector<int> memo(100000, 0);

int get_sum(int num) {
  int key = num;
  if (memo[key] == 0) {
    int sum = 0;
    while (num > 0) {
      sum += num % 10;
      num /= 10;
    }
    memo[key] = sum;
  }

  return memo[key];
}

int main() {
    int N, ans = 10000000;
    cin >> N;

    for (int i = 1; i <= N / 2; i++) {
      ans = min(ans, get_sum(i) + get_sum(N - i));
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main 
{
    public static void main(String[] args) throws IOException 
    {
        Scanner sc = new Scanner(System.in);    
        int a = sc.nextInt();    
        int b = sc.nextInt();
        if ((a % 2 == 0) || (b % 2 == 0)) {
            System.out.print("Even");
        }
        else {
            System.out.print("Odd");
        }
    }
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
// priority_queue<pll,vector<pll>,greater<pll> >pq;
// priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T,n,m;

int main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n;
    ll ans = 0;
   	for(ll i=1;i<=n;i++){
   		if(i%3==0 || i%5==0)
   			continue;
   		ans+=i; 
   	}
   	cout << ans;

    return 0;
}


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

typedef long long ll;

int main() {
    int N, K; cin >> N >> K;
    vector<int> H(N); for(int i = 0; i < N; i++) cin >> H[i];
    sort(H.begin(), H.end(), greater<int>());
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (i >= K) ans += H[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while(T--) {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    string S;
    cin >> S;
    vector<ll> base;
    bool ok = true;
    rrep(i, N) {
      for(ll b: base) A[i] = min(A[i]^b, A[i]);
      if(S[i] == '0') {
        if(A[i]) base.push_back(A[i]);
      } else {
        if(A[i]) {
          cout << 1 << "\n";
          ok = false;
          break;
        }
      }
    }
    if(ok) cout << 0 << "\n";
  }
  return 0;
}


Measured memory_bytes: 3580
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cassert>
using namespace std;
 
void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}
 
const int N = 5000;
char a[N+3];
char ans[N+3][N+3];
char mnc;
int n,m,num;
 
bool cmp(int x,int y)
{
    for(int i=1; i<=n; i++)
    {
        if(ans[x][i]<ans[y][i]) return true;
        if(ans[x][i]>ans[y][i]) return false;
    }
    return false;
}
 
int main()
{
    scanf("%d%d",&n,&m);
    scanf("%s",a+1);
    mnc = 'z'; for(int i=1; i<=n; i++) mnc = min(mnc,a[i]);
    if(m>=14) {for(int i=1; i<=n; i++) printf("%c",mnc); return 0;}
    int len = 0,mxl = 0;
    for(int i=1; i<=n; i++)
    {
        if(a[i]!=mnc) len = 0;
        else len++;
        if(len>mxl) {mxl = len;}
    }
    len = 0; num = 0;
    for(int i=1; i<=n; i++)
    {
        if(a[i]!=mnc) len = 0;
        else len++;
        if(i==n)
        {
            num++;
            int tmp = min(n,len*(1<<m));
            for(int j=1; j<=tmp; j++) ans[num][j] = mnc;
            for(int j=tmp+1,k=n-len; j<=n; j++,k--) ans[num][j] = a[k];
        }
        if(len==mxl)
        {
            num++;
            int tmp = min(n,len*(1<<m-1));
            for(int j=1; j<=tmp; j++) ans[num][j] = mnc;
            for(int j=tmp+1,k=i+1; j<=n; j++,k++)
            {
                ans[num][j] = a[k<=n?k:2*n+1-k];
            }
        }
    }
//  for(int i=1; i<=num; i++) {for(int j=1; j<=n; j++) printf("%c",ans[i][j]); puts("");}
    int fans = 1;
    for(int i=1; i<=num; i++)
    {
        if(cmp(i,fans))
        {
            fans = i;
        }
    }
    for(int j=1; j<=n; j++) printf("%c",ans[fans][j]); puts("");
    return 0;
}


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

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

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

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


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n;
    cin >> n;
    vector<int> p;
    while(n--){
        int v;
        cin >> v;
        p.push_back(v);
    }
    
    cout << accumulate(p.begin(), p.end(), 0) - *max_element(p.begin(), p.end()) / 2 << endl;

    return 0;
}



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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    string s; cin >> s;
    string ans = "";
    for (char c : s) {
        if (c == 'B') {
            if (!ans.empty()) ans.pop_back();
        }
        else ans.push_back(c);
    }
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
/*
int main(){
  int n; scanf("%d",&n);
  long long a[2 * 100000];
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", &a[i]);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n; j++)
    {
      if(j - i == a[i] + a[j])ans++;
    }
    
  }
  printf("%lld\n", ans);
}
*/

int main(){
  int n; cin >> n;
  vector<int> a(n);
  for (auto &&i : a)
  {
    cin >> i;
  }
  vector<int> L(n);
  vector<int> R(n);
  for (int i = 0; i < n; i++)
  {
    L.at(i) = i + a.at(i);
    R.at(i) = i - a.at(i);
  }
  long long count = 0;
  map<int,int> mp;
  for (auto &&i : L)
  {
    if(mp.count(i))
    {
      mp[i]++;
    }
    else
    {
      mp[i] = 1;
    }
    
  }
  for (auto &&i : R)
  {
    count += mp[i];
  }
  

  cout << count << endl;

}

Measured memory_bytes: 22708
#include<stdio.h>
int main(void){
	int N,a[100]={0},i,j,buff,G=0;
	scanf("%d\n",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<N;i++){
		for(j=i;j<N;j++){
			if(a[i]<a[j]){
				buff=a[i];
				a[i]=a[j];
				a[j]=buff;
			}
		}
	}
	for(i=0;i<N;i+=2){
		G+=a[i]-a[i+1];
	}
	printf("%d\n",G);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include <typeinfo>
using namespace std;
int main(void){
    // Your code here!
	int a;
	int sums=0;
    int& sum=sums;
    
	    cin>>a;
    
    sum=a;
	    int b[2];
	    b[0]=(a%10);a=a/10;
	    b[1]=(a%10);a=a/10;
    
    if(b[0]==9 || b[1]==9) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}

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

public class Program{
    public static void Main(){
        long[] numbers = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        numbers[0] = Math.Abs(numbers[0]);
        long minToZero = numbers[0] / numbers[2];
        long result = 0;
        
        if ((numbers[0] % numbers[2]) * 2 > numbers[2]) minToZero++;
        
        if (numbers[1] < minToZero){
            result = numbers[0] - numbers[1] * numbers[2];
        }else {
            long tmp = Math.Abs(numbers[0] - numbers[2] * minToZero);
            if ((numbers[1] - minToZero) % 2 == 0){
                result = tmp;
            }else {
                result = Math.Abs(tmp - numbers[2]);
            }
            
        }
        
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 28248
#include<bits/stdc++.h>
using namespace std;
int32_t main()
{
int h1,s1,h2,s2;cin>>h1>>s1>>h2>>s2;
  while(h1>0 && h2>0)
  {h2-=s1;
   if(h2<=0)break;
  h1-=s2;
   if(h1<=0)break;
  }
  if(h2<=h1)cout<<"Yes";
  else cout<<"No";
  return 0;
}
  


Measured memory_bytes: 3624
n, m = map(int, input().split())
all_like = list(range(1, m + 1))
for i in range(n):
    fav_list = list(map(int, input().split()))
    remove_list = []
    for j in all_like:
        if j not in fav_list[1:]:
            remove_list.append(j)
    for j in remove_list:
        all_like.remove(j)
print(len(all_like))

Measured memory_bytes: 3060
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input=Console.ReadLine().Split(' ');
        string stream = input[0];

        int a=stream.IndexOf('A');
        int z = stream.LastIndexOf('Z');
        int ans = z-a+1;
        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    ll x;cin>>x;
    ll ans=(x/500)*1000;
    x%=500;
    ans+=(x/5)*5;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
if R - L >= 2019:
    ans = 0
else:
    ans = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            a = (i * j) % 2019
            if ans > a:
                ans = a
            if ans == 1:
                break
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include <numeric>
#include<cmath>
#include<string>
using namespace std;
#define ll long long
typedef pair<ll,ll> p;

int main(void){
    ll n;
    cin >> n;
    std::vector<p> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i].second>>p[i].first;
    }
    sort(p.begin(),p.end());
    
    // for(int i=0;i<p.size();i++){
    //     cout << p[i].first<<' '<<p[i].second<<endl;
    // }
    
    ll cnt=0;
    bool flag = true;
    for(int i=0;i<n;i++){
        cnt += p[i].second;
        // cout << p[i].first << ' '<<cnt << endl;
        if(p[i].first<cnt){
            cout << "No"<<endl;
            flag = false;
            break;
        }
    }
    if(flag == true)
    cout << "Yes"<<endl;
}

Measured memory_bytes: 3328
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ATravelingBudget {
public:
	void solve(istream& in, ostream& out) {
        int a,b,c,d;
        in >> a >> b >> c >> d;
        int t = min(a,b);
        int v = min(c,d);
        out << t + v << endl;
	}
};

int main() {
	ATravelingBudget solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
int main() {
    string s;
    cin >> s;
    string s2;
    int n = s.size();
    vector<int>a;
    int cnt=0;
    rep(i, 0, n){
        if(s[i]=='x'){
            cnt++;
        }else{
            a.push_back(cnt);
            cnt =0;
            s2 += s[i];
        }
    }
    a.push_back(cnt);
    string s3 = s2;
    reverse(s2.begin(),s2.end());
    if(s2 != s3){
        cout << -1 << endl;
        return 0;
    }
    int ans = 0, m = a.size()/2;
    rep(i, 0, m){
        if(a[i] != a[(a.size()-1)-i])ans += abs(a[i]-a[(a.size()-1)-i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef struct Node_ Node;

struct Node_ {
    int key;
    Node* prev;
    Node* next;
};

Node* nil;

static bool isEmpty()
{
    return (nil->next == nil);
}


static void insert(int key)
{
    Node* x = (Node*)malloc(sizeof(Node));
    x->key = key;
    x->prev = nil;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
}

static Node* search(int key)
{
    Node* cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

static void deleteNode(Node* node)
{
    if (node == nil)
        return;
    node->prev->next = node->next;
    node->next->prev = node->prev;
    free(node);
}

static void deleteFirst()
{
    deleteNode(nil->next);
}

static void deleteLast()
{
    deleteNode(nil->prev);
}

static void deleteKey(int key)
{
    deleteNode(search(key));
}

static void printList()
{
    Node* cur = nil->next;
    int i = 0;

    while (cur != nil) {
        if (i++ > 0) {
            printf(" ");
        }
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

static void initialize()
{
    nil = (Node*)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

static void finalize()
{
    while (!isEmpty()) {
        deleteFirst();
    }
    free(nil);
}

int main()
{
    int n, key;
    char command[20];

    initialize();
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%s%d", command, &key);

        if (command[0] == 'i') {
            insert(key);
        } else if (command[0] == 'd') {
            if (strlen(command) > 6) {
                if (command[6] == 'F') {
                    deleteFirst();
                } else if (command[6] == 'L') {
                    deleteLast();
                }
            } else {
                deleteKey(key);
            }
        }
    }

    printList();
    finalize();
    return 0;
}


Measured memory_bytes: 32948
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e15;
const ll mod = 1e9 + 7;

int n, m;
vector <set <int>> adj(1001);
vi visited(1001), d(1001), p(1001);

void input()
{
    cin >> n >> m;
    FOR (i, 1, m)
    {
        int x, y;
        cin >> x >> y;
        adj[x].insert(y);
    }
}

void bfs (int root)
{
    visited.assign(1001, 0);
    d.assign(1001, inf);
    p.assign(1001, 0);
    
    queue <int> q;
    q.push(root);
    d[root] = 0;
    visited[root] = true;
    
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        
        for (int u: adj[v])
        {
            if (!visited[u])
            {
                q.push(u);
                visited[u] = true;
                d[u] = d[v] + 1;
                p[u] = v;
            }
        }
    }
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	input();
	int veri, verj, ans = inf;
	
	FOR (i, 1, n)
	    for (int j: adj[i])
	    {
	        adj[i].erase(j);
	        bfs(j);
	        if (d[i] < ans) ans = d[i], veri = i, verj = j;
	        
	        adj[i].insert(j);
	    }
	    
	if (ans >= inf) {cout << -1; return 0;}
	cout << ans + 1 << endl;
	
	bfs(verj);
	while (veri != verj)
	{
	    cout << veri << endl;
	    veri = p[veri];
	}
	cout << verj;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B;cin>>A>>B;
    //ans=0->1 ans=1->A ans=2->A*2-1
    int ans=0;
    int kuchi=1;
    while(kuchi<B){
        ans++;kuchi+=A-1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
n = int(input())
L = sorted(list(map(int,input().split())),reverse = True)

A,B = 0,0
for i in range(n):
    if i%2 == 0:
        A += L[i]
    else:
        B += L[i]
print(A-B)

#print(sum(L[::2]) - sum(L[1::2]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << 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; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


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

    // 方針：Nまでの各値までの加算回数の最小値をメモするDP

    vector<int> v;
    v.pb(1);
    int u1 = 6; rep(i, 9) { v.pb(u1); u1 *= 6; }
    int u2 = 9; rep(i, 7)  { v.pb(u2); u2 *= 9; }
    sort(all(v));

    int dp[100009];
    for (int i=0; i <= 100000; ++i) dp[i] = INF;
    dp[0] = 0;
    for (int i=0; i <= 100000; ++i) {
        // v[j]を加算することで先のv[i+j]までの回数をメモしておく
        for (int j : v) {
            if (i+j <= 100000) dp[i+j] = min(dp[i+j], dp[i]+1);
        }
    }

    print(dp[N]);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

	int A, B, C;
	cin >> A >> B >> C;
	int li[3] = { A,B,C };
	int calc_li[3] = {};
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (j == i) {
				calc_li[i] += li[j] * 10;
			}
			else {
				calc_li[i] += li[j];
			}
		}
	}

	int max_calc_li = 0;
	for (int i = 0; i < 3; i++) {
		if (max_calc_li < calc_li[i]) {
			max_calc_li = calc_li[i];
		}
	}
	cout << max_calc_li;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
z = [-1] * (N+1)
for i in range(M):
     z[int(input())] = 0

for i, x in enumerate(z):
     if i == 0:
          z[i] = 1
     elif i == 1 and z[i] != 0:
          z[i] = 1
     elif z[i] == 0:
          continue
     elif z[i-1] == 0 and z[i-2] == 0:
          print(0)
          exit()
     else:
          z[i] = z[i-1] + z[i-2]
print(z[-1] % 1000000007)


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


int main() {
    int n, s;
    cin >> n;
    vector <int> a(n,0);
    s=0;

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

    for (int i=0; i<n; i++) {
        int ans = s^a[i];
        if (i) cout << " " ;
        cout << ans ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4008
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define isko_lga_dala_to_life_jhinga_la_la ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define pld pair<long double,long double>
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define inv(v) for(auto&i:v) in(i)
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpl vector<pair<ll,ll>>
#define INF 0x3f3f3f3f

template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<t.first<<" "<<t.second; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }

int main() {
    ll n;
    in(n);
    vl v(n);
    for(auto& i:v) in(i);
    ll c=0,req=1;
    loop(i,n) {
        if(req == v[i]) {
            c++;
            req++;
        }
    }
    if(!c) cout<<-1<<endl;
    else
    cout<<n-c<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size())ans += (s[i] != t[i]);
    cout << ans << endl;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

signed main() {
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n);
    vector<ll> xo(n); // 累積xor
    vector<ll> su(n); // 累積和

    rep(i,0,n) cin>>a[i];
    xo[0] = su[0] = a[0];
    rep(i,1,n){
        xo[i] = xo[i-1]^a[i];
        su[i] = su[i-1]+a[i];
    }

    rep(i,0,n){ // 区間[i j] が条件を満たすなら、区間[i k](k<=j) も条件を満たす。 区間[i,j]を求める
        ll l = i, r = n;
        while(l+1<r){
            ll m = (l+r)/2;
            ll x = (xo[m] ^ xo[i]) ^ a[i];
            ll s = (su[m] - su[i]) + a[i];
            (x==s ? l : r) = m;
        }
        ll j = l;
        ans += (j-i)+1;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4992
N,A,B = map(int,input().split())
S = input().strip()
cnt = 0
cnt2 = 0
for i in range(N):
    if S[i]=="c":
        print("No")
        continue
    if S[i]=="a":
        if cnt<A+B:
            print("Yes")
            cnt += 1
        else:
            print("No")
    elif S[i]=="b":
        if cnt<A+B and cnt2<B:
            print("Yes")
            cnt += 1
            cnt2 += 1
        else:
            print("No")
            cnt2 += 1

Measured memory_bytes: 76104
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,p[1001];
vector<int>v;
int nibuntansaku(int x){
  int l=0,r=v.size();
  while(l<r){
    int mid=(l+r)/2;
    if(v[mid]>x)r=mid;
    else l=mid+1;
  }
  if(v[l]>x&&l!=0)l--;
  return v[l];
}
main(){
  while(cin>>n>>m,n){
    v.clear();
    v.push_back(0);
    for(int i=0;i<n;i++){
      cin>>p[i];
      v.push_back(p[i]);
    }
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
        v.push_back(p[i]+p[j]);
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<v.size();i++){
      int x=nibuntansaku(m-v[i])+v[i];
      if(x<=m)sum=max(x,sum);
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 7060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;
typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,d,h,k,w,x;
ll T;


int main()
{
   ll c1,c2,c3,c4,c5,c6;
    ll a,b,c,e,g;
    ll x,y,z;
    //freopen("stupd.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    vector<ll> A;
    for(c1 = 0; c1 < 2*n; c1++){
        cin >> a;
        A.push_back(a);

    }

    sort(A.begin() , A.end());

    ll ans = 0;

    for(c1 = 0; c1 < 2*n; c1 += 2){

        ans += A[c1];

    }

    cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 764
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		
		for (int i=0;i < k;i++) {
			if ((a >= b) && (a >= c)) {
				a = a*2;
			} else if ((b >= a) && (b >= c)) {
				b = b*2;
			} else {
				c = c*2;
			}
		}
		System.out.println(a+b+c);
	}
}

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

int main(){
	// sengen
	char s;
	// nyuryoku
	cin >> s;
	// keisan
	if(s == 'A'){
		cout << "T" << endl;
	}else if(s == 'T'){
		cout << "A" << endl;
	}else if(s == 'C'){
		cout << "G" << endl; 
	}else{
		cout << "C" << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 3424
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int h, w;
    cin >> h >> w;
    akari<seika> bs(h);
    for (int i = 0; i < h; i++)
    {
        cin >> bs[i];
    }
    maki<int> dp(4, yukari<int>(h, akari<int>(w)));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (bs[i][j] == '#')
            {
                continue;
            }
            if (i)
            {
                dp[0][i][j] = dp[0][i - 1][j] + (bs[i - 1][j] == '.');
            }
            if (j)
            {
                dp[1][i][j] = dp[1][i][j - 1] + (bs[i][j - 1] == '.');
            }
        }
    }
    for (int i = h - 1; i >= 0; i--)
    {
        for (int j = w - 1; j >= 0; j--)
        {
            if (bs[i][j] == '#')
            {
                continue;
            }
            if (i != h - 1)
            {
                dp[2][i][j] += dp[2][i + 1][j] + (bs[i + 1][j] == '.');
            }
            if (j != w - 1)
            {
                dp[3][i][j] += dp[3][i][j + 1] + (bs[i][j + 1] == '.');
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            ans = max(ans, dp[0][i][j] + dp[1][i][j] + dp[2][i][j] + dp[3][i][j] + (bs[i][j] == '.'));
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 82944
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] ret = new int[w+1];
		for(int i =0 ; i < w+1; i++) ret[i] = i;
		for(int k = 0;  k< n ; k++){
			String ts = sc.next();
			ts = ts.replace(',', ' ');
			Scanner str = new Scanner(ts);
			int d1 =str.nextInt();
			int d2 =str.nextInt();
			int temp = ret[d1];
			ret[d1] = ret[d2];
			ret[d2] = temp;
		}
		for(int i = 1;i < w+1;i++){
			System.out.println(ret[i]);
		}
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if(a == b && b == c && a % 2 == 0) ans = -1;
    else{
        while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
            ans++;
            int t1 = b/2 + c/2;
            int t2 = a/2 + c/2;
            int t3 = a/2 + b/2;
            a = t1;
            b = t2;
            c = t3;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int K, X;
  cin >> K >> X;
  auto mn = max(-1000000, X - K + 1);
  auto mx = min(1000000, X + K - 1);

  for(int i = mn; i <= mx; ++i) {
    cout << i << " ";
  }
  cout << endl;

  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	vector<int>A(N);
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		sum += A[i];
	}
	
	if (sum % 2 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;
int main() {
	int n, l,a;
	cin >> n>>l;
	if (l >= 0) { a = l * (n-1)+ n * (n - 1) / 2; }
	else if(l+n-1<=0){ a = l * (n - 1) + n * (n - 1) / 2 - n + 1; }
	else { a = l * n + n * (n - 1) / 2; }
	cout<<a;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int64_t A,B,C,D;
int64_t func(int64_t x){
  int64_t sum= x/C+x/D-x/(C*D/__gcd(C,D));
  return sum;
}
int main() {
  cin>>A>>B>>C>>D;
  cout<<(B-A+1)-(func(B)-func(A-1))<<endl;
  return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(void){

   int i,d,area;

   while(scanf("%d",&d)!=EOF){
      area=0;
      for(i=d;i<=600-d;i+=d){

         area+=i*i*d;
      }
      printf("%d\n",area);

   }
   return 0;
}

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

int main(){
    int N,K; cin >> N >> K;
    vector<long long> p(N);
    for(int i=0; i<N; i++) cin >> p.at(i), ++p.at(i);

    //累積和
    vector<long long> s(N+1,0); //sをゼロに初期化
    for(int i=0; i<N; i++) s.at(i+1) = s.at(i) + p.at(i);

    //K 差を見ていく
    long long res =0;
    for(int i=0; i+K <= N; i++) res = max(res, s.at(i+K) -s.at(i));
    cout << fixed << setprecision(10) << (double)(res)/2 << endl;
}

Measured memory_bytes: 3328
n = int(input())
lst = list(map(int, input().split()))
flg = True

for i in range(len(lst)-2, 0, -1):
  if lst[i] == 1 + lst[i+1]:
    lst[i] -= 1
  elif lst[i] > 1 + lst[i+1]:
    flg = False
    break

#if lst.index(max(lst)) < lst.index(min(lst)) and max(lst)>min(lst)+1:
if sorted(lst) != lst:
  flg = False
  
if flg:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 63984
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut a = vec![];
	let mut b = vec![];
	for _ in 0..n {
		let x: i64 = s.next().unwrap().parse().unwrap();
		let y: i64 = s.next().unwrap().parse().unwrap();
		a.push(x - y);
		b.push(x + y);
	}
	let amax = a.iter().max().unwrap();
	let amin = a.iter().min().unwrap();
	let bmax = b.iter().max().unwrap();
	let bmin = b.iter().min().unwrap();
	let d = std::cmp::max(amax - amin, bmax - bmin);
	println!("{}", d);
}


Measured memory_bytes: 9212
/*  
Function：Tarjan无向图求割点割桥, O(n+m), 无重边/重边情况均可处理 
1. 求出所有的桥，再将 
*/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<=b; ++i)
#define repp(i,a,b) for(int i=b; i>=a; --i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ms(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int>vi;
const int maxn = 1e4+7;
// 建边 
struct edge{
    int to, next;
}e[maxn << 1]; //两倍空间 
int fi[maxn], id=0;
void adde(int u, int v){
    e[id].to = v;
    e[id].next = fi[u];
    fi[u] = id++;
    return ;
}
int dfn[maxn], low[maxn], sig;  
bool cut[maxn]; //是否为割点

typedef pair<int, int> pii; 
vector<pii>cutbg; //保存割桥

void init(){
    ms(fi, -1), ms(dfn, 0), ms(low, 0), ms(cut, false);
    sig = id = 0;
    cutbg.clear();
    return ;
} 
int ans = 0;
void tarjan(int u,int eid) // eid指父亲边   
{  
    low[u] = dfn[u] = ++sig;  
    int i, son = 0; // 记录子树 
    for(i = fi[u]; ~i; i = e[i].next){  
        int to = e[i].to;  
        if( i == (eid^1) ) continue;  //重边 
        if( !dfn[to] ){  
            son++;
            tarjan( to, i );  

            low[u]=min(low[u],low[to]);  
            if(low[to] > dfn[u]){ // 判断割桥 
                ans++;
            }
//            if(low[to] >= dfn[u]){ // 判断割点 
//                cut[u] = true;
//            }
        }  
        else low[u]=min(low[u],dfn[to]);  
    }  
    //if(eid == -1 && son <= 1) cut[u] = 0; // 当u为根节点，且u只有一个子树或没有子树的时候 , u一定不是割点 
}  
int main(){
    //freopen("in.txt", "r", stdin);
    int n, m;
   	cin >> n >>m;
    init();
    int u, v;
    rep(i, 1, m){  
        scanf("%d%d",&u,&v);  
        adde(u,v);
        adde(v, u); 
    }  
	rep(i, 1, n){
		if(!dfn[i]) 
			tarjan(i,-1); // 若确定为联通图    	
	}
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, ans = 0, nn;
	cin >> n;
	nn = n;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	if (nn % ans == 0) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <queue>

using namespace std;

int main(){
    string s; cin >> s;
    int n=s.size();
    vector<int> ans(n);

    int last_r=0;
    for(int i=1; i<n; ++i){
        if(s[i]=='R'){
            last_r=i;
        } else{
            int d=i-last_r;
            if(d%2) ++ans[last_r+1];
            else ++ans[last_r];
        }
    }

    int last_l=n-1;
    for(int i=n-2; i>=0; --i){
        if(s[i]=='L'){
            last_l=i;
        } else{
            int d=last_l-i;
            if(d%2) ++ans[last_l-1];
            else ++ans[last_l];
        }
    }

    for(int i=0; i<n; ++i){
        cout << ans[i] << (i==n-1 ? '\n' : ' ');
    }
    return 0;
}



Measured memory_bytes: 1024
/**
 *    author:  Mohamad Milhem
 *    created: 2020-03-07-14.07.07
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


int main(){

    FAST;

    string s;
    cin >> s ;

    if ((s == "AAA")||(s == "BBB"))cout << "No"  <<endl;
    else cout << "Yes" <<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n, m, c, ca, a, ans = 0;
	cin >> n >> m >> c;
	vector<int>b(m);
	for (auto& i : b)
	{
		cin >> i;
	}
	for (int i = 0; i < n; i++)
	{
		ca = c;
		for (int j = 0; j < m; j++)
		{
			cin >> a;
			ca += a * b[j];
		}
		if (ca > 0) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//abc075_b.cpp
//Sat Jun  9 11:21:39 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
	int h,w;
	cin >> h >> w;

	char ans[h][w];
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			ans[i][j] = '0';
		}
	}

	for (int i=0;i<h;i++){
		string temp;
		cin >> temp;
		for (int j=0;j<w;j++){
			if (temp[j] == '#'){
				if (ans[i-1][j-1] != '#' && i>0 && j>0){
					ans[i-1][j-1]++;
				}
				if (ans[i-1][j] != '#' && i>0){
					ans[i-1][j]++;
				}
				if (ans[i-1][j+1] != '#' && i>0 && j<w-1){
					ans[i-1][j+1]++;
				}
				if (ans[i][j-1] != '#' && j>0){
					ans[i][j-1]++;
				}
				ans[i][j] = '#';
				if (ans[i][j+1] != '#' && j<w-1){
					ans[i][j+1]++;
				}
				if (ans[i+1][j-1] != '#' && i<h-1 && j>0){
					ans[i+1][j-1]++;
				}
				if (ans[i+1][j] != '#' && i<h-1){
					ans[i+1][j]++;
				}
				if (ans[i+1][j+1] != '#' && i<h-1 && j<w-1){
					ans[i+1][j+1]++;
				}
			}
		}
	}


	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			cout << ans[i][j];
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
import math
a, b, x = list(map(int, input().split()))
s = 0.5 * a * b
if x/a <= s:
    h = 2 * x / a / b
    ans = math.degrees(math.atan2(b, h))
else:
    h = 2 * (b - x / a / a)
    ans = math.degrees(math.atan2(h, a))

print(ans)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int64_t> a(n);
    for (auto& e : a) cin >> e;
    vector<int64_t> acc(n+1);
    acc[0] = 0;
    for (int64_t i = 0; i + 1 < n + 1; i++) acc[i+1] += acc[i] + a[i];

    map<int64_t, int64_t> rs;
    int64_t ans = 0;
    for (auto& e : acc) {
        int64_t i = e % m;
        ans += rs[i]++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 5760