akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vector<ll> a(n);
  scan(a);

  rep(i, 0, n) a[i] -= ll(i + 1);

  sort(all(a));
  ll middle = a[n / 2];
  ll ans = 0;
  rep(i, 0, n) ans += abs(a[i] - middle);
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int num5 = 0;
    int num7 = 0;

    if (a == 5) num5++;
    else num7++;
    if (b == 5) num5++;
    else num7++;
    if (c == 5) num5++;
    else num7++;

    if (num5 == 2 && num7 == 1)
    {
	cout << "YES";
    }
    else
    {
	cout <<"NO";
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[6**i for i in range(10)]+[9**i for i in range(10)]
dp=list(range(10**5+1))
dp[1]=1
for i in range(n):
    for j in a:
        if i+j<10**5+1:
            dp[i+j]=min(dp[i+j],dp[i]+1)
print(dp[n])

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
   	int n, w;
   	cin >> n >> w;
   	ll dp[w + 5] = {};
   	f(n) {
   		int x, v;
   		cin >> x >> v;
   		for (int j = w ; j >= x ; j--) {
   			dp[j] = max(dp[j], dp[j - x] + v); 
   		}
   	}
   	cout << dp[w] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)


template<class T>
T gcd(T a, T b) {
	return (b == 0) ? a : gcd(b, a % b);
}


int main() {
	ll A, B;
	cin >> A >> B;

	ll ans = 0;
	if (A <= 5) {
		ans = 0;
	} else if (A >= 13) {
		ans = B;
	} else {
		ans = B / 2;
	}

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 140010
#define INF 140000000000000ll
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<pll> vec;
int n;
vector<int> a[MAXN],w[MAXN];
ll mid,minv[MAXN];
vec f[MAXN];
bool sort_by_x(pll x,pll y){
	return x.first<y.first;
}
bool sort_by_y(pll x,pll y){
	return x.second<y.second;
}
void solve(vec &ls,vec &rs,vec &f){
	if(ls.size()>rs.size())
		swap(ls,rs);
	sort(ls.begin(),ls.end(),sort_by_y);
	sort(rs.begin(),rs.end(),sort_by_x);
	minv[0]=rs[0].second;
	for(int i=1;i<int(rs.size());i++)
		minv[i]=min(minv[i-1],rs[i].second);
	for(int i=0,j=int(rs.size())-1;i<int(ls.size());i++){
		while(j>=0&&ls[i].second+rs[j].first>mid)
			j--;
		if(j>=0)
			f.push_back(make_pair(ls[i].first,minv[j]));	
	}
	sort(ls.begin(),ls.end(),sort_by_x);
	sort(rs.begin(),rs.end(),sort_by_y);
	minv[0]=rs[0].first;
	for(int i=1;i<int(rs.size());i++)
		minv[i]=min(minv[i-1],rs[i].first);
	for(int i=0,j=int(rs.size())-1;i<int(ls.size());i++){
		while(j>=0&&ls[i].first+rs[j].second>mid)
			j--;
		if(j>=0)
			f.push_back(make_pair(minv[j],ls[i].second));	
	}
}
void dfs(int x){
	if(f[x].size()!=0)
		f[x].clear();
	if(a[x].size()==0){
		f[x].push_back(make_pair(0,0));
		return ;	
	}
	dfs(a[x][0]);
	dfs(a[x][1]);
	vec &ls=f[a[x][0]];
	vec &rs=f[a[x][1]];
	for(int i=0;i<int(ls.size());i++){
		ls[i].first+=w[x][0];
		ls[i].second+=w[x][0];
	}
	for(int i=0;i<int(rs.size());i++){
		rs[i].first+=w[x][1];
		rs[i].second+=w[x][1];
	}
	solve(ls,rs,f[x]);
}
int main(){
	//freopen("travel.in","r",stdin);
	//freopen("travel.out","w",stdout);
	int u,val;
	SF("%d",&n);
	for(int i=2;i<=n;i++){
		SF("%d%d",&u,&val);
		a[u].push_back(i);
		w[u].push_back(val);
	}
	ll l=0,r=INF,ans=INF;
	while(l<=r){
		mid=(l+r)>>1ll;
		//PF("[%lld %lld %lld]\n",l,r,mid);
		dfs(1);
		if(f[1].size()){
			r=mid-1ll;
			ans=mid;
		}
		else
			l=mid+1ll;
	}	
	PF("%lld",ans);
}

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

int main() {
  int X;
  cin >> X;
  
  int five_hundred;
  int five;
  
  five_hundred = (int)(X/500);
  five = (int)((X - 500 * five_hundred)/5);
  
  cout << five_hundred * 1000 + five * 5 << endl;
 
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * ReverseNumber
 */
public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }

        for (int i = a.length - 1; i > 0; i--) {
            System.out.print(a[i] + " ");
        }
        System.out.println(a[0]);

        sc.close();
    }
}


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

string S,T;

int main(){
    cin>>S>>T;
    
    int sum=0;
    
    for(int i=0; S[i];i++){
        if(S[i]!=T[i]) sum++;
    }
    
    cout<<sum;
    
    return 0;
}


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


ll N, X;
vector<pair<ll, ll>> w;


ll solve(int i) {
    if (X == 0) return 0;
    if (i == 0) return 1;
    if (X == 1) return 0;
    X--;
    if (X <= w[i-1].first) return solve(i - 1);
    X -= w[i-1].first;
    if (X == 1) return w[i-1].second + 1;
    X--;
    if (X <= w[i-1].first) return w[i-1].second + 1 + solve(i - 1);
    return 2 * w[i-1].second + 1;
}


int main() {
    cin >> N >> X;
    w = vector<pair<ll, ll>>(N + 1);
    w[0] = make_pair(1, 1);
    for (int i = 1; i <= N; i++) {
        w[i].first = 2 * w[i-1].first + 3;
        w[i].second = 2 * w[i-1].second + 1;
    }
    ll ans = solve(N);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;
using Pos = std::pair<int, int>;
//cout<<fixed<<std:cout<<fixed<<setprecision(2)<<Max<<endl;
constexpr int mod=1e9+7;

int main() {
    long long N,M;
    cin>>N>>M;

    long long ans=0;
    if(2*N>=M){
        ans=M/2;
    }else{
        ans+=N;
        M-=2*N;
        ans+=M/4;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
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(false);

    string s;
    cin >> s;
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
    } else {
        if (s.size() == 26) {
            rrep(i, 0, s.size()) {
                rrep(j, i + 1, s.size()) {
                    if (s[i] < s[j]) {
                        swap(s[i], s[j]);
                        cout << s.substr(0, i + 1) << endl;
                        return 0;
                    }
                }
            }
        } else {
            set<char> st(s.begin(), s.end());
            rep(i, 0, 26) {
                char c = 'a' + i;
                if (st.count(c)) continue;
                s += c;
                break;
            }
            cout << s << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,p,pc,np,h,i,j,k,l,m,n,y;
	ll		ans = 0;
	string	x,xx;
	cin >> n >> x;
	vector<ll> pcm(n),pcp(n);
	pc=0;
	for(i=0;i<n;i++) if (x[i]=='1') pc++;
	if (pc>1) pcm[n-1] = 1 % (pc-1);
	else pcm[n-1] = 0;
	pcp[n-1] = 1 % (pc+1);
	for(i=n-2;i>=0;i--) {
		if (pc>1) pcm[i] = (pcm[i+1]*2)%(pc-1);
		else pcm[i] = 0;
		pcp[i] = (pcp[i+1]*2)%(pc+1);
	}
	a = b = 0;
	for(i=n-1;i>=0;i--) {
		if (x[i]=='1') {
			a+=pcm[i];
			if (pc>1) a %= pc-1;
			b+=pcp[i];
			b %= pc+1;
		}
	}
	
//printf("pc=%d a=%d b=%d\n",pc , a , b);
	for(i=0;i<n;i++) {
		ans=0;
		if (x[i]=='0') {
			p = pc+1;
			np = (b + pcp[i])%p;
		} else {
			p = pc-1;
			if (p!=0) np = (a + p - pcm[i])%p;
			else np = 0;
		}
		if (p!=0) ans++;

//printf("p=%d np=%d\n",p,np);

		while(np!=0) {
			ans++;
			p = __builtin_popcount(np);
			np = np % p;
		}

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


Measured memory_bytes: 5184
#include <bits/stdc++.h>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define pb push_back
  #define f first
  #define se second
  
  using namespace std;
  int main()
  {
    std::ios::sync_with_stdio(false);
    ll n=0,m=0,W,k=0,x=0,t1=0,t2=0,t3=0,f=0,sum=0,count=0;

    cin>>n>>W; //see the mobile photograph for concepts 
    ll dp[n+1][W+1]; mem(dp,0);
    ll w[n+1],v[n+1]; mem(w,0); mem(v,0);

    for (ll i = 1; i < n+1; ++i){
      cin>>w[i]>>v[i];
    }

    // dp[1][w[1]]=v[1];   base case told in a video lecture

    for (ll i = 1; i < n+1; ++i)
    {
      dp[i][0]=0; // since for 0 capacity value is 0
      
      for (ll j = 1; j < W+1; ++j)
      {
        dp[i][j]=dp[i-1][j];   //exclude

        if(j-w[i]>=0)
          dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);  // include & exclude maxm take
      }
    }

    for (ll i = 0; i < W+1; ++i)
    {
      count=max(count,dp[n][i]);  // selecting the maxm from the nth row.
    }

    cout<<count;

    return 0;
  }

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

int main() {
  int n,k;

  cin >> n >> k;

  ll dp[n + 1];
  int i,j;
  rep(i,0,n + 1) dp[i] = 100100100100;

  int h[n + 1];
  rep(i,1,n + 1) cin >> h[i];

  dp[0] = 0;
  dp[1] = 0;

  for(i = 1;i <= n;i++){
    for(j = 1;j <= k;j++){
      if(i + j <= n){
        dp[i + j] = min(dp[i + j],dp[i] + abs(h[i + j] - h[i]));
      }
    }
  }

  cout << dp[n] << endl;

  return 0;
}


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

int main()
{
    int n;
    string str;
    cin >> n >> str;
    
    int x = 0, ans = 0;

    for(int i = 0; i < n; i++){
        if(str[i] == 'I')x++;
        if(str[i] == 'D')x--;
        ans = max(x, ans);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
program ABC162_D
  character(4000)::S
  integer*8::R=0,G=0,B=0,A
  read(*,*)N
  read(*,*)S
  do i=1,N
     if(S(i:i)=='R') R=R+1
     if(S(i:i)=='G') G=G+1
     if(S(i:i)=='B') B=B+1
  end do
  A=R*G*B
  do i=1,N
     do j=1,N
        if(i+2*j>N) cycle
        if(S(i:i)/=S(i+j:i+j) .and. S(i+j:i+j)/=S(i+2*j:i+2*j) .and. S(i+2*j:i+2*j)/=S(i:i)) A=A-1
     end do
  end do
  write(*,*)A
end program ABC162_D

Measured memory_bytes: 2864
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    int ans = 0;
    for(int i=1; i<=n; i++) {
    	if(i<=9){
    	    if(a<=i && i<=b) {
    		    ans += i;
    	        }
    	}else if(i<=99) {
    		if(a <= i/10 + i%10 && i/10 + i%10 <= b) {
    			ans += i;   				
    			}
      	}else if(i<=999) {
      		if(a <= i/100 + (i%100)/10 + (i%10) && i/100 + (i%100)/10 + (i%10) <= b) {
      			ans += i;
      		}
        }else if(i<=9999) {
      		if (a <= i/1000 + (i%1000)/100 + ((i%1000)%100)/10 +(i%10) && i/1000 + (i%1000)/100 + ((i%1000)%100)/10 +(i%10)<= b) {
      			ans += i;
      		}
      	}else if(i== 10000){
    		if(a==1) {
    			ans += i;
    	}
    }
    }
        	System.out.println(ans);
      }
}

Measured memory_bytes: 35760
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// http://drken1215.hatenablog.com/entry/2019/02/16/075900
using Edge = pair<int, long long>;
int N, M;
vector<vector<Edge>> G;

int main() {
    int N, M;
    cin >> N >> M;
    G.resize(N);
    REP(i, M) {
        int a, b;
        long long w;
        cin >> a >> b >> w;
        a--;
        b--;
        G[a].push_back(Edge(b, -w));
    }
    vector<long long> dist(N, INF);
    bool negative = false;
    dist[0] = 0;
    for(int iter = 0; iter <= N * 2; iter++) {
        for(int v = 0; v < N; v++) {
            // vertex
            if(dist[v] >= INF / 2) {
                continue;
            } //なんで
            for(auto e : G[v]) {
                if(chmin(dist[e.first], dist[v] + e.second)) {
                    if(e.first == N - 1 and iter == N * 2) {
                        negative = true; //壊れてる
                    }
                }
            }
        }
    }
    if(!negative) {
        cout << -dist[N - 1] << endl;
    } else {
        cout << "inf" << endl;
    }
}

Measured memory_bytes: 384
N = int(input())

#文字数分aで埋める
#末尾をbにする
#一桁上の文字+1文字までは許容するルールで増加させていく

ans = [0 for _ in range(N)]
stop = [i for i in range(N)]

def ans_print(ans_list):
    ans = list()
    for a in ans_list:
        ans.append(chr(a+97)) #97でaが出る

    print(''.join(map(str, ans)))
    return 0

def ans_check(ans):
    max_in_ans = 0

    for i in range(1,N):
        if max_in_ans + 1 < ans[i]:
            ans[i-1] += 1
            ans[i] = 0
            return ans_check(ans)
        else:
            max_in_ans = max(max_in_ans,ans[i])
    else:
        return ans

if N == 1:
    print("a")
else:
    while 1:
        ans_check(ans)
        ans_print(ans)
        ans[-1] += 1
        if ans == stop:
            ans_print(ans)
            break


Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;   //m[3]=5;
vector<int> v;
 
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		int x;
		cin>>x;
		if(m.count(x)==0)v.push_back(x);
		++m[x];
	}
	int ans=0;
	for(int i=0;i<v.size();++i)
		if(v[i]>m[v[i]]) ans+=m[v[i]];
		else if(v[i]<m[v[i]]) ans+=m[v[i]]-v[i];
	cout<<ans<<"\n";
	return 0; 
}

Measured memory_bytes: 5112
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <utility>
#include <algorithm>
template <typename T> using vec=std::vector<T>;
using intp=std::pair<int,int>;
using i64=int64_t;
using std::sort;
using std::lower_bound;
static constexpr char nl='\n';
template <typename T1,typename T2> static inline const T1 &pe0(const std::pair<T1,T2> &p) { return p.first; }
template <typename T1,typename T2> static inline const T2 &pe1(const std::pair<T1,T2> &p) { return p.second; }
template <typename T1,typename T2> static inline T1 &pe0(std::pair<T1,T2> &p) { return p.first; }
template <typename T1,typename T2> static inline T2 &pe1(std::pair<T1,T2> &p) { return p.second; }
template <typename Tf> static inline void rep(int n, Tf f) { for ( int i=0; i<n; i++ ) { f(i); } }
template <typename Tf> static inline void repr(int n, Tf f) { for ( int i=n-1; i>=0; i-- ) { f(i); } }
template <typename T> static inline int blen(T n) {
  int i=0;
  while ( n>0 ) { i++; n>>=1; }
  return i;
}
template <typename Te,typename Tc> class segtree {
private:
  const int _n,_n2;
  const Tc _f;
  const Te _e;
  vec<Te> _ctn;
public:
  segtree(int n,Tc f,Te e): _n(n),_n2(1<<(1+blen(n))),_f(f),_e(e) {
    _ctn.assign(_n2-1,e);
  }
  const Te &operator[](int p) const {
    return _ctn[p];
  }
  void set(int p,Te val) {
    _ctn[p]=val;
    for ( int pprev=p,prdist=_n2-p,pnext; (prdist&1)==0&&prdist>2; pprev=pnext ) {
      prdist>>=1;
      pnext=_n2-prdist;
      _ctn[pnext]=val=_f(val,_ctn[pprev+1]);
    }
  }
  Te get(int ib,int ie) {
    int w=1<<(blen(ib^ie)-1);
    int rm=(ib&ie&~(w-1))|w;
    Te ret=_e;
    for ( int rt=rm,wt=w; ib<rt; wt>>=1 ) {
      if ( rt-wt<ib ) continue;
      ret=_f(ret,_ctn[_n2-(_n2-rt)/wt-1]);
      rt-=wt;
    }
    for ( int rt=rm,wt=w; rt<ie; wt>>=1 ) {
      if ( ie<rt+wt ) continue;
      ret=_f(ret,_ctn[_n2-(_n2-rt)/wt]);
      rt+=wt;
    }
    return ret;
  }
};
int solve(int n,vec<intp> xds) {
  constexpr int M=998244353;
  std::sort(xds.begin(),xds.end());
  vec<int> ys(n);
  rep(n,[&](int i){
    intp bound(pe0(xds[i])+pe1(xds[i]),0); // 0: dummy
    auto ib=xds.begin(),ie=xds.end();
    auto lb=std::lower_bound(ib,ie,bound);
    ys[i]=lb==ie ? n : lb-ib;
  });
  auto fmax=[](int a,int b)->int{ return a>b ? a : b; };
  segtree<int,decltype(fmax)> sgt(n,fmax,-1);
  repr(n,[&](int i){
    sgt.set(i,ys[i]==i+1 ? i+1 : sgt.get(i+1,ys[i]));
  });
  vec<int> cs(n+1,0);
  cs[0]=1;
  rep(n,[&](int i){
    cs[i+1]=(cs[i+1]+cs[i])%M;
    cs[sgt[i]]=(cs[sgt[i]]+cs[i])%M;
  });
  return cs[n];
}

void doit(std::istream &sin, std::ostream &sout) {
  int n;
  sin >> n;
  vec<intp> xds(n);
  rep(n,[&](int i){
    sin >> pe0(xds[i]) >> pe1(xds[i]);
  });
  int ans=solve(n,xds);
  sout << ans << nl;
}
int main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  doit(std::cin,std::cout);
}

Measured memory_bytes: 7040
#include <stdio.h>
#include <math.h>

int main(){
	int i,j;
	for (i=1;i<10;i++)
	{
		for (j=1;j<10;j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

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

int main(){
  int N,cnt = 0;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i = 0; i < N;i++){
    if(a[a[i]] == i) cnt++;
  }
  cout << cnt/2 << endl;
  return 0;
}


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

int GCD(int a, int b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int ans = A.at(0);
  for (int i = 0; i < N; i++) {
    ans = GCD(ans, A.at(i));
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional> 
#include <vector>

using namespace std;

int main(){

    int n;
    cin >> n;

    if(n==0){
        cout << "2";
        return 0;
    }
    if(n==1){
        cout << "1";
        return 0;
    }

    long long int a = 2;
    long long int b = 1;
    long long int ans;

    for(int i=0;i<n-1 ;++i){
        ans = a + b;
        a = b;
        b = ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>

using namespace std;

int main()
{
	char s[0x10000];
	
	int sum = 0;
	while(scanf("%s", s) != EOF){
		int x = 0;
		for (int i = 0; s[i]; i++){
			if (isdigit(s[i])){
				x = x * 10 + (s[i] - '0');
			}
			else {
				sum += x;
				x = 0;
			}
		}
		sum += x;
	}
	
	printf("%d\n", sum);
	
	return(0);
}

Measured memory_bytes: 976
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int c = 0;
        HashSet<String> m = new HashSet<>();
        ArrayDeque<String> q = new ArrayDeque<>();
        q.add("357");
        q.add("375");
        q.add("537");
        q.add("573");
        q.add("735");
        q.add("753");
        m.add("357");
        m.add("375");
        m.add("537");
        m.add("573");
        m.add("735");
        m.add("753");
        while (!q.isEmpty()) {
            String s = q.pop();
            if (Long.parseLong(s) <= n) {
                c++;
                for (int i = 0; i < s.length() + 1; i++) {
                    for (int j = 3; j <= 7; j += 2) {
                        String x = s.substring(0, i) + j + s.substring(i);
                        if (!m.contains(x)) {
                            q.add(x);
                            m.add(x);
                        }
                    }
                }
            }
        }
        out.println(c);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 99956
while line = gets do
  m, f, r = line.split.map(&:to_i)
  if m + f + r == -3 then break end
  if m == -1 || f == -1 || m + f < 30
   puts "F"
  elsif m + f >= 80
    puts "A"
  elsif m + f >= 65
    puts "B"
  elsif m + f >= 50 || (m + f >= 30 && r >= 50)
    puts "C"
  elsif m + f >= 30
    puts "D"
  end 
end

Measured memory_bytes: 8676
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> cnt(n);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0, x; j < d; j++) {
            cin >> x;
            --x;
            ++cnt[x];
        }
    }
    int ans = 0;
    for (auto &i : cnt) {
        if (!i) ++ans;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > x = {
	{0,3,6,9,15,23,26,29,20,17},
	{2,5,8,11,12,21,24,27,18,14},
	{0,1,2,14,18,27,28,29,15,20},
	{6,7,8,12,9,21,22,23,17,11}
};
int q; map<vector<int>, int> dp;
int main() {
	vector<int> r = {1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3};
	queue<vector<int> > que; que.push(r); dp[r] = 1;
	while(!que.empty()) {
		vector<int> u = que.front(); que.pop();
		if(dp[u] == 9) continue;
		for(int i = 0; i < 4; i++) {
			vector<int> t = u;
			for(int j = 0; j < 5; j++) swap(t[x[i][j]], t[x[i][j + 5]]);
			if(!dp[t]) dp[t] = dp[u] + 1, que.push(t);
		}
	}
	cin >> q;
	while(q--) {
		vector<int> s(30);
		for(int i = 0; i < 30; i++) cin >> s[i];
		cout << dp[s] - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3228
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

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

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong N;
    cin >> N;
    string S;
    cin >> S;

    llong leftCount = 0;
    llong rightCount = 0;

    FOR(i, N) {
        if(S[i] == '(') leftCount++;
        else rightCount++;
    }

    llong r = rightCount - leftCount;
    FOR(i, r) {
        S = '(' + S;
    }
    FOR(i, -r) {
        S = S + ')';
    }

    N = S.length();
    leftCount = 0;
    rightCount = 0;
    llong diff = 0;
    FOR(i, N) {
        if(S[i] == '(') leftCount++;
        else rightCount++;
        diff = max(diff, rightCount - leftCount);
    }
    FOR(i, diff) {
        cout << '(';
    }
    cout << S;
    FOR(i, diff) {
        cout << ')';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

constexpr int64_t kMod = 1e9+7;

int main() {
  int64_t N;
  cin >> N;
  vector<pair<int64_t, int64_t>> zs(N);
  vector<pair<int64_t, int64_t>> ws(N);
  for (int64_t n = 0; n < N; ++n) {
    int64_t x, y;
    cin >> x >> y;
    zs[n] = {x + y, n};
    ws[n] = {x - y, n};
  }
  sort(zs.begin(), zs.end());
  sort(ws.begin(), ws.end());
  
  int64_t dist_z = zs.back().first - zs.front().first;
  int64_t dist_w = ws.back().first - ws.front().first;

  cout << max(dist_z, dist_w) << endl;

  return 0;
}


Measured memory_bytes: 9528
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
  int n,m,ans,max_l,min_r;
  cin>>n>>m;
  max_l=0,min_r=n;
  for(int i=1; i<=m; i++){
    int l,r;
    cin>>l>>r;
    max_l=max(max_l,l);
    min_r=min(min_r,r);
  }
  ans=min_r-max_l+1;
  if(ans>=0){
    cout<<ans<<endl;
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    int N;cin >> N;
    double v[107];
    rep(i,N){
        cin >> v[i];
    }
    sort(v,v+N);
    double ans=v[0];
    rep(i,N-1){
        ans+=v[i+1];
        ans/=2;
    }
    printf("%lf",ans);
}

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

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

class list {
  private:
    Node *nil;
    void deleteNode(Node *t);
    Node *listSearch(int key);
  public:
    list();
    void insert(int key);
    void deleteKey(int key);
    void deleteFirst();
    void deleteLast();
    void printList();
};

list::list() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

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

Node* list::listSearch(int key) {
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key ) {
    cur = cur -> next;
  }
  return cur;
}

void list::deleteNode(Node *t){
  if ( t == nil ) { return; }
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void list::deleteKey(int key) {
  list::deleteNode(list::listSearch(key));
}

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

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

void list::printList() {
  Node *cur = nil -> next;
  while (cur != nil) {
    cout << cur -> key;
    cur = cur -> next;
    if (cur != nil) { cout << " "; } else { cout << endl;}
  }
}

int main(){

  int n; cin >> n;
  list L;

  for (int i=0; i<n; i++){
    char command[20]; int x; scanf("%s%d", command, &x);
    if (command[6] == 'F'){
      L.deleteFirst();
    } else if (command[6] == 'L'){
      L.deleteLast();
    } else if (command[0] == 'i'){
      L.insert(x);
    } else {
      L.deleteKey(x);
    }
  }

  L.printList();

  return 0;
}



Measured memory_bytes: 34400
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
    #include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
    #define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
    #define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
    #define debug(x...)
    #define light_debug(x) 
#endif


using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    #ifdef DEBUG
        freopen("debug", "w", stderr);
    #endif
    
    int X;
    cin >> X;
    if(X >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";

    #ifdef DEBUG
        dbg::dout << "\nExecution time: " << clock() << "ms\n";
    #endif

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

struct A {
	ll x, y, z;
};

A data[1000] = {};

int main(void) {

	ll N, M,result = 0;
	cin >> N >> M;

	for (int i = 0; i < N; i++) {
		cin >> ::data[i].x >> ::data[i].y >> ::data[i].z;
	}

	for (int a = 0; a < 2; a++) {
		for (int b = 0; b < 2; b++) {
			for (int c = 0; c < 2; c++) {
				sort(::data, ::data + N, [&](const A& left, const A& right) {

					ll l = 0, r = 0;

					if (a == 0) {
						l += left.x;
						r += right.x;
					}
					else if (a == 1) {
						l -= left.x;
						r -= right.x;
					}
					if (b == 0) {
						l += left.y;
						r += right.y;
					}
					else if (b == 1) {
						l -= left.y;
						r -= right.y;
					}
					if (c == 0) {
						l += left.z;
						r += right.z;
					}
					else if (c == 1) {
						l -= left.z;
						r -= right.z;
					}

					return l < r;

				});

				ll x_sum = 0, y_sum = 0, z_sum = 0;

				for (int i = 0; i < M; i++) {
					x_sum += ::data[i].x;
					y_sum += ::data[i].y;
					z_sum += ::data[i].z;
				}

				//cerr << x_sum << " " << y_sum << " " << z_sum << endl;

				CHMAX(result,abs(x_sum) + abs(y_sum) + abs(z_sum));

			}
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
map<int,int> cnt;
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    int mx=0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        cin>>tmp;
        cnt[tmp]++;
        if(cnt[tmp]==2)
        {
            cnt[tmp]-=2;
            ans=max(ans,1LL*mx*tmp);
            mx=max(mx,tmp);
        }
    }
    print(ans);

}

Measured memory_bytes: 4992
N = int(input())
hs = list(map(int, input().split()))

"""
dp[i] i番目に到達するときの最小値
遷移
送るDP
i-1段目まで下記を実施
dp[i+1] = min(dp[i+1], dp[i]+コスト)
if (一段飛ばしできる余地があれば): 
    dp[i+2] = min(dp[i+2],dp[i]+コスト)

"""
INF = 10**9+7
dp = [INF]*101000
dp[0] = 0
for i in range(1,N):
    if i-2 >= 0:
        cost2 = abs(hs[i]-hs[i-2])
        dp[i] = min(dp[i],dp[i-2]+cost2)
    cost1 = abs(hs[i]-hs[i-1])
    dp[i] = min(dp[i],dp[i-1]+cost1)

print(dp[N-1])

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);

	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double al = 2*M_PI*(60*h+m)/(12*60);
	double be = 2*M_PI*m/60;
	
	double ax = a*cos(al);
	double ay = a*sin(al);
	double bx = b*cos(be);
	double by = b*sin(be);
	cout << setprecision(20);
	cout << sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by)) << endl;
	return 0;
}


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

int main(){
  int N;
  string s;
  cin >> N >> s;
  int cnt=0;
  for(int i=0; i<N; i++){
    if(s.at(i)=='R') cnt++;
    else cnt--;
  }
  if(cnt>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;

int main()
{
	int a,b,c;
	cin >> a >> b >>c;
	int n = 0;
	if (b - a * c >= 0) {
		n = c;
	}
	else {
		n = (b - b % a) / a;
	}

	cout << n << endl;

	return 0;

}

Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
	public static void main(String[] args) {
		
		FastReader sc = new FastReader();
	   int n = sc.nextInt();
	   int d = sc.nextInt();
	   int[][] tab = new int[n][d];
	   for(int i=0;i<n;++i) {
		   for(int j=0;j<d;++j) {
			   tab[i][j] = sc.nextInt();
		   }
	   }
	   long ans = 0;
	   for(int i=0;i<n;++i) {
		   for(int j=i+1;j<n;++j) {
			   double dis = 0.0;
			   for(int k=0;k<d;++k) {
				   dis+=Math.pow(tab[i][k]-tab[j][k],2);
			   }
			   dis = Math.sqrt(dis);
			   if(dis == (int)dis) ++ans;
		   }
	   }
	   
	   out.println(ans);
		out.close();
		
	}
	
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc035_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  map<ll, int> m;
  rep(i, N) {
    ll x;
    cin >> x;
    m[x]++;
  }

  bool ok = false;
  if (m.size() == 1 && m.begin()->first == 0) {
    ok = true;
  } else if (m.size() == 2) {
    int zn, xn;
    for (auto kv : m) {
      if (kv.first == 0) {
        zn = kv.second;
      } else {
        xn = kv.second;
      }
    }
    if (xn / 2 == zn && xn + zn == N) {
      ok = true;
    }
  } else if (m.size() == 3) {
    int n = 0;
    set<int> s;
    int xr = 0;
    for (auto kv : m) {
      s.insert(kv.second);
      xr = xr ^ kv.first;
    }
    if (s.size() == 1 && xr == 0) {
      ok = true;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 8364
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
    string s,t;
    int i = 0;
    cin >> s >> t;
    for(i = 0; i < s.length(); i++){
        if(s[i] != t[i])break;
    }
    if(i == s.length())cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620