akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
use std::fmt::Write;

fn main() {
    input! {
        h: usize,
        w: usize,
        a: usize,
        b: usize,
    }

    let mut ans = String::new();
    for i in 0..h {
        if i < b {
            for j in 0..w {
                if j < a {
                    write!(&mut ans, "0").unwrap();
                } else {
                    write!(&mut ans, "1").unwrap();
                }
            }
        } else {
            for j in 0..w {
                if j < a {
                    write!(&mut ans, "1").unwrap();
                } else {
                    write!(&mut ans, "0").unwrap();
                }
            }
        }
        writeln!(&mut ans).unwrap();
    }

    print!("{}", ans);
}


Measured memory_bytes: 2876
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	int n, k;
	int multi, half_multi;
	long ret;
	scanf("%d %d\n", &n, &k);
	multi = n / k;
	ret = (long)multi * multi * multi;
	if(k%2 == 0) {
		half_multi = n / (k/2) - multi;
		ret += (long)half_multi * half_multi * half_multi;
	}
	printf("%ld\n", ret);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        boolean r = true;

        for(int i=0; i<n; i++){
            int a = sc.nextInt();
            if (a % 2 == 1){continue;}
            if (a % 3 == 0 || a % 5 == 0){continue;}
            r = false;
        }

        if(r){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }

        sc.close();
    }
}

Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
int main(){
  int a, b, c;
  cin >> a >> b >> c;
cout<< max({a, b, c}) - min({a, b, c}) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[1000][1000];
int b[1000];
int answer[1000];
int main(){
    int n, m;
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=1;i<=m;i++){
        cin >> b[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            answer[i] += a[i][j] * b[j];
        }
    }
    for(int i=1;i<=n;i++){
        cout << answer[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3488
#pragma GCC optimize ("-O3")
#ifdef LOCAL
  #include "helper_funcs.hpp"
#else
  #include <bits/stdc++.h>
#endif
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define frn(i,a,b) for(ll i=a;i<b;i++)
#define rfrn(i,a,b) for(ll i=a;i>b;--i)
#define forn(i,a,b) for(ll i=a;i<=b;i++)
#define rforn(i,a,b) for(ll i=a;i>=b;--i)
#define sqfrn(i,a,b) for(ll i=a;i*i<b;i++)
#define sqforn(i,a,b) for(ll i=a;i*i<=b;i++)
#define frt(it,v) for(auto &it:v)
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define SQR(a) (a)*(a)
#define SUM(n) ((n)*(n+1))/2
// #define SqSUM(n) ((n)*(n+1)*(2*n+1))/2
// #define GMSUM(a,r,n) (a*pow(r,n)-a)/(r-1)
#define ciel(x, y) (((x) / (y)) + ((x) % (y) != 0))
#define input(v,a,b) for(ll i = a ; i<b ; i++) cin>>v[i]
#define output(v,a,b) cout<<"["<<#v<<"]: "; for(ll i = a ; i<b ; i++) cout<<v[i]<<" "; cout<<ln
#define cout_p(x, p) cout << fixed << setprecision((p)) << x
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
const long long int md = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef vector<ll> v1;
typedef vector<vector<ll > > vv2;
#define M 32
#ifndef M_PI
  #define M_PI 3.14159265358979323846
#endif
typedef bitset<M> btst;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;
typedef priority_queue<int, vector<int>> max_heap;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//     indexed_set;
const ll MAX = LONG_MAX;
const ll lrg = 1000000007;

ll pw(ll a, ll x)
{
	ll cp=x, pr=a, ans=1;
	while(cp>0)
	{
		if(cp%2!=0)
		{
			ans=(ans*pr)%lrg;
		}
		cp/=2;pr=(pr*pr)%lrg;
	}
	return ans;
}

void solve()
{
	ll n;
	cin>>n;
	cout<<(pw(10, n) - (2*(pw(9, n)-pw(8, n)))%lrg - pw(8, n) + 2*lrg)%lrg;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1,cp;
  // cin>>t;
  cp=t;
  while(t--){
   // cout<<"Case #"<<cp-t<<": ";
   solve();
   cout<<"\n";
  }
  return 0;
}

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

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    from collections import Counter

    w = Counter(input())
    result = 'Yes'

    for count in w.values():
        if count % 2 != 0:
            print('No')
            exit()

    print(result)


Measured memory_bytes: 3316
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long n = read.to!long;
	
	long best = 1_000_000_999;
	long[] ms = [1, 10, 100, 1_000, 10_000, 100_000, 1_000_000];
	foreach(i; 1 .. n){
		long a = i;
		long b = n - a;
		long x;
		while(a > 0 || b > 0){
			x += a % 10, a /= 10;
			x += b % 10, b /= 10;
		}
		best = min(best, x);
	}
	
	best.writeln;
}


Measured memory_bytes: 384
import java.util.*;


import java.io.*;
/**
 * MLASERP
 */
public class Main {

    
    static MyScanner in  = new MyScanner();
   static int mod  = 1000000007;
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      static StringTokenizer st;
      static int []dr  = {1,-1,0,0};
      static int [] dc = {0,0,-1,1};
public static void main(String[] args) {
    String N = in.nextLine();
    long val =0;
    for(int i=0;i<N.length();i++){
        val+=(N.charAt(i)-'0');
    }
    out.println(val%9==0?"Yes":"No");
   out.flush();
}
private static int compare(String substring, String t) {
    int val = 0;
    for(int i=0;i<t.length();i++){
        if(t.charAt(i)!=substring.charAt(i))
            val++;
    }
    return val;
}
static int rcToxy(int r, int c,int W){
    return r*W+c;
}
static class Node{
    int r, c,prev,change;
    Node(int r, int c){
        this.r =r ;
        this.c = c;
    }
}
public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
}

Measured memory_bytes: 37252
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const double INF = 2147483647;
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP(i, 1, n+1)
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, x, n) for(int i = (int)(n) - 1 - (int)(x); i >= 0; i--)

template<class T>
void printv(vector<T> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}


int main() {
    int N,M;
    cin>>N>>M;
    cout<<N*M;
    
    return 0;
}

Measured memory_bytes: 3640
//This code is written by Shammi Anand
#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define Max(a,b,c)      max((a),max((b),(c))
#define Min(a,b,c)      min(a,min(b,c))
#define pb              push_back
#define mp              make_pair
#define f               first
#define s               second
#define mod             1000000007
#define nl              "\n"
#define w(x)            int x; cin>>x; while(x--)


const int N = 1e5 + 5;
ll W[105], V[105], w, n;
ll dp[105][N];

ll solve(ll capacity, ll item) {
	if (capacity == 0 || item == 0) {
		return 0;
	}
	if (dp[item][capacity] != -1) {
		return dp[item][capacity];
	}
	if (W[item] > capacity) {
		return dp[item][capacity] = solve(capacity, item - 1);
	} else {
		return dp[item][capacity] = max(V[item] + solve(capacity - W[item], item - 1), solve(capacity, item - 1));
	}
}

int main() {
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> W[i] >> V[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(w, n) << nl;

	return 0;
}

Measured memory_bytes: 85668
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;
  string S;
  cin>>S;

  Int ofset = 0;
  for(Int i=0;i<N-1;i++) if(S[i] == S[i+1]) ofset++;
  {
    string nS;
    Int i = 0;
    while(i < N){
      char ch = S[i];
      while(i < N && S[i] == ch) i++;
      nS += ch;
    }
    S = nS;
  }
  S.pop_back();
  pr(ofset,S);
  Int ans = ofset + min(K * 2, (Int)S.size());
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 592
import copy

N=int(input())
F=[ [ [ 0 for i in range(3)] for j in range(6)] for k in range(N+1)]
# print(F)
for i in range(1,N+1):
     line = [int(k) for k in input().split()]
     for j in range(1,6):
         for k in range(1,3):
             F[i][j][k]=line[2*(j-1)+(k-1)]

P=[[0 for i in range(11)] for j in range(N+1)]
for i in range(1,N+1):
    line = [int(j) for j in input().split()]
    for k in range(11):
        P[i][k]=line[k]

# print(P)
# print(F)

stack=[]
stack.append([True])
stack.append([False])
rieki_max=float("inf")
# print(stack)
while(1):
    if len(stack)==0:
        break
    kumiawase=stack.pop()
    if len(kumiawase)==10:
        #利益計算
        if kumiawase.count(True)==0:
            continue
        kaburi=[0 for i in range(N+1)]
        for i in range(1,6):
            for j in range(1,3):
                if kumiawase[(i-1)*2+j-1]==False:
                    continue
                for k in range(1,N+1):
                    if F[k][i][j]==1:
                        kaburi[k]+=1
        rieki=0
        # print(kaburi)
        for i in range(0,N+1):
            rieki+=P[i][kaburi[i]]
        # print(kumiawase,kaburi,rieki)
        if rieki_max < rieki or rieki_max==float("inf"):
            rieki_max = rieki
    else:
        tmp_a = copy.deepcopy(kumiawase)
        tmp_a.append(True)
        stack.append(tmp_a)
        tmp_b = copy.deepcopy(kumiawase)
        tmp_b.append(False)
        stack.append(tmp_b)
print(rieki_max)


Measured memory_bytes: 3568
{-# LANGUAGE FlexibleInstances #-}

import Data.List

-- stdin
class In a where stdin :: IO a
instance In [Int] where stdin = map read . words <$> getLine

getIndex :: [Int] -> Int
getIndex ns = indexOf ns $ sort $ permutations [1..(length ns)]
  where
    indexOf x xs = length $ takeWhile (/=x) $ sort xs

main = do
    _ <- getLine
    a <- stdin
    b <- stdin

    print $ abs (getIndex a - getIndex b)


Measured memory_bytes: 21884
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#define MP make_pair
#define F first
#define S second
using namespace std;

int ans = 0;

int main () {
	int a, b, c;
	cin >> a >> b;
	if (a == 3)	ans += 100000;
	if (a == 2)	ans += 200000;
	if (a == 1)	ans += 300000;

	if (b == 3)	ans += 100000;
	if (b == 2)	ans += 200000;
	if (b == 1)	ans += 300000;

	if (a == 1 && b == 1)	ans += 400000;
	cout << ans << endl;
	return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int n, k;
  cin >> k >> n;
  vector<int> A(n);
  for (auto &a : A) {
    cin >> a;
  }
  int max_diff = -1;
  for (int i = 1; i < n; i++) {
    max_diff = max(max_diff, A[i] - A[i - 1]);
  }
  max_diff = max(max_diff, k - A[n - 1] + A[0]);
  cout << k - max_diff << "\n";
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e15;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        if(i<k) continue;
        if(a[i-k]<a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4780
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let n:Int=Int(readLine()!)!
let a=readInts()
let b=readInts()
let c=readInts()
var ans=0

for i in 0..<n{ans+=b[i]}

for i in 0..<n-1{if a[i+1]-a[i]==1 {ans+=c[a[i]-1]}}


print(ans)

Measured memory_bytes: 13588
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){

	double x1, x2, y1, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	printf("%.8f", sqrt( pow(x2 - x1 , 2 ) + pow(y2 - y1, 2)));

	return 0;
}


Measured memory_bytes: 3212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int [] array = new int[n];
		for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for(int i=0;i<n;i++) {
			int tmpA = 0;
			tmpA = array[i];
			int tmpB = 0;
			tmpB = k-array[i];
			if(tmpB<0) {
				tmpB = -1*tmpB;
			}
			if(tmpB>=tmpA) {
				ans = ans + 2*tmpA;
			}else {
				ans = ans + 2*tmpB;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35908
#include <iostream>
using namespace std;
#define int long long
#define f(i,n) for(int i=0;i<n;i++)

signed main(){
	int n,k;
	cin>>n>>k;
	int modu = n%k;
	if(modu>k/2){
		cout<<k-modu<<endl;
	}else{
		cout<<modu<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;

}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<int> X(N);
  rep(i, N)
    cin >> X[i];
  ll ans = 0;
  for (int i=1; i<N; i++)
    ans += min((X[i]-X[i-1])*A, B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(250000)

from scipy.special import comb
# a = comb(n, r)

def main():
    # a,b,c,d = map(int, input().split())
    n = int(input())

    sum = 10**n - 9**n*2 + 8**n
    # temp = (10 ** 9 + 7)
    # sum = 0
    # if n >= 2:
    #     for i in range(2, n+1):
    #         a = int(comb(i, 2)) * 2
    #         a = (a * 8**(i-2)) % temp
    #         sum = sum + a
    # else:
    #     print(0)

    print(sum % (10 ** 9 + 7))

main()


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

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

int main()
{
    int x,y; cin>>x>>y;
    cout<<gcd(x,y)<<endl;
    return 0;   
}


Measured memory_bytes: 3104
import Data.List
import Data.Ord

main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  let m = map (\g -> (head g, length g)) $ group $ sortBy (comparing Down) as
  print $ solve m 0

solve :: [(Int,Int)] -> Int -> Int
solve [] _ = 0
solve ((v,i):xs) n
  | i >= 4 = if v*v > v*n then v*v else v*n
  | i >= 2 && n /= 0 = v*n
  | i >= 2 = solve xs v
  | otherwise = solve xs n


Measured memory_bytes: 38524
MOD = 1000000007

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

L1 = [0 for _ in range(N)]
R1 = [0 for _ in range(N)]
L2 = [0 for _ in range(N)]
R2 = [0 for _ in range(N)]

tmp1 = 1
tmp2 = 1

for i in range(N):
    if tmp1 < T[i]:
        L1[i] = T[i]
        R1[i] = T[i]
        tmp1 = T[i]
    elif tmp1 == T[i]:
        L1[i] = 1
        R1[i] = tmp1
    else:
        print(0)
        break
    if tmp2 < A[~i]:
        L2[~i] = A[~i]
        R2[~i] = A[~i]
        tmp2 = A[~i]
    elif tmp2 == A[~i]:
        L2[~i] = 1
        R2[~i] = tmp2
    else:
        print(0)
        break
else:
    res = 1
    for i in range(N):
        res *= max(min(R1[i], R2[i]) - max(L1[i], L2[i]) + 1, 0)
        res %= MOD
    print(res)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a.rbegin(),a.rend());
  int ans=0;
  for(int i=0;i<N;i++){
    if(i==0){
      ans++;
      continue;
    }
    if(a[i-1]==a[i]) continue;
    ans++;
  }
  cout << ans;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (d2 == 1)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

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

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (auto &a : A) cin >> a;
  sort(A.begin(), A.end());

  long L = -2e18, R = 2e18;
  while (R - L > 1) {
    long M = (L + R) / 2, cnt = 0;
    for (int i = 0; i < N; i++) {
      if (A.at(i) >= 0) {
        int l = i, r = N;
        while (r - l > 1) {
          int m = (l + r) / 2;
          (A.at(i) * A.at(m) < M) ? l = m : r = m;
        }
        cnt += l - i;
      } else {
        int l = i, r = N;
        while (r - l > 1) {
          int m = (l + r) / 2;
          (A.at(i) * A.at(m) < M) ? r = m : l = m;
        }
        cnt += N - r;
      }
    }
    (cnt < K) ? L = M : R = M;
  }
  cout << L << "\n";
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

int main(){
    double a,b,x;
    std::cin >> a >> b >> x;
    printf("%.10lf\n",(a*a*b > x*2) ? (90-atan(2*x/(a*b*b))*180/acos(-1)) : (90-atan(a*a*a/2/(a*a*b-x))*180/acos(-1)));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	const int p = 10;
	int mountain[p];
	for (int i = 0; i < p; i++) { cin >> mountain[i]; }

	for (int t = 0; t < p - 1; t++) {
		for (int s = t + 1; s < p; s++) {
			if (mountain[s] > mountain[t]) {
			//?????????
				int osu = mountain[t];
				mountain[t] = mountain[s];
				mountain[s] = osu;
			}
		}
	}
	for (int k = 0; k < 3; k++) { cout << mountain[k] << endl; }
}

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

int n;
string s;
ll t[MAX_N];
ll dp[MAX_N][11];

int main(){
  while(1){
    cin>>s;
    if(s=="0")break;
    n=s.size();
    for(int i=0;i<n;i++)t[i]=s[i]-'0';
    
    for(int i=0;i<=n;i++)
      for(int j=0;j<11;j++)
        dp[i][j]=0;
    
    for(int i=0;i<n;i++){
      if(t[i]!=0)dp[i+1][t[i]]=1;
      for(int j=0;j<11;j++){
        int to=(j*10+t[i])%11;
        dp[i+1][to]+=dp[i][j];
      }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
      ans+=dp[i][0];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 8816
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[] counts = new int[200000];
		int[] numbers = new int[200000];
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long result = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			numbers[i] = a;
			result += counts[a - 1];
			counts[a - 1]++;
		}
		sc.close();

		for (int i = 0; i < n; i++) {
			int a = numbers[i];
			int c = counts[a - 1];
			System.out.println(result - (c - 1));
		}
	}
}


Measured memory_bytes: 96320
K = int(input())
l = list(range(1,10))

for x in l:
    if x > 3234566667: break
    back = int(str(x)[-1])
    for b in [back-1, back, back+1]:
        if 0 <= b <= 9:
            l.append(10*x + b)

print(l[K-1])

Measured memory_bytes: 86768
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    X -= Z;
    cout << X / (Y + Z) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    q = deque([3, 5, 7])
    answer = 0
    d = 3
    while d <= N:
        d = q.popleft()
        if len(set(list(str(d)))) == 3 and d <= N:
            answer += 1
        q.append(d * 10 + 3)
        q.append(d * 10 + 5)
        q.append(d * 10 + 7)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 6124
#!ruby -na00F\n
x=$F.find_index{|r|$y=r.index ?1}
n=[
[[1,0],[1,1],[0,1]],
[[1,0],[2,0],[3,0]],
[[0,1],[0,2],[0,3]],
[[1,0],[1,-1],[2,-1]],
[[1,1],[1,2],[0,1]],
[[1,0],[1,1],[2,1]],
[[1,0],[0,1],[1,-1]]].find_index{|c|c.all?{|i,j|($F[x+i]&&$F[x+i][$y+j])==?1}}
puts [*?A..?G][n]

Measured memory_bytes: 6116
x, y = map(int, input().split())

if abs(x) < abs(y):
    ans = abs(y)-abs(x)
    if x < 0:
        ans += 1
    if y < 0:
        ans += 1
    print(ans)
else:
    ans = abs(x)-abs(y)
    if 0 < x:
        ans += 1
    if 0 < y:
        ans += 1
    print(ans)


Measured memory_bytes: 9124
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

template<int MOD> struct ModInt {
	static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
	ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
	ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
	int get() const { return (int)x; }
	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
	ModInt inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
		return ModInt(u);
	}
	bool operator==(ModInt that) const { return x == that.x; }
	bool operator!=(ModInt that) const { return x != that.x; }
	ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r;
}
typedef ModInt<1000000007> mint;


int main(){
	string s;
	cin >> s;

	mint ans = 0;
	int la = 0, lp = 0;
	int rc = 0, rp = 0;

	fore(c, s) {
		if (c == 'C')rc++;
		if (c == '?')rp++;
	}

	fore(c, s) {
		if (c == 'C')rc--;
		if (c == '?')rp--;

		if (c == '?' || c == 'B') {
			mint l = mint(la) * (mint(3) ^ lp) + mint(lp) * (mint(3) ^ (lp - 1));
			mint r = mint(rc) * (mint(3) ^ rp) + mint(rp) *(mint(3) ^ (rp - 1));
			ans += l * r;
		}
		if (c == 'A')la++;
		if (c == '?')lp++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        List<Long> list = getDivisor(n);
        if (list.size() == 1) {
            System.out.println(1);
            return;
        }
        int l1 = String.valueOf(list.get(list.size() - 1)).length();
        int l2 = String.valueOf(list.get(list.size() - 2)).length();
        System.out.println(Math.max(l1, l2));
    }

    private static List<Long> getDivisor(long n) {
        List<Long> list = new ArrayList<>();
        long i = 1;
        while (i <= n / i) {
            if (n % i == 0) {
                list.add(i);
                list.add(n / i);
            }
            i++;
        }
        return list;
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int A, B;
    cin >> A >> B;
    int ans = max(0, A - 2*B);
    print(ans);
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720368ll;
int power(int base,int n,int m = mod)
 {
  if(n == 0)
     return 1;
  if(n&1)
     {
      int y = power(base,n-1,m);
      return (y*base)%m;
     }
  else
     {
      int y = power(base,n/2,m);
      return (y*y)%m;
     }
 }
unordered_map<int,int> cache;
int modinv(int x)
 {
  if(cache[x] != 0)
     return cache[x];
  int ans = power(x,mod-2);
  cache[x] = ans;
  return ans;
 }
int nCr(int k, int n)
{
  if (n < k) return 0;
  if (k > n / 2) k = n - k;
  int ret = 1;
  int divider = 1;
  loop(i,0,k) 
  {
   ret = ret * (n - i) % mod;
   divider = divider * (i + 1) % mod;
  }
  return (ret * modinv(divider))% mod;
}
void solve()
 { 
  int n,a,b;
  cin>>n>>a>>b;
  int tot = power(2ll,n);
  tot = (tot - 1ll + mod)%mod;
  //cerr<<tot;
  int a_reduce = nCr(a,n);
  int b_reduce = nCr(b,n);
  int reduce = (a_reduce + b_reduce)%mod;
  //cerr<<a_reduce<<" "<<b_reduce<<" "<<tot;
  tot= (tot - reduce + mod)%mod;
  cout<<tot;
 }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;
ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    if (n < 10)
    {
        cout << n << endl;
    }
    else if (n < 100)
    {
        cout << 9 << endl;
    }
    else if (n < 1000)
    {
        cout << 9 + (n - 99) << endl;
    }
    else if (n < 10000)
    {
        cout << 9 + 900 << endl;
    }
    else if (n < 100000)
    {
        cout << 9 + 900 + (n - 9999) << endl;
    }
    else
    {
        cout << 90909 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

ll mod_pow(ll n, ll k, ll p) {
  if (k == 0) return 1;
  ll res = mod_pow(n * n % p, k / 2, p);
  if (k & 1) res = res * n % p;
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(k + 1);
  a[0] = 0;
  rep(i, k) a[i + 1] = mod_pow((ll)i + 1, n, MOD);
  vector<ll> ans(k + 1);
  vector<ll> tmp(k + 1);
  for (ll i = k; i > 0; --i) {
    ll num = k / i;
    tmp[i] = a[num];
    for (ll j = i + i; j <= k; j += i) {
      tmp[i] -= tmp[j];
      while (tmp[i] < 0) tmp[i] += MOD;
    }
    ans[i] = (tmp[i] * i) % MOD;
  }
  ll q = 0;
  rep(i, k) q = (q + ans[i + 1]) % MOD;
  cout << q << endl;
  return 0;
}

Measured memory_bytes: 5628
//パソコン甲子園2008本選 問題09

#include<stdio.h>

int main(void){

	double *nl, **L, *ml, max, tmp;
	int n, m, f1, f2, f3;
	
	while(scanf("%d %d",&n,&m) && n > 0){
	
		L = new double *[n];
		nl = new double [n];
		 
		for(f1 = 0; f1 < n; f1++){
			nl[f1] = 1.0;//１回目は1.0なので1.0で初期化
			L[f1] = new double [n];
			for(f2 = 0; f2 < n; f2++)
				scanf("%lf",&L[f1][f2]);
		}
		
		for(f1 = 1; f1 < m; f1++){
		
			ml = new double [n];
			
			for(f2 = 0; f2 < n; f2++)//初期化
				ml[f2] = 0.0;
			//計算
			for(f2 = 0; f2 < n; f2++){
				for(f3 = 0; f3 < n; f3++){
					tmp = nl[f2] * L[f2][f3];
					if(tmp > ml[f3])
						ml[f3] = tmp;
				}
			}
			nl = ml;
		}
		//最大値を求める
		max = nl[0];
		for(f1 = 0; f1 < n; f1++){
			if(max < nl[f1])
				max = nl[f1];
		}
		//出力
		printf("%.2lf\n",max);
			
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
int n,c[510],s[510],f[510],i,a,j;main(){for(scanf("%d",&n);~scanf("%d%d%d",c+j++,s+j,f+j););for(f[j-1]=1;i<n;a=0)for(j=i++;j<n||!printf("%d\n",a);)a=(a<s[j]?s[j]:(~-a/f[j]+1)*f[j])+c[j++];}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int cnt[5];
int rrr[5] = {0, 1, 1, 2, 2};

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    
    rep(i, 3) {
        int a, b; cin >> a >> b;
        cnt[a]++, cnt[b]++;
    }
    sort(cnt, cnt+5);
    rep(i, 5) {
        if (cnt[i] != rrr[i]) {
            cout << "NO";
            exit(0);
        }
    }
    cout << "YES";    
}


Measured memory_bytes: 256
H,W = map(int,input().split())
src = [input() for i in range(H)]
dxy = [(0,1),(1,0),(0,-1),(-1,0)]
for y in range(H):
    for x in range(W):
        if src[y][x] == '.': continue
        for dx,dy in dxy:
            nx,ny = x+dx,y+dy
            if not 0 <= nx < W: continue
            if not 0 <= ny < H: continue
            if src[ny][nx] == '#': break
        else:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
	int n;
	while ((n = nextInt()) != 0) {
	    int[][] map = new int[21][21];
	    for (int i = 0; i < n; i++) {
		map[nextInt()][nextInt()] = 1;

	    }
	    int m = nextInt();
	    int x = 10;
	    int y = 10;
	    int count = 0;
	    for (int i = 0; i < m; i++) {
		// if (count != n) {
		char c = getChar();
		int l = nextInt();
		int dx = 0;
		int dy = 0;
		if (c == 'N') {
		    dy = 1;
		} else if (c == 'E') {
		    dx = 1;
		} else if (c == 'S') {
		    dy = -1;
		} else if (c == 'W') {
		    dx = -1;
		}
		for (int j = 0; j < l; j++) {
		    count += map[x][y];
		    map[x][y] = 0;
		    x += dx;
		    y += dy;
		}
		count += map[x][y];
		map[x][y] = 0;
		// } else {
		// skip();
		// }
	    }
	    if (count == n) {
		System.out.println("Yes");
	    } else {
		System.out.println("No");
	    }
	}
    }

    private static void skip() throws IOException {
	int c = System.in.read();
	while (c != '\n') {
	    c = System.in.read();
	}

    }

    private static char getChar() throws IOException {
	int c = ' ';
	while (c != 'N' && c != 'E' && c != 'W' && c != 'S') {
	    c = System.in.read();
	}
	return (char) c;
    }

    private static int nextInt() throws IOException {
	int c = System.in.read();
	while ((c < '0' || '9' < c) && c != '-') {
	    c = System.in.read();
	}
	if (c == '-') {
	    return -nextInt();
	}
	int result = 0;
	while ('0' <= c && c <= '9') {
	    result = result * 10 + (c - '0');
	    c = System.in.read();
	}
	return result;
    }
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    vector<P> red; 
    vector<P> blue;
    rep(i,n){
        int a,b; cin >> a >> b;
        red.push_back(make_pair(a,b));
    }
    rep(i,n){
        int a,b; cin >> a >> b;
        blue.push_back(make_pair(a,b));
    }
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    int ans = 0;
    bool not_use[n];
    rep(i,n) not_use[i] = true;
    rep(i,n){
        int bx = blue[i].first,by = blue[i].second;
        int now_y = -1;
        int id= -1;
        rep(j,n){
            if(!not_use[j]) continue;
            int rx = red[j].first,ry = red[j].second;
            if(rx < bx && ry < by && now_y < ry){
                id = j;
                now_y = ry;
            }
        }
        if(id != -1){
            ans++;
            not_use[id] = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(v.begin(),v.end()),v.end())
#define RET(p,x) return p<<x<<endl,0;
#define Debug(x) cerr<<#x<<" = "<<x<<endl
const int inf=1e9;
const ll h1=239017;
const ll h2=731604233;
const ll mod=1000000007;
const ll mod2=1000000009;
const int dx[]={1,0,-1,0,1,0,-1,0};
const int dy[]={0,1,0,-1,1,0,-1,0};
ll n,m;
signed main()
{
	ios_base::sync_with_stdio();cin.tie();cout.tie();
	cout<<setprecision(15);
	cin>>n>>m;
	if (n>=3 && m>=3)
	{
		cout<<(n-2)*(m-2)<<endl;
		return 0;
	}
	if (n==1 && m==1)
	{
		cout<<1<<endl;
		return 0;
	}
	if (n==1)
	{
		cout<<m-2<<endl;
		return 0;
	}
	if (m==1)
	{
		cout<<n-2<<endl;
		return 0;
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var par []int
var rank []int

func root(x int) int {
	if par[x] == x {
		return x
	}
	par[x] = root(par[x])
	return par[x]
}

func unite(x, y int) {
	xr := root(x)
	yr := root(y)
	if xr == yr {
		return
	}

	if rank[xr] > rank[yr] {
		par[yr] = xr
	} else {
		par[xr] = yr
		if rank[xr] == rank[yr] {
			rank[yr]++
		}
	}
}

func main() {
	n := readInt()
	m := readInt()
	par = make([]int, n)
	rank = make([]int, n)
	for i := range par {
		par[i] = i
		rank[i] = 0
	}

	for i := 0; i < m; i++ {
		x := readInt()
		y := readInt()
		readInt()
		x--
		y--
		unite(x, y)
	}

	roots := make(map[int]struct{})
	for i := range par {
		roots[root(par[i])] = struct{}{}
	}

	fmt.Println(len(roots))
}


Measured memory_bytes: 5888
#include<stdio.h>
int main(){
 int m,n,k,h;
 int i,j;
 int A[101][101];
 int B[101][101];
 long C[101][101]={0};

/*m,n,k???????????????*/
 scanf("%d %d %d",&m,&n,&k);

/*??????A???????????????*/
 for(i=1;i<=m;i++){

   for(j=1;j<=n-1;j++){
     scanf("%d ",&A[i][j]);
    }
     scanf("%d\n",&A[i][n]);

 }

/*??????B???????????????*/
 for(i=1;i<=n;i++){

    for(j=1;j<=k-1;j++){
      scanf("%d ",&B[i][j]);
     }
     scanf("%d\n",&B[i][k]);
 
  }

/*?????????????¨????*/

 for(i=1;i<=m;i++){
 
  for(j=1;j<=k;j++){

   for(h=1;h<=n;h++){
    C[i][j]+=A[i][h]*B[h][j];
  }

  }
 }

/*C?????¨???*/
 for(i=1;i<=m;i++){

  for(j=1;j<=k-1;j++){
   printf("%ld ",C[i][j]);
  }
   printf("%ld\n",C[i][k]);

 }

return 0;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int x;
    cin>>x;
    int i = 0;
    int sum = 0;
    while(1){
        i++;
        sum += i;
        if(sum >= x) break;
    }
    cout << i << endl;
    return 0;
    
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		Structure[] s = new Structure[n];
		
		for(int i = 0; i < n; i++){
		    s[i] = new Structure(i + 1, sc.nextInt());
		}
		Arrays.sort(s);
		
		// 計算
		//int result = 0;

		// 出力
		for(int i = 0; i < n; i++){
		    System.out.print(s[i].id + " ");
		}
        
	}
}

class Structure implements Comparable<Structure> {
	int id;
	int num;

	Structure(int n, int s) {
		this.id = n;
		this.num = s;
	}

	@Override
	public int compareTo(Structure obj) {
	    // this > obj => 1
	    // this < obj => -1
	    // this == obj => 0
	    int order = 0;
	    
	    order = Integer.compare(this.num, obj.num);

		return order;
	}

	public String toString() {
		return String.valueOf(id);
	}
}

Measured memory_bytes: 67108
import java.util.*;
import java.math.BigDecimal;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    if (N % 500 <= A) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 20948
def resolve():
    n = int(input())
    x = list(map(int, input().split()))
    ans = float("inf")
    for i in range(101):
        a = 0
        for j in range(n):
            a += (i - x[j]) ** 2
        ans = min(ans, a)
    print(ans)


if __name__ == '__main__':
    resolve()


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

int main(){
  int a;
  cin >> a;
  for(int i=1;i<=9;i++){
    if(a%i!=0){
      if(i==9){
          cout << "No" <<endl;
          break;
        }
      continue;
    }
    else{
      if(a/i>=10){
        if(i==9){
          cout << "No" <<endl;
          break;
        }
        continue;
      }
      else{
        cout << " Yes" <<endl;
        break;
      }
    }
  }
}
      

Measured memory_bytes: 256