akhauriyash/Code-Regression huggingface dataset:
import collections
n = int(input())
a_list = list(map(int, input().split()))
a_dict = dict(collections.Counter(a_list))
sorted_dict = sorted(a_dict.items(), key=lambda x:x[0])
a_set = set(a_list)
m = max(a_list)
for key, count in sorted_dict:
    if  key in a_set:
        j = key * 2
        while j <= m:
            a_set.discard(j)
            j += key
    if count > 1:
        a_set.discard(key)

print(len(a_set))

Measured memory_bytes: 57076
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	h := getNextInt(scanner)
	w := getNextInt(scanner)
	grid := makeInts(h+1, w+1)

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			tile := getNextInt(scanner)
			if tile == 1 {
				continue
			}
			grid[i+1][j+1] = grid[i+1][j] + 1
		}
	}

	ans := 0
	stack := make([]Pair, 1500)
	stack[0] = Pair{
		p: -1,
		h: 0,
	}
	for j := 0; j < w; j++ {
		s := 0
		for i := 0; i < h; i++ {
			for s > 0 && stack[s].h > grid[i+1][j+1] {
				if ans < stack[s].h*(i-stack[s-1].p-1) {
					ans = stack[s].h * (i - stack[s-1].p - 1)
				}
				s--
			}
			s++
			stack[s] = Pair{
				p: i,
				h: grid[i+1][j+1],
			}
		}
		for i := 0; i <= s; i++ {
			if ans < (h-stack[i].p)*stack[i].h {
				ans = (h - stack[i].p) * stack[i].h
			}
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type Pair struct {
	p, h int
}



Measured memory_bytes: 19012
#include<iostream>
#include<vector>
#include<climits>
#include<vector>
using namespace std;
long long dp[100001][3]={0};
long long vecation(vector<vector<int> > v,int n)
{ 
dp[1][0]=v[1][0];  
dp[1][1]=v[1][1];  
dp[1][2]=v[1][2]; 

for(int i=2;i<=n;i++) 
{ dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
  dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
	dp[i][2]=v[i][2]+max(dp[i-1][1],dp[i-1][0]);
	
	}	
return 	max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main()
{
	int n;
	cin>>n;
	vector<vector<int> > v(n+1,vector<int>(3));
	for(int i=1;i<=n;i++)
	  for(int j=0;j<=2;j++)
	 cin>>v[i][j];
	 cout<<vecation(v,n);
	 
	
	
	
}

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
typedef long long int lli;
typedef long long ll;
typedef long double ld;


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        ll max=1e18;
        ll ans=1;
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(a[i]==0){
                cout<<0;
                return 0;
            }
        }
        for(int i=0;i<n;i++){
            if(a[i]>max/ans){
                cout<<"-1";
                return 0;
            }
            ans*=a[i];
        }
        cout<<ans;
    }   
    return 0;
}


Measured memory_bytes: 3912
#include <stdio.h>
#include <string.h>

int main(void){
  char S[100000];
  scanf("%s",S);

  char str = S[0];
  int ans = 0;
  for(int i = 0;i < strlen(S);i++){
    if(str != S[i]){
      str = S[i];
      ans++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	ll n;
	cin >> n;
	ll sum = 0;
	for (ll i = 1; i*i <= n; i++)
	{
		if ((n-i)%i == 0 && i < (n-i)/i) sum += (n-i) / i;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<vector>

using namespace std;

int n,m;
int p[1001];

int solve(){
  int pp[(n+1)*(n+1)];
  
  for(int i = 0;i<=n;i++){
    for(int j = 0;j<=n;j++){
      pp[n*i+j] = p[i] + p[j];
      // cout<<"pp:"<<pp[n*i+j]<<endl;
    }
  }
  /*
  for(int i = 0;i<=n;i++){
    for(int j = 0;j<=n;j++){
      cout<<"ij:"<<n*i+j<<"\t"<<pp[i*n+j]<<endl;
    }
  }
  */
  int ans = 0;
  
  sort(pp,pp+n*n+n+1);
  /*
  for(int i = 0;i<=n;i++){
    for(int j = 0;j<=n;j++){
      cout<<"ij:"<<n*i+j<<"\t"<<pp[i*n+j]<<endl;
    }
  }
  */
  for(int i = 0;i<=n;i++){
    for(int j = 0;j<=n;j++){
      int* it = upper_bound(pp,pp+n*n+n+1,m-p[i]-p[j]);
      --it;
      // cout<<"it"<<*it<<endl;
      // cout<<"ij:"<<p[i]<<"\t"<<p[j]<<endl;
      // cout<<"ans:"<<p[i]+p[j]+(*it)<<endl;
      if(p[i] + p[j] > m)continue;
      ans = max(ans,p[i]+p[j]+(*it));
    }
  }
  return ans;
}

int main(){
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    p[0] = 0;
    for(int i = 1;i<=n;i++){
      cin>>p[i];
    }
    
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 5096
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=105;
int f[2][N],a[2][N];
int main()
{
	int n=ri(),i;
	for(i=1;i<=n;i++)	a[0][i]=ri();
	for(i=1;i<=n;i++)	a[1][i]=ri();
	for(i=n;i>=1;i--)	f[1][i]=f[1][i+1]+a[1][i];
	f[0][n]=a[0][n]+a[1][n];
	for(i=n-1;i>=1;i--)
		f[0][i]=max(f[0][i+1],f[1][i])+a[0][i];
	wi(f[0][1]);putchar('\n');
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int a;
  while(cin >> a) {
    if(a == -1) return 0;
    string ans = "0";
    rep(i, 0, a) {
      int f = 0;
      dep(j, ans.length() - 1, 0) {
        if(ans[j] == '3') {
          ans[j] = '0';
          if(j == 0) {
            ans = "1" + ans;
            break;
          }
        }else {
          if(f) break;
          ans[j]++;
          break;
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3108
#include <iostream>

 

using namespace std;

 

int main()
{
    int a ,b, temp, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        if(a <=0 && b <=0)
            break;
            
        if(a > b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

constexpr ll MOD = 1e9+7;

using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

ll fact[100001];

int main() {

  fact[0] = 1;
  REP(i, 1, 100001) {
    fact[i] = fact[i-1] * i % MOD;
  }

  for(int N, R; cin >> N && N;) {
    cin >> R;
    vector<int> vs(N);
    ordered_set ost;
    rep(i, N) vs[i] = i, ost.insert(i);

    rep(i, R) {
      int s, t; cin >> s >> t; s--, t--;
      swap(vs[s], vs[t]);
    }

    ll ans = 0;

    rep(i, N) {
      ans += (ll)ost.order_of_key(vs[i]) * fact[N - i - 1] % MOD;
      ost.erase(vs[i]);
      ans %= MOD;
    }

    cout << ans << endl;
  }

  return 0;
}

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

int main() {
    int l, r;
    cin >> l >> r;

    int ml = l % 2019;
    int mr = r % 2019;

    int ans;
    if (r - l >= 2018) {
        cout << 0 << endl;
        return 0;
    } 

    if (mr <= ml) ans = 0;
    else { // ml < mr 
        ans = 2018;
        for (int i = ml; i < mr; i++) {
            for (int j = i+1; j <= mr; j++) {
                ans = min(ans, (i * j) % 2019);
            }
        }
    } 

    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>

using namespace std;

const int SIZE = 100010;
const int INF = 1000000000;

struct SST{
  int segn2;
  vector<int> data, s_data;

  SST(int n){
    for(segn2=1;segn2<n;segn2*=2);
    data.assign(segn2*2, 0);
    s_data.assign(segn2*2, 0);
  }

  int q(int a, int b, int l=0, int r=-1, int k=0){
    if(r == -1) r += segn2;
    if(r<a || b<l) return INF;
    if(a<=l && r<=b) return data[k] + s_data[k];
    return min(q(a,b,l,(l+r)/2,k*2+1), q(a,b,(l+r)/2+1,r,k*2+2)) + s_data[k];
  }

  int add(int a, int b, int x, int l=0, int r=-1, int k=0){
    if(r==-1) r += segn2;
    if(a<=l && r<=b){
      s_data[k]+=x;
    }else if(a<=r && l<=b){
      data[k] = min(add(a,b,x,l,(l+r)/2,k*2+1), add(a,b,x,(l+r)/2+1,r,k*2+2));
    }
    return data[k] + s_data[k];
  }
};

int main(){
  int n,m,q;
  int d,a,b,e,s,t;
  pair<int,pair<int,int> > el[SIZE];
  pair<pair<int,int>,pair<int,int> > qu[SIZE];
  
  
  scanf("%d%d%d",&n,&m,&q);

  for(int i=0;i<m;i++){
    scanf("%d%d%d",&d,&a,&b);
    el[i] = {d,{a,b}};
  }

  for(int i=0;i<q;i++){
    scanf("%d%d%d",&e,&s,&t);
    qu[i] = {{e,i},{s,t}};
  }

  bool ans[SIZE];
  SST sst(n+1);
  
  sort(el, el+m);
  sort(qu, qu+q);

  t = 0;
  
  for(int i=0;i<q;i++){
    
    while(t < m && el[t].first < qu[i].first.first){
      sst.add(el[t].second.first, el[t].second.second-1, 1);
      t++;
    }

    bool f = false;
    int v = qu[i].first.second;
    int a = qu[i].second.first;
    int b = qu[i].second.second;

    if(a < b){
      int p = sst.q(a,b-1);
      f = p > 0;
    } else {
      f = true;
    }

    ans[v] = f;
  }

  for(int i=0;i<q;i++){
    puts(ans[i] ? "Yes" : "No");
  }

  return 0;
}
  



Measured memory_bytes: 7872
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int k, n;
        cin >> k >> n;
        int a[n];
        for(int i = 0; i < n; i++)
            cin >> a[i];

        int mx = k - (a[n - 1] - a[0]);
        for(int i = 0; i < n - 1; i++)
            mx = max(mx, a[i + 1] - a[i]);
        cout << k - mx << '\n';
    }
    
    return 0;
}



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

const int p=1e5+5;
const int M=2*p;

int A[M],B[M];

int main() {
	int n;
	cin>>n;
	for (int i=1;i<=n;++i) scanf("%d",&A[i]);
	int l,r;
	l=r=p;
	B[p]=A[1];
	l--,r++;
	for (int i=2;i<=n;++i) {
		if (i&1) B[l--]=A[i];
		else B[r++]=A[i];
	}
	if (n&1) {
		for (int i=l+1;i<r;++i) cout<<B[i]<<" ";
	}
	else {
		for (int i=r-1;i>l;--i) cout<<B[i]<<" ";
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

ll n, a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> a >> b;
	if (a > b) cout << 0 << endl;
	else if (a == b) cout << 1 << endl;
	else {
		if (n == 1) cout << 0 << endl;
		else if (n == 2) cout << 1 << endl;
		else cout << (b-a)*(n-2)+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
#import matplotlib.pyplot as plt

def kock(n,p1,p2):
    #global x
    #global y
    if n==0:
        return
    s=[0,0]
    t=[0,0]
    u=[0,0]
    
    s[0]=(float((2*p1[0]+p2[0])/3))
    s[1]=(float((2*p1[1]+p2[1])/3))
    t[0]=(float((p1[0]+2*p2[0])/3))
    t[1]=(float((p1[1]+2*p2[1])/3))

    u[0]=((t[0]-s[0])*math.cos(math.radians(60))-(t[1]-s[1])*math.sin(math.radians(60))+s[0])
    u[1]=((t[0]-s[0])*math.sin(math.radians(60))+(t[1]-s[1])*math.cos(math.radians(60))+s[1])
    


    kock(n-1,p1,s)
    print(*s)
   # x.append(s[0])
    #y.append(s[1])
    kock(n-1,s,u)
    print(*u)
    #x.append(u[0])
    #y.append(u[1])
    kock(n-1,u,t)
    print(*t)
    #x.append(t[0])
    #y.append(t[1])
    kock(n-1,t,p2)



n=int(input())
p1=[0.0,0.0]
p2=[100.0,0.0]
#x=[]
#y=[]
print(*p1)
#x.append(p1[0])
#y.append(p1[1])
kock(n,p1,p2)
print(*p2)



Measured memory_bytes: 5780
x,y,z,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
ab=[]
for i in range(x):
    for j in range(y):
        ab+=[a[i]+b[j]]
ab.sort(key=lambda x: -x)
c.sort(key=lambda x: -x)
ans=[]
ct=[0]
ansc=[ab[0]+c[0]]
while (len(ans)<k):
    if(ct[-1]!=0 and len(ct)<z):
        ansc+=[ab[0]+c[len(ct)]]
        ct+=[0]
    ans+=[max(ansc)]
    tmp=ansc.index(max(ansc))
    if(ct[tmp]==len(ab)-1):
        ansc[tmp]=0
    else:
        ct[tmp]+=1
        ansc[tmp]=ab[ct[tmp]]+c[tmp]
for i in ans:
    print(i)

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

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

    int t, x, y;
    int prev_t = 0, prev_x = 0, prev_y = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> t >> x >> y;
        int d = abs(x - prev_x) + abs(y - prev_y);
        bool flag = false;
        for (int j = 0; j <= t - prev_t; j += 2)
        {
            if (d + j == t - prev_t)
                flag = true;
        }

        if (flag == false)
        {
            cout << "No" << endl;
            return 0;
        }

        prev_t = t;
        prev_x = x;
        prev_y = y;
    }

    cout << "Yes" << endl;
}

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

s = [0] * (k + 1)
ans = 0

for i in range(k, 0, -1):
    s[i] += pow(int(k / i), n, int(1e9 + 7))
    s[i] %= 1e9 + 7
    for j in range(i * 2, k + 1, i):
        s[i] += 1e9 + 7
        s[i] -= s[j]
        s[i] %= 1e9 + 7

for i in range(1, k+1):
    ans += i * s[i]
    ans %= 1e9 + 7

ans %= 1e9+7

print(int(ans))

Measured memory_bytes: 12688
/**
 *      ABC 110 B
 *      author  : kyomukyomupurin
 *      created : 
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M, X, Y; cin >> N >> M >> X >> Y;
    int x[N] = {}; int y[M] = {};
    for (auto i = 0; i < N; ++i) {
        cin >> x[i];
    }
    for (auto i = 0; i < M; ++i) {
        cin >> y[i];
    }

    int xx = -101; int yy = 101;

    for (auto i = 0; i < N; ++i) {
        if (x[i] > xx){
            xx = x[i];
        }
    }

    for (auto i = 0; i < M; ++i) {
        if (y[i] < yy){
            yy = y[i];
        }
    }

    if (max(xx, X) < min(yy, Y)){
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>=22)cout <<"bust"<<endl;
    else{
        cout <<"win"<<endl;
    }
    
}
 


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

using namespace std;

const int INF = 1e9 + 5;
 
int main() {

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

    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++)cin>>h[i];

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

    cout<<dp[n-1]<<'\n';

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    int N, M;
    int[] a, b;
    void Solve() {
        //input
        N = io.Int;
        M = io.Int;
        a = new int[M];
        b = new int[M];
        for (int i = 0; i < M; ++i) {
            a[i] = io.Int;
            b[i] = io.Int;
        }
        //cal        
        var ziped = a.Zip(b, (v1, v2) => new { v1, v2 });
        var from1 = ziped.Where(v => v.v1 == 1).Select(v => v.v2);
        var toN = ziped.Where(v => v.v2 == N).Select(v => v.v1);
        var toHash = new HashSet<int>(toN);
        var ans = from1.Any(v => toHash.Contains(v));
        //ret
        WriteLine(ans ? "POSSIBLE" : "IMPOSSIBLE");
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 21168
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,C;
    cin >> A >> B >> C;
    ll sum = A+B+C;
    cout << max(A,max(B,C))*9 + sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 200000
int main()
{
	int n;
	scanf("%d",&n);
	int a[N];
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}
	int min=a[0],max=a[1]-a[0];
	for(int i=1;i<n;i++)
	{
		if(min>=a[i-1])
		{
			min=a[i-1];
		}
		if(max<=(a[i]-min))
		{
			max=a[i]-min;
		}
	}
	printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 3504
s = input() + "<"

a = 0
b = 0
ans = 0
pre = s[0]

for i in s:
    if i == ">":
        a += 1
        if pre == "<":
            ans += ((1 + b - 1) * (b - 1)) // 2
        pre = i
    if i == "<":
        if pre == ">":
            if b <= a:
                ans += ((1 + a) * a) // 2
            else:
                ans += ((1 + a - 1) * (a - 1)) // 2 + b
            a = 0
            b = 0
        b += 1
        pre = i
if i == "<":
    ans += ((1 + b - 1) * (b - 1)) // 2
print(ans)


Measured memory_bytes: 4116
n, y = gets.to_s.split.map{|t|t.to_i}

y /= 1000

0.upto(y/10) do |m|
  t = y - 10 * m
  break if y < 0
  0.upto(y/5) do |g|
    s = t - 5 * g
    break if s < 0
    if n == m + g + s
      puts "#{m} #{g} #{s}"
      exit
    end
  end
end

puts "-1 -1 -1"

Measured memory_bytes: 1788
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		final int n = sc.nextInt();
		final int m = sc.nextInt();
		final int x = sc.nextInt();

		List<Integer> mlist = new ArrayList<Integer>();
		for (int i = 0; i < m; i++) {
			mlist.add(sc.nextInt());
		}

		int rcost = 0;
		for (int j = x; j < n; j++) {
			if (mlist.contains(j)) {
				rcost++;
			}
		}

		int lcost = 0;
		for (int k = x; k > 0; k--) {
			if (mlist.contains(k)) {
				lcost++;
			}
		}

		if (rcost > lcost) {
			System.out.println(lcost);
		} else {
			System.out.println(rcost);
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <set>
#include <tuple>
#include <vector>
#include <algorithm>
using namespace std;

long long N, S[1 << 18], T[1 << 18], X[1 << 18];
long long Q, D[1 << 18], ans[1 << 18];
vector<tuple<long long, int, int>> vec;
set<int> Set;

int main() {
	cin >> N >> Q;
	for (int i = 1; i <= N; i++) {
		cin >> S[i] >> T[i] >> X[i];
		S[i] -= X[i];
		T[i] -= X[i];
		vec.push_back(make_tuple(S[i], 1, X[i]));
		vec.push_back(make_tuple(T[i], 0, X[i]));
	}
	for (int i = 1; i <= Q; i++) {
		cin >> D[i];
		vec.push_back(make_tuple(D[i], 2, i));
	}
	sort(vec.begin(), vec.end());

	for (int i = 0; i < vec.size(); i++) {
		if (get<1>(vec[i]) == 1) Set.insert(get<2>(vec[i]));
		if (get<1>(vec[i]) == 0) Set.erase(get<2>(vec[i]));
		if (get<1>(vec[i]) == 2) {
			if (Set.size() == 0) ans[get<2>(vec[i])] = -1;
			else {
				auto itr = Set.begin();
				ans[get<2>(vec[i])] = (*itr);
			}
		}
	}
	for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 30692
n,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]

xy.sort()
ans = 10**20

for i in range(n):
    for j in range(i,n):
        xy_tmp = xy[i:j+1]
        if len(xy_tmp) >= k:
            l1 = xy_tmp[0][0]
            r1 = xy_tmp[-1][0]
            xy_tmp.sort(key = lambda x: x[1])
            for jj in range(len(xy_tmp) - k + 1):
                ans = min(ans, (r1-l1) * (xy_tmp[k+jj-1][1] - xy_tmp[jj][1]))

print(ans)


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import bisect
INF = 2**31 - 1

n = int(input())
A = list(map(int, input().split()))
T = [[] for _ in range(n)]
for _ in range(n-1):
  u, v = map(int, input().split())
  u -= 1
  v -= 1
  T[u].append(v)
  T[v].append(u)
stack = []
L = [INF]*n
ans = [0]*n
def dfs(v, par=-1):
  a = A[v]
  idx = bisect.bisect_left(L, a)
  stack.append((idx, L[idx]))
  L[idx] = a
  ans[v] = bisect.bisect_left(L, INF)
  for nv in T[v]:
    if nv != par:
      dfs(nv, v)
  b, c = stack.pop()
  L[b] = c
dfs(0)
print(*ans, sep="\n")

Measured memory_bytes: 373320
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head=0, tail, n;
void enqueue (P);

int main(){
  int elaps = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  tail = n;

  while(tail!=head){
    if(Q[head].t > q){
      elaps += q;
      Q[head].t -= q;
      enqueue(Q[head]);

    }
    else{
      elaps+=Q[head].t; 
      printf("%s %d\n",Q[head].name,elaps);

    }
    head++;
    if(head == LEN){
      head = 0;
    }
  }  
  return 0;
}
void enqueue(P x){
  strcpy(Q[tail].name,x.name);
  Q[tail].t = x.t;
  tail++;
  if(tail == LEN){
    tail = 0; 
  }
}

Measured memory_bytes: 10768
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int N;
	cin >> N;
	vector<pair<long double, long double>> town(N);

	rep(i, N){
		long double x, y; 
		cin >> x >> y;
		town[i] = {x, y};
	}

	vector<int> P(N);
	iota(all(P), 0);

	long double ans = 0;
	do{
		for(int i = 0; i < N-1; i++){
			ans += sqrtl(powl(town[P[i]].first - town[P[i+1]].first, 2) + powl(town[P[i]].second - town[P[i+1]].second, 2));
		}
	}while(next_permutation(all(P)));

	long double factN = 1;
	for(int i = 1; i <= N; i++) factN *= i;
	
	cout << setprecision(15) << ans / factN << endl;
}


Measured memory_bytes: 256
//  author  :  brucewayne8
#include <bits/stdc++.h>
#define fast       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll         long long
//pair
#define pii        pair<int,int>
#define fi         first
#define sec        second
//end


//vector
#define vi          vector<int>
#define vl          vector<long>
#define vii         vector<pii>
#define vs          vector<string>
#define sz(x)       (int)x.size()
#define pb          push_back
//end


//matrice
#define vvi         vector<vector<int>>
#define vvii        vector<vector<pii>>
//end


//map
#define mi          map<int,int>
#define mii         map<pii,int>
//end


//loop
#define f(i,a,b)  for(int i=a;i<b;i++)
#define f0(i,a)  for(int i=0;i<a;i++)
#define rf(i,a,b)  for(int i=b;i>=a;i--)
#define rf0(i,a)  for(int i=a;i>=0;i--)
//end


//nec
#define int         ll
#define endl        '\n'
const int mod  = 1e9+7 ;
//end


using namespace std;

void solve(){
    string str;
    cin>>str;
    if(str[str.size()-1] == 's') str+="es";
    else str+='s';
    cout<<str<<endl;
}


int32_t main(){
fast;
int t=1;
// cin>>t;
f(i,0,t){
//cout<<"Case #"<<i+1<<": ";
solve();
}
return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int x;
    cin >> x;
    int position = 0;
    int ans = 0;
    bool flag = false;
    for(int i = 1; i < 1e9; i++){
        position += i;
        ans++;
        if(position == x) break;
        else if(position+i+1 > x){
            ans++;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    D, G = map(int, input().split())
    PC = [tuple(map(int, input().split())) for _ in range(D)]
    PC = [(p, c // 100) for p, c in PC]
    G //= 100
    m = 10 * 100
    for i in range(2 ** D):
        g = 0
        t = 0
        k = -1
        for j, (p, c) in enumerate(PC):
            if (1 << j) & i:
                g += (j + 1) * p + c
                t += p
            else:
                k = j
        if g >= G:
            m = min(m, t)
            continue
        p, c = PC[k]
        if (k + 1) * p + g < G:
            continue
        m = min(m, t + (G - g + k) // (k + 1))
    return m

print(main())


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

int main() {
    string str;
    cin >> str;
    int q;
    cin >> q;

    string command;
    int a, b;
    string p;
    for (int i = 0; i < q; i++) {
        // cout << "str:" << str << endl;
        cin >> command;
        if (command == "replace") {
            cin >> a >> b >> p;
        } else {
            cin >> a >> b;
        }


        if (command == "reverse") {
            string tmp = "";
            string reversed = "";
            for (int j = 0; j < str.size(); j++) {
                if (a <= j && j <= b) {
                    reversed = str.at(j) + reversed;
                    if (j == b) {
                        tmp += reversed;
                    }
                } else {
                    tmp += str.at(j);
                }
            }
            str = tmp;
        } else if (command == "replace") {
            string tmp = "";
            for (int j = 0; j < str.size(); j++) {
                if (j == a) {
                    tmp += p;
                    j += p.size()-1;
                } else {
                    tmp += str.at(j);
                }
            }
            str = tmp;
        } else if (command == "print") {
            for (int j = 0; j < str.size(); j++) {
                if (a <= j && j <= b) {
                    cout << str.at(j);
                }
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    string SS;
    SS = S.substr(0, 4); 
    string Shiduke = S.substr(5, 2);
    int moon = stoi(Shiduke);
    int Suji = stoi(SS);
    if (Suji <= 2018){
        cout << "Heisei" << endl;
    }else if (Suji >= 2020){
        cout << "TBD" << endl;
    }else{
        if (moon >= 5){
            cout << "TBD" << endl;
        }else{
            cout << "Heisei" << endl;
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> suuji(N);
   for (int i=0; i<N ;i++) {
     cin >> suuji.at(i) ;
   }
  sort(suuji.begin(),suuji.end());
  reverse(suuji.begin(),suuji.end());
  
  int x = 0;
  for (int j=0; j<N ; j++){
    if (j%2==0){
      x = x + suuji.at(j);
    }
    else {
      x = x - suuji.at(j);
    }
  }
  
  cout << x << endl;
      
}

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

void boost1() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main()
{
    boost1();
    string s,t;
    cin>>s;
    cin>>t;
    int i,j,n1=s.length(),n2=t.length();
    int dp[3001][3001];
    memset(dp,0,sizeof(dp));
    int mx=0;
    for(i=0;i<=n1;i++)
    {
        for(j=0;j<=n2;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                if(s[i-1]==t[j-1])
                    dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
            }
            mx=max(mx,dp[i][j]);
        }
    }  
    // cout<<mx<<endl;
    string lcs="";
    i = n1;
    j = n2; 
   while (i > 0 && j > 0) 
   { 
      if (s[i-1] == t[j-1]) 
      { 
        //   lcs[index-1] = X[i-1];
          lcs+=s[i-1];
          i--; j--;
        //   index--;
      } 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   }  
   reverse(lcs.begin(),lcs.end());
   cout<<lcs<<endl; 
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll a;
lli ans = 0;


int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  lli b = 0;
  for(lli l = 0,r = 0;r < n;r++){
    while((b&a[r]) != 0){
      b ^= a[l];
      l++;
    }
    b ^= a[r];
    // cout << r << " " << l << endl;
    ans += r-l+1;
  }
  cout << ans << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <functional>

using namespace std;
typedef long long ll;

const ll MOD = 998244353;
ll N, M, K;

ll power(ll a, ll b)
{
    ll ret = 1;
    while(b)
    {
        if(b&1)
        {
            ret = (ret * a) % MOD;
        }
        a = (a * a) % MOD;
        b /= 2;
    }
    return ret;
}

int main()
{
    cin >> N >> M >> K;
    ll C = 1;
    ll sum = 0;
    for(ll k = 0;k <= K;k++)
    {
        sum += C * M % MOD * power(M-1, N-1-k) % MOD;
        sum %= MOD;
        C = C * (N-1-k) % MOD * power(k+1, MOD-2) % MOD;
    }
    cout << sum << endl;
    return 0;
}

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

int N;
long long K;
vector<int> A, T;

int main()
{
  cin >> N >> K;
  A.resize(N + 1);
  for (int i = 1; i <= N; i++)
  {
    cin >> A.at(i);
  }
  T.resize(N + 1, -1);
  int timer = 0;
  int next = 1;
  int loop_size, q;
  while (1)
  {
    if (T.at(next) != -1)
    {
      loop_size = timer - T.at(next);
      q = T.at(next);
      break;
    }
    T.at(next) = timer;
    next = A.at(next);
    timer++;
  }
  int loop_times = 0;
  if (K < q)
  {
    loop_times = K;
  }
  else
  {
    loop_times = ((K - q) % loop_size) + q;
  }
  int ans = 1;
  for (int i = 0; i < loop_times; i++)
  {
    ans = A.at(ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#define FOR(n) for(int i=0;i<n;i++)
#define For(i,n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
int main()
{

int a,s;
  cin>>a>>s;
  char d[s];
  char f[a];
  FOR(a) d[i]=(char)s;
  FOR(s) f[i]=(char)a;
   if( lexicographical_compare(d, d+a, f, f+s)) 
    { 
        FOR(a) cout<<s; 
          
    } 
    else
    { 
      FOR(s) cout<<a;
          
    } 













return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  ll cnt = 0;
  for (auto i = 0; i < s.size() / 2; i++)
  {
    if (s[i] == s[s.size() - i - 1])
    {
      continue;
    }
    else
    {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
int main(){
  int N, W, H;
  cin >> N >> W >> H;
  vector< pair<int,int> > X, Y;
  int x, y, w;
  for(int i = 0; i < N; ++i){
    cin >> x >> y >> w;
    X.push_back(make_pair(max(0,x-w),min(W,x+w)));
    Y.push_back(make_pair(max(0,y-w),min(H,y+w)));
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  int l = X[0].first, r = X[0].second;
  for(int i = 1; i < N; ++i){
    int l_i = X[i].first, r_i = X[i].second;
    if(l_i <= r) r = max(r,r_i);
  }
  if(l == 0 && r == W){
    cout << "Yes" << endl;
    return 0;
  }
  l = Y[0].first, r = Y[0].second;
  for(int i = 1; i < N; ++i){
    int l_i = Y[i].first, r_i = Y[i].second;
    if(l_i <= r) r = max(r,r_i);
  }
  if(l == 0 && r == H){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

const int N = 2e5 + 10;

int n;
string s;
vector<int> adj[N];
int cnt[N][2], alive[N];

int main() {
    int m; cin >> n >> m;
    cin >> s;
    while (m--) {
        int u,v; cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        cnt[u][s[v]-'A']++;
        cnt[v][s[u]-'A']++;
    }
    fill_n(alive, n, 1);
    vector<int> bad;
    for (int u = 0; u < n; u++) if (!cnt[u][0] || !cnt[u][1])
        bad.push_back(u);

    while (!bad.empty()) {
        auto u = bad.back(); bad.pop_back();
        alive[u] = 0;
        for (auto v : adj[u]) if (alive[v]) {
            if (--cnt[v][s[u]-'A'] == 0) bad.push_back(v);
        }
    }
    bool ans = 0;
    for (int u = 0; u < n; u++) ans |= alive[u];
    cout << (ans ? "Yes" : "No");

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int N; cin >>N;
    vector<int> p(N); cin >> p;

    int c = 0;
    for (int i = 0; i < N; i++) {
        if (p[i] != i + 1) {
            c++;
            if (c > 2)
                break;
        }
    }
    
    YES(c<=2);
}


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

ll calc_xor(ll n)
{
    if ((n + 1) % 4 == 0)
        return 0LL;
    else
    {
        ll res = n;
        rep(i, 0, (n + 1) % 4 - 1)
            res ^= (n - i - 1);
        return res;
    }
}

int main()
{
    ll a, b;
    cin >> a >> b;

    ll ans = calc_xor(b);
    // cout << ans << endl;
    if (a > 0)
        ans ^= calc_xor(a - 1);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const S = arg.slice(1, N + 1);
    
    let list = [];
    
    for(let i=0; i<N; i++) {
        list.push(S[i]);
    }
    
    const sets = new Set(list);
    
    console.log(sets.size);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 62248
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define ld long double
#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()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  vector<ll> A(n);
  fenwick_tree<ll> bit(n);
  rep(i, n) {
    cin >> A[i];
    bit.add(i, A[i]);
  }
  rep(_, q) {
    int t; cin >> t;
    if(t == 0) {
      int p; ll x; cin >> p >> x;
      bit.add(p, x);
    } else {
      int l, r; cin >> l >> r;
      cout << bit.sum(l, r) << endk;
    }
  }
  return 0;
}


Measured memory_bytes: 12168
#include<iostream>
#include<algorithm>
using namespace std;
long N,A,B;
main()
{
	cin>>N>>A>>B;
	if(A%2==B%2)
	{
		long d=abs(A-B);
		cout<<d/2<<endl;
	}
	else
	{
		cout<<min(A,N-B+1)+(B-A-1)/2<<endl;
	}
}


Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    String[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int D = int.Parse(input[1]);
    int w = 2 * D + 1;
    if (N % w == 0)
    {
      Console.WriteLine(N / w);
    } else
    {
      Console.WriteLine(N / w + 1);
    }
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int gcd(int a,int b){if (b == 0) return a; return gcd(b , a%b);}
int lcm(int a, int b){ return a/gcd(a,b)*b;}
inline int read(){
    int f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}

int main(){
    int a,b;
    cin >> a >> b;
    for (int i=1; i<=3; i++) {
        if (i * a * b & 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if (a + b <= k) {
    cout << "0 0" << endl;
  } else if (a <= k) {
    cout << "0 " << a + b - k << endl;
  } else {
    cout << a - k << " " << b << endl;
  }
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 100010;
int dp[maxn][101][2];
string s;
int d,n;
const int mod = 1e9 + 7;

void add(int &a, int b){
	a += b;
	if(a < 0){a += mod;}
	if(a >= mod){
		a -= mod;
	}
}

int solve(int idx, int sisa, int isLebihKecil) {
	int i,j,k;
	if(idx == n){
		if(sisa == 0){return 1;}
		else{return 0;}
	}
	if(dp[idx][sisa][isLebihKecil]!=-1){return dp[idx][sisa][isLebihKecil];}
	int batas = (isLebihKecil ? 9: s[idx] - '0');
	int ans = 0;
	for(i=0;i<=batas;i++){
		if(i < batas){
			add(ans, solve(idx+1, (sisa + i) % d, 1));
		}else{
			add(ans, solve(idx+1, (sisa + i) % d, isLebihKecil));
		}
	}
	return dp[idx][sisa][isLebihKecil] = ans;
}

int main(){
	
	int i,j,k;
	cin>>s>>d;
	n = s.length();

	//bottom up

	// dp[0][0][0] = 1;
	// for(i=0;i<n;i++) {
	// 	for(j=0;j<d;j++){
	// 		for(k=0;k<2;k++){
	// 			int batas;
	// 			if(k == 0){
	// 				batas = s[i] - '0';
	// 			}else{
	// 				batas = 9;
	// 			}
	// 			// printf("k: %d batas: %d\n",k,batas);
	// 			for(int l=0;l<=batas;l++){
	// 				if(l < batas){
	// 					add(dp[i+1][(j + l) % d][1], dp[i][j][k]);
	// 					// printf("dp[%d][%d][%d] jd: %d\n",i+1,(j+l)%d, 1, dp[i+1][(j+l)%d][1]);
	// 				}
	// 				else{
	// 					add(dp[i+1][(j + l) % d][k], dp[i][j][k]);
	// 					// printf("dp[%d][%d][%d] jd: %d\n",i+1,(j+l)%d, k, dp[i+1][(j+l)%d][k]);
	// 				}
					
	// 			}
	// 		}
	// 	}
	// }
	// int ans = 0;
	// add(ans, dp[n][0][0]);
	// add(ans, dp[n][0][1]);
	// add(ans, -1);

	memset(dp, -1, sizeof dp);
	int ans = solve(0,0,0);
	add(ans, -1);
	printf("%d\n",ans);
	return 0;
};

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

using namespace std;

long long n, a[5], minn, necknum, ans;

int main(void) {

	cin >> n;

	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
		if (i == 0)minn = a[i];
		else minn = min(minn, a[i]);
	}

	necknum = (n + minn - 1) / minn;

	ans = 5 + (necknum - 1);

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,y=100000000000,m,w;
    	string s,t;
    	cin>>s>>t;
    	n=s.size();
    	k=t.size();
		ll dp[n+1][k+1];
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=k;j++)
			{
				if(i==0||j==0)
				dp[i][j]=0;
				else if (s[i-1]==t[j-1])
					dp[i][j]=1+dp[i-1][j-1];
				else
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
			string ans="";
			while(n>0&&k>0)
			{
				if(s[n-1]==t[k-1])
				{
					ans.pb(s[n-1]);
					n--;
					k--;
				}
			    else if(dp[n][k]==dp[n-1][k])
			    n--;
			    else
			    k--;
			}
			reverse(ans.begin(),ans.end());
		cout<<ans;
	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int a, n;
  cin>>n>>a;
  if(n%500<=a)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256