akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
ll dp[1000005][3];
vector<ll> a(100002,0),b(100002,0),c(100002,0);

ll vacation(ll i,int type){
    if(dp[i][type] != -1) return dp[i][type];
    if(type ==  2){
        dp[i][type] = max(vacation(i-1,0),vacation(i-1,1)) + c[i];
    }else if(type == 1){
        dp[i][type] = max(vacation(i-1,0),vacation(i-1,2)) + b[i];
    }else{
        dp[i][type] = max(vacation(i-1,1),vacation(i-1,2)) + a[i];
    }
    return dp[i][type];
}


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; 
    cin >> n;
    for(int i = 1; i < n+1;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    REP(i,n+1) REP(l,3) dp[i][l] = -1;
    REP(i,3) dp[0][i] = 0;
    dp[1][0] = a[1];
    dp[1][1] = b[1]; 
    dp[1][2] = c[1];

    for(ll i = 2; i < n+1;i++){
        for(int l = 0; l < 3;l++){
            vacation(i,l);
        }
    }
    ll ans = max(dp[n][0],dp[n][1]);
    ans = max(ans,dp[n][2]);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6656
/*
 *      ┌─┐       ┌─┐ + +
 *   ┌──┘ ┴───────┘ ┴──┐++
 *   │                 │
 *   │       ───       │++ + + +
 *   ███████───███████ │+
 *   │                 │+
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │
 *       │         │   + +
 *       │         │       Code is far away from bug with the animal protecting
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘  + + + +
 *                神兽保佑
 *               代码无BUG!
 */

#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
ll C(ll n,ll m,ll p){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;

int main(){
    int n;in>>n;
    ll D;in>>D;
    D*=D;
    int cnt=0;
    rep(i,1,n){
        ll x,y;
        in>>x>>y;
        if(x*x+y*y<=D)++cnt;

    }
    out<<cnt;
    return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();
		
		int n = Integer.parseInt(input);
		
		int fx = 0;
		char[] array = input.toCharArray();
		for(int i = 0; i < input.length(); i++){
			fx += array[i] - '0';
		}
		if(n % fx == 0){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


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

int main(){
  int a = 0;
  int b = 0;
  int c = 0;

  cin >> a >> b;
  a = a - 1;
  b = b - 1;
  c = (b + (a - 1)) / a;

  cout << c;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>

using namespace std;
int main(){
    int a[5];
    for(int i=0;i<5;i++)
        cin >> a[i];
    sort(a,a+5);
    for(int i=4;i>=0;i--)
        cout << a[i] <<(i==0 ? '\n':' ');
    return 0;
}

Measured memory_bytes: 1176
using System;
using System.Collections.Generic;
using System.Linq;

public class Pg
{
    public static void Main()
    {
        List<List<int>> map = new List<List<int>>();
        const int DATUM = 11;
        List<int> ans = new List<int>();
        for (string line; !string.IsNullOrEmpty(line = Console.ReadLine()); map.Clear())
        {
            map.Add(line.ToCharArray().Select(x => int.Parse(x.ToString())).ToList());
            for (int i = 0; i < DATUM; ++i)
            {
                map.Add(Console.ReadLine().ToCharArray().Select(x => int.Parse(x.ToString())).ToList());
            }
            var op = new Operate(map);
            ans.Add(op.GetNumsOfIslands());
        }
        Console.WriteLine(string.Join("\n", ans));
    }
}
class Operate
{
    List<List<int>> Map { get; set; }
    internal Operate(List<List<int>> map)
    {
        Map = map;
        Console.ReadLine();
    }
    internal int GetNumsOfIslands()
    {
        int cnt = 0;
        for (int i = 0; i < 12; i++)
        {
            for (int j = 0; j < 12; j++)
            {
                if (Map[i][j] == 1)
                {
                    IsSpreadMore(i, j);
                    ++cnt;
                }
            }
        }
        return cnt;
    }

    private void IsSpreadMore(int i, int j)
    {
        Map[i][j]--;
        if (j != 0 && Map[i][j - 1] == 1)
        {
            IsSpreadMore(i, j - 1);
        }
        if (j != 11 && Map[i][j + 1] == 1)
        {
            IsSpreadMore(i, j + 1);
        }
        if (i != 0 && Map[i - 1][j] == 1)
        {
            IsSpreadMore(i - 1, j);
        }
        if (i != 11 && Map[i + 1][j] == 1)
        {
            IsSpreadMore(i + 1, j);
        }
    }
}



Measured memory_bytes: 18460
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <memory.h>
#include <stdlib.h>


int main(void)
{	
	char s[120];
	int i,lon;
	scanf("%s",s);
	
	lon=strlen(s);
	
	printf("%c%d%c\n",s[0],lon-2,s[lon-1]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;
 

int main(){
  
  	int cnt =0;
  	string S, T;
	cin >> S >> T;
  
  	for(int i =0; i<S.size(); i++){
    	if(S.at(i) != T.at(i))
          cnt++;
    }
  
  	cout << cnt <<endl;
  
  
  return 0;
  
}

Measured memory_bytes: 3468
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

N,Y=MI()
ans=[-1,-1,-1]

for i in range(N+1):
    for j in range(N+1):
        k=N-(i+j)
        if k<0:
            break
        if i*10000 + j*5000 +k*1000 == Y:
            ans=[i,j,k]
            
            
print(' '.join(map(str, ans)))

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

int main(){
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  pair<int,int> p = make_pair(0,1);
  for(int a = 0; a <= 30; ++a){
    for(int b = 0; b <= 30; ++b){
      int water = A * a + B * b;
      for(int c = 0; c <= F-100*water; c++){
	for(int d = 0; d <= F-100*water-C*c; d++){
	  int sugar = C * c + D * d;
	  if(100 * water + sugar > F) continue;
	  if(water * E < sugar) continue;
	  if(sugar * p.second >= water * p.first){
	    p.first = sugar;
	    p.second = water;
	  }
	}
      }
    }
  }
  cout << 100 * p.second + p.first << " " << p.first << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int n,k,perm[10];
string s[10];

int fact(int n){
	if(n==0)return 1;
	return n*fact(n-1);
}

int main(){
	while(cin>>n>>k){
		if(!n)return 0;
		set<string> t;
		for(int i=0;i<n;i++)cin>>s[i];
		int wait=0;
		for(int i=0;i<n;i++)perm[i]=i;
		do{
			if(wait){wait--;continue;}
			string a="";
			for(int i=0;i<k;i++)a+=s[perm[i]];
			t.insert(a);
			wait=fact(n-k)-1;
		}while(next_permutation(perm,perm+n));
		cout<<t.size()<<endl;
	}
}

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

const int N = 200005, M = 40;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}
template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

int n, cnt1 = 0, cnt2 = 0;
long long a[N], b[N], f[N][M + 1], t;

struct node {
	long long A;
	long long B;
	bool operator < (node rhs) const {
		long long val1 = (A - 1) * rhs.B;
		long long val2 = (rhs.A - 1) * B;
		return (val1 > val2) || (val1 == val2 && A < rhs.A);
	}
} vec[N];

long long num[N], pre[N];

int main () {
	read(n), read(t);
	for (int i = 1; i <= n; i++) {
		read(a[i]), read(b[i]);
		if (a[i]) {
			node x = {a[i] + 1, a[i] + b[i] + 1};
			vec[++cnt1] = x;
		}
		else num[++cnt2] = b[i] + 1;
	}

	sort(vec + 1, vec + cnt1 + 1);
	sort(num + 1, num + cnt2 + 1);

	pre[0] = 0ll;
	for (int i = 1; i <= cnt2; i++) pre[i] = pre[i - 1] + num[i];

	for (int i = 0; i <= M; i++) f[0][i] = t + 1;
	f[0][0] = 0ll;
	
	for (int i = 1; i <= cnt1; i++) {
		for (int j = 0; j <= M; j++) {
			f[i][j] = f[i - 1][j];
			if (j) f[i][j] = min(f[i][j], vec[i].A * f[i - 1][j - 1] + vec[i].B);
		}
	}

	int ans = 0;
	for (int i = 0; i <= M; i++) {
		if (f[cnt1][i] > t) continue;
		int pos = lower_bound(pre, pre + cnt2 + 1, t + 1 - f[cnt1][i]) - pre - 1;
		ans = max(ans, pos + i);
	}
	write(ans), putchar('\n');
	return 0;
}

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

int judge(char s) {
	if ((s == 'y' )|| (s == 'u') || (s == 'i') || (s == 'o') || (s == 'p') || (s == 'h') || 
		(s == 'j') || (s == 'k') || (s == 'l') || (s == 'n') || (s == 'm'))return 1;
	else 	return 0;
};

int main()
{
	char s[33];
		for (; cin >> s , s[0] != '#';)
		{
			int count = 0;
			for (int i = 0; i+1 < strlen(s); i++)
			{
				if(!(judge(s[i]) == judge(s[i+1])))count++;
			}
			cout << count << endl;
		}
	return 0;
}

Measured memory_bytes: 1140
// 2020-08-02 17:19:52
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int MX = 305;
const ll inf = 1e15;
ll dp[MX][MX];
void answer() {
  int n, k;
  cin >> n >> k;
  vector<ll> h(n+1);
  rep(i, n) cin >> h[i+1];
  rep(i, MX) rep(j, MX) dp[i][j] = inf;
  dp[0][0] = 0;
  REPC(i, 1, n) REPC(j, 1, n-k) {
    rep(k, i) chmin(dp[i][j], dp[k][j-1] + max(0ll, h[i] - h[k]));
  }
  ll ans = inf;
  repc(i, n) chmin(ans, dp[i][n-k]);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int dfs(vector<bool> &seen, graph &G, int &v, int &cnt, vector<ll> &point, vector<ll> &ans)
{
  seen[v] = true; // v を訪問済にする
  // v から行ける各頂点 next_v について
  cnt += point[v];
  ans[v] = cnt;
  for (auto next_v : G[v])
  {
    if (seen[next_v])
      continue;                            // next_v が探索済だったらスルー
    dfs(seen, G, next_v, cnt, point, ans); // 再帰的に探索
  }
  cnt -= point[v];
  return 0;
}
int main()
{
  int n, q;
  cin >> n >> q;
  graph g;
  rep(i, n-1, 1)
  {
    int a, b;
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }
  vector<ll> score(n, 0);
  rep(i, q, 1)
  {
    int p, x;
    cin >> p >> x;
    score[p - 1] += x;
  }
  vector<ll> ans(n, 0);
  vector<bool> seen(n, false);
  int vi = 0;
  int ct = 0;
  dfs(seen,g,vi,ct,score,ans);
  rep(i, n, 1)
  {
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 46992
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  FOR(i,0,N)cin >> A[i];
  sort(ALL(A));
  if(N%2){
    if(A[0] != 0){
      cout << 0 << endl;
      return 0;
    }
    FOR(i,1,N/2+1){
      if(A[2*i-1] != i*2 || A[2*i] != i*2){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  else{
    FOR(i,0,N/2)if(A[2*i] != i*2+1 || A[2*i+1] != i*2+1){
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  FOR(i,0,N/2){
    ans *= 2;
    ans %= INF;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()

{
    long long a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0)
    {
        cout << "Zero" << endl;
    }
    else if (a > 0 && b > 0)
    {
        cout << "Positive" << endl;
    }
    else
    {
        if ((b - a) % 2 == 0)
        {
            cout << "Negative" << endl;
        }
        else
        {
            cout << "Positive" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

	ll ans = 0;
	vi count(26);
	REP(i, N) {
		int c = S[i] - 'a';
		ll tmp = 1;
		REP(j, 26) {
			if (j != c) {
				tmp = (tmp*(count[j] + 1)) % MOD;
			}
		}
		ans = (ans + tmp) % MOD;
		count[c]++;
	}

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

Measured memory_bytes: 512
def deg(n):
    cnt = 0
    while n%2==0:
        cnt += 1
        n = n//2
    return cnt
def gcm(a,b):
    while b>0:
        a,b = b,a%b
    return a
def lcm(a,b):
    c = gcm(a,b)
    return (a//c)*b
N,M = map(int,input().split())
A = list(map(int,input().split()))
n = deg(A[0])
flg = 0
for i in range(1,N):
    if deg(A[i])==n:continue
    else:
        flg = 1
        break
if flg==1:
    print(0)
else:
    B = [A[i]//2**n for i in range(N)]
    b = B[0]
    for i in range(1,N):
        b = lcm(b,B[i])
    m = 2**(n-1)*b
    print((M+m)//(2*m))

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

using namespace std;

typedef pair<int,int> P;

struct UF {
  vector<int> data;
  UF(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

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

  int n,k,l;cin>>n>>k>>l;
  UF road(n),rail(n);
  for(int i=0;i<k;i++){
      int p,q;cin>>p>>q;
      p--;q--;
      road.unite(p,q);
  }
  for(int i=0;i<l;i++){
      int r,s;cin>>r>>s;
      r--;s--;
      rail.unite(r,s);
  }
  map<P,int> mp;
  for(int i=0;i<n;i++){
      mp[P(road.root(i),rail.root(i))]++;
  }
  for(int i=0;i<n;i++){
      cout<<mp[P(road.root(i),rail.root(i))];
      if(i!=n-1)cout<<" ";
      else cout<<endl;
  }
}


Measured memory_bytes: 13568
#include <cstdio>
#define N 100
int main(){
    int M[N][N];
    int n,u,k,v;
    scanf("%d\n",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)M[i][j]=0;
}
  for(int i=0;i<n;i++){
   scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
       scanf("%d",&v);
        v--;
        M[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(j)printf(" ");
       printf("%d",M[i][j]);
    }
   printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2780
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=55;
int N,a[maxn],sum;
int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++)
		sum+=(a[i]=read());
	long long ans=0;
	for(int i=1;i<=N;i++)
		ans+=1LL*a[i]*(sum-a[i]);
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = input()
N = len(X)
Y = int(X)
X_SUM = 0
for i in range(N):
	X_SUM += Y%10
	Y //= 10

print("Yes" if int(X)%X_SUM == 0 else "No")

Measured memory_bytes: 5200
import sys
import bisect
from collections import deque

def main():
    _ = int(input())
    A = list(map(int, sys.stdin.readlines()))
    
    arr = deque()
    arr.append(A[0])
    for a in A[1:]:
        if a <= arr[0]:
            arr.appendleft(a)
        else:
            insert_index = bisect.bisect_left(arr, a)
            update = max(0, insert_index-1)
            arr[update] = a
    print(len(arr))
    
if __name__=='__main__':
    main()

Measured memory_bytes: 14468
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,k,n1,n2,n3,n4,sum,sum2=0,rem,rem2;
    scanf("%d",&k);
    for(a=1; a<=k; a++)
    {
        for(b=1; b<=k; b++)
        {
            for(c=1; c<=k; c++)
            {
                n1=a;
                n2=b;
                n3=c;
                if(n1>=n2&&n1>=n3)
                {
                    while(n2!=0)
                    {
                        rem=n1%n2;
                        n1=n2;
                        n2=rem;
                    }
                    n4=n1;
                    while(n3!=0)
                    {
                        rem2=n4%n3;
                        n4=n3;
                        n3=rem2;
                    }
                    sum=n4;
                }
                else if(n2>=n3)
                {
                    while(n1!=0)
                    {
                        rem=n2%n1;
                        n2=n1;
                        n1=rem;
                    }
                    n4=n2;
                    while(n3!=0)
                    {
                        rem2=n4%n3;
                        n4=n3;
                        n3=rem2;
                    }
                    sum=n4;
                }
                else
                {
                    while(n1!=0)
                    {
                        rem=n3%n1;
                        n3=n1;
                        n1=rem;
                    }
                    n4=n3;
                    while(n2!=0)
                    {
                        rem2=n4%n2;
                        n4=n2;
                        n2=rem2;
                    }
                    sum=n4;
                }
            sum2=sum2+sum;
            }

        }

    }
printf("%d",sum2);
return 0;
}


Measured memory_bytes: 2152
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
const long long Maxn=1e2;
typedef long long ll;

int a[105];

int main(){
	int n,d,x;
	int sum=0;
	scanf("%d",&n);
	cin>>d>>x;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(d%a[i]!=0) sum+=d/a[i]+1;
		else sum+=d/a[i];
	}
	sum=sum+x;
	printf("%d",sum);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long double lb;

const int INF=1<<27;
const int MOD=(int)1e9+7;

int main(void)
{
	int n[30];
	bool po[1000001];
	rep(i,1000001)po[i]=true;
	int prime[1000001]={0};
	po[0]=false;
	po[1]=false;
	int cnt;
	while(cin>>n[cnt]) cnt++;

	int m=0;
	rep(i,cnt) m=max(n[i],m);

	for(int j=2;j<=m;j++){
		if(po[j]){
			prime[j]=prime[j-1]+1;
			for(int k=1;j*k<=m;k++) {
				po[j*k]=false;
			}
		}else{
			prime[j]=prime[j-1];
		}
	}

	rep(i,cnt) cout << prime[n[i]] << endl;

        return 0;
}

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

using namespace std;
typedef long long ll;

ll n, x;
ll a, b;
ll ap, bp;

int main()
{
	long long ans = 0;
	cin >> n >> x;
	ans += x + (x / (n - x)) * (n - x) * 2 + (n - x);
	a = x % (n - x);
	b = n - x;
	while (true)
	{
		if (a == 0)
		{
			ans -= b;
			break;
		}
		ans += (b / a) * 2 * a;
		b %= a;
		if (b == 0)
		{
			ans -= a;
			break;
		}

		ans += (a / b) * 2 * b;
		a %= b;
	}



	cout << ans << '\n';
	return 0;
}



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

int main(void){
	int n;

	while(cin>>n && n){
		int t[10];
		memset(t,0,sizeof(t));

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

		for(int i=0;i<10;i++){
			if(t[i] == 0){
				cout<<"-";
			}
			else{
				for(int j=0;j<t[i];j++){
					cout<<"*";
				}
			}

			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
    char x[1101];
    int j;
    int num, sum = 0;
    
    while (1) {
        scanf("%s", x);
        if (x[0] == '0') break;
        for (j = 0;x[j] != '\0'; j++) {
            num = x[j] - '0';
            sum = sum + num;
        }
        printf("%d\n", sum);
        sum = 0;
    }
    
    return 0;
}

Measured memory_bytes: 536
import math
a,b,h,m=list(map(int,input().split()))
angh=(h+m/60)/12*360
angm=m/60*360
#print(angh,angm)
AB=min(angh-angm,360-(angh-angm))
#print(AB)
cos=math.cos(math.radians(AB))
c=(a**2+b**2-2*a*b*cos)**0.5
print(c)

Measured memory_bytes: 9500
#include <iostream>

using namespace std;

int main() {
    int n,d,x;
    cin >> n >> d >> x;
    int ans = x + n;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        ans += (d-1) / a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 888
//2018-1-14
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (100000+5)

int a[N], b[N], m, f[N];
bool num[N];

map<int, int> ms, id;
int Find(int x){return x == f[x]? x: (f[x] = Find(f[x]));}

int main(){
	int n, axor = 0;
	
	scanf("%d", &n);
	For(i, 1, n){
		scanf("%d", &a[i]); axor ^= a[i];
		if(ms.count(a[i])) ++ms[a[i]]; else ms[a[i]] = 1;
	}
	if(ms.count(axor)) ++ms[axor]; else ms[axor] = 1;

	int ans = 0;
	For(i, 1, n){
		scanf("%d", &b[i]);
		if(!ms.count(b[i]) || !ms[b[i]]){puts("-1"); return 0;}
		--ms[b[i]]; if(b[i] != a[i]) ++ans;
	}
	
	For(i, 1, n) if(a[i] != b[i]){
		if(!id.count(a[i])) id[a[i]] = ++m;
		if(!id.count(b[i])) id[b[i]] = ++m;
	}
	if(!id.count(axor)) id[axor] = ++m;

	int u, v;
	For(i, 1, m) f[i] = i;
	For(i, 1, n) if(a[i] != b[i]){
		u = Find(id[a[i]]), v = Find(id[b[i]]);
		if(u != v) f[u] = v;
	}

	num[Find(id[axor])] = true;
	For(i, 1, m) if(!num[Find(i)]){
		num[Find(i)] = true; ++ans;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n;
    cin >> n;
    ll a[n];
    rep(i, n)cin >> a[i];
    qsort(a, n, sizeof(ll), desc);
    cout << a[0] - a[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np

N, M = [int(x) for x in stdin.readline().rstrip().split()]

#[競プロ等におけるpython3の標準入力 \- Qiita](https://qiita.com/zenrshon/items/c4f3849552348b3dbe67)
L = []
R = []
for i in range(M):
    l,r=[int(i) for i in input().split()]
    L.append(l)
    R.append(r)

tmp = int(min(R) - max(L))
          
if tmp < 0:
    print(0)
else:
    print(tmp + 1)

Measured memory_bytes: 21544
from heapq import heappush, heappop

N, M = map(int, input().split())
tmp = list(map(int, input().split()))
A = []

for t in tmp:
    heappush(A, -t)

for m in range(M):
    p = -heappop(A)
    p //= 2
    heappush(A, -p)

print(-sum(A))


Measured memory_bytes: 64792
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll x,m;
    cin>>x>>m;
    if (m<=x*2)
        cout<<m/2<<endl;
    else
    {
        ll ans=x;
        m=m-x*2;
        cout<<ans+m/4<<endl;
    }
    return 0;
}


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

int main()
{
    string str, sentence;
    getline(cin, str);
    for (int i = 0; i != str.size(); ++i)
    {
        if (islower(str[i]))
        {
            str[i] = toupper(str[i]);
        }
        else
        {
            str[i] = tolower(str[i]);
        }
        
        sentence += str[i];
    }
    cout << sentence << endl;
    return 0;
}


Measured memory_bytes: 3164
//Radhe Radhe
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include<boost/math/common_factor.hpp>
#include <ext/numeric>
using namespace __gnu_cxx;
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define array(a,n) int a[n]; for(int i=0;i<n;i++) cin>>a[i];
#define loop(i,a,b,x) for(int i=a;i<b;i+=x)
const int MOD = 1000000007;
const int N = 10001;
//const int N = (2 * (1e5)) + 2;

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
   
    int t = 1;
    //cin >> t;
    while (t--) {
        int n, W;
        cin >> n >> W;
        vector<int> weight(n), value(n);
        for (int i = 0; i < n; ++i) {
            cin >> weight[i] >> value[i];
        }

        const int MAX_VALUE = 100 * 1000 + 1, INF = 1e15 + 5;
        vector<int> dp(MAX_VALUE, INF);
        dp[0] = 0;

        int answer = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = MAX_VALUE - 1; j >= value[i]; j--)
            {
                if (dp[j - value[i]] + weight[i] <= W)
                {
                    dp[j] = min(dp[j], dp[j - value[i]] + weight[i]);
                    answer = max(answer, j);
                }
            }
        }
        cout << answer << endl;
    }
    return 0;

}






Measured memory_bytes: 3988
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = float('inf')
for i in range(2 ** (N-1)):
    l = [0] * (N-1)
    for j in range(N-1):
        if (i >> j) & 1:
            l[j] = 1
    cost = 0
    AA = A.copy()
    for k in range(N-1):
        if l[k] == 1:
            maxA = max(AA[:k+1])
            if maxA >= AA[k+1]:
                diff = maxA - AA[k+1] + 1
                AA[k+1] = maxA + 1
                cost += diff
    cnt = 1
    for num in range(1, N):
        if AA[num] > max(AA[:num]):
            cnt += 1
    if cnt >= K:
        ans = min(ans, cost)
print(ans)

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

using namespace std;

const int N = 1e5 + 5;
int n;
pair<int, int> bl[N];
pair<int, int> mov[10];
set<pair<int, int>> arr[10];
set<pair<int, int>> black;
long long h, w;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    mov[1] = {0, 0};
    mov[2] = {0, -1};
    mov[3] = {0, -2};
    mov[4] = {-1, 0};
    mov[5] = {-2, 0};
    mov[6] = {-1, -1};
    mov[7] = {-1, -2};
    mov[8] = {-2, -1};
    mov[9] = {-2, -2};
    
    cin >> h >> w >> n;
    long long res = (h - 2) * (w - 2);
    for(int i = 1; i <= n; i++){
        int a, b;
        cin >> a >> b;
        bl[i] = {a, b};
        black.insert(bl[i]);
    }

    for(int i = 1; i <= n; i++){
        int r = bl[i].first;
        int c = bl[i].second;
        for(int j = 1; j <= 9; j++){
            int startr = r + mov[j].first;
            int startc = c + mov[j].second;
            if(startr >= 1 && startr <= h - 2 && startc >= 1 && startc <= w - 2){
                int cnt = 0;
                for(int d = startr; d <= startr + 2; d++){
                    for(int f = startc; f <= startc + 2; f++){
                        pair<int, int> hehe = {d, f};
                        if(black.count(hehe)){
                            cnt++;
                        }
                    }
                }

                arr[cnt].insert({startr, startc});
            }
        }
    }

    for(int j = 1; j <= 9; j++){
        res -= (long long) arr[j].size();
    }
    cout << res << '\n';
    for(int j = 1; j <= 9; j++){
        cout << arr[j].size() << '\n';
    }
    return 0;
}

Measured memory_bytes: 47872
import math
import collections

n = int(input())
nf = math.factorial(n)
sosu = []

for i in range(1, n+1):
    if (2 ** i-1) % i == 1:
        sosu.append(i)

# print(sosu)
yakusu = collections.Counter()

for i in range(1, n+1):
    for j in sosu:
        if i < j:
            break
        elif i % j == 0:
            while i % j == 0 or i < 1:
                yakusu[j] += 1
                i = i / j


# print(yakusu)

ans = 1
for i in yakusu.values():
    ans *= (i+1)
print(ans % (10**9 + 7))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int taka, ao;
  if(c % b == 0) taka = c/b;
  else taka = c/b+1;
  if(a % d == 0) ao = a/d;
  else ao = a/d+1;
  if(taka > ao) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3636
import java.util.*;
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();
    }
    boolean flag = true;
    int ans = 0;
    while(flag){
      flag = false;
      for(int j=N-1;j>=1;j--){
        if(A[j]<A[j-1]){
          int tmp = A[j];
          A[j] = A[j-1];
          A[j-1] = tmp;
          flag = true;
          ans++;
        }
      }
    }
    for(int i=0;i<N;i++){
      if(i>0){
        System.out.print(" ");
      }
      System.out.print(A[i]);
    }
    System.out.print("\n");
    System.out.println(ans);
  }

}



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

public class Main {
    static long mod = 1_000_000_007L;
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        //two ways to find the lcm of two numbers -> (1) use product + gcd
        //-> (2) use the fact that the lcm is simply the product of the maximum occurrence of any prime in any component number
        int sz = 1_000_005;
        int[] largest = new int[sz];
        for(int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
            int cur = arr[i];
            for(int j = 2; j * j <= cur; j++) {
                if (cur % j == 0) {
                    int cnt = 0;
                    while(cur % j == 0) {
                        cur/=j;
                        cnt++;
                    }
                    largest[j] = Math.max(largest[j], cnt);
                }
            }
            if (cur > 1) {
                largest[cur] = Math.max(largest[cur], 1);
            }
        }
        //compute the lcm
        long lcm = 1;
        for(int i = 0; i < sz; i++) {
            for(int j = 0; j < largest[i]; j++) {
                lcm = (lcm * i) % mod;
            }
        }
        long ans = 0;
        for(int i = 0; i < n; i++) {
            ans = (ans + lcm * modInv(arr[i])) % mod;
        }
        out.println(ans);
        out.flush();
    }
    static long modInv(long x) {
        if (x == 0) return 0;
        return modPow(x, mod-2);
    }
    static long modPow(long x, long p) {
        if (p == 0) return 1L;
        long t = modPow(x, p/2);
        t = (t * t) % mod;
        if (p % 2 == 0) return t;
        return (t * x) % mod;
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 28464
from collections import deque

def main():
    S = deque(input())
    Q = int(input())
    revFlag = False
    for i in range(Q):
        tmp = list(input().split())
        if tmp[0] == "1":
            if revFlag:
                revFlag = False
            else:
                revFlag = True
        else:
            if tmp[1] == "1":
                if revFlag:
                    S.append(tmp[2])
                else:
                    S.appendleft(tmp[2])
            else:
                if revFlag:
                    S.appendleft(tmp[2])
                else:
                    S.append(tmp[2])
    if revFlag:
        S = list(S)
        S.reverse()
        print("".join(S))
    else:
        S = list(S)
        print("".join(S))


if __name__ == '__main__':
    main()

Measured memory_bytes: 8436
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

int main()
{
    int N;
    cin >> N;
    vector<int> eat(N);
    vector<int> h(N);
    vector<int> bonus(N - 1);
    int sum = 0;
    for(int i = 0;i < N;i++)
        cin >> eat[i];
    for(int i = 0;i < N;i++)
        cin >> h[i];
    for(int i = 0;i < N - 1;i++)
        cin >> bonus[i];
    for(int i = 0;i < N;++i)
    {
        sum += h[i];
        if(i == 0)
            continue;
        if(eat[i] - eat[i - 1] == 1)
            sum += bonus[eat[i - 1] - 1];
    }
    cout << sum << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

int main(){
	fast;
	
	int n,r,dr;
	cin>>n>>r;
	
	if(n>=10)
	dr=r;
	
	else{
		dr=r+100*(10-n);
	}
	
	cout<<dr;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int a,b;

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

  int c=b-a;

  int aa=1,bb=3;
  int s=2;

  while(bb-aa!=c){
    aa+=s;
    bb+=s+1;
    s++;
  }

  
  cout<<aa-a<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define P pair<int, int>
const int maxn = 1e5 + 111;
char s[200][200];
const ll mod=1e9+7;
ll qm(ll a,ll b){
    ll ret=1;
    while(b){
        if(b&1){
            ret=ret*a%mod;
        }
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}
int main() {
    ll n,m;
    scanf("%lld%lld",&n,&m);
    if(n>m){
        puts("0");
        return 0;
    }
    ll ans=1;
    ll ans2=1;
    for(ll i=m;i>m-n;--i){
        ans=ans*i%mod;
    }
    printf("%lld\n",ans);
    return 0;
}



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s;
int N = 0;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int x;
  cin >> s;
  rep(i, s.length())
  {
    if (s[i] == '9')
    {
      Yes();
      return 0;
    }
  }
  No();
  return 0;
}

Measured memory_bytes: 3636
r, d = 0, 0
while True:
    try:
        (a,b,c) = [int(i) for i in raw_input().split(',')]
    except:
        break
    if(a==b):
        d += 1
    if(a*a+b*b==c*c):
        r += 1
print r
print d

Measured memory_bytes: 4224
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)

mo=10**9+7
#n=int(input()) 
n,d=map(int,input().split())
y=[]
for i in range(n):
    x=[int(i) for i in input().split()]
    y.append(x)
    
def dist(x,y):
    a=0
    rt=False
    for i in range(len(x)):
        a+=(x[i]-y[i])**2
    if a==int(a**0.5)**2:
        rt=True
    return rt
    #print(a,int(a**0.5)**2)
ans=0
for i in range(n):
    for j in range(i+1,n):
        ans+=1 if dist(y[i],y[j]) else 0


print(ans)



Measured memory_bytes: 38256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    scan.nextLine();
    String S=scan.nextLine();
    if((N!=1)&&(N%2==0)){
      if((S.substring(0,N/2)).equals(S.substring(N/2,N))){
        System.out.println("Yes");
        System.exit(0);
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
 
 int main(){
       int A,B;
     scanf("%d %d",&A,&B);
     if(A==1){ A+=13;}
      if(B==1){ B+=13;}
    
       if(A>B){
   printf("Alice");}
     else if(A==B){
      printf("Draw");}
       else { printf("Bob");
     }
     return 0;
       }

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
	int N;
  	cin >> N;
  	int count = 0;
  	for(int i = 1; i <= N; i += 2){
    	int divisorNum = 0;
      	for(int j = 1; j <= N; ++j){
          	if(i % j == 0) ++divisorNum;
        }
      	if(divisorNum == 8){
          	++count;
        }
    }
  	cout << count << endl;
}


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

int main(){
  int N,K,ans=0;
  cin >> N >> K;
  int a[N],b[N]={};
  for(int i=0;i<N;i++){
    cin >> a[i];
    b[a[i]-1]++;
  }
  sort(b,b+N);
  int s=0;
  for(int i=0;i<N;i++){
    if(b[i]==0)
      s++;
  }
  if(N-s>K){
 	for(int i=s;i<N-K;i++){
   	ans += b[i];
 	}
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int main(){
    ll n;cin>>n;
    vector<ll> div;
    for(ll i=1;i*i<=n;++i){
        if(n%i==0){
            div.push_back(i);
            if(i!=n/i) div.push_back(n/i);
        }
    }
    ll ans=0;
    for(auto r:div){
        ll m=n/r-1;
        if(m>r) ans+=m;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3740