akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n, a, b := readInt(), readInt(), readInt()
	x := n / (a + b)
	r := n % (a + b)
	fmt.Println(a*x + min(a, r))
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

void solve(){
    int N;
    cin >> N;

    vi p(N);
    int maxprice = -1;
    int total=0;
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        maxprice = max(maxprice, p[i]);
        total += p[i];
    }

    cout << maxprice / 2 + (total - maxprice) << endl;



    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)

using namespace std;

typedef pair<int, int> P;


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

    int mod = 1e9 + 7;
    int N;
    cin >> N;

    vector<P> v;
    REP(i, N) {
        int a;
        cin >> a;
        v.push_back({a, 1});
    }
    REP(i, N) {
        int b;
        cin >> b;
        v.push_back({b, 2});
    }

    sort(v.begin(), v.end());

    int ans = 1;
    stack<int> stack;
    REP(i, 2 * N) {
        P& p = v[i];
        if (stack.empty()) {
            stack.push(p.second);
            continue;
        }

        int t = stack.top();
        if (p.second != t) {
            ans = (ans * stack.size()) % mod;
            stack.pop();
        } else {
            stack.push(p.second);
        }
    }
    cout << ans << endl;

    return 0;
}


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

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

    priority_queue<int> used;
    used.push(0);
    int ans = 0;
    for(int i=0; i<n; i++){
        while(used.top() > a[i]){
            used.pop();
        }
        if(a[i] > used.top()){
            used.push(a[i]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4620
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	printf(a % 2 == b % 2 ? "Alice\n" : "Borys\n");
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (chunk) {
	var a = parseInt(chunk/3600);
	var b = parseInt((chunk%3600)/60);
	var c = parseInt((chunk%3600)%60);
    console.log(a+':'+b+':'+c);
});

Measured memory_bytes: 15596
#include <stdio.h>
#include <utility>
#include <queue>
#include <string.h>
 
int map[2000][2000],visited[1000];
 
using namespace std;
int main(void)
{
    while(true) {
        queue< pair<int,int> > q;
        int w,h,res=-1;
 
        scanf("%d%d", &w, &h);
        if(!w && !h) break;
 
        memset( map, 0, sizeof(map) );
        memset( visited, 0, sizeof(map) );
 
        for(int i=0; i < h-1; i++) {
            for(int j=0; j < w-1; j++) {
                int in;
                scanf("%d", &in);
                if(!in) {
                    map[i*w+j][i*w+j+1] = 1;
                    map[i*w+j+1][i*w+j] = 1;
                }
            }
            for(int j=0; j < w; j++) {
                int in;
                scanf("%d", &in);
                if(!in) {
                    map[i*w+j][(i+1)*w+j] = 1;
                    map[(i+1)*w+j][i*w+j] = 1;
                }
            }
        }
        {
            int i=h-1;
            for(int j=0; j < w-1; j++) {
                int in;
                scanf("%d", &in);
                if(!in) {
                    map[i*w+j][i*w+j+1] = 1;
                    map[i*w+j+1][i*w+j] = 1;
                }
            }
        }
 
        q.push(make_pair(0,0));
        while(!q.empty() && res==-1) {
            int p,d;
            std::pair<int,int> t;
 
            t=q.front(); q.pop();
            p=t.first;
            d=t.second;
//            printf(":%d:",map[p][p+h]);
 if(visited[p]) continue;
            visited[p] = 1;
 
            if(p==w*h-1) {
                res = d;
            }
 
            if(map[p][p+1] && !visited[p+1])
                q.push(make_pair(p+1, d+1));
 
            if(p-1>0 && map[p][p-1] && !visited[p-1])
                q.push(make_pair(p-1, d+1));
 
            if(map[p][p+w] && !visited[p+w])
                q.push(make_pair(p+w, d+1));
 
            if(p-w >= 0 && map[p][p-w] && !visited[p-w])
                q.push(make_pair(p-w, d+1));
 
        }
        printf("%d\n", res+1);
    }
    return 0;
}

Measured memory_bytes: 16684
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int N=in.nextInt();
    int M=in.nextInt();int A[]=new int [N];
    int i;long p=0,m=0;
    for(i=0;i<N;i++)
    {
      A[i]=in.nextInt();
      p=p+A[i];
    }
    int y=(int)Math.ceil((p/(4.0*M)));
    for(i=0;i<N;i++)
    {
      if(A[i]>=y)
      {
        m++;
      }
    }
    if(m>=M)
      System.out.println("Yes");
      else
        System.out.println("No");
  }
}
      
    


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n;
  string s;
  cin>>n;
  cin>>s;
  vector<int> R={},G={},B={};
  rep(i,n){
    if(s.at(i)=='R') R.push_back(i);
    if(s.at(i)=='G') G.push_back(i);
    if(s.at(i)=='B') B.push_back(i);
  }
  int m=B.size();
  in ans=0;
  for(int i : R){
    for(int j : G){
      
      ans+=m;
      if((i-j)%2==0){
        if(find(all(B),(i+j)/2)!=B.end())
          ans--;
      }
      int J=max(i,j);
      int I=min(i,j);
      if(find(all(B),2*J-I)!=B.end()) 
        ans--;
      if(find(all(B),2*I-J)!=B.end()) 
        ans--;
    }
  }
  cout<<ans<<endl;
  //cout<<s.size()<<endl;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<vector<ll>> dp(h+1, vector<ll>(w, 0));
    dp[0][0] = 1;
    rep(i, h) {
        rep(j, w) {
            rep(l, (1<<(w-1))) {
                // 実行可能な線の引き方か
                bool ok = true;
                rep(m, w-2) {
                    if((1 & (l>>m)) && (1 & (l>>(m+1)))) ok = false;
                }
                if(ok) {
                    // 左
                    if(j>0 && (1 & (l>>(j-1)))) {
                        dp[i+1][j-1] += dp[i][j];
                        dp[i+1][j-1] %= MOD;
                    }
                    // 右
                    else if(j<w-1 && (1 & (l>>j))){
                        dp[i+1][j+1] += dp[i][j];
                        dp[i+1][j+1] %= MOD;
                    }
                    // 下
                    else {
                        dp[i+1][j] += dp[i][j];
                        dp[i+1][j] %= MOD;
                    }
                }
            }
        }
    }
    cout << dp[h][k-1] << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

string mau1, mau2;
string mau;
int soluong[3];

int main()
{
    cin>>mau1>>mau2;
    int a,b;
    cin>>a>>b; cin.ignore();
    cin>>mau;
    
    if(mau == mau1) {a--;}
    if(mau == mau2) {b--;}
    cout<<a<<" "<<b;
}

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


int main() {
   ll n, max=-1000000, min=1000000, sum=0, a;
   cin>>n;
   rep(i, n){
         cin>>a;
        if(a>max)max=a;
         if(a<min)min=a;
        sum+=a;


}

   cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3096
mod = 10 ** 9 + 7

N = int(input())
A = [int(input().replace(" ", ""), 2) for _ in range(N)]

dp = [0] * (2 ** N)
dp[0] = 1

for state in range(2 ** N - 1):
    a = A[bin(state).count("1")] & ~state
    for j in range(N):
        if a & (1 << j):
            dp[state | (1 << j)] += dp[state]

print(dp[-1] % mod)

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

using namespace std;
typedef long long unsigned int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int n; cin >> n;
    int k; cin >> k;
    int ans;
    if (k == 1){
        ans = 0;
    } else {
        ans = n-k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

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

class BSomeSums {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, A, B;
        in >> N >> A >> B;

        int result = 0;
        for (int i = 1; i <= N; ++i) {
            int x = i;
            int sum_of_digits = 0;
            while (x > 0) {
                sum_of_digits += x % 10;
                x /= 10;
            }
            if (A <= sum_of_digits && sum_of_digits <= B) {
                result += i;
            }
        }

        out << result;
    }
};


int main() {
	BSomeSums solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  cout << (n+1)/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  const int h = S / 3600;
  const int rem = S % 3600;
  const int m = rem / 60;
  const int s = rem % 60;
  cout << h << ":" << m << ":" << s << endl;

  return 0;
}

Measured memory_bytes: 3080
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int INF = numeric_limits<int>::max();

vector<vector<int>> edge;
vector<int> a;
vector<bool> is_visited;
vector<int> result;

void dfs(int node, vector<int> &dp) {
  is_visited[node] = true;

  int j = lower_bound(dp.begin(), dp.end(), a[node]) - dp.begin();
  int prev = dp[j];
  dp[j] = a[node];

  result[node] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();

  for (int v : edge[node]) {
    if (!is_visited[v]) {
      dfs(v, dp);
    }
  }
  dp[j] = prev;
}

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

  edge.resize(N);
  a.resize(N);
  rep(i, N) { cin >> a[i]; }

  rep(i, N - 1) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }

  is_visited.resize(N, false);
  result.resize(N);
  vector<int> dp(N, INF);
  dfs(0, dp);

  rep(i, N) { cout << result[i] << "\n"; }

  return 0;
}

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

int main()
{
    int a, b, c, d, e;

    cin >> a >> b >> c >> d >> e;

    int sum;
    if( a < 0  )
        sum = a * -1 * c + d + b * e;
    else if( a == 0 )
        sum = d + b * e;
    else
        sum = ( b - a ) * e;

    cout << sum << endl;

    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long lint;

int N;
lint L, a[100005];

int main() {
	cin >> N >> L;
	for_(i,0,N) cin >> a[i];
	
	int s = -1;
	for_(i,0,N-1) if (a[i] + a[i+1] >= L) { s = i; break; }
	
	if (s == -1) return !printf("Impossible\n");
	puts("Possible");
	for_(i,0,s) cout << i+1 << endl;
	for_rev(i,N-2,s) cout << i+1 << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    long long int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<long long int> a(x);
    vector<long long int> b(y);
    vector<long long int> c(z);

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

    for (long long int i = 0; i < y; i++) {
        cin >> b[i];
    }

    for (long long int i = 0; i < z; i++) {
        cin >> c[i];
    }

    vector<long long int> d;
    for (long long int i = 0; i < x; i++) {
        for (long long int j = 0; j < y; j++) {
            d.push_back(a[i]+b[j]);
        }
    }

    sort(d.begin(), d.end(), greater<long long int>());
    long long int sz = d.size();
    vector<long long int> e;
    for (long long int i = 0; i < min(k, sz); i++) {
        e.push_back(d[i]);
    }

    vector<long long int> ans;
    for (long long int i = 0; i < z; i++) {
        for (long long int j = 0; j < e.size(); j++) {
            ans.push_back(c[i]+e[j]);
        }
    }

    sort(ans.begin(), ans.end(), greater<long long int>());

    for (long long int i = 0; i < k; i++) {
        cout << ans[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 43400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=51;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a[N],max,min,w;
	int maxi,mini,ans,ansx[2*N],ansy[2*N],key,n;
	ans=0;
	CLR(a);
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		if(i==1){
			max=min=a[i];
			maxi=mini=i;
		}
		if(a[i]>max){
			max=a[i];
			maxi=i;
		}
		if(a[i]<min){
			min = a[i];
			mini = i;
		}
	}


	w = max + min;
	if(w>=0){
		key = 0;
	}else{
		key = 1;
	}


	if(key==0){
		for(int i=1;i<=n;i++){
			if(a[i]<0){
				ans++;
				a[i]+=a[maxi];
				ansx[ans]=maxi;
				ansy[ans]=i;
			}
		}

		for(int i=1;i<n;i++){
			if(a[i]>a[i+1]){
				a[i+1]+=a[i];
				ans++;
				ansx[ans]=i;
				ansy[ans]=i+1;
			}
		}




	}else{
		for(int i=1;i<=n;i++){
			if(a[i]>0){
				ans++;
				a[i]+=a[mini];
				ansx[ans]=mini;
				ansy[ans]=i;
			}
		}

		for(int i=n;i>1;i--){
			if(a[i-1]>a[i]){
				a[i-1]+=a[i];
				ans++;
				ansx[ans]=i;
				ansy[ans]=i-1;
			}
		}
	}
	cout << ans << endl;
	for(int i=1;i<=ans;i++){
		cout << ansx[i] << " " << ansy[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");

vector<ll> tree[200001];
ll counter[200001] = {};
ll cnt[200001] = {};

void dfs(ll cur, ll pre, ll plus){
  plus += cnt[cur];
  counter[cur] += plus;
  rep(i, 0, tree[cur].size()){
    if (tree[cur][i] != pre){
      dfs(tree[cur][i], cur, plus);
    }
  }
}

int main(){
  ll n, q, a, b, p, x;
  cin >> n >> q;
  
  
  rep(i, 0, n-1){
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  /*
  rep(i, 1, n+1){
    rep(j, 0, tree[i].size()){
      cout << tree[i][j] << " ";
    }
    print("");
  }
  */
  rep(i, 0, q){
    cin >> p >> x;
    cnt[p] += x;
  }
  dfs(1, -1, 0);
  rep(i, 1, n+1){
    cout << counter[i] << " ";
  }
  
  return 0;
}

Measured memory_bytes: 28672
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;



string cot[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI",  "SAT"};

int main(){

    string day;
    cin>>day;

    for(int i=0;i<7;i++){
        if(cot[i]==day) cout<<7-i<<endl;
    }

    return 0;
}


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

x = map(int, input().split())
y = map(int, input().split())

abs_dist_lst = [abs(z[0] - z[1]) for z in zip(x, y)]

print(sum(abs_dist_lst))

for p in [2, 3]:
    dist = 0
    for abs_d in abs_dist_lst:
        dist += abs_d ** p
    dist = dist ** (1 / p)
    print(dist)

print(max(abs_dist_lst))


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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x; cin >> x;
	if (x >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3584
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char b; cin >> b;

    char ans;
    if (b == 'A') ans = 'T';
    else if (b == 'T') ans = 'A';
    else if (b == 'C') ans = 'G';
    else if (b == 'G') ans = 'C';

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define PI 3.1415926535

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
   string s; cin >> s;
   int K; cin >> K;
   vector<string> prefix;
   rep(i,s.size()){
     rep(j,min(K,(int)s.size()-i)){
       prefix.push_back(s.substr(i,j+1));
     }
   }
   sort(prefix.begin(),prefix.end());
   set<string> p;
   rep(i,prefix.size()){
     p.insert(prefix[i]);
   }
   
   auto it = p.begin();
   rep(i,K-1){
     it++;
   }
   string ans = *(it);
   cout << ans << endl;
}
   

Measured memory_bytes: 2300
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    a1, a2, a3 = intin()

    a12 = abs(a1 - a2)
    a23 = abs(a2 - a3)
    a31 = abs(a3 - a1)

    mina = min(a12 + a23, a23 + a31)
    mina = min(mina, a31 + a12)
    print(mina)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3540
import sys
from collections import deque
sys.setrecursionlimit(10 ** 9)

N = int(input())
P = [[] for i in range(N)]
ans = [0] * (N - 1)

for i in range(N - 1):
    a, b = map(int, input().split())
    P[a - 1].append((b - 1, i))


q = deque()
q.append((0, 0))

while len(q) > 0:
    c, n = q.popleft()
    ac = 1
    for l, i in P[n]:
        if ac == c:
            ac += 1
        q.append((ac, l))
        ans[i] = ac
        ac += 1

print(max(ans))
for a in ans:
    print(a)


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

using namespace std;

int n, x[100005], y[100005], z[100005], ta;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d%d", x + i, y + i, z + i);
	for (int i = 1; i <= n; i++) {
		ta = abs(y[i - 1] - y[i]) + abs(z[i - 1] - z[i]);
		if (ta > x[i] - x[i - 1] || ta % 2 != (x[i] - x[i - 1]) % 2) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

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

class Point{
public:
  ll x, y;

  Point() {}
  Point(ll x, ll y):
    x(x), y(y) {}

  Point operator - (Point const & right){
    return Point(x - right.x, y - right.y);
  }

  ll cross_product(Point const & right){
    return x * right.y - y * right.x;
  }

  bool operator < (Point const & right) const{
    return (x < right.x) || ((x == right.x) && (y < right.y));
  }

  bool operator ==(Point const & right) const{
    return (x == right.x) && (y == right.y);
  }
};

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

  vector<Point> xy(N);
  for(int i = 0; i < N; i++){
    cin >> xy[i].x >> xy[i].y;
  }
  sort(xy.begin(), xy.end());

  int ans = 50;
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      Point pq = xy[j] - xy[i];
      vector<bool> checked(N, false);
      int ans_tmp = 0;
      for(int k = 0; k < N; k++){
	if(!checked[k]){
	  checked[k] = true;
	  ans_tmp++;
	}
	for(int l = k + 1; l < N; l++){
	  if(xy[l] - xy[k] == pq){
	    checked[l] = true;
	  }
	}
      }
      ans = min(ans, ans_tmp);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	
	//read input
	public static void main(String[] args) {
		int N = 0;
		int W = 0;
		
		Scanner sc = new Scanner(System.in);
		
		 N = sc.nextInt();
		 int[] v = new int[N+1]; //0 to v
		 W = sc.nextInt();
		 int[] w = new int[N+1]; //0 to W
		
		for(int i = 1; i <= N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		
		int sumValues = 0;
		
		for(int value : v) {
			sumValues += value;
		}
		
		long[] dp = new long[sumValues+1]; //dp[i][j] max value from 1 to i with max weight j
		
		for(int i = 1; i < sumValues+1; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		for (int i = 1; i <= N; ++i) {
			for(int j = sumValues; j >= v[i]; --j) {
				dp[j] = Math.min(dp[j], dp[j - v[i]] + w[i]);
			}	
		}
		
		int max = 0;
		for(int i = 0; i <= sumValues; i++) {
			if(dp[i] <= W) {
				max = Math.max(max, i);
			}
		}
		
	   
	 System.out.println(max);
	}
}


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

using namespace std;

int main(){
    int a,b,c,d,n;
    cin >> n;
    a=(n/1000)%10,b=(n/100)%10,c=(n/10)%10,d=n%10;
    if((a==b&&b==c&&c==a)||(b==c&&c==d&&d==b)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define maxm 
#define mod 
#define maxn 100010
vector<int> w[maxn];
int a[maxn], b[maxn], c[maxn];
ll d[maxn];
void dfs(int x, int p) {
	for (int i = 0; i < w[x].size(); i++) {
		if (a[w[x][i]] == x) {
			if (b[w[x][i]] == p) continue;
			int y = b[w[x][i]];
			d[y] += d[x] + c[w[x][i]];
			dfs(y, x);
		} else {
			if (a[w[x][i]] == p) continue;
			int y = a[w[x][i]];
			d[y] += d[x] + c[w[x][i]];
			dfs(y, x);
		}
	}
} 
int main()
{
	int n, x, y, q, k;
	
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
		w[a[i]].push_back(i);
		w[b[i]].push_back(i);
	}
	scanf("%d%d", &q, &k);
	dfs(k, 0);
	while (q--) {
		scanf("%d%d", &x, &y);
		printf("%lld\n", d[x] + d[y]);
	}
}

Measured memory_bytes: 15488
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;

int n, m, dp[1005][1005];
string str[1005];

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

    cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        cin >> str[i];
        str[i] = " " + str[i];
    }

    dp[1][1] = 1;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (str[i][j] == '.')
                dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }

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

    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0; i<N; i++)cin>>a[i];
  int c=1,d=0;
  bool b=false;
  for(int i=0; i<200000; i++){
     c=a[c-1];d++;
     if(c==2){b=true;break;}
  }
  cout<<(b ? d:-1)<<endl;
}

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

signed main() {
  int N;
  cin >> N;
  
  vector<int> P(N);
  int cnt = 0;
  bool mae = false;
  for( int i = 0; i < N; i++ ){
    cin >> P.at(i);
    if( P.at(i) == i+1 ){
      if( mae == true ) mae = false;
      else{
        cnt++;
        mae = true;
      }
    }else{
      mae = false;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const ll N=1e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    if (s.find('A')!=-1&&s.find('B')!=-1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<vector<pair<int,int>>> A(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    for(int j=0;j<a;j++){
      int k,l;
      cin>>k>>l;
      A.at(i).push_back(make_pair(k-1,l));
    }
  }
  int k=0;
  for(int tmp=0;tmp<(1<<N);tmp++){
    bitset<15> s(tmp);
    bool bo=false;
    for(int i=0;i<N;i++){
      if(!s.test(i))
        continue;
      for(pair<int,int> j:A.at(i)){
        if(s[j.first]^j.second){
          bo=true;
          break;
        }
      }
      if(bo)
        break;
    }
    if(bo)
      continue;
    k=max(k,(int)(s.count()));
  }
  cout<<k<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	string s; cin >> s;
	vector<string> ss(3);
	for (int i = 0; i < 3; i++) {
		ss[i] = s[i];
	}
	ssort(ss);
	eerase(ss);
	if (ss.size() != 3)cout << "No";
	else cout << "Yes";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int n;
  scanf("%d\n", &n);

  vector<tuple<string, int, int>> rests(n);

  char str[20];
  REP(i, n) {
    scanf("%s", str);
    get<0>(rests[i]) = string(str);
    scanf("%d\n", &get<1>(rests[i]));
    get<1>(rests[i]) = 100 - get<1>(rests[i]);
    get<2>(rests[i]) = i + 1;
  }

  sort(ALL(rests));

  REP(i, n) {
    printf("%d\n", get<2>(rests[i]));
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),aa(100005);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
        aa[a[i]]++;
    }
    ll q;
    cin>>q;
    vector<ll> vsum(q);
    rep(i,q){
        ll b,c;
        cin>>b>>c;
        sum+=(aa[b]*(c-b));
        aa[c]+=aa[b];
        aa[b]=0;
        vsum[i]=sum;
    }
    rep(i,q){
        cout<<vsum[i]<<endl;
    }

}

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

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	string N;
  	cin>>N;
  		
  	cout<<"ABC"<<N<<endl;
  	
  	
  
  
}

Measured memory_bytes: 3540
import numpy as np

N, D = map(int,input().rstrip().split())
li = [[int(_) for _ in input().rstrip().split()] for __ in range(N)]

count = 0
for i in range(N-1):
    for j in range(i+1, N):
        if np.linalg.norm(np.array(li[i])-np.array(li[j])).is_integer():
            count += 1

print(count)

Measured memory_bytes: 12448
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
#include <fstream>
#include <random>
#include <set>
#include <queue>
#include <complex>
#include <stack>
#include <numeric>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
using namespace std;
std::vector<bool> IsPrime;



void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない
    
    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
inline void InitRand()
{
    srand((unsigned int)time(NULL));
}

int main() {
    //InitRand();
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //std::ifstream in("input.txt");std::cin.rdbuf(in.rdbuf());
    
    long long n,m;
    cin>>n>>m;
    if(m==1&&n==1){cout<<1<<endl;return 0;}
    if(m==1){cout<<n-2<<endl;return 0;}
    if(n==1){cout<<m-2<<endl;return 0;}
    long long ans=0;
    if(0>=n-2){n=0;}else{n=n-2;}
    if(0>=m-2){m=0;}else{m=m-2;}
    ans=n*m;
    cout<<ans<<endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	void solve(){
		lli N,i,j,res,p,q;
		cin>>N;
		for(i=0;i<N;i++){
			cin>>arr[i];
		}
		arr[0]-=1;
		for(i=1;i<N;i++){
			//if(arr[i]<arr[i-1])arr[i]-=1;
			if(arr[i]<arr[i-1]){
				cout<<"No\n";
				return;
			}
			if(arr[i]>arr[i-1])arr[i]-=1;
		}
		cout<<"Yes";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

const int inf = 1e9 + 7;
int n, m;
vector<vector<int>> g;
int s, t;
// dp[頂点][距離%3]=回数
vector<vector<int>> dp;

void bfs() {
    queue<pair<int, ll>> q;
    q.emplace(s, 0);
    while(!q.empty()) {
        pair<int, ll> p = q.front(); q.pop();
        for(auto e : g[p.first]) {
            int parity = (p.second + 1) % 3;
            int count = (p.second + 3) / 3;
            if (dp[e][parity] > count) {
                dp[e][parity] = count;
                q.emplace(e, p.second + 1);
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    cin >> n >> m;
    g.resize(n);
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
    }
    cin >> s >> t;
    s--; t--;
    dp.resize(n, vector<int>(3, inf));
    dp[s][0] = 0;
    bfs();
    if (dp[t][0] == inf) {
        cout << -1 << endl;
    }
    else {
        cout << dp[t][0] << endl;
    }
    return 0;
}


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

int main(){

    string S,T,U;
    int A,B;
    cin >> S >> T>>A>>B>>U;

    if(S == U)        cout << A-1 <<" "<<B;
    

    else if(T == U) cout << A <<" "<< B-1;


}



Measured memory_bytes: 256
N, L = map(int, input().split())

low = L+1-1
high = L+N-1
total = (low+high)*N//2

min_diff = 10**4
min_total = -1
for i in range(N):
    diff = abs(L+i)
    if diff < min_diff:
        min_diff = diff
        min_total = total - (L+i)
print(min_total)


Measured memory_bytes: 9000
def main(argv)
  n = gets.chomp.to_i
  s = gets.chomp
  
  flag = false
  if (n % 2) == 0 then
    m = n / 2
    t = s[0...m]
    flag = (s == (t + t))
  end
  
  puts (flag ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using namespace std;

int n;
string s;

int main() {
  cin >> n >> s;
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) ans++;
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n+1);
  int max=0;
  cin >> a[0];
  a[n]=k+a[0];
  for (int i=1;i<=n;++i){
    if(i<n){
      cin >> a[i];
    }
    max = a[i]-a[i-1] > max ? a[i]-a[i-1] : max;
  }
  cout << k - max << endl;
  return 0;
}


Measured memory_bytes: 1024
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

int n;
cin>>n;
vpll v;
for(int i=0;i<n;i++)
{
	ll a,b;
	cin>>a>>b;
	v.pb(mp(b,a));
}

sort(all(v));

ll s=0;
bool f=true;

for(int i=0;i<n;i++)
{
	s+=v[i].se;
	if(s>v[i].fi)
	{
		f=false;
		break;
	}
}

if(f)
cout<<"Yes";
else
cout<<"No";




}return 0;}

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

using namespace std;

int main() {
	vector<int> sprime(200000, 0);
	sprime[0] = 2;
	int a = 1;
	for (int i = 3; i < 123456 * 2; i += 2) {
		int k = 3;
		while (k<=sqrt(i)) {
			if (i % k == 0) break;
			k += 2;
		}
		if (k > sqrt(i)) {
			sprime[a] = i;
			a++;
		}
	}

	int n;
	while (cin >> n && n) {
		int cnt = 0;
		for (int i = 0; i < n; ++i)
			if (n < sprime[i] && sprime[i] <= 2 * n) cnt++;
		cout << cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 3384