akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array
import Text.Printf

main :: IO ()
main = do
  n <- getl toInt
  solve n 1

solve :: Int -> Int -> IO ()
solve n i = do
  when (i <= n) $ do
    getLine
    ss <- replicateM 8 getLine
    x <- getl toInt
    y <- getl toInt
    printf "Data %d:\n" i
    mapM_ putStrLn $ bomb ss (y, x)
    solve n (i + 1)

bomb :: [String] -> (Int, Int) -> [String]
bomb ss (y, x) = split8 $ elems $ f fld (y, x)
  where
    fld = listArray ((1,1),(8,8)) $ concat ss
    f arr (i,j)
      | arr ! (i,j) == '0' = arr
      | otherwise = foldl f (arr // [((i,j),'0')]) ps
      where
        ps = [(ii,jj)|(ii,jj) <- [(i+1,j),(i+2,j),(i+3,j),(i-1,j),(i-2,j),(i-3,j),(i,j+1),(i,j+2),(i,j+3),(i,j-1),(i,j-2),(i,j-3)], ii >= 1, ii <= 8, jj >= 1, jj <= 8]
    split8 xs
      | null xs = []
      | otherwise  = take 8 xs : split8 (drop 8 xs)

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  int a,b,k;cin>>a>>b>>k;
  set<int> st;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0 && b % i == 0){
      k--;
      if(k==0){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

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

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, K, Q;
    cin >> N >> K >> Q;
    vec<lint> times_won(N);
    range(i, 0, Q) {
        lint answerer;
        cin >> answerer; answerer--;
        times_won.at(answerer) += 1;
    }
    // cout << times_won << "\n";
    range(i, 0, N) {
        cout << (K - Q + times_won.at(i) > 0 ? "Yes" : "No") << "\n";
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(int argc, const char * argv[]) {
    
    
    
    int k,x; cin >> k >> x;
    
    int start = max(-1000000,x-k+1);
    int end   = min( 1000000,x+k-1);
    
    for (int i = start; i <= end; i++) {
        cout << i;
        if(i<end) cout << " ";
        else if(i==end) cout << endl;
    }
    
    
    

    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		final String s = sc.nextLine();
		final String[] split = s.split("/");
		
		final int y = Integer.parseInt(split[0]);
		final int m = Integer.parseInt(split[1]);
		final int d = Integer.parseInt(split[2]);
		
		if (y < 2019) {
			System.out.println("Heisei");
		} else if (y > 2019) {
			System.out.println("TBD");
		} else {
			if (m <= 4) {
				System.out.println("Heisei");
			} else {
				System.out.println("TBD");
			}
		}
	}

}

Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		if(X == 7 || X == 5 || X == 3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22736
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


string s;
i64 k;

int main(){
	cin >> s >> k;
	int n = s.size();
	if(n == 1){
		cout << k/2 << endl;
		return 0;
	}
	bool b = 0;
	for(int i = 0; i < n-1; i++){
		if(s[i] != s[i+1]) b = 1;
	}
	if(!b){
		cout << n*k/2 << endl;
		return 0;
	}
	string t =s+s;
	i64 cnt = 0;
	for(int i = 0; i < n; i++){
		i64 c = 0;
		for(;i < n; i++){
			c++;
			if(t[i] != t[i+1]) break;
		}
		cnt += c/2 * k;
		if(i == n && c%2){
			c = 0;
			for(int j = 0; j < n; j++){
				if(t[n-1] != t[j]) break;
				c++;
			}
			if(c%2) cnt += k-1;
		}
	}
	//aaaabaaaaaba
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)


def set_calc(left, right, ope):
    return set(ope(l, r) for l in left for r in right)


def div(left, right):
    res = set()
    for l in left:
        for r in right:
            if r == 0:
                continue
            if l == 0:
                res.add(0)
                continue
            res.add(abs(l) // abs(r) * ((l * r) // abs(l * r)))
    return res


O = {'+': lambda l, r: set_calc(l, r, lambda l, r: l + r),
     '-': lambda l, r: set_calc(l, r, lambda l, r: l - r),
     '*': lambda l, r: set_calc(l, r, lambda l, r: l * r),
     '/': lambda l, r: div(l, r)}


class Source():
    def __init__(self, S, i=0):
        self.S = S
        self.pos = i


def peek(S):
    return S.S[S.pos] if S.pos < len(S.S) else 'a'


def next(S):
    S.pos += 1


def concreate(left, m, right, i, j):
    return set(Source(l.S[:i] + m + r.S[j:]) for l in left for r in right)

memo = dict()

def expr(S):
    if S.S in memo:
        return memo[S.S]
    # print(S.S)
    i = S.pos
    left = factor(S)
    res = set()

    if not peek(S) in O:
        return left

    while peek(S) in O:
        ope = peek(S)
        next(S)
        next_i = S.pos
        right = factor(S)
        j = S.pos
        for m in O[ope](left, right):
            res |= expr(Source(S.S[:i] + str(m) + S.S[j:]))
        left = right
        i = next_i

    # print('res:', res, S.S)
    memo[S.S] = res
    return res


def factor(S):
    if peek(S) == '(':
        cnt = 1
        next(S)
        res = expr(Source(S.S[S.pos:]))
        while cnt > 0:
            if peek(S) == '(':
                cnt += 1
            elif peek(S) == ')':
                cnt -= 1
            next(S)
    else:
        res = num(S)
    return res


def num(S):
    sign = 1
    if peek(S) == '-':
        sign = -1
        next(S)
    res = 0
    while '0' <= peek(S) <= '9':
        res = res * 10 + int(peek(S))
        next(S)

    return {sign * res}


while True:
    S = input()
    if S == '#':
        break
    memo = dict()
    print(len(expr(Source(S))))



Measured memory_bytes: 8672
from itertools import combinations

if __name__ == '__main__':
    while True:
        # ?????????????????\???
        data = [int(x) for x in input().split(' ')]
        upper_limit = data[0]
        target_number = data[1]
        if upper_limit == 0 and target_number == 0:
            break

        # ????????????????????????
        choices = combinations(range(1, upper_limit+1), 3)

        # ????¨???????X????????´????????°????¢????????????????
        hit_count = 0
        for c in choices:
            # print(c)
            if sum(c) == target_number:
                hit_count += 1
        print(hit_count)

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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define endl "\n"
#define precise std::cout << std::fixed;std::cout << std::setprecision(6); 
#define F first
#define S second  
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

int binexpo(int x, int y, int p) {    
    int res = 1;     // Initialize result  
    x = x % p; // Update x if it is more than or  
                // equal to p  

    while (y > 0)  {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;
}
// --------------------------template ends here------------------------------

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;     

    return;
}

int32_t main() {
    FO;
    solve();
    return 0;
}

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

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

    int cnt = 0, mx = max(A, B);
    for (int i = mx; i >= 1; i--) {
        if (A % i == 0 && B % i == 0) cnt++;
        if (cnt == K) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
	ll v[maxtam];
	int nums;
	cin>>nums;
	
	for(int i=0; i<nums; i++)
		cin>>v[i];
		
	sort(v,v+nums);
	cout<<v[nums-1]-v[0]<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long s[n];
    for(long long i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n);
    if(s[0]==0)
    {
        cout<<0<<endl;
        return 0;
    }
    long long ans=1;
    for(long long i=0;i<n;i++)
    {
        if(s[i]>1000000000000000000/ans)
        {
            cout<<-1<<endl;
            return 0;
        }
        else ans*=s[i];
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int> > vv;
///-------------------------


int main()
{
    Phuong_; /// <3333
    string s;
    cin >> s;
    if (s.back() == 's') s+= "es"; else s+="s";
    cout << s ;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

long long inq(long long a, long long b, long long kek)
{
    if (b == 0) return 1;
    ll l = inq(a, b / 2, kek);
    if (b % 2) return l * l % kek * a % kek;
    return l * l % kek;
}

long long x, y;
long long fact[1050000], ufact[1050000];
const long long MOD = 1e9 + 7;

long long cnk(int n, int k)
{
    return 1LL * fact[n] * ufact[n - k] % MOD * ufact[k] % MOD;
}

signed main()
{
    fact[0] = 1;
    ufact[0] = 1;
    for (int i = 1; i <= 1000000; i++) fact[i] = fact[i - 1] * i % MOD, ufact[i] = inq(fact[i], MOD - 2, MOD);
    srand(time(NULL));
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> x >> y;
    if ((x + y) % 3 != 0)
    {
        cout << 0;
        return 0;
    }
    long long ans = 0;
    for (int t1 = 0; t1 <= 1000000; t1++)
    {
        long long xx = x - t1, yy = y - 2 * t1;
        if (xx >= 0 && yy >= 0 && xx == 2 * yy)
        {
            //cout << xx << " " << yy << endl;
            ans += cnk((x + y) / 3, yy);
            ans %= MOD;
        }
    }
    cout << ans;
}


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

typedef long long ll;

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

  int cnt=0;
  while(A%2==0 && B%2==0 && C%2==0){
    if(A==B && B==C){
      cnt=-1;
      break;
    }
    int AA, BB, CC;
    AA = B/2+C/2;
    BB = A/2+C/2;
    CC = A/2+B/2;

    A=AA; B=BB; C=CC;
    //cout << A <<" "<< B <<" "<< C << endl;
    cnt++;
  }

  cout << cnt << endl;
}

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



int main(){
  int ans = 700;
  char c;
  rep(i,3){
    cin >> c;
    if(c == 'o') ans += 100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)


[n,x]=[int(x) for x in input().split()]
xlist=[int(x) for x in input().split()]+[x,]
xlist.sort()
sabunlist=[xlist[i+1]-xlist[i] for i in range(n)]
print(gcd_list(sabunlist))

Measured memory_bytes: 16304
def main():
    N = int(input())
    r = list()
    for i in range(N):
        s, p = input().split()
        r.append([s, int(p), i + 1])
    r.sort(key = lambda x :x[1], reverse = True)
    r.sort(key = lambda x :x[0])
    for i in range(N):
        print(r[i][2])
main()

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

int N;
vector<int> v(101), w(101);
vector<vector<ll>> dp(101,vector<ll>(1000001,-1));

// i番目以降の品物から重さの和がj以下なるように選んだときの、
// 取りうる価値の総和の最大値を返す関数
// i=品物 j=容量
ll rec(int i, int j) {
	if (dp[i][j] != -1) {
		return dp[i][j];
	}

	ll res;
	if (i == N) {
		// 品物がもう残っていないときは、価値の和の最大値は0で確定
		res = 0;
	}
	else if (j < w[i]) {
		// 残りの容量が足りず品物iを入れられないので、入れないパターンだけ処理
		// i+1 以降の品物のみを使ったときの最大値をそのままこの場合の最大値にする
		res = rec(i + 1, j);
	}
	else {
		// 品物iを入れるか入れないか選べるので、両方試して価値の和が大きい方を選ぶ
		res = max(rec(i + 1, j) , rec(i + 1, j - w[i]) + v[i]);
	}

	dp[i][j] = res;
	return res;
}

int main() {
	//入力
	int W;
	cin >> N >> W;
	rep(i, N) cin >> w[i] >> v[i];

	//答え
	cout << rec(0,W) << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a[10000000],b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n;
       rep(i,n)cin>>a[i];
       rep(i,n){
        sum+=a[i];
        if(a[i]==0){
            ans+=sum/2;
            sum=0;
        }
        else if(i==n-1){
            ans+=sum/2;
        }
       }
       Cout(ans);
       
return 0;
}


Measured memory_bytes: 1024
w,h,n=map(int,input().split())
lx=0
rx=w
by=0
ty=h
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    lx=max(lx,x)
  elif a==2:
    rx=min(rx,x)
  elif a==3:
    by=max(by,y)
  else:
    ty=min(ty,y)
if rx-lx>0 and ty-by>0:
  print((rx-lx)*(ty-by))
else:
  print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    string s; cin >> s;
    sort(s.begin(), s.end());
    if (s[0] != s[2]) cout << "Yes";
    else cout << "No";
}

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

int main(){
  int N;
  cin>>N;
  vector<int64_t> B(N);
  int cnt=0;
  for(int i=0;i<N;++i){
    int64_t A;
    cin>>A;
    
    if(A<=0)  ++cnt;
    B[i]=abs(A);
  }

  int64_t ans=0;
  if(cnt%2==0){
    for(int i=0;i<N;++i){
      ans += B[i];
    }
    cout<<ans<<endl;
  }
  else{
    sort(B.begin(),B.end());
    for(int i=0;i<N;++i){
      if(i==0) ans -= B[i];
      else ans += B[i];
    }
    cout<<ans<<endl;
  }
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a).size()
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define endl "\n"

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
//K-th smallest
//cout << k << "rd smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

// priority_queue <ll,vector<ll>,greater<ll> > p;

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

ll mod=1000000007;

ll power(ll x, ll y) 
{
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return (temp*temp)%mod;
	else
		return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	vector<ll> a;
	vector<ll> ad[200005];
	ll i;
	for(i=0;i<n;i++)
	{
		ll val;
		cin>>val;
		a.pb(val);
		ad[val].pb(i);
	}
	ll p=1;
	ll cur=0;
	while(true)
	{
		ll x = a[cur];
		ll idx = upper_bound(all(ad[x]), cur)-ad[x].begin();
		if(idx == sz(ad[x]))
		{
			p++;
			idx = 0;
		}
		idx = ad[x][idx];
		if(idx == n-1)
			break;
		cur = idx+1;
	}
	k %= p;
	p = 1;
	cur = 0;
	while(true)
	{
		if(p == k)
			break;
		ll x = a[cur];
		ll idx = upper_bound(all(ad[x]), cur)-ad[x].begin();
		if(idx == sz(ad[x]))
		{
			p++;
			idx = 0;
		}
		idx = ad[x][idx];
		if(idx == n-1)
			break;
		cur = idx+1;
	}
	vector<ll> ans;
	for(i=cur;i<n;i++)
	{
		ll x = a[i];
		ll idx = upper_bound(all(ad[x]), i)-ad[x].begin();
		if(idx == sz(ad[x]))
		{
			ans.pb(x);
			continue;
		}
		else
		{
			idx = ad[x][idx];
			i = idx;
		}
	}
	for(i=0;i<sz(ans);i++)
		cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 15856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var aArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


            string result = "APPROVED";
            foreach(long a in aArray)
            {
                if(a % 2 == 0)
                {
                    if(a % 3 !=0 && a % 5 != 0)
                    {
                        result = "DENIED";
                        break;
                    }
                }
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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


int main() {
	
	string s;
	set<int>AC,WA;
	int n,m,x,totalWa =0;;
	
	cin>>n>>m;
	int arr[n+1]={0};
	
	for(int i=0;i<m;i++)
	{
		cin>>x>>s;
		if(s=="AC")
		{
			AC.insert(x);
			if(!WA.count(x))
			{
				totalWa+=arr[x];
				WA.insert(x);
			}
		}
		if(s=="WA")
		{
			if (!AC.count(x)) 
			{  
			   arr[x]++;
			}

		}
	}
	
	cout<<AC.size()<<" "<<totalWa<<endl;
	return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

ll func(int k) {
    if (k==0) return 5;
    if (k==1) return 0;
    return 2;
}

int main() {
    int N; cin >> N;
    ll X; cin >> X;
    vector<ll> x(N);
    REP(i,N) cin >> x[i];
    vector<ll> x_sum(N+1,0);
    REP(i,N) x_sum[i+1] = x_sum[i] + x[i];
    ll ans = INF;
    FOR(i,1,N+1) {
        ll tmp = 0;
        int cnt = 0;
        for(int j=N;j>=1;j-=i) {
            tmp += func(cnt) * x_sum[j];
            if(tmp > (ll)1e17) break;
            cnt ++;
        }
        ans = min(ans, tmp + ((ll)N+i)*X);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import collections

blue = [input() for i in range(int(input()))]
red = [input() for i in range(int(input()))]

blue_c = collections.Counter(blue)
red_c = collections.Counter(red)

ans = 0

blue_s = set(blue)

for i in blue_s:
    if blue_c[i] - red_c[i] > ans:
        ans = blue_c[i] - red_c[i]
        
print(ans)


Measured memory_bytes: 3316
/**
 *    author:  FromDihPout
 *    created: 2020-08-25
**/

#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;
const int N = 1e3 + 10;
queue<pair<int,int>> q, q2;
int dist[N][N], h, w, sh, sw, eh, ew;
vector<pair<int,int>> ADJ = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
vector<string> a;

void dfs(int r, int c) {
    q2.emplace(r, c);
    for (auto neigh : ADJ) {
        int nr = r + neigh.first, nc = c + neigh.second;
        if (nr < 0 || nr >= h || nc < 0 || nc >= w || a[nr][nc] == '#') continue;
        if (dist[r][c] < dist[nr][nc]) {
            dist[nr][nc] = dist[r][c];
            dfs(nr, nc);
        }
    }
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> h >> w >> sh >> sw >> eh >> ew;
    sh--, sw--, eh--, ew--;
    a.resize(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dist[i][j] = INF;
        }
    }
    q.emplace(sh, sw);
    dist[sh][sw] = 0;
    while (1) {
        bool ok = false;
        while (!q.empty()) {
            auto pos = q.front();
            q.pop();
            int r = pos.first, c = pos.second;
            if (r == eh && c == ew) {
                ok = true;
                break;
            }
            dfs(r, c);
        }
        if (ok) break;
        
        while (!q2.empty()) {
            auto pos = q2.front();
            q2.pop();
            int r = pos.first, c = pos.second;
            if (r == eh && c == ew) {
                ok = true;
                break;
            }
            
            for (int nr = max(0, r-2); nr <= min(h-1, r+2); nr++) {
                for (int nc = max(0, c-2); nc <= min(w-1, c+2); nc++) {
                    if (nr == r && nc == c) continue;
                    if (nr < 0 || nr >= h || nc < 0 || nc >= w || a[nr][nc] == '#') continue;
                    if (dist[r][c] + 1 < dist[nr][nc]) {
                        dist[nr][nc] = dist[r][c] + 1;
                        q.emplace(nr, nc);
                    }
                }
            }
        }
        if (ok) break;
        if (q.empty()) break;
    }
    
    if (dist[eh][ew] < INF) {
        cout << dist[eh][ew] << '\n';
    }
    else {
        cout << -1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 8756
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	ll A[100010];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	int ans = 1;
	int State = 0;
	for (int i = 1; i < N; i++) {
		if (State == 0) {
			if (A[i - 1] - A[i] < 0) State = -1;
			else if(A[i - 1] - A[i] > 0) State = 1;
		}
		else if (State == 1) {
			if (A[i - 1] - A[i] < 0) {
				State = 0;
				ans++;
			}
		}
		else if (State == -1) {
			if (A[i - 1] - A[i] > 0) {
				State = 0;
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int k,a,b;
  cin >> k>>a>>b;
  if(b/k > a/k || a%k==0 || b%k==0)cout << "OK" <<endl;
  else cout <<"NG\n";
  return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  int R,S,P;
  cin>>R>>S>>P;
  string T;
  cin>>T;
  vector<int> frag(N);
  int64_t sum=0;

  for(int i=0;i<K;++i){
    if(T.at(i)=='r'){
      sum += P;
      frag.at(i)=1;
    }
    if(T.at(i)=='s'){
      sum += R;
      frag.at(i)=1;
    }
    if(T.at(i)=='p'){
      sum += S;
      frag.at(i)=1;
    }
  }

  for(int i=K;i<N;++i){
    if(T.at(i)==T.at(i-K) && frag.at(i-K)==0){
      if(T.at(i)=='r'){
        sum += P;
        frag.at(i)=1;
      }
      if(T.at(i)=='s'){
        sum += R;
        frag.at(i)=1;
      }
      if(T.at(i)=='p'){
        sum += S;
        frag.at(i)=1;
      }
    }
    else if(T.at(i)!=T.at(i-K)){
      if(T.at(i)=='r'){
        sum += P;
        frag.at(i)=1;
      }
      if(T.at(i)=='s'){
        sum += R;
        frag.at(i)=1;
      }
      if(T.at(i)=='p'){
        sum += S;
        frag.at(i)=1;
      }
    }
  }

  cout<<sum<<endl;
}


Measured memory_bytes: 896
import itertools


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def factorize_list(n):
    result = []
    for val,perm in factorize(n):
        result+= [val]*perm
    return result



def mul(args):
    r =1
    for v in args:
        r*= v
    return r

def getcomb(l):
    if len(l)==0:
        return [1]
    result = []
    v,perm = l[0]
    for i in range(perm+1):
        result+= [(v**i)*val for val in getcomb(l[1:])]
    return result


N,M=list(map(int,input().split()))
factorized = factorize(M)
result=1
for i in range(len(factorized)//2+1):
    for vals in getcomb(factorized):
        A= vals
        B= M//A
        #print(A,B,vals)
        if A>=N:
            result = max(B,result)
        if B>=N:
            result = max(A,result)


print(result)

Measured memory_bytes: 3064
fn main() {
    let (n, m, a) = input();
    println!("{}", solve(n, m, a));
}

fn input() -> (u64, u64, Vec<u64>) {
    let mut buf1 = String::new();
    let mut buf2 = String::new();
    std::io::stdin().read_line(&mut buf1).unwrap();
    std::io::stdin().read_line(&mut buf2).unwrap();
    buf1.pop();
    buf2.pop();
    let mut buf1 = buf1.split_whitespace();
    let n: u64 = buf1.next().unwrap().parse().unwrap();
    let m: u64 = buf1.next().unwrap().parse().unwrap();
    let mut iter = buf2.split_whitespace();
    let a: Vec<u64> = iter.map(|x| x.parse().unwrap()).collect();
    (n, m, a)
}

fn solve(n: u64, m: u64, a: Vec<u64>) -> i64 {
    let sum = a.iter().sum();
    if n < sum { return -1; }
    (n - sum) as i64
}

Measured memory_bytes: 2212
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())

n = ni()
lis = []
ans = [[] for _ in range(n)]
for i in range(n):
    s, p = nsm()
    p = -int(p)
    lis.append([s, p, i])
lis.sort()
for i in range(n):
    print(lis[i][2] + 1)


Measured memory_bytes: 3316
import math
A, B, H, M = list(map(int, input().split()))

h = (H%12) / 12 * 360 + .5 * M
m =  M / 60 * 360
radian = math.cos(math.radians(abs(h-m)))
ans = math.sqrt(A**2 + B**2 - 2 * A * B * radian)
print('{:.15f}'.format(ans))

Measured memory_bytes: 9448
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10,mod=1e9+7,B=63;

ll n , k, a[N] , sp[N][B];
int main ()
{
    FASTIO
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> sp[i][0];
    }
    for(int b=1;b<B;b++){
        for(int i=1;i<=n;i++){
            ll next=sp[i][b-1];
            sp[i][b] = sp[next][b-1];
        }
    }
    ll ans=1;
    for(int b=B-1;b>=0;b--){
        if((k&(1ll<<b))){
            ans = sp[ans][b];
        }
    }
    cout << ans << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 102084
import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.language.postfixOps

object Main {
  private[this] var cnt = 0
  private[this] val l = new Array[Int](260000)
  private[this] val r = new Array[Int](260000)
  val b = new ListBuffer[(Int,Int)]

  def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {
    val n1 = mid-left
    val n2 = right-mid
    Array.copy(a,left,l,0,n1)
    l(n1) = Int.MaxValue
    Array.copy(a,mid,r,0,n2)
    r(n2) = Int.MaxValue
    var i=0
    var j=0
    for(k<-left until right) {
      if(l(i)<=r(j)){
        a(k) = l(i)
        i += 1
      } else  {
        a(k)=r(j)
        j += 1
      }
      cnt += 1
    }
  }

 def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {
    var w = n
    var h = 0
    while(w>1) {
      h += 1
      w = w/2
    }

    def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {
      if(h==0) l
      else
        scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)
    }
    scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val l = getSortIndex(n)
    for(e2<-l) {
      for(e<-e2) {
        val mid = (e._2+e._1)/2
        if(e._2-e._1>1)
          merge(a,e._1,mid,e._2)
      }
    }
    merge(a,0,n/2,n)
    println(a.mkString(" "))
    println(cnt)
  }
}

Measured memory_bytes: 316636
#include<iostream>
using namespace std;
int s[51];
int main(){
	int i,j,k,l;
	int a;
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			for(k=0;k<10;k++){
				for(l=0;l<10;l++){
					s[i+j+k+l]++;
				}
			}
		}
	}
	while(cin>>a){
		cout<<s[a]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from functools import reduce
from fractions import gcd


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x*y//gcd(x, y)
    return reduce(lcm, iter)


AB = map(int, input().split())
print(least_common_multiple(AB))


Measured memory_bytes: 5128
#include <cstdio>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <bitset>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

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

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){
  return os << '(' << p.first <<',' << p.second << ')';
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& a){
  os << '[';
  rep(i,a.size()) os << (i ? " " : "") << a[i];
  return os << ']';
}

int main() {
  for(int N; cin >> N, N != 0; ) {
    bitset<100> ps[100];
    rep(i, N) {
      int M; cin >> M;
      rep(j, M) {
        int p; cin >> p;
        ps[i][p - 1] = 1;
      }
    }
    bitset<100> ls;
    int K; cin >> K;
    rep(i, K) {
      int l; cin >> l;
      ls[l - 1] = 1;
    }

    int cnt = 0;
    int ans = -1;
    rep(i, N) {
      if ((ps[i] | ls) == ps[i]) {
        cnt++;
        ans = i;
      }
    }

    if (cnt == 1) cout << ans + 1 << endl;
    else cout << -1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int dp[100001];
vector<int> stone;
int k;
int solve(int n){
	if(dp[n] > -1) return dp[n];
	if(n == 0){
		return dp[n] = 0;
	}
	int minimum = INT_MAX;
	for(int i = 1; i <= k; i++){
		if(n - i >= 0){
			minimum = min(minimum, solve(n-i) + abs(stone[n] - stone[n - i]));
		}
	}
	return dp[n] = minimum;
}
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin >> n >> k;
  	stone.resize(n);
  	for(int i = 0; i < n; i++){
  		int m;
  		cin >> m;
  		stone[i] = m;
  	}
  	for(int i = 0; i < 100001; i++) dp[i] = -1;
  	reverse(stone.begin(), stone.end());
  	cout << solve(n-1) << endl;
	return 0;
}


Measured memory_bytes: 7296
#include <cstdio>
using namespace std;

int main() {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	if (n*a > b) {
		printf("%d", b);
	}
	else {
		printf("%d", n*a);
	}
	return 0;
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  ll m = 0, ans = 0;
  for(int i=0; i<n; ++i) cin >> a[i];

  for(int i=0; i<n; ++i){
    ans += a[i]-1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3616
#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>;

int main(){
   string s;
   cin >> s;
   int ans=0,con=0;
   for(int i=0;i<3;i++){
      if(s[i]=='R'){
         con++;
      }else{
         con=0;
      }
      ans = max(ans,con);
   }

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long int ans = 1;
  bool b = false;
  bool c = true;
  vector<long long int> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if(vec.at(i) == 0) {
      b = true;
      break;
    }
  }
  if(b) {
    cout << 0 << endl;
  }
  else {
    for(int i = 0; i < N; i++) {
      if(1000000000000000000 / ans < vec.at(i)) {
      	c = false;
        break;
      }
      else {
        ans *= vec.at(i);
      }
    }
    if(c) {
      cout << ans << endl;
    }
    else {
      cout << -1 << endl;
    }
  }
}


Measured memory_bytes: 4052
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-13 17:16:45
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

LL gcd(LL k, LL l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

int bin_pow(int n)
{
    if (n % 2 == 0) return 1 + bin_pow(n/2);
    else return 0;
}

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

    int ok = 1;
    int b = bin_pow(a[0]);
    LL lcm = a[0]/2;
    for (int i = 1; i < n; i++) {
        lcm *= ((LL)a[i]/2)/(gcd(lcm, a[i]/2));
        if (b != bin_pow(a[i]) || lcm <= 0 || lcm > m) ok = 0;
    }

    int ans = 0;
    for (int t = 1; lcm*t <= m; t += 2)
        ans += ok;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
def main():
  ans = 0
  n,m = map(int, input().split())
  if n == m == 1:
      ans = 1
  elif n == 1 or m == 1:
      ans = max(n,m)-2
  else:
      ans = (n-2)*(m-2)
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    public void solve() {
    	int N = ni();
    	int[] H = new int[N];
    	boolean f = true;
    	for (int i = 0; i < N; i++) {
			H[i] = ni();
			if(H[i] > 0)	f = false;
		}
    	if(f) {
    		out.println(0);
    		return;
    	}
    	int ans = 0;
    	boolean f2;
    	while(true) {
    		f = true;
    		f2 = false;
    		for (int i = 0; i < N; i++) {
    			if(H[i] > 0) {
    				if(!f2) {
    					ans++;
    					f2 = true;
    				}
        			H[i]--;
        			f = false;
    			} else {
    				f2 = false;
    			}
    		}
    		if(f)	break;
		}
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 23764
// D - Recording
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int N,C; cin>>N>>C;
	vector<vi> tv(100000, vi(C, 0));
	while(N--){
		int s,t,c; cin>>s>>t>>c; --c;
		rp(i, s-1, t) tv[i][c] = 1;
	}
	int ans = 0;
	rp(z, 0, tv.size()){
		int s = 0; rp(c, 0, tv[z].size()) s += tv[z][c];
		ans = max(ans, s);
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 18036
$n = 0

def merge(sorted_left, sorted_right)
  arr = []
  l_p = r_p = 0
  max = 1000000000
  sorted_left.push(max)
  sorted_right.push(max)
  l_v = r_v = 0
  while l_v != max || r_v != max
    flag = true
    l_v = sorted_left[l_p].to_i
    while flag
      r_v = sorted_right[r_p].to_i
      if l_v == max && r_v == max then
        return arr
      elsif l_v < r_v then
        arr.push(l_v)
        l_p = l_p + 1
        flag = false
      else
        arr.push(r_v)
        r_p = r_p + 1
      end
      $n = $n + 1
    end
  end
  arr
end

def mergeSort(arr)
  if arr.size == 0 then
    arr
  elsif arr.size == 1 then
    arr
  else
    m = arr.size / 2
    left = arr.take(m)
    right = arr.drop(m)
    merge(mergeSort(left), mergeSort(right))
  end
end

n = STDIN.gets.to_i
arr = STDIN.gets.split(' ')
puts mergeSort(arr).join(' ')
puts $n

Measured memory_bytes: 83104
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define INF (1<<28)
typedef long long Int;

int N, B[64], C[64];
string A[64], D[64][64];
int g[64][64], vis[64];
int r[64], p[64];
Int f[64];

void collect(vector<int>& q, int at) {
    if (vis[at]) return ;
    vis[at] = 1;
    q.push_back(at);
    rep (i, N) if (g[at][i]) collect(q, i);
}

void prepare(vector<int>& q) {
    const int n = q.size();
    vector<pair<int, int> > ps;
    rep (i, n) ps.push_back(mp(-B[q[i]], q[i]));
    sort(ps.begin(), ps.end());
    rep (i, n) r[i] = ps[n-1-i].second;
    //rep (i, n) r[i] = q[i];
    rep (i, n) p[i] = B[r[i]];
    rep (i, n) {
        f[i] = 0;
        rep (j, n) if (g[r[i]][r[j]]) f[i] |= 1LL<<j;
    }
}

int rec(int n, int k, Int u) {
    if (k == n) return 0;
    rep (i, k) if (!(u&(1LL<<i)) && !(f[i]&u)) return -INF;
    int ans = -INF;
    const int mask = (1LL<<n) - 1;
    if (u&(1LL<<k)) ans = max(ans, rec(n, k+1, u&(mask-f[k])) + p[k]);
    if (r[k]) ans = max(ans, rec(n, k+1, u&(mask-(1LL<<k))));
    return ans;
}

int solve() {
    memset(vis, 0, sizeof(vis));
    int ans = 0;
    rep (i, N) if (!vis[i]) {
        vector<int> q;
        collect(q, i);
        prepare(q);
        ans += rec(q.size(), 0, (1LL<<q.size())-1);
    }
    return ans;
}

int main() {
    for (;;) {
        cin >> N;
        if (N == 0) return 0;
        map<string, int> of;
        rep (i, N) {
            cin >> A[i] >> B[i] >> C[i];
            of[A[i]] = i;
            rep (j, C[i]) cin >> D[i][j];
        }
        memset(g, 0, sizeof(g));
        rep (i, N) rep (j, C[i]) g[i][of[D[i][j]]] = 1;
        printf("%d\n", solve());
    }
}

Measured memory_bytes: 1396
s=input()
t=input()

a = len(s)
b = len(t)
c = a-b;
min1 = 0;
min2 = 0;
for i in range(c+1):
  for j in range(b):
    
    if s[j+i]==t[j]:
      
      min2 += 1
  if min1<min2:
    min1 = min2
  min2 =0
print(b-min1)

Measured memory_bytes: 8848