akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll n_): num((n_ + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)

modint pow3(ll r){
    return modint(3LL)^(ll)r;
}

int main(void){
    string s;
    cin >> s;
    int n = s.size();
    modint res = 0;
    ll num1 = 0;
    rep(i,n){
        if (s[i] == '1') {
            res += (modint(2)^num1)*pow3(n-1-i);
            num1++;
        }
    }
    res += (modint(2)^num1);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, K; cin >> N >> K;
    vector X(N, 0);
    vector Y(N, 0);
    vector XS(N, 0);
    vector YS(N, 0);
    rep(i, N) {
        int x, y; cin >> x >> y;
        X[i] = x;
        Y[i] = y;
        XS[i] = x;
        YS[i] = y;
    }
    sort(XS.begin(), XS.end());
    sort(YS.begin(), YS.end());

    ll res = INT64_MAX;
    rep(x1, N) {
        for (int x2 = x1 + 1; x2 < N; x2++) {
            rep(y1, N) {
                for (int y2 = y1 + 1; y2 < N; y2++) {
                    int L = XS[x1], R = XS[x2];
                    int B = YS[y1], T = YS[y2];
                    int num = 0;
                    rep(i,N) {
                        int x = X[i], y = Y[i];
                        if (L <= x && x <= R && B<=y && y<=T) num++;
                    }
                    if (num >= K) res = min(res, (ll)(R-L)*(T-B));
                }
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
	int n,x,t=1;scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&x);
		if(x%2==0)
		{
			if(x%3&&x%5)t=0;
		}
	}
	printf(t?"APPROVED\n":"DENIED\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  for (int i = 0; i < n; ++i)
    cin >> x[i] >> y[i] >> h[i];
  for (int cy = 0; cy <= 100; ++cy)
  {
    for (int cx = 0; cx <= 100; ++cx)
    {
      int hh = -1;
      bool flag = true;
      int hmax = 2e9;
      for (int i = 0; i < n; ++i)
      {
        int d = abs(x[i] - cx) + abs(y[i] - cy);
        if (h[i] > 0)
        {
          int th = hh - d;
          if (hh > 0 && th != h[i])
          {
            flag = false;
            break;
          }
          else
            hh = h[i] + d;
        }
        else
          hmax = min(hmax, d);
      }
      if (flag && hh <= hmax)
      {
        cout << cx << ' ' << cy << ' ' << hh << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int N,mas[16][17],dp[1<<16];
int rec(int bit){
  if(dp[bit]) return dp[bit];
  if(!bit) return 0;
  int ret = INF;
  for(int i = 0 ; i < N ; i++ ){
    if(!(bit & (1 << i))) continue;
    int min_cost = mas[i][0];
    for(int j = 0 ; j < N ; j++ ){
      if(!(bit & (1 << j))) min_cost = min( min_cost, mas[i][j+1]);
    }
    ret = min( ret, min_cost + rec(bit&~(1 << i)));
  }
  return dp[bit] = ret;
}
int main(){
  while(cin >> N , N ){
    for(int i = 0 ; i < 1 << N ; i++ ) dp[i] = 0;
    for(int i = 0 ; i < N ; i++ ){
      for(int j = 0 ; j <= N ; j++ ){
        cin >> mas[i][j];
      }
    }
    cout << rec((1 << N)-1) << endl;
  }
}

Measured memory_bytes: 1416
#include <iostream>
using namespace std;
int A[50], n;

// 入力値のMから選んだ要素を引いていく再起関数
int solve(int i, int m) {
	if (m == 0) return 1;
	if (i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	int q, M, i;

	cin >> n;
	for (i = 0; i < n; i++) cin >> A[i];
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> M;
		if (solve(0, M)) cout << ("yes") << endl;
		else cout << ("no") << endl;;
	}

	return 0;
}


Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,x; cin >> N >> x;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<priority_queue<ll, vector<ll>, greater<ll>>> B(N);
    ll ans = 1e18;
    for (ll i = 0; i < N; i++) {
        rep(j,N) B[j].emplace(A[(j+i)%N]);
        ll val = 0;
        rep(j,N) val += B[j].top();
        chmin(ans,val+i*x);
    }

    cout << ans << endl;
}

Measured memory_bytes: 32512
#include<cstdio>
 #include<cstring>
 #include<queue>
 #include<cmath>
 using namespace std;
 const int Ni = 300;
 const int MAX = 1<<26;
 struct Edge{
     int u,v,c;
     int next;
 }edge[4000];
 int n,m;
 int edn;//\u8fb9\u6570
 int p[Ni];//\u7236\u4eb2
 int d[Ni];
 int sp,tp;//\u539f\u70b9\uff0c\u6c47\u70b9

 void addedge(int u,int v,int c)
 {
     edge[edn].u=u; edge[edn].v=v; edge[edn].c=c;
     edge[edn].next=p[u]; p[u]=edn++;

     edge[edn].u=v; edge[edn].v=u; edge[edn].c=0;
     edge[edn].next=p[v]; p[v]=edn++;
 }
 int bfs()
 {
     queue <int> q;
     memset(d,-1,sizeof(d));
     d[sp]=0;
     q.push(sp);
     while(!q.empty())
     {
         int cur=q.front();
         q.pop();
         for(int i=p[cur];i!=-1;i=edge[i].next)
         {
             int u=edge[i].v;
             if(d[u]==-1 && edge[i].c>0)
             {
                 d[u]=d[cur]+1;
                 q.push(u);
             }
         }
     }
     return d[tp] != -1;
 }
 int dfs(int a,int b)
 {
     int r=0;
     if(a==tp)return b;
     for(int i=p[a];i!=-1 && r<b;i=edge[i].next)
     {
         int u=edge[i].v;
         if(edge[i].c>0 && d[u]==d[a]+1)
         {
             int x=min(edge[i].c,b-r);
             x=dfs(u,x);
             r+=x;
             edge[i].c-=x;
             edge[i^1].c+=x;
         }
     }
     if(!r)d[a]=-2;
     return r;
 }

 int dinic(int sp,int tp)
 {
     int total=0,t;
     while(bfs())
     {
         while(t=dfs(sp,MAX))
         total+=t;
     }
     return total;
}
int main(){
	scanf("%d%d",&n,&m);
	edn=0;
	memset(p,-1,sizeof(p));
	for (int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		addedge(a-1,b-1,1);
		addedge(b-1,a-1,1);
	}
	scanf("%d%d",&sp,&tp);
	sp--;
	tp--;
	int ans=dinic(sp,tp),tot=0;
	for (int i=0;i<m;i++) if (edge[i*4+2].c==0) tot++;
	printf("%d\n%d\n",ans,tot);
	for (int i=0;i<m;i++) if (edge[i*4+2].c==0) printf("%d\n",i+1);
	
}

Measured memory_bytes: 2796
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h, w := scanInt(), scanInt()
	c := make([][]int, 10)
	for i := 0; i < 10; i++ {
		c[i] = scanInts(10)
	}
	cnt := map[int]int{}
	for i := 0; i < h*w; i++ {
		cnt[scanInt()]++
	}

	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				c[i][j] = min(c[i][j], c[i][k]+c[k][j])
			}
		}
	}

	ans := 0
	for i := 0; i < 10; i++ {
		ans += cnt[i] * c[i][1]
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100010];

int main()
{
    int n,k,s;
    cin >> n >> k >> s;
    for(int i=1;i<=k;i++)   a[i]=s;
    for(int i=k+1;i<=n;i++) a[i]=(s==1000000000)?1:s+1;
    cout << a[1];
    for(int i=2;i<=n;i++)
        cout << " " << a[i];
    cout << endl;
    return 0;
}

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

int main() {
  long long W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << W * H / 2.0 << ' ';
  if (x + x == W && y + y == H)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let r: i32 = sc.read();
    let D: i32 = sc.read();
    let mut x: i32 = sc.read();

    for i in 0..10 {
        x = r * x - D;
        println!("{}", x);
    }
}

Measured memory_bytes: 2012
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
    string s;
    cin >> s;
    if (s.length()>=3){
        for (int i=0; i<s.length()-2; i++){
            if (s[i]==s[i+1] ||s[i]==s[i+2] || s[i+1]==s[i+2]){
                cout << i+1 << " " << i+3 << endl;
                return 0;
            }
        }
    }
    else {
        if (s[0]==s[1]){
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 4608
function parse(input) {
  const arr = input.split(" ")
  const n = parseInt(arr[0], 10)
  const k = parseInt(arr[1], 10)

  return [n, k]
}

function f(n, k) {
  return n % k ? 1 : 0
}

module.exports = {
  parse,
  f,
}

function Main(input) {
  const arr = parse(input)
  const n = arr[0]
  const k = arr[1]

  console.log(f(n, k))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7372
n, y = gets.chomp.split.map(&:to_i)

(0..n).each do |num_10000|
  (0..(n-num_10000)).each do |num_5000|
    if 10000*num_10000 + 5000*num_5000 + 1000*(n-num_10000-num_5000) == y then
      print("#{num_10000} #{num_5000} #{n-num_10000-num_5000}")
      exit
    end
  end
end
print("-1 -1 -1")


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int a = scanner.nextInt() * 100;
        final int b = scanner.nextInt() * 100;
        final int c = scanner.nextInt();
        final int d = scanner.nextInt();
        final int e = scanner.nextInt();
        final int f = scanner.nextInt();

        int water = a;
        int sugar = 0;
        for (int i = 100; i < f; i += 100) {
            if (!isEnable(a, b, i)) {
                continue;
            }
            for (int j = 0; j <= Math.min(e * i / 100, f - i); j++) {
                if (!isEnable(c, d, j)) {
                    continue;
                }
                if (concentration(i, j) > concentration(water, sugar)) {
                    water = i;
                    sugar = j;
                }
            }
        }
        System.out.println(water + sugar + " " + sugar);
    }

    private static boolean isEnable(final int a, final int b, final int f) {
        for (int i = 0; i <= f; i += a) {
            if ((f - i) % b == 0) {
                return true;
            }
        }
        return false;
    }

    private static double concentration(final double water, final double sugar) {
        return 100 * sugar / (water + sugar);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
	int n;
	cin >> n;
	long ans =1;
	vec<long> a(n);
	for (auto &&e : a)
	{
		cin >> e;
	}
	sort(a.begin(),a.end());
	bool flag = true;
	for (auto &&e : a)
	{
		if (e==0)
		{
			ans *= e;
			break;
		}
		
		if (e>1000000000000000000/ans)
		{
			flag = false;
			break;
		}
		ans *= e;
	}
	if(flag)
	{
		cout << ans << endl;
	}
	else
	{
		cout << -1 << endl;
	}

}


Measured memory_bytes: 3980
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include<queue>
using namespace std;

int main() {
	string S;
	cin >> S;
	int A[4];
	for (int i = 0; i < 4; i++) {
		if (S[i] == '1')A[i] = 1;
		if (S[i] == '2')A[i] = 2;
		if (S[i] == '3')A[i] = 3;
		if (S[i] == '4')A[i] = 4;
		if (S[i] == '5')A[i] = 5;
		if (S[i] == '6')A[i] = 6;
		if (S[i] == '7')A[i] = 7;
		if (S[i] == '8')A[i] = 8;
		if (S[i] == '0')A[i] = 0;
		if (S[i] == '9')A[i] = 9;
	}
	

	for (int i = 0; i < 2; i++) {
		for (int k = 0; k < 2; k++) {
			for (int y = 0; y < 2; y++) {
				if ((A[0] + A[1] * pow(-1, i) + A[2] * pow(-1, k) + A[3] * pow(-1, y)) == 7) {
					
					char a = 'a';
					char b = 'b';
					char c = 'c';
					if (i == 0) a = '+';
					if (i == 1) a = '-';

					if (k == 0) b = '+';
					if (k == 1) b = '-';

			        if (y == 0) c = '+';
					if (y == 1) c = '-';
					
					cout << A[0] << a << A[1] << b << A[2] << c << A[3] << "=7" << endl;
					goto go;
				}
			}
		}
	}
go:;
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(w: str):
    c = collections.Counter(w)
    d = c.values()
    flag = True
    for dd in d:
        if dd % 2 != 0:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    w = next(tokens)  # type: str
    solve(w)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5204
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> cnt(4, 0);
  REP(i, N){
    string s;
    cin >> s;

    if(s == "AC") cnt[0]++;
    if(s == "WA") cnt[1]++;
    if(s == "TLE") cnt[2]++;
    if(s == "RE") cnt[3]++;
  }

  cout << "AC x " << cnt[0] << "\n";
  cout << "WA x " << cnt[1] << "\n";
  cout << "TLE x " << cnt[2] << "\n";
  cout << "RE x " << cnt[3] << "\n";

  return 0;
}


Measured memory_bytes: 3656
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
#define MAX_A 1'000'001
int N;
vector<int> A, C(MAX_A, 0);

// 素数と個数を求める
vector<pair<int,int>> factorize(int n){
  vector<pair<int,int>> res;
  for(int i=2; i*i<=n; ++i){
    if (n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n,1);
  return res;
}

string solve(){
	for(int a:A)
		for(auto p:factorize(a)) C[p.first]++;
	int max_c = 0;
	for(auto c:C) max_c = max(max_c, c);
	if(max_c <= 1) return "pairwise";
	else if(max_c <= N-1) return "setwise";
	return "not";
}

int main(){
	cin>>N;
	A.resize(N); for(int i=0; i<N; ++i) cin>>A[i];
	cout<< solve() <<" coprime\n";
}


Measured memory_bytes: 11100
#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;




int main() {
	//freopen("input.txt", "r", stdin);

	int N, H, W; cin >> N >> H >> W;

	int ans = (N-W+1)*(N-H+1);
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


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

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

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

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a;
	cin >> a;
	int k;
	cin >> k;
	vector<string> data;

	rep(i, 0, a.size()) {
		rep(j, 1, k + 1) {
			string mesu = a.substr(i, j);

			data.push_back(mesu);
		}
	}
	sort(data.begin(), data.end());

	data.erase(unique(data.begin(), data.end()), data.end());

	cout << data[k-1] << endl;
	return 0;
		
	
	
	
	
}
	

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
num = [0]*42
n_num = [0]*42
for e in range(41,-1,-1):
    mask = 1<<e
    for a in A:
        if a&mask:
            num[e]+=1
    n_num[e] = N-num[e]
max_f = 0
#for d in range(1,len(bit))[::-1]:
for d in range(41,-2,-1):
    #d=d-2
    if (d != -1 and not (K & 1 << d)):
        continue
    f=0
    #for e in range(2,len(bit))[::-1]:
    for e in range(41,-1,-1):
        mask = 1<<e
        if e>d:
            if K&mask:
                f += mask*n_num[e]
            else:
                f += mask*num[e]
        elif e==d:
            f += mask*num[e]
        else:
            f += mask*max(n_num[e],num[e])
    max_f = max(f,max_f)
print(max_f)

Measured memory_bytes: 14816
#include <bits/stdc++.h>
#define INF (1 << 30)
#define int long long
using namespace std;

int dp[101][100001]; // object, weight
// dp[i][j] : largest value using first i items, at most weight j
int32_t main(){
	int n, w;
	cin >> n >> w;
	for(int i = 1; i <= n; i++){
		int v_i, w_i;
		cin >> w_i >> v_i; 
		for(int j = 1; j <= w; j++){
			// exclude the i th item
			dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
			// include the i th item
			if(j >= w_i)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w_i] + v_i);
		}
	}
	cout << dp[n][w];
}

Measured memory_bytes: 78336
import bisect


def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    B = list(map(int, input().split()))
    C = sorted(map(int, input().split()))

    ans = 0
    for b in B:
        na = bisect.bisect_left(A, b)
        nc = N - bisect.bisect_right(C, b)
        ans += na * nc

    print(ans)


def TLE(N, A, B, C):
    # a<b<c となる並べ方の数
    # b<c となる並べ方の数、１つずつに対してN個調べるO(N^2) => すでにOver => pypy
    # b M個となったとき (b_c_i - b_c_m) を保持する
    # a<b となる並べ方の数、１つずつに対してN個調べるO(M*N)
    # b L個となったとき (b_a_i - b_a_m) を保持する (b_cと対応付ける)

    ans = 0
    for b in B:
        less_b_count = sum(1 for a in A if a < b)
        if less_b_count > 0:
            over_b_count = sum(1 for c in C if b < c)
            ans += less_b_count * over_b_count

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24180
N, M = list(map(int, input().split()))

l_max, r_min = -1, 100000
for _ in range(M):
    L, R = list(map(int, input().split()))
    if l_max < L:
        l_max = L
    if r_min > R:
        r_min = R

if r_min >= l_max:
    print(r_min - l_max + 1)
else:
    print(0)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char s[11];
    
    scanf("%s", s);
    
    s[3]='8';
    
    printf("%s", s);
    
    return 0;
}



Measured memory_bytes: 1696
import copy
n = int(input())
w = [input() for i in range(n)]
flag = True
count = 0
for i in range(n):
    w_temp = copy.deepcopy(w)
    w_temp.pop(i)
    if w[i] in w_temp:
        print('No')
        exit()
for i in range(1, n):
    if w[i][0] != w[i-1][-1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3444
n,m = map(int,input().split())
edge = [[] for _ in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)

def checkpath(nodes,E,current):
    next = []
    newnodes = nodes.copy()
    newnodes[current] = 0

    for e in E[current]:
        if newnodes[e]:
            next.append(e)

    if len(next) == 0:
        if sum(newnodes) == 0:
            return 1
        else:
            return 0
    else:
        return sum([checkpath(newnodes,E,e) for e in next])

nodes = [1]*(n+1)
nodes[0] = 0
print(checkpath(nodes,edge,1))

Measured memory_bytes: 3064
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
using namespace std;
int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	char buffer[33];

	cin >> a;
	cin >> b;
  if (a==0&&b==100)
	{
		cout<<101<<endl;
    return 0;
	}
	if (a == 1 && b == 100)
	{
		cout << 10100 << endl;
      return 0;
	}
	if (a == 2 && b == 100)
	{
		cout << 1010000 << endl;
      return 0;
	}
	d = 1;
	for ( c = 0; c < a; c++)
	{
		d *= 100;
	}
	cout<<b*d <<endl;




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

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

int main()
{
    int n, x, y;
    cin>>n>>x>>y;
    int ans[n+1]={};

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            ans[min(j-i, abs(x-i)+1+abs(j-y))]++;

    for(int i=1;i<n;i++)
        cout<<ans[i]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

ll gcd(ll x, ll y)
{
    if (x < y) {
        swap(x, y);
    }

    if (x % y == 0) {
        return y;
    }

    return gcd(y, x % y);
}

ll lcm(ll x, ll y)
{
    return x / gcd(x, y) * y;
}

ll f(ll x, ll C, ll D)
{
    ll res = x;
    res -= x / C;
    res -= x / D;
    res += x / lcm(C, D);
    
    return res;
}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << f(B, C, D) - f(A-1, C, D) << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    string ABCD;
    cin >> ABCD;
    int total = 0;
    int A= (int)ABCD[0]-(int)'0';
    int B =(int)ABCD[1]-(int)'0';
    int C =(int)ABCD[2]-(int)'0';
    int D =(int)ABCD[3]-(int)'0';
    if( (A+B+C+D)==7){
        cout<< A << "+" << B << "+" << C << "+" << D <<"=7" << endl;
    }
    else if( (A+B+C-D)==7){
        cout<< A << "+" << B << "+" << C << "-" << D <<"=7" << endl;
    }
    else if( (A+B-C+D)==7){
        cout<< A << "+" << B << "-" << C << "+" << D <<"=7" << endl;
    }
    else if( (A+B-C-D)==7){
        cout<< A << "+" << B << "-" << C << "-" << D <<"=7" << endl;
    }
    else if( (A-B+C+D)==7){
        cout<< A << "-" << B << "+" << C << "+" << D <<"=7" << endl;
    }
    else if( (A-B+C-D)==7){
        cout<< A << "-" << B << "+" << C << "-" << D <<"=7" << endl;
    }
    else if( (A-B-C+D)==7){
        cout<< A << "-" << B << "-" << C << "+" << D <<"=7" << endl;
    }
    else if( (A-B-C-D)==7){
        cout<< A << "-" << B << "-" << C << "-" << D <<"=7" << endl;
    }
}

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


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

   if(n<10){
      cout<<n;
   }
   else if(n>9&&n<100){
      int x=n/10;
      if(11*x<n){
         cout<<(x+1)*11<<endl;
      }
      else{
      cout<<x*11<<endl;
      }
   }
   else{
      int y=n/100;
      if(111*y<n){
         cout<<(y+1)*111<<endl;
      }else{
      cout<<y*111<<endl;
      }
   }

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
    int n, R[MAX];

    cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int max_v = -1000000000;
	int min_v = R[0];

	for (int i = 1; i < n; i++) {
		max_v = max(max_v, R[i]-min_v);
		min_v = min(min_v, R[i]);
	}

	cout << max_v << endl;

    return 0;
}

Measured memory_bytes: 1940
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

    int N = sc.nextInt();
    Map<String, Integer> map = new HashMap<>();

    int max = 1;

    for (int i = 0; i < N; i++) {
      String s = sc.next();
      if (map.containsKey(s)) {
        map.put(s, map.get(s)+1);
        if (map.get(s) > max) max = map.get(s);
      } else {
        map.put(s, 1);
      }
    }

    List<String> list = new ArrayList<>();

    for (Map.Entry<String, Integer> e : map.entrySet()) {
      if (e.getValue() == max) {
        list.add(e.getKey());
      }
    }

    Collections.sort(list);
    for (String s : list) {
      System.out.println(s);
    }

    sc.close();
  }
}

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

int main(){
  int h,a;
  cin >> h >> a;
  int ans = (h+a-1)/a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int A,B,m,ans,id1,id2,c;
int a[N],b[N]; 
int main(){
	ans=2e9;
	scanf("%d%d%d",&A,&B,&m);
	for (register int i=1; i<=A; ++i) scanf("%d",&a[i]);
	for (register int i=1; i<=B; ++i) scanf("%d",&b[i]);

	for (register int i=1; i<=m; ++i)
	{
		scanf("%d%d%d",&id1,&id2,&c);
		ans=min(ans,a[id1]+b[id2]-c);
	}	
	sort(a+1,a+A+1);
	sort(b+1,b+B+1);
	ans=min(ans,a[1]+b[1]);
	printf("%d\n",ans);
return 0;	
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<intmax_t> a(N+1);
  for (size_t i=0; i<N; ++i)
    scanf("%jd", &a[i]);

  std::sort(a.begin(), a.end());
  
  if (N == 1) {
    if (a[1] % 2 == 0) {
      puts("second");
    } else {
      puts("first");
    }
    return 0;
  }

  intmax_t gdy = 0;
  for (size_t i=1; i<=N; ++i) {
    intmax_t c = a[i]-a[i-1];
    if (c % 2 == 0) continue;
    gdy ^= (N-i+1);
  }
  
  if (gdy == 0) {
    puts("second");
  } else {
    puts("first");
  }
}


Measured memory_bytes: 1024
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number } => {
  const N = +lines[0]
  const obj = { N }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N } = parseLines(lines)
  return `${N ** 3}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 7628
from time import perf_counter
t0 = perf_counter()


import sys
sys.setrecursionlimit(300000)
from collections import defaultdict
from random import randint

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


D = I()
C = LMI()
S = [LMI() for _ in range(D)]


# 貪欲解の生成
last = defaultdict(int)
ans0 = []
for d in range(D):
    m = -INF
    ans = -1
    for i in range(26):
        lans = S[d][i]
        for j in range(26):
            if i == j:
                lans -= C[j] * (d + 1 - d - 1)
            else:
                lans -= C[j] * (d + 1 - last[j])
        if lans > m:
            m = lans
            ans = i
    ans0.append(ans)



T = ans0
last = [[i + 1] * 26 for i in range(D)]
for d in range(D):
    i = T[d]
    j = 0
    for dd in range(d, D):
        last[dd][i] = j
        j += 1

def eval(d, q):
    i = T[d]
    val = S[d][q] - S[d][i]

    contrib = 0
    if d == 0:
        j = 1
    else:
        j = last[d - 1][i] + 1
    for dd in range(d, D):
        if dd > d and last[dd][i] == 0:
            break
        contrib += j - last[dd][i]
        # last[dd][i] = j
        j += 1
    val -= contrib * C[i]

    contrib = 0
    j = 0
    for dd in range(d, D):
        if last[dd][q] == 0:
            break
        contrib += last[dd][q] - j
        # last[dd][q] = j
        j += 1
    val += contrib * C[q]

    # T[d] = q

    return val

def apply(d, q):
    i = T[d]

    if d == 0:
        j = 1
    else:
        j = last[d - 1][i] + 1
    for dd in range(d, D):
        if dd > d and last[dd][i] == 0:
            break
        last[dd][i] = j
        j += 1

    j = 0
    for dd in range(d, D):
        if last[dd][q] == 0:
            break
        last[dd][q] = j
        j += 1

    T[d] = q

while perf_counter() - t0 < 1.8:
    d = randint(0, D - 1)
    q = randint(0, 25)
    if eval(d, q) > 0:
        apply(d, q)
    else:
        if randint(0, 10) == 3:
            apply(d, q)
for t in T:
    print(t + 1)

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

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

    int n, S, q, T;
    unordered_map<int, bool> um;
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> S;
        um[S] = true;
    }

    int ans = 0;
    cin >> q;
    for (int i=0; i<q; ++i) {
        cin >> T;
        ans += um[T];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

char str[MAXN];
int ans[MAXN];
int odd,eve,len;
void sch(int id) {
    odd = 0,eve = 0;
    for (int i = id;i >= 1;i --) {
        if (str[i] != 'R') break;
        int cha = id-i;
        if (cha&1) {
            odd ++;
        }else {
            eve ++;
        }
    }
    rep(i,id+1,len) {
        if (str[i] != 'L') break;
        int cha = i-id;
        if (cha&1) {
            odd ++;
        }else {
            eve ++;
        }
    }
    ans[id] = eve;
    ans[id+1] = odd;
}

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

    cin >> str+1;
    len = strlen(str+1);
    rep(i,1,len-1) {
        if (str[i] == 'R' && str[i+1] == 'L') {
            sch(i);
        }
    }
    rep(i,1,len) {
        cout << ans[i] << " ";
    }cout << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};

// const int C ;
// const int M = 1000000007;

int N, M;
int X[100010];
int mod[100010];
int same[100010];
int same_mod[100010];

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; i++) {
    cin >> X[i];
  }
  fill(mod, mod+100010, 0);
  fill(same, same+100010, 0);
  fill(same_mod, same_mod, 0);
  for (auto i = 0; i < N; i++) {
    mod[X[i]%M]++;
    same[X[i]]++;
  }
  for (auto i = 0; i < 100010; i++) {
    same_mod[i%M] += (same[i]/2)*2;
  }
  int ans = 0;
  for (auto i = 1; i <= M/2; i++) {
    if (M%2 == 0 && i == M/2) continue;
    int t = min(mod[i], mod[M-i]);
    // cerr << i << " " << t << endl;
    ans += t;
    mod[i] -= t;
    mod[M-i] -= t;
  }
  ans += mod[0]/2;
  mod[0] %= 2;
  // cerr << ans << endl;
  if (M%2 == 0) {
    ans += mod[M/2]/2;
    mod[M/2] %= 2;
    // cerr << ans << endl;
  }
  for (auto i = 0; i < M; i++) {
    // cerr << "mod[" << i << "] = " << mod[i] << ", ";
    // cerr << "same_mod[" << i << "] = " << same_mod[i] << endl;
    ans += min(mod[i], same_mod[i])/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;
class Main{
    void solve(){
        int N, C, sum = 0;
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        C = sc.nextInt();
        for ( int i = 0; i < C; i++ ){
            int x = sc.nextInt();
            sum += x;
        }
        N++;

        System.out.println(sum/N + (sum%N==0?0:1));
    }

    public static void main(String[] args){ new Main().solve(); }
}


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (b - a <= 0) {
    cout << "delicious" << endl;
  }
  else if (b - a > x) {
    cout << "dangerous" << endl;
  }
  else {
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int print(int p){
  for(int i = 0; i < p; i++){
     printf("#");
     }
    printf("\n");
    return 0;
   }
  

int main(void){

  int H = 0;
  int W = 0;
  int pic_yoko = 0;        //実際に表示するときの横のピクセル
  char  picture[101][101]; //二重配列
 
  scanf("%d %d", &H, &W);
  
  pic_yoko = W + 2;
 
  for(int i = 0; i < H; i++) {
    scanf("%s", &picture[i][0]);
  }
 
  print(pic_yoko); // 上から１行目
  
  for(int i = 0; i < H; i++) {
    printf("#%s#\n", picture[i]);
  }
  
  print(pic_yoko); // 一番下の行
 
  return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(n: chars);
    let mut rem = 0;
    for c in n {
        let k = c as u8 - b'0';
        rem += k as i32;
    }
    puts!("{}\n", if rem % 9 == 0 { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

const long long mod = 1e9 + 7;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<long long> pos, neg;
  for(int i = 0; i < N; i++){
    long long A;
    cin >> A;
    if(A >= 0) pos.push_back(A);
    else neg.push_back(-A);
  }
  
  int n_pos = int(pos.size()), n_neg = int(neg.size());
  
  long long ans = 1;
  
  if(K == N){
    for(int i = 0; i < n_pos; i++){
      ans *= pos[i];
      ans %= mod;
    }
    
    for(int i = 0; i < n_neg; i++){
      ans *= -neg[i];
      ans %= mod;
    }
  }else if(n_neg == N && (K & 1)){
    sort(neg.begin(), neg.end());
    
    ans = -1ll;
    for(int i = 0; i < K; i++){
      ans *= neg[i];
      ans %= mod;
    }
  }else{  
    sort(pos.begin(), pos.end(), greater<long long>());
    sort(neg.begin(), neg.end(), greater<long long>());
    
    int idx_pos = 0, idx_neg = 0;
    
    if(K & 1){
      --K;
      ans = pos[idx_pos++];
    }
    
    for(int i = 0; i < K; i += 2){
      if(idx_pos + 1 < n_pos && idx_neg + 1 < n_neg){
        if(pos[idx_pos] * pos[idx_pos + 1] < neg[idx_neg] * neg[idx_neg + 1]){
          ans *= neg[idx_neg] * neg[idx_neg + 1] % mod;
          idx_neg += 2;
        }else{
          ans *= pos[idx_pos] * pos[idx_pos + 1] % mod;
          idx_pos += 2;
        }
      }else if(idx_pos + 1 < n_pos){
        ans *= pos[idx_pos] * pos[idx_pos + 1] % mod;
        idx_pos += 2;
      }else{
        ans *= neg[idx_neg] * neg[idx_neg + 1] % mod;
        idx_neg += 2;
      }
      
      ans %= mod;
    }
  }
  
  cout << (ans + mod) % mod << endl;
  
  return 0;
}

Measured memory_bytes: 5444
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
#define int ll
using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
struct dsu {
    vector<ll> par, rank;
    dsu(ll n): par(n+1), rank(n+1) {
        for (ll i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    ll root(ll a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(ll a, ll b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        rank[a] += rank[b];
        par[b] = a;
    }
};
void  solve(){
  ll n,m,x,y;
  cin>>n>>m;
  vector<pair<ll,ll> > edg(m);
  rep(i,0,m) cin>>edg[i].f>>edg[i].s;

  dsu d(n);
  multiset<ll> s1;
  // map<int,int> m1;
  // rep(i,0,n) s1.insert(1);
  vector<ll> ans(m);
  ll sum=n;
  rrep(i,m-1,0){
    ans[i]=(n*n-sum)/2;
    pii x=edg[i];
    ll y=d.root(x.f-1),z=d.root(x.s-1);
    if(y!=z){
      ll num1=d.rank[y],num2=d.rank[z];
      // s1.erase(num1),s1.erase(num2);
      // s1.insert(num1+num2);
      // cout<<num1<<" "<<num2<<endl;
      sum-=(num1*num1+num2*num2);
      sum+=((num1+num2)*(num1+num2));
      d.merge(y,z);
    }
  }
  rep(i,0,m) cout<<ans[i]<<endl;
}
int32_t main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 7892
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  1000000
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;

int main()
{
    int r, g, b;
    cin>>r>>g>>b;
    int k;
    cin>>k;

    while(k && r>=g)
    {
        g=g*2;
        k--;
    }

    while(k && g>=b)
    {
        b= b*2;
        k--;
    }


    if(r<g && g<b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

using namespace std;


void solve() {
    string s; cin >> s;
    int n = s.size();
    int cnt = 0;
    int m = n/2;
    for (int i = 0; i < m; i++) {
        cnt += s[i] != s[n-i-1];
    }
    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256