akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;

constexpr int64_t MOD = 1'000'000'007LL;

#define INT(NAME) int NAME; cin>>NAME;
#define VECTOR(NAME, TYPE, SIZE) std::vector<TYPE> NAME((SIZE));\
    for(int __i=0; __i<SIZE; __i++) cin>>NAME[__i];

int main() {
    INT(K)
    INT(N)
    VECTOR(A, int, N)
    A.push_back(A[0]+K);
    int max_dist = -1;
    for(int i=0; i<N; i++)
        max_dist = max(max_dist, A[i+1]-A[i]);
    int ans = K - max_dist;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb       push_back
#define mp       make_pair
#define mod      1000000007
#define pi       acos(-1.0)
typedef long long ll;
using namespace std;
int main()
{

     ios::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
     ll a,b,c,d;
     cin>>a>>b>>c>>d;
      ll x,y,z;
      x=a*c;
      y=a*d;
      ll p=b*c;
      ll q=b*d;
       cout<<max(max(x,y),max(p,q))<<endl;

      return 0;
 }

Measured memory_bytes: 3656
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    W, H, N, *XYA = map(int, read().split())

    vec_x = [0] * (W + 1)
    vec_y = [0] * (H + 1)
    for x, y, a in zip(*[iter(XYA)] * 3):
        if a == 1:
            vec_x[0] += 1
            vec_x[x] -= 1
        elif a == 2:
            vec_x[x] += 1
            vec_x[W] -= 1
        elif a == 3:
            vec_y[0] += 1
            vec_y[y] -= 1
        else:
            vec_y[y] += 1
            vec_y[H] -= 1

    vec_x = list(accumulate(vec_x))
    vec_y = list(accumulate(vec_y))

    ans = 0
    for i in range(W):
        for j in range(H):
            if vec_x[i] == 0 and vec_y[j] == 0:
                ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9256
#include <stdio.h>
int main(void)
{
    int i=0, cnt1=0, cnt0=0;
    char s[1000000];
    scanf("%s", s);

    while(s[i]!='\0'){
        if(s[i]=='1') cnt1++;
        else if(s[i]=='0') cnt0++;
        i++;
    }

    if(cnt1>=cnt0 && cnt1>0 && cnt0>0) printf("%d\n", 2*cnt0);
    else if(cnt1>0 && cnt0>0) printf("%d\n", 2*cnt1);
    else printf("%d\n", 0);
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int m, f, r, mf;
    while(1){
        scanf("%d%d%d", &m, &f, &r);
        if(m==-1 && f==-1 && r==-1) break;
        mf = m + f;
        if(m==-1 || f==-1) printf("F\n");
        else if(mf>=80) printf("A\n");
        else if(mf>=65) printf("B\n");
        else if(mf>=50) printf("C\n");
        else if(mf>=30){
            if(r>=50) printf("C\n");
            else printf("D\n");
        }
        else printf("F\n");
    }
    return 0;
}


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

int main(){
  int H,W;
  bool s[50][50];
  bool end;

  cin >> H >> W;

  char work;
  for(int y = 0; y < H; ++y){
    for(int x = 0; x<W; ++x){
      cin >> work;

      if(work == '.'){
	s[y][x] = false;
      }else{
	s[y][x] = true;
      }
    }
  }
  

  end = true;
  for(int y = 0; y < H; ++y){
    for(int x = 0; x<W; ++x){
      if(s[y][x]){
	if(x > 0)
	  if(s[y][x-1]) continue;
	if(x<W-1)
	  if(s[y][x+1]) continue;
	if(y>0)
	  if(s[y-1][x]) continue;
	if(y<H-1)
	  if(s[y+1][x]) continue;

	end = false;
	break;
      }
    }
    if(!end)break;
  }

  if(end){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


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

int main() {
    long N, K;
    cin >> N >> K;
    long ans = 0;
    long max, min;



    for (long i=K; i<=N+1; i++) {
        max = i*(2*N-i+1)/2;
        min = i*(i-1)/2;
        ans += max - min + 1;
    }
    cout << ans%1000000007 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <atcoder/all>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using namespace atcoder;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll N, Q;
    cin >> N >> Q;
    dsu uf(N);
    ll t, u, v;
    REP(i, Q){
        cin >> t >> u >> v;
        if(t == 0) uf.merge(u, v);
        else PRINT(uf.same(u, v));
    }
    return 0;
}

Measured memory_bytes: 3920
N = int(input())
A = list(map(int,input().split()))
ans = 29
for x in A:
    cnt = 0
    for i in range(ans):
        if x % 2 == 0:
            x = x//2
            cnt += 1
        else:
            break
    ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        boolean check = false;
        while(!check){
            int x = scan.nextInt();
            int y = scan.nextInt();
            if(x != 0 || y != 0){
                if(x > y){
                    int box = y;
                    y = x;
                    x = box;
                }
                System.out.println(x + " " + y);
            }else if (x == 0 && y == 0){
                check = true;
            }
        }
    }
}


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


int n,k;
long long  dp[101][100001];
long long m=1000000000+7;

int   a[101];
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  cin>>n>>k;
 for(int i=1;i<=n;i++)
 {
 	cin>>a[i];
 }
 
 dp[0][0]=1;
 for(int i=1;i<=k;i++)
 {
 	dp[0][i]=0;
 }
 
 
 
 for(int i=1;i<=n;i++)
 {
 	 int sums[k+1];
        sums[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sums[j]=(sums[j-1]+dp[i-1][j])%m;  
        }
        
 	for(int j=0;j<=k;j++)
 	{
 	int tr=sums[j];
 	int ur=j-a[i]-1;
 	if(ur>=0)
 	{
 	tr=(tr-sums[ur]+m)%m;
	}
	dp[i][j]=tr;
	}
 }
  
 
  cout<<dp[n][k]<<endl;
 
}


Measured memory_bytes: 79616
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int N = 200228;

int p[N];
int par[N];
int sz[N];

int gp(int x) {
    return (p[x] == x) ? x : (p[x] = gp(p[x]));
}

void uni(int a, int b) {
    p[a] = b;
    sz[b] += sz[a];
}


vector<int> e[N];

int f[N];
int c[N];

int n;


int t = 0;

int curnx[N];
int bef[N];

void dfs(int v, int p, int mx, int mx2) {
    bef[v] = mx;
    par[v] = p;

    auto it = find(e[v].begin(), e[v].end(), p);
    if (it != e[v].end()) {
        e[v].erase(it);
    }

    int nmx = mx, nm2 = mx2;

    if (v > mx) {
        ++f[v];
        nmx = v;
        nm2 = 0;
    } else {
        int prev = bef[mx];
        nm2 = max(nm2, v);

        if (prev > nm2) {
            ++f[mx];
        } else {
            int nx = curnx[mx];
            ++f[nx];
        }
    }

    for (int u: e[v]) {
        curnx[v] = u;
        dfs(u, v, nmx, nm2);
    }
}

void dfs_ans(int v, int up) {
    c[v] = up + f[v];

    for (int u: e[v]) {
        dfs_ans(u, c[v]);
    }
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);

    for (int i = 1; i <= n; ++i) {
        p[i] = i;
        sz[i] = 0;
    }

    cin >> n;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    dfs(1, 1, 0, 0);

    for (int v: e[1]) {
        dfs_ans(v, 0);
    }

    for (int i = 2; i<= n; ++i) {
        cout << c[i] << " ";
    }

    cout << "\n";
}



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

int main(){
	cout<<fixed<<setprecision(12);
	
	int n, x[100], y[100];
	double p1 = 0, p2 = 0, p3 = 0, pi = 0, temp;
	
	cin>>n;
		
	for(int i = 0; i < n; i++)  cin>>x[i];
	for(int i = 0; i < n; i++)  cin>>y[i];
	
	pi = fabs(x[0] - y[0]);

	for(int i = 0; i < n; i++){
		temp = fabs(x[i] - y[i]);
		p1 += temp;
		p2 += pow(temp, 2);
		p3 += pow(temp, 3);
		if(pi < temp) swap(pi, temp);
	}
	
	p2 = pow(p2, 1.0/2.0);
	p3 = pow(p3, 1.0/3.0);
	
	cout<<p1<<endl<<p2<<endl<<p3<<endl<<pi<<endl;

	return 0;
}


Measured memory_bytes: 3412
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;

int a[100000];
int b[100000];
int h[100000];
int ah[100000];
int bh[100000];

const ll MOD = ll(1e9 + 7);

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

	int N;
	cin >> N;

	memset(ah, -1, sizeof ah);
	memset(bh, -1, sizeof bh);
	for(int i = 0; i < N; i++) {
		cin >> a[i];
	}
	ah[0] = a[0];
	for(int i = 1; i < N; i++) {
		if(a[i - 1] != a[i]) ah[i] = a[i];
	}

	for(int i = 0; i < N; i++) {
		cin >> b[i];
	}
	bh[N - 1] = b[N - 1];
	for(int i = 0; i < N - 1; i++) {
		if(b[i] != b[i + 1]) bh[i] = b[i];
	}

	ll ans = 1;
	for(int i = 0; i < N; i++) {
		bool ok = true;
		if(ah[i] != -1 && bh[i] != -1) {
			if(ah[i] != bh[i]) {
				ok = false;
			}
		}
		else if(ah[i] == -1 && bh[i] != -1) {
			if(a[i] < bh[i]) {
				ok = false;
			}
		}
		else if(ah[i] != -1 && bh[i] == -1) {
			if(b[i] < ah[i]) {
				ok = false;
			}
		}
		else {
			ans *= min(a[i], b[i]);
			ans %= MOD;
		}
		if(!ok) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

template<unsigned mod=998244353>struct mint {
   unsigned val;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=ll(val)*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=ll(val)*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
template<unsigned mod=998244353>struct factorial {
   using Mint=mint<mod>;
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};
using Mint=mint<>;

Mint dp[3010][3010],sum[3010][3010];

int main(){
   int n,k; scanf("%d%d",&n,&k);
   vector<int> a(n); rep(i,0,n)scanf("%d",&a[i]);
   rep(i,0,n+1)dp[i][0]=sum[i][0]=1;
   rep(i,0,n){
      rep(j,0,k-a[i]+1)if(sum[i][j].val){
         if(j==0)dp[i+1][j+a[i]]+=sum[i][j]*(i+1);
         else dp[i+1][j+a[i]]+=sum[i][j];
      }
      rep(j,1,k+1)sum[i+1][j]=sum[i][j]+dp[i+1][j];
   }
   Mint res=0;
   rrep(i,n-1,-1)res+=dp[i+1][k]*(n-i);
   printf("%d\n",res.val);
   return 0;
}

Measured memory_bytes: 71040
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> dp(N+1, 0);
  vvi las = vv(N+1, 64, 0, int);
  string c[] = {"A", "C", "G", "T"};
  //3
  for(int i=0;i<64;i++) if(i!=24 && i!=36 && i!=18) las[3][i]=1;
  //for(int i=0;i<64;i++) std::cout << i << las[3][i] << '\n';
  // 4>
  if(N==3) {
    std::cout << 61 << '\n';
    return 0;
  }
  for(int t=4;t<=N;t++){
    for(int i=0;i<64;i++){
      int A, B, C, D;
      D = i,A = D % 4,D/=4,B = D % 4,D/=4,C = D%4;
      for(int j=0;j<4;j++){
        int reg = B+C*4+j*16;
        int AGC = A + 4*reg;
        if(reg!=36&&reg!=18&&reg!=24){
          if(AGC!=96&&AGC!=100&&AGC!=104&&AGC!=108&&AGC!=72&&AGC!=88&&AGC!=104&&AGC!=120){
            las[t][reg] =(las[t][reg]+las[t-1][i])%1000000007;
            dp[t] = (dp[t] + las[t-1][i])%1000000007;
          }
        }
      }
    }
    //for(int i =0;i<64;i++) std::cout <<  i << las[t][i] << '\n';
  }
  std::cout << dp[N] << '\n';
  return 0;
}


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

#define ll long long

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

	ll sum = 0;
	for (ll i = 1; i <= n; i++)
	{
		if (i % 3 == 0 && i % 5 == 0 || i % 5 == 0 || i % 3 == 0) continue;

		else sum += i;
	}
	cout << sum;

}

Measured memory_bytes: 3628
#include<stdio.h>

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);
    int size = A + B + 1;
    
    char str[100];
    scanf("%s", str);
    
    int i, count = 0;
    
    if (str[A] == '-')
    {
        for (i = 0; i < size; i++)
        {
            if (str[i] >= '0' && str[i] <= '9')
            {
                count++;
            }
        }
        
        if (count == size - 1)
        {
            printf("Yes\n");
        }
        
        else
        {
            printf("No\n");
        }
    }
    
    else
    {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1664
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char s[] = scanner.nextLine().toCharArray();
        Map<String, Integer> map = new HashMap<>();
        for (char str : s) {
            if (!map.containsKey(String.valueOf(str))) {
                map.put(String.valueOf(str), Integer.valueOf(1));
            } else {
                Integer count = map.get(String.valueOf(str));
                map.put(String.valueOf(str), count + 1);
            }
        }
        boolean ansflag = true;
        for (Integer count: map.values()) {
            if (count % 2 != 0) {
                ansflag = false;
            }
        }

        if (ansflag) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }

    }
}


Measured memory_bytes: 23124
k=int(input())
def s(n):
    m=str(n)
    l=list(m)
    l=map(int,l)
    return n/sum(l)
p=1
q=0
for i in range(k):
    print(p)
    if s(p+10**q)>s(p+10**(q+1)):
        q+=1
    p+=10**q

Measured memory_bytes: 3188
n = int(input().split()[0])
c = sorted(filter(lambda x:x <= n,map(int,input().split())))

minimum = [ i for i in range(n+1) ]
for i in c:
    minimum[i] = 1

for i in range(2,n+1):
    for j in c:
        if j > i:
            break
        if minimum[i-j] + 1 < minimum[i]:
            minimum[i] = minimum[i-j]+1

print(minimum[n])

Measured memory_bytes: 9636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

template<typename C>
struct Trie {
    struct Node {
        int exist;
        vector<int> accept;
        map<C, int> ch;
        Node() : exist(0) {}  
    };

    vector<Node> node;
    vector<vector<int>> dp;

    Trie() {node.emplace_back();}

    template<typename S>
    void add (const S &A, int id) {
        int cur = 0;
        for (int i = 0; i < (int)A.size(); i++) {
            if (!node[cur].ch.count(A[i])) {
                int nex = node.size();
                node.emplace_back();

                node[cur].ch.emplace(A[i],nex);
            }
            node[cur].exist++;
            cur = node[cur].ch[A[i]];
        }
        node[cur].exist++;
        node[cur].accept.emplace_back(id);
    }

    template<typename S>
    int find(const S &A) {
        int cur = 0;
        for (int i = 0; i < (int)A.size(); i++) {
            if (!node[cur].ch.count(A[i])) return -1;
            cur = node[cur].ch[A[i]];
        }
        return cur;
    }

    int count() const {return node[0].eixst;}

    int size() const {return(int)node.size();}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<string> S(N);
    rep(i,N) {
        cin >> S[i];
        reverse(all(S[i]));
    }
    sort(all(S),[&](string s, string t){return (int)s.size() > (int)t.size();});
    Trie<char> T;
    rep(i,N) T.add(S[i],i);
    int M = T.size();
    vector<vector<int>> cnt(M, vector<int>(26));
    ll ans = 0;
    rep(i,N) {
        int K = S[i].size();
        int cur = 0;
        vector<int> path = {0};
        vector<int> seen(26);
        rep(j,K) {
            if (j==K-1) {
                ans += cnt[cur][S[i].back()-'a'];
            }
            cur = T.node[cur].ch[S[i][j]];
            path.emplace_back(cur);
        }
        for (int j = K-1; j >= 0; j--) {
            seen[S[i][j]-'a'] = 1;
            rep(k,26) cnt[path[j]][k] += seen[k];
        }
    }

    cout << ans << ln;
}

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

using namespace std;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    string* s = &a;
    while (!(*s).empty()) {
        auto ch = (*s)[0];
        (*s).erase(0, 1);
        if (ch == 'a') {
            s = &a;
        } else if (ch == 'b') {
            s = &b;
        } else {
            s = &c;
        }
    }
    cout << (s == &a ? 'A' : (s == &b ? 'B': 'C')) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using namespace std;


int h[1010];


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

	h[1] = 1;
	rep(i, 2, 1000)
		h[i] = h[i-1]+i;

	cout << h[b-a]-b << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;



int main(){

	int D,N;

    cin >> D >> N;

    int b = 1;

    for(int i = 1;i <=D;i++){
    	b*=100;
    }
    

	   if(N < 100){
           cout << b*N << endl;
	   }else if(N == 100){		   
		   cout << b*N + b << endl;
	   }

    return 0;
}


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

const long long int INF = 1e15;

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

    vector<long long int> s(a+2), t(b+2), x(q);
    s[0] = -INF;
    s[a+1] = +INF;
    t[0] = -INF;
    t[b+1] = +INF;
    
    for(int i=1; i<=a; i++){
        cin >> s[i];
    }
    for(int i=1; i<=b; i++){
        cin >> t[i];
    }
    for(int i=0; i<q; i++){
        cin >> x[i];
    }

    for(int i=0; i<q; i++){
        auto sw = lower_bound(s.begin(),s.end(),x[i]) - 1;
        auto tw = lower_bound(t.begin(),t.end(),x[i]) - 1;
        long long int min_distance = INF;
        for(auto j = sw; j <= sw+1; j++){
            for(auto k = tw; k <= tw+1; k++){
                long long int d1 = abs(x[i]-*j) + abs(*j-*k);
                long long int d2 = abs(x[i]-*k) + abs(*k-*j);
                min_distance = min({min_distance, d1, d2});
            }
        }
        cout << min_distance << endl;
    }    
    return 0;
}

Measured memory_bytes: 3712
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
#include <cmath>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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

const int MAX_N = (int)1e5 + 10;

map<pair<int, int>, vector<pair<int,int>>> g;
vector<int> cost;
int s, t;
int n, m;

int main(void)
{
	cin >> n >> m;
	cost.resize(3 * n+3, -1);
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		g[make_pair(u, 0)].emplace_back(make_pair(v, 1));
		g[make_pair(u, 1)].emplace_back(make_pair(v, 2));
		g[make_pair(u, 2)].emplace_back(make_pair(v, 0));
	}
	cin >> s >> t;

	queue<tuple<int, int, int>> q;
	q.emplace(s, 0, 0);
	while (!q.empty()) {
		auto top = q.front(); q.pop();
		int a, b, c;
		tie(a, b, c) = top;
		int index = a * 3 + b;
		if (cost[index] < 0) {
			cost[index] = c;
		}
		else {
			continue;
		}
		for (auto e : g[make_pair(a,b)]) {
			q.emplace(e.first, e.second, c + 1);
		}
	}
	if (cost[3 * t] < 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << cost[3 * t]/3 << endl;
	return 0;
}

Measured memory_bytes: 34176
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let x: usize = read();
    let mut ans = 0;
    for i in 0..a+1 {
        for j in 0..b+1 {
            for k in 0..c+1 {
                if 500 * i + 100 * j + 50 * k == x { ans += 1; }
            }
        }
    }
    println!("{}", ans);
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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


int main(){
    int N; cin >> N;
    int cnt=0;
    bool ans=false;
    for(int i=0; i<N; i++){
        int a, b; cin >> a >> b;
        if(a == b) cnt++;
        else cnt=0;
        if(cnt >= 3) ans=true;
    }
    cout << (ans?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3592
#![allow(non_snake_case)]

use std::f64::consts::PI;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let R = iter.next().unwrap().parse::<f64>().unwrap();

    println!("{} {}", R * R * PI, 2f64 * R * PI);
}



Measured memory_bytes: 5060
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int B=1000;
int p[B*2+5],x;

signed main(){
	for(int i=-B;i<=B;i++)
		p[i+B]=i*i*i*i*i;
	read(x);
	for(int i=-B;i<=B;i++)
		for(int j=-B;j<=B;j++) if(p[i+B]-p[j+B]==x){
			printf("%lld %lld",i,j);
			return 0;
		}
}

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

int main() {
  int N;
  cin >> N;
  if (N % 1111 == 0 || N % 1000 % 111 == 0 || N / 10 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X,Y = map(int,read().split())

"""
from functools import lru_cache
import numpy as np
@lru_cache(None)
def solve_naive(X,Y):
    if X <= 1 and Y <= 1:
        return False
    for i in range(2,X+1,2):
        if not solve_naive(X - i, Y + i//2):
            return True
    for i in range(2,Y+1,2):
        half = i // 2
        if not solve_naive(Y - i, X + i//2):
            return True
    return False
A = np.zeros((16,16),np.int8)
for i in range(16):
    for j in range(16):
        A[i,j] = solve_naive(i,j)
print(A)
"""

if abs(X-Y) in [0,1]:
    print('Brown')
else:
    print('Alice')

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string w;
    cin >> w;
    map<char,int> cnt;
    for (char i = 'a'; i <= 'z'; i++){
        cnt[i] = 0;
    }
    for (int i = 0; i < (int)w.size(); i++){
        cnt[w[i]]++;
    }

    bool ok = true;
    for (char i = 'a'; i <= 'z'; ++i) {
        if (cnt[i] % 2 != 0){
            ok = false;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 317847191;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 1000005;
const int MAXV = 10000005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int arr[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int T = read<int>();
    printf("%d\n", T + T * T + T * T * T);
    return 0;
}

Measured memory_bytes: 3748
#include <set>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#define MAXN 10010
#define LL long long
#define INF 0x7fffffff
using namespace std;

int main(){
	int x,t;
	cin>>x>>t;
	if (t>x) cout<<0<<endl;
	else cout<<x-t<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   // Your code here!
   int a,b,c;
   cin>>a>>b>>c;
   if (a==5&&b==7&&c==5) cout<<"YES"<<endl;
   else if (a==5&&b==5&&c==7) cout<<"YES"<<endl;
   else if (a==7&&b==5&&c==5) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
a=input()
b=input()
if len(a)>len(b):
    print('GREATER')
elif len(a)<len(b):
    print('LESS')
else:
    n=len(a)
    for i in range(n):
        if a[i]<b[i]:
            print('LESS')
            exit()
        if a[i]>b[i]:
            print('GREATER')
            exit()
    print('EQUAL')

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

int main(){
  int T[101][101], r, c;
 
  cin >> r >> c;  
  for ( int i = 0; i < r; i++ )
   for ( int j = 0; j < c; j++ ) cin >> T[i][j];

  for ( int i = 0; i <= r; i++ ) T[i][c] = 0;
  for ( int j = 0; j <= c; j++ ) T[r][j] = 0;

  for ( int i = 0; i < r; i++ ){
    for ( int j = 0; j < c; j++ ){
       T[i][c] += T[i][j];
       T[r][j] += T[i][j];
       T[r][c] += T[i][j];
    }
  }

  for ( int i = 0; i <= r; i++ ){
    for ( int j = 0; j <= c; j++ ){
      if (j) cout << " ";
      cout << T[i][j];
    }
    cout << endl;
  }

 return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
bool a[N],flag=1;
int f[N],g[N];

signed main()
{
	int n=0,ans=0;
	char c=getchar();
	while ('0'<=c&&c<='1')
	{
		a[++n]=c-'0';
		c=getchar();
	}
	for (int i=1;i<=n;i++) f[i]=f[i-1]+!a[i];
	for (int i=n;i>=1;i--) g[i]=g[i+1]+!a[i];
	for (int i=1;i<=n;i++)
	if (a[i]) ans+=(f[i]+1+(i&1))/2+flag*g[i],flag^=1;
		 else flag=1;
	int tot=n-f[n]-1;
	print(ans+(1+tot/2)*(tot/2)+(tot&1?(tot+1)/2:0));

	return 0;
}

Measured memory_bytes: 6928
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_map>
#define rep(i,n) for( int i = 0; i < n; i++)
using namespace std;
using ll = long long;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
ll u18 = 1000000000000000000;
int main()
{
    
	int n ;
  cin >> n ;
	string s[n];
  rep(i,n) cin >> s[i] ;
	
	unordered_map< string, int > mp;
  
  rep(i,n){
		mp[s[i]]++;
	}	
	
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	
   
  return 0;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
typedef pair<int, int> P;
 
P data[40];
int cnt[11];
int main(){
  int m, a, b, c, score;
  while(cin >> m && m){
    rep(i, m){
      score = 0;
 
      fill(cnt, cnt + 10, 0);
      cin >> data[i].second;
      rep(j, 10){
    cin >> a;
    score += a;
    rep(k, 10) if(cnt[k] > 0){
      cnt[k]--;
      score += a;
    }
 
    if(a == 10){
 
      if(j != 9)cnt[j]+=2;
      else{
        cin >> b >> c;
        score += b + c;
        rep(k, 10)if(cnt[k]){
          cnt[k]--;
          score += b;
        }
      }
       
    }else{
 
      cin >> b;
      score += b;
      rep(k, 10) if(cnt[k] > 0){
        cnt[k]--;
        score += b;
      }
      if(a + b == 10){
        if(j != 9)cnt[j]++;
        else{
          cin >> c;
          score += c;
        }
      }
    }
      }
      data[i].first = -score;
    }
    sort(data, data + m);
    rep(i, m){
      cout << data[i].second << " " << -data[i].first << endl;
    }
  }
  return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define form(i,x,N) for(int i=x;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using umap=unordered_map<int,int>;
using uset=unordered_set<int>;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int a[10];
forn(i,3) {
  int x;
  cin>>x;
  a[x]++;
}
if(a[5]==2 and a[7]==1)
  cout<<"YES"<<endl;
else
  cout<<"NO"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
 
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()

int main(void)
{
  ll N;
  ll ans;

  cin >> N;
  
  vector<ll> A(N+1);
  rep(i,N+1) cin >> A[i];
  vector<ll> B(N);
  rep(i,N) cin >> B[i];
  
  ans = 0;
  if(A[0]-B[0]>0){
    ans += B[0];
    A[0] -= B[0];
    B[0] = 0;
  }else{
    ans += A[0];
    B[0] -= A[0];
    A[0] = 0;
  }
  if(A[1]-B[0]>0){
    ans += B[0];
    A[1] -= B[0];
    B[0] = 0;
  }else{
    ans += A[1];
    B[0] -= A[1];
    A[1] = 0;
  }

  rep2(i,1,N){
    if(A[i]-B[i]>0){
      ans += B[i];
      A[i] -= B[i];
      B[i] = 0;
    }else{
      ans += A[i];
      B[i] -= A[i];
      A[i] = 0;
    }
    if(A[i+1]-B[i]>0){
      ans += B[i];
      A[i+1] -= B[i];
      B[i] = 0;
    }else{
      ans += A[i+1];
      B[i] -= A[i+1];
      A[i+1] = 0;
    }
  }

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


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
#define debug(output) cout<<#output<<"= "<<output<<endl
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;

void solve(){
    lint n,m,a,b;cin>>n>>m>>a>>b;
    lint res=floor_sum(n,m,a,b);
    cout<<res<<"\n";
}
signed main(){
  int t;cin>>t;
  rep(i,t)solve();
  return 0;
}

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

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = min(a, b); i >= 1; --i) {
		if (a % i == 0 && b % i == 0) k--;
		if (k == 0) {
			cout << i;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n+2),b(n+2);
	FOR(i,1,n+1){
		cin>>a[i];
	}
	bool flag=true;
	priority_queue<P> que;
	FOR(i,1,n+1){
		cin>>b[i];
		if(b[i]<a[i]){
			flag=false;
		}
		if(b[i]!=a[i]) que.push(P(b[i],i));
	}
	if(!flag){
		cout<<-1<<endl;
		return 0;
	}
	b[0]=b[n],b[n+1]=b[1];
	ll ans=0;
	while(!que.empty()){
		auto [num,ind]=que.top();
		que.pop();
		ll diff=b[ind-1]+b[ind+1];
		if(b[ind]<=diff){
			cout<<-1<<endl;
			return 0;
		}
		if((b[ind]-a[ind])%diff){
			ans+=b[ind]/diff;
			b[ind]%=diff;
            if(b[ind]<a[ind]){
                cout<<-1<<endl;
                return 0;
            }
			que.push(P(b[ind],ind));
		}else{
			ans+=(b[ind]-a[ind])/diff;
			b[ind]=a[ind];
		}
		b[0]=b[n],b[n+1]=b[1];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 10504
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int a=0;
	for(int i=0;i<s.size();++i){
		if(s[i]!=t[i])++a;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[8] = {}, b[3] = {}, z = 890328;
    cin >> n >> b[0] >> b[1] >> b[2];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(b, b + 3);
    for (int i = 1; i < (1 << n); i++) for (int j = 1; j < (1 << n); j++) for (int k = 1; k < (1 << n); k++) if ((i & j) == 0 && (j & k) == 0 && (k & i) == 0) {
        int d[3] = {}, e[3] = {};
        for (int l = 0; l < n; l++) {
            if (i & (1 << l)) d[0] += a[l], e[0]++;
            if (j & (1 << l)) d[1] += a[l], e[1]++;
            if (k & (1 << l)) d[2] += a[l], e[2]++;
        }
        sort(e, e + 3);
        z = min(z, (e[0] + e[1] + e[2] - 3) * 10 + abs(b[0] - d[0]) + abs(b[1] - d[1]) + abs(b[2] - d[2]));
    }
    cout << z;
}


Measured memory_bytes: 256
S = input()
month_list = ['0' + str(ii) for ii in range(1, 10)]
month_list.extend(['10', '11', '12'])

if S[:2] in month_list:
    if S[2:4] in month_list:
        print("AMBIGUOUS")
    else:
        print('MMYY')
else:
    if S[2:4] in month_list:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include<stdio.h>
#define INFTY 2000000000
typedef struct node{
  char mark;
  int num;
}C;

int n;

void merge(C A[], int left, int mid, int right){
  int n1 = mid - left ,n2 = right - mid,i,j,k;
  C L[n1+1],R[n2+1];
  for(i = 0; i < n1; i++) L[i] = A[left + i];
  for(i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1].num =  INFTY;
  R[n2].num =  INFTY;
  i = 0; j = 0;
  for(k = left; k < right; k++){
    if(L[i].num <= R[j].num){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(C A[],int left, int right){
  int mid;
  if (left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(C A[],int p,int r){
  int i,j;
  C x,numb;
  x = A[r];
  i = p-1;
  for(j = p; j < r;j++){
    if(A[j].num <= x.num){
      i = i+1;
      numb = A[i];
      A[i] = A[j];
      A[j] = numb;
    }
  }
  numb = A[i+1];
  A[i+1] = A[r];
  A[r] = numb;
  return i + 1;
}

void quicksort(C A[],int p,int r){
  int q;
  if(p < r){
    q = partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}

int main(){
  int i,nu,stable = 0;
  C A[100000],B[100000];
  char P;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf(" %c %d",&P,&nu);
    A[i].mark = P;
    B[i].mark = P;
    A[i].num = nu;
    B[i].num = nu;
  }
  mergeSort(A,0,n);
  quicksort(B,0,n-1);

  for(i = 0; i < n; i++){
    if(A[i].mark != B[i].mark) stable = 1;
  }

  if(stable == 0) printf("Stable\n");
  else printf("Not stable\n");

  for(i = 0; i < n; i++){
    printf("%c %d\n",B[i].mark,B[i].num);
  }
  return 0;
}



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

using namespace std;
using ll = long long;

int main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << ((double)W * (double)H / 2.0) << " " << (x * 2 == W && y * 2 == H ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
int pr(int n)
{
 for(int i=2;i*i<=n;i++)
      {
          if(n%i==0)
          return 0;
      }
      return 1;
}
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {
      int n;
      cin>>n;
      int sum=0;
      for(int i=1;i<=n;i++)
      {
          if(i%3==0 ||i%5==0)
          continue;
          else
          sum+=i;
      }
      cout<<sum;
    }
    
}
// 🍪 🍪 🍪


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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 r, D, x2000;
  cin >> r >> D >> x2000;
  i64 prev = x2000;
  repi(i, 2001, 2011) {
    prev = r * prev - D;
    cout << prev << '\n';
  }
}


Measured memory_bytes: 256
s=input()
l=[]
tmp=0
tmps="R"
for i in s:
    if i==tmps:
        tmp+=1
    else:
        l.append(tmp)
        tmps=i
        tmp=1
l.append(tmp)
n=len(l)//2
ans=[]
for i in range(n):
    nr=l[2*i]
    nl=l[2*i+1]
    for j in range(nr-1):
        ans.append(0)
    if (nr+nl)%2==0:
        ans.append((nr+nl)//2)
        ans.append((nr+nl)//2)
    elif nr%2==0:
        if nr>nl:
            ans.append((nr+nl)//2)
            ans.append((nr+nl)//2+1)
        else:
            ans.append((nr+nl)//2)
            ans.append((nr+nl)//2+1)
    else:
        if nr>nl:
            ans.append((nr+nl)//2+1)
            ans.append((nr+nl)//2)
        else:
            ans.append((nr+nl)//2+1)
            ans.append((nr+nl)//2)
    for j in range(nl-1):
        ans.append(0)
print(*ans)

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

const int mod=1e9+7;

void mul(int &a,int b)
{
    a=(a*b)%mod;
}

signed main()
{
    int N; cin>>N;
    vector<pair<int,bool> > v(2*N);
    for(int i=0;i<N;i++){
        int a; cin>>a;
        v[i]=make_pair(a,0);
    }
    for(int i=0;i<N;i++){
        int b; cin>>b;
        v[N+i]=make_pair(b,1);
    }
    sort(v.begin(),v.end());
/*
    for(auto p:v){
        cout<<p.first<<' '<<p.second<<endl;
    }
*/
    int cnt=0,flag=-1;
    int ans=1;
    for(auto p:v){
        if(cnt==0){
            cnt++;
            flag=p.second;
            continue;
        }
        if(p.second==flag){
            cnt++;
        }else{
            mul(ans,cnt);
            cnt--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
a, b, c, x, y = gets.split.map(&:to_i)

if a + b <= c * 2
  puts a * x + b * y
  exit
end

if x == y
  puts c * x * 2
  exit
elsif x > y
  rest = x - y
  ans = c * y * 2
  ans += [a * rest, c * rest * 2].min
  puts ans
else
  rest = y - x
  ans = c * x * 2
  ans += [b * rest, c * rest * 2].min
  puts ans
end


Measured memory_bytes: 14416
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int gcd(int a,int b);
int compare(const void* a, const void* b);

int main(void){
    char S[4];
    scanf("%s",S);
    if (S[1]=='B'){
        printf("ARC\n");
    }else{
        printf("ABC\n");
    }
    return 0;
}
int compare(const void* a, const void* b){
    return strcmp(a, b);
}
// 最大公約数
int gcd(int a,int b){
    int c;
    int tmp;
    if(b > a){  //bがaより大きい場合bとaを入れ替える
        c = a;
        a = b;
        b = c;
    }
    tmp = a % b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a % b;
    }
    return b;
}


Measured memory_bytes: 1644