akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
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 MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

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



int main(){
    int N,x; cin >> N >> x;
    if(x == 1 || x == 2*N-1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    vector<int> ans(2*N-1);
    vector<bool> ok(2*N-1,false);
    if(x == 2){
        int d = (2*N-1)/2;
        ans[d-1] = x+1;
        ans[d] = x;
        ans[d+1] = x-1;
        ans[d+2] = x+2;
        ok[d-1] = ok[d] = ok[d+1] = ok[d+2] = true;
        int now = 5;
        rep(i,2*N-1){
            if(!ok[i]){
                ans[i] = now;
                ok[i] = true;
                now++;
            }
        } 
    }
    else{
        int d = (2*N-1)/2;
        ans[d-1] = x-1;
        ans[d] = x;
        ans[d+1] = x+1;
        ans[d+2] = x-2;
        ok[d-1] = ok[d] = ok[d+1] =ok[d+2] = true;
        int now = 1;
        rep(i,2*N-1){
            if(now == x-2) now += 4;
            if(!ok[i]){
                ans[i] = now;
                ok[i] = true;
                now++;
            }
        }
    }
    rep(i,2*N-1) cout << ans[i] << endl;
}



Measured memory_bytes: 2304
#include<iostream>
#include<set>
using namespace std;
int main(){
  long long n,i,a,ans=0,p[222222];
  cin>>n;
  for(i=1;i<=n;i++){
    cin>>a;
    p[a]=i;
  }
  set<long long> s;
  set<long long> s2;
  s.insert(0);
  s.insert(n+1);
  s2.insert(0);
  s2.insert(-n-1);
  for(i=1;i<=n;i++){
    auto itr1=s2.lower_bound(-p[i]);
    auto itr2=s.upper_bound(p[i]);
    ans+=(*itr2-p[i])*(p[i]+*itr1)*i;
    s.insert(p[i]);
s2.insert(-p[i]);
  }
  cout<<ans<<endl;
}


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

#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    # include <bits/stdc++.h>
#endif

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

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

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

#define arr (int)(5e5+10)

int bpow(int a,int n)
{
    int res=1;
    while (n){
        if (n&1){
            res=res*a%md;
        }
        n/=2;
        a=a*a%md;
    }
    return res;
}

int f[arr];
int rf[arr];

int C(int n,int k)
{
//    cerr<<"C("<<n<<","<<k<<")"<<"\n";
//    cerr<<f[n]<<" "<<rf[n-k]<<" "<<rf[k]<<"\n";
    return f[n]*rf[n-k]%md*rf[k]%md;
}

signed main()
{
    #ifdef __APPLE__
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    f[0]=1;
    for (int i=1;i<arr;i++){
        f[i]=f[i-1]*i%md;
    }
    rf[arr-1]=bpow(f[arr-1],md-2);
    for (int i=arr-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%md;
    }

    int n,m;
    cin>>n>>m;
    int ans=0;
    for (int i=0;i<=n;i++){
        int kf=(i%2==0?+1:-1);
        int cur=C(n,i)*C(m,i)%md*f[i] %md* C(m-i,n-i)%md*C(m-i,n-i)%md*f[n-i]%md*f[n-i];
//        cout<<i<<" :: "<<kf<<" "<<cur<<"\n";
        ans+=kf*cur;
        ans%=md;
        if (ans<0){
            ans+=md;
        }
    }
    cout<<ans<<"\n";
}


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

namespace ALDS1_11_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            d = new int[n];
            f = new int[n];
            time = 1;

            Vertexes = new List<int>[n];
            for (int i = 0; i < n; i++)
            {
                Vertexes[i] = new List<int>();

                var input = ReadInt();
                for (int j = 0; j < input[1]; j++)
                {
                    Vertexes[i].Add(input[j + 2]);
                }
            }

            for (int i = 0; i < n; i++)
            {
                int id = i + 1;
                if (d[i] == 0) DFS(id);
            }

            for (int i = 0; i < n; i++)
            {
                string ans = i + 1 + " " + d[i] + " " + f[i];
                Console.WriteLine(ans);
            }
            Console.ReadKey();
        }

        static int[] d;
        static int[] f;
        static int time;
        static List<int>[] Vertexes;
        static void DFS(int vs) //頂点番号　1始まり
        {
            if (d[vs - 1] != 0) return;
            d[vs - 1] = time;
            time++;

            foreach (var v in Vertexes[vs - 1])
            {
                DFS(v);
            }

            f[vs - 1] = time;
            time++;
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



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

signed main() {

	int n, k;
	int x[111];
	int sum = 0;
	cin >> n >> k;

	for(int i = 0; i < n; i++) {
		cin >> x[i];
		sum += min(x[i], k - x[i]) * 2;
	}


	cout << sum << endl;
}
	


Measured memory_bytes: 256
h,w = map(int,input().split())
c = 0
if w%2 == 0:
    c = (w//2)*h
else:
    if h%2 == 0:
        c = (h//2)*w
    else:
        c = ((h//2)+1)*((w//2)+1)+(h//2)*(w//2)

if h == 1 or w == 1:
    c = 1
print(c)

Measured memory_bytes: 2940
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int N;
  cin >> N;
  vector<ll> A(N);
  ll l, r = 0;
  REP(i, N) {
    cin >> A[i];
    r += A[i];
  }
  ll ans = abs(l - r);
  REP(i, N) {
    l += A[i];
    r -= A[i];
    chmin(ans, abs(l - r));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Vector;

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

    Vector<Integer> vec = new Vector<Integer>();
    while(sc.hasNextInt()){
      vec.add( sc.nextInt() );
    }
		for ( Integer n : vec ){
			long debt = 100000;
			for ( int i = 0; i < n; ++i ){
				long add = debt / 20;
				long mod = add % 1000;
				if ( 0 < mod) {
					add = add + (1000-mod);
				}
				debt += add;
			}
			System.out.println(debt);
		}

  }
}

Measured memory_bytes: 15336
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 1000040
 
const int  m = 1000033;
//const int  m2= 1000003;
//7069 - 60
char stack[MAX][15];
int h1(long long);
int h2(long long);
int insert(long long,int);
long long sti(char *);
 
int main(){
  int val,i,j,n,dic=0,dicc=MAX,index2=0,vall;
  char op[15],s[15];
  int exist=-1,index=0;
 
  while(scanf("%d",&n) != EOF){
    dic=0,dicc=MAX;
    for(i=0;i<=MAX;i++)strcpy(&stack[i][0],"not");
    for(i=0;i<n;i++){
      exist=-1;
      scanf("%s %s",op,s);
      if(op[0] == 'i'){
    index=0;
    while(1){
      val = insert(sti(&s[0]),index);
      if(strcmp(&stack[val][0],"not") == 0){
        strcpy(&stack[val][0],&s[0]);
        break;
      }
      else index++;
      if(index == MAX)break;
    }
      }
      else if(op[0] =='f'){
    index2=0;
    while(1){
      vall=insert(sti(s),index2);
      if(strcmp(stack[vall],s) == 0){
        exist=1;
        break;
      }
      else if(strcmp(&stack[vall][0],"not") == 0){
        break;
      }
      index2++;
      if(index2 == MAX)break;
    }
    if(exist == 1)printf("yes\n");
    else printf("no\n");
      }
    }
  }
  return 0;
}
 
 
int h1(long long k){
  return k%m;
}
 
int h2(long long k){
  return 1+k%(m-1);
}
 
int insert(long long k,int i){
  return (h1(k) + i*h2(k))%m;
}
 
long long sti(char *s){
  long long i=0,sum=0;
  while(s[i] != '\0'){
    sum*=10;
    sum+=s[i]-'A'+1;
    i++;
  }
  return sum;
}






Measured memory_bytes: 16448
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	int n;
	cin >> n;
	int x = n % 1000;
	if (x == 0)cout << 0 << endl;
	else cout << 1000 - x << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n;
    cin >> n;
    map<pair<int, int>, int> cand;

    int res = 0;
    rep(i, n){
        int a;
        cin >> a;
        --a;

        if(cand[make_pair(min(i, a), max(i, a))] > 0){
            ++res;
            --cand[make_pair(min(i, a), max(i, a))];
        }
        else ++cand[make_pair(min(i, a), max(i, a))];
    }

    cout << res << endl;

    return 0;
}

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

int main()
{
  int a, b, c, d, e, f ;
  cin >> a >> b >> c >> d >> e >> f ;
  cout << fixed << setprecision(6) ;
  a *= 100 ;
  b *= 100 ;  
  double concent = 0 ;
  double ans_conc = 0 ;
  int answer = 0 ;
  int ans_sugar = 0 ;
  
  for(int i = 0 ; i * a <= f ; i++)
  {
    for(int j = 0 ; j * b <= f ; j++)
    {
      int water = i * a + j * b ;
      if(water == 0 || water > f)
      {
        continue ;
      }

      for(int k = 0 ; k * c <= f ; k++)
      {
        for(int l = 0 ; l * d <= f ; l++)
        {
          int sugar = k * c + l * d ;
          if(water + sugar > f || sugar > e * (water / 100))
          {
            continue ;
          }
          
          concent = (double)sugar * 100 / ( (double)water + (double)sugar ) ;
          ans_conc = max(ans_conc , concent) ;
          if(concent == ans_conc)
          {
            answer = water + sugar ;
            ans_sugar = sugar ;
          }
        }
      }
    }
  }
  
  cout << answer << " " << ans_sugar << endl ;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> token = new ArrayList<>();

		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			token.add(sc.nextInt());
		}
		int M = sc.nextInt();

		for (int i = 0; i < M; i++) {
			int ind = sc.nextInt()-1;
			if (token.get(ind) == 2019 || token.contains(token.get(ind) + 1)) {
				continue;
			} else {
				token.set(ind, token.get(ind) + 1);
			}
		}

		for(int num : token) {
			System.out.println(num);
		}

	}
}



Measured memory_bytes: 26504
#include <stdio.h>
int main(void){
    int a[100]={0};
    int n;
    int i;
    int max=0;
    
    while(scanf("%d\n", &n)!=EOF) a[n-1]++;
    
    for(i=0; i<100; i++){
        if(a[i]>max) max=a[i]; 
    }
    
    for(i=0; i<100; i++){
        if(max==a[i]) printf("%d\n", i+1);
    }
    
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int a, b,c;
    cin >> a >> b;
    if(a!=1 and b!=1)
        c = 1;
        if(a!=2 and b!=2)
            c = 2;
            if(a!=3 and b!=3)
                c = 3;
            cout << c;
            return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
using namespace std;
long long n;
vector<int> data;
void dfs(long long x) {
	if (x <= n) {
		data.push_back(x);
		dfs(x * 10 + 3);
		dfs(x * 10 + 5);
		dfs(x * 10 + 7);
	}
}

int main(void) {
	int cnt=0;
	cin >> n;
	dfs(0);
	
	for (int i = 0; i < data.size(); i++) {
		stringstream ss;
		ss << data[i];
		string str = ss.str();
		bool three, five, seven;
		three = five = seven = false;
		for (int j = 0; j < str.length(); j++) {
			if (str.at(j) == '3') three = true;
			if (str.at(j) == '5') five = true;
			if (str.at(j) == '7') seven = true;
		}
		if (three && five && seven) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##################################
# University of Wisconsin-Madison
# Author: Yaqi Zhang
##################################

# standard library
import sys

def cmb(n, r, mod):
    r = min(r, n - r)
    x, y = 1, 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod - 2, mod)
    return x * y % mod


def main():
    import math
    n, a, b = map(int, input().split())
    MOD = int(1e9 + 7)
    ans = pow(2, n, MOD) - 1
    ans = ans - cmb(n, a, MOD) - cmb(n, b, MOD)
    while ans < 0:
        ans += MOD
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int to_int(vector<int> &v) {
    int res = 0;
    for (int k: v) res = res * 10 + k;
    return res;
}

int main() {
    int n, m, s, c;
    cin >> n >> m;
    vector<int> di(n, -1);
    for (int i=0; i<m; ++i) {
        cin >> s >> c;
        if (di[s-1] == -1 || di[s-1] == c) di[s-1] = c;
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    if (n > 1 && di[0] == 0) {
        cout << -1 << endl;
        return 0;
    }
    
    if (di[0] == -1) {
        if (n == 1) di[0] = 0;
        else di[0] = 1;
    }
    for (int i=0; i<(int)di.size(); ++i) {
        if (di[i] == -1) di[i] = 0;
    }
    cout << to_int(di) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int l;
  int r;
  int d;
  int count = 0;
  
  cin >> l;
  cin >> r;
  cin >> d;
  for (int i = l; i <= r;i++){
    if((i % d) == 0 ){
      count++;
    }
  }

    cout << count;
  
  return 0;

}

Measured memory_bytes: 3560
//ÈÓã Çááå æáÇ Íæá æáÇ ÞæÉ ÅáÇ ÈÇááå 
#include<bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define pb push_back
#define fast ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
using namespace std;
ll t,n,m,k,x,y,sum,con,ans;
ll a,b;
//ll a[2020202],b[2020202];
pair<ll,ll>p;
map<string,ll>mp;
vector<ll>v;
set<ll>st;
set<ll>::iterator it;
string s;
int main(){
	fast;
	cin>>t;
	while(t--){
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<'\n';
	cout<<"WA x "<<mp["WA"]<<'\n';
	cout<<"TLE x "<<mp["TLE"]<<'\n';
	cout<<"RE x "<<mp["RE"]<<'\n';
}

Measured memory_bytes: 3668
n = int(input())
a = list(map(int, input().split()))

import collections

c = collections.Counter(a)

s = 0
for i in c:
    j = c[i]

    s += j * (j - 1) // 2

for i in range(n):
    j = c[a[i]]
    s2 = s - j * (j - 1) // 2 + max(0, (j - 1) * (j - 2) // 2)
    print(s2)


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


using namespace std;

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

	int n;
	cin >> n;

	vector<long long> a(n), b(n);
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = x; b[i] = y;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	long long ret;

	if (n % 2 == 1) {
		ret = b[n / 2] - a[n / 2] + 1;
	} else {
		ret = b[n / 2 - 1] + b[n / 2] - (a[n / 2 - 1] + a[n / 2]) + 1;
	}
	cout << ret << "\n";

}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

class Human {
 public:
  // int id;
  vector<pair<int, bool> > answers;
};

int GetBinFromDec(int dec, const int& digit) {
  // example
  // dec: 5
  // bin: B101
  // when digit is 0, return 1
  // when digit is 1, return 0
  // when digit is 2, return 1
  // when digit is 3, return -1

  if (digit < 0) return -1;
  for (int i = 0; i < digit; i++) {
    dec /= 2;
  }
  return dec % 2;
}

int main() {
  int n;
  cin >> n;
  vector<Human> people(n);
  FOR(i, 0, n) {
    // people[i].id = i;
    int a;
    cin >> a;
    FOR(j, 0, a) {
      int x, y;
      cin >> x >> y;
      people[i].answers.push_back(pair<int, bool>(x - 1, y));
    }
  }
  int case_max = pow(2, n);
  int ans = 0;
  FOR(i, 0, case_max) {
    bool is_able = true;
    FOR(j, 0, n) {
      int bin = GetBinFromDec(i, j);
      if (bin == -1) {
        cout << "error" << endl;
        return 0;
      }
      if (bin == 0) continue;
      FOR(k, 0, people[j].answers.size()) {
        int check_id = people[j].answers[k].first;
        int target_flag = GetBinFromDec(i, check_id);
        if (target_flag != people[j].answers[k].second) {
          is_able = false;
          break;
        }
      }
      if (!is_able) break;
    }
    if (!is_able) continue;
    int test_ans = 0;
    FOR(j, 0, n) {
      if (GetBinFromDec(i, j) == 1) test_ans++;
    }
    ans = max(test_ans, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	h := make([]int, n)
	
	max := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
		if max < h[i] {
			max = h[i]
		}
		if max-1 > h[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 6316
// https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

type Graph = Vec<Vec<usize>>;

fn dfs(now: usize, par: usize, g: &Graph) {

}


fn main() {
    input! {
        n: usize,
        edges: [(usize1, usize1); n-1],
        c: [u64; n],
    };
    let mut c = c;
    c.sort();

    let mut g = vec![vec![]; n];
    for &(u, v) in &edges {
        g[u].push(v);
        g[v].push(u);
    }

    let mut visited = vec![false; n];
    visited[0] = true;
    let mut deq = VecDeque::new();
    deq.push_back(0);

    let mut ans = vec![0; n];
    while let Some(now) = deq.pop_front() {
        ans[now] = c.pop().unwrap();
        for &to in &g[now] {
            if visited[to] {
                continue;
            }
            visited[to] = true;
            deq.push_back(to);
        }
    }

    let total = ans.iter().fold(0, |a, c| a + c) - ans[0];
    let line = ans.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" ");
    println!("{}", total);
    println!("{}", line);
}


Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int INF = 1e9 + 5;

int n, a[N];

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for (int i = 1; i <= 3; ++i) {
		cin >> a[i];
	}
	sort(a + 1, a + 3 + 1);
	if(a[1] == a[2] && a[2] != a[3]) {
		cout << "Yes\n";
	}
	else if (a[1] != a[2] && a[2] == a[3]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

/*int par[100000];

void init(int n){
    for(int i=0; i<n; i++) par[i] = i;
}

int find(int x){
    if(par[x] == x) return x;
    else{
        par[x] = find(par[x]);
        return par[x];
    }
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    par[x] = y;
}*/

int main(){
	int H,R;
	cin>>H>>R;
	if(H>-R){
		cout<<1<<endl;
	}
	if(H==-R){
		cout<<0<<endl;
	}
	if(H<-R){
		cout<<-1<<endl;
	}

	/*
int W;
cin>>W;
cout<<W*32<<endl;*/

    return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    if (k <= a) {
        cout << k << endl;
    }
    else if (a < k && k <= a + b) {
        cout << a << endl;
    }
    else if (a + b < k && k <= a + b + c) {
        cout << a - (k - (a + b)) << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>

using namespace std;

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

	bool makeable = false;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			if ((i * m + j * n - i * j * 2) == k)
				makeable = true;
	printf("%s\n", (makeable ? "Yes" : "No"));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}

void solve()
{
  //code begins from here//
  ll n;
  cin>>n;
  if(n%1000==0) cout<<"0"<<endl;
  else cout<< 1000-(n%1000)<<endl;
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
   // cin>>testcase;
    while(testcase--) solve();
    return 0;
}


Measured memory_bytes: 3612
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
int main(){
    long long int N;
    cin >> N;
    long long int A[N];
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    sort(A,A+N);
    long long int num=0;
    long long int count=0;
    long long int res=0;
    long long int act=0;
      
        count =0;
        while(res<N){
              act=A[res];
              count=0;
        while(res<N && act==A[res]){
            count++;
            res++;
        }
        num+=count%2;
        }
    cout << num;
    }

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

using namespace std;

typedef long long ll;

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

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

	int k;
	cin >> k;

	ll ans = 0;
	for(int a = 1; a <= k; a++){
		for(int b = 1; b <= k; b++){
			for(int c = 1; c <= k; c++){
				ans += mygcd(mygcd(a, b), c);
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3648
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

type move struct {
	xs, ys, xe, ye int
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	H, W := getInt(), getInt()
	a := make([][]int, H)
	odd := 0
	for i := 0; i < H; i++ {
		a[i] = make([]int, W)
		for j := 0; j < W; j++ {
			a[i][j] = getInt()
			if a[i][j]%2 == 1 {
				odd++
			}
		}
	}

	x := 0
	y := 0
	cnt := 0
	dx := 1
	m := make([]move, 0)
	for i := 0; i < H*W; i++ {
		if a[y][x]%2 == 1 {
			cnt++
		}
		nx := x
		ny := y
		nx += dx
		if nx == W {
			nx--
			dx = -1
			ny++
		}
		if nx < 0 {
			nx++
			dx = 1
			ny++
		}
		if cnt%2 == 1 {
			if cnt < odd {
				m = append(m, move{x, y, nx, ny})
			}
		}
		x = nx
		y = ny
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	fmt.Fprintln(w, len(m))
	for _, v := range m {
		fmt.Fprintf(w, "%d %d %d %d\n", v.ys+1, v.xs+1, v.ye+1, v.xe+1)
	}
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000
vector<int> cnt;
int N;

struct Next{
	int to;
	long long cost;
	int maxi;
	int other;
};


int dfs(vector<vector<Next>> &E,int now,int p){
	cnt[now] = 1;
	int ind = -1;
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i].to;
		if(to==p){
			ind = i;
			continue;
		}
		cnt[now] += dfs(E,to,now);
		E[now][i].maxi = cnt[to];
	}
	if(ind!=-1){
		E[now][ind].maxi = N-cnt[now];
	}
	return cnt[now];
}

int main(){
	
	
	cin>>N;
	vector<vector<Next>> E(N,vector<Next>());

	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		long long c;
		cin>>c;
		
		struct Next n = {b,c,0,E[b].size()};
		
		E[a].push_back(n);
		n.to=a;
		n.other = E[a].size()-1;
		E[b].push_back(n);
	}

	cnt.resize(N,0);
	
	dfs(E,0,-1);
	
	long long ans = 0LL;
	
	long long temp = 0LL;
	for(int i=0;i<N;i++){
		for(int j=0;j<E[i].size();j++){
			int to = E[i][j].to;
			if(i>to)continue;
			int x = min(cnt[i],cnt[to]);
			int y = N-x;
			temp += E[i][j].cost * min(x,y)*2;
		}
	}
//	cout<<temp<<endl;
	
	vector<vector<int>> M0(N,vector<int>()),M1(N,vector<int>());
	for(int i=0;i<N;i++){
		for(int j=0;j<E[i].size();j++)M0[i].push_back(E[i][j].maxi);
	}
	M1 = M0;
	
	for(int i=0;i<N;i++){
		for(int j=1;j<E[i].size();j++)M0[i][j] = max(M0[i][j],M0[i][j-1]);
		
		if(E[i].size()>=2){
			for(int j=E[i].size()-2;j>=0;j--)M1[i][j] = max(M1[i][j],M1[i][j+1]);
		}
		
	}

	for(int i=0;i<N;i++){
		for(int j=0;j<E[i].size();j++){
			int to = E[i][j].to;
			if(i>to)continue;
			int maxi = 0;
			if(j!=0)maxi = max(maxi,M0[i][j-1]);
			if(j+1<M1[i].size())maxi = max(maxi,M1[i][j+1]);
			int toj = E[i][j].other;
			if(toj!=0)maxi = max(maxi,M0[to][toj-1]);
			if(toj+1<M1[to].size())maxi = max(maxi,M1[to][toj+1]);
			//if(to==4)cout<<maxi<<endl;
			if(maxi<(N+1)/2){
				ans = max(ans,temp-E[i][j].cost);
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 29812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  string s, t;
  cin >> s >> t;
  int dp[sz(s) + 2][sz(t) + 2];
  rep(i, sz(s) + 2) rep(j, sz(t) + 2) dp[i][j] = 0;

  rep(i, sz(s) + 1) rep(j, sz(t) + 1) {
    // i, j からいけるとこ
    chmax(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]));
    chmax(dp[i + 1][j], dp[i][j]);
    chmax(dp[i][j + 1], dp[i][j]);
  }
  // cout << dp[sz(s)][sz(t)] << endl;
  // rep(i, sz(s) + 1) { rep(j, sz(t) + 1) cout << dp[i][j] << " "; cout << endl; }
  int i = sz(s), j = sz(t);
  string u;
  while (1) {
    while (j && dp[i][j - 1] == dp[i][j]) j--;
    while (i && dp[i - 1][j] == dp[i][j]) i--;
    if (i < 0 || j < 0 || dp[i][j] == 0) break;

    if (i) u += s[i - 1]; // debuged, if (i)
    i--; j--;
  }
  reverse(all(u));
  // cout << sz(u) << endl;
  cout << u << endl;
}


Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAX = 1000010;

bool p[MAX];

int main ( void )
{
	fill(p, p+MAX, true);
	p[0] = p[1] = false;
	for (int i = 2, I = sqrt(MAX)+1; i < I; ++i) {
		if (!p[i]) { continue; }
		for (int j = i+i; j < MAX; j+=i) { p[j] = false; }
	}

	int a, d, n;
	while (cin >> a >> d >> n, a|d|n) {
		int i = 0;
		while (i != n) {
			if (p[a]) { ++i; }
			a += d;
		}
		cout << a - d << endl;
	}
	return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;


int main(void) {
    int N, K;
    scanf("%d %d", &N, &K);

    while(N!=0) {
        N /= K;
        ans++;
    }
   

  
    printf("%d\n", ans);

	return 0;
}


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

Measured memory_bytes: 3920
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
  scanf("%d %d",&n,&q);
  printf("%d",max(0,n-2*q));

return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep1(i, n){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end(), greater<ll>());
    rep1(i, n){
        if (a[i]==b[0]) cout << b[1] << endl;
        else cout << b[0] << endl;
    }
}

Measured memory_bytes: 6308
import sys
input = sys.stdin.readline

N = int(input())
s = [int(input()) for _ in range(N)]

dp = {0}
for i in range(N):
    tmp = set()
    for x in dp:
        tmp.add(x + s[i])
    dp |= tmp

dp = [x for x in sorted(dp) if x % 10 != 0]
if len(dp) > 0:
    print(dp[-1])
else:
    print(0)


Measured memory_bytes: 4656
package main

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

func main() {
	nextReader = NewScanner()
	line1 := nextInt()
	N := line1[0]
	C := line1[2]

	var ints [][]int
	B := nextInt()
	for i := 0; i < N; i++ {
		ints = append(ints, nextInt())
	}

	var count int
	for _, v := range ints {
		var sum int
		for i := 0; i < len(v); i++ {
			sum += v[i] * B[i]
		}
		if sum+C > 0 {
			count++
		}
	}

	fmt.Println(count)
}

// ------ Mathライブラリ ---------------------------------//
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func maxIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minIdx(a ...int) int {
	r := a[0]
	index := 0
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
			index = i
		}
	}
	return index
}

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

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

// ------ Mathライブラリ ---------------------------------//

// ----- 標準入力用の関数 ----------------------------------//
var nextReader func() []string

func NewScanner() func() []string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	return func() []string {
		r.Scan()
		return strings.Fields(r.Text())
	}
}

func nextString() []string {
	return nextReader()
}

func nextInt() []int {
	var intArray []int
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.Atoi(v)
		intArray = append(intArray, i)
	}
	return intArray
}

func nextFloat64() []float64 {
	var floatArray []float64
	strArray := nextReader()
	for _, v := range strArray {
		f, _ := strconv.ParseFloat(v, 64)
		floatArray = append(floatArray, f)
	}
	return floatArray
}

// ------ 標準入力用の関数 ---------------------------------//

// ------ あまり使わない -----------------------------------//
func nextInt64() []int64 {
	var int64Array []int64
	strArray := nextReader()
	for _, v := range strArray {
		i, _ := strconv.ParseInt(v, 10, 64)
		int64Array = append(int64Array, i)
	}
	return int64Array
}

// ------ あまり使わない -----------------------------------//


Measured memory_bytes: 640
w,h,n = map(int, input().split())

x1,x2,y1,y2 = 0,0,0,0
for _ in range(n):
  x,y,a = map(int, input().split())
  if a == 1: x1 = max(x1, x)
  if a == 2: x2 = max(x2, w-x)
  if a == 3: y1 = max(y1, y)
  if a == 4: y2 = max(y2, h-y)

w -= x1+x2
h -= y1+y2
if w > 0 and h > 0: print(w*h)
else: print(0)

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

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

int n, m, a, b, ans = 0;

struct edge {
  int to, cost;
};
typedef pair<int, int> P;
vector<edge> G[200005];
int d[200005];
int from[200005];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> q;
  fill(d, d + n, INF);
  d[s] = 0;
  q.push(P(0, s));

  while (q.size()) {
    P p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    rep(i, G[v].size()) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        from[e.to] = v;
        q.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin >> n >> m;
  rep(i, m) {
    cin >> a >> b, a--, b--;
    G[a].push_back({b, 1});
    G[b].push_back({a, 1});
  }

  dijkstra(0);
  bool ok = true;
  rep(i, m) if (d[i] == INF) ok = false;

  if (ok) {
    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i) cout << from[i] + 1 << endl;
  } else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 15904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pair<int, int>, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

ll pow5(ll x) {
    ll p = x;
    x *= x;
    x *= x;
    x *= p;
    return x;
}

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

    int X;
    cin >> X;

    for (int i = -1000; i <= 1000; ++i) {
        for (int j = -1000; j < i; ++j) {
            ll tmp = pow5(i) - pow5(j);
            if (tmp == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  bool OK = (A<C&&C<B)||(A>C&&C>B);
  if (OK) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,j,n,m,bas;cin>>n>>m;
	static llint seg[524288]={0};
	static llint ans[524288];
	for(i=0;i<524288;i++){ans[i]=-big;}
	bas=262144;
	while(bas>0){ans[bas]=0;bas/=2;}
	vector<vector<pair<int,int>>>ivent(n+2);
	for(i=0;i<m;i++){
		int l,r,a;cin>>l>>r>>a;
		ivent[l].pub(mp(l,a));
		ivent[r+1].pub(mp(l,-a));
	}
	for(i=1;i<=n+1;i++){
		for(auto it:ivent[i]){
			bas=262144+it.fir;
			while(bas>1){
				if(bas%2){seg[bas-1]+=it.sec;ans[bas-1]+=it.sec;}
				bas/=2;
				ans[bas]=max(ans[bas+bas],ans[bas+bas+1])+seg[bas];
			}
		}
		//cerr<<ans[1]<<endl;
		ans[262144+i]=ans[1];
		bas=262144+i;
		while(bas>1){
			bas/=2;
			ans[bas]=max(ans[bas+bas],ans[bas+bas+1])+seg[bas];
		}
	}
	cout<<ans[1]<<endl;
	return 0;
}


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

using namespace std;

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

    vector<pair<int, int> > to[n];
    for (int i = 0; i < n - 1; ++i) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;
        b--;
        w %= 2;
        to[a].emplace_back(make_pair(b, w));
        to[b].emplace_back(make_pair(a, w));
    }

    vector<int> ans(n, -1);
    ans[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto x:to[v]) {
            int u = x.first;
            int w = x.second;
            if (ans[u] != -1) continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
        }
    }
    
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6784
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		long[] ans = new long[N];
		PriorityQueue<Deck> que = new PriorityQueue<>();
		for(int i=1;i<=N;i++){
			que.add(new Deck(i,io.nextInt()));
		}
		que.add(new Deck(0,0));
/*		for (int i = 0; i < N; i++) {
			System.out.println(que.peek().NO+" "+que.poll().num);
		}
*/
		Deck nowDeck;
		int nowNO = Integer.MAX_VALUE;
		int nowNum;
		for(int i=1;i<=N;i++){
			nowDeck = que.poll();
			nowNO = Math.min(nowNO,nowDeck.NO);
			ans[nowNO-1] += (long)(nowDeck.num-que.peek().num)*i;
		}
		for(int i=0;i<N;i++){
			System.out.println(ans[i]);
		}
	}
}

class Deck implements Comparable<Deck>{
	int NO;
	int num;
	public Deck(int NO, int num){
		this.NO = NO;
		this.num = num;
	}
	@Override
	public int compareTo(Deck o) {
		return (o.num-num==0)? o.NO-NO
							  :o.num-num;
	}
	
}

Measured memory_bytes: 72236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N%10==9||N/10==9) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
 //freopen(".in","r",stdin);
 //freopen(".out","w",stdout);
 cin>>a>>b>>c;
 if(b-a==c-b) cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
 return 0;
}

Measured memory_bytes: 256