akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	string a;
	long long k;
	cin>>a>>k;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='1')
		{
			if(k==1)
			{
				cout<<1;
				return 0;
			}
			else
			{
				k--;
			}
		}
		else
		{
			cout<<a[i];
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool mmp(int a,int b)
{
return a>b;
}
int main()
{
   int n,k,ass=0;
   int a[51];
   cin>>n>>k;
   for(int i=1;i<=n;i++)
    {
    cin>>a[i];
    }
    sort(a+1,a+n+1,mmp);
    for(int i=1;i<=k;i++)   
    {
        ass+=a[i];
    }
    cout<<ass<<endl;//endl换行
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define ull unsigned long long
#define ld long double
#define uint unsigned int
struct debug {
~debug() {cerr << "\n";}template<class C> debug& operator<<(C c) {cerr << c;return *this;}
};
#define var(x) " [" << #x << ": " << x << "]"

int n;

void solve() {
    cin >> n;
    int a=n^1;
    cout << a << "\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define inf 10000000000ll
#define N 100009
using namespace std;

int n,m,cnt,pt,prm[N],b[N]; ll a[N],p[N],q[N]; bool vis[N];
map<ll,int> mp;
int main(){
	scanf("%d",&n); m=2200;
	int i,j,k; ll x,y,z;
	for (i=2; i<=m; i++) if (!vis[i]){
		prm[++cnt]=i;
		for (j=i; j<=m; j+=i) vis[j]=1;
	}
	for (i=1; i<=n; i++){
		scanf("%lld",&x); y=1;
		for (j=1,pt=0; j<=cnt; j++) if (!(x%prm[j])){
			a[++pt]=prm[j]; b[pt]=0;
			for (; !(x%prm[j]); x/=prm[j]) b[pt]++; 
			b[pt]%=3;
			if (!b[pt]){ pt--; continue; }
			for (k=1; k<=b[pt]; k++) y*=prm[j];
		}
		if (x>1){
			j=sqrt((double)x); y*=x;
			if ((ll)j*j==x){
				a[++pt]=j; b[pt]=2;
			} else{
				a[++pt]=x; b[pt]=1;
			}
		}
		mp[p[i]=y]++;
		for (j=1,z=1; j<=pt && z<=inf; j++)
			for (k=0; k<3-b[j] && z<=inf; k++) z*=a[j];
		if (z>inf) z=-1; q[i]=z;
	}
	int ans=0;
	for (i=1; i<=n; i++){
		if (p[i]==1){
			if (mp[1]) ans++; mp[1]=0; continue;
		}
		ans+=max(mp[p[i]],mp[q[i]]);
		mp[p[i]]=mp[q[i]]=0;
	}
	printf("%d\n",ans);
	return 0;
}


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

signed main() {
  int n,a,b;
  cin >> n >> a >> b;

  int c = a - b;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  int ng = 0, ok = 1e9;
  while(ok - ng > 1) {
    int mid = (ok + ng) / 2;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int val = h[i] - b*mid;
      if(val > 0) {
        cnt += (val + c - 1) / c;
      }
    }
    if(cnt <= mid) ok = mid;
    else ng = mid;
  }
  cout << ok << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
typedef long long ll;
int main()
{
	ll n,l;
	scanf("%lld %lld",&n,&l);
	l--;
	ll ans = l*n + (n*(n+1))/2;
	ll min= l+1;
	ll temp;
	for(ll i=1;i<n+1;i++)
	{
		temp = l+i;
		if(abs(temp) < abs(min))
		{
			min = temp;
		}
	}
	ans -= min;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int check(int mid, int k, int n, int w[]){
        int i=0, j;
        for(j=0; j<k; j++){
                int s=0;
                while(s+w[i]<=mid){
                        s+=w[i];
                        i++;
                        if(i==n){
                            
                                return n;
                        }
                }
        }
        
        return i;
}

int main(){
        int i, n, k, right=0, left=0;
        scanf("%d %d", &n, &k);
        int w[n];
        for(i=0; i<n; i++){
                scanf("%d", &w[i]);
                right+=w[i];
                if(left<w[i])
                        left=w[i];
        }

        int mid;

        while(left<right){
                mid=(right+left)/2;
                int key=check(mid, k, n, w);
                if(key>=n){
                        right=mid;
                }else{
                        left=mid+1;
                }
        }
        printf("%d\n", right);

        return 0;
}



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

#define rep(i, n)  for (int i = 0; i < (n) ; ++i)
#define mod 1000000007

using namespace std;
using ll=long long;
const ll INF = 100000000;

int main() {
    int n, k;
    vector<int> p;
    cin >> n >> k;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    sort(p.begin(), p.end());

    ll res = 0;
    for (int j = 0; j < k; ++j) {
        res += p[j];
    }
    cout << res;
    return 0;
}

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


int main() {
  string S;cin >> S;
  sort(S.begin(),S.end());
  int len = S.size();

  bool flag = true;
  char old = ' ';
  for (int i = 0;i < len;i++){
    if (i == 0){
      old = S.at(i);
    }else{
      if (old == S.at(i)){
        flag = false;
        break;
      }else{
        old = S.at(i);
      }
    }
  }
  if (flag){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }

}       

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int ans = 0;
	string s;
	cin >> s;
	for (int i = 0; i < 4;i++) {
		if (s[i]=='+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//file_name:ABC111_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);

    int nn = (n-1)/111;
    int ans = 0;

    ans = (nn+1)*111;

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    A = []
    B = []
    for _ in range(N):
        a, b = (int(i) for i in input().split())
        A.append(a)
        B.append(b)
    A.sort()
    B.sort()
    ans = -1
    if N % 2 == 1:
        ans = B[N//2] - A[N//2] + 1
    else:
        a = (A[N//2] + A[N//2 - 1])/2
        b = (B[N//2] + B[N//2 - 1])/2
        ans = b - a + 1
        ans += ans - 1
    print(int(ans))


if __name__ == '__main__':
    main()


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

#define endl '\n'

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

    int n, m, k;
    cin >> n >> m >> k;

    int a = 0, b = 0;
    if(k == 0 || k == n * m) {
        cout << "Yes";
        return 0;
    }
    for(int i = 1; i <= n; i++) {
        a += m;
        if(k == a) {
            cout << "Yes";
            return 0;
        }
        b = a;
        for(int j = 1; j <= m; j++) {
            b += n - (i * 2);
            if(k == b) {
                cout << "Yes";
                return 0;
            } 
        }
    }

    swap(n, m);
    a = 0; b = 0;
    for(int i = 1; i <= n; i++) {
        a += m;
        if(k == a) {
            cout << "Yes";
            return 0;
        }
        b = a;
        for(int j = 1; j <= m; j++) {
            b += n - (i * 2);
            if(k == b) {
                cout << "Yes";
                return 0;
            } 
        }
    }

    cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;
typedef pair<int,int> P;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  vector<int> B(M), C(M);
  vector<P> D;
  rep(i, 0, N) cin >> A[i];
  rep(i, 0, M) {
    cin >> B[i] >> C[i];
    D.push_back({C[i], B[i]});
  }
  sort(A.begin(), A.end());
  priority_queue<int,vector<int>,greater<int>> Q;
  rep(i, 0, N) Q.push(A[i]);
  sort(D.begin(),D.end(),greater<P>());
  ll ans = 0;
  rep(i, 0, M) {
    int n = D[i].second;
    while(!Q.empty() && n && D[i].first > Q.top()) {
      Q.pop();
      n--;
      ans += D[i].first;
    }
  }
  while(!Q.empty()) {
    ans += Q.top();
    Q.pop();
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> n >> A;
	ans = n * n - A;
	cout << ans;
}

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

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

  int aa = a, bb = b;
  for (int i = 1; i < b; i++) {
    aa += (a * pow(10, i));
  }
  for (int i = 1; i < a; i++) {
    bb += (b * pow(10, i));
  }

  string as, bs;
  as = to_string(aa);
  bs = to_string(bb);

  cout << min(as, bs) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,Y; cin>>N>>Y;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(N-i-j<0)break;
      if(i*10000+j*5000+(N-i-j)*1000==Y){
        cout<<i<<" "<<j<<" "<<N-i-j<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 3556
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int A; cin >> A;
    string S; cin >> S;

    string ans = A >= 3200 ? S : "red";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            try
            {

                long N = long.Parse(Console.ReadLine());

                string[] s = Console.ReadLine().Split(' ');
                long[] l = new long[N];

                for (long i = 0; i < N; i++)
                {
                    l[i] = long.Parse(s[i]);
                }

                long answer = 1;

                Array.Sort(l);

                for (int i = 0; i < N; i++)
                {
                    checked
                    {
                        answer *= l[i];
                    }
                   
                    if (answer > 1000000000000000000)
                    {
                        Console.WriteLine("-1");
                        return;
                    }
                }

                Console.WriteLine(answer);
            }
            catch (Exception e)
            {
                Console.WriteLine("-1");
            }
        }
    }
}

Measured memory_bytes: 41724
#include <stdio.h>
int main()
{
  int n ;
  int card[4][13]  ;
  char l, m ;
  int rank ;
  int i, j ;

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      card[i][j] = 0 ;
    }
  }

  scanf("%d",&n) ;

  for( i=0 ; i<n ; i++ ){
    scanf("%c",&l) ; /*改行の\nを読み込んだ*/
    scanf("%c %d",&m,&rank) ;
    if( m == 'S'){
      card[0][rank-1] = rank ;
    }else if( m == 'H'){
      card[1][rank-1] = rank ;
    }else if( m == 'C'){
      card[2][rank-1] = rank ;
    }else if( m == 'D'){
      card[3][rank-1] = rank ;
    }
  }

  for( i=0 ; i<13 ; i++){
      if(card[0][i] == 0){
        printf("S %d\n",i+1);
      }
  }
  for( i=0 ; i<13 ; i++){
      if(card[1][i] == 0){
        printf("H %d\n",i+1);
      }
  }
  for( i=0 ; i<13 ; i++){
      if(card[2][i] == 0){
        printf("C %d\n",i+1);
      }
  }
  for( i=0 ; i<13 ; i++){
      if(card[3][i] == 0){
        printf("D %d\n",i+1);
      }
  }

  return 0;
}


Measured memory_bytes: 2020
import string
alp=string.ascii_lowercase
s=input()
k=int(input())
ans=''
i=0
while i<len(s)-1:
    t=s[i]
    d=(26-alp.index(t))%26
    if d<=k:
        k-=d
        ans+='a'
    else:
        ans+=t
    i+=1
if k>0:
    ans+=alp[(alp.index(s[-1])+k%26)%26]
else:
    ans+=s[-1]
print(ans)


Measured memory_bytes: 4092
class RSQ(object):
    INIT = 0

    def __init__(self, num) -> None:
        n = 1
        while n <= num:
            n = n * 2
        self.n = n
        self.val = [self.INIT] * (2 * n - 1)

    @staticmethod
    def merge(a: int, b: int) -> int:
        return a + b

    def update(self, k: int, x: int) -> None:
        k = k + self.n - 1
        self.val[k] += x
        while k:
            k = (k - 1) // 2
            self.val[k] = self.merge(self.val[k * 2 + 1], self.val[k * 2 + 2])

    def dfs(self, beg: int, end: int, k: int, l: int, r: int) -> int:
        if (end <= l or r <= beg):
            return self.INIT
        if (beg <= l and r <= end):
            return self.val[k]
        vl = self.dfs(beg, end, k * 2 + 1, l, (l + r) // 2)
        vr = self.dfs(beg, end, k * 2 + 2, (l + r) // 2, r)
        return self.merge(vl, vr)

    def query(self, beg: int, end: int) -> int:
        return self.dfs(beg, end, 0, 0, self.n)


if __name__ == "__main__":
    n, q = map(lambda x: int(x), input().split())
    rmq = RSQ(n)

    for _ in range(q):
        com, x, y = map(lambda x: int(x), input().split())
        if (0 == com):
            rmq.update(x, y)
        else:
            print(rmq.query(x, y + 1))



Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    bool win = false;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(a%2 ==1) win = true;
    }
    if(win) cout<<"first"<<endl;
    else cout<<"second"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> l(N);
    for(int i = 0; i < N; i++) cin >> l[i];
    sort(l.begin(),l.end());
    int L = 0;
    for(int i = 0; i < N - 1; i++) L += l[i];
    if(l[N-1] < L) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sn = 0;
        int nclone = n;
        while(nclone!=0){
            sn += nclone%10;
            nclone /= 10;
        }
        if(sn==0) {
            System.out.println("No");
        }else if(n%sn==0){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<P> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  multiset<int> ms;
  ms.insert(-1);
  ms.insert(-1);
  ms.insert(n);
  ms.insert(n);
  ll su = 0;
  for(int i=0;i<n;++i) {
    ll val = p[i].first;
    int pos = p[i].second;
    auto it = ms.lower_bound(pos);
    ll l1, l2, r1, r2;
    r1 = *it++;
    r2 = *it--;
    it--;
    l1 = *it--;
    l2 = *it;
    su += (l1 - l2) * (r1 - pos) * val;
    su += (r2 - r1) * (pos - l1) * val;
    ms.insert(pos);
  }
  cout << su << endl;
}


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

int main() {
    int a[5];
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    int k;
    cin >> k;

    bool can = true;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            if (abs(a[i] - a[j]) > k) {
                can = false;
                break;
            }
        }
    }

    if (can) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

const int mod = 1e9 + 7;
const int N = 400012;
const int inf = 2e9;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k;
    ll ans = 0;
    cin >> n >> k;
    for(int i = 0; i < k; ++i) {
        int cnt = 0;
        for(int j = (i == 0 ? i + k : i); j <= n; j += k) {
            ++cnt;
        }
        if(i * 2 % k == 0) ans += cnt *1ll* cnt *1ll* cnt;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
minimum = 1000001
maximum = -1000001
sum = 0
for i in range(n):
    if(a[i] < minimum):
        minimum = a[i]
    if(maximum < a[i]):
        maximum = a[i]
    sum += a[i]
print("%d %d %d" % (minimum, maximum, sum))

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

int main(void) {
  int n,d;
  cin >> n >> d;
  for(int i=1; i<=n; i++) {
    if(n <=i*(2*d+1)){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

void solve()
{
  ll N;
  std::cin >> N;
  std::vector< ll > A(N, 0LL);
  for (ll i = 0; i < N; i++) std::cin >> A[i];

  // i - j = A[i] + A[j] なので、
  // i - A[i] = j + A[j] となる
  // まずは、i-A[i] となる値の個数を map を用いて列挙する
  std::map<ll, ll> mcnt;
  for (ll i = 0; i < N; i++) {
    mcnt[i - A[i]]++;
  }

  // i - A[i] == i + A[i] となる場合
  // 0 == 2 * A[i] なので、
  // 制約条件である A[i] >= 1 に該当しなくなる。
  // そのため i - A[i] == i + A[i] にはならない。
  // よって、ある i で i + A[i] を求め、j - A[j] となる個数がいくつあるか調べる。
  ll ans = 0LL;
  for (ll i = 0; i < N; i++) {
    ans += mcnt[i + A[i]];
  }

  print(ans);
}

int main()
{
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);

  solve();

  return 0;
}


Measured memory_bytes: 27376
import java.util.*;
import java.io.*;

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 < n; i++) {
            a[i] = sc.nextInt();
        }
        int max = -1;
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                int tmp = a[i] * a[j];
                if(tmp <= max) continue;
                String s = String.valueOf(tmp);
                boolean ok = true;
                for(int k = 0; k < s.length()-1; k++) {
                    if(s.charAt(k)+1 != s.charAt(k+1)) {
                        ok = false;
                        break;
                    }
                }
                if(ok) {
                    max = tmp;
                }
            }
        }
        System.out.println(max);
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

int main(){
	ll N; cin>>N;
    vector<ll> L(N);
    rep(i,N) cin>>L[i];
  sort(L.begin(),L.end());
  ll tmp=0;
  rep(i,N-1) tmp+=L[i];
  if(L[N-1]<tmp) cout<<"Yes";
  else cout<<"No";
}

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

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

  int c0 = 0;
  int c1 = 0;
  int c2 = 0;
  int c3 = 0;

  string s;
  for (int i=0;i<n;++i) {
    cin >> s;

    if (s == "AC") c0++;
    else if (s == "WA") c1++;
    else if (s == "TLE") c2++;
    else if (s == "RE") c3++;
  }

  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;

  return 0;
}


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

ll n,k,cnt,ans;

int main(){
    cin>>n>>k;
    for(ll i=k; i; i>>=1) ++cnt;
    for(ll j=cnt,i=1; i<=n; ++i){
        while(j>=1 && (i<<j)>=(k<<1)) --j;
        //cout<<i<<' '<<cnt<<' '<<j<<endl;
        ans+=1<<(cnt-j);
    }
    cout.precision(30);
    cout<<(long double)ans/(n<<cnt);
    return 0;
}


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

struct TreeNode;
typedef struct TreeNode * Tree;
typedef struct TreeNode * Position;
typedef int ElementType;

struct TreeNode
{
    ElementType ele;
    Tree left;
    Tree right;
};

void priTreeNode(Tree);
Tree insert(Tree, ElementType);
Tree find(Tree, ElementType);
void inorder(Tree, void (*)(Tree));
void preorder(Tree, void (*)(Tree));

int main(void)
{
    int m, k;
    char op[7];

    Tree T;

    scanf("%d", &m);
    while (m--) {
        scanf("%s", op);
        if (op[0] == 'i') {
            scanf("%d", &k);
            T = insert(T, k);
        } else if (op[0] == 'f') {
            scanf("%d", &k);
            puts(find(T, k) ? "yes" : "no");
        } else if (op[0] == 'p') {
            inorder(T, priTreeNode);
            putchar('\n');
            preorder(T, priTreeNode);
            putchar('\n');
        }
    }

    return 0;
}

void priTreeNode(Tree T)
{
    printf(" %d", T->ele);
}

Tree insert(Tree T, ElementType x)
{
    if (T == NULL) {
        T = (Tree) malloc(sizeof(struct TreeNode));
        T->ele = x;
        T->left = T->right = NULL;
    } else if (T->ele < x) {
        T->right = insert(T->right, x);
    } else if (T->ele > x) {
        T->left = insert(T->left, x);
    }
    return T;
}

Tree find(Tree T, ElementType x)
{
    if (T == NULL)
        return NULL;
    else if (T->ele < x)
        return find(T->right, x);
    else if (T->ele > x)
        return find(T->left, x);
    else
        return T;
}

void inorder(Tree T, void (* print)(Tree))
{
    if (T == NULL)
        return;
    inorder(T->left, print);
    print(T);
    inorder(T->right, print);
}

void preorder(Tree T, void (* print)(Tree))
{
    if (T == NULL)
        return;
    print(T);
    preorder(T->left, print);
    preorder(T->right, print);
}


Measured memory_bytes: 14192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
#include <list>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

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

typedef ll SegT;
static const SegT defvalue = 0;
class SegTree{
private:
    vector<SegT> val;
    int n;
public:
    SegTree(int size){
        n=1;
        while(n<size)n<<=1;
        val=vector<SegT>(2*n, defvalue);
    }
    void update(int a,int b,SegT x,int k=0,int l=0,int r=-1){
        if(r==-1)r=n;
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b){
            val[k] += x;
        }
        else{
            update(a,b,x,k*2+1,l,(l+r)/2);
            update(a,b,x,k*2+2,(l+r)/2,r);
        }
        return;
    }
    SegT query(int i){
        i+=n-1;
        SegT ret = val[i];
        while(i>0){
            i=(i-1)/2;
            ret += val[i];
        }
        return ret;
    }
};

int main(void) {
  int n, m;
  cin >> n >> m;
  vi a(n);

  SegTree t1(2*m+100), t2(2*m+100);

  REP(i, n) cin >> a[i];
  ll s = 0;
  REP(i, n - 1) {
    s += (m + a[i+1] - a[i]) % m;
  }
  REP(i, n - 1) {
    ll left = a[i], right = a[i+1];
    if(right >= left) {
      t1.update(left+1, right+1, left+1);
      t2.update(left+1, right+1, 1);
    } else {
      t1.update(left+1, right+m+1, left+1);
      t2.update(left+1, right+m+1, 1);
    }
  }

  ll ans = 0;
  for(int i = 1; i <= m; i++){
    ll res = 0;
    res += (i * t2.query(i) - t1.query(i));
    res += ((i+m) * t2.query(i+m) - t1.query(i+m));
    //cout << "[i, res] = " << i << " " << res << endl;
    ans = max(ans, res);
  }
  cout << (s - ans) << endl;
}


Measured memory_bytes: 8832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string str = Console.ReadLine();
                if (str == null)
                {
                    break;
                }
                float[] array = str.Split(' ').Select(float.Parse).ToArray();
                float[] array2 = new float[6];
                for (int i = 0; i < 3; i++)
                {
                    array2[i] = array[i] * array[3];
                }
                for(int i = 3; i < 6; i++)
                {
                    array2[i] = array[i] * array[0];
                }
                float y = (array2[2] - array2[5]) / (array2[1] - array2[4]);
                float x = (array[2] - array[1] * y)/array[0];

                Console.WriteLine("{0} {1}",x.ToString("0.000"),y.ToString("0.000"));

            }
        }

       
    }
}

Measured memory_bytes: 9740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

bool sign(int x, int y) {
    if (x == 0) return true;
    if (y == 0) return true;
    if (x < 0 && y < 0) return true;
    if (x > 0 && y > 0) return true;
    return false;
}

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int cx = 0, cy = 0;
    ll ans = 0;
    for (int i = 0, x, y; i < n; i++) {
        cin >> x >> y;
        if (i == 0) cx = x, cy = y;
        int dx = x - cx, dy = y - cy;
        if (dx == dy) {
            ans += abs(dx);
        } else if (sign(dx, dy)) {
            if (dx < 0 || dy < 0) {
                if (dx > dy) {
                    ans += abs(dx);
                    dy -= dx;
                    ans += abs(dy);
                } else {
                    ans += abs(dy);
                    dx -= dy;
                    ans += abs(dx);
                }
            } else {
                if (dx > dy) {
                    ans += dy;
                    dx -= dy;
                    ans += dx;
                } else {
                    ans += dx;
                    dy -= dx;
                    ans += dy;
                }
            }
        } else {
            ans += abs(dx) + abs(dy);
        }
        cx = x, cy = y;
    }
    cout << ans << endl;
}


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

int n;
string s;

int main(){
	cin>>n;
	cin>>s;
	if(n % 2 == 1){
		cout<<"No"<<endl;
	}
	else if(s.substr(0,n/2) == s.substr(n/2,n/2)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
from collections import deque

s = input()
q = int(input())

roll = False
ans = deque([s])
preNum = 0

for i in range(q) :
    inp = input()
    if inp[:1] == '1' :
        roll = not roll
        #print(roll)
    else :
        t, f, c = inp.split()
        #print(ans)
        #print(t, f, c)
        if (f == '1' and (not roll)) or (f == '2' and roll) :
            ans.appendleft(c)
            preNum += 1
        else :
            ans.append(c)
#print(ans)
ans = list(ans)
if roll :
    ans[preNum] = ans[preNum][::-1]
    ans = ans[::-1]

#print(ans)
#print("".join(ans))
for s in ans :
    print(s, end='')


Measured memory_bytes: 7024
#!/usr/bin/env python3

N = int(input())
L = input().split()
L_num = []

for i in range(len(L)):
    L_num.append(int(L[i]))

L_num.sort()

total = 0
for j in range(len(L) - 1):
    total += L_num[j]

if total <= L_num[N-1]:
    print("No")
else:
    print("Yes")




Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <ctime>
#include <math.h> 
using namespace std;

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

	if (price % 1000 != 0) {
		cout << ((ceil(price / 1000.00) * 1000) - price);

	}
	else {
		cout << 0;

	}


}

Measured memory_bytes: 3780
W, H, x, y, r = map(int, input().split())
#条件1：x-r,y-r>=0
#条件2：x+r<=W,y+r<=H
if x - r < 0 or y - r < 0 or x + r > W or y + r > H:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 5596
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n, m;
vector<int> v[MAXN];
int ans;

int main() { 

  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int from, to;
    scanf("%d %d", &from, &to);
    from--; to--;
    v[from].push_back(to);
  }

  int curCut = 1e9;
  for (int i = 0; i + 1 < n; i++) {
    for (auto x : v[i]) {
      curCut = min(curCut, x);
    }
    if (i + 1 == curCut) {
      ans++;
      curCut = 1e9;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5888
#include<iostream>

using namespace std;

int main(){

  int a,b,c;
  cin>>a>>b>>c;
  int t;

 if(a>b){
      t=a;
      a=b;
      b=t;
    }

   if(b>c){
      t=b;
      b=c;
      c=t;
    }
   if(a>b){
     t=a;
     a=b;
     b=t;
   }

   cout << a << " " << b << " " << c << endl;

      

  return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)


//(a + b ) % m = (a % m + b % m ) %m

//(a - b ) % m = ( (a % m - b % m ) + m ) %m

//(a * b ) % m = (a % m * b % m ) %m

//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)


ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}




void solve(){
	ll n,i,j;
	cin>>n;
	string s=to_string(n);
	while(n>0){
		ll tmp=n%10;
		if(tmp==7){
			cout<<"Yes\n";
			return;
		}
		n=n/10;
	}
	cout<<"No\n";

}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 3680
#include <iostream>
using namespace std;
int main(){
  string str;
  cin >> str;
  bool flag=false;
  if((str[0]==str[1])&&(str[2]==str[3])&&(str[0]!=str[2]))flag=true;
  if((str[0]==str[2])&&(str[3]==str[1])&&(str[0]!=str[3]))flag=true;
  if((str[0]==str[3])&&(str[1]==str[2])&&(str[0]!=str[1]))flag=true;
  if(flag)cout << "Yes" << endl; 
  else cout << "No" <<endl;
  return 0;
}

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

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.rbegin(), a.rend());

    int cost = 0;
    for(int i = 1; i < 3; i++){
        cost += abs(a[i]-a[i-1]);
    }
    cout << cost << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(3*10**5)

N, M = map(int,input().split())
adj = [[] for i in range(N+1)]
for i in range(M):
	u, v, w = map(int,input().split())
	adj[u].append(v)
	adj[v].append(u)

vis = [False for i in range(N+1)]
def bfs(s):
	frontier = [s]
	ptr = 0
	while ptr < len(frontier):
		u = frontier[ptr]
		if not vis[u]:
			vis[u] = True
			for v in adj[u]:
				if not vis[v]:
					frontier.append(v)
		ptr += 1
ans = 0
for u in range(1,N+1):
	if not vis[u]:
		ans += 1
		bfs(u)

print(ans)


Measured memory_bytes: 103516
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 50
string g[N];
int di[] = {0, 0, -1, 1};
int dj[] = {-1, 1, 0, 0};
int d[N][N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w;
    cin >> h >> w;
    int white = 0;
    for(int i = 0; i < h; i++) {
        cin >> g[i];
        for(int j = 0; j < w; j++) {
            if(g[i][j] == '.') {
                white++;
            }
        }
    }
    memset(d, -1, sizeof d);
    d[0][0] = 0;
    queue<pair<int, int>> q;
    q.push({0, 0});
    while(not q.empty()) {
        int i = q.front().first;
        int j = q.front().second;
        q.pop();
        for(int x = 0; x < 4; x++) {
            int ni = i + di[x];
            int nj = j + dj[x];
            if(0 <= ni and ni < h and 0 <= nj and nj < w and d[ni][nj] == -1 and g[i][j] == '.') {
                d[ni][nj] = d[i][j] + 1;
                q.push({ni, nj});
            }
        }
    }
    cout << (d[h - 1][w - 1] == -1 ? -1 : white - d[h - 1][w - 1] - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    cout<<(a<b&&b<c ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3100
(defun turn90 (x1 x2 y1 y2)
  (list (+ y1 (- x2 y2)) (+ y2 (* -1 (- x1 y1)))))
(defparameter *x1* (read))
(defparameter *y1* (read))
(defparameter *x2* (read))
(defparameter *y2* (read))
(format t "~A ~A ~A ~A"
        (car (turn90 *x1* *y1* *x2* *y2*))
        (cadr (turn90 *x1* *y1* *x2* *y2*))
        (car (turn90 *x2* *y2* (car (turn90 *x1* *y1* *x2* *y2*)) (cadr (turn90 *x1* *y1* *x2* *y2*))))
        (cadr (turn90 *x2* *y2* (car (turn90 *x1* *y1* *x2* *y2*)) (cadr (turn90 *x1* *y1* *x2* *y2*)))))


Measured memory_bytes: 10724
S=input()
T=input()
ans=0
for i in range(len(S)-len(T)+1):
    #print(S[i:])
    cnt=0
    for j in range(len(T)):
        if S[i+j]==T[j]:
            cnt+=1
    if ans<cnt:
        ans=cnt
print(len(T)-ans)

Measured memory_bytes: 9044
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
  //flash;
  int x;
  cin>>x;
  for (int i = 0; i <= 9; ++i)
  {
    for (int j = 0; j <= 9; ++j)
    {
      if(i*j==x){cout<<"Yes";return 0;}
    }
  }
  cout<<"No";
  return 0;
}
//code the AC sol !
// BS/queue/map


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

int main(){
    string s;
    string longest;
    map<string,int> m;
    while(cin >> s){
        m[s]++;
        if(longest.size() < s.size()) longest = s;
    }
    string freq;
    for(auto & e : m){
        if(m[freq] < e.second) freq = e.first;
    }
    cout << freq << " " << longest << endl;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ipa pair<lld,lld>
#define lld long long int
#define x first
#define y second
#define ld long double
#define pb push_back
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI (atan(1)*4)
#define mp make_pair
#define mlog 21
#define mod 1000000000
using namespace std;
const int maxn=1e6+2;
lld min(lld a,lld b)
{
	return (a<b)?a:b;
}
main()
{
	fastread;
	lld i,j,n,m,k,arr[maxn];
	cin>>n>>k;
	lld dp[n+2];
	dp[0]=0;
	for(i=0;i<n;++i)
	{
		cin>>arr[i];
	}
	dp[1]=fabs(arr[1]-arr[0]);
	for(i=2;i<n;++i)
	{
		dp[i]=INT_MAX;
		for(j=i-1;j>=max((lld)0,i-k);--j)
			dp[i]=min(dp[i],dp[j]+fabs(arr[j]-arr[i]));
	}

	cout<<dp[n-1];
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    int len=s.size();
    for(int i=0;i<=len;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i;j<=len;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
    string S;
    cin>>A>>B>>S;
    bool ok=true;
    REP(i,S.size()){
        if(i==A&&S[i]!='-')ok=false;
        if(i!=A&&S[i]=='-')ok=false;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
program main
    character (10**5) :: s
    character, allocatable :: ss(:)
    character (10**5) :: ans
    integer :: are = 0
    read *, s
    do i = 1, len(trim(s))
        if (mod(i,2)==1) then
            write (*,fmt='(a)', advance='no') s(i:i)
        end if
    end do
end program main


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

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

	int s_len = s.length();
	int b_n = s_len - 1;
	long long answer = 0;
	for (int bit = 0; bit < (1 << b_n); ++bit) {
		string str;
		for (int i = 0; i < s_len; ++i) {
			str += s[i];
			
			if (bit & (1 << i)) {
				answer += atoll(str.c_str());
				str = "";
			}
		}
		answer += atoll(str.c_str());
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int a,b,c[100010],d;
  
 
  cin >> a >>b ;

  for(int i=0;i<a;i++)
    cin >> c[i];
  
  d=0;
  
  for(int i=0;i<a;i++){
    
    if(c[i]>=b){
      d++;
    }
  }
  
  cout << d << endl;
}


Measured memory_bytes: 640
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

#define v vector
#define ALL(x) x.begin(),x.end()
#define rALL(x) x.rbegin(),x.rend()
#define endl '\n'
#define DEBUG

template<typename T> void DBG(const char* name, T&& H) {
	cerr << name << " = " << H << ')' << endl;
}

template<typename T, typename... Args> void DBG(const char* names, T&& H, Args&&... args) {
	const char* NEXT = strchr(names+1, ',');
	cerr.write(names, NEXT-names) << " = " << H << " |";
	DBG(NEXT+1, args...);
}

#ifdef DEBUG
	#define dbg(...) cerr << __FUNCTION__ << ' ' <<__LINE__ << " : (", DBG(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
#endif

using ll = long long;
using ld = long double;

const ll mod = 1e9 + 7;
const ld PI = acos(-1.0);
const ll maxN = 1e6+1;

int ID = 0, sigma = 0;
int mapping[3][3];
int SZ[3];
vector<vector<int>> isMatch;
string s[3];

void computeMatch(int F, int S) {
	vector<int> a = {0};
	for(int i = 1; i <= SZ[F]; i ++) {
		int pos = 1;
		for(int j = 1, k = i; j <= min(SZ[S], SZ[F]-i+1); j ++, k ++) {
			if((s[F][k] != '?') && (s[S][j] != '?') && (s[F][k] != s[S][j])) pos = 0;
		}
		a.push_back(pos);
	}
	mapping[F][S] = ID;
	ID ++;
	isMatch.push_back(a);
}

int computeTwo(int F, int S, int T) {
	int ans = sigma;
	for(int i = 1; i <= SZ[F]; i ++) {
		if(isMatch[mapping[F][S]][i]) {
			ans = min(ans, i-1 + max(SZ[F]-i+1, SZ[S]) + SZ[T]);
		}
	}
	return ans;
}

int computeThree(int F, int S, int T) {
	int ans = sigma;
	for(int i = 1; i <= SZ[F]; i ++) {
		if(!isMatch[mapping[F][S]][i]) continue;
		for(int j = 1; j <= SZ[S]; j ++) {
			if(!isMatch[mapping[S][T]][j]) continue;
			int k = i-1+j;
			if(k > SZ[F]) {
				int overlap1 = min(SZ[S], SZ[F]-i+1);
				int overlap2 = min(SZ[T], SZ[S]-j+1);
				ans = min(ans, sigma-overlap1-overlap2);
				continue;
			}
			if(!isMatch[mapping[F][T]][k]) continue;
			ans = min(ans, max({SZ[F], i-1+SZ[S], k-1+SZ[T]}));
		}
		if(SZ[F] > i-1+SZ[S]) {
			for(int j = i+SZ[S]; j <= SZ[F]; j ++) {
				if(!isMatch[mapping[F][T]][j]) continue;
				ans = min(ans, max(SZ[F], j-1+SZ[T]));
				break;
			}
		}
	}
	return ans;
}


void Solve() {
	for(int i = 0; i < 3; i ++) {
		cin >> s[i];
		SZ[i] = s[i].size();
		sigma += SZ[i];
		s[i] = " " + s[i];
	}
	for(int i = 0; i < 3; i ++) {
		for(int j = 0; j < 3; j ++) {
			if(i == j) continue;
			computeMatch(i, j);
		}
	}
	int ans = sigma;
	for(int i = 0; i < 3; i ++) {
		for(int j = 0; j < 3; j ++) {
			for(int k = 0; k < 3; k ++) {
				if((i == j) || (j == k) || (k == i)) continue;
				ans = min(ans, computeTwo(i, j, k));
				ans = min(ans, computeThree(i, j, k));
			}
		}
	}
	cout << ans << endl;
}	

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int tt = 1;
	while(tt --) {
		Solve();
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;

int H, W;
char map[8][8];

int check(int h, int w){
    
    //cout << h << ":" << w << endl;
    map[h][w] = '.';

    if(h == H - 1 && w == W - 1){
        for(int h = 0; h < H; h++){
            for(int w = 0; w < W; w++){
                if(map[h][w] == '#'){
                    cout << "Impossible" << endl;
                    return 0;
                }
            }
        }
        cout << "Possible" << endl;
        return 0;
    }

    int cnt = 0;
    if(h + 1 < H){
        if(map[h+1][w] == '#'){
            cnt += 1;
        }
    }
    if(w + 1 < W){
        if(map[h][w+1] == '#'){
            cnt += 2;
        }
    }

    if(cnt == 0 || cnt == 3){
        cout << "Impossible" << endl;
        return 0;
    }
    
    if(cnt == 1){
        check(h+1, w);
    }
    if(cnt == 2){
        check(h, w+1);
    }

    return 0;

}

int main(){

    cin >> H >> W;

    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            cin >> map[h][w];
        }
    }
    check(0,0);

}

Measured memory_bytes: 256
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

long long t[N];

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, m; cin >> n >> m;

    for(long long i = 0; i < m; i++) {
        long long l, r; cin >> l >> r;
        t[l]++, t[r + 1]--;
    }

    long long ans = 0;
    for(long long i = 1; i < N; i++) {
        t[i] += t[i - 1];
        if(t[i] == m) ans++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4396