akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let k: usize = sc.read();
    let a = sc.read_vec::<usize>(n);

    for i in k..n {
        if a[i] > a[i - k] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
int N,c=0;
signed main(){
  cin >> N;
  int p;
  for(int i=1;i<=N;i++){
    cin >> p;
    if(c>=3){
      cout << "NO" << endl;
      return 0;
    }
    if(p!=i) c++;
  }
  cout << "YES" << endl;
  return 0;
}


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

using namespace std;

int main(void)
{
    int X, N;
    int p[100];

    cin >> X >> N;
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    for(int i = 0; i <= X; i++){
        if(find(p, p+N, X-i) == p+N){
            cout << X - i << endl;
            break;
        }
        if(find(p, p+N, X+i) == p+N){
            cout << X + i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3644
#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
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#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 998244353
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

ll comb(ll N_, ll C_) {
	const int NUM_ = 400001;
	static ll fact[400002], factr[400002], inv[400002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mod, factr[i] = factr[i - 1] * inv[i] % mod;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mod*factr[N_ - C_] % mod;
}
ll modpow(ll a, ll n = mod - 2) {
	ll r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % mod, a = a * a%mod, n >>= 1;
	return r;
}


int dp[3010][3010];

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

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	
	dp[A][B] = 1;

	for (int i = A; i <= C; i++) {
		for (int j = B; j <= D; j++) {
			dp[i][j] += dp[i - 1][j] * j;
			dp[i][j] %= mod;
			dp[i][j] += dp[i][j - 1] * i;
			dp[i][j] %= mod;
			dp[i][j] -= dp[i - 1][j - 1] * (i - 1)*(j - 1) % mod;
			dp[i][j] += mod;
			dp[i][j] %= mod;
			dp[i][j] %= mod;
		}
	}


	cout << dp[C][D] << endl;

	return 0;
}



Measured memory_bytes: 74140
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i, n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";

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 modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int n, ans=inf;
signed main() {
	cin >> n;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans = min(ans, i + n / i - 2);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
keys = c.keys()

st = set()
for key in keys:
    for i in (-1, 0, 1):
        st.add(key + i)

ans = 0
for x in st:
    cnt = c[x-1] + c[x] + c[x+1]
    ans = max(ans, cnt)

print(ans)


Measured memory_bytes: 20944
#include<iostream>
#define maxm 200010
#define maxn 200010
using namespace std;
int link[maxm],head[maxn],to[maxm],d[maxn];
int tot,flag,ans;
void add(int u,int v){
	link[++tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
void dfs(int x){
	if(flag) return ;
	for(int i=head[x];i;i=link[i]){
		if(d[to[i]]==d[x]) flag=1;
		if(d[to[i]]) continue;
		if(flag) break;
		else{
			if(d[x]==1){
				d[to[i]]=2;
				ans++;
			}
			else d[to[i]]=1;
			dfs(to[i]);
		}
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		add(u,v);
		add(v,u);
	}
	d[1]=1;
	dfs(1);
	if(flag) cout<<1LL*n*(n-1)/2-m<<endl;
	else cout<<1LL*ans*(n-ans)-m<<endl;
	return 0;
}

Measured memory_bytes: 2816
from collections import defaultdict

graph = defaultdict(set)
n, m = map(int, input().split())

for i in range(m):
    a, b = map(int, input().split())
    graph[a].add(b)
    graph[b].add(a)


# paths = [0] * (n+1)
# paths[1] = 1
# for i in range(1, n+1):
#     for j in graph[i]:
#         paths[j] += paths[i]
# print(paths[n])

def find_all_paths(graph, start, rest, path=[]):
    path = path + [start]
    rest2 = rest.copy()
    rest2.remove(start)
    if len(rest2) == 0:
        return [path]
    if start not in graph:
        return []
    paths = []
    for node in graph[start]:
        if node not in path:
            newpaths = find_all_paths(graph, node, rest2, path)
            for newpath in newpaths:
                paths.append(newpath)
    return paths

paths = find_all_paths(graph, 1, set(graph.keys()))
print(len(paths))

Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <cmath>
#include <complex>

using namespace std;

typedef complex<double> Point;

const double EPS = 1e-8;

int n;
Point data[300];

int calc(Point a, Point b){
  int res = 0;
  double d = abs(b - a) / 2.0;
  Point ab = (b - a) / (2.0 * d);
  if(d < 1){
    Point o = ab * d;
    d = sqrt(1.0 - d * d);
    o += Point(d * ab.imag() + a.real(), -d * ab.real() + a.imag());
    for(int i=0;i<n;i++){
      if(abs(o - data[i]) < 1.0 + EPS) res++;
    }
  }
  return res;
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> data[i].imag() >> data[i].real();
    }
    int ans = 1;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        ans = max(ans, calc(data[i], data[j]));
        ans = max(ans, calc(data[j], data[i]));
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 980
#!/usr/bin/env lua

s = io.read("*line")
nlist = {}
j = 1
for i in string.gmatch(s, "%S+") do
    nlist[j] = tonumber(i)
    j = j + 1
end

if nlist[1] + nlist[2] >= 10 then
    print("error")
else
    print(nlist[1]+nlist[2])
end

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed main(){
  int N, X, T;
  cin >> N >> X >> T;
  cout << (N+X-1)/X * T << endl;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string S; cin >> S;
	int len = S.length();

	int ans = 1 << 30;
	int cnt = 0;
	REP(i,len){
		int x = S[i] - '0';
		if(x != i%2) cnt++;
	}

	ans = min(ans, cnt);
	cnt = 0;
	REP(i,len){
		int x = S[i] - '0';
		if(x != (i+1)%2) cnt++;
	}

	ans = min(ans, cnt);
	cout << ans << endl;

	return 0;

}


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

typedef long long ll;

int main(){
    string a,b;
    cin>>a>>b;
    if(a[0]==b[2]&&a[2]==b[0]&&a[1]==b[1]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


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

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

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

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    vector<int> x(n, -1);

    rep(i, m) {
        int s, c;
        cin >> s >> c;
        if (x[s - 1] == -1)
            x[s - 1] = c;
        else if (x[s - 1] != c) {
            cout << -1 << endl;
            return 0;
        }
    }

    if (x[0] == 0 && n > 1) {
        cout << -1 << endl;
        return 0;
    }

    if (x[0] == -1) {
        if (n > 1) {
            x[0] = 1;
        } else {
            x[0] = 0;
        }
    }

    rep(i, n) {
        if (x[i] == -1) {
            x[i] = 0;
        }
        cout << x[i];
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 char ch,temp='1';
 int cnt=0;
 for(int i=0;i<n;i++)
 {
     cin>>ch;
     if(temp==ch){}
     else cnt++;
     temp=ch;
 }
cout<<cnt;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (A, B, C, X, Y) = listOfLong()
    var k = 0L
    var ans = Long.MAX_VALUE
    while ( k < X + Y) {
        val now = 2 * C * k + Math.max(X - k, 0) * A + Math.max(Y - k, 0) * B
        ans = Math.min(ans, now)
        k += 1
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong(d: Int = 0) = listOfString().map { it.toLong() + d }


Measured memory_bytes: 38048
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
ll ans;
int main() {
	ll i, s, last, n, cha = 0;
	scanf("%lld %lld", &n, &s);
	last = s;
	for(i = 1; i < n; i++) {
		scanf("%lld", &s);
		if(s > last) {
			last = s;
			continue;
		}
		ans += last - s;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1720
#include <string.h>
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long unsigned int ll;

#define N 8

int main() {
    int n = 0;
    double x[N];
    double y[N];

    
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    vector<int> order(n);
    for (int i = 0; i < n; i++) order[i] = i;

    double res = 0.0;
    double cnt = 0;
    do {
        double sum = 0;
        for (int i = 1; i < n; ++i) {
            double x_ = x[order[i-1]]-x[order[i]];
            double y_ = y[order[i-1]]-y[order[i]];
            double tmp = std::sqrt(x_ * x_+ y_ * y_);
            sum += tmp;
            //cout << std::fixed << tmp << endl;
        }

        res += sum;
        //cout << std::fixed << res << endl;
        cnt++;

    } while (next_permutation(order.begin(), order.end()));
    cout << std::fixed << res/cnt  << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b=1,atk=0;
	scanf("%lld",&a);
	while(a)
	{
		a=a/2;
		atk+=b;
		b=b*2;
	}
	printf("%lld",atk);
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    eunique(v);
    cout << v.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define ll long long
using namespace std;
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	x=x*10+(ch^48);
	return x*f;
}
//}}}
const int N=1e6+5;
int n,a[N],b[N];
int C(int n,int m){
	if((n&m)==m)	return 1;
	return 0;
}
int work(){
	int res=0;
	for(int i=1;i<n;i++)
		if(b[i]&&C(n-2,i-1))	res^=1;
	return res;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	a[i]=read();
	for(int i=1;i<n;i++)	b[i]=(abs(a[i]-a[i+1]));
	int flag=0;
	for(int i=1;i<n;i++)
		if(b[i]==1)	flag=1;
	if(flag){
		for(int i=1;i<=n;i++)
			if(b[i]==2)	b[i]=0;
	}
	else{
		for(int i=1;i<=n;i++)
			if(b[i]==2)	b[i]=1;
	}
	int d=work();
	if(flag){
		if(d)	puts("1");
		else	puts("0");
	}
	else{
		if(d)	puts("2");
		else	puts("0");
	}
	return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>

int main(){
	
	//準備部分
	int x=0,i;
	char a[1001]={};
	
	//入力部分
	while(1){
		scanf("%s",a);
		if(a[0]=='0')break;
		for(i=0;i<1001;i++){
			if(a[i]=='\0')break;
			x+=a[i]-'0';
		}
		printf("%d\n",x);
		x=0;
	}
	
	return 0;
}



Measured memory_bytes: 2100
n=0
stones=[0]*n
memo=[-1]*n

def dp(pos):
  if pos==n-1:
    return 0
  if pos==n-2:
    return abs(stones[pos+1]-stones[pos])
  if memo[pos] is not -1:
    return memo[pos];
  memo[pos]=min(abs(stones[pos+1]-stones[pos])+dp(pos+1),abs(stones[pos+2]-stones[pos])+dp(pos+2))
  return memo[pos]

def dp_iterative():
  memo[n-1]=0
  if n>=2:
    memo[n-2]=abs(stones[n-1]-stones[n-2])
  for index in range(n-3,-1,-1):
    memo[index]=min(memo[index+1]+abs(stones[index+1]-stones[index]),memo[index+2]+abs(stones[index+2]-stones[index]))
  return memo[0]

if __name__=='__main__':
  n=int(input())
  stones=[0]*n
  stones=[int(val) for val in input().split()]
  memo=[-1]*n
  print(dp_iterative())


Measured memory_bytes: 14676
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define REP(i, N) for(int i=0; i<(int)N; i++)
#define REPR(i, N) for(int i=(int)N-1; i>=0; i--)
#define mp make_pair
#define pb push_back

// Type
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;

// Constants
const ll MOD = 1000000007;

/**
  型に合わせたINFを返す
  int: 214,748,364 (2.14 * 1e8)
  ll : 922,337,203,685,477,580 (9.22 * 1e17)
*/
template <typename T>
T getINF() {
  // NOTE: INF同士を足してもオーバーフロー起こさないように、10で割っている
  return numeric_limits<T>::max() / 10;
}

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  priority_queue<Pll> q;

  int n, m;
  cin >> n >> m;
  REP(i, n) {
    ll a;
    cin >> a;
    q.push(mp(a, 1));
  }
  REP(i, m) {
    ll b, c;
    cin >> b >> c;
    q.push(mp(c, b));
  }

  ll ans = 0;
  REP(i, n) {
    Pll e = q.top(); q.pop();
    ans += e.first;
    if(e.second > 1) {
      q.push(mp(e.first, e.second-1));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6256
unittest
{
	assert( [ "6 4", "-10 8 2 1 2 6" ].solve == 14 );
	assert( [ "6 4", "-6 -100 50 -2 -5 -3" ].solve == 44 );
	assert( [ "6 3", "-6 -100 50 -2 -5 -3" ].solve == 0 );
	
	assert( [ "6 8", "-10 8 2 1 2 -6" ].solve == 13 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s"( n, k );
	input.popFront;
	auto vs = input.front.split.to!( long[] );
	
	auto ans = long.min;
	foreach( c; 0L .. k + 1 )
	{
		auto cc = min( n, c );
		foreach( l; 0L .. cc + 1 )
		{
			foreach( r; 0L .. cc - l + 1 )
			{
				auto t = 0L;
				long[] ms;
				foreach( v; vs[ 0 .. l ] )
				{
					t += v;
					if( v < 0 ) ms ~= v;
				}
				foreach( v; vs[ $ - r .. $ ] )
				{
					t += v;
					if( v < 0 ) ms ~= v;
				}
				t -= ms.sort.take( c - l - r ).sum;
				ans = max( ans, t );
			}
		}
	}
	return ans;
}


Measured memory_bytes: 3880
use std::io;


fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut like = vec![0; m + 1];

    for _ in 0..n {
        let ak = read::<usize>();
        for i in 1..ak.len() {
            like[ak[i]] += 1;
        }
    }

    println!("{:?}", like.iter().filter(|&l| l == &n).count());
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    ll a,b,c;
    cin >> a >>b >>c;
    if(a==0){
        cout << b/c+1 << endl;
    }else cout << b/c -(a-1)/c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0) break;
		for(i=0;i<W;i++){
			printf("#");
		}
		printf("\n");
		for(i=0;i<(H-2);i++){
			printf("#");
			for(j=0;j<(W-2);j++){
				printf(".");
			}
			printf("#");
			printf("\n");
		}
		for(i=0;i<W;i++){
			printf("#");
		}
		printf("\n");
				printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
w,h,x,y = map(int,input().split())

max_area = w*h/2

if w%2!=0 or h%2!=0:
    split = 0

else:
    split = 0
    if x==w//2:
        if y==h//2:
            split = 1

print('{} {}'.format(max_area, split))

Measured memory_bytes: 2940
def resolve():
    n=int(input())
    s=list(input())
    chk1=[0]*10
    chk2=[0]*100
    l=[]
    ans=0
    for i in range(n-2):
        if chk1[int(s[i])]==0:
            chk1[int(s[i])]=1
            for j in range(i+1,n-1):
                x=s[i]+s[j]
                if chk2[int(x)]==0:
                    chk2[int(x)]=1
                    if x in l:
                        continue
                    else:
                        l.append(x)
                        ans+=len(set(s[j+1:]))
    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9452
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int n;
    string s;
    cin>>n>>s;
    int r = 0;
    vector<int> red(n, 0), blue(n, 0), green(n, 0);
    ++(s[0] == 'R' ? red : s[0] == 'G' ? green : blue)[0];
    for (int i = 1; i < n; ++i) {
        red[i] += red[i - 1];
        green[i] += green[i - 1];
        blue[i] += blue[i - 1];
        ++(s[i] == 'R' ? red : s[i] == 'G' ? green : blue)[i];
    }
    for (int i = 0; i < n - 3; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (s[i] == s[j]) continue;
            int ki = j + j - i;
            map<char, bool> m;
            m[s[i]] = m[s[j]] = true;
            char colc = (m['R']?(m['G']?'B':'G'):'R');
            assert(colc != s[i] && colc != s[j]);
            vector<int>& col = (colc == 'R' ? red : (colc == 'G' ? green : blue));
            int nk = col[n - 1] - col[j] - (ki<n&&s[ki]==colc?1:0);
            r += nk;
        }
    }
    cout << r;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 20
#define DIVISOR 1000000007

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

#define NUM_MAX 1000
#define K_MAX 1000

// pdp[# of partitions][# of balls]
static uint64_t pdp[K_MAX+1][NUM_MAX+1];
void init() {
    pdp[0][0] = 1;
    int i, j;
    for(i = 1; i <= K_MAX; i++) {
        for(j = 0; j <= NUM_MAX; j++) {
            pdp[i][j] = pdp[i-1][j];
            if(j>=i) pdp[i][j] = (pdp[i][j] + pdp[i][j-i])%DIVISOR;
        }
    }
    return;
}

int main(void) {
    int n, k;
    get_int2(&n, &k);
    init();
    printf("%d\n", (int)pdp[k][n]);
    return 0;
}


Measured memory_bytes: 9676
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(int argc, char **argv){
  ll N;
  if(argc == 2){
    N = atoi(argv[1]);
  }else{
    cin >> N;
  }


  string namae = "";

  while(N > 0){
    int t = N%26;
    if(t == 0){
      namae = "z" + namae;
    }else{
      char c = t-1 + 'a';
      namae = c + namae;
    }
    N -= t;
    if(t == 0){N -= 26;}
    N /= 26;
  }

  cout << namae << endl;

  return 0;
}


Measured memory_bytes: 3596
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)
N, K =LI()
A = LI()
F = LI()
A.sort(reverse=True)
F.sort()

xupper = max(A)*max(F)
xlower = int(0)
xcandi = xupper//2

sumA = sum(A)

while (True):
#    print(xlower,xupper, xcandi)
    k = int(0)
    for i in range(N):
        k += max((A[i]*F[i]-xcandi+(F[i]-1))//F[i],0)
#    print(k)

    if k>K:
        xlower = xcandi
        xcandi = ((xcandi + xupper) // 2)+1
    else:
        if xupper-xlower<=1:
            ans = xcandi
            break
        else:
            xupper = xcandi
            xcandi = (xcandi + xlower) // 2

print(ans)

Measured memory_bytes: 107084
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

const double pi = 3.141592653589793;
vector<double> x(101), y(101);
int n; 

inline double naiseki(const double& x1, const double& y1, const double& x2, const double& y2) {
  return x1 * x2 + y1 * y2;
}

// 角度 theta の方向を最終的に向くとして計算
// theta は radian
double calc(const double& theta) {
  double res = 0.0;
  double dx = cos(theta), dy = sin(theta);
  for (int i = 0; i < n; ++i) {
    res += max(0.0, naiseki(dx, dy, x[i], y[i]));
  }
  return res;
}

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

  auto start = chrono::system_clock::now();

  cin >> n;
  rep(i, n) cin >> x[i] >> y[i];

  int step = 7777777;

  double ans = 0.0;

  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> r(0, step);

  auto msec = 0.0;

  do {
    double theta = 2.0 * pi * r(mt) / step;
    chmax(ans, calc(theta));
    auto end = chrono::system_clock::now();
    auto dur = end - start;
    msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
  } while (msec <= 1990);

  cout << setprecision(15) << ans << '\n';

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
//#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdlib>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i,j,k) for(int i=j;i<(int)(k);++i)
#define foreach(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const int INF = 99999999;
const double EPS = 1e-9;

int getR(const int& top, const int& front){
	if(top>=4) return getR(7-top,7-front);
	if(front>=4) return 7-getR(top,7-front);
	if(top==1){
		if(front==2) return 3;
		else return 5;
	} else if(top==2){
		if(front==1) return 4;
		else return 1;
	} else {
		if(front==1) return 2;
		else return 6;
	}
}
int getL(const int& top, const int& front){ return 7-getR(top,front); }
int getF(const int& top, const int& front){ return front; }
int getB(const int& top, const int& front){ return 7-front; }

const int dx[]={0,1,0,-1},dy[]={-1,0,1,0};//D,R,U,L
int n,t,f,map[210][210],rank[210][210];

int main()
{
	int (*Func[4])(const int&, const int&) = { getF, getR, getB, getL };
	while(cin>>n,n){
		memset(map,0,sizeof(map));
		memset(rank,0,sizeof(rank));
		rep(dice,n){
			cin >> t >> f;
			bool flag=false;
			int x=105,y=105;

			while(1){
				if(flag) break;
				flag=true;
				for(int d=6;d>=4;--d){
					if(!flag) break;
					rep(i,4){
						if(!flag) break;
						if(d!=(*Func[i])(t,f)) continue;

						int xx = x+dx[i],yy=y+dy[i];
						if(rank[x][y]<=rank[xx][yy]) continue;
						// printf("%d %d\n",(*Func[i])(t,f),i);
						// printf("%d %d %d %d %d\n",d,t,f,x,y);
						x=xx;
						y=yy;
						int res;
						if(i==0){
							res=f;
							f=t;
							t=7-res;
						} else if(i==1){
							t=getL(t,f);
						} else if(i==2){
							res=t;
							t=f;
							f=7-res;
						} else {
							t=getR(t,f);
						}
						flag=false;
					}
				}
			}
			map[x][y]=t;
			rank[x][y]++;
			//printf("%d %d %d\n",t,x,y);
		}

		int ans[7]={0};
		rep(i,210)rep(j,210) ans[map[i][j]]++;
		REP(i,1,7)printf("%d%c",ans[i],i!=6?' ':'\n');
	}
	
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int A, P; cin >> A >> P;
  P += A * 3;
  cout << P / 2 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


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

    ll factorial=1;
    for(int i=1;i<=n;++i){
        factorial = (factorial*i)%(1000000000+7);
    };
    cout<<factorial<<endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c = gets.split.map(&:to_i).sort!
a, b = c - a, c - b

diva, a = a.divmod(2)
divb, b = b.divmod(2)
ans = diva + divb

if a + b == 0
  puts ans
else
  puts ans + 3 - (a + b)
end


Measured memory_bytes: 1788
import math

def h():
    a,b,x = map(int,input().split())

    xdash = x / a
    FULL = a * b

    if xdash == FULL:
        return 0
    elif FULL / 2 == xdash:
        return b/a
    elif FULL / 2 > xdash:
        return b*b/xdash/2
    else:
        return 2*(a*b-xdash)/a/a

print(math.degrees(math.atan(h())))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

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

const int kMaxN = 100;

int N, x;
int a[kMaxN];

int ans = 0;

signed main() {
  cin >> N >> x;
  REP(i, N) { cin >> a[i]; }

  sort(a, a+N);
  REP(i, N) {
    if (x <= 0) { break; }

    if (i != N-1) {
      if (x-a[i] > 0) {
        x -= a[i];
      } else if (x-a[i] == 0) {
        ans = i+1;
        break;
      } else {
        ans = i;
        break;
      }
    } else {
      if (x-a[i] > 0) {
        ans = N-1;
      } else if (x-a[i] == 0) {
        ans = N;
      } else {
        ans = N-1;
      }
    }
  }

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


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

ans = 10**9
for i in range(L, min(R, L+2019)+1):
    for j in range(i+1, min(R, L+2019)+1):
        ans = min(ans, (i % 2019) * (j % 2019) % 2019)

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("in.txt","r",stdin);
    int a,b;
    int n;
    while(scanf("%d",&n)!=-1)
    {
    	int flag=0;
    	for(int i=1;i<=9;i++)
    	{
    		if(n%i==0&&n/i<=9)
    		{
    			flag=1;
    			break;
    		}
    	}
    	if(flag)cout<<"Yes"<<endl;
    	else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        String N = scanner.next();
        if (N.length() <= K) {
            System.out.println(N);
        } else {
            System.out.println(N.substring(0, K) + "...");
        }
    }
}


Measured memory_bytes: 38352
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<vector>
#include<string>
#include<algorithm>
#include<memory.h>
using namespace std;
typedef long long LL;
const int INF =0x3f3f3f3f;

int main()
{
    char s[10];
    cin >> s;
    int cnt = 0;
    for(int i = 0;i < 6;i++)
    {
        if(s[i] == '1')
        {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,N) for(int i=a;i<N;i++)

using namespace std;

int main() {
	string a;
	cin>>a;
	REP(i,0,19){
		
		if(a[i]==',') {
			cout<<" ";
			continue;
		}
		cout<<a[i];
	}
	/*cout<<" ";
	REP(i,6,13){
		cout<<a[i];
	}
	cout<<" ";
	REP(i,14,19){
		cout<<a[i];
	}*/
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	std::string input;
	while (true) {
		getline(std::cin, input);
		if (input == "0") break;
		int a=0, b=0;
		for (int i=1; i<input.length(); i++) {
			if (input[i] == 'A') a++;
			else b++;
		}
		if (a>b) a++;
		else b++;
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=998244353;
const int N=500000;

ll gcd(ll x,ll y){
    if(x) return gcd(y%x,x);
    else return y;
}

main(){
    int h,w;cin>>h>>w;
    vector<vec> mp(100,vec(100));
    rep(i,h){
        rep(j,w){
            int a=in();
            mp[i][j]+=a;
        }
    }
    rep(i,h)rep(j,w){int a=in();mp[i][j]-=a;}
    vector<vector<vector<bool>>> dp(100,vector<vector<bool>>(100,vector<bool>(30000)));
    ll T=13000;
    rep(i,h){
        rep(j,w){
            int now=mp[i][j];
            if(i==0&&j==0) {
                dp[i][j][now+T]=1;
                dp[i][j][T-now]=1;
            }
            if(i!=0){
                rep(k,30000){
                    if(dp[i-1][j][k]){
                        dp[i][j][k+now]=1;
                        dp[i][j][k-now]=1;
                    }
                }             
            }
            if(j!=0){
                rep(k,30000){
                    if(dp[i][j-1][k]){
                        dp[i][j][k+now]=1;
                        dp[i][j][k-now]=1;
                    }
                }
            }
        }
    }
    int ans=INT_MAX;
    rep(i,30000){
        if(dp[h-1][w-1][i]){
            ans=min(ans,abs((int)(i-T)));
        }
    }
    cout<<ans;
}

Measured memory_bytes: 39868
//  299143BT
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define pi 3.1415926535
#define fi first
#define se second
#define vll vector<ll>
#define vpll vector<pair <ll,ll> >AC
#define vvll vector< vll >
#define str string
#define umap unordered_map
#define uset unordered_set
#define rep(i,n) for(ll i=0;i<n;i++)
#define repA(i,s,n) for(ll i=s;i<=n;i++)
#define repD(i,s,n) for(ll i=s;i>=n;i--)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define elif else if
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ALL(v) v.begin(),v.end()
#define sortA(v) sort(ALL(v))
#define sortD(v) sort(ALL(v),greater <ll> ())
#define print(v) for(auto itr:v) cout<<*itr<<" ";
#define sz size()
#define nl cout<<"\n";
using namespace std;
ll factorial(ll n){return (n==1||n==0)?1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll powerMod(ll x,ll y,ll m){if(y==0)return 1;ll p=powerMod(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll modInverse(ll a,ll m){return powerMod(a,m-2,m);}
ll gcd(ll a,ll b){if(a==0){return b;}else if(b==0){return a;}else{if(a>b){return gcd(a%b,b);}else{return gcd(b%a,a);}}}

void pre(){

}

void solve(){
   ll d=0,t=0,s=0;
   cin>>d>>t>>s;
   if(d<=(t*s)) cout<<"Yes";
   else cout<<"No";
}

int main(){

    pre();
    solve();
    return 0;
}

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

int main() {
	int x[5];
	rep(i,5) cin >> x[i];
	rep(i,5) {
		if (x[i]==0) {
			cout << i+1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3548
import math

x = []
cnt = 0
dis = 0
n, d = map(int, input().split())
for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp)
for k in range(n):
    for i in range(k, n):
        if i == k:
            continue
        dis = 0
        for j in range(d):
            dis += (x[k][j] - x[i][j])**2
        # print(dis)
        dis = math.sqrt(dis)
        if dis.is_integer() == True:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<stdio.h>

#define rep(i,n) for(i=0;i<n;i++)
#define size 100000

int main(){
  int n,s[size],q,t[size];
  int i,j,k;
  int count=0;

  scanf("%d",&n);
  rep(i,n)
    scanf("%d",&s[i]);
  scanf("%d",&q);
  rep(i,q)
    scanf("%d",&t[i]);

  rep(i,q){
    rep(j,n){
      if(s[j]==t[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

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

int main() {
	int N;	// 整数.
	cin >> N;
	int n1 = ((N % 10000) / 1000);
	int n2 = ((N % 1000) / 100);
	int n3 = ((N % 100) / 10);
	int n4 = (N % 10);
	if (n1 == n2 && n2 == n3) {
		cout << "Yes" << endl;
	}
	else if (n2 == n3 && n3 == n4) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  string s;
  cin >> s;
  cout << (count(s.begin(), s.end(), 'g') - count(s.begin(), s.end(), 'p')) / 2 << endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

    int ret = n;
    if (ret == 100) ret = 101;

    if (d == 1) ret *= 100;
    else if (d == 2) ret *= 10000;

    cout << ret << endl;
}

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

int ck(int v1[], int v2[], int n){
    int a=1;;
    for (int i=0; i<n; i++){
        if (v1[i]!=v2[i]){
            a=0;
            break;
        }
    }
    return a;
}
long long a=1,b=1,n,c,d;
string ss,l[100][100];
int main(){
    cin>>n;
    int v1[n];
    int v2[n];
    int v3[n];
    for (int i=0; i<n; i++){
        v3[i]=i+1;
    }
    for (int i=0; i<n; i++){
        cin>>v1[i];
    }
    for (int i=0; i<n; i++){
        cin>>v2[i];
    }
    while(c==0 or d==0){
        if (ck(v1,v3,n)){
            c=-1;
        }
        if (ck(v2,v3,n)){
            d=-1;
        }
        if(c==0){
            a++;
        }
        if (d==0){
            b++;
        }
        next_permutation(v3, v3+n);
    }
    cout<<abs(a-b);
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC170
{
    class A
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();

            for (int i = 0; i < 5; i++)
            {
                if (A[i] == 0) Console.WriteLine(i + 1);
            }

        }
    }
}


Measured memory_bytes: 27892