akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
	public Main() {
		FastScanner scanner = new FastScanner();
		long N = scanner.nextLong();
		
		long ans = (N*(N+1L)*(2L*N+1L) + 3L*N*(N+1L)) / 12L;
		
		for (long i = 0L; i < N-1; i++) {
			long u = scanner.nextLong();
			long v = scanner.nextLong();
			
			if (u > v){
				u = u ^ v;
				v = u ^ v;
				u = u ^ v;
			}
		
			ans -= u*(N-v+1L);
		}
		
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

signed main(){
    long long a , b , x;
    cin >> a >> b >> x;
    
    if(a == 0){
        cout << b/x + 1 << endl;
    } else {
        cout << b/x - (a-1)/x << endl;
    }
    return(0);
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a = int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換

    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(int(a/b))
    elif op == "?":
        break


Measured memory_bytes: 5596
N,Y=map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
        z=N-i-j
        if 10000*i+5000*j+1000*z==Y and z>=0:
            print(i,j,z)
            exit()
print('-1 -1 -1')


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

const int MOD = 1000000007;

struct MAT {
	MAT() { memset(d, 0, 2500 * sizeof(int)); }
	int d[50][50];
	
	MAT operator * (const MAT &t) const {
		MAT ret;
		for(int i = 0; i < 50; i++) for(int j = 0; j < 50; j++) for(int k = 0; k < 50; k++)
			ret.d[i][k] = (ll(d[i][j]) * t.d[j][k] + ret.d[i][k]) % MOD;
		return ret;
	}
} E, KT;

MAT pw(MAT n, ll k) {
	MAT r = E; for(; k; k >>= 1) {
		if(k & 1) r = r * n;
		n = n * n;
	}
	return r;
}

int Ans;
int N; ll K;

int main() {
	cin >> N >> K;
	for(int i = 0; i < N; i++) {
		E.d[i][i] = 1;
		for(int j = 0; j < N; j++)
			cin >> KT.d[i][j];
	}
	KT = pw(KT, K);
	for(int i = 0; i < N; i++) for(int j = 0; j < N; j++)
		Ans = (Ans + KT.d[i][j]) % MOD;
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.strip.to_i
a = gets.strip.split(' ').map(&:to_i)

rain = a.inject(:+)

even_index_sum = a.map.with_index {|tmp, index| (index+1).even? ? tmp : 0 }.inject(:+)
first = rain - 2*even_index_sum

results=[]
results.push(first)

(1..n-1).to_a.each do |num|
  results.push(a[num-1]*2-results[num-1])
end


puts results.join(' ')


Measured memory_bytes: 15988
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP2(i,n,s) for(int i=(int)s;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int a[4]; string s;
    cin >> s;
    REP(i,4) {
        a[i] = s[i] - '0';
    }

    REP(i, 8) {
        int x = i, s = a[0];
        REP2(j,4,1) {
            if(x%2 == 1) s += a[j];
            else s -= a[j];
            x >>= 1;
        }
        if (s == 7) {
            int x = i;
            REP(j,3) {
                cout << a[j];
                if(x%2 == 1) cout << "+";
                else cout << "-";
                x >>= 1;
            }
            cout << a[3] << "=7" << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <sstream>
#include<vector>
using namespace std;


int main(){
	int n,ans=0;
	for(int i=0;i<10;i++){
		cin>>n;
		ans+=n;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    // cout.precision(21);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        a[i] = 0;
    }
    for(int i = 0; i < n - 1; i++){
        int x;
        cin >> x;
        a[x - 1]++;
    }
    for(int i = 0; i < n; i++){
        cout << a[i] << endl;
    }
}

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

using namespace std;

int a[4][3][10];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        cin >> b >> f >> v >> r;
        a[b - 1][f - 1][v - 1] += r;
    }
    for (int i = 0; i < 4; i++)
    {
        for(int j =0;j<3;j++){
            for(int k=0;k<10;k++){
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }

  
        if (i != 3)
        {
           
            for (int tmp = 0; tmp < 20; tmp++)
            {
                printf("#");
            }
            printf("\n");
            
        }
        
    }

    return 0;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
#define fi first
#define se second
map<int,int> mp;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
ll a,b,c;
cin>>a>>b>>c;
if(a%2==0&&a==b&&b==c){
    cout<<-1<<endl;
    return 0;
}
if(a%2==1||b%2==1||c%2==1){
    cout<<0<<endl;
    return 0;
}
ll cnta=0,cntb=0,cntc=0;
while(a%2==0){
    a/=2;
    cnta++;
}
while(b%2==0){
    b/=2;
    cntb++;
}
while(c%2==0){
    c/=2;
    cntc++;
}
ll ans=min(cnta,min(cntb,cntc));
if(cnta==cntb&&cntb==cntc)ans++;
cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = 0; i < n-2; i++) {
            int prev = p[i];
            int curr = p[i+1];
            int next = p[i+2];
            if((prev < curr && curr < next) || (prev > curr && curr > next)) count++;
        }
        System.out.println(count);
    }
}


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

using namespace std;

const int white=0;
const int gray=1;
const int black=2;
const int n=100;

int cnt,m[n][n],color[n],d[n],f[n],tt,nt[n];

int next(int u)
{
    for(int v=nt[u];v<cnt;v++){
        nt[u]=v+1;
        if(m[u][v]){
            return v;
        }
    }
    return -1;
}

void dfs_visit(int r)
{
    for(int i=0;i<cnt;i++){
        nt[i]=0;
    }
    stack<int>s;
    s.push(r);
    color[r]=gray;
    d[r]=++tt;
    while(!s.empty()){
        int u=s.top();
        int v=next(u);
        if(v!=-1){
            if(color[v]==white){
                color[v]=gray;
                d[v]=++tt;
                s.push(v);
            }
        }else{
            s.pop();
            color[u]=black;
            f[u]=++tt;
        }
    }
}

void dfs()
{
    for(int i=0;i<cnt;i++){
        color[i]=white;
        nt[i]=0;
    }
    tt=0;
    for(int u=0;u<cnt;u++){
        if(color[u]==white){
            dfs_visit(u);
        }
    }
    for(int i=0;i<cnt;i++){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

int main()
{
    int u,k,v;
    cin>>cnt;
    for(int i=0;i<cnt;i++){
        for(int j=0;j<cnt;j++){
            m[i][j]=0;
        }
    }
    for(int i=0;i<cnt;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            m[u][v]=1;
        }
    }
//    for(int i=0;i<cnt;i++){
//        for(int j=0;j<cnt;j++){
//            cout<<m[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    dfs();
    return 0;
}
/*
6
1 2 2 3
2 2 3 4
3 1 5
4 1 6
5 1 6
6 0
*/



Measured memory_bytes: 3108
#include <stdio.h>

int main()
{
    int a,b,c,k;
    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &k);
    while(b <= a){
        b *= 2;
        k--;
    }
    while(c <= b){
        c *= 2;
        k--;
    }
    if (k >= 0){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

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

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	long long int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			res += v[i]*v[j];
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<list>
#include<string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl

int coin[4] = { 10,50,100,500 };
int main()
{
	int n;
	cin >> n;
	while (1)
	{
		if (n == 0)break;
		int mycoin[4] = {};
		int sum = 0;
		REP(i, 4)
		{
			cin >> mycoin[i];
			sum += mycoin[i] * coin[i];
		}
		int ret = sum - n;
		for (int i = 3; i >= 0; i--)
		{
			int temp = ret / coin[i];
			mycoin[i] -= temp;
			ret -= temp*coin[i];
		}
		REP(i, 4)
		{
			if (mycoin[i] > 0)cout << coin[i] << " " << mycoin[i] << endl;
		}
		cin >> n;
		if (n != 0)cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>s;
    ll aa = -1,bb = -1;
    rep(i,s.size()){
        if(i-1>=0){
            if(s[i]==s[i-1]){
                aa = i;
                bb = i+1;
                break;
            }
        }
        if(i-2>=0){
            if(s[i-2]==s[i]){
                aa = i-1;
                bb = i+1;
                break;
            }
        }
    }
    cout<<aa<<" "<<bb<<endl;
    return 0;
}

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

#define     ll     long long int

int main( )
{
    ll s = 0, n, m, i, j, k;
    cin >> n >> m;
    i = min(n, m / 2);
    s += i;
    n -= i;
    m -= (2 * i);
    s += (m / 4);
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int ans;
int N,a[100],b[100];
int main(void){
    cin>>N;
    for(int i=0;i<=N-1;i++){
        cin>>a[i];
    }
    for(int i=0;i<=N-1;i++){
        cin>>b[i];
    }
    for(int j=0;j<=N-1;j++){
        int x=0;
        for(int i=0;i<=j;i++){
            x=x+a[i];
        }
        for(int i=j;i<=N-1;i++){
            x=x+b[i];
        }
        if(ans<x){
            ans=x;
        }
    }
    cout<<ans<<endl;
    
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
//

const ll MAX = 110000;

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll N; cin >> N;

    UnionFind uf(MAX * 2);
    for (int i = 0; i < N; ++i){
        ll x, y;
        cin >> x >> y;
        uf.merge(x, y + MAX);
    }

    // 連結成分ごとに、左ノードと右ノードの個数を数える
    map<int, ll> mx, my;
    for (int i = 0; i < MAX; ++i){
        mx[uf.root(i)]++;
    }
    for (int i = MAX; i < MAX*2; ++i){
        my[uf.root(i)]++;
    }

    ll res = 0;
    for (int r = 0; r < MAX*2; ++r){
        res += mx[r] * my[r];
    }

    cout << res- N << endl;
    return 0;
}


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

int main(){
	string s1,s2;
	int n;
	cin >> n >> s1 >> s2;
	int i = 0, j = 0;
	string s = "";
	while(i < n && j < n){
		s += s1[i++];
		s += s2[j++];
	}
	cout << s << endl;
	return 0;	
} 

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

int main()
{
	int a,b,c,sum=0;
	char s[100];
	
	cin>>a;
    for(int i=a;;i++)
    {
        if(i%2==0 && i%a==0)
        {
            cout<<i;
            return 0;
        }
    }
	return 0;
}
	

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

using namespace std;

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

const ld INF = 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector< vector<int> > g(n);
    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        g[s].push_back(t);
    }

    vector<ld> dp(n, INF), sum(n, 0);
    dp[n - 1] = 0;

    for (int i = n - 2; i >= 0; i--) {
        for (int j : g[i]) {
            sum[i] += dp[j];
        }

        dp[i] = sum[i] / g[i].size() + 1;
    }

    vector<ld> p(n, 0);
    p[0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j : g[i]) {
            p[j] += p[i] / g[i].size();
        }
    }

    ld ans = dp[0];
    for (int i = n - 2; i >= 0; i--) {
        if (g[i].size() <= 1) continue;
        for (int j : g[i]) {
            ans = min(ans, dp[0] - (dp[i] - (sum[i] - dp[j]) / (g[i].size() - 1) - 1) * p[i]);
        }
    }
    cout << fixed << setprecision(20) << ans << "\n";
    return 0;
}

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

int main()
{
	int x, y;
	while (scanf("%d%d", &x, &y) != EOF) {
		if ((y - 2 * x) % 2 == 0 && (4 * x - y) % 2 == 0) {
			int a, b;
			a = (y - 2 * x) / 2;
			b = (4 * x - y) / 2;
			if (a >= 0 && b >= 0 && a + b == x) {
				printf("Yes\n");
			} else {
				printf("No\n");
			}
		} else {
			printf("No\n");
		}
	}
	return (0);
}


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

int K;

ll gcd(ll a, ll b) {
    ll large = max(a, b);
    ll small = min(a, b);
    if (small == 0) return large;
    else return gcd(small, large % small);
}

int main() {
    cin >> K;

    ll ans = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            ll a_b = gcd(a, b);
            for (int c = 1; c <= K; c++) {
                ans += gcd(a_b, c);       
            }
        }
    }

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

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

int main(void) {
  vector<int> border = {3200, 2800, 2400, 2000, 1600, 1200, 800, 400, 1};
  int N;
  cin >> N;
  set<int> s;
  int free_color = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < border.size(); j++) {
      if (border[j] <= a) {
        if (j != 0) {
          s.insert(j);
        } else {
          free_color++;
        }
        break;
      }
    }
  }

  if (s.size() == 0) {
    cout << 1 << " " << free_color << endl;
  } else {
    cout << s.size() << " " << free_color + (int)s.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>

using namespace std;

const int MAX = 2000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  	COMinit();
    int N, K;
    cin>>N>>K;

    for(int i=1; i<=K; i++){
        uint64_t mod = uint64_t(1000000007);
        uint64_t blue_group = COM(K-1, i-1);
        uint64_t select_space = N-K+1>=i ? COM(N-K+1, i) : 0;
        cout << (blue_group * select_space)%mod << endl;
    }

    return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int N, X;
  int L[100];
  int ans = 1;
  int place = 0;

  cin >> N >> X;
  for(int i = 0; i < N; i++)
    cin >> L[i];

  while(1)
  {
    if((ans - 1) >= N)
      break;
    place += L[ans - 1];
    if(place > X)
      break;
    else
      ans++;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
long long N , A;
cin >>N;
long long a[N];
for (long long i=1 ; i<=N ; i++)
   {
       cin >> A;
       a[A]=i;}
    for (long long i=1 ; i<=N ; i++)
   {
       cout << a[i]<< ' ' ;
   }
    return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
 Atcoder 100~200点代
 アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
//void solve(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
//void solve(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc044.contest.atcoder.jp/tasks/abc044_a
//void solve(){ll N,K,X,Y;cin>>N>>K>>X>>Y; cout<<X*min(N,K)+Y*max(0LL,N-K)<<endl;}
// https://abc045.contest.atcoder.jp/tasks/abc045_a
//void solve(){ll a,b,h;cin>>a>>b>>h;cout<<(a+b)*h/2<<endl;}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
//void solve(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc047.contest.atcoder.jp/tasks/abc047_a
//void solve(){ll a,b,c;cin>>a>>b>>c;if(a==b+c||b==a+c||c==a+b)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
// https://abc048.contest.atcoder.jp/tasks/abc048_a
//void solve(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
// https://abc049.contest.atcoder.jp/tasks/abc049_a
//void solve(){char c;cin>>c;string s="aiueo";if(s.find(c)!=string::npos)cout<<"vowel"<<endl;else cout<<"consonant"<<endl;}
// https://abc050.contest.atcoder.jp/tasks/abc050_a
//void solve(){ll A,B;char op;cin>>A>>op>>B;if(op=='+')cout<<A+B<<endl;else cout<<A-B<<endl;}
// https://abc051.contest.atcoder.jp/tasks/abc051_a
//void solve(){string s;cin>> s;cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14)<<endl;}
// https://abc052.contest.atcoder.jp/tasks/abc052_a
//void solve(){ll A,B,C,D;cin>>A>>B>>C>>D;cout<<max(A*B,C*D)<<endl;}
// https://abc053.contest.atcoder.jp/tasks/abc053_a
//void solve(){ll x;cin>>x;cout<<(x<1200?"ABC":"ARC")<<endl;}
// https://abc054.contest.atcoder.jp/tasks/abc054_a
void solve(){ll A,B;cin>>A>>B;if(A==1)A=14;if(B==1)B=14;cout<<(A>B?"Alice":(A==B?"Draw":"Bob"))<<endl;}

// Main function
int main(void) {cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }


Measured memory_bytes: 256
N, X = map(int, input().split())
L_list = list(map(int, input().split()))
d_sum = 0
bounce_count = 0

for L in L_list:
    if d_sum+L>X:
        break
    d_sum = d_sum + L
    bounce_count = bounce_count + 1

print(bounce_count+1)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    vector<int> a(3, 0);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if ((b + a)%2) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int k, n;
    int A[200001] = {0};
    int ans = 0;

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

    if(k == 2){
        if(A[1] - A[0] > (k >> 1)){
            cout << A[0] + (k - A[1]) << endl;
        }
        else{
            cout << A[1] - A[0] << endl;
        }
    }
    else{
        for(int i = 0; i < n - 1; i++){
            if(A[i+1] - A[i] > ans){
                ans = A[i+1] - A[i];
            }
        }
        if(ans < A[0] + (k - A[n-1])){
            ans = A[0] + (k - A[n-1]);
        }
        cout << k - ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 200005
using namespace std;
int n,A,B,C,D;
char in[M];
int main()
{
    while (~scanf("%d %d %d %d %d", &n,&A,&B,&C,&D)) {
        scanf("%s", in+1);

        auto chk = [&](int x,int y) {
            REP(i,x+1,y) if(in[i]=='#' && in[i-1]=='#') return false;
            return true;
        };
        auto chk2 = [&](int x,int y) {
            REP(i,x,y) if(in[i-1]!='#' && in[i]!='#' && in[i+1]!='#') return true;
            return false;
        };

        if (C<D && chk(A,C) && chk(B,D)) puts("Yes");
        else if (C>D && chk(A,C) && chk(B,D) && chk2(B,D)) puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end(),greater<int>());
    long long ans=0;
    for(int i=k;i<n;i++){
        ans+=h[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define int long long
#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 VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll N;

signed main() {
    SCIN(S, T);
    ll cnt = 0;
    REP(i, 3) {
        if(S[i] == T[i]) cnt++;
    }
    cout << cnt << "\n";
}


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

using namespace std;
#define ll long long

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	ll N;
	cin >> N;

	ll x, mn = (ll)1e15;

	for (int i = 0; i < 5; ++i) {
		ll x;
		cin >> x;
		
		mn = min(mn, x);
	}

	ll cnt = ceil ( (double)N / (double) mn);
	cout << cnt + 4 << '\n';



	return 0;
}


Measured memory_bytes: 256
import java.lang.Math.abs
import java.util.Collections.max
import java.util.Collections.min

fun main(args: Array<String>) {
    readLine()
    val a = readLine()!!.split(' ').map(String::toInt)
    val max = max(a)
    val min = min(a)
    print(abs((max - min)))
}

Measured memory_bytes: 36380
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define PQ priority_queue<double, vector<double>, greater<double> >q

#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    FAST();
    ll int n,m,a,b,res=0;
    cin>>n>>m;
    m=m*m;
    while(n--)
    {
        cin>>a>>b;
        a=a*a+b*b;
        if(a<=m)res++;

    }
    cout<<res<<endl;


}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    int X,A;
    cin >> X >> A;
    if(X < A) cout << 0 << endl;
    else{
        cout << 10 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
  int n;
  int i;
  int alice = 0;
  int bob = 0;
  int max = 0;
  vector<int> d(100);
  cin >> n;
  for(i=0;i<n;i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end(),greater<int>());
  for(i=0;i<n;i += 2){
    alice += d.at(i);
    bob += d.at(i+1);
  }
  cout << alice - bob << "\n";
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_E 10000
#define MAX_V 10000

struct edge{
	int from, to;
	long long int cost;
};

edge es[MAX_E];
long long int d[MAX_V];
int V, E;

bool shortest_path(int s){
	for(int i = 0; i <= V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	for(int loop = 0; loop < V; loop++){
		for(int i = 0; i < E; i++){
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
    long long int dist = d[V];
	for(int loop = 0; loop < V; loop++){
		for(int i = 0; i < E; i++){
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
    return dist != d[V];
}

int main(){
    long long int P;
    cin >> V >> E >> P;
    for(int i = 0; i < E; i++){
        long long int cost;
		cin >> es[i].from >> es[i].to >> cost;
        es[i].cost = P - cost;
    }
    
	bool ret = shortest_path(1);
	
	if(ret){
		cout << -1 << endl;
	}else{
        cout << max(0LL, -d[V]) << endl;
    }
    return 0;
}

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

int main(void){
    // Your code here!
    int n,m;
    cin >> n >>m;
    pair<int,int> request[m];
    for(int i=0;i<m;i++){
        pair<int,int> a;
        cin >>a.second >> a.first;
        request[i]=a;
    }
   sort(request,request+sizeof(request)/sizeof(request[0]));
    int index=0,ans=0;
    for(int i=0;i<m;i++){
        if(index<request[i].second){
            index = request[i].first-1;
            ans++;
        }
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;
int dp[2][20001];

int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, 0, n) cin >> s[i];

    dp[1][0] = 1;
    rep(i, 0, n)
    {
        int now = i % 2;
        int prev = (i + 1) % 2;
        for (int j = 0; j < 10001; j++)
        if (dp[prev][j])
        {
            dp[now][j] = 1;
            dp[now][j + s[i]] = 1;
        }
    }

    int ans = 0;
    rep(i, 0, 10001)
    if( i % 10 != 0)
        ans = max(ans, i * dp[(n-1)%2][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

// int n; 

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    string x;
    cin >> x;
    ll sum = 0;

    for(int i = 0; i < x.length(); i++) {
        sum += (x[i] - '0');
        sum %= 9;
    }
    if(sum % 9) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3752
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

int dp[3000 + 1][3000 + 1];

void solve() {
  string s, t;
  cin >> s >> t;

  for (int i = 0; i < s.size(); i++) {
    for (int p = 0; p < t.size(); p++) {
      dp[i + 1][p + 1] = max(dp[i + 1][p], dp[i][p + 1]);
      if (s[i] == t[p]) {
        dp[i + 1][p + 1] = max(dp[i + 1][p + 1], dp[i][p] + 1);
      }
    }
  }

  if (dp[s.size()][t.size()] == 0) {
    cout << endl;
    return;
  }

  int i = s.size();
  int p = t.size();

  string ans;

  while (dp[i][p]) {
    if (s[i - 1] == t[p - 1] && dp[i][p] == dp[i - 1][p - 1] + 1) {
      ans.push_back(s[i - 1]);
      i--;
      p--;
    } else if (dp[i][p] == dp[i][p - 1]) {
      p--;
    } else {
      i--;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 35456
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;
 
LL N, T[112];
std::vector<LL>o, m;
 
LL gcd(LL x, LL y)
{
	LL r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
 
LL lcm(LL x, LL y)
{
	return (x / gcd(x, y))* y;
}
 
int main()
{
	in >> N;
	rep(i, N) { in >> T[i]; }
 
	rep(i, N) { o.push_back(T[i]); }
	while (o.size() > 1)
	{
		for (int i = 0; i + 1 < o.size(); i += 2)
		{
			m.push_back(lcm(o[i], o[i + 1]));
		}
		if (o.size() % 2 == 1) { m.push_back(o[o.size() - 1]); }
		o.clear();
		o = m;
		m.clear();
	}
 
	out << o[0] << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int A = s.nextInt();
			final int B = s.nextInt();
			final int T = s.nextInt();

			int ret = 0;
			for(int i = A; i <= T; i += A) {
				ret += B;
			}
			System.out.println(ret);
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n; cin >> n;
  vector<int> data(n); REP(i,n) cin >> data[i];
  int sum = 0;
  sort(ALL(data));
  REP(i,n-1){
    sum += data[i];
  }
  if(data[n-1] < sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
} 

Measured memory_bytes: 3504
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] s = sc.next().split(",");
			int a = Integer.valueOf(s[0]);
			double b = Double.valueOf(s[1]);
			double c = Double.valueOf(s[2]);
			if(b/(c*c)>=25){
				System.out.println(a);
			}
		}		
	}
}

Measured memory_bytes: 17144
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

typedef pair<int,int> P;

const int INF=INT_MAX/3;
//const int V_MAX=10000,E_MAX=10000;
//int V,E;
const int N=20000;

bool primes[N];

void sieve(){

  fill(primes,primes+N,true);
  primes[0]=false;
  primes[1]=false;
  
  for(int i=2;i<N;i++)
    if(primes[i])
      for(int j=2*i;j<N;j+=i) primes[j]=false;
  
}

int solve(int n){

  int res=0;
  for(int i=2;i<n;i++)
    if(primes[i] && primes[n-i+1]) res++;
  return res;
}

int main(){

  int n=0;
  sieve();
  while(cin>>n)
    cout<<solve(n)<<endl;

  return 0;
}

Measured memory_bytes: 3008
#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>;
const int INF = 1001001001;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  rep(i, s.size()) {
    if(s[i] == '?') s[i] = 'D';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3740
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll a,b;
  cin>>a>>b;
  cout<<(a-1)*(b-1)<<endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
T,A=list(map(int,input().split()))
H=input().split()
H=[int(i) for i in H]
min=999999

for i in range(N):
    if abs(A-(T-H[i]*0.006))<min:
        min=abs(A-(T-H[i]*0.006))
        key=i+1
        
print(key)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    ll n, m;
    cin >> n;

    ll ans = 0;

    unordered_map<string, ll>ct;
    string s;
    REP(i, n){
        cin >> s;
        sort(ALL(s));
        // cout << s << endl;

        if (ct[s] > 0){
            
            ans += ct[s];
            ct[s]++;
        }
        else ct[s] = 1;;
    }
    cout << ans << endl;

}

Measured memory_bytes: 10376
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main( int argc, char* argv[]) {
  int N;
  cin >> N;
  vector<int> x(N),y(N),h(N);
  for( int i=0; i<N; ++i ){
    cin >> x[i] >> y[i] >> h[i];
  }
  int hmin = *min_element(h.begin(), h.end());
  for( int cx=0; cx<=100; ++cx ){
    for( int cy=0; cy<=100; ++cy ){
      for( int H=hmin; H<=hmin+200; ++H ){
        bool check = true;
        for( int i=0; i<N; ++i ){
          if( h[i] != max(0,H-abs(cx-x[i])-abs(cy-y[i])) ){
            check = false;
            break;
          }
        }
        if( check ){
          cout << cx << " " << cy << " " << H << endl;
          return 0;
        }
      }
    }
  }
}
   

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

int main() {
  int m;
  cin >> m;
  long digit = 0, s = 0;
  for (int i = 0; i < m; i++) {
    long d, c;
    cin >> d >> c;
    digit += c;
    s += d * c;
  }
  cout << digit - 1 + (s - 1) / 9 << endl;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	deque<int> d;
	int n; cin >> n;
	rep(i, 0, n) {
		int t; cin >> t;
		if (i % 2 == 0) d.push_front(t);
		else d.push_back(t);
	}
	if (n % 2 == 0) reverse(all(d));
	rep(i, 0, d.size()) cout << d[i] << " \n"[i + 1 == sz(d)];
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N, L;
    cin >> N >> L;
    int min = L, max = L + N - 1;
    int eat;
    if (0 < min)
        eat = min;
    else if (max < 0)
        eat = max;
    else
        eat = 0;
    cout << ((min + max) * N / 2) - eat;
}

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

int main() 
{
      int n,k;
      cin>>n>>k;
      int arr[n+1];
      for(int i=1; i<=n;i++)
      cin>>arr[i];
      if(n==0 || n==1)
        cout<<0<<endl;
      else  
      {int dp[n+1];
      dp[0]=1,dp[1]=0,dp[2]=abs(arr[2]-arr[1]);
      
      for(int i=3; i<=n; i++)
      {  int mn=INT_MAX;
        for(int j=i-1; j>=i-k && j>=1 ;j-- )
         mn=min(mn,dp[j]+abs(arr[i]-arr[j]));
        dp[i]=mn;
        }
        cout<<dp[n]<<endl;
      } 
      
        return 0;
}

Measured memory_bytes: 4328
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll n;
  ll ans=0;
  cin>>n;
  vector<ll>a(n,0);
  vector<ll>b(n+1,0);
  for(ll i=0;i<n;i++){
    cin>>a[i];
    b[i+1]=b[i]+a[i];
  }
  sort(b.begin(),b.end());
  ll t=0;
  while(t<n){
    if(b[t]==b[t+1]){
      ll s=2;
      while((t+s)<=n&&b[t]==b[t+s]){
        s++;
      }
      ans+=s*(s-1)/2;
      t+=s;
    }
    else{
      t++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cmath>
#include<stack>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
const ll inf =1e17;
#define scn(a) scanf("%d",&a)
#define scd(a) scanf("%lf",&a)
#define scl(a) scanf("%lld",&a)
#define ptf(a) printf("%d\n",&a)
#define mes(a,b) memset(a,b,sizeof(a))
#define fon(s,n) for(int i=s;i<=n;i++)
#define range(i,a,b) for(int i=a;i<=b;++i)
#define rerange(i,a,b) for(int i=a;i>=b;--i)
//#define N 100010
const int S=20;
ll gcd(ll a,ll b) { return b>0 ? gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll q_pow(ll a,ll b,ll mod)
{
	ll ans=1,res=a;
	while(b){
		if(b&1) ans=ans*res%mod;
		res=res*res%mod;
		b>>=1;
	}
	return ans%mod;
}
 bool cmp(const pair<string,int> &p1, const pair<string,int> &p2) {
    return p1.second > p2.second;
}
int cnt[105]={0};
int main()
{
    int n,k,d,temp;
    scn(n);scn(k);
    while(k--){
        scn(d);
        while(d--){
            scn(temp);
            cnt[temp]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++) if(cnt[i]==0) ans++;
    printf("%d\n",ans);
}

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

	return 0;
}


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

using namespace std;

const int mxk = 1e6 + 7;

struct node {
	int nxt, to;
}edge[mxk << 1];

int tot = 0, head[mxk], k;

void addedge(int u, int v) { edge[++tot].to = v; edge[tot].nxt = head[u]; head[u] = tot; }

int n, fa[mxk], ans = 0, cnt = 0;

int dfs(int u, int depth) {
	int ret = depth; ++cnt;
	for(int i = head[u]; i; i = edge[i].nxt) 
		ret = max(ret, dfs(edge[i].to, depth + 1));
	if(fa[u] != 1 && u != 1 && ret - depth == k - 1) {++ans; return 0;}
	else return ret;
}

int main() {
	ios :: sync_with_stdio(false); 
	cin >> n >> k >> fa[1]; ans += (fa[1] != 1);
	for(int i = 2; i <= n; ++i) cin >> fa[i], addedge(fa[i], i);
	dfs(1, 0); cout << ans + n - cnt << endl;
}
/*
Vocabulary Collections : 
facility
*/

Measured memory_bytes: 13008
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]


AB = sorted(AB, key=lambda x: x[0])
ans = 0
cans = 0
for i in range(N):
    if cans + AB[i][1] >= M:
        ans += AB[i][0] * (M-cans)
        print(ans)
        quit()
    else:
        cans += AB[i][1]
        ans += AB[i][0] * AB[i][1]

Measured memory_bytes: 65368