akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int a, b, x;
   cin >> a >> b >> x;

   while (b > 0) {
      if (a >= x) break;
      b--;
      a++;
   }

   if (a == x) {
      puts("YES");
   } else {
      puts("NO");
   }

   return 0;
}

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

int main() {
  
  vector<vector<int>> vec(3, vector<int>(3));
  for(int i = 0; i < 3; i++){
    for(int j = 0;  j < 3; j++){
      int a;
      cin >> a;
      vec.at(i).at(j) = a;
    }
  }
  
  int n;
  cin >> n;
  
  for(int i = 0; i<n; i++){
    int b;
    cin >> b;
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(vec.at(j).at(k) == b) vec.at(j).at(k) = 0;
      }
    }
  }
  
  int ans = 0;
  
  for(int i = 0; i<3; i++){
    if(vec.at(i).at(0) == vec.at(i).at(1) && vec.at(i).at(1) == vec.at(i).at(2)){
      ans = 1;
      break;
    }
    if(vec.at(0).at(i) == vec.at(1).at(i) && vec.at(1).at(i) == vec.at(2).at(i)){
      ans = 1;
      break;
    }
    if(vec.at(0).at(0) == vec.at(1).at(1) && vec.at(1).at(1) == vec.at(2).at(2)){
      ans = 1;
      break;
    }
    if(vec.at(0).at(2) == vec.at(1).at(1) && vec.at(1).at(1) == vec.at(2).at(0)){
      ans = 1;
      break;
    }
  }
  
  if(ans == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
  
  
  
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
 
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        ll d[n+1];
        rep(i,n+1)cin>>d[i];
        ll ans=0;
        ll can=1;
        ll arr[n+1]={0};
        ll val=1e13+5;
        for(ll i=0;i<=n;i++){
            if(d[i]>can||(can==0)){
                cout<<-1;
                return 0;
            }
            ans=ans+can;
            arr[i]=can;
            // dbg(can);
            can=2*(can-d[i]);
            if(can>(val)){
                can=val;
            }
        }
        ans-=(arr[n]-d[n]);
        arr[n]=d[n];
        for(ll i=n-1;i>=0;i--){
            ll t=arr[i]-d[i];
            if(t>(arr[i+1])){
                ans-=arr[i];
                arr[i]=arr[i+1]+d[i];
                ans+=arr[i];
            }
        }
        cout<<ans<<endl;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
const int M = 1e5;
int n, m;
char s[N], t[N];
int main() {
	cin >> n >> m;
	scanf("%s %s", s, t);
	ll L = (ll)n * m / __gcd(n, m);
	int n1 = n / __gcd(n, m);
	int m1 = m / __gcd(n, m);
	for (int i = 0, j = 0; i < n; i += n1, j += m1) {
		if (s[i] != t[j]) {
			puts("-1");
			return 0;
		}
	}
	cout << L << endl;
} 

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N; cin >> N;
    vector<long long> cnt(45*20*10, 0);
    for(int i=0;i<N;i++){
        string s; cin >> s;
        long long v = 0;
        int a = -1;
        for(auto& c : s){
            if(c == '.') a = 0;
            else {
                v = 10 * v + c - '0';
                if(a >= 0) ++a;
            }
        }
        int p2 = 0, p5 = 0;
        while(v%2 == 0){ p2++; v /= 2; }
        while(v%5 == 0){ p5++; v /= 5; }
        cnt[(p2*20+p5)*10+max(0, a)]++;
    }
    long long res = 0;
    for(int i=0;i<cnt.size();i++){
        int a0 = i%10;
        int p5_0 = i/10%20;
        int p2_0 = i/10/20;
        if(min(p5_0, p2_0) >= a0)
            res += cnt[i]*(cnt[i]-1)/2;
        for(int j=i+1;j<cnt.size();j++){
            int a1 = j%10;
            int p5_1 = j/10%20;
            int p2_1 = j/10/20;
            if(min(p2_0+p2_1, p5_0+p5_1) >= a0+a1)
                res += cnt[i] * cnt[j];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3708
#[allow(non_snake_case)]
fn main() {
    proconio::input! {
        W: usize,
        H: usize,
        M: usize,
        B: [(usize, usize); M],
    }

    let mut xmax = 0;
    let mut ymax = 0;
    let mut xs = vec![0; W + 1];
    let mut ys = vec![0; H + 1];

    for b in &B {
        xs[b.0] += 1;
        ys[b.1] += 1;
        xmax = xmax.max(xs[b.0]);
        ymax = ymax.max(ys[b.1]);
    }

    let xn = xs.iter().fold(0, |a, &n| a + if n == xmax { 1 } else { 0 });
    let yn = ys.iter().fold(0, |a, &n| a + if n == ymax { 1 } else { 0 });
    let bn = B.iter().fold(0, |a, b| a + if xs[b.0] == xmax && ys[b.1] == ymax { 1 } else { 0 });

    println!("{}", xmax + ymax - (if xn * yn == bn { 1 } else { 0 }));
}

Measured memory_bytes: 12960
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout<<#x<<" "<<x<<endl
#define ll long long int
#define ld long double
#define fo(i, n) for(ll i = 0; i<n; i++)
#define Fo(i, k, n) for(ll i = k; i<n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define pi pair<int, int>
#define pl pair<ll, ll>
//const ll MOD = 998244353;
const int Max = 1e5+2;
const ll MOD = 1e9+7;
//functions;
ll power(int x, int y){int temp; if(y==0)return 1; temp = power(x, y/2); if(y%2==0) return temp*temp; else return x*temp*temp;}
ll gcd(ll a, ll b){return b?gcd(b, a%b):a;}
ll Ceil(ll a, ll b){if(a%b) return (a/b)+1; return a/b;}
//ll dp[Max], sum[Max];
int n, m, t;
int main()
{
    int n;
    cin>>n;
    short t = n%10;
    if(t==2 || t==4 || t==5 || t==7 || t==9) cout<<"hon"<<endl;
    else if(t==0 || t==1 || t==6 || t==8) cout<<"pon"<<endl;
    else cout<<"bon"<<endl;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    string A, B, C;
    cin >> A >> B >> C;
    if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
*    author:  Dooloper
*    created: 02.05.2020 20:53:47
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>


using namespace std;
typedef unsigned long long ll;

int main() {
    cin.tie(0);
    ll A,B,N;
    cin>>A>>B>>N;
    ll x = min(B-1, N);
    ll ans = (ll)(A*x/B)-A*(ll)(x/B);
    cout<<ans<<endl;
    // cout<<(int)(5/2)<<endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n;
            while((n = scn.nextInt()) > 0) {
                Dice dice = new Dice();
                int sum = 1;
                for(int i = 0; i < n; i++) {
                    dice.move(scn.next());
                    sum += dice.showTop();
                }
                System.out.println(sum);
            }
        }
    }
}

interface DirectionValues {
    int TMP    = 0;
    int TOP    = 1;
    int FRONT  = 2;
    int RIGHT  = 3;
    int LEFT   = 4;
    int BACK   = 5;
    int BOTTOM = 6;
    int[] dirNorth = {TMP, TOP, FRONT, BOTTOM, BACK, TMP};
    int[] dirEast  = {TMP, TOP, LEFT, BOTTOM, RIGHT, TMP};
    int[] dirWest  = {TMP, TOP, RIGHT, BOTTOM, LEFT, TMP};
    int[] dirSouth = {TMP, TOP, BACK, BOTTOM, FRONT, TMP};
    int[] dirRight = {TMP, FRONT, RIGHT, BACK, LEFT, TMP};
    int[] dirLeft  = {TMP, FRONT, LEFT, BACK, RIGHT, TMP};
}

class Dice implements DirectionValues {
    private int[] nums;

    Dice() {
        int[] nums = new int[7];
        nums[TOP]    = 1;
        nums[FRONT]  = 2;
        nums[RIGHT]  = 3;
        nums[LEFT]   = 4;
        nums[BACK]   = 5;
        nums[BOTTOM] = 6;
        this.nums = nums;
    }

    int showTop() {
        return nums[TOP];
    }

    void move(String cmd) {
        switch(cmd) {
          case "North":
            rotate(dirNorth);
            break;
          case "East":
            rotate(dirEast);
            break;
          case "West":
            rotate(dirWest);
            break;
          case "South":
            rotate(dirSouth);
            break;
          case "Right":
            rotate(dirRight);
            break;
          case "Left":
            rotate(dirLeft);
            break;
          default:
            assert false;
        }
    }

    private void rotate(int[] dir) {
        for(int i = 0; i < 5; i++) {
            nums[dir[i]] = nums[dir[-~i]];
        }
    }
}

Measured memory_bytes: 34428
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    int count['Z' - 'A' + 1];
    fill(begin(count), end(count), 1 << 20);

    cin >> n;

    for (int _ = 0; _ < n; _++) {
        string s;
        cin >> s;
        int thisCount['Z' - 'A' + 1] = {};

        for (size_t i = 0; i < s.length(); i++) {
            thisCount[s[i] - 'a']++;
        }

        for (int i = 0; i < ('Z' - 'A' + 1); i++) {
            count[i] = min(count[i], thisCount[i]);
        }
    }

    for (int i = 0; i < ('Z' - 'A' + 1); i++) {
        if (count[i] < (1 << 20)) {
            for (int j = 0; j < count[i]; j++) {
                cout << (char)('a' + i);
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int town = 10;
	static int path = 46;
	static int INF = 1<<29;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = 0;
			while ((n = in.nextInt()) != 0) {

				int[][] d = new int[town][town];
				for (int i = 0; i < d.length; i++) {
					Arrays.fill(d[i], INF);
				}
				for (int i = 0; i < d.length; i++) {
					d[i][i] = 0;
				}
				for (int i = 0; i < n; i++) {
					int a = in.nextInt();
					int b = in.nextInt();
					int c = in.nextInt();
					d[a][b] = c;
					d[b][a] = c;
				}

				warshallFloyd(d);

				int[] ans = new int[town];
				for (int i = 0; i < d.length; i++) {
					for (int j = 0; j < d.length; j++) {
						if (d[i][j] != INF) {
							ans[i] += d[i][j];
						}
					}
				}

				int cost = 1 << 29;
				int tt = -1;
				for (int i = 0; i < ans.length; i++) {
					if (ans[i] != 0 && ans[i] < cost) {
						cost = ans[i];
						tt = i;
					}
				}

				out.println(tt + " " + cost);
			}

		}

		void warshallFloyd(int[][] d) {
			int n = d.length;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					for (int k = 0; k < n; k++) {
						d[j][k] = Math.min(d[j][k], d[j][i] + d[i][k]);
					}
				}
			}
		}
	}


	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 24424
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func main() {
	var N, A, B int
	fmt.Scanf("%d %d %d\n", &N, &A, &B)
	if N*A > B {
		fmt.Println(B)
	} else {
		fmt.Println(N * A)
	}
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


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

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        int mn = LLONG_MAX, sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        int ans = a[n - 1], rem = n - 2;
        for (int i = n - 2; i >= 0 && rem > 0; i--) {
            ans += min((long long)2, rem) * a[i];
            rem -= 2;
        }
        cout << ans;
    }
    return 0;
}

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

const int maxn = 2.5e6, mod = 998244353;
int n, m, k, fact[maxn + 3], finv[maxn + 3];

int qpow(int a, int b) {
	int c = 1;
	for (; b; b >>= 1, a = 1ll * a * a % mod) {
		if (b & 1) c = 1ll * a * c % mod;
	}
	return c;
}

void prework(int n) {
	fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = 1ll * fact[i - 1] * i % mod;
	}
	finv[n] = qpow(fact[n], mod - 2);
	for (int i = n; i; i--) {
		finv[i - 1] = 1ll * finv[i] * i % mod;
	}
}

int C(int n, int m) {
	if (n < 0 || m < 0 || m > n) {
		return 0;
	}
	return 1ll * fact[n] * finv[m] % mod * finv[n - m] % mod;
}

int main() {
	scanf("%d %d", &n, &m);
	k = n + 1.5 * m;
	prework(k);
	int ans = 0;
	for (int i = 0; i <= m; i++) {
		if ((m * 3 - i) & 1) continue;
		int t = (m * 3 - i) >> 1;
		ans = (ans + 1ll * C(n, i) * C(t + n - 1, n - 1)) % mod;
	}
	ans = (ans + 1ll * mod * mod - 1ll * n * C(m - 1 + n - 1, n - 1)) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 18688
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int n,m,d,q,a,b,c,w[200000],x[200000],y[200000];
int main()
{
	cin>>n>>m>>d;
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++){
			cin>>a;a=a-1;
			x[a]=i;y[a]=j;
		}
	cin>>q;
	for (int i=d;i<200000;i++){
		w[i]=w[i-d];
		w[i]+=abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
	}
	for (int i=0;i<q;i++){
		cin>>b>>c;b=b-1;c-=1;
		cout<<w[c]-w[b]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m;
  while (cin >> n >> m, m) {
    vector<int> seq(n);
    for (int i = 0; i < n; ++i)
      seq[i] = i + 1;

    while (seq.size() > 1) {
      rotate(seq.begin(), seq.begin() + (m - 1) % seq.size(), seq.end());
      seq.erase(seq.begin());
    }
    cout << seq[0] << endl;
  }
}


Measured memory_bytes: 3056
import java.util.*;
import java.lang.Math;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long count = 1;
        long div = 1000000007;

        count = modPow(2,n,div);

        long ax = 1;
        for(int i=1; i<=a; i++){
            ax = (ax * (n-i+1)) % div;
        }
        long ay = 1;
        for(int i=1; i<=a; i++){
            ay = (ay * i) % div;
        }
        long ayinv = modPow(ay, div-2, div);

        long bx = 1;
        for(int i=1; i<=b; i++){
            bx = (bx * (n-i+1)) % div;
        }
        long by = 1;
        for(int i=1; i<=b; i++){
            by = (by * i) % div;
        }
        long byinv = modPow(by, div-2, div);

        System.out.println(mod(count - ((ax*ayinv)%div) - ((bx*byinv)%div) -1, div));
    }
    public static long mod(long a, long p){
        long val = a % p;
        if(val >= 0){
            return val;
        }else{
            return val + p;
        }
    }
    public static long modPow(long a, long n, long p){
        if(n==1){
            return a % p;
        }else if (n%2==0){
            long t = modPow(a, n/2, p);
            return (t*t) % p;
        }else{
            return (modPow(a, n-1, p) * a) % p;
        }
    }
}

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

int main() {
 
  int A, B, C, K;
  int result = 0;
  int now = 0;
  
  cin >> A >> B >> C >> K;
  
  while (A > 0) {
    A--;
    now++;
    result++;
    
    if (now == K){
      cout << result << endl;
      return 0;      
    }  
  }  
  
  while (B > 0) {
    B--;
    now++;
        
    if (now == K){
      cout << result << endl;
      return 0;      
    }  
  }  
  
  while (C > 0) {
    C--;
    now++;
    result--;
    
    if (now == K){
      cout << result << endl;
      return 0;
    }  
  }  
}

Measured memory_bytes: 3624
//import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public int[] link;
    private int curr;
    public int size=3000000;
     
    public Main() {
        this.link= new int[size];
        this.curr=0;
    }
     
    public void insert(int k) {
        this.link[curr]=k;
        this.curr++;
        int m =curr;
        //System.out.println(m);
        while ((m>=2)&&(this.link[m-1]>=this.link[m/2-1])) {
            //System.out.println(m);
            this.link[m-1]=this.link[m/2-1];
            this.link[m/2-1]=k;
            m=m/2;
        }
    }
     
    public void maxHeap(int[] a,int i) {
        int l = this.link[2*i-1];
        int r = this.link[2*i];
        int par = this.link[i-1];
        int largest=i;
        if ((2*i<=curr)&&(l>par)) {
            largest = 2*i;
        }
         
        if ((2*i+1<=curr)&&(r>this.link[largest-1])){
            largest = 2*i+1;
        }
        if (largest != i) {
            int m = this.link[i-1];
            this.link[i-1]=this.link[largest-1];
            this.link[largest-1]=m;
            this.maxHeap(this.link,largest);
        }   
    }
     
    //public void buildMaxHeap(int[] m) {
    //  for (int i=(curr+1)/2;i>0;i--) {
    //      this.maxHeap(m,i);
    //  }
    //}
 
     
    public int extract() {
        //this.buildMaxHeap(this.link);
        //System.out.println(Arrays.toString(this.link));
        int t = this.link[0];
        if (curr>0) {
            this.link[0]=this.link[--curr];
        }
        this.link[curr]=0;
        //System.out.println(Arrays.toString(this.link));
        this.maxHeap(this.link, 1);
        //System.out.println(Arrays.toString(this.link));
        return t;
         
    }
     
    public static void main(String[] wjy) {
        Scanner sc = new Scanner(System.in);
        Main lk = new Main();
        boolean suit =true;
        while (suit) { 
            String a = sc.next();
            if (a.equals("end")) {
                suit = false;
            }
            else if(a.equals("extract")) {
                System.out.println(lk.extract());
            }
            else {
                int j=(int) sc.nextInt();
                lk.insert(j);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 560420
R, G, B ,N = map(int, input().split())

cnt = 0
for r in range(N//R + 1):
  for g in range((N-r*R)//G + 1):
    val = N - (r*R + g*G)
    if val % B == 0 and  val >= 0:
      cnt += 1
print(cnt)


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

int main() {
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin >> m.at(i);
    X -= m.at(i);
  }
  sort(m.begin(), m.end());
  int result = N;
  result += X/m.at(0);
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<functional>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
vector<string>vec[500000], W; vector<int>vec2[500000];
int n, t, num; string a, b; pair<int, int>dist[500000];
vector<pair<int, int>>X[500000];

pair<int, int> dijkstra(string S, string T) {
	priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>>Q;
	int cnt4 = 0; for (int i = 0; i < 500000; i++)dist[i] = make_pair(1069999999, 1069999999);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < vec[i].size(); j++) {
			if (S == vec[i][j]) { Q.push(make_tuple(0, cnt4, 0)); dist[cnt4] = make_pair(0, 0); }
			cnt4++;
		}
	}
	while (!Q.empty()) {
		int a1 = get<0>(Q.top()), a2 = get<1>(Q.top()), a3 = get<2>(Q.top()); Q.pop();
		for (int i = 0; i < X[a2].size(); i++) {
			int to = X[a2][i].first;
			int U = 0; if (a2 >= num)U = 1;
			if (dist[to] > make_pair(a1 + X[a2][i].second, a3 + U)) {
				dist[to] = make_pair(a1 + X[a2][i].second, a3 + U);
				Q.push(make_tuple(dist[to].first, to, dist[to].second));
			}
		}
	}
	cnt4 = 0; pair<int, int> minx = make_pair(2139999999, 2139999999);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < vec[i].size(); j++) {
			if (T == vec[i][j]) { minx = min(minx, dist[cnt4]); }
			cnt4++;
		}
	}
	return minx;
}
int main() {
	cin >> n >> t >> a >> b; int cnt1 = 0;
	for (int i = 0; i < n; i++) {
		int E; cin >> E;
		for (int j = 0; j < E; j++) {
			string W2; cin >> W2; W.push_back(W2);
			vec[i].push_back(W2); cnt1++;
		}
		for (int j = 0; j < E - 1; j++) { int W3; cin >> W3; vec2[i].push_back(W3); }
	}
	int cnt2 = 0; sort(W.begin(), W.end());
	vector<string>V; V.push_back(W[0]); for (int i = 1; i < W.size(); i++) { if (W[i - 1] != W[i])V.push_back(W[i]); }
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < vec2[i].size(); j++) {
			X[cnt2].push_back(make_pair(cnt2 + 1, vec2[i][j]));
			X[cnt2 + 1].push_back(make_pair(cnt2, vec2[i][j]));
			cnt2++;
		}
		cnt2++;
	}
	num = cnt2;
	int cnt3 = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < vec[i].size(); j++) {
			int pos1 = lower_bound(W.begin(), W.end(), vec[i][j]) - W.begin();
			X[cnt2 + pos1].push_back(make_pair(cnt3, 0));
			X[cnt3].push_back(make_pair(cnt2 + pos1, t));
			cnt3++;
		}
	}
	pair<int, int>ans = dijkstra(a, b);
	if (ans.first > 1000000000)cout << "-1" << endl;
	else cout << ans.first << ' ' << ans.second << endl;
	return 0;
}

Measured memory_bytes: 58028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	for(ll i=sqrt(n);i>=1;i--){
		if(n%i==0){
			cout << i-1+n/i-1;
			return 0;
		}
	}
	// your code goes here
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[1000010][2];

int main() {
    string S;
    cin >> S;
    ll N = S.length();
    reverse(S.begin(), S.end());
    ll index = 0;
    dp[0][0] = 0;
    dp[0][1] = 1;
    while (index < S.length()) {
        dp[index + 1][0] = dp[index][0] + S[index] - '0';
        if (S[index] != '9') {
            dp[index + 1][0] = std::min(dp[index + 1][0], dp[index][1] + S[index] - '0' + 1);
            dp[index + 1][1] = std::min(dp[index][0] + (10 - (S[index] - '0')) % 10,
                                        dp[index][1] + (9 - (S[index] - '0')));
        }
        else {
            dp[index + 1][0] = INF;
            dp[index + 1][1] = std::min(
                    dp[index][0] + (10 - (S[index] - '0')) % 10, dp[index][1] + (9 - (S[index] - '0')));
        }
        if (S[index] == '0')
            dp[index + 1][1]++;
        index++;
    }

    //! 最後に繰り上がり
    cout << std::min(dp[N][0], dp[N][1] + 1) << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()  
#define sz(x) int(x.size()) 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=63;
const int mxn=0;
bool DEBUG=0;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,x,t;
    cin>>n>>x>>t;
    int cnt = n/x + bool(n%x);
    cout<<cnt*t<<"\n";
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
bool T=false;

int main(){
    vector<int> A(5);
    for (int i = 0; i < 5; i++)
    {
        cin>>A[i];
    }
    for (int i = 0; i < 5; i++)
    {
        if(A[i]==0)cout<<i+1;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;

int main(){
    int A, B, Q; cin >> A >> B >> Q;

    vector<ll> s(A), t(B), x(Q);
    rep(i,A) cin >> s[i];
    rep(i,B) cin >> t[i];
    s.push_back(INF); s.push_back(-INF);
    t.push_back(INF); t.push_back(-INF);
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    rep(i,Q) cin >> x[i];

    rep(i,Q){

        int s_left = upper_bound(s.begin(), s.end(), x[i]) - s.begin()-1;
        int s_right = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
        int t_left = upper_bound(t.begin(), t.end(), x[i]) - t.begin()-1;
        int t_right = lower_bound(t.begin(), t.end(), x[i]) - t.begin();

        ll s_distances[2];
        s_distances[0] = s[s_left];
        s_distances[1] = s[s_right];

        ll t_distances[2];
        t_distances[0] = t[t_left];
        t_distances[1] = t[t_right];

        ll ans = INF;
        for (int j = 0; j < 2; j++){
            ans = min(ans, abs(x[i] - s_distances[j]) +abs(s_distances[j] - t_distances[j]));
            ans = min(ans, abs(x[i] - s_distances[j]) +abs(s_distances[j] - t_distances[(j+1)%2]));
        }
        for (int j = 0; j < 2; j++){
            ans = min(ans, abs(x[i] - t_distances[j]) +abs(t_distances[j] - s_distances[j]));
            ans = min(ans, abs(x[i] - t_distances[j]) +abs(t_distances[j] - s_distances[(j+1)%2]));
        }

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

    }


}

Measured memory_bytes: 6412
S=str(input())
k=len(S)
ans="Yes"
if k%2==0:
    for i in range(k//2):
        t=S[2*i:2*i+2:1]
        if t=="hi":
            continue
        else:
            ans="No"
            break
else:
    ans="No"
print(ans)


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

int main(void) {
	int a;
	cin >> a;
	int ans;
	for (int i = a; i <= 999; i++) {
		if (i % 111 == 0) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if((a==1 || a==3||a==5||a==7||a==8||a==10||a==12)&& (b==1||b==3||b==5||b==7||b==8||b==10||b==12)){
        printf("Yes");
    }
    else if ((a ==4||a==6||a==9||a==11)&&( b==4||b==6||b==9||b==11)){
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9 + 7, N = 2e6 + 100;
int p[N], cnt[N], n, X;
void sieve(int N) {
    for(int i = 2; i < N; ++i) {
        if(p[i]) continue;
        p[i] = i;
        for(int j = i; j < N; j += i) {
            if(!p[j]) p[j] = i; 
        }
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); 
    sieve(1e6 + 5);
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        int a;
        cin >> a;
        X = __gcd(X, a);
        int prev = -1;
        vector < int > primes;
        while(a > 1) {
            int cur = p[a];
            if(cur != prev) {
                primes.push_back(cur);
            }
            prev = cur;
            a /= p[a];
        }
        for(int x : primes) ++cnt[x];
    }
    if(X > 1) {
        cout << "not coprime\n";
        return 0;
    }
    string ans = "pairwise coprime";
    for(int i = 2; i < N; ++i) {
        if(cnt[i] > 1) {
            ans = "setwise coprime";
            break;
        }
    }
    cout << ans << endl;
}

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

//bool ok[100];
int kind[14];

int n;
int num[100];
bool fin;
int mem[100];


const int MAX_PRIME = 1000;
void dfs(int sum,int cnt){
    if(cnt==1){
        for(int i = 1; i < 14; i++){
            if(kind[i]>0){
                mem[n-cnt]=i;
                break;
            }
        }
        fin=true;
        return;
    }
    for(int i = 1; i < 14; i++){
        if(kind[i]==0)
            continue;
        int nsum=sum-i;
        if(nsum%i==0){
            kind[i]--;
            mem[-cnt+n]=i;
            dfs(nsum,cnt-1);
            if(fin)
                return;
            kind[i]++;
        }
    }
}

int main(){
    while(cin>>n&&n!=0){
        int sum=0;
        fin=false;
        fill(kind,kind+14,0);
        for(int i = 0; i < n; i++){
            cin>>num[i];
            kind[num[i]]++;
            sum+=num[i];
        }
        dfs(sum,n);
        if(fin){
            for(int i = 0; i < n; i++){
                cout<<mem[n-1-i];
                if(i==n-1)
                    cout<<endl;
                else
                    cout<<" ";
            }
        }
        else
            cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "complex"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;


long long int N, M, K, H, W, L, R;

list<int> Prime(int num) {
	list<int>P;
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (j*j > i) {
				break;
			}
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if (j*j > i + 2) {
				break;
			}
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	P.push_front(3);
	P.push_front(2);
	return P;
}

inline long long int gcd(long long int a, long long int b) {
	if (a < b)a ^= b ^= a ^= b;
	while (b) {
		a %= b;
		a ^= b ^= a ^= b;
	}
	return a;
}

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

	cin >> N;
	auto P = Prime(10000);
	list<int>p;
	P.pop_front();
	while (p.size() < N + 2) {
		p.push_back(P.front());
		P.pop_front();
	}
	vector<int>tate((N+2)/2);
	vector<int>yoko((N+2)/2);
	for (int i = 0; i < (N + 2) / 2; i++) {
		if (i % 2) {
			tate[i] = p.front();
			p.pop_front();
		}
		else {
			tate[i] = p.back();
			p.pop_back();
		}
	}
	for (int i = 0; i < N/2+1; i++) {
		if (i % 2) {
			yoko[i] = p.front();
			p.pop_front();
		}
		else {
			yoko[i] = p.back();
			p.pop_back();
		}
	}
	vector<vector<long long int>>v(N, vector<long long int>(N));
	map<long long int, int>m;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if ((i^j) & 1) {
				v[i][j] = tate[i / 2] * yoko[j / 2] * 2;
				if (m[v[i][j]])v[i][j] *= 2;
				m[v[i][j]]++;
			}
		}
	}
	int dir[] = { 0,1,0,-1,0 };
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (!v[i][j]) {
				v[i][j] = 1;
				for (int k = 0; k < 4; k++) {
					int ny = i + dir[k];
					int nx = j + dir[k + 1];
					if (ny < 0 || nx < 0 || ny >= N || nx >= N)continue;
					v[i][j] = v[i][j] / gcd(v[i][j], v[ny][nx])*v[ny][nx];
				}
				v[i][j]++;
				if (m[v[i][j]])v[i][j] = v[i][j] * 2 - 1;
				m[v[i][j]]++;
			}
		}
	}
	long long int mx = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (j)cout << " ";
			cout << v[i][j];
			mx = max(mx, v[i][j]);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 20608
use std::collections::HashMap;
use std::io;

type Board = Vec<Vec<bool>>;
type Layout = HashMap<Ball, (usize, usize)>;
type Balls = Vec<Ball>;
type Ball = i32;

fn init_board() -> Board {
    vec![
        vec![false, false, false],
        vec![false, false, false],
        vec![false, false, false],
    ]
}

fn set_ball(board: &mut Board, layout: &Layout, b: Ball) {
    match layout.get(&b) {
        None => return,
        Some(&(x, y)) => board[x][y] = true,
    }
}

fn any_bingo(board: &Board) -> bool {
    for x in 0..3 {
        if board[x][0] && board[x][1] && board[x][2] {
            return true;
        }
    }
    for y in 0..3 {
        if board[0][y] && board[1][y] && board[2][y] {
            return true;
        }
    }
    if board[0][0] && board[1][1] && board[2][2] {
        return true;
    }
    if board[0][2] && board[1][1] && board[2][0] {
        return true;
    }
    return false;
}

fn solve(layout: &Layout, balls: &Balls) -> bool {
    let mut board = init_board();
    for b in balls {
        set_ball(&mut board, &layout, *b);
    }
    any_bingo(&board)
}

fn main() {
    let mut layout: Layout = HashMap::new();
    for y in 0..3 {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        for x in 0..3 {
            let a: i32 = iter.next().unwrap().parse().unwrap();
            layout.insert(a, (x, y));
        }
    }
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let n: usize = input.trim().parse().unwrap();
    let mut balls: Vec<i32> = Vec::with_capacity(n);
    for _ in 0..n {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        let b: i32 = input.trim().parse().unwrap();
        balls.push(b);
    }
    if solve(&layout, &balls) {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (a.at(i) == 0) continue;
		int tmp = a.at(i);
		if (a.at(tmp - 1) == (i + 1)) {
			ans++;
			a.at(i) = 0;
			a.at(tmp - 1) = 0;
		}
	}
	cout << ans << endl;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n;
  cin >> n;
  vi h(n);
  REP (i, 0, n)  cin >> h[i];

  for(int i = n - 1; i > 0; i--){
      if (h[i - 1] <= h[i])
        continue;
      else if (h[i - 1] == h[i] + 1)
        h[i - 1]--;
      else{
        cout << "No\n";
        return 0;
      }
  }
  cout << "Yes\n";

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
void solve(){
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int &i : a){
        cin >> i;
        sum += i;
    }
    cout << sum - n << '\n';
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        solve();
    }
}

Measured memory_bytes: 34592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

template<typename T>
struct BIT {
    std::vector<T> dat;
 
    BIT(int n) : dat(n + 1) {}
 
    void add(int k, T v) {
        k++;
        while (k < dat.size()) {
            dat[k] += v;
            k += k & -k;
        }
    }
 
    T sum(int k) {
        k++;
        T ret = 0;
        while (k > 0) {
            ret += dat[k];
            k &= k - 1;
        }
        return ret;
    }
};

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    string S;
    cin >> S;
    VI conv(SZ(S));
    REP(i,SZ(S))
    {
        if(S[i] == 'B')
        {
            conv[i] = 1;
        }
        if(S[i] == 'W')
        {
            conv[i] = 0;
        }
    }

    BIT<int> bit(2 * 1e5 + 10);
    LL res = 0;
    REP(i,SZ(S))
    {
        res += i - bit.sum(conv[i]);
        bit.add(conv[i],1);
    }

    cout << res << endl;

}


Measured memory_bytes: 2196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <limits>
#include <queue>
#include <set>
using namespace std;
typedef long long int lld;
int T;
int N, P;
int check[1000001];
int gcd (int a, int b){
    return b? gcd(b, a%b): a;
}
int main(void){
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    bool bb = true;
    int i;
    for(i; i < s.size(); i+=2){
        string t = s.substr(i,2);
        if(t != "hi"){bb = false; break;}
    }
    if(i != s.size()) cout << "No";
    else  bb? cout << "Yes" : cout << "No";
    return 0;
}


Measured memory_bytes: 256