akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  int a;
  cin >> a;
  if(a==1){
    cout << 3 << endl;
    return 0;
  }
  int ans = a*a*a*a;
  cout << (ans-1)/(a-1)-1 << endl;
  
  return 0;
}


Measured memory_bytes: 3576
N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N

for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())

tm = 0 
t_x = 0 
t_y = 0 
ans = "Yes"

for i in range(N):
        if abs(t_x - x[i]) + abs(t_y - y[i]) <= t[i] - tm and ((t[i] % 2 == 0) == ((x[i] + y[i]) % 2 == 0)):
                pass
        else:
                ans = "No"

        t_x = x[i]
        t_y = y[i]
        tm = t[i]

print(ans)

Measured memory_bytes: 11636
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n = arr.shift() - 0;
var a = 0;
for (var i = 0; i < n; i++) {
   (arr[i] == "A") ? a++ : a--;
   if (a < 0) break;
}
console.log((a == 0) ? "YES" : "NO");

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

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> vec(N);
  rep(i, N){
    cin >> vec.at(i);
  }
  
  int j = 0;
  
  rep(i, N){
    if(K <= vec.at(i)){
      j++;
    }
  }
  cout << j << endl;
}

Measured memory_bytes: 768
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

min_eight_ex_tax = float(A / 0.08)
max_eight_ex_tax = float((A + 1) / 0.08)
min_ten_ex_tax = int(B / 0.1)
max_ten_ex_tax = int((B + 1) / 0.1)

res = float(-1)
for x in range(min_ten_ex_tax, max_ten_ex_tax, 1):
    if min_eight_ex_tax <= x < max_eight_ex_tax:
        res = float(x)
        break
#print(min_eight_ex_tax, max_eight_ex_tax, min_ten_ex_tax, max_ten_ex_tax)
print(int(res))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;



void Main(){
  ll X, N, M, ans = -100;

  cin >> X >> N;

  vector<bool> x(101, true);

  rep(i, N){
    ll p;
    cin >> p;
    x[p] = false;
  }

  rep(i, 100){
    M = X - i;
    if(M >= 0 && x[M]){
      ans = M;
      break;
    }

    M = X + i;
    if(M >= 0 && x[M]){
      ans = M;
      break;
    }
  }

  cout << ans << endl;



}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3652
/*
16:30
 */
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<vector>
#include<cassert>
#include<climits>
#include<map>
#include<sstream>
#include<set>
#include<cstdlib>

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

using namespace std;

struct Tree{
  int depth;// root -> -1
  string key,str;
  Tree* parent;
  vector<Tree*> children;
  Tree(int depth=IINF):depth(depth){}
};


vector<string> input;
vector<int> depth;

pair<string,string> divide(string line){
  string a = "",b = "";
  int sp = -1;
  bool coron = false;
  rep(i,line.size()){
    if(sp == -1 && line[i] != ' '){
      sp = i;
    }
    if(line[i] == ':'){
      a = line.substr(sp,i-sp);
      coron = true;
      sp = i + 2;
    }
    if(coron && i >= sp){
      b += line[i];
    }
  }
  return pair<string,string>(a,b);
}

void makeTree(Tree *tree){
  tree->depth = -1;
  rep(i,input.size()){
    while((tree->depth) >= depth[i]){
      tree = tree->parent;
    }
    pair<string,string> tmp = divide(input[i]);
    //cout << "input[" << i << "] = "  << input[i] << endl;
    //cout << "divide = (" << tmp.first << "," << tmp.second << ")" << endl;
    Tree* child = new Tree;
    child->depth = depth[i];
    child->parent = tree;
    child->key = tmp.first;
    child->str = tmp.second;
    (tree->children).push_back(child);
    tree = child;
  }
  while((tree->depth) != -1){
    tree = tree->parent;
  }
}

void Answer(vector<string> query,Tree* tree){
  bool not_found = false;
  rep(i,query.size()){
    bool found = false;
    rep(j,tree->children.size()){
      if(tree->children[j]->key == query[i]){
	tree = tree->children[j];
	found = true;
	break;
      }
    }
    if(!found){
      cout << "no such property" << endl;
      return;
    }
  }
  if(tree->str.empty()){
    cout << "object" << endl;
  } else {
    cout << "string \"" << (tree->str) << "\"" << endl;
  }
}
/*
void tree_walk(Tree *t,int depth)
{
  cout << "cur : " <<  (t->key) << " depth = " << (t->depth) << endl; 
  rep(i,t->children.size()){
    cout << "( " << (t->children[i]->key) << "," << (t->children[i]->str) << " )" << endl;
  }
  rep(i,t->children.size()){
    tree_walk(t->children[i],depth+1);
  }
}
*/
int main(){
  string query;
  getline(cin,query);
  rep(i,query.size()){
    if(query[i] == '.')query[i] = ' ';
  }
  stringstream ss;
  ss << query;
  vector<string> squery;
  while(!(ss >> query).fail()){
    squery.push_back(query);
  }

  string line;
  while(getline(cin,line)){
    input.push_back(line);
    int cnt = 0, index = input.size()-1;
    rep(i,input[index].size()){
      if(input[index][i] != ' '){ 
	break;
      }
      cnt++;
    }
    depth.push_back(cnt);
  }

  Tree tree;
  makeTree(&tree);
  //tree_walk(&tree,0);
  Answer(squery,&tree);

  return 0;
}

Measured memory_bytes: 1420
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
const int MX=5e5+7;
const int mod=1e9+7;
const double pi=3.1415926535897932384;
double isp=1e-13;
using namespace std;
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}
ll __gcm(ll a,ll b){return a*b/__gcd(a,b);}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
void add(ll &x,ll y){x=(x+y)%mod;}
ll p[MX];
ll C(ll n,ll m)
{
    return p[n]*inv(p[m]*p[n-m]%mod)%mod;
}
void solve()
{
    int n,m;
    cin>>n>>m;
    p[0]=1;
    for(int i=1;i<=max(n,m);i++)
    {
        p[i]=p[i-1]*i%mod;
    }
    ll ans=p[n]*C(m,n)%mod;
    int op=1;
    for(int i=1;i<=n;i++)
    {
        op*=-1;
        (ans+=op*p[n-i]*C(m-i,n-i)%mod*C(n,i)%mod+mod)%=mod;
    }
    cout<<p[n]*C(m,n)%mod*ans%mod<<endl;//sum=ans*(ans-res)
}
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  solve();
}


Measured memory_bytes: 7540
import java.util.*;

class Main {
	Scanner sc;
	int N;
	int[] X;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		X = new int[N];
		for (int i = 0; i < N; i++) X[i] = sc.nextInt();
		
		int m = Integer.MAX_VALUE;
		for (int p = 1; p < 101; p++) {
			int s = 0;
			for (int i = 0; i < N; i++)
				s += (X[i]-p)*(X[i]-p);
			m = Math.min(m, s);
		}
		System.out.println(m);
	}

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


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i+1];
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if ((i % 2 != 0) && (a[i] % 2 != 0)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
from sys import stdin
import queue

H, W = [int(x) for x in stdin.readline().rstrip().split()]
maze = [stdin.readline().rstrip().split()[0] for _ in range(H)]

ans = 0

for h in range(H):
    for w in range(W):
        if maze[h][w] == '#':
            continue
        else:
            q = queue.Queue()
            q.put((h, w, 0))
            visited = [[0] * W for _ in range(H)]
            visited[h][w] = 1
            while q.qsize() > 0:
                temp = q.get()
                temp_h = temp[0]
                temp_w = temp[1]
                temp_d = temp[2]
                ans = max(ans, temp_d)
                if temp_h + 1 < H and maze[temp_h + 1][temp_w] == '.' and visited[temp_h + 1][temp_w] == 0:
                    visited[temp_h + 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h + 1, temp_w, temp_d + 1))
                if temp_h - 1 >= 0 and maze[temp_h - 1][temp_w] == '.' and visited[temp_h - 1][temp_w] == 0:
                    visited[temp_h - 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h - 1, temp_w, temp_d + 1))
                if temp_w + 1 < W and maze[temp_h][temp_w + 1] == '.' and visited[temp_h][temp_w + 1] == 0:
                    visited[temp_h][temp_w + 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w + 1, temp_d + 1))
                if temp_w - 1 >= 0 and maze[temp_h][temp_w - 1] == '.' and visited[temp_h][temp_w - 1] == 0:
                    visited[temp_h][temp_w - 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w - 1, temp_d + 1))

print(ans)

Measured memory_bytes: 111464
function Main(input){
var an = input.split("\n");
var k = an[5];
an.pop();
for(i=0;i<=4;i++){
  an[i] = parseInt(an[i],10);
}
for(j=0;j<=4;j++){
  for(s=0;s<=4;s++){
    if(j<=s){
      continue;
    }else{
      var dist = Math.abs(an[j] - an[s]);
      var judge = dist <= k;// true or false
      if(judge==false){
        console.log(":(");
        break;
      }
      if(judge==true&&j==4&&s==3){
        console.log("Yay!");
      }
    }
  }
  if(judge==false){
    break;
  }
}
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7496
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
#include <cassert>
#include <cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef long long ll;
typedef string::const_iterator State;
int N;
ll inf=2e18;
string op="*+-&^|",nums="0123456789";
map<ll,ll> mp;
ll exp(State &be);
ll num(State &be){
	ll ret=0;
	while(isdigit(*be)){
		ret*=10;
		ret+=*be-'0';
		be++;
	}
	return ret;
}
ll factor(State &be){
	if(*be=='('){
		be++;
		ll ret=exp(be);
		be++;
		return ret;
	}else{
		return num(be);
	}
}
ll a3(State &be){
	ll ret=factor(be);
	while(true){
		if(*be=='*'){
			be++;
			ret*=factor(be);
		}else{
			break;
		}
	}
	return ret;
}
ll a2(State &be){
	ll ret=a3(be);
	while(true){
		if(*be=='+'){
			be++;
			ret+=a3(be);
		}else if(*be=='-'){
			be++;
			ret-=a3(be);
		}else{
			break;
		}
	}
	return ret;
}
ll a1(State &be){
	ll ret=a2(be);
	while(true){
		if(*be=='&'){
			be++;
			ret&=a2(be);
		}else{
			break;
		}
	}
	return ret;
}
ll a0(State &be){
	ll ret=a1(be);
	while(true){
		if(*be=='^'){
			be++;
			ret^=a1(be);
		}else{
			break;
		}
	}
	return ret;
}
ll exp(State &be){
	ll ret=a0(be);
	while(true){
		if(*be=='|'){
			be++;
			ret|=a0(be);
		}else{
			break;
		}
	}
	return ret;
}
ll hhash(string s,int k){
	ll ret=0;
	rep(i,s.size()){
		ret*=93;
		ret+=s[i];
	}
	ret*=15;
	ret+=k;
	return ret;
}
int n;
ll dfs(string s,int k){
	ll tmp=hhash(s,k);
	if(mp.count(tmp)) return mp[tmp];
	if(k==N){
//		show(s);
		State be=s.begin();
		return exp(be);
	}
	ll ret=inf;
	if(k%2==0) ret=-inf;
	rep(i,s.size()){
		bool ok=false;
		if(isdigit(s[i])){
			if( i-1>=0&&isdigit(s[i-1]) ) ok=true;
			else if( i+1<s.size()&&isdigit(s[i+1])&&s[i+1]!='0') ok=true;
		}else if(s[i]!='('&&s[i]!=')'){
			if(isdigit(s[i-1])&&isdigit(s[i+1])) ok=true;
		}
		if(!ok) continue;
		string ns=s;
		ns.erase(i,1);
		ll val=dfs(ns,k+1);
		if(k%2) ret=min(ret,val);
		else ret=max(ret,val);
	}
	rep(i,s.size()+1){
		bool ok=false,ok0=false;
		if( i-1>=0&&isdigit(s[i-1]) ) ok0=true,ok=true;
		else if( i<s.size()&&isdigit(s[i]) ) ok=true;
		if(ok){
			rep(j,10){
				if(j==0&&!ok0) continue;
				string ns=s.substr(0,i)+nums[j]+s.substr(i);
				ll val=dfs(ns,k+1);
				if(k%2) ret=min(ret,val);
				else ret=max(ret,val);
			}
		}
		if(i>0&&i<s.size()&&isdigit(s[i-1])&&isdigit(s[i])&&s[i]!='0'){
			rep(j,6){
				string ns=s.substr(0,i)+op[j]+s.substr(i);
				ll val=dfs(ns,k+1);
				if(k%2) ret=min(ret,val);
				else ret=max(ret,val);
			}
		}
	}
	assert(ret!=inf&&ret!=-inf);
	return mp[hhash(s,k)]=ret;
}
int main(){
	while(true){
		string s;
		cin>>N>>s;
		if(N==0) break;
		if(N%2) N=1;
		else N=2;
		n=s.size();
		mp.clear();
		cout<<dfs(s,0)<<endl;
	}
}

Measured memory_bytes: 1236
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	k := getNextInt(scanner)
	n := getNextInt(scanner)
	aa := make([]int, n)
	ans := 0
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	sort.Ints(aa)
	for i := 1; i < n; i++ {
		if ans < aa[i]-aa[i-1] {
			ans = aa[i] - aa[i-1]
		}
	}

	if ans < aa[0]+k-aa[n-1] {
		ans = aa[0] + k - aa[n-1]
	}

	fmt.Fprintln(writer, k-ans)
}


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

#define INF int(1e9)

int n, m, ans;
int c[21], memo[50001];

int solve(int v) {
    if (v < 0) return INF;
    if (v == 0) return 0;
    if (memo[v] != INF) return memo[v];

    int ret = INF;

    for (int i = 0; i < m; ++i) {
        ret = min(ret, solve(v - c[i]) + 1);
    }

    return memo[v] = ret;
}

int main() {
    fill(memo, memo + 50001, INF);
    
    cin >> n >> m;
    for (int i = 0; i < m; ++i) cin >> c[i];

    ans = solve(n);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> R(n,0),G(n,0),B(n,0);
    rep(i,n){
        for(int j=i+1;j<n;j++){
            if(s[j] =='R') R[i] ++;
            else if(s[j] =='G') G[i] ++;
            else B[i] ++;
        }
    }
    ll ans = 0;
    rep(i,n){
        char L = s[i];
        for(int j =i+1;j<n;j++){
            char C = s[j];
            if(L==C) continue;
            if((L == 'R' && C =='G')||(L == 'G' && C =='R')){
                if(j + j-i < n){
                    if(s[j+j-i] =='B') ans += B[j]-1;
                    else ans += B[j];
                }
                else ans += B[j];
            }else if((L == 'B' && C =='G')||(L == 'G' && C =='B')){
                if(j + j-i < n){
                    if(s[j+j-i] =='R') ans += R[j]-1;
                    else ans += R[j];
                }
                else ans += R[j];
            }else if((L == 'R' && C =='B')||(L == 'B' && C =='R')){
                if(j + j-i < n){
                    if(s[j+j-i] =='G') ans += G[j]-1;
                    else ans += G[j];
                }
                else ans += G[j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q,ans;
ll x[500005],y[500005],z[500005];
ll dp[3005][3005];
char s[500005],t[500005];
bool flag,dame;

int main(){
    cin >> a >> b >> c >> d;
	p((a - c) * (b - d));

	return 0;
}

Measured memory_bytes: 24960
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define all(cont) cont.begin(), cont.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<int, pair<int, int>> pipii;
 
const int INF = 1e9+1;
const int MAX_N = 1e5+1;
const int mod = 1000000007;
 
const double PI = acos(-1);
const double halfC = PI / 180;


ll dp[101][MAX_N];
void solve(){
	int n, w;
	cin >> n >> w;
	
	ll wgt[n+1];
	ll val[n+1];
	for(int i = 0; i < n; ++i){
		cin >> wgt[i] >> val[i];
	}
	
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= w; ++j){
			if(i == 0 || j == 0) continue;
			if(wgt[i-1] <= j){
				dp[i][j] = max(val[i-1] + dp[i-1][j-wgt[i-1]], dp[i-1][j]);
			} else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	
	cout << dp[n][w];
	
}
 
int main(){
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int i = 1, t = 1;
	//cin >> t;
	while(i <= t){
		//cout << "CASE #" << i << ": ";
		solve();
		i++;
	}	
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>

using namespace std;

int main(){
    int N,M,X,Y;
    cin >> N;
    cin >> M;
    cin >> X;
    cin >> Y;
    int x[N],y[M];
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    for(int j = 0; j < M; j++){
        cin >> y[j];
    }
    int maxx = -100;
    for(int i = 0; i < N; i++){
        if(maxx < x[i]){
            maxx = x[i];
        }
    }
    int miny = 100;
    for(int j = 0; j < M; j++){
        if(miny > y[j]){
            miny = y[j];
        }
    }
    for(int k = X+1; k <= Y; k++){
        if(maxx < k && miny >= k){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000005
vector<int>g[M];
int sz[M],w[M],sk[M],mx[M],id[1005][1005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)id[i][j]=(i-1)*n+j;
	for(int i=1;i<=n;++i){
		for(int j=1;j<n;++j)scanf("%d",&w[j]);
		for(int j=2;j<n;++j){
			int a=i,b=w[j],c=i,d=w[j-1];
			if(a>b)swap(a,b);
			if(c>d)swap(c,d);
			g[id[a][b]].push_back(id[c][d]);
			sz[id[c][d]]++;
		}
	}int l=1,r=0,ans=1;
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if(!sz[id[i][j]]){
				sk[++r]=id[i][j];
				mx[id[i][j]]=1;
			}
	while(l<=r){
		int p=sk[l++];
		ans=max(ans,mx[p]);
		for(int i=0;i<(int)g[p].size();++i){
			int v=g[p][i];
			mx[v]=max(mx[v],mx[p]+1);
			sz[v]--;if(sz[v]==0)sk[++r]=v;
		}
	}
	if(r!=n*(n-1)/2)puts("-1");
	else printf("%d",ans);
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i = 0;i < h;i++){
    cin >> s[i];
  }
  vector< vector<int> > hor(h,vector<int>(w));
  for(int i = 0;i < h;i++){
    vector<int> rock;
    for(int j = 0;j < w;j++){
      if(s[i][j] == '#'){
        rock.push_back(j);
      }
    }
    rock.push_back(w);
    int cur = 0;
    for(int j = 0;j < w;j++){
      if(j == rock[cur])cur++;
      else{
        int prev = 0;
        if(cur)prev = rock[cur-1]+1;
        hor[i][j] = rock[cur] - prev;
      }
    }
  }
  int ret = 0;
  for(int j = 0;j < w;j++){
    vector<int> rock;
    for(int i = 0;i < h;i++){
      if(s[i][j] == '#'){
        rock.push_back(i);
      }
    }
    rock.push_back(h);
    int cur = 0;
    for(int i = 0;i < h;i++){
      if(i == rock[cur])cur++;
      else{
        int prev = 0;
        if(cur)prev = rock[cur-1]+1;
        ret = max(ret,hor[i][j]+rock[cur] - prev - 1);
      }
    }
  }
  cout << ret << endl;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
typedef unsigned long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;

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

int main() {
    ll n, x;
    cin >> n >> x;
    ll TotalLength = n - x;
    ll TriangleLength = x;
    ll quo;
    ll res = 0;
    while (true) {
        if (TriangleLength == 0) {
            cout << res << endl;
            return 0;
        }
        quo = TotalLength / TriangleLength;
        res += 3 * quo * TriangleLength;
        ll temp = TotalLength;
        TotalLength = TriangleLength;
        TriangleLength = temp % TriangleLength;
    }
}


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

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long mod = 1000000007;
long long N, K, dp[100009];

int main() {
	cin >> N >> K;
	for (int i = K; i >= 1; i--) {
		dp[i] = modpow((K / i), N, mod);
		for (int j = i * 2; j <= K; j += i) { dp[i] -= dp[j]; dp[i] += mod; dp[i] %= mod; }
	}
	long long ans = 0;
	for (int i = 1; i <= K; i++) ans += 1LL * i * dp[i] % mod;
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n,m,l;
    cin>>n>>m>>l;
    long a[n][m];
    long  b[m][l];
    for(long i=0;i<n;i++){
        for(long j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(long i=0;i<m;i++){
        for(long j=0;j<l;j++){
            cin>>b[i][j];
        }
    }
    long c[n][l];
    long h=0;
    for(long i=0;i<n;i++){
        for(long j=0;j<l;j++){
            h=0;
            for(long k=0;k<m;k++){
                h+=a[i][k]*b[k][j];
            }
            c[i][j]=h;
        }
    }
    for(long i=0;i<n;i++){
        for(long j=0;j<l;j++){
            if(j==0){
                cout<<c[i][j];
            }
            else{
                cout<<' '<<c[i][j];
            }
        }
        cout<<endl;
    }
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST(N)

B = [0] * N
for i, a in enumerate(A):
    B[a-1] = i

mx = cnt = 1
for i in range(N-1):
    if B[i] < B[i+1]:
        cnt += 1
    else:
        cnt = 1
    mx = max(mx, cnt)
print(N - mx)


Measured memory_bytes: 19000
alice = [False for _ in range(100)]
bob = [False for _ in range(100)]

a,b,c,d = map(int,input().split(" "))
for i in range(a,b):
    alice[i] = True

for i in range(c,d):
    bob[i] = True

count = 0
for i in range(100):
    if alice[i] and bob[i]:
        count += 1

print(count)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();
        if(b - a + c < 0){
            System.out.println(0);
        }else{
            System.out.println( - a + b + c);
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
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; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n ;
    cin >>n ;
    vint num(n) ;
    REP(i,n){
        cin >> num[i] ;
    }
    sort(ALL(num)) ;

    cout << abs(num[0]- num[n-1]) <<endl ;

    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    loop {
        let (h, w) = input();
        if (h, w) == (0, 0) {
            break;
        }

        for i in 0..h {
            for j in 0..w {
                let s = if i == 0 || i == h - 1 || j == 0 || j == w - 1 {
                    "#"
                } else {
                    "."
                };
                print!("{}", s);
            }
            println!("");
        }
        println!("");
    }
}

fn input() -> (i32, i32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();

    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();

    (a, b)
}



Measured memory_bytes: 5024
#include<iostream>
using namespace std;
int main(){
long l,m,n,s,i,ii,f;
while(cin>>l){
if(l==0)break;
for(s=ii=f=0,i=0;i<12;i++){
cin>>m>>n;
s+=m-n;
if(f==0&&s>=l){ii=i+1;f=1;}
}
if(ii==0)cout<<"NA"<<endl;
else cout<<ii<<endl;
}
return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    ab = [A,B]
    if 1 not in ab:
        print(1)
    elif 2 not in ab:
        print(2)
    elif 3 not in ab:
        print(3)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
deque <int> d;
void solve () {
	int n, k;
	cin >> n >> k;	
	if (k > (1 << n) - 1) {
		cout << -1;
		return;
	}	
	if (k == 0) {
		int x = 0;
		for (int i = 1; i <= (1 << n); i ++) {
			cout << x << " " ;
			x ++;
		}
		x = (1 << n) - 1;
		for (int i = 1; i <= (1 << n); i ++) {
			cout << x << " ";
			x --;
		}
		return;
	}                
	if (n == 1) {
		cout << -1;
		return;
	}	
	d.pb (0);
	d.pb (k);
	d.pb (0);
	for (int i = 1; i <= (1 << n) - 1; i ++) {
		if (i != k) {
			d.pb (i);
			d.pf (i);
		}           
	}
	d.pb (k);
	for (int i = 0; i < sz (d); i ++) cout << d[i] << " ";
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}	

Measured memory_bytes: 2944
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        sx: isize,
        sy: isize,
        tx: isize,
        ty: isize,
    }

    let dx = (tx - sx).abs();
    let dy = (ty - sy).abs();

    for _ in 0..dx {
        print!("{}", 'R');
    }
    for _ in 0..dy {
        print!("{}", 'U');
    }
    for _ in 0..dx {
        print!("{}", 'L');
    }
    for _ in 0..dy + 1 {
        print!("{}", 'D');
    }
    for _ in 0..dx + 1 {
        print!("{}", 'R');
    }
    for _ in 0..dy + 1 {
        print!("{}", 'U');
    }
    print!("{}", "LU");
    for _ in 0..dx + 1 {
        print!("{}", 'L');
    }
    for _ in 0..dy + 1 {
        print!("{}", 'D');
    }
    println!("{}", 'R');
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
    char ch; int sign = 1;
    while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
    n = ch - '0';
    while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
    n *= sign;
}
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
int a, b, c, x, y;

int main(){
    read(a), read(b), read(c), read(x), read(y);
    int ans = 0;
    if (2 * c <= a + b){
        int t = min(x, y);
        ans += t * 2 * c;
        x -= t, y -= t;
    }
    ans += min(a * x + b * y, max(x, y) * 2 * c);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    ll gezan_fix = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        gezan_fix += max(0, b[i] - a[i]);
    }
    vector<int> I(n);
    iota(I.begin(), I.end(), 0);
    sort(I.begin(), I.end(), [&](int i, int j) {
        return b[i] > b[j];
    });
    ll ans = 0;
    for(int i : I) {
        if(a[i] < b[i]) {
            ans += b[i];
        } else if(a[i] - b[i] < gezan_fix) {
            gezan_fix -= (a[i] - b[i]);
            ans += b[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) { cout << "a > b" << endl; }
	else if (a == b) { cout << "a == b" << endl; }
	else { cout << "a < b" << endl; }
}


Measured memory_bytes: 3084
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string S;
int main(){
    cin>>S;
    ll ans=INF;
    for(ll i=0;i<S.length();i++){
        if(S[i]!=S[i+1]){
            ans=min(ans,max(i+1,(ll)S.length()-(i+1)));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;

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

const int MAXN = 1e5 + 1;

int x;

int main(){

    cin >> x;
    cout << !x;

    return 0;

}


Measured memory_bytes: 3628
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  for(i<-1 to readInt) {
    val x = readLine.split(" ") map { _.toDouble }
    val p = (x(2)-x(0))*(x(7)-x(5)) - (x(6)-x(4))*(x(3)-x(1))
    if(p< 1e-10 && p > -(1e-10)) println("YES") else println("NO")
  }
}

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

int main(){
  int k;
  vector<int> vec(5);
  for(int i=0;i<5;i++){
    cin >> vec[i];
  }
  cin >> k;
  if(vec[4]-vec[0]>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e5 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, m, a[88][88], b[88][88];
bool dp[88][88][13333];

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));

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

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);
        
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			scanf("%d", &b[i][j]);

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) {
			if(i == 1 && j == 1) {
				dp[1][1][abs(a[i][j] - b[i][j])] = 1;
				continue;
			}

			for(int k = 0; k <= 12000; k++) {
				if(dp[i - 1][j][k]) {
					int x = abs(a[i][j] - b[i][j]);
					dp[i][j][abs(k - x)] = 1;
					if(k + x <= 12000) dp[i][j][k + x] = 1;
				}
				if(dp[i][j - 1][k]) {
					int x = abs(a[i][j] - b[i][j]);
					dp[i][j][abs(k - x)] = 1;
					if(k + x <= 12000) dp[i][j][k + x] = 1;
				}
			}
		}				

	for(int i = 0; i <= 12000; i++)
		if(dp[n][m][i]) return cout << i, 0;

    return 0;                                        
}

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

int N, a[105];

signed main(){
  
  cin>>N;
  
  double ave = 0;
  
  for(int i=0;i<N;i++){
    cin>>a[i];
    ave += a[i];
  }
  
  ave /= N;
  
  double minv = 10000000;
  int idx = 0;
  
  for(int i=N-1;i>=0;i--){
    
    if( minv >= abs( ave - a[i] ) ){
      minv = abs( ave - a[i] );
      idx = i;
    }
    
  }
  
  cout<<idx<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int Prime(int);

int main(){
  int n,i,x,num = 0;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&x);
    if(Prime(x)){
      ++num;
    }
  }
  printf("%d\n",num);
  return 0;
}

int Prime(int x){
  int i;
  if(x < 2){ return 0; }
  for(i = 2 ; i*i <= x ; i++){
    if(x % i == 0){ return 0; }
  }
  return 1;
}



Measured memory_bytes: 2072
<?php 
list($A,$B,$C) = sscanf(fgets(STDIN),"%d %d %d");
if(($A == $C)&&($A != $B)){
    printf("Yes");
    exit;
}
if(($A == $B)&&($A != $C)){
    printf("Yes");
    exit;
}
if(($C == $B)&&($A != $C)){
    printf("Yes");
    exit;
}
printf("No");

Measured memory_bytes: 3828
S = input()
B = False
for i in range(0, len(S)):
    if i % 2 == 0 and S[i] == "L":
        break
    elif i % 2 != 0 and S[i] == "R":
        break
else:
    B = True
if(B):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n;
	cin >> n;
	if(n<105){
		cout << 0 << endl;
	} else if(105<=n && n<135){
		cout << 1 << endl;
	} else if(135<=n && n<165){
		cout << 2 << endl;
	} else if(165<=n && n<189){
		cout << 3 << endl;
	} else if(189<=n && n<195){
		cout << 4 << endl;
	} else {
		cout << 5 << endl;
	}
	
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

const int MOD = 1e9+7;

int a[1005][1005],d[1005][1005];
int h,w,sx,sy,ex,ey;
int dx[4]= {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(d,0x3f3f3f3f,sizeof(d));
	cin >> h >> w >> sx >> sy >> ex >> ey;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c=='#') a[i][j]=1;
		}
	}
	sx--,sy--,ex--,ey--;
	deque<PII> q;
	q.push_back(mp(sx,sy));
	d[sx][sy]=0;
	while (!q.empty()) {
		PII cur = q.front();
		q.pop_front();
		for (int i = 0; i < 4; i++) {
			int nx = cur.fi+dx[i];
			int ny = cur.se+dy[i];
			if (nx<0||ny<0||nx>=h||ny>=w||a[nx][ny]) continue;
			if (d[nx][ny]>d[cur.fi][cur.se]) {
				d[nx][ny]=d[cur.fi][cur.se];
				q.push_front(mp(nx,ny));
			}
		}
		for (int i = cur.fi-2; i<= cur.fi+2; ++i) {
			for (int j = cur.se-2; j<=cur.se+2; ++j) {
				if (i<0||j<0||i>=h||j>=w||a[i][j]) continue;
				if (d[i][j]>d[cur.fi][cur.se]+1) {
					d[i][j]=d[cur.fi][cur.se]+1;
					q.push_back(mp(i,j));
				}
			}
		}
	}

	cout << (d[ex][ey]>1e7?-1:d[ex][ey]) << "\n";
}

Measured memory_bytes: 11592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int a,b,c,d;
    cin >> a >> b>> c>> d;
    string no = "No";
    string yes = "Yes";
    if (abs(c-a) <= d){
        cout << yes << endl;
        return  0;
    }
    if (abs(b-a) <= d & abs(c-b) <= d){
        cout << yes << endl;
        return  0; 
    }

    cout << no << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

typedef long long ll;
const ll N=100;
ll a[N];
int main()
{
	ll n;
	ll sum=1000;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;){
//		cout<<"&&"<<endl;
		bool flag=0;
//		cout<<i<<endl;
		int j;
		if(a[i]>=a[i+1]&&i+1<=n){
			while(a[i]>=a[i+1]&&i+1<=n){
				i+=1;
			}
			continue;
		}
		for(j=i+1;j<=n;j++){
			if(a[j]>=a[j-1]){
				flag=1;
			}
			else break;
		}
//		cout<<flag<<endl;
		if(flag){
			sum=sum%a[i]+sum/a[i]*a[j-1];
			i=j;
		} 
		else break;
//		cout<<sum<<endl;
//		cout<<i<<endl; 
	}
	printf("%lld\n",sum);
	return 0;
}

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

main(){
  long long ans,i,n;
  cin >> n;
  ans=n+1;
  
  for(i=1;i<=sqrt(n);i++){
    if(n%i==0 && i+n/i-2 < ans ) ans = i+n/i-2;
  } 
  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(map(int,input().split()))
    BC = [list(map(int,input().split())) for _ in range(m)]

    BC = sorted(BC,key=lambda x:(x[1]),reverse=True)
    append_list = []
    for b,c in BC:
        if len(append_list)>=n:
            break
        append_list+=[c]*b
    A+=append_list
    A.sort(reverse=True)
    print(sum(A[:n]))

if __name__=='__main__':
    main()

Measured memory_bytes: 35284
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct fck
{
	string c;int v,id;
	bool operator<(const fck&x)const
	{
		return c==x.c?(v>x.v):c<x.c;
	}
}a[101];
int main()
{
	int n,i;cin>>n;
	for (i=1;i<=n;i++) cin>>a[i].c,cin>>a[i].v,a[i].id=i;
	sort(a+1,a+n+1);for (i=1;i<=n;i++) cout<<a[i].id<<endl;
	
}


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

int e[200005], l[200005];

int main()
{
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    int cnt = 1;
    for (int i = 0; i < n; ) {
        if (s[i] == 'o') {
            e[i] = cnt++;
            i += c + 1;
        }
        else i++;
        if (cnt > k) break;
    }
    cnt = k;
    for (int i = n - 1; i >= 0; ) {
        if (s[i] == 'o') {
            l[i] = k--;
            i -= c + 1;
        }
        else i--;
        if (k < 1) break;
    }
    for (int i = 0; i < n; i++) {
        if (e[i] && e[i] == l[i]) {
            cout << i + 1 << endl;
        }
    }
}


Measured memory_bytes: 3332
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l=sc.nextInt();
        if(l%3==0){
            double res=(l/3)*(l/3)*(l/3);
            System.out.println(res);
            return;
        }

        double max=(double)l/3;
        System.out.println(max*max*max);

    }
}

Measured memory_bytes: 20820
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int sum = 0;
        
        for(int i=a; i<=b; i++ ){
            if(c % i == 0){
                sum++;
            }
        }
        System.out.println(sum);
    }
}



Measured memory_bytes: 26176
N=input()

A = list(map(int, input().split()))

Rate = []
for i in range(9):
    Rate.append(0)

for i in A:
    index=i//400
    if index > 8:
        index = 8
    Rate[index] = Rate[index] + 1

a = 0

for i in range(8):
    if Rate[i] > 0:
        a=a+1

Max = a + Rate[8]
Min = max(a, 1)

print(Min, Max)



Measured memory_bytes: 3060