akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

signed main(void)
{
	int n, ans;
	cin >> n;
	vector<int> l(2 * n);
	rep(i, 2 * n) cin >> l[i];
	sort(l.begin(), l.end());
	ans = 0;
	for(int i = 0; i < 2 * n; i+=2)
	{
		ans += l[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_set>

int main()
{
  int n;
  std::cin >> n;
  std::unordered_set<int64_t> a;
  for (int i = 0; i < n; ++i)
  {
    int64_t num;
    std::cin >> num;
    if (a.find(num) != a.end())
    {
      a.erase(num);
    }
    else
    {
      a.emplace(num);
    }
  }
  std::cout << a.size() << std::endl;
  return 0;
}

Measured memory_bytes: 4388
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;

  int h[N + 3];
  for (int i = 1; i <= N; i++) {
    cin >> h[i];
  }

  sort(h + 1, h + 1 + N);

  int minn = 1e9;
  for (int i = 1; i <= N - K + 1; i++) minn = min(minn, h[i + K - 1] - h[i]);

  cout << minn << endl;
  return 0;
}


Measured memory_bytes: 640
import scala.math.abs

object Main extends App {
  val Array(n, x, y) = io.StdIn.readLine().split(' ').map(_.toInt)

  val count = Array.fill(n)(0)
  for (k <- 1 until n) {
    for (i <- 1 to n; j = i+k; if j <= n) {
      val len = Seq(abs(i-j), abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)).min
      count(len) += 1
    }
  }
  for (a <- count.drop(1)) println(a)
}

Measured memory_bytes: 116464
/*
 * Author : Sadi
 * Sat 04/07/2020
 * 18:26:42.02
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int a, b;
    cin >> a >> b;
    if(b % a == 0) {
        cout << a + b << endl;
    }
    else {
        cout << b - a << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
#[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, ( $($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);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        p: [usize],
    }
    let mut ans = 0;
    for i in 0..p.len() - 2 {
        let mut q = p[i..i + 3].to_vec();
        q.sort();
        if p[i + 1] == q[1] {
            ans += 1;
        }
    }
    puts!("{}\n", ans);
}

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: 8572
#include"bits/stdc++.h"
using namespace std;
int main(){
	int N,ans=0,in,i,sp,kan,st,tf,comlen,temlen;
	char com[100],tem[100];
	cin>>N;
	cin>>tem;
	temlen=strlen(tem);
	for(in=0;in<N;in++){
		cin>>com;
		comlen=strlen(com);
		for(kan=0;kan<(comlen/(temlen-1));kan++){
			for(sp=0;sp<=kan;sp++){
			    for(st=sp;st<comlen-((kan+1)*(temlen-1));st+=kan+1){
					tf=1;
					for(i=0;i<temlen;i++){
						if(com[st+i*(kan+1)]!=tem[i]){
							tf=0;
							break;
						}
					}
					if(tf==1){
						ans++;
						break;
					}
				}
			if(tf==1)break;
			}
		if(tf==1)break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3084
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let s: Vec<u8> = sc.ne::<String>().into_bytes();
    let t: Vec<u8> = sc.ne::<String>().into_bytes();
    let n = s.len();
    let m = t.len();
    let mut sum_s = vec![0; n + 2];
    let mut sum_t = vec![0; m + 2];
    for i in 1..n + 1 {
        sum_s[i] += if s[i - 1] == b'A' { 1 } else { 0 };
        sum_s[i + 1] += sum_s[i];
    }
    for i in 1..m + 1 {
        sum_t[i] += if t[i - 1] == b'A' { 1 } else { 0 };
        sum_t[i + 1] += sum_t[i];
    }
    let q: usize = sc.ne();
    for _ in 0..q {
        let (a, b, c, d): (usize, usize, usize, usize) = (sc.ne(), sc.ne(), sc.ne(), sc.ne());
        let tmp = sum_s[b] - sum_s[a - 1];
        let num_s = tmp + (b - a + 1 - tmp) * 2;
        // print!("{} ", tmp);
        let tmp = sum_t[d] - sum_t[c - 1];
        let num_t = tmp + (d - c + 1 - tmp) * 2;
        // print!("{} ", tmp);
        // println!("{} {}", num_s, num_t);
        if num_s % 3 == num_t % 3 {
            println!("YES");
        } else {
            println!("NO");
        }
    }
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


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

int main(){
    int N;
    string S;

    cin >> N >> S;

    int count = 1;
    char letter = S[0];
    for(int i = 0; i < N; i++) {
        if (S[i] != letter) {
            count++;
            letter = S[i];
        }
    }

    cout << count << "\n";

    return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> c(n);
    int a, b;
    REP(i, n) {
        cin >> a >> b;
        c[i] = make_pair(a, b);
    }
    sort(ALL(c));

    vector<vector<int>> dp(n + 1, vector<int>(6001, 0));

    REP(i, n) {
        REP(j, 6001) {
            // not eat
            chmax(dp[i + 1][j], dp[i][j]);
            // eat
            if (j - c[i].first >= 0 && j - c[i].first < t) chmax(dp[i + 1][j], dp[i][j - c[i].first] + c[i].second);
        }
    }
    // REP(i, n + 1) {
    //     REP(j, 30) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << EOL;
    // }
    int ans = 0;
    REP(i, 6001) chmax(ans, dp[n][i]);
    cout << ans << EOL;
}


Measured memory_bytes: 70784
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int H, W;

    cin >> H >> W;
    char pixel[H][W];
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> pixel[i - 1][j - 1];
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cout << pixel[i - 1][j - 1];
        }
        cout << endl;
        for (int j = 1; j <= W; j++) {
            cout << pixel[i - 1][j - 1];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200005;

int tree[4*MAXN],lazy[4*MAXN],A[MAXN];
vector<int> pos[MAXN];

void updatenode(int now,int L,int R,int val){
	tree[now]+=val;
	lazy[now]+=val;
}

void pushdown(int now,int L,int R){
	int mid=(L+R)/2;
	updatenode(2*now,L,mid,lazy[now]);
	updatenode(2*now+1,mid+1,R,lazy[now]);
	lazy[now]=0;
}

void build(int now,int L,int R){
	if(L==R){
		tree[now]=A[L];
		return;
	}
	int mid=(L+R)/2;
	build(2*now,L,mid);
	build(2*now+1,mid+1,R);
	tree[now]=max(tree[2*now],tree[2*now+1]);
}

int query(int now,int L,int R,int x,int y){
	if(L>=x && R<=y)return tree[now];
	if(L>y || R<x)return INT_MIN;
	pushdown(now,L,R);
	int mid=(L+R)/2;
	return max(query(2*now,L,mid,x,y),query(2*now+1,mid+1,R,x,y));
}

void update(int now,int L,int R,int x,int y,int val){
	if(L>=x && R<=y){
		updatenode(now,L,R,val);
		return;
	}
	if(L>y || R<x)return;
	int mid=(L+R)/2;
	pushdown(now,L,R);
	update(2*now,L,mid,x,y,val);
	update(2*now+1,mid+1,R,x,y,val);
	tree[now]=max(tree[2*now],tree[2*now+1]);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,m,l,r;
	cin >> n >> m;
	int ans=n-m;
	for(int i=1;i<=n;i++){
		cin >> l >> r;
		pos[l].push_back(r);
	}
	for(int i=2;i<=m+1;i++)A[i]=-m+i-1;
	build(1,2,m+1);
	for(int i=0;i<=m+1;i++){
		if(i)update(1,2,m+1,2,m+1,-1);
		for(auto isi : pos[i])update(1,2,m+1,2,isi,1);
		ans=max(ans,query(1,2,m+1,i+2,m+1));
	}
	cout << max(ans,0) << endl;
	return 0;
}






Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

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

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> H(N);
  rep(i,N) cin >> H[i];
  int M = H[0];
  int count = 0;
  rep(i,N)
  {
    if(H[i]>=M)
    {
      count ++;
    }
    M = max(M,H[i]);
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3508
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	vector<pii> P;
	REP(i, N) {
		int a;
		cin >> a;
		P.push_back(make_pair(a, i));
	}
	SORT(P);
	int cnt = 0;
	int tmp = 0;
	REP(i, N - 1) {
		if (P[i].second < P[i + 1].second) {
			cnt++;
		}
		else {
			tmp = max(tmp, cnt + 1);
			cnt = 0;
		}
	}
	tmp = max(tmp, cnt + 1);
	cout << N - tmp << endl;

	
	return 0;
}



Measured memory_bytes: 6512
N,Q = map(int,input().split())
Edge = [[] for _ in range(N+1)]

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

PX = [list(map(int,input().split())) for _ in range(Q)]

visited = [True for _ in range(N+1)]
visited[1] = False
stack = [1]
Ans = [0]*(N+1)

for p,x in PX:
    Ans[p] += x

while len(stack) > 0:
    nextnode = stack.pop()
    for e in Edge[nextnode]:
        if visited[e]:
            visited[e] = False
            stack.append(e)
            Ans[e] += Ans[nextnode]
print(*Ans[1:],sep = " ")



Measured memory_bytes: 126584
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>

using namespace std;

typedef long long ll;

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

    ll len = b - a + 1;
    ll div = ((b-a)/x);
    ll last = len - (div*x) - 1 + (a%x);
    ll diff = (last >= x || a % x == 0) ? 1 : 0;

    cout << div + diff << endl;
    return 0;
}

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

int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  int ans = N - 1;
  
  for (int j = 0; j < N; j++) {
    x -= a.at(j);
    if (x < 0) {
      ans = j;
      break;
    }
    if (x == 0) {
      ans = j + 1;
      break;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import math
X = int(input())
key = 0

def prim(N):
    sqt = int(math.sqrt(N))
    for i in range(2,sqt+1):
        if N%i == 0:
            return False
    return True

while key == 0:
    if prim(X):
        key = 1
        break
    X += 1

print(X)

Measured memory_bytes: 2940
N = int(input())
H_list = [int(x) for x in input().split()]
cnt = 1
for i, H in enumerate(H_list):
    if (i==0): continue
    visible = True
    for j in range(i):
        if (H_list[j] > H):
            visible = False
            break
    if (visible):
        cnt += 1
print(cnt)            


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll MOD = 1000000007LL;
string name[14];
vector<string> v;
bool NG[14];
int len[14][14];
int dp[1 << 14][14];
int main() {
	int N;
	while (cin >> N, N) {
		for (int i = 0; i < N; i++) cin >> name[i];
		memset(NG, 0, sizeof(NG));
		for (int i = 0; i < N; i++) {
			if (NG[i]) continue;
			for (int j = 0; j < N; j++) {
				if (i == j) continue;
				if (NG[j]) continue;
				for (int k = 0; k + name[j].size() <= name[i].size(); k++) {
					if (name[i].substr(k, name[j].size()) == name[j]) {
						NG[j] = 1;
						break;
					}
				}
			}
		}
		v.clear();
		for (int i = 0; i < N; i++) if (!NG[i]) v.push_back(name[i]);
		N = v.size();
		memset(len, 0, sizeof(len));
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (i == j) continue;
				for (int k = 1; k <= min(v[i].size(), v[j].size()); k++) {
					if (v[i].substr(v[i].size() - k) == v[j].substr(0, k)) len[i][j] = k;
				}
			}
		}
		fill((int*)dp, (int*)(dp + (1 << 14)), 1 << 30);
		for (int i = 0; i < N; i++) dp[1 << i][i] = v[i].size();
		for (int i = 1; i < (1 << N); i++) {
			for (int j = 0; j < N; j++) {
				if (!(i&(1 << j))) continue;
				for (int k = 0; k < N; k++) {
					if (i&(1 << k)) continue;
					dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + (int)v[k].size() - len[j][k]);
				}
			}
		}
		int ans = 1 << 30;
		for (int i = 0; i < N; i++) ans = min(ans, dp[(1 << N) - 1][i]);
		cout << ans << endl;
	}
}


Measured memory_bytes: 4084
#include<stdio.h>

int main(void)
{
  char str1[10] = {"Sunny"};
  char str2[10] = {"Cloudy"};
  char str3[10] = {"Rainy"};
  char str4[10];
  
  scanf("%s",str4);
  
  if(strcmp(str1,str4) == 0){
    printf("%s",str2);
  }
  
  else if(strcmp(str2,str4) == 0){
    printf("%s",str3);
  }
  
  else if(strcmp(str3,str4) == 0){
    printf("%s",str1);
  }
  
  return 0;
}
  

Measured memory_bytes: 128
import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n = getint()
vs = getints()


even = vs[0::2]
odds = vs[1::2]

even_counter = collections.Counter()
odds_counter = collections.Counter()

for e in even:
    even_counter[e] += 1
for e in odds:
    odds_counter[e] += 1

even_counter = list(sorted(list(even_counter.items()), key=lambda s: -s[1]))
odds_counter = list(sorted(list(odds_counter.items()), key=lambda s: -s[1]))

if len(even_counter) < 2:
    even_counter.append((-1, 0))
if len(odds_counter) < 2:
    odds_counter.append((-2, 0))

res = 2 * n
for i in range(2):
    for j in range(2):
        even_val = even_counter[i][0]
        odds_val = odds_counter[j][0]
        if even_val == odds_val:
            continue
        tmp1 = len(list(filter(lambda s: s != even_val, even)))
        tmp2 = len(list(filter(lambda s: s != odds_val, odds)))
        res = min(res, tmp1 + tmp2)

print(res)


Measured memory_bytes: 19260
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[201],p[101],t[101];
	scanf("%s%s",s,p);
	strcpy(t,s);
	strcat(s,t);
	if(strstr(s,p)==NULL)puts("No");
	else puts("Yes");
	return 0;
}



Measured memory_bytes: 2112
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

const int MAX = 1000001; 

struct Query 
{ 
    int l, r, idx; 
}; 
  

bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  

void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 

int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void fun(int arr[], int n, Query queries[], int q) 
{ 
    
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
         
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
         
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
//int main() 
//{ 
    //int a[] = {1, 1, 2, 1, 3}; 
    //int n = sizeof(a)/sizeof(a[0]); 
    //Query queries[3]; 
    //queries[0].l = 0; 
    //queries[0].r = 4; 
    //queries[0].idx = 0; 
    //queries[1].l = 1; 
    //queries[1].r = 3; 
    //queries[1].idx = 1; 
    //queries[2].l = 2; 
    //queries[2].r = 4; 
    //queries[2].idx = 2; 
    //int q = sizeof(queries)/sizeof(queries[0]); 
    //sort(queries, queries+q, cmp); 
    //answeringQueries(a, n, queries, q); 
    //return 0; 
//} 

void solve(){
	int n,q;
	cin >> n >> q;
	int a[n];
	for(int i = 0; i < n; ++i)cin >> a[i];
	Query queries[q];
	for(int i = 0; i < q; ++i){
		queries[i].idx = i;
		cin >> queries[i].l >> queries[i].r;
		queries[i].l--;
		queries[i].r--;
	}
	sort(queries, queries + q, cmp);
	fun(a, n, queries, q);
	return;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


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

using namespace std;

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

long long calc(long long l, long long r, long long p) {
    long long left = l / p * p;
    if (left < l) left += p;
    long long right = r / p * p;
//    cout << left << " " << right << endl;
    return (right / p - left / p) + 1;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long e = c * d / gcd(c, d);
    long long len = b - a + 1;
//    cout << calc(a, b, c) << endl;
//    cout << calc(a, b, d) << endl;
    long long ans = len - (calc(a, b, c) + calc(a, b, d) - calc(a, b, e));
    cout << ans;
    return 0;
}


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

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

int main() {
  int n, k; cin >> n >> k;
  vector<ll> x(n), y(n), xx(n), yy(n);
  REP(i,n) {
    cin >> x[i] >> y[i];
    xx[i] = x[i], yy[i] = y[i];
  }
  whole(sort, xx);
  whole(sort, yy);
  ll ans = (xx[n-1] - xx[0]) * (yy[n-1] - yy[0]);
  REP(ixl, n) for (int ixr = ixl+1; ixr < n; ixr++)
  REP(iyl, n) for (int iyr = iyl+1; iyr < n; iyr++) {
    ll xl = xx[ixl], xr = xx[ixr];
    ll yl = yy[iyl], yr = yy[iyr];
    ll count = 0;
    REP(i,n) {
      if (!(xl <= x[i] && x[i] <= xr)) continue;
      if (!(yl <= y[i] && y[i] <= yr)) continue;
      count++;
    }
    if (count >= k) {
      ll area = (xr - xl) * (yr - yl);
      chmin(ans, area);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p;
//vector<int>v;
//map<int,int>mp;
ll a[30];
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>s;
    for(char c:s)
    {
        a[c-97]++;
    }
    for(i=0;i<26;i++)
    {
        if(a[i]%2==1)
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

h, w, K = map(int, input().split())
field = []
field_int = []
for _ in range(h):
    s = input().rstrip()
    line = [int(item) for item in s]
    field.append(line)

ans = 10**5
for i in range(2**(h-1)):
    group = [0]
    g = 0
    for j in range(h-1):
        if i & 1 << j: 
            g += 1
            group.append(g)
        else:
            group.append(g)
    line_num = bin(i).count("1") + 1
    cnt = [0] * line_num
    ret = 0
    ok = True
    for j in range(w):
        tmp = [0] * line_num
        for k in range(h):
            tmp[group[k]] += field[k][j]
        should_cut = False
        for c, t in zip(cnt, tmp):
            if t > K:
                ok = False
            if c + t > K:
                should_cut = True
        if not should_cut:
            for i, t in enumerate(tmp):
                cnt[i] += t
        else:
            ret += 1
            for i, t in enumerate(tmp):
                cnt[i] = t
    if not ok:
        continue
    ans = min(ans, ret + line_num - 1)
print(ans)

Measured memory_bytes: 46812
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long lli;

lli gcd(lli x, lli y){ return y ? gcd(y, x%y) : x; }

main(){
  int n;
  while(cin >> n && n){
    vector<lli> vec[2];
    for(int i=0;i<n*(n+1)/2;i++){
      lli in;
      cin >> in;
      if(in%2) vec[1].push_back(in);
      else vec[0].push_back(in);
    }
    for(int i=0;i<2;i++) sort(vec[i].begin(), vec[i].end());
    lli t = gcd(vec[0][0], vec[1][0]);
    lli a = sqrt(vec[0][0] / t * (vec[0][1] / (vec[1][0] / t)));
    cout << a << endl;
    for(int i=0;i<vec[0].size();i++) cout << vec[0][i] / a << (i+1 == vec[0].size() ? "\n" : " ");
  }
}

Measured memory_bytes: 1608
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 105;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int arr[3];
	rep(i,0,3)
	cin>>arr[i];
	sort(arr,arr+3);
	if(arr[0]+arr[1]==arr[2])
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
}


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

typedef long long ll;

int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> a(N),b(N),c(M),d(M);
    for(int i=0; i<N; i++) cin >> a[i] >> b[i];
    for(int i=0; i<M; i++) cin >> c[i] >> d[i];
    
    ll mi=1e9, ti=0;
    for(int i=0; i<N; i++){
        mi = 1e9;
        for(int j=0; j<M; j++){
            ll t = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(t<mi){
                mi = t;
                ti = j;
            }
        }
        cout << ti+1 << endl;
    }
}


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

using namespace std;

int N;
int Count;

int main() {
  cin >> N;

  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if(a % 2 == 1) Count++;
  }

  if(Count % 2 == 0) cout << "YES" <<endl;
  else cout << "NO" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

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

  ll n;
  cin >> n;

  cout << n * n * n << endl;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()

for x in range(1,10):
    for y in range(1,10):
        if x*y == N:
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 4076
//{{{
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
//}}}

constexpr int nax = 1e5, mod = 1e9 + 7;

int n, m, tab[nax];

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

    cin >> n >> m;

    int res = 1;

    for (int r : {n, m})
    {
        for (int i = 0; i < r; ++i)
            cin >> tab[i];
        int sum = 0, su = 0;
        for (int i = 1; i < r; ++i)
        {
            int r = (tab[i] - tab[i - 1]) % mod;
            r = ((ll)r * i) % mod;
            su = (su + r) % mod;
            sum = (sum + su) % mod;
        }
        res = ((ll)res * sum) % mod;
    }
    cout << res << '\n';
}

Measured memory_bytes: 640
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
a = [None]*h
for i in range(h):
    a[i] = input()
# print(a)

dx = [-1, -1, -1, 0, 1, 1, 1, 0]
dy = [-1, 0, 1, 1, 1, 0, -1, -1]

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            print('#', end="")
        else:
            count = 0
            for k in range(8):
                x = i+dx[k]  # (i,j)の位置からk移動させたときのx座標
                y = j+dy[k]  # (i,j)の位置からk移動させたときのy座標
                if x < 0 or x >= h or y < 0 or y >= w:
                    # x,yが盤面の中に入っていて'#'のとき
                    continue

                if a[x][y] == '#':
                    count += 1

            print(count, end="")

    print('\n', end="")


Measured memory_bytes: 4076
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
string s; cin >> s;
set<char> t;
rep(i,s.size()) t.insert(s[i]);

	if((t.count('E') && t.count('W') ) || (! t.count('E') && ! t.count('W'))){
		if((t.count('N') && t.count('S') ) || (! t.count('N') && ! t.count('S'))){
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS cin.tie(NULL);iosbase::sync_with_stdio(false);
#define pb push_back
int red,green,a,b,c,x,y,z;
long long ans;
int p[100005],q[100005],r[100005];
int32_t main(){
   cin>>red>>green>>a>>b>>c;
   for(int i=0;i<a;i++){
       cin>>p[i];
   }
   for(int i=0;i<b;i++){
       cin>>q[i];
   }
   for(int i=0;i<c;i++){
       cin>>r[i];
   }
   sort(p,p+a,greater<int>());
   sort(q,q+b,greater<int>());
   sort(r,r+c,greater<int>());
   vector<int> d;
   for(int i=0;i<red;i++){
       d.pb(p[i]);
   }
   for(int i=0;i<green;i++){
       d.pb(q[i]);
   }
   for(int i=0;i<min(c,red+green);i++){
       d.pb(r[i]);
   }
   sort(d.begin(),d.end(),greater<int> ());
   for(int i=0;i<(red+green);i++){
       ans += d[i];
   }
   cout<<ans;
}

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

int main() {
  int N; 
  cin>>N;
  int ans;
  int sum;
  for(int i=0;2*i+1<=N;i++){
    sum=0;
    for(int j=1;j<=2*i+1;j++){
      if((2*i+1)%j==0)sum++;
    }
    if(sum==8)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

ll solve(ll h,ll w){
  ll ans=LLONG_MAX;
  for(ll i=1;i<w;i++){
    ll s1,s2,s3;
    s1=i*h;
    s2=(h/2)*(w-i);
    if(h%2){
      s3=(h/2+1)*(w-i);
    }else{
      s3=s2;
    }
    ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
    s2=((w-i)/2)*h;
    if((w-i)%2){
      s3=((w-i)/2+1)*h;
    }else{
      s3=s2;
    }
    ans=min(ans,max({s1,s2,s3})-min({s1,s2,s3}));
  }
  return ans;
}

int main(){
  ll h,w;
  cin>>h>>w;
  cout<<min(solve(h,w), solve(w,h))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	int ans = 1;
	for (int i = 0; i < N; i++) {
		if (K > ans) ans *= 2;
		else ans += K;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = gets.chop.split('')

def solve(s)
  if s[0] != 'A'
    return 'WA'
  end
  count = 0
  s[2..-2].each_with_index do |char, i|
    if char == 'C'
      count += 1
      idx = i
    end
  end
  if count != 1
    return 'WA'
  end
  count = 0
  s.each do |char|
    count += 1 if char != char.downcase
  end
  if count == 2
    return 'AC'
  else
    return 'WA'
  end
end

puts solve(s)


Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
	int n[28];
	int j, i;
	int m[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 };

	for (i = 0;i < 28;i++) {
		scanf("%d", &n[i]);
		for (j = 0;j < 30;j++) {
			if (m[j] == n[i]) {
				m[j] = 0;
			}
		}
	}
		for (i = 0;i < 30;i++) {
			if (m[i] != 0) 
				printf("%d\n", m[i]);
			
		}
			
			return 0;
		}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;

namespace ABC_045
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());

            int ans = (a + b) * h / 2;

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 2776
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 1e6;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d, x; cin >> n >> d >> x;
    int p[d + 1][n + 1];
    for(int i = 0; i < d; i++) 
    {
        for(int j = 0; j < n; j++) cin >> p[i][j];
    }
    int dp[MAX_N + 1];
    int now = x;
    for(int day = 0; day < d - 1; day++)
    {
        for(int money = 0; money <= now; money++) dp[money] = money;
        int tmp = x;
        for(int num = 0; num < n; num++)
        {
            for(int money = 0; money <= now; money++)
            {
                if(money - p[day][num] < 0) continue;
                dp[money] = max(dp[money], dp[money - p[day][num]] + p[day + 1][num]);
                tmp = max(dp[money], tmp);
            }
        }
        now = tmp;
    }
    cout << now << endl;
    return 0;
}


Measured memory_bytes: 3280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    ll N;
    cin >> N;
    string s = "";
    while(N > 0){
        int hoge = (N - 1) % 26;
        N = (N - 1) / 26;
        s = char('a' + hoge) + s;
    }
    cout << s << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  map<int, int> a;
  int tmp;
  REP(i, n) {
    cin >> tmp;
    a[tmp]++;
  }

  int t1 = 0, t2 = 0;

  for(auto i=a.rbegin();i != a.rend();i++) {
    if(i->second >= 4 && t1 == 0) {
      t1 = i->first;
      t2 = i->first;
      break;    
    } else if(i->second >= 2 && t1 == 0) {
      t1 = i->first;
    } else if(i->second >= 2) {
      t2 = i->first;
      break;
    }
  }
  cout << t1 * t2 << endl;

  
}


Measured memory_bytes: 6528
#!/usr/bin/env python3
import sys
from itertools import combinations


def solve(N: int, L: "List[int]"):
    l1 = list(combinations(L, 3))
    cnt = 0
    for l in l1:
        s = set(l)
        if len(s) == 3:
            M = max(l)
            if sum(l) - M > M:
                cnt += 1
    print(cnt)
    return


# Generated by 1.1.7.1 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()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()

Measured memory_bytes: 87452
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

asum = [0]
a.each do |ai|
  asum << asum.last + ai
end
asum << asum.last + k + 1

bsum = [0]
b.each do |bi|
  bsum << bsum.last + bi
end
bsum << bsum.last + k + 1

ans = 0
asum.each_with_index do |av, i|
  break if av > k
  j = bsum.bsearch_index{|x| x + av > k}
  newans = i + j - 1
  ans = newans if ans < newans
end
puts ans


Measured memory_bytes: 45208
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main()
{
  int h,w,dp[1005][1005]={};
  char a[1005][1005];
  cin>>h>>w;

  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin>>a[i][j];
    }
  }

  dp[1][1]=1;

  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(a[i-1][j-1]!='#'){
	dp[i][j]+=(dp[i][j-1]%MOD+dp[i-1][j]%MOD)%MOD;
      }
    }
  } 
  cout<<dp[h][w]<<'\n';
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		set<UL> s;
		rep(i, N) {
			UL a; cin >> a;
			if (s.count(a)) { cout << "NO" << endl; return; }
			s.insert(a);
		}
		cout << "YES" << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

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

    int ans = 0;
    int a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
}


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



int main() {
    int n;
    cin >> n;
    
    vector<long int> all(n+1);
    long int sum = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j += i) {
            all[j]++;
        }
        sum += all[i] * i;
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 81408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(1){ 
    cin>>n;
    if(!n)break;
    int data[12][12]={0};
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>data[i][j];
	data[n][j]+=data[i][j];
	data[i][n]+=data[i][j];
      }
      data[n][n]+=data[i][n];
    }
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	printf("%5d",data[i][j]);
      }
      printf("\n");
    }
  }
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMonstersBattleRoyale

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		try {
			FastScannerMonstersBattleRoyale sc = new FastScannerMonstersBattleRoyale(System.in);
			int N = sc.nextInt();
			long[] A = new long[N];
			for (int i = 0; i < N; i++) {
				A[i] = sc.nextInt();
			}

			Gcd gcd = new Gcd();
			long cmd = A[0];
			//最大公約数を前から順次計算していく。
			for (int i = 1; i < N; i++) {
				cmd = gcd.getGcd(cmd, A[i]);
			}
			System.out.println(cmd);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

class Gcd {

	/**
	 * ユークリッドの互除法で最大公約数を求める
	 */
	public long getGcd(long a, long b) {
		if (b == 0)
			return a;
		return getGcd(b, a % b);
	}

}

//高速なScanner
class FastScannerMonstersBattleRoyale {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMonstersBattleRoyale(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

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


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

int main(){

  int n,l;

  scanf("%d %d", &n, &l);

  vector<string> s(n);

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

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

  for(i = 0;i < n;i++) cout << s[i];

  printf("\n");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long i64;
const int N=1e5+7;
i64 ans=0;
int n1,n2,n3,n,nx[N],nv[N],pp1,pp2,vs[N];
struct pos{
	int x,v;
	bool operator<(const pos&w)const{return v<w.v;}
}ps1[N],ps2[N];
std::priority_queue<pos>q;
int main(){
	scanf("%d%d%d",&n1,&n2,&n3);
	n=n1+n2+n3;
	for(int i=1,a,b,c;i<=n;++i){
		scanf("%d%d%d",&a,&b,&c);
		ans+=c;
		ps1[i]=(pos){i,a-c};
		ps2[i]=(pos){i,b-c};
		vs[i]=b-a;
	}
	std::sort(ps1+1,ps1+n+1);
	std::sort(ps2+1,ps2+n+1);
	pp1=pp2=n;
	for(int i=1;i<=n1;++i){
		pos p=ps1[pp1--];
		nx[p.x]=1;
		ans+=p.v;
		q.push((pos){p.x,vs[p.x]});
	}
	for(int i=1;i<=n2;++i){
		while(nx[ps1[pp1].x])--pp1;
		while(nx[ps2[pp2].x])--pp2;
		int v1=ps1[pp1].v,v2=ps2[pp2].v;
		while(q.size()&&nx[q.top().x]!=1)q.pop();
		int v21=q.size()?q.top().v+v1:INT_MIN;
		if(v2>v21){
			nx[ps2[pp2--].x]=2;
			ans+=v2;
		}else{
			int x=ps1[pp1--].x;
			nx[x]=1;
			nx[q.top().x]=2;
			q.pop();
			ans+=v21;
			q.push((pos){x,vs[x]});
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3704