akhauriyash/Code-Regression huggingface dataset:
H, W, D = (int(i) for i in input().split())

dd = [[(-1,-1)] * (H * W // D + 1) for i in range(D)]

for i in range(H):
    ww = [int(j) for j in input().split()]
    for j in range(len(ww)):
        dd[(ww[j] - 1)%D][(ww[j] - 1)//D] = (i, j)

dds = [[0] * (H * W // D + 1) for i in range(D)]

for i in range(D):
    for j in range(1, len(dd[i])):
        if dd[i][j] != (-1, -1):
            temp = abs(dd[i][j][0] - dd[i][j-1][0]) + abs(dd[i][j][1] - dd[i][j-1][1])
            dds[i][j] = dds[i][j-1] + temp
        else:
            pass

Q = int(input())
for i in range(Q):
    l, r = ( int(i) for i in input().split())
    print( dds[(r-1)%D][(r-1)//D] - dds[(l-1)%D][(l-1)//D] )

Measured memory_bytes: 71660
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

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

signed main() {
    solve();
    
    return 0;
}

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


def solve(N: int, M: int, A: "List[int]"):
    c = dict()
    c[0] = 1
    total = 0
    res = 0
    for a in A:
        total = (total + a) % M
        if total in c:
            c[total] += 1
        else:
            c[total] = 1
        res += c[total] - 1
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19892
x,n = map(int,input().split())
l = list(map(int,input().split()))
s = set(l)
o = []
d = {}
for i in range(-1000,1000):
    if i not in s:
        g = abs(i-x)
        o.append(g)
        if g in d:
            h = d[g]
            h.append(i)
            d[g] = h

        else:
            d[g] = [i]

o.sort()
k = o[0]
n = d[k]
n.sort()
print(n[0])

Measured memory_bytes: 65676
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
template <typename T>
inline void w(T x) {
	if (x > 9) w(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x, char c) {
	w(x);
	putchar(c);
}
template <typename T>
inline void read(T &x) {
	x = 0;
	T f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
int main(){
	char s[N];
	cin >> s;
	for(int i = 0; i < strlen(s); i++){
		if(s[i] == '7'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");

	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

ll s[200000],mx,n;
sltr itr;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    for(int c=1;c<n;c++){
        ll score = 0;
        sll z;
        for(int k=0; k<=2*n; k++){
            if(k*c >=n )break;
            ll a = (n-1)-k*c;
            ll d = k*c;

            ll b = a - c;
            if(b<=0)break;
            if(z.count (a))break;
            else{
                z.insert(a);
            }
            score += s[a];

            if(z.count(d))break;
            else{
                z.insert(d);
            }
            score += s[d];

            mx = max(mx,score);

        }
    }
    cout<<mx<<newl;


}



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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 

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

bool is_prime(ll n){
    int a = sqrt(n);
    if(n == 1 || n == 2 || n == 3) return true;
    else{
        bool frag = true;
        FOR(i, 2, a+1){
            if(n % i == 0) frag = false;
        }
        return frag;
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b;
    int j=0;
    vector<ll> p;
    cin >> a >> b;
    ll g;
    if(a >= b) g = gcd(a, b);
    else g = gcd(b, a);
    if(g == 1){}
    else if(is_prime(g)){p.PB(g);}
    else{
      while(g % 2 == 0){p.PB(2); g /= 2;}
      int i = 3;
      ll gg = g;
      while(pow(i, 2) <= g){
        while(gg % i == 0){gg /= i; p.PB(i);}
        i += 2;
        if(gg == 1) break;
      }
      if(gg != 1) p.PB(g);
    }
    set<ll> ans;
    REP(i, p.size()) ans.insert(p[i]);
    cout << ans.size()+1 << endl;
}

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

int main(){
	int n,fg=0,ts=0,tx=0,ty=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		int t,x,y;
		scanf("%d %d %d",&t,&x,&y);
		int ans = abs(x - tx) + abs(y - ty);
		if(t - ts >= ans){
			if((t - ts + ans) % 2 == 0){
				fg=1;
			}
			else if(t - ts == ans){
				fg=1;
			}
			else{
				fg=0;
			}
		}
		else{
			fg=0;
		}
		ts = t;
		tx = x;
		ty = y;
	}
	if(fg){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
while True:
    a = 0
    n, x = [int(i) for i in input().split()]
    if n == x == 0:
        break

    s = 1
    m = s+1
    while not m == n:
        for e in range(m+1,n+1):
            result = s+m+e
            if result == x:
                a += 1
        m += 1
        if m == n:
            s += 1
            m = s+1

    print(a)

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

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

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int A,B,C,X; cin >> A >> B >> C >> X;
	int ans = 0;
	rep(i,A+1)rep(j,B+1)rep(k,C+1){
		if(500*i+100*j+50*k == X) ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
package main

// Solution for https://atcoder.jp/contests/abc173/tasks/abc173_e

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

const mod = 1e9 + 7

func (con *contest) main() error {
	var N, K int
	con.Scan(&N, &K)
	pos := make([]int, 0, N)
	neg := make([]int, 0, N)
	zero := 0
	for i := 0; i < N; i++ {
		var a int
		con.Scan(&a)
		if a > 0 {
			pos = append(pos, a)
		}
		if a < 0 {
			neg = append(neg, -a)
		}
		if a == 0 {
			zero++
		}
	}
	sort.Slice(pos, func(i, j int) bool { return pos[i] > pos[j] })
	sort.Slice(neg, func(i, j int) bool { return neg[i] > neg[j] })
	sum, i, j, k := 1, 0, 0, K
	for k > 1 {
		if i+1 < len(pos) && j+1 < len(neg) {
			if pos[i]*pos[i+1] > neg[j]*neg[j+1] {
				sum *= pos[i]
				sum %= mod
				sum *= pos[i+1]
				sum %= mod
				i += 2
			} else {
				sum *= neg[j]
				sum %= mod
				sum *= neg[j+1]
				sum %= mod
				j += 2
			}
		} else if i+1 < len(pos) {
			sum *= pos[i]
			sum %= mod
			sum *= pos[i+1]
			sum %= mod
			i += 2
		} else if j+1 < len(neg) {
			sum *= neg[j]
			sum %= mod
			sum *= neg[j+1]
			sum %= mod
			j += 2
		} else {
			break
		}
		k -= 2
	}
	if k == 0 {
		con.Println(sum)
		return nil
	}
	if k == 1 && i < len(pos) {
		sum *= pos[i]
		sum %= mod
		con.Println(sum)
		return nil
	}
	if zero > 0 {
		con.Println(0)
		return nil
	}
	for i, j := 0, len(pos)-1; i < j; i, j = i+1, j-1 {
		pos[i], pos[j] = pos[j], pos[i]
	}
	for i, j := 0, len(neg)-1; i < j; i, j = i+1, j-1 {
		neg[i], neg[j] = neg[j], neg[i]
	}
	sum, i, j, k = 1, 0, 0, K
	for k > 0 {
		if i < len(pos) && j < len(neg) {
			if pos[i] < neg[j] {
				sum *= pos[i]
				sum %= mod
				i++
			} else {
				sum *= neg[j]
				sum %= mod
				j++
			}
		} else if i < len(pos) {
			sum *= pos[i]
			sum %= mod
			i++
		} else if j < len(neg) {
			sum *= neg[j]
			sum %= mod
			j++
		}
		k--
	}
	con.Println(mod - sum)
	return nil
}


Measured memory_bytes: 6772
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n,m;
  int x,y;
  int i,j;

  while(true){
    cin>>n;
    if(n==0)break;

    int grid[25][25]={};
    rep(i,n){
      cin>>x>>y;
      grid[y][x]++;
    }
    scanf("%d\n",&m);
    x=10;
    y=10;
    rep(i,m){
      char d;
      int l;
      scanf("%c %d\n",&d,&l);
 
      if(d=='N'){
	for(j=y;j<=y+l;j++)
	  grid[j][x]=0;
	y=y+l;
      }else if(d=='S'){
	for(j=y;j>=y-l;j--)
	  grid[j][x]=0;
	y=y-l;
      }else if(d=='E'){
	for(j=x;j<=x+l;j++)
	  grid[y][j]=0;
	x=x+l;
      }else if(d=='W'){
	for(j=x;j>=x-l;j--)
	  grid[y][j]=0;
	x=x-l;
      }
    }

    int ans=0;
    rep(i,23)rep(j,23)
      if(grid[i][j])
	ans++;
    if(ans)
      cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
  }

}

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

const int N = 100005;

int n, a[N], b[N];

void ins(int x) {
	for (int i = 30; i >= 0; i--) {
		if (x>>i&1) {
			if (b[i]) x ^= b[i];
			else {
				b[i] = x;
				break;
			}
		}
	}
}

int main() {
	scanf("%d", &n);
	int tot = 0, x;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x);
		tot ^= x;
		ins(x^(x - 1));
	}
	int ans = 0;
	for (int i = 30; i >= 0; i--) {
		if (tot>>i&1) {
			if (b[i]) {
				ans++;
				tot ^= b[i];
			}
		}
	}
	if (tot) printf("-1\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 55;
ll n, k, arr[N];
ll solve2(priority_queue<ll>pq, ll rem)
{
    ll sum = 0;
    while(pq.size() && rem && pq.top() > 0)
    {
        pq.pop();
        --rem;
    }
    while(pq.size())
    {
        sum += -pq.top();
        pq.pop();
    }
    return sum;
}
ll solve(int sz)
{
    ll mx = -1e18, rem = k;
    priority_queue<ll>pq;
    for(int i = 0;i < sz;++i)
    {
        pq.push(-arr[i]);
        rem--;
        mx = max(mx, solve2(pq, rem));
    }
    for(int i = n - 1;i >= 0 && i >= sz && rem;--i)
    {
        pq.push(-arr[i]);
        rem--;
        mx = max(mx, solve2(pq, rem));
    }
    return mx;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll mx = -1e18;
    cin >> n >> k;
    for(int i = 0;i < n;++i)
        cin >> arr[i];
    for(int i = 0;i <= min(n, k);++i)
    {
        mx = max(mx, solve(i));
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int N,M;
	cin>>N>>M;
	if((N==1)&&(M==1)){
		cout<<1<<endl;
	}
	else if((N==1)&&(M!=1)){
		cout<<M-2<<endl;
	}
	else if((N!=1)&&(M==1)){
		cout<<N-2<<endl;
	}
	else if((N!=1)&&(M!=1)){
		cout<<((N-2)*(M-2))<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b;
  char c;
  for(int i=0; i<100000; i++) {
      cin >> a >> c >> b;
      if(c=='+') {
          cout << a+b << endl;
      }
      else if(c=='-') {
          cout << a-b << endl;
      }
      else if(c=='*') {
          cout << a*b << endl;
      }
      else if(c=='/') {
          cout << a/b << endl;
      }
      else {
          return 0;
      }
  }
}


Measured memory_bytes: 3108
#include<stdio.h>
int main()
{
    int A,B,C,K,sum,max,i;
    while(scanf("%d %d %d",&A,&B,&C)!=EOF)

    {
        scanf("%d",&K);
        if(A>=B)
        {
            if(A>=C)
                max=A;
            else
                max=C;
        }
        else if(A>=C)
        {
            if(A>=B)
                max=A;
            else
                max=B;
        }
        else
        {
            if(B>=C)
                max=B;
            else
                max=C;
        }

        sum=max;
        for(i=1; i<=K; i++)
            sum=sum*2;

        sum=sum+A+B+C-max;
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  stack<int>S1;
  stack<pair<int,int> >S2;
  char ch;
  int sum=0;

  for(int i=0;cin>>ch;i++){
    if(ch=='\\')S1.push(i);
    else if(ch=='/' && S1.size()>0){
      int j=S1.top();
      S1.pop();
      sum+=i-j;
      int a=i-j;
      while(S2.size()>0 && S2.top().first>j){
        a+=S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }

  vector<int> ans;
  while(S2.size()>0){
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(),ans.end());
  cout<<sum<<endl;
  cout<<ans.size();
  for(int i=0;i<ans.size();i++){
    cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;

  return 0;
}




Measured memory_bytes: 3200
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    s = list(input())
    t = list(input())

    ans = 0
    for i in range(len(s)):
        if s[i] == t[i]:
            continue
        ans += 1

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """cupofcoffee
cupofhottea"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """abcde
bcdea"""
        output = """5"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """apple
apple"""
        output = """0"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N); 
    for(int i=0;i<N;i++) cin >> vec[i];
    for(int i=0;i<N;i++){
        if(vec[i]%2==0){
            if(vec[i]%3==0 || vec[i]%5==0){
                continue;
            }
            else{
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt();
		List<String> arr = new ArrayList<>();
		for (int i = 0; i < a; i++) {
			arr.add(sc.next());
		}
		arr = arr.stream().distinct().collect(Collectors.toList());
		System.out.println(arr.size());
	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

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

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

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

			return tokenizer.nextToken("\n");
		}

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

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

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

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

Measured memory_bytes: 72732
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define MAXN 2005
#define MOD 998244353
int main()
{
     ll a,b,n;
     cin>>a>>b>>n;
     ll x=min(b-1,n);
     cout<<floor((a*x)/b)<<e;
}





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

using namespace std;

struct Dice {
    Dice(const vector<int>& v) : v(v) {
        for (int i = 0; i < v.size(); i++) {
            im[v[i]] = i;
        }
        m[0] = {1, 2, 4, 3};
        m[1] = {5, 2, 0, 3};
        m[2] = {5, 4, 0, 1};
        m[3] = {5, 1, 0, 4};
        m[4] = {0, 2, 5, 3};
        m[5] = {1, 3, 4, 2};
    };
    vector<int> v;
    map<int, int> im;
    map<int, vector<int> > m;
    void n() {
        int tmp = v[0];
        v[0] = v[1];
        v[1] = v[5];
        v[5] = v[4];
        v[4] = tmp;
    }
    void s() {
        int tmp = v[0];
        v[0] = v[4];
        v[4] = v[5];
        v[5] = v[1];
        v[1] = tmp;
    }
    void e() {
        int tmp = v[0];
        v[0] = v[3];
        v[3] = v[5];
        v[5] = v[2];
        v[2] = tmp;
    }
    void w() {
        int tmp = v[0];
        v[0] = v[2];
        v[2] = v[5];
        v[5] = v[3];
        v[3] = tmp;
    }
    int right(int top, int front) {
        top = im[top];
        front = im[front];
        vector<int> mv = m[top];
        for (int i = 0; i < mv.size(); i++) {
            if (front == mv[i]) {
                if (i == mv.size() - 1) {
                    return v[mv[0]];
                } else {
                    return v[mv[i + 1]];
                }
            }
        }
        return 0;
    }
};

int main() {
    vector<int> v(6);
    for (int i = 0; i < v.size(); i++) {
        cin >> v[i];
    }
    Dice dice(v);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int top, front;
        cin >> top >> front;
        cout << dice.right(top, front) << endl;
    }
    return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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(){
    long long X;
    scanf("%lld",&X);
    bool f=false;
    ll a,b;
    for (long long i = -118; i <= 119; i++) {
        for (long long j = -188; j <= 119; j++) {
            if(i*i*i*i*i - j*j*j*j*j==X){
                f=true;
                a=i;
                b=j;
                break;
            }
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3656
#!/usr/bin/env python3
math_inf = float('inf')  # the Python of AtCoder is too old

def solve(n, m, a):
    cost = [ math_inf, 2, 5, 5, 4, 5, 6, 3, 7, 6 ]
    dp = [ None ] * (n + 1)
    dp[0] = 0
    for i in range(1, len(dp)):
        dp[i] = max([ dp[i - cost[a_i]] * 10 + a_i for a_i in a if cost[a_i] <= i ] + [ - math_inf ])
    return str(dp[n])


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


Measured memory_bytes: 14392
#include <iostream>
#include <algorithm>
#include <vector>
#include "string"

using namespace std;

typedef long long ll;

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

    ll r, D, x0;

    cin >> r >> D >> x0;

    ll tmp = x0;
    for (int i = 0; i < 10; i++) {
        tmp = r * tmp - D;
        cout << tmp << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n=k()
c = Counter(list(l())).most_common()
for i in c:
    if i[0]>i[1]:
        cnt+=i[1]
    else:
        cnt+=i[1]-i[0]

print(cnt)


Measured memory_bytes: 26176
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<ll> b(100010);
	for (ll i = 0; i < n; i++)
	{
		ll a;
		cin >> a;

		if (a <= 100000)
		{
			b[a]++;
		}
		else
		{
			b[100001]++;
		}
	}

	ll res = 0;
	for (ll i = 1; i <= 100001; i++)
	{
		if (b[i] == 0 || b[i] == i)
		{

		}
		else
		{
			res += (b[i] > i) ? b[i] - i : b[i];
		}
	}

	println(res);
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    int hh, ww; cin >> hh >> ww;
    int h, w; cin >> h >> w;
    cout << hh * ww - h * ww - hh * w + h * w << endl;
}


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

typedef long long ll;

int qi[1000005];

int main()
{
	
	int n;
	cin>>n;
	qi[1]=7%n;
	for( int i=2;i<=1e6;i++ )
	{
		qi[i]=qi[i-1]*10;
		qi[i]%=n;
	}
	ll sum=0;
	for( int i=1;i<=1e6;i++ )
	{
		sum+=qi[i];
		sum%=n;
		if( sum==0 )
		{
			cout<<i<<endl;
			return 0;
		}
	}
	puts("-1");
//	cout<<cnt<<endl;
}

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

int main() {
  ll M = 0,ans = 1;
  cin >> M;
  rep(i,M){
    ans *= i + 1;
    ans %= 1000000007;
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Peaks.
 */
public class Main {
    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        var n = Integer.parseInt(scanner.next());
        var m = Integer.parseInt(scanner.next());
        var heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = Integer.parseInt(scanner.next());
        }

        var maxHeight = new int[n];
        for (int i = 0; i < m; i++) {
            var a = Integer.parseInt(scanner.next());
            var b = Integer.parseInt(scanner.next());
            maxHeight[a - 1] = Math.max(maxHeight[a - 1], heights[b - 1]);
            maxHeight[b - 1] = Math.max(maxHeight[b - 1], heights[a - 1]);
        }
        var count = 0;
        for (int i = 0; i < n; i++) {
            if (heights[i] > maxHeight[i]) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 60004
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

char r(char s){
	if(s=='S')return 'W';
	else return 'S';
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n; 
	string s; cin >> s;
	for(int i=0;i<4;i++){
		string t="";
		if(i%2)t+='S';
		else t+='W';
		if(i%3)t+='S';
		else t+='W';
		for(int j=1;j<n-1;j++){
			if(t[j]=='S'){
				if(s[j]=='o'){
					t+=t[j-1];
				}
				else{
					t+=r(t[j-1]);
				}
			}
			else{
				if(s[j]=='o'){
					t+=r(t[j-1]);
				}
				else{
					t+=t[j-1];
				}
			}
		}
		if(t[0]=='S'){
			if(s[0]=='x'&&t[1]==t[n-1])continue;
			if(s[0]=='o'&&t[1]!=t[n-1])continue;
		}
		else{
			if(s[0]=='x'&&t[1]!=t[n-1])continue;
			if(s[0]=='o'&&t[1]==t[n-1])continue;
		}
		if(t[n-1]=='S'){
			if(s[n-1]=='o'&&t[0]!=t[n-2])continue;
			if(s[n-1]=='x'&&t[0]==t[n-2])continue;
		}
		else{
			if(s[n-1]=='o'&&t[0]==t[n-2])continue;
			if(s[n-1]=='x'&&t[0]!=t[n-2])continue;
		}
		cout << t << endl;
		return 0;
	}
	cout << -1 << endl;
}


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

signed main(){
	int H,N;
	cin>>H>>N;
	int sum=0;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		sum+=a;
	}
	cout<<((H<=sum)? "Yes":"No")<<endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 2e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;

struct rec {
	int x, y;
	inline bool operator < (const rec &v) {
		return (x == v.x) ? y > v.y : x < v.x;
	}
}a[maxN];

namespace Seg {
	static const int maxN = 524297;
	#define lc (x << 1)
	#define rc (x << 1 | 1)

	int mx[maxN], tag[maxN];

	void pushup(int x) {
		mx[x] = max(mx[lc], mx[rc]);
	}

	void totag(int x, int d) {
		mx[x] += d; tag[x] += d;
	}

	void pushdown(int x) {
		if (tag[x]) {
			totag(lc, tag[x]);
			totag(rc, tag[x]);
			tag[x] = 0;
		}
	}

	void build(int x, int l, int r) {
		tag[x] = 0;
		if (l == r) {
			mx[x] = l;
			return;
		}
		int mid = (l + r) >> 1;
		build(lc, l, mid);
		build(rc, mid+1, r);
		pushup(x);
	}

	void add(int x, int l, int r, int tl, int tr) {
		if (tl <= l && r <= tr) {totag(x, 1); return;}
		int mid = (l + r) >> 1;
		pushdown(x);
		if (tl <= mid) add(lc, l, mid, tl, tr);
		if (mid < tr) add(rc, mid+1, r, tl, tr);
		pushup(x);
	}

	int get(int x, int l, int r, int tl, int tr) {
		if (tl <= l && r <= tr) return mx[x];
		int mid = (l + r) >> 1;
		pushdown(x);
		if (tr <= mid) return get(lc, l, mid, tl, tr);
		if (mid < tl) return get(rc, mid+1, r, tl, tr);
		return max(get(lc, l, mid, tl, tr), get(rc, mid+1, r, tl, tr));
	}

	inline void build() {build(1, 0, m+1);}
	inline void add(int l, int r) {add(1, 0, m+1, l, r);}
	inline int get(int l, int r) {return get(1, 0, m+1, l, r);}

	#undef lc
	#undef rc
}

int main() {

	n = ri(), m = ri();
	rep (i, 1, n) a[i].x = ri(), a[i].y = ri();
	sort(a+1, a+n+1);
	
	int res = max(n - m, 0);
	Seg::build();
	rep (i, 1, n) {
		Seg::add(1, a[i].y);
		if (a[i].x <= m) res = max(res, Seg::get(a[i].x + 1, m + 1) - a[i].x - (m + 1));
	}
	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 5888
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let n : i32 = s.trim().parse().ok().unwrap();

    let mut k = 0;
    let mut ans = 1;
    while k*k <= n {
        ans = k*k;
        k += 1;
    }
    println!("{}", ans);
}


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

const long long MOD = 1000000000 + 7;

int main()
{
	auto& in = cin;
	long long S;
	in >> S;

	long long N[2001];
	N[0] = N[1] = N[2] = 0;
	N[3] = N[4] = N[5] = 1;
	for (int s = 6; s <= 2000; ++s) {
		long long num = 0;
		for (int s2 = 3; s2 <= s; ++s2) {
			int s3 = s - s2;
			num += N[s3];
			num %= MOD;
		}
		N[s] = num + 1;
	}
	cout << N[S];

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
string str;
int main()
{
    cin>>str;
    if(str=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(str=="Rainy")
        cout<<"Sunny"<<endl;
    else
        cout<<"Rainy"<<endl;
    return 0;
}


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

int dp[1005][1005], q[1005][1005], mod = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
     for (int j = 1; j <= m; j++){
         char c;
         cin >> c;
         if (c=='#') q[i][j] = 0, dp[i][j] = -1; else q[i][j] = 1;
     }
     
     
     
     for (int i=0; i<=n; i++)
        dp[0][i] = -1, dp[i][0] = -1;
     
     dp[1][1] = 1;
     
     for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++){
          if (q[i][j]){
              if (dp[i][j-1]!=-1){
                  dp[i][j] = (dp[i][j-1]) % mod;
              }
              if (dp[i-1][j]!=-1){
                  dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
              }
          }
      }
      
      cout<<dp[n][m];
}

Measured memory_bytes: 11444
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = ReadLine();
            if(s.Count(x=>x == 'A') > 0 && s.Count(x=>x == 'B') > 0){
                WriteLine("Yes");
            }
            else{
                WriteLine("No");
            }
        }



    }

}


Measured memory_bytes: 13268
#include <cstdio>

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

Measured memory_bytes: 256
#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.at(i);
  }
  
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  int sum=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      sum+=A.at(i);
    }else{
      sum-=A.at(i);
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
	int a,b,h; cin >> a >> b >> h;
	cout << (a+b)*h/2 << endl;
	}

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

typedef long long ll;

vector<ll> divisor(ll n) { 
  vector<ll> ret;
  for (ll i = 1; (ll)i*i <= n; ++i) { 
    if (n % i == 0) {
      ret.push_back(i);
      if (i*i != n) { ret.push_back(n/i); }
    }
  }
  sort(ret.begin(), ret.end(), greater<ll>());
  return ret;
};


int main() {
  ll n, k; cin >> n >> k;
  vector<ll> la(n);
  ll s = 0;
  for (ll &a: la) {
    cin >> a;
    s += a;
  }
  vector<ll> divs = divisor(s);
  for (ll d : divs) {
    // cerr << d << endl;
    auto check = [&](ll x){
      vector<ll> lr;
      for (ll a : la) { 
        lr.push_back(a%d);
      }
      sort(lr.begin(), lr.end());
      vector<ll> s1(n+1), s2(n+1);
      for (ll i = 0; i < n; ++i) {
        s1[i+1] += s1[i] + lr[i];
        s2[n-i-1] += s2[n-i] + d-lr[n-i-1];
      }
      for (ll i = 0; i <= n; ++i) {
        // cerr << i << " " << s1[i] << " " << s2[i] << endl;
        if (max(s1[i], s2[i]) <= k) return true;
      }
      return false;
    };
    if (check(d)) { 
      cout << d << endl;
      return 0;
    }
  }

}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a[10][10], b, c, d, e, f;
	int i, j;
	e = 0;
	f = 0;
	for(i = 0; i < 10; i++){
		for(j = 0; j < 10; j++){
			a[i][j] = 0;
		}
	}
	while(scanf("%d,%d,%d", &b, &c, &d) != EOF){
		if(d == 1){
			if(b - 1 >= 0) a[b - 1][c]++;
			a[b][c]++;
			if(b + 1 < 10)	a[b + 1][c]++;
			if(c - 1 >= 0) a[b][c - 1]++;
			if(c + 1 < 10) a[b][c + 1]++;
		}else if(d == 2){
			if(b - 1 >= 0){
				if(c - 1 >= 0) a[b - 1][c - 1]++;
				a[b - 1][c]++;
				if(c + 1 < 10) a[b - 1][c + 1]++;
			}
			a[b][c]++;
			if(c - 1 >= 0) a[b][c - 1]++;
			if(c + 1 < 10) a[b][c + 1]++;
			if(b + 1 < 10){
				if(c - 1 >= 0)a[b + 1][c - 1]++;
				a[b + 1][c]++;
				if(c + 1 < 10) a[b + 1][c + 1]++;
			}
		}else{
			if(b - 2 >= 0) a[b - 2][c]++;
			if(b - 1 >= 0){
				a[b - 1][c]++;
				if(c - 1 >= 0) a[b - 1][c - 1]++;
				if(c + 1 < 10) a[b - 1][c + 1]++;
			}
			a[b][c]++;
			if(c - 1 >= 0) a[b][c - 1]++;
			if(c + 1 < 10) a[b][c + 1]++;
			if(b + 1 < 10){
				if(c - 1 >= 0) a[b + 1][c - 1]++;
				a[b + 1][c]++;
				if(c + 1 < 10) a[b + 1][c + 1]++;
			}
			if(b + 2 < 10) a[b + 2][c]++;
			if(c - 2 >= 0) a[b][c - 2]++;
			if(c + 2 < 10) a[b][c + 2]++;
		}
	}
	for(i = 0; i < 10; i++){
		for(j = 0; j < 10; j++){
			if(a[i][j] == 0){
				e++;
			}else if(f < a[i][j]){
				f = a[i][j];
			}
		}
	}
	printf("%d\n%d\n", e, f);
	return 0;
}

Measured memory_bytes: 600
w,h,n=map(int,input().split())

up=h
down=0
left=0
right=w


for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        left=max(left,x)
    if a==2:
        right=min(right,x)
    if a==3:
        down=max(down,y)
    if a==4:
        up=min(up,y)

   
if right>left and up>down:
    print((right-left)*(up-down))
else:
    print(0)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int n,k,i,c=0;
  scanf("%d %d",&n,&k);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  while(n>1){
    n -=(k-1);
    c ++;
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    int a[N], b[N];
    REP(i, N) cin >> a[i] >> b[i];

    set<int> p[N], q[N];

    REP(i, N) {
        int c, d;
        cin >> c >> d;

        REP(j, N) {
            if (a[j] < c && b[j] < d) {
                p[j].insert(i);
                q[i].insert(j);
            }
        }
    }

    set<int> op, oq;
    REP(i, N) {
        op.insert(i);
        oq.insert(i);
    }

    int ans = 0;
    REP(i, N) {
        int m = inf;
        int k = -1;
        for (auto e: op) {
            if (p[e].size() < m) {
                m = p[e].size();
                k = e;
            }
        }
        op.erase(k);

        if (p[k].size() < 1) continue;

        ++ans;

        m = inf;
        int l = -1;
        for (auto e: p[k]) {
            if (q[e].size() < m) {
                m = q[e].size();
                l = e;
            }
        }
        oq.erase(l);

        for (auto e: op) {
            p[e].erase(l);
        }

        for (auto e: oq) {
            q[e].erase(k);
        }
    }

    cout << ans << endl;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int count = 0; 
  
  for (int i = a; i < b + 1; i++) {
    if (i / 10000 == i % 10 && (i / 1000) % 10 == (i % 100 - i % 10)/10){
      count++;
    }
  }
  
  cout << count << endl;
}
  
  

Measured memory_bytes: 256
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]

mh = max(H)
x = mh//A
y = -(-mh//B)

def judge(cnt):
    d = A-B
    tmp = 0
    for h in H:
        nh = max(h-B*cnt,0)
        tmp += -(-nh//d)
    if cnt >= tmp:
        return True
    else:
        return False

def biserch(left=x,right=y):
    while right-left>1:
        middle = (left+right) // 2
        if judge(middle) is True:
            right = middle
        else:
            left = middle
    return right

rec = biserch()
print(rec)

Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct SegTree {
    int siz;
    vector<int> node;

    SegTree(vector<int> &v) : siz(1) {
        int N = v.size();
        while (siz < N)
            siz *= 2;
        node.resize(2 * siz - 1, INT_MAX);

        for (int i = 0; i < N; ++i)
            node[i + siz - 1] = v[i];
        for (int i = siz - 2; i >= 0; --i)
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(int k, int x) {
        k += siz - 1;
        node[k] = x;
        while (k > 0) {
            k = (k - 1) / 2;
            node[k] = min(node[2 * k + 1], node[2 * k + 2]);
        }
    }

    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        if (r <= a || b <= l)
            return INT_MAX;
        if (a <= l && r <= b)
            return node[k];
        int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

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

    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    SegTree segtree(a);
    ll ans = LLONG_MAX;
    for (int i = 0; i < N; ++i) {
        ll tmp = (ll)i * x;
        for (int j = 0; j < N; ++j) {
            int l = j - i, r = j + 1;
            if (l < 0) {
                l += N;
                tmp += min(segtree.query(l, N), segtree.query(0, r));
            } else
                tmp += segtree.query(l, r);
        }
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 3588
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int point[] = new int[2];
		for (int i = 0; i < n; i++) {
			String game = sc.nextLine();
			String games[] = game.split(" ");
			if (games[0].compareTo(games[1]) == 0) {
				point[0]++;
				point[1]++;
			} else if (games[0].compareTo(games[1]) > 0) {
				point[0] += 3;
			} else {
				point[1] += 3;
			}
		}
		System.out.println(String.format("%d %d", point[0], point[1]));
	}

}

Measured memory_bytes: 31484
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N;
	string S;
	int K;
	cin >> N >> S >> K;
	char A = S.at(K - 1);
	int i;
	for (i = 0; i < N; i++) {
		if (S.at(i) != A) {
			S.at(i) = '*';
		}
	}
	cout << S;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int P,M,K;
  P = A + B;
  M = A - B;
  K = A * B;
  if(P > M){
    if(P > K){
      cout << P << endl;
    }
    else{
      cout << K << endl;
    }
  }
  else if(K > P){
    if(K > M){
      cout << K << endl;
    }
    else{
        cout << M << endl;
    }
  }
  else if(M > K){
      cout << M << endl;
  }
  else{
      cout << K << endl;
  }
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;
long double eps = 1e-9;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int t;
	cin >> t;
	while(t--){
		pair<long double, long double> cors[4];
		for(int i = 0; i < 4; i++){
			cin >> cors[i].first >> cors[i].second;
		}
		long double slope1 = (cors[1].second - cors[0].second) * (cors[3].first - cors[2].first);
		long double slope2 = (cors[3].second - cors[2].second) * (cors[1].first - cors[0].first);
		// deb(slope1, slope2);
		if(slope1 - slope2 == 0){
			cout << "YES\n";
		}
		else cout << "NO\n";
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3088