akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<assert.h>
#include<set>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<bitset>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define per(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
using namespace std;
typedef long long LL;
//template
typedef double db;
const db eps=1e-10;
const db pi=acosl(-1.0);
int sign(db x){if(x<-eps)return -1;if(x>eps)return 1;return 0;}
int cmp(db x,db y){return sign(x-y);}
bool inmid(db x,db l,db r){return cmp(x,l)*cmp(x,r)<=0;}
struct po{
	db x,y;
	po(db _x=0,db _y=0):x(_x),y(_y){}
	void read(){scanf("%lf%lf",&x,&y);}
};
po operator +(const po &a,const po &b){return po(a.x+b.x,a.y+b.y);}
po operator -(const po &a,const po &b){return po(a.x-b.x,a.y-b.y);}
po operator *(const po &a,const db &b){return po(a.x*b,a.y*b);}
po operator /(const po &a,const db &b){return po(a.x/b,a.y/b);}
db operator *(const po &a,const po &b){return a.x*b.x+a.y*b.y;}
db operator ^(const po &a,const po &b){return a.x*b.y-a.y*b.x;}
db mo2(po a){return a*a;}
db mo(po a){return sqrt(a*a);}
po proj(po x,po y){//proj x to y
	return y*((x*y)/mo2(y));
}
po refl(po x,po y){//refl x from y
	return proj(x,y)*2-x;
}
bool onseg(po x,po l,po r){
	return (sign((x-l)^(r-l))==0)&&inmid(x.x,l.x,r.x)&&inmid(x.y,l.y,r.y);
}
bool inter(db l1,db r1,db l2,db r2){
	if(cmp(l1,r1)==1)swap(l1,r1);
	if(cmp(l2,r2)==1)swap(l2,r2);
	return cmp(min(r1,r2),max(l1,l2))>=0;
}
bool checkss(po a,po b,po c,po d){
	return sign((b-a)^(c-a))*sign((b-a)^(d-a))<=0&&sign((d-c)^(a-c))*sign((d-c)^(b-c))<=0&&inter(a.x,b.x,c.x,d.x)&&inter(a.y,b.y,c.y,d.y);
}
//template
int main(){
	int t;scanf("%d",&t);
	while(t--){
		po a,b,c,d;
		a.read();b.read();c.read();d.read();
		if(checkss(a,b,c,d))puts("1");else puts("0");
	}
	return 0;
}






Measured memory_bytes: 3236
from itertools import product

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

for y, x in product(range(H), range(W)):
    if S[y][x] == "#":
        continue

    count = 0
    for i, j in product((-1, 0, 1), repeat=2):
        if not (0 <= y + i < H and 0 <= x + j < W):
            continue
        if S[y + i][x + j] == "#":
            count += 1
    S[y][x] = str(count)

print("\n".join("".join(r) for r in S))

Measured memory_bytes: 9220
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        int cnt = 1;
        for (int i = 1; i < N; i++) {
            boolean flag = true;
            for (int j = 0; j < i; j++) {
                if (a[j] > a[i]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cnt++;
            }
        }

        out.println(cnt);
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
//#define ll long long
long long int dp[100005][105];
//int val[100005];
//int wt[100005];
  long long int fun(long long int w,long long int n,long long int val[],long long int wt[])
  {
      if(w==0||n==0)
       return 0;
       
      if(wt[n-1]>w)
          return dp[w][n]=fun(w,n-1,val,wt);
      if(dp[w][n]!=-1)
         return dp[w][n];
     
         return dp[w][n]= max(fun(w-wt[n-1],n-1,val,wt)+val[n-1],fun(w,n-1,val,wt));
      

  }

int main()
{
   
	
  long long int n,w;
  cin>>n>>w;
  memset(dp,-1,sizeof(dp));
  long long int val[n+1];
  long long int wt[n+1];
  for(long long int i=0;i<n;i++)
  {
      cin>> wt[i];
      cin>> val[i];
  }
  cout<< fun(w,n,val,wt);
}


   


Measured memory_bytes: 82304
# https://www.youtube.com/watch?v=eB0eT-948Vw

# 一部の自明なケースを除くと、ループする
# [(C+1)-B,C+(D-B)]
# この範囲に0未満の値があって、取ることが可能ならNoである

# 2つの変化(-B),(D-B)は、まとめて-B(mod D)と捉える
# ループ区間で、
# g=gcd(D,B)を法として、
# Aと合同なXは、すべて取ることができる(らしい)

# 0未満の値を取れるならNoである
# gを法として、Aと合同なXのうち、0以上の最小値は、
# A%gと表せるので、
# gを法として、Aと合同なXのうち、0未満の最大値は、
# (A%g)-gである
# [(C+1)-B,0)に(A%g)-gが含まれるならNoである

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def judge(A, B, C, D):
    """A:初期値,B:減少量,C以下で増加,D増加量"""
    if (B > A) or (B > D):
        # 減る
        # 初回購入できない/増加が追い付かない
        return False

    if B <= C:
        # 増える
        # C以下の値は一度に削りきらないと増加してしまうが、削り切れない
        return True

    # ループ
    # (C < B) and (B <= A) and (B <= D)
    g = gcd(B, D)
    a = A % g
    return a - g < C + 1 - B
    # ループ範囲は、C+1-B以上なので、
    # gを法として、Aと合同な値のうち、0未満で最大の値a-gが
    # C+1-B未満なら、ループ範囲に0未満の値は含まれず、無限にジュースを飲める


T = int(input())
for _ in range(T):
    bl = judge(*map(int, input().split()))
    print('Yes' if bl else 'No')
    

Measured memory_bytes: 3060
n = gets.to_i
S = gets.split(" ").map(&:to_i)
q = gets.to_i
T = gets.split(" ").map(&:to_i)
@count = 0

def binary_search(arr,n, target)
  left = 0
  right = n
  while(left < right)
    md = (left + right) / 2
    if(arr[md] == target)
      @count += 1
      return
    elsif arr[md] < target
      left = md + 1
    else
      right = md
    end
  end
end

T.each do |target|
  binary_search(S.dup, n, target)
end

puts @count



Measured memory_bytes: 17324
import sys

S = input()
odd = ["R", "U", "D"]
even = ["L", "U", "D"]

for i, c in enumerate(S):
    if i % 2 == 0:
        if not c in odd:
            print('No')
            sys.exit()
    else:
        if not c in even:
            print('No')
            sys.exit()

print('Yes')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int a[223456], N, K;

map<LL, int> mapa;

int bit[523456];

int get(int idx) {
	int ret = 0;
	while (idx > 0) {
		ret += bit[idx];
		idx -= idx & (-idx);
	}
	return ret;
}

void update(int idx) {
	while (idx <= N + 1) {
		bit[idx]++;
		idx += idx & (-idx);
	}
}

int main() {
	scanf("%d %d", &N, &K);
	FOR (i, N)
		scanf("%d", &a[i]);
	FOR (i, N)
		a[i] -= K;

	vector<LL> sums;
	LL sum = 0LL;
	sums.pb(0LL);
	FOR (i, N) {
		sum += a[i];
		sums.pb(sum);
	}
	sort(all(sums));
	mapa.clear();
	int cnt = 1;
	FOR (i, sums.sz)
		if (i == 0 || sums[i] != sums[i - 1]) {
			mapa[sums[i]] = cnt;
			cnt++;
		}

	SET(bit, 0);
	LL ret = 0LL;
	sum = 0;
	update(mapa[0LL]);
	FOR (i, N) {
		sum += a[i];
		ret += get(mapa[sum]);
		update(mapa[sum]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 17136
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
ll lcm(ll a,ll b){
	ll x = max(a,b);
	ll y = min(a,b);
	while(x % y != 0){
		ll t = x % y;
		x = y;
		y = t;
	}
	return a*b/y;
}

int main()
{
	ll N,M;
	cin>>N>>M;
	vector<ll> a(N);
	vector<ll> ord(N,0);
	for(ll i = 0; i < N; i++){
		cin>>a[i];
		ll k = a[i];
		while(k % 2 ==0){
			k /= 2;
			ord[i]++;
		}
		if(ord[i] != ord[0]){
			cout<<0<<endl;
			return 0;
		}
	}
	ll nLCM = 1;
	for(ll i = 0; i < N; i++){
		nLCM = lcm(nLCM,a[i]);
		if(nLCM > 2*M){
			cout<<0<<endl;
			return 0;
		}
	}
	ll halfLCM = nLCM / 2;
	cout<< (M/halfLCM) - (M/nLCM)<<endl;
	return 0;
}


Measured memory_bytes: 4436
f = lambda: map(int,input().split())

n,m = f()
s = [[] for _ in range(n)]
for _ in range(m):
    a, b = f()
    a-=1; b-=1
    s[a].append(b); s[b].append(a)
for i in s[0]:
    if n-1 in s[i]:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)
int main(){
	int n;
	cin >> n;
	int g[n];
	int sum = 0;
	for(int i = 0; i < n; i++){
		cin >> g[i];
		sum += g[i];
	}
	int left = 0;
	int ans = 99999;
	for(int i = 0; i < n; i++){
		left += g[i];
		ans = min(ans,abs(sum-left-left));
	}
	cout << ans << endl;
	return 0;
}

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

w = [int(i) for i in input().split()]

min_abs = 10**9
for i in range(1,len(w)+1):
    s1 = sum(w[:i])
    s2 = sum(w[i:])
    min_abs = min(abs(s1 - s2), min_abs)
print(min_abs)

Measured memory_bytes: 3060
#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 repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(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 bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
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; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
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 exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

using BS = bitset<25601>;

void solve() {
  int h, w;
  cin >> h >> w;
  vector<vi32> a(h, vi32(w));
  vector<vi32> b(h, vi32(w));
  cin >> a >> b;
  
  vector<vi32> c(h, vi32(w));
  rep(i, h) rep(j, w) c[i][j] = abs(a[i][j] - b[i][j]);

  vector<vector<BS>> dp(h + 1, vector<BS>(w));

  dp[0][0] = BS().set(12800 + c[0][0]);
  rep(i, h) rep(j, w) {
    if (i < h - 1) {
      dp[i + 1][j] |= dp[i][j] << c[i + 1][j];
      dp[i + 1][j] |= dp[i][j] >> c[i + 1][j];
    }
    if (j < w - 1) {
      dp[i][j + 1] |= dp[i][j] << c[i][j + 1];
      dp[i][j + 1] |= dp[i][j] >> c[i][j + 1];
    }
  }
  int ans = 1e9;
  repc(i, 25600) if (dp[h - 1][w - 1].test(i)) {
    amin(ans, abs(i - 12800));
  }
  cout << ans << endl;
}


Measured memory_bytes: 20992
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <string>

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORN(i, n, s) for (int i = s; i < n; i++)
#define OUT(s) cout << s << endl;
#define IN(a) cin >> a;
#define PACK(a, n) \
  for (int i = 0; i < n; i++) cin >> a[i];
#define PACKN(a, n, s) \
  for (int i = s; i < n; i++) cin >> a[i];
#define LIST(a, n) \
  for (int i = 0; i < n; i++) cout << "[" << i << "] " << a[i] << endl;

using namespace std;

int main() {
  int N, M, X, Y;
  IN(N >> M >> X >> Y);
  int x[N];
  PACK(x, N);
  int y[M];
  PACK(y, M);
  int xMax = x[0];
  FOR(i, N) {
    if (x[i] > xMax) xMax = x[i];
  }
  int yMin = y[0];
  FOR(i, M) {
    if (y[i] < yMin) yMin = y[i];
  }
  if (xMax < yMin && X < yMin && Y > xMax && X < Y) {
    OUT("No War");
  } else {
    OUT("War");
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


  int index = 0;
  int count = 1;
  string preS = "";
  int ans = 0;
  while(index + count <= S.size())
  {
    string s = S.substr(index, count);
    if(preS == s)
    {
	    count++;
    }else{
      preS = s;
      index += count;
      count = 1;
      ans++;
//      cout << s << endl;
    }
  }
  cout << ans << endl;

  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll K;
ll A[101010],B[101010];
int NG[101010];

ll ok(int D) {
	int i;
	if(D<0) {
		ll low=0;
		FOR(i,N) if(NG[i]==0) low+=B[i];
		return low;
	}
	if(K&(1<<D)) {
		ll low=0;
		FOR(i,N) if(NG[i]==0 && ((A[i]&(1<<D))==0)) low+=B[i];
		return max(low,ok(D-1));
	}
	else {
		FOR(i,N) if((A[i]&(1<<D))) NG[i]=1;
		return ok(D-1);
	}
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i]>>B[i];
	cout<<ok(30)<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
int main()
{
	int m,d,dl[11]={31,29,31,30,31,30,31,31,30,31,30};
	int y=2;
	char yb[][10]={
		"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"
	};
	while(1){
		y=2;
		scanf("%d%d",&m,&d);
		if(m==0){
			break;
		}
		if(m!=1){
			for(int i=2;i<=m;i++){
				y+=dl[i-2];
			}
		}
		y+=d;
		printf("%s\n",yb[y%7]);
	}
	return 0;
}

Measured memory_bytes: 2496
#include<stdio.h>

int main() {
	int x, a, b ,c;
	int count = 0;

	scanf("%d %d %d", &a, &b, &c);
	for (x = a; x <= b; x++) {
		if (c < x) break;
		if (c % x == 0) count++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 2148
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>

using namespace std;
int main() {
	int N;
	cin >> N;
	vector<string>w(N);
	set<string>sw;

	for (auto& e : w) {
		cin >> e;
		sw.insert(e);
	}

	char c;
	bool ans = true;
	c = w[0][w[0].size()-1];

	for (int i = 1; i < N; ++i) {
		if (c != w[i][0]) {
			ans = false;
			break;
		}
		else c = w[i][w[i].size() - 1];
	}

	if (!ans||sw.size() != N)cout << "No";
	else cout << "Yes";
	cout << endl;

	return 0;
}


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

bool jud(int a) {
	bool elf = false;
	for (int i = 1; i * i <= a; ++i) {
		if (i * i == a)elf = true;
	}
	return elf;
}

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	rep(i, n)rep(j, d) cin >> x[i][j];
	int ans = 0;
	rep(i, n - 1)for (int j = i + 1; j < n; ++j) {
		int tmp = 0;
		rep(k, d) {
			tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
		}
		if (jud(tmp)) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b;
  cin >> a >> b;
  if (a == 0 || b == 0 || a < 0 && b > 0)
    cout << "Zero" << endl;
  else
  {
    if (a > 0)
      cout << "Positive" << endl;
    else
    {
      ll cnt = b - a + 1;
      if (cnt % 2 == 0)
        cout << "Positive" << endl;
      else
        cout << "Negative" << endl;
    }
  }
  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  for(ll i=0;i<n;i++) {
    cin >> b[i];
  }
  for(ll i=0;i<n;i++) {
    cin >> c[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  vector<ll> bsum(n);
  for(ll i=0;i<n;i++) {
    ll ok=upper_bound(c.begin(),c.end(),b[i])-c.begin();
    bsum[i]=n-ok;
  }
  for(ll i=n-2;i>-1;i--) {
    bsum[i]+=bsum[i+1];
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ll ok=upper_bound(b.begin(),b.end(),a[i])-b.begin();
    if(ok==n) continue;
    ans+=bsum[ok];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            string s,s2;
            cin>>s>>s2;
            int ans=0,i;
            for(i=0;i<3;++i)
                if(s[i]==s2[i])
                    ++ans;
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A1,A2,A3,sum;
    scanf("%d%d%d",&A1,&A2,&A3);
    sum=A1+A2+A3;

    if(sum>=22)
    {
        printf("bust");
    }
    else
    {
        printf("win");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	int n,a,b,passed,b_rank;
	string s;

	cin>>n>>a>>b;
	cin>>s;

	
	b_rank=0;
	passed=0;
	for(auto& letter:s){
		if(passed < a+b){
			if(letter=='a'){
				passed++;
				cout<<"Yes\n";
				}	
			else if(letter=='b'){
				b_rank++;
				if(b_rank <= b){
					passed++;
					cout<<"Yes\n";
				}
				else
					cout<<"No\n";
			}
			else
				cout<<"No\n";
		}
		else
			cout<<"No\n";
	}

	return 0;

}

Measured memory_bytes: 3760
integer N
read*,N
do i=1,N-1
  do j=i+1,N
    do k=1,10
      if(BTEST(i,k-1).neqv.BTEST(j,k-1))then
        write(*,"(i0)",advance="no") k
        if(j/=N)write(*,"(A)",advance="no") " "
        exit
      endif
    end do
  end do
  write(*,*)
end do
end

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long k;
long long a[50];
int main() {
    cin >> k;
    /*if (k == 0) {
        cout << 1 << '\n';
        cout << 0;
        return 0;
    }*/
    //x + n ... x + n - a
    //x ... x - b
    //2n - a - 1  a
    //n - a - 1 b
    //a + n * (x - (n - a - 1)) = k;
    cout << 50 << '\n';
    long long a = (k % 50);
    long long x = (k / 50) + (50 - a - 1);
    for (int i = 0; i < a; i++) {
        cout << x + 50 << " ";
        //a[i] = x + 50;
    }
    for (int i = a; i < 50; i++) {
        cout << x << " ";
        //a[i] = x;
    }
    return 0;
}


Measured memory_bytes: 256
import heapq

N, M = [int(_) for _ in input().split()]
ABs = [[] for _ in range(M + 1)]
r = 0

for i in range(N):
    A, B = [int(x) for x in input().split()]
    if A <= M:
        ABs[A].append(-B)

q = []

for m in range(1, M + 1):
    if ABs[m] != 0:
        for b in ABs[m]:
            heapq.heappush(q, b)

    if len(q) != 0:
        r -= heapq.heappop(q)

print(r)


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n, k;
    cin >> n >> k;
    v_int v(n);
    cin >> v;    

    ll ans = 0;
    irep(a, k+1) {
        irep(b, k+1) {
            v_int u;
            ll sum = 0;
            if(a + b <= min(n, k)) {
                irep(i, a) { u.push_back(v[i]); sum += v[i]; }
                irep(i, b) { u.push_back(v[n-i-1]); sum += v[n-i-1]; }
            }

            sort(u.begin(), u.end());
            //cout << u << endl; 

            int cnt = max(0, k - a - b);
            irep(i, u.size()) {
                if(u[i] < 0 && cnt > 0) {
                    sum -= u[i];
                    cnt--;
                }
            }
            chmax(ans, sum);
        } 
    }
    
    cout << ans << endl;
    
    return 0;
} /*atcoder*/


Measured memory_bytes: 3624
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    using namespace std;
    int main() {
        int d;
        cin >> d ;
        if(d == 7 || d == 5 || d == 3){
            cout << "YES" << endl;
        }else cout << "NO" << endl;
    }

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

int swap(int& a, int& b) {
    int t;
    t = a;
    a = b;
    b = t;

    return 0;
}

int main()
{
    int n;
    cin >> n;
    int val[100];
    
    for (int i = 0; i < n; i++) {
        cin >> val[i];
    }

    for (int j = 0; j < n / 2; j++) {
        swap(val[j], val[n-1-j]);       
    }
    for (int x = 0; x < n-1; x++) {
        cout << val[x] << " ";
    }
    cout << val[n-1];

    cout << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll rec[2000][2000];
vector<VVP> DAG;

ll dfs(PL p){
    ll ret = 0;
    if(rec[p.first][p.second] != -1) return rec[p.first][p.second];
    for(auto g : DAG[p.first][p.second]){
        ret = max(dfs(g), ret);
    }
    rec[p.first][p.second] = ret + 1;
    return ret + 1;
}

int main(){
    ll N;
    cin >> N;
    VVL A(N+1, VL(N-1));
    rep(i, 1, N+1){
        rep(j, 0, N-1) cin >> A[i][j];
    }

    DAG.resize(N+1, VVP(N+1));
    VVL h(N+1, VL(N+1, 0));
    rep(i, 1, N+1){
        rep(j, 0, N-2){
            DAG[min(i, A[i][j])][max(i, A[i][j])].push_back({min(i, A[i][j+1]),max(i, A[i][j+1])});
            h[min(i, A[i][j+1])][max(i, A[i][j+1])]++;
        }
    }
    
    queue<PL> que;
    stack<PL> st;
    rep(i, 1, N){
        rep(j, i+1, N+1){
            if(h[i][j] == 0){
                st.push({i,j});
                que.push({i,j});
            }
        }
    }
    
    vector<PL> tps;
    while(!st.empty()){
        auto s = st.top();
        st.pop();
        tps.push_back(s);
        for(auto j : DAG[s.first][s.second]){
            h[j.first][j.second]--;
            if(h[j.first][j.second] == 0){
                st.push(j);
            }
        }
    }

    ll v = N*(N-1)/2;
    cerr << v << "," << tps.size() << endl;
    if(tps.size() != v){
        cout << -1 << endl;
        return 0;
    }

    rep(i, 0, 2000){
        rep(j, 0, 2000) rec[i][j] = -1;
    }

    ll ans = 0;
    while(!que.empty()){
        auto q = que.front();
        que.pop();
        ans = max(ans, dfs(q));
    }
    
    cout << ans << endl;
    return 0;
}

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

int ans;
int a[50], b[50], c[50], d[50];
int n, m, q;

void dfs(vector<int> A) {
    if (A.size() == n + 1) {
        int now = 0;
        rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    dfs(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
A,B,C,X=[int(input()) for i in range(4)]
cnt = 0
for a in range(0,A+1):
    Y = X - 500*a
    if Y==0:
        cnt += 1
        break
    elif Y<0:
        break
    for b in range(0,B+1):
        Z = Y - 100*b
        if Z==0:
            cnt += 1
            break
        elif Z<0:
            break
        for c in range(0,C+1):
            W = Z - 50*c
            if W == 0:
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
//http://acm-icpc.aitea.net/index.php?plugin=attach&refer=2009%2FPractice%2F%E6%A8%A1%E6%93%AC%E5%9C%B0%E5%8C%BA%E4%BA%88%E9%81%B8%2F%E8%AC%9B%E8%A9%95&openfile=b.pdf

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	while(1){
		int n, d;//n country  d limit
		cin >> n >> d;
		if(n == 0 && d == 0) return 0;

		vector<pair<int, int> > inf(n);//fi ???????????????????????????????¨????se????¬?????????????????????¨?????§???????????????????????????
		rep(i, n) inf[i].fi = 0;//?????????
		rep(i, n) inf[i].se = 0;//?????????
		vector<vector<int> > misairu(n);//misairu[i][]??????i???????????????????????\???

		rep(i, n){
			int m; scanf("%d", &m);
			misairu[i].resize(m);
			for (int j = m - 1; j >= 0 ; --j){//?????????????????????????????????????????????????????§??????????????\??????
				int c; scanf("%d", &c);
				misairu[i][j] = c;
				inf[i].fi += c;//??????????????????????????\????????????
			}
		}

		//??§?¬????
		while(1){
			bool endflag = false;
			int cntflag = 0;
			rep(j, n){
				int size = misairu[j].size() - inf[j].se;//j???????????¨?????????????????????????????£????????????

				if(size <= 0) continue;
				int now = inf[j].se;//???????¶?????????¨?????§???????????????????????????
				int tikara = misairu[j][now];//????????¨??????????????¨????????????????????????????¨????
				int tmp = inf[j].fi;//????¨?????????????????????????
				inf[j].fi -= tikara;//??????????????????????????????????¨???????????¨????
				//?????§?????¨????°?????????¢???
				int dai = -1, syou = 10000000;
				rep(k, n){
					dai = max(dai, inf[k].fi);
					syou = min(syou, inf[k].fi);
				}

				if(dai - syou > d){//??????????¨?????????§???????????¨?°????????????????????????????d????¶???????????????????????????§??????
					inf[j].fi = tmp;//?????????????????????
					cntflag++;
					if(j == n - 1 && cntflag == n){
						printf("No\n");
						endflag = true;
						break;
					}  
				}else{
					inf[j].se++;
				}
				//?????????????????????????????????????????????????¨????????¨????
				int sum = 0;
				rep(j, n) sum += inf[j].fi;
				if(sum == 0){
					printf("Yes\n");
					endflag = true;
					break;
				}
			}
			if(endflag == true) break;
		}
	}
	return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	int count;
	count = 0;
	for (int i = A; i < B + 1; i++) {
		if (i % 10 == i / 10000 && (i / 10) % 10 == (i / 1000) % 10)
			count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;


int main() {
    ll N;
    cin >> N;
    vector<ll> ans(N, 0);
    rep(i,N - 1){
        ll tmp;
        cin >> tmp;
        tmp--;
        ans[tmp]++;
    }
    
    rep(i,N){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4832
# -*- coding: utf-8 -*-

N = int(input())

# 解説動画通りにDPしてみる

dp = [0] * 100001
# dp[0] = 0

for n in range(1, 100001):
    dp[n] = float("inf")
    power = 1
    while power <= n:
        dp[n] = min(dp[n], dp[n-power] + 1)
        power *= 6
    power = 1
    while power <= n:
        dp[n] = min(dp[n], dp[n-power] + 1)
        power *= 9

print(dp[N])

Measured memory_bytes: 3956
#include<stdio.h>
#include<stdlib.h>
#define Max 2000000
#define vMax 10000

int main(){
  unsigned short *A, *B;

  int c[vMax + 1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for(i = 0 ; i <= vMax ; i++) c[i] = 0;

  for(i = 0 ; i < n ; i++){
    scanf("%hu", &A[i + 1]);
    c[A[i + 1]]++;
  }

  for(i = 1 ; i <= vMax ; i++) c[i] = c[i]+ c[i - 1];

  for(j = 1 ; j <= n ; j++){
    B[c[A[j]]] = A[j];
    c[A[j]]--;
  }

  for(i = 1 ; i <= n ; i++){
    if(i > 1) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}


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

typedef long long ll;

const ll inf=1e18;

int main(){
    int N; cin >> N;
    ll a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    ll dp[N+1]={};
    dp[1]=max(a[1],a[0]);
    ll tmp=a[0];
    for(int i=2;i<N;i++){
        if(i%2==1){
            tmp+=a[i-1];
            dp[i]=max(dp[i-2]+a[i],tmp);
        }else{
            dp[i]=max(dp[i-1],dp[i-2]+a[i]);
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 6740
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <cmath>
#include <bitset>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <string>
#include <stack>
#include <cstring>
#include <sstream>

using namespace std;


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

    for (int i = 1; i <= 5; ++i) {
      int x;
      cin >> x;
      if (!x) {
        cout << i;
        return 0;
      }
    }
}


Measured memory_bytes: 3628
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
if sum(a) < x:
    print(n-1)
    exit()
if sum(a) == x:
    print(n)
    exit()
idx = s = 0
while True:
    s += a[idx]
    if x == s:
        print(idx+1)
        exit()
    if x < s:
        print(idx)
        exit()
    idx += 1

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

int main() {
  unsigned long a, b, r, i, j;
  cin >> a >> b;
  if (a < b) swap(a, b);
  while (a%b != 0) {
    r = a%b; a = b; b = r;
  }
  if (b == 1) { cout << 1 << endl; return 0; }
  vector<bool> p((int)sqrt(b), true);
  int ans = 1; double lim = sqrt(b);
  for (i = 2; i <= b && i <= lim; i++) {
    if (p[i] == true && b%i == 0) {
      ans++; while (b%i == 0) b /= i;
    }
    if (p[i] == true)
      for (j = i; j <= b && j <= lim; j += i) p[i] = false;
  }
  if (b >= lim) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 384
package main

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

func parseInt(s string) int {
	return int(parseInt64(s))
}

func parseInt64(s string) int64 {
	x, _ := strconv.ParseInt(s, 10, 64)
	return x
}

var reader *bufio.Reader

func readLine() string {
	s, _ := reader.ReadString('\n')
	return strings.TrimSuffix(s, "\n")
}

var CYCLE int64
var N int

// var w [100000]int64
var b [100000]int64
var p [100000]int64
var visited [100000]bool
var edges [100000][]int

func getChildren(i int) []int {
	possibleChildren := edges[i]
	visited[i] = true
	result := make([]int, 0, len(possibleChildren))
	for _, c := range possibleChildren {
		if !visited[c] {
			result = append(result, c)
		}
	}
	return result
}

func add(x, y int64) int64 {
	return (x + y) % CYCLE
}

func mul(x, y int64) int64 {
	return (x * y) % CYCLE
}

func solve1(i int) {
	children := getChildren(i)
	b[i] = int64(1)
	for _, c := range children {
		solve1(c)
		b[i] = mul(b[i], b[c]+1)
	}
}

func solve2(i int) {
	children := getChildren(i)
	a := int64(1)
	for j := 0; j < len(children); j++ {
		c := children[j]
		p[c] = mul(p[i], a)
		a = mul(a, b[c]+1)
	}
	a = int64(1)
	for j := len(children) - 1; j >= 0; j-- {
		c := children[j]
		p[c] = mul(p[c], a)
		a = mul(a, b[c]+1)
	}
	for _, c := range children {
		p[c] = add(p[c], 1)
		solve2(c)
	}
}

func clearVisited() {
	for i := 0; i < N; i++ {
		visited[i] = false
	}
}

func main() {
	reader = bufio.NewReader(os.Stdin)
	fmt.Scan(&N, &CYCLE)
	for i := 0; i < N-1; i++ {
		fields := strings.Fields(readLine())
		x := parseInt(fields[0])
		y := parseInt(fields[1])
		edges[x-1] = append(edges[x-1], y-1)
		edges[y-1] = append(edges[y-1], x-1)
	}

	solve1(0)
	clearVisited()
	p[0] = 1
	solve2(0)

	// fmt.Println(b[:N])
	// fmt.Println(p[:N])
	for i := 0; i < N; i++ {
		fmt.Println(mul(b[i], p[i]))
	}
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll MOD = 998244353 ;
const int MAXN = 55;
//EAZY..PIZZIIEE

void solve(){
    int n; cin >> n;
    vector<ll> a(n + 1);
    vector<ll> cnt(n + 1);
    ll total = 0;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int ct = 1; ct <= n; ++ct){
        total += cnt[ct] * (cnt[ct] - 1) /2;
    }
    for(int k = 1; k <= n; ++k){
        ll ans = total;
        ll num = a[k];
        ll its = cnt[num];
        ans -= (its - 1);
        cout << ans << '\n';
    }




}

int main(){
    //int t; cin >> t;
    //while(t--)
        solve();
}

Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
	long long int n, m;
	scanf("%lld %lld", &n, &m);
	if (n == 2 || m == 2)
		printf("0\n");
	else if (n == 1 && m == 1)
		printf("1\n");
	else if (n == 1)
		printf("%lld\n", m - 2);
	else if (m == 1)
		printf("%lld\n", n - 2);
	else
		printf("%lld\n", (n - 2) * (m - 2));
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	string s;
	cin >> s;
	ll k;
	cin >> k;
	if(s.size() >= k){
		for(ll i = 0;i < k;i++){
			if(s[i] != '1'){
				cout << s[i] << endl;
				return 0;
			}
		}
		cout << 1 << endl;
	}
	else{
		for(ll i = 0;i < s.size();i++){
			if(s[i] != '1'){
				cout << s[i] << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
let N = Int(readLine()!) ?? 0
let rgbArray = Array(readLine()!)
var count = 0
var rgbIndex = Array(repeating: Array(repeating: 0, count: 0), count: 3)

rgbArray.enumerated().forEach{
    if $0.1 == "R"{
        rgbIndex[0].append($0.0)
    }
    if $0.1 == "G"{
        rgbIndex[1].append($0.0)
    }
    if $0.1 == "B"{
        rgbIndex[2].append($0.0)
    }

    
}
var total = rgbIndex[2].count*rgbIndex[1].count*rgbIndex[0].count

for i in 0 ..< N {
    for j in i+1 ..< N {
        let k = 2 * j - i
        if k >= N {
          break
        }
        if rgbArray[i] != rgbArray[j] && rgbArray[j] != rgbArray[k] && rgbArray[k] != rgbArray[i] {
            total -= 1
        } 
    }
}

print(total)


Measured memory_bytes: 7916
#include <iostream>

using namespace std;

int main() {
    string str;
    cin>>str;
    unsigned long long sum=0;
    for(int i=0;i<str.size();i++){
        sum+=str[i]-'0';
    }
    if(sum%9) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    
    
}

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

int main() {
  int H, W;
  string s;
  cin >> H >> W;
  for (int i=0; i < W + 2; i++) {
    cout << '#';
  }
      cout << endl;
  for (int i=0; i < H; i++) {
    cout << '#';
    cin >> s; cout << s;
    cout << '#' << endl;
  }
  for (int i=0; i < W + 2; i++) {
    cout << '#';
  }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	line := strings.Split(nextLine(), " ")
	a, _ := strconv.Atoi(line[0])
	b, _ := strconv.Atoi(line[1])

	n := b - a

	fmt.Println(n*(n-1)/2 - a)
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int n, m = 100000, i;
	
	scanf("%d", &n);
	
	for(i = 1; i <= n; i++) m = (int)((m * 1.05 + 999) / 1000) * 1000;
	
	printf("%d\n", m);
	
	return 0;
}

Measured memory_bytes: 592
N = int(input())
A = []
count = 1
ans = 0

for _ in range(N):
  A.append(int(input()))

A.sort()

for i in range(N-1):
  if A[i] == A[i+1]:
    count += 1
  else:
    if count%2 == 1:
      ans += 1
    count = 1
else:
  if count%2 == 1:
    ans += 1
  else:
    count = 1

print(ans)

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

a = list(map(int,input().split()))
b = [0]+list(map(int,input().split()))
c = [0]+list(map(int,input().split()))

suf = b[a[0]]
for i in range(1,n):
    suf += b[a[i]]
    if a[i] - a[i-1] == 1:
        suf += c[a[i-1]]

print(suf)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int n = sc.nextInt();
				int k = sc.nextInt();
				if(n+k == 0) break;
				
				int[][] s = new int[n+1][2];
				boolean[] c = new boolean[n+1];
				for(int i=0; i<k; i++) c[sc.nextInt()] = true;
				
				int max0 = 0;
				int max1 = 0;
				for(int i=1; i<=n; i++) {
					s[i][0] = c[i] ? s[i-1][0]+1 : 0;
					s[i][1] = c[i] ? s[i-1][1]+1 : s[i-1][0]+1;
					max0 = Math.max(max0, s[i][0]);
					max1 = Math.max(max1, s[i][1]);
				}
				System.out.println(c[0] ? max1 : max0);
			}
		}
	}
}


Measured memory_bytes: 69984
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std; 
    using ll = long long;
    using P = pair<int,int>; // 1 つの証言を表す構造体 // 「人」と「0 or 1」
    
    int main() {
    string s;
    cin >> s;
    string front = s.substr(0,s.size()/2);
    
    string str2 = s;
    string str3 = front;
    reverse(str2.begin(),str2.end());
    reverse(str3.begin(),str3.end());
       if(s == str2 && front == str3)
    cout << "Yes" << endl; // -1
    else
    cout << "No" << endl; // -1
    
     return 0;
    }
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
                using namespace std;
                #define lli long long int
                #define fr(i,a,b) for(int i=a;i<b;i++)
                #define bfr(i,a,b) for(int i=a;i>=b;i--)
                #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
                #define tc int t;cin>>t;while(t--)
                #define mod 1000000007 
                #define all(vec) vec.begin(),vec.end()  
                #define ld long double


               
        int main()
                {
                      
                     fio
                     
                     lli n,m,x,y;
                     map<lli,set<lli>> z;
                     cin>>n>>m;

                     fr(i,0,m)
                     {
                        cin>>x>>y;
                        z[x].insert(y);

                     }

                     for(auto x:z)
                        if(x.second.size()>1){cout<<-1;return 0;}

                   vector<lli> num;
                   fr(i,1,n+1)
                   if(z.count(i)==0 && i==1 && n!=1)num.push_back(1);
                   else if(z.count(i)==0 )num.push_back(0);
                   else num.push_back((*(z[i].begin())));

                   if(num[0]==0 && n!=1){cout<<-1;return 0;}
                   else for(auto l:num)cout<<l;





                     







                     


                     

                     

                     


return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dfs(vector<int> &dp, vector<vector<int>> &c, vector<char> &e, int v = 0){
  if (e[v] == '+'){
    dp[v] = 0;
    for (int w : c[v]){
      dp[v] += dfs(dp, c, e, w);
    }
  } else if (e[v] == '*'){
    dp[v] = 1;
    for (int w : c[v]){
      dp[v] *= dfs(dp, c, e, w);
    }
  } else {
    dp[v] = e[v] - '0';
  }
  return dp[v];
}
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<string> S(n);
    for (int i = 0; i < n; i++){
      cin >> S[i];
    }
    vector<int> d(n, 0);
    for (int i = 0; i < n; i++){
      while (S[i][d[i]] == '.'){
        d[i]++;
      }
    }
    vector<int> p(n);
    p[0] = -1;
    for (int i = 1; i < n; i++){
      p[i] = i;
      while (d[p[i]] >= d[i]){
        p[i]--;
      }
    }
    vector<vector<int>> c(n);
    for (int i = 1; i < n; i++){
      c[p[i]].push_back(i);
    }
    vector<char> e(n);
    for (int i = 0; i < n; i++){
      e[i] = S[i][d[i]];
    }
    vector<int> dp(n);
    dfs(dp, c, e);
    cout << dp[0] << endl;
  }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int cnt = 0;
  getline(cin, s);
  for (int i = 0; i < s.length() - 1 - i; i++)
    if (s[i] != s[s.length() - 1 - i])
      cnt++;
  cout << cnt << "\n";
  return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  if(A >= 13){
    cout << B << endl;
  }
  else if((6 <= A) && (A <= 12)){
    cout << B/2 << endl;
  }
  else if(A <= 5){
    cout << 0 << endl;
  }
}

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

int main() {
  int r,d,x;
  cin>>r>>d>>x;
  for(int i=0;i<10;i++){
    x=x*r-d;
    cout<<x<<endl;
  }
  
 // cout << /* ここに式を書く */ << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SP << " " <<
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, D;
  cin >> N >> D;
  int tmp = D * 2 + 1;
  int ans;
  if(N % tmp == 0) {
    ans = N / tmp;
  } else {
    ans = N / tmp + 1;
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	char S[10];
	char T[10];
	cin >> S >> T;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) {
			count++;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>



int main() {
	double a, b, p, q, r;
	cin >> a >> b >> p >> q >> r;
	cout << fixed << setprecision(10) << b + (b * p - (b - a) * q) / (q + r) << endl;

}




Measured memory_bytes: 3280