akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int N,K,count=0,Ki=0,min;
    int k[200000];

    cin >> N;
    cin >> K;
    
    for (int i = 0; i < N;i++) {
        cin >> k[i];
    }

    while (1) {
        min = k[Ki];
        for (int i = Ki; i < K; i++) {
            if (k[i] < min) {
                min = k[i];
            }
        }
        if (Ki==0) {
            Ki++;
        }
        Ki += K-1;
        count++;
        if (Ki >= N) {
            break;
        }
    }


    cout << count;
        
    cout << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  int N,K,j=0,ans=0;
  cin >> N >> K;
  int A[N];
  rep(i,N) cin >> A[i];
  sort(A,A+N);
  int count[N]={};
  rep(i,N){
    count[j]++;
    if(i<N-1 && A[i]!=A[i+1]) j++;
  }
  int count2[j+1]={};
  rep(i,j+1) count2[i]=count[i];
  sort(count2,count2+j+1);
  int kind=j+1;
  j=0;
  while(kind>K){
    kind--;
    ans+=count2[j];
    j++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        Console.WriteLine((n / 11) * 2 + (n % 11 == 0 ? 0 : (n % 11 <= 6 ? 1 : 2)));
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,ind;
struct node{
	int ls,rs,sum;
}tr[20500010];
void pushup(int o){
	tr[o].sum=tr[tr[o].ls].sum+tr[tr[o].rs].sum;
}
void build(int &o,int l,int r){
	o=++ind;
	if(r==l)return;
	build(tr[o].ls,l,(l+r)/2);
	build(tr[o].rs,(l+r)/2+1,r);
}
void update(int &_new,int old,int l,int r,int pos){
	_new=++ind;
	tr[_new]=tr[old];
	tr[_new].sum++;
	if(l==r)return;
	int mid=(l+r)/2;
	if(pos<=mid)update(tr[_new].ls,tr[old].ls,l,mid,pos);
	else update(tr[_new].rs,tr[old].rs,mid+1,r,pos);
	pushup(_new);
}
int query(int _new,int old,int l,int r,int x,int y){
	if(x>r||y<l)return 0;
	if(x<=l&&y>=r)return tr[_new].sum-tr[old].sum;
	int mid=(l+r)/2;
	if(y<=mid)return query(tr[_new].ls,tr[old].ls,l,mid,x,y);
	else if(x>mid)return query(tr[_new].rs,tr[old].rs,mid+1,r,x,y);
	else return query(tr[_new].ls,tr[old].ls,l,mid,x,mid)+query(tr[_new].rs,tr[old].rs,mid+1,r,mid+1,y);
}
int rt[551000];
struct data{
	int l,r;
	friend bool operator <(data a,data b){
		return a.l==b.l?a.r<b.r:a.l<b.l;
	}
}item[300100];
void solve(int d){
	int res=0,now=0,pre=0;
	for(int i=1;i*d<=m;++i){
		int k=0;
		for(int j=18;j>=0;--j){
			if((1<<j)>n)continue;
			if((k+(1<<j))<=n&&(item[k+(1<<j)].l-1)/d<i)k+=(1<<j);
		}
		now=k;
		if(now>n)now=n;
		int t=(item[now].l-1)/d;
		res+=query(rt[now],rt[pre],1,m,d*(t+1),m);
		pre=now;
	}
	printf("%d\n",res);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d%d",&item[i].l,&item[i].r);
	}
	sort(item+1,item+n+1);
	build(rt[0],1,n);
	for(int i=1;i<=n;++i){
		update(rt[i],rt[i-1],1,m,item[i].r);
	}
	for(int d=1;d<=m;++d){
		solve(d);
	}
}

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

int main(){
    int n; cin >> n;
    vector<pair<string,int>> sp(n), sp2(n);

    for(int i = 0; i < n; i++){
        string s;
        int p;
        cin >> s >> p;
        p *= -1;
        sp[i] = make_pair(s,p);
    }
    sp2 = sp;
    sort(sp.begin(),sp.end());

    for(auto a: sp){
        for(int i = 0; i < n; i++){
            if(a == sp2[i]){
                cout << i+1 << endl;
                break;
            }
        }
    }
}

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

def number_of_divisor(n):
    ans=[0]*(n+1)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            ans[j]+=1
    return ans

divisor=number_of_divisor(n)
ans=0
for i in range(1,n+1):
    ans+=i*divisor[i]

print(ans)

Measured memory_bytes: 151820
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int n,k;
int a[109];
int cnt[109];
bool pos[109];
bool yo(int x)
{
    if(x%2==1)
    {
        int tmp=k/2;
        f(i,0,tmp)
        {
            int val=k-i;
            if(cnt[val]<2)return false;
            cnt[val]-=2;
            if(i<tmp)pos[val]=true;
        }
        f(i,1,n-1)
        {
            if(cnt[i]>0 && pos[i]==false)return 0;
        }
    }
    else
    {
          int tmp=k/2;
        f(i,0,tmp-1)
        {
            int val=k-i;
            if(cnt[val]<2)return false;
            cnt[val]-=2;
            pos[val]=true;
        }
        if(cnt[k-tmp]<1)return false;
        cnt[k-tmp]-=1;
        f(i,1,n-1)
        {
            if(cnt[i]>0 && pos[i]==false)return false;
        }
    }
    return true;
}
 main()
{
    fast
    cin>>n;
    f(i,1,n)cin>>a[i],cnt[a[i]]++,k=max(k,a[i]);
    if(yo(k))cout<<"Possible\n";
    else     cout<<"Impossible\n";
    return 0;

}














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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll Euclid(ll A, ll B){
    if(A<B) swap(A, B);
    ll C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

int main(){
	ll N, X;
	cin >> N >> X;
	ll G = Euclid(N, X);
	cout << (3*G)*(N/G-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
int main() {
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<int> A(N);
  REP(i,N) cin >> A[i];
  vector<int> tbl(N);
  REP(i,N) {
    int maxVal = A[i], minVal = A[i];
    REP(j,M) {
      maxVal = max(maxVal, A[(i + j) % N]);
      minVal = min(minVal, A[(i + j) % N]);
    }
    tbl[i] = maxVal - minVal;
  }
  int k = 0;
  int ans = 0;
  while(true) {
    ans += tbl[k];
    k += M;
    k %= N;
    if (k == 0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define drep(i,n) for (int i = n; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, n)
  {
    cout << '[';
    rep(p, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}


//------------------------------------------------------------
string divide[4] = {"dream","dreamer","erase","eraser"};

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

  bool bool1=true, bool2=true;

  reverse(all(s));
  rep(i, 4) reverse(all(divide[i]));

  rep(i, s.size())
  {
    bool2 = false;
    rep(j, 4)
    {
      if(s.substr(i,divide[j].size()) == divide[j])
      {
        i += divide[j].size()-1;
        bool2 = true;
        break;
      }
    }
    if(!bool2)
    {
      bool1 = false;
      break;
    }
  }

  if(bool1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define S second
#define MOD 1000000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define MAXN 100008
#define MAXI 100000000007

signed main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    bitset<4000003> b;
    b[0] = 1;
    int sum=0;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	b = b|(b<<a[i]);
    	sum+=a[i];
    }
    int mid = sum/2 + sum%2;
    while(mid&&!b[mid])
    	mid++;
    cout<<mid<<endl;
}

Measured memory_bytes: 2176
import sys
sys.setrecursionlimit(200000)

N = int(input())
hpns = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0, 0, 0] for _ in [0]*(N)]
dp[0] = hpns[0]

def solve():
  for i in range(0,N-1):
    dp[i+1][0] = hpns[i+1][0] + max(dp[i][1], dp[i][2])
    dp[i+1][1] = hpns[i+1][1] + max(dp[i][0], dp[i][2])
    dp[i+1][2] = hpns[i+1][2] + max(dp[i][0], dp[i][1])


solve()
ans = 0
for i in range(3):
  ans = max(ans, dp[N-1][i])
  
print(ans)


Measured memory_bytes: 40208
N=int(input())
d=[input().split() for i in range(N)]
num=0
n=0
for i in range(N):
    if d[i][0]==d[i][1]:
        num+=1
        if num==3:
            print("Yes")
            n+=1
            break
    else:
        num=0
if n==0:
    print("No")

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	char k[51][51]; 
	for(int i=0;i<a;i++){
		scanf("%s",k[i]);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(k[i][j]=='#'){
				if(k[i-1][j]!='#'&&k[i][j-1]!='#'&&k[i+1][j]!='#'&&k[i][j+1]!='#'){
					cout<<"No";
					return 0;
				}
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("input.txt");ofstream coutt("output.txt");

int a,b,n;

int ff(int x){
    return (a*x)/b - a*(x/b);
}

int f(int l,int r){
    if(l>r)return 0;
    if(l/b==r/b){
        return ff(r);
    }
    int mid=(l+r)/2;
    return max(f(l,mid),f(mid+1,r));
}

signed main(){
    FASTER;
    cin>>a>>b>>n;
    n=min(b,n);
    cout<<f(0,n);
}


Measured memory_bytes: 3584
#include <iostream>

int main() {
  // 入力
  int a, b, h;
  std::cin >> a >> b >> h;

  // 台形の面積
  int area_of_trapezoid = (a + b) * h / 2;

  // 出力
  std::cout << area_of_trapezoid << std::endl;

  return 0;
}


Measured memory_bytes: 888
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

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

	string x; cin >> x;
	int tot = 0;
	int s = 0;
	forn(i,x.size()) {
		if (x[i] == 'S') s++;
		else {
			if (s) s--;
			else tot++;
		}
	}
	
	cout << tot + s << endl;
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll less = n % 11;
  ll ans = (n / 11) * 2;
  if(less > 0)
    ans++;
  if(less > 6)
    ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
M = max(A)
D = {}
for i in range(N):
  if A[i] in D:
    D[A[i]] += 1
  else:
    D[A[i]] = 1
sorted(D)
S = 1
if A[0] == 0 and D[0] == 1:
  for i in D:
    if i != M:
      if i + 1 not in D:
        S = 0
        break
      else:
        S *= (D[i] ** D[i+1]) % 998244353
        S %= 998244353
else:
  S = 0
print(S % 998244353)


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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF (ll)2e9
#define MOD ((ll)1e9+7)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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

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

template<class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

class mod {
    static ll fact[];
public:

    template<class... A>
    static ll mul(A... args) {
        ll res = 1;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static ll power(ll base, ll exp) {
        if (exp == 0) return 1;
        if (exp & 1) {
            return mul(base, power(base, exp - 1));
        } else {
            ll p = power(base, exp / 2);
            return mul(p, p);
        }
    }

    static ll factorial(int n) {
        if (fact[n] != 0) return fact[n];
        if (n == 0) return 1;
        return fact[n] = mul(n, factorial(n - 1));
    }

    static ll inverse(int n) {
        return power(n, MOD - 2);
    }

    static ll comb(int n, int r) {
        if (r < 0 || r > n) return 0;
        return mul(factorial(n), inverse(factorial(n - r)), inverse(factorial(r)));
    }

    template<class... A>
    static ll div(ll dividend, A... args) {
        ll res = dividend;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = mul(res, inverse(i));
        }
        return res;
    }

    template<class... A>
    static ll add(A... args) {
        ll res = 0;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    template<class... A>
    static ll sub(ll l, A... args) {
        ll res = l;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res - i + MOD) % MOD;
        }
        return res;
    }
};

ll mod::fact[(int) 1e6 + 1];

int ni() {
    int i;
    cin >> i;
    return i;
}

ll nll() {
    ll l;
    cin >> l;
    return l;
}

int main() {
    int N = ni();
    ll count[50][26] = {};
    REP(i, N) {
        string s;
        cin >> s;
        REP(j, s.length()) {
            count[i][s[j]-'a']++;
        }
    }

    string ans = "";
    REP(i, 26) {
        ll m = INF;
        REP(j, N) {
            m = min(m, count[j][i]);
        }
        REP(j, m) ans.push_back('a' + i);
    }

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

Measured memory_bytes: 256
N, M, d = [int(_) for _ in input().split()]

t = 0

from itertools import product

def calc0(N, M, d):
    E = list(range(N))
    t = 0
    for xs in product(*([E] * M)):
        r = sum(abs(xs[i]-xs[i+1]) == d for i in range(M-1))
        t += r
    return t, N**M, t/N**M

def calc(N, M, d):
    if d == 0:
        k = N
    else:
        k = (N - d) * 2
    # r = k * N**(M - 2) * (M - 1) / (N**M)
    r = k * (M - 1) / N**2
    return r

#print(calc(N, 2, d))
#print(calc(N, 3, d))

print(calc(N, M, d))


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

using namespace std;

typedef long long ll;

const int N = 1e8;
const int INF = 1e9;
const int MOD = 998244353;



int main() {
    set<int> st;
    int x = 3, y;
    while (x--) {
        cin >> y;
        st.insert(y);
    }
    cout << st.size();
}

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

using namespace std;

void solve() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int ans1, ans2;
    ans1 = X;
    ans2 = X;

    while (true)
    {
        if (!binary_search(p.begin(), p.end(), ans1))
        {
            cout << ans1 << endl;
            return;
        }
        if (!binary_search(p.begin(), p.end(), ans2))
        {
            cout << ans2 << endl;
            return;
        }
        ans1--;
        ans2++;
    }
    
}

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

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

int main(){
  int input;
  vector<int> vec(4);//vec0=a,vec3=d
  cin >> input;
  for(int i=0;i<4;i++){
    vec.at(3-i) = input%10;
    input/=10;
  }

  int eval; vector<int> op(3);
  vector<char> opans(3);
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        eval=vec.at(0);
        op.at(0) = -1+2*i;
        op.at(1) = -1+2*j;
        op.at(2) = -1+2*k;
        for(int ii=0;ii<3;ii++) eval+=(vec.at(ii+1)*op.at(ii));
        if(eval == 7){
          for(int ii=0;ii<3;ii++){
            if(op.at(ii) == 1) opans.at(ii)='+';
            else opans.at(ii)='-';
            cout<<vec.at(ii)<<opans.at(ii);
          }
          cout<<vec.at(3)<<"=7"<<endl;;
          return 0;
        }
      }
    }
  }
  
}
          
          


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int N, M;
int a[50], b[50], c[50], d[50];


int main() {
    cin >> N >> M;
    for (int j = 0; j < N; ++j) {
        cin >> a[j] >> b[j];
    }
    for (int j = 0; j < M; ++j) {
        cin >> c[j] >> d[j];
    }
    for (int j = 0; j < N; ++j) {
        int ind = 0;
        int min_dist = abs(a[j]-c[0]) + abs(b[j]-d[0]);
        for (int k = 1; k < M; ++k) {
            if (abs(a[j]-c[k]) + abs(b[j]-d[k]) < min_dist) {
                min_dist = abs(a[j]-c[k]) + abs(b[j]-d[k]);
                ind = k;
            }
        }
        cout << (ind+1) << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")

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

  int N;
  cin >> N;

  ULL L1=2, L2=1;
  REP(N-1){
    ULL L3 = L1 + L2;
    L1 = L2;
    L2 = L3;
  }
  cout << L2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

ll solve(string s) {
    ll ans = 0;
    ll count = 0;
    rep(i, s.size()) {
        if (s[i] == 'B') {
            ans += count;
        } else if (s[i] == 'A') {
            count++;
        } else {
            count = 0;
        }
    }

    return ans;
}

int main() {
    // source
    string s;
    cin >> s;
    // string mine = "";
    int dust = 0;
    int n = s.size();

    ll count = 0;
    ll ans = 0;

    rep(i, n) {
        if (dust == 0) {
            if (s[i] == 'A') {
                // mine += "A";
                count++;

            } else if (s[i] == 'B') {
                if (i + 1 != n) {
                    if (s[i + 1] == 'C') {
                        // mine += "B";
                        ans += count;
                        i++;
                    } else if (s[i + 1] == 'A') {
                        // mine += "D";
                        count = 0;
                    } else {
                        // mine += "D";
                        count = 0;
                        dust = 1;
                    }
                }
            } else {
                dust = 1;
                // mine += "D";
                count = 0;
            }
        } else {
            if (s[i] == 'A') {
                // mine += "A";
                count++;
                dust = 0;
            }
        }
    }

    // rep(i, mine.size()) { ans = solve(mine); }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

int main(void) {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int MAX = (H2 - H1) * 60;
    MAX = MAX - M1 + M2;

    int DIFF = MAX - K;

    cout << DIFF << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<cstdlib>
#define inf INT_MAX
using namespace std;
int main(){
int n,k;
cin>>n>>k;
int a[n+1];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}

long long int dp[n+1]={0};
dp[1]=0;

for(int i=2;i<=n;i++)
{
	dp[i]=inf;
	for(int j=i-1;j>=1 && (i-j)<=k;j--)
	{
		//cout<<a[i-1]<<" "<<a[j-1]<<" "<<"rfg"<<endl;
		dp[i]=min(dp[i],abs(a[i-1]-a[j-1])+dp[j]);
	}

}
cout<<dp[n]<<endl;
}


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

const int XD = 1e5 + 2;
int tab[ XD ], dp[ XD ];

int main()
{
    ios_base::sync_with_stdio( false );
    int n; cin >> n;
    for( int i = 1; i <= n; i++ )
        cin >> tab[ i ];
    dp[ 2 ] = abs( tab[ 1 ] - tab[ 2 ] );
    for( int i = 3; i <= n; i++ )
        dp[ i ] = min( dp[ i - 1 ] + abs( tab[ i - 1 ] - tab[ i ] ), dp[ i - 2 ] + abs( tab[ i - 2 ] - tab[ i ] ) );
    cout << dp[ n ];
    return 0;
}


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

using namespace std;

using ll = long long;
using Matrix = vector<vector<ll>>;

inline ll ceil_ll(ll x, ll y) { return (x + y - 1) / y; }

Matrix mulMatrix(const Matrix &A, const Matrix &B, const ll MOD) {
    Matrix C(3, vector<ll>(3));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                (C[i][j] += (A[i][k] * B[k][j]) % MOD) %= MOD;
            }
        }
    }
    return C;
}

Matrix powMatrix(Matrix A, ll e, const ll MOD) {
    vector<vector<ll>> X(3, vector<ll>(3));
    X[0][0] = X[1][1] = X[2][2] = 1;

    for ( ; 0 < e; e >>= 1) {
        if (e & 1) X = mulMatrix(X, A, MOD);
        A = mulMatrix(A, A, MOD);
    }
    return X;
}

using ull = unsigned long long;
ll fast_pow10(ull e, const ull MOD) {
    ull a = 10, x = 1;
    for ( ; 0 < e; e >>= 1) {
        if (e & 1) (x *= a) %= MOD;
        (a *= a) %= MOD;
    }
    return x;
}

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

    constexpr int DIGITS = 19;
    vector<ll> pow10(DIGITS);
    pow10[0] = 1;
    for (int i = 1; i < DIGITS; ++i)
        pow10[i] = 10 * pow10[i - 1];


    ll L, A, B, M;
    cin >> L >> A >> B >> M;

    vector<ll> begin(DIGITS), num(DIGITS);
    for (ll d = 1; d < DIGITS; ++d) {
        begin[d] = max(0ll, ceil_ll(pow10[d - 1] - A, B));
        const ll end = min((pow10[d] - A - 1) / B, L - 1);

        const ll s_l = A + B * begin[d], s_r = A + B * end;
        if (pow10[d - 1] <= s_l && s_r < pow10[d] && begin[d] <= end)
            num[d] = end - begin[d] + 1;
    }

    ll ans = 0;
    for (ll d = 1; d < DIGITS; ++d) {
        if (num[d] == 0) continue;

        Matrix X(3, vector<ll>(3));
        X[0][0] = pow10[d] % M; X[0][1] = 1;
        X[1][1] = 1; X[1][2] = B % M;
        X[2][2] = 1;

        X = powMatrix(X, num[d], M);

        const ll s0 = (A + B * begin[d]) % M;
        const ll s = ((X[0][1] * s0) % M + X[0][2]) % M;

        (ans *= fast_pow10((unsigned long long)d * num[d], M)) %= M;
        (ans += s) %= M;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,x[205],y[205],mod=998244353,cnt,v[205],s,p[205];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n; p[0]=1;
    for(int i=1;i<=n;i++){
        cin >> x[i] >> y[i];
        p[i]=p[i-1]*2%mod;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++) v[j]=0;
        for(int j=i+1;j<=n;j++){
            if(v[j]) continue;
            v[j]=1;
            s=1;
            for(int t=j+1;t<=n;t++){
                if((x[t]-x[i])*(y[j]-y[i])==(x[j]-x[i])*(y[t]-y[i])) s++,v[t]=1;
            }
            cnt+=(p[s]-1);
            cnt%=mod;
        }
    }
    cnt=(p[n]-cnt-1-n+2*mod)%mod;
    cout << cnt;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        cs: chars,
    }

    let mut cnt = 1;
    let mut tmp: char = cs[0];
    for i in 0..n{
        if cs[i]!=tmp {
            cnt += 1;
            //println!("{}", cs[i]);
        }
        tmp = cs[i];
    }

    println!("{}", cnt);
}

Measured memory_bytes: 4352
def gcd(a,b):
    if(a==0):
        return b
    return gcd(b%a,a)


a,b,c,d=[int(i) for i in input().split()]

if(a%c==0):
    first = (b//c) - (a//c)+1
else:
    first = (b//c) - (a//c)
if(a%d==0):
    second = (b//d) - (a//d) + 1
else:
    second = (b//d) - (a//d)
lcm = (c*d)//gcd(c,d)
if(a%lcm==0):
    common = (b//lcm) - (a//lcm) + 1
else:
    common = (b//lcm) - (a//lcm)
print((b-a+1)-(first+second-common))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  int n,k;
  cin>>n>>k;
  COMinit();
  rep2(i,1,k+1){
    cout<<COM(n-k+1,i)*COM(k-1,i-1)%MOD<<endl;
  }
}

Measured memory_bytes: 23680
n,k = map(int,input().split())
h = []
for i in range(n):
    x = int(input())
    h.append(x)
h.sort()

res = h[k-1]-h[0]
for i in range(n-k+1):
    res = min(res,h[k-1+i]-h[i])
print(res)
    

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

int main() {
	ll n, a, b;
	vector<ll>v;
	cin >> n;
	ll p[1000];
	for (int i = 0;i < n;i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 1;i < n;i++) {
		if (p[i] == p[i - 1]) {
			ans++;
			p[i] = 100000;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pie M_PI
#define maxx 2147483647
#define FOR(i,a,b) for(int i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
const long long int maxs = 100000000;




int main()
{

    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    // cout.tie(NULL);
    int n, m;
    ll k;
    scanf("%d %d %lld", &n, &m, &k);
    ll a[n + 1], b[m + 1];
    ll no;
    a[0] = 0;
    b[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%lld", &no);
        a[i] = a[i - 1] + no;
    }
    for(int i = 1; i <= m; i++)
    {
        scanf("%lld", &no);
        b[i] = b[i - 1] + no;
    }
    ll mx = 0, ans = 0, diff;
    for(int i = 0; i <= n; i++)
    {
        diff = k - a[i];

        if(diff < 0)
            break;
        ll low = 1;
        ll high = m;
        ll mid;
        ans = 0;
        while(low <= high)
        {
            mid = (high + low) / 2;
            if(b[mid] <= diff)
            {
                ans = mid;
                low = mid + 1;
            }
            else
                high = mid - 1;
        }
        mx = max(mx, i + ans);

    }
    cout << mx << endl;

}


Measured memory_bytes: 6868
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  int s[M], c[M];
  for(int i=0;i<M;++i) {
    cin>>s[i]>>c[i];
    s[i]--;
  }
  int ans = -1;
  string tmp;
  bool can;
  for(int i=0;i<1000;++i) {
    tmp = to_string(i);
    if(tmp.size()!=N) continue;
    can = true;
    for(int j=0;j<M;++j) {
      if(tmp.size()<=s[j]) {
        can = false;
        break;
      }
      if(tmp[s[j]]!=c[j]+'0') can = false;
    }
    if(can) {
      ans = i;
      break;
    }
  }
  cout<<ans<<endl;
}



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

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

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	bool dp[100001]={};
	rep(i,k+1) rep(j,n) if(a[j]<=i && !dp[i-a[j]]) dp[i]=true;

	puts(dp[k]?"First":"Second");

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if (a+b>=a-b && a+b>=a*b)
    printf("%d\n", a+b);
    else if (a-b>=a+b && a-b>=a*b)
    printf("%d\n", a-b);
    else if (a*b>=a+b && a*b>=a-b)
    printf("%d\n", a*b);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int N;
	while ( cin >> N, N ) {
		int m[21][21] = {0};
		for (int i = 0; i < N; ++i) {
			int x, y; cin >> x >> y;
			++m[y][x];
		}
		int px = 10, py = 10;
		int M; cin >> M;
		int ans = m[py][px];
		for (int i = 0; i < M; ++i) {
			char d; int l; cin >> d >> l;
			int dx = d == 'E' ? 1 : d == 'W' ? -1 : 0;
			int dy = d == 'N' ? 1 : d == 'S' ? -1 : 0;
			for (int j = 0; j < l; ++j) {
				px += dx, py += dy;
				ans += m[py][px];
				m[py][px] = 0;
			}
		}
		if (ans == N) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1148
m,f,r = gets.split.map &:to_i
grade = ""
score = 0

while m!=-1 || f!=-1 || r!= -1 do
    score = m+f
    if(m==-1 || f ==-1)
        grade = "F";
    elsif(score >= 80)
        grade = "A";
    elsif(score < 80 && score >= 65)
        grade = "B";
    elsif(score < 65 && score >= 50)
        grade = "C";
    elsif(score < 50 && score >= 30)
        if(r>=50)
            grade = "C";
        else
            grade = "D";
        end
    else
        grade = "F";
    end
    puts grade
    m,f,r = gets.split.map &:to_i
end

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

using namespace std;

int main(){
    
    int a, b;
    int d, r;
    double f;
    cin >> a >> b;
    
    double a1=a, b2=b;
    
    d = a/b;
    r = a%b;
    f = a1/b2;
    
    cout << d << " " << r << " ";
    printf ("%.10f\n",f );
    
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}

#define REP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000+7)

int main() {
    string S;
    cin >> S;
    int buf[2] = {0,0};
    vector<int> ans(S.size());
    int sp = 0;
    REP(i, 0, S.size()) {
        if (i < S.size()-1 && S[i] == 'R' && S[i+1] == 'L') {
            buf[i%2]++;
            ans[i] += buf[i%2];
            ans[i+1] += buf[(i+1)%2];
            
            buf[0] = 0; buf[1] = 0;
            sp = i;
        }else {
            if (S[i] == 'R') {
                buf[i%2]++;
            } else {
                ans[sp + (i-sp)%2]++;
            }
        }
    }
    
    REP(i, 0, S.size()) {
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  a.push_back(0);
  rep(i, n) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  a.push_back(0);

  int max_length = 0;
  rep(i, n + 1) max_length += abs(a[i + 1] - a[i]);
  rep2(i, 1, n + 1) {
    int length = max_length;
    length -= abs(a[i] - a[i - 1]);
    length -= abs(a[i + 1] - a[i]);
    length += abs(a[i + 1] - a[i - 1]);
    printf("%d\n", length);
  }
  return 0;
}

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

int main()
{
    string s;
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.length();i++)
    {
        sum+=(int)(s[i]-'0');
    }
    if(sum%9==0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからb - 1まで
#define p(x) cout<<x<<endl  //xを改行付きで出力
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int a,b;
  cin >> a >> b;
  cout << a + 1 - b << endl;
  return 0;
}

Measured memory_bytes: 256
import fractions

if __name__ == '__main__':
  a, b, c, d = map(int, input().split(" "))
  c_num = b // c - (a-1) // c
  d_num = b // d - (a-1) // d
  lcm = (c * d) // fractions.gcd(c, d)
  cd_num = b // lcm - (a-1) // lcm
  print(b - a  + 1 - (c_num + d_num - cd_num))


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N;
    string S;
    cin >> N >> S;
    int c = 0;
    for (int i=0; i+2<N; ++i) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            c ++;
            i += 2;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
vector<int> dp[N];
ll gp[N][2];
ll f(int i,int j,int k)
{
       if(gp[i][k] != -1){return gp[i][k];}

       ll ans = 1;
       for(int l : dp[i]){
              if(l != j){
                     if(k==1){
                            ans *= f(l,i,0);
                            ans %= mod;
                     }
                     else{
                            ans *= (f(l,i,1)+f(l,i,0))%mod;
                            ans %= mod;
                     }      
              }
       }
       return gp[i][k] = ans;
}
int main()
{
       memset(gp,-1,sizeof gp);
       int n;
       cin>>n;
       fri(i,1,n){
              int x,y;
              cin>>x>>y;
              --x;--y;
              dp[x].pb(y);
              dp[y].pb(x);
       }
       cout<<((f(0,0,0)+f(0,0,1))%mod)<<endl;

}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cast static_cast
#define ll long long int
#define v vector
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define pair p
using namespace std;
ll modF=1e9+7;

void solve(){
	ll n,w;
	cin>>n>>w;
	ll wa[n+1];
	ll va[n+1];
	for(int i=1;i<=n;i++){
		cin>>wa[i]>>va[i];
	}
	ll dp[n+1][w+1];
	for(int i=0;i<n+1;i++){
		for(int j=0;j<=w;j++){
			if(j<=0 || i<=0)
				dp[i][j]=0;
			else{
				ll n1,n2;
				if(wa[i]<=j)
					n1=va[i]+dp[i-1][j-wa[i]];
				else
					n1=0;
				n2=dp[i-1][j];
				dp[i][j]=max(n2,n1);
			}
		}
	}
	cout<<dp[n][w]<<"\n";
}

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

Measured memory_bytes: 82500
#include <iostream>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
int main()
{
	int s=0,n;
	cin >> n;
	int a[n],b[n],c[n];
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n-1) cin >> c[i];
	rep(i,n) s+=b[i];
	rep(i,n-1)
	{
		if((a[i]+1) == (a[i+1]))
			s+=c[a[i]-1];
	}
	cout << s<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int t,countt1=0,countt2=0;
    cin>>s;
    for(int i=0;i<s.size();i+=2)
    {
        if(s[i]=='R' || s[i]=='U' || s[i]=='D')
        {
            countt1++;
        }
    }
    for(int j=1;j<s.size();j+=2)
    {
        if(s[j]=='L' || s[j]=='U' || s[j]=='D')
        {
            countt2++;
        }
    }
   // cout<<countt1<<" "<<countt2<<endl;
    t=s.size();
    if(t%2!=0)
    {
        if((countt1==((t+1)/2)) && (countt2==((t-1)/2))  )
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else{

        if((countt1==(t/2)) && (countt2==(t/2))  )
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,m;
int x[100010];

void input(){
    cin >> n >> m;
    for(int i=0;i<m;i++) cin >> x[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    if (n >= m) cout << 0 << endl;
    else{
        int sum = 0;
        sort(x,x+m);
        vector<int> margin;
        for(int i=1;i<m;i++) margin.push_back(x[i]-x[i-1]);
        sort(margin.begin(), margin.end());
        for(int i=0;i<(n-1);i++) margin.pop_back();
        for(int i=0;i<margin.size();i++) sum += margin[i];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<queue>
const int MAX = 52;

using namespace std;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};

int H, W;
int dist[MAX][MAX];
int white[MAX][MAX];
int white_cnt = 0;

struct point {
    int x; int y;
};

int main(){
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            dist[i][j] = -1;
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++){
            char c;
            cin >> c;
            if (c == '.') {
                white[i][j] = 1;
                white_cnt ++;
            } else {
                white[i][j] = 0;
                }
        }
    }

    queue<point> qu;
    qu.push({0, 0});
    dist[0][0] = 0;
    while (!qu.empty()) {
        point cur = qu.front();
        qu.pop();
        for (int k = 0; k < 4; k++) {
            point nex = {cur.x + dx[k], cur.y + dy[k]};
            if (white[nex.x][nex.y] == 1 && dist[nex.x][nex.y] == -1){
                dist[nex.x][nex.y] = dist[cur.x][cur.y] + 1;
                qu.push(nex);
            }
        }
    }

    if (dist[H-1][W-1] == -1){
        cout << -1 << endl;
    } else {
        cout << white_cnt - dist[H-1][W-1] - 1 << endl;
    }
}

Measured memory_bytes: 256