akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

gen = 2019
l, r = map(int, input().split())

for i in range(l, l+gen+1):
    if i%gen == 0:
        check = i - l

if r-l>=check:
    print(0)
    exit()

ll = min(l%gen, r%gen)
rr = max(l%gen, r%gen)

if rr-ll == 1:
    print((ll*rr)%gen)
    exit()

ans = 10**9

for i in range(ll, rr+1):
    for j in range(i+1, rr+1):
        ans = min(ans, (i*j)%gen)
print(ans)

Measured memory_bytes: 3064
import resource
import sys
from functools import lru_cache
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.reverse()
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def f(k, p):
  for a in A:
    if k >= a:
      if f(k-a, p ^ 1) == p:
        return p
  return p ^ 1

print('First' if f(K, 0) == 0 else 'Second')


Measured memory_bytes: 299612
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int ans=0;
    int n,q;
    vector<int> s;
    vector<int> t;
    cin>>n;
    for (int i=0; i<n; i++) {
        int input;
        cin>>input;
        s.push_back(input);
    }
    cin>>q;
    for (int i=0; i<q; i++) {
        int input;
        cin>>input;
        t.push_back(input);
    }
    for (int i=0; i<q; i++) {
        for (int j=0; j<n; j++) {
            if (t[i] == s[j]) {
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1320
import java.util.*;
public class Main{
	static String ACJudge(String s){
		if(s.charAt(0)!='A')return "WA";
		int count = 0;
		int idx = 0;
		for(int i=2; i<s.length()-1; i++){
			if(s.charAt(i)=='C'){
				count++;
				idx = i;
			}
		}
		if(count!=1)return "WA";
		String t = s.toLowerCase();
		if(!s.substring(1, idx).equals(t.substring(1, idx)))return "WA";
		if(!s.substring(idx+1).equals(t.substring(idx+1)))return "WA";
		return "AC";
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		System.out.println(ACJudge(st));
	}
}

Measured memory_bytes: 23124
#include <iostream>

int main()
{
	int a, b, c, x, y, min0, min1, max0, max1, sum[3];
	std::cin >> a >> b >> c >> x >> y;
	if(x < y)
	{
		min0 = x;
		min1 = a;
		max0 = y;
		max1 = b;
	}else{
		min0 = y;
		min1 = b;
		max0 = x;
		max1 = a;
	}
	sum[0] = min0 * 2 * c;
	sum[0] += (max0 - min0) * max1;

	sum[1] = a * x + b * y; 

	sum [2] = max0 * 2 * c;

	if(sum[0] < sum[1] && sum[0] < sum[2])
	{
		std::cout << sum[0] << std::endl;
	}else if(sum[1] < sum[0] && sum[1] < sum[2])
	{
		std::cout << sum[1] << std::endl;
	}else{
		std::cout << sum[2] << std::endl;
	}

}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
    auto HWN = s_.split.map!(to!int)();
    immutable H=HWN[0], W=HWN[1], N=HWN[2];
    bool[int[2]] ps;
    foreach(_;0..N) {
        auto ab = readln.split.map!(to!int);
        immutable a=ab[0], b=ab[1];
        ps[[a,b]]=true;
    }
    bool[int[2]] u;
    auto c=new long[10];
    foreach(ref v,_;ps) {
        foreach(a;max(1,v[0]-2)..min(H-1,v[0]+1))
            foreach(b;max(1,v[1]-2)..min(W-1,v[1]+1)) {
                immutable int[2] p = [a,b];
                if(p !in u) {
                    u[p]=true;
                    int n=0;
                    foreach(i;a..a+3) foreach(j;b..b+3) {
                        immutable int[2] q = [i,j];
                        if(q in ps) ++n;
                    }
                    ++c[n];
                }
            }
    }
    c[0] = (H-2)*(W-2).to!long()-u.length;
    return c.map!(to!string).join("\n");
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 62332
h,w,k = map(int, input().split())
A = [list(input()) for i in range(h)]

n = 0
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for x in range(h):
            for y in range(w):
                if i >> x & 1 and j >> y & 1:
                    if A[x][y] == '#':
                        cnt += 1
        if cnt == k:
            n += 1
print(n)


Measured memory_bytes: 9204
# 複雑な全探索

a_max = gets.to_i # 500
b_max = gets.to_i # 100
c_max = gets.to_i # 50
x = gets.to_i

count = 0

for a in 0..a_max
    for b in 0..b_max
        for c in 0..c_max
            if 500*a + 100*b + 50*c == x
                count += 1
            end
        end
    end
end

p count

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

using namespace std;

int main()
{
    deque<char>d;

    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')d.push_back('0');
        else if(s[i]=='1')d.push_back('1');
        else if(!d.empty())d.pop_back();
    }
    for(auto p:d)cout<<p;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
def inpl(): return list(map(int, input().split()))

N = int(input())
A = [0] + inpl()
D = [0]*(N+1)

for i in range(N, 0, -1):
    D[i] = (sum(D[2*i::i])%2)^A[i]
print(sum(D))
print(*[i for i in range(N+1) if D[i]])

Measured memory_bytes: 13108
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int n;
void func(int c, string s) {
	if (s.size() == n) {
		cout << s << endl;
		return;
	}
	REP(i, c + 1) {
		if (i == c) {
			func(c + 1, s + (char)('a' + i));
		}
		else {
			func(c, s + (char)('a' + i));
		}
	}
}

int main() {
	cout << fixed << setprecision(10);
	cin >> n;

	func(1, "a");

	return 0;
}

Measured memory_bytes: 1536
// Problem : B - Frog 2
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define tc ll t;cin>>t;while(t--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF 1e18

int main()
{
	io;
	ll n,k;
	cin>>n>>k;
	cinv(h,n);
	vll dp(n,INF);
	dp[0]=0;
	FOR(i,0,n)
	{
		FOR(j,1,k+1)
		{
			if(i+j>=n){break;}
			dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout<<dp[n-1];
	return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n;
    cin >> n;

    bool found = false;
    for (int i = 0; i <= (n / 4); i++) {
        for (int j = 0; j <= (n / 7); j++) {
            if (4 * i + 7 * j == n) {
                found = true;
                break;
            }
        }
        if (found) break;
    }

    cout << (found ? "Yes" : "No") << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	int sum = 0;
	rep(i,n){
		int x;
		cin >> x;
		sum += min(abs(k-x)*2,x*2);
	}
	cout << sum << '\n';
	return 0;
}


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

typedef long long ll;
#define mod 1000000007

// debug fn.
template<typename T>
void deb(initializer_list<T> l)
{
    for (auto &e : l)
        cout << e << ' ';
    cout << endl;
}

void solve(){
    int a;
    cin>>a;
    cout<<a + (a*a) + (a*a*a);
}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define int long long
// iteration and input/output stream
#define rep(i,a,b) for(int i = a;i<=b;i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
 
typedef long long ll; // 64 bit integer
typedef unsigned long long ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
 
vi h;
vi dp;
int n;

int f(int i)
{
    if(i<=0)return 0;
    if(dp[i]!=-1) return dp[i];
    if(i==1)
    {
        return dp[i] = 0;
    }
    else if(i==2)
    {
        return dp[i] = abs(h[i]-h[i-1]) + f(i-1);
    }
    else
    {
        return dp[i] = min(abs(h[i]-h[i-1])+f(i-1),abs(h[i]-h[i-2])+f(i-2));
    }
}

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    cin>>n;
    dp.resize(n+1,-1);
    h.resize(n+1,0);
    for (int i = 1; i <= n; i++)
    {
        cin>>h[i];
    }
    cout<<f(n)<<"\n";
    return 0;
}

Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


vint e[100005];
vint T, A;
void A_dfs(int v, int c) {
    A[v] = c;
    for (int u : e[v]) {
        if (A[u] == -1) A_dfs(u, c+1);
    }
}

void T_dfs(int v, int c) {
    T[v] = c;
    for (int u : e[v]) {
        if (T[u] == -1) T_dfs(u, c+1);
    }
}

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    --u;
    --v;
    T.resize(n, -1);
    A.resize(n, -1);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    T_dfs(u, 0);
    A_dfs(v, 0);
    int ans = 0;
    rep(i, n) if (T[i] < A[i]) ans = max(ans, A[i]-1);

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

Measured memory_bytes: 9088
#c
N,Q = list(map(int,input().split()))
S = input()
L = []
R = []
for i in range(Q):
    a = list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
   
    if S[i] == "A" :
        A_flag = True
    else:
        A_flag = False
    S_count.append(count)

for i in range(Q):
    print(S_count[R[i] - 1] - S_count[L[i] - 1])

Measured memory_bytes: 14240
def inpl(): return [int(i) for i in input().split()]

N,A,B = inpl()
Xi = inpl()
dist =[]
ans = 0
for i in range(N-1):
    dist.append(Xi[i+1]-Xi[i])
for i in range(N-1):
    if dist[i]*A <B:
        ans += dist[i]*A
    else:
        ans += B

print(ans)

Measured memory_bytes: 14480
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e8+7;


void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)
 
  
int main()
{
    char x;
    cin>>x;
    
    if((int)x>=97&&(int)x<=122)
    cout<<"a";
    
    else
    cout<<"A";
    
    
    
    
            
}

Measured memory_bytes: 3620
//ラブライブ！サンシャイン！！
//AT2274 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=9223372036854775807ll;

struct line{
    ll k,b;
    line(ll k=0,ll b=0):k(k),b(b){}
    ll get(ll x){return k*x+b;}
}st[300010],u;

int tp;

double its(line a,line b){
    return (b.b-a.b)/double(a.k-b.k);
}

int t[300010],n;
ll s[300010],f[300010],g[300010];
void dp(ll*f)
{
    for(int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
    tp=1;
    st[1]=line(0,0);
    for(int i=1;i<=n;i++)
	{
        while(tp>1&&st[tp].get(i)<=st[tp-1].get(i)) tp--;
        f[i]=max(st[tp].get(i)+((ll)i*i+i)/2-s[i],f[i-1]);
        u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
        while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1])) tp--;
        st[++tp]=u;
    }
}
ll h[300010];
void solve(int l,int r)
{
    if(l==r)
	{
        h[l]=f[l-1]+g[l+1]+1-t[l];
        return;
    }
    int mid,i,now;
    ll mx;
    mid=(l+r)>>1;
    solve(l,mid);
    solve(mid+1,r);
    tp=0;
    for(int i=l-1;i<mid;i++)
	{
        u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
        while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1])) tp--;
        st[++tp]=u;
    }
    now=1;
    mx=-inf;
    for(i=r;i>mid;i--)
	{
        while(now<tp&&its(st[now],st[now+1])>=i)now++;
        mx=max(mx,st[now].get(i)+((ll)i*i+i)/2-s[i]+g[i+1]);
        h[i]=max(h[i],mx);
    }
    tp=0;
    for(i=mid+1;i<=r;i++)
	{
        u=line(-i,g[i+1]+((ll)i*i+i)/2-s[i]);
        while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1]))tp--;
        st[++tp]=u;
    }
    now=tp;
    mx=-inf;
    for(i=l-1;i<mid;i++)
	{
        while(now>1&&its(st[now],st[now-1])<=i)now--;
        mx=max(mx,st[now].get(i)+((ll)i*i-i)/2+s[i]+f[i]);
        h[i+1]=max(h[i+1],mx);
    }
}
int main()
{
    int m,x,y;
    cin>>n;
    for(int i=1;i<=n;i++)
		scanf("%d",&t[i]);
    dp(f);
    reverse(t+1,t+n+1);
    dp(g);
    reverse(t+1,t+n+1);
    reverse(g+1,g+n+1);
    for(int i=1;i<=n;i++)
		s[i]=s[i-1]+t[i];
    solve(1,n);
    scanf("%d",&m);
    while(m--)
	{
        scanf("%d%d",&x,&y);
        printf("%lld\n",max(f[x-1]+g[x+1],h[x]+t[x]-y));
    }
    return 0;
}

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

int main() {
  map<int, int> mi;
  int N;
  cin >> N;
  int tmp;
  rep(i, N-1) {
    cin >> tmp;
    ++mi[tmp];
  }

  rep(i, N) {
    cout << mi[i+1] << "\n";
  }
  return 0;
}


Measured memory_bytes: 12980
package main

import (
	"fmt"
)

func main() {
	var h int
	var w int
	var hd int
	var wd int
	fmt.Scan(&h)
	fmt.Scan(&w)
	fmt.Scan(&hd)
	fmt.Scan(&wd)

	fmt.Println((h - hd) * (w - wd))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    ll sum = 0LL;
    bool zeroflg = false;
    ll cntminus = 0;
    ll minv = 1000000000000LL;

    for(int i=0; i<N; i++){
        ll v; cin >> v;

        sum += abs(v);
        if(v == 0) zeroflg = true;
        if(v < 0) cntminus++;
        minv = min(minv, abs(v));
    }

    if(zeroflg == true){
        cout << sum << endl;
    }
    else if(cntminus%2 == 0){
        cout << sum << endl;
    }
    else{
        cout << sum-2*minv << endl;
    }

}

Measured memory_bytes: 384
#include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int op(int a, int b) { return max(a, b); }
int e() { return -1; }

int x, v, l, r;

bool f(int x) { return x < v; }

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

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    atcoder::segtree<int, op, e> seg(a);

    while(q--) {
        int t;
        cin >> t;
        if(t == 1) {
            cin >> x >> v;
            x--;
            seg.set(x, v);
        }
        if(t == 2) {
            cin >> l >> r;
            cout << seg.prod(l - 1, r) << "\n";
        }
        if(t == 3) {
            cin >> x >> v;
            x--;
            cout << seg.max_right<f>(x) + 1 << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 6104
#include<bits/stdc++.h>
using namespace std;
#define r(i,asd) for(int i=0;i<asd;i++)
int main(){
  int n;
  cin>>n;
  while(n--){
    int a[6],b[6],l=0;
    r(i,6)cin>>a[i];
    for(int i=1;i<=13;i++){
      if(i==7)continue;
      else{
        int c=0;
        r(j,6)if(a[j]==i)c++;
        if(!c)b[l++]=i;}
    }
    pair<int,int>me[6],en[6];
    int a1[2]={},b1[2]={};
    int a2=14,a3=0,b2=14,b3=0,amax,bmax;
    r(i,6){
      if(0<=a[i]&&a[i]<=6)a1[0]++;
      else a1[1]++;
      if(0<=b[i]&&b[i]<=6)b1[0]++;
      else b1[1]++;
    }
    r(i,6){
      a2=min(a2,a[i]);
      a3=max(a3,a[i]);
      b2=min(b2,b[i]);
      b3=max(b3,b[i]);
    }
    if(abs(a2-7)>abs(a3-7))amax=0;
    else if(abs(a2-7)<abs(a3-7))amax=1;
    else amax=2;
    if(abs(b2-7)>abs(b3-7))bmax=0;
    else if(abs(b2-7)<abs(b3-7))bmax=1;
    else bmax=2;
    r(i,6){
      if(a[i]==1||a[i]==13)me[i]=make_pair(7,a[i]);
      if(a[i]==2||a[i]==12)me[i]=make_pair(8,a[i]);
      if(a[i]==3||a[i]==11)me[i]=make_pair(9,a[i]);
      if(a[i]==4||a[i]==10)me[i]=make_pair(10,a[i]);
      if(a[i]==5||a[i]==9)me[i]=make_pair(11,a[i]);
      if(a[i]==6||a[i]==8)me[i]=make_pair(12,a[i]);
      if(b[i]==1||b[i]==13)en[i]=make_pair(7,b[i]);
      if(b[i]==2||b[i]==12)en[i]=make_pair(8,b[i]);
      if(b[i]==3||b[i]==11)en[i]=make_pair(9,b[i]);
      if(b[i]==4||b[i]==10)en[i]=make_pair(10,b[i]);
      if(b[i]==5||b[i]==9)en[i]=make_pair(11,b[i]);
      if(b[i]==6||b[i]==8)en[i]=make_pair(12,b[i]);
    }
    r(i,6){
      if(amax==0&&me[i].second<7)me[i].first-=6;
      else if(amax==1&&me[i].second>7)me[i].first-=6;
      if(bmax==0&&en[i].second<7)en[i].first-=6;
      else if(bmax==1&&en[i].second>7)en[i].first-=6;
    }
    sort(me,me+6);
    sort(en,en+6);
    //r(i,6)cout<<en[i].second<<endl;
    bool table[15]={0};
    bool p1[6]={0},p2[6]={0};
    r(i,6)p1[i]=p2[i]=0;
    r(i,15)table[i]=0;table[7]=1;
    while(1){
      r(j,6)
      if(!p1[j]&&(table[me[j].second+1]||table[me[j].second-1])){
      p1[j]=1;
      table[me[j].second]=1;
      break;
    }
    r(j,6)
      if(!p2[j]&&(table[en[j].second+1]||table[en[j].second-1])){
        p2[j]=1;
        table[en[j].second]=1;
        break;
      }
      int c1=0,c2=0;
      r(i,6){if(!p1[i])c1++;}
      r(i,6)if(!p2[i])c2++;
      //cout<<c1<<endl;
      //cout<<c2<<endl;
      if(!c1){cout<<"yes"<<endl;break;}
      if(!c2){cout<<"no"<<endl;break;}
    }
  }
}

Measured memory_bytes: 3092
#include <iostream>
#include <utility>

using namespace std;

struct Card
{
    char pic;
    unsigned int val;
    int order;
};

void quick_sort(Card *, int, int);

int partition(Card *cards, int l, int r)
{
    Card pivot = cards[r];
    int i = l - 1;

    for (int j = l; j < r; j++) {
        if (cards[j].val <= pivot.val)
            swap(cards[++i], cards[j]);
    }

    swap(cards[++i], cards[r]);
    
    return i;
}

void quick_sort(Card *cards, int l, int r)
{
    if (l < r) {
        int p = partition(cards, l, r);
        quick_sort(cards, l, p - 1);
        quick_sort(cards, p + 1, r);
    }
}

void print_cards(Card *cards, int n)
{
    for (int i = 0; i < n; i++)
        cout << cards[i].pic << " " << cards[i].val << endl;
}

bool is_stable(Card *cards, int n)
{
    for (int i = 1; i < n; i++)
        if (cards[i-1].val == cards[i].val && cards[i-1].order > cards[i].order)
            return false;

    return true;
}

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

    int n;
    Card cards[100000];

    cin >> n;

    for (int i = 0; i < n; i++) {
        char pic;
        unsigned int val;
        cin >> pic >> val;
        cards[i] = Card{pic, val, i};
    }

    quick_sort(cards, 0, n-1);

    cout << (is_stable(cards, n) ? "Stable" : "Not stable") << endl;
    print_cards(cards, n);
    
    return 0;
}

Measured memory_bytes: 2368
#include <iostream>

int main()
{
  int H, N;
  std::cin >> H >> N;
  int sum = 0;
  for (int i=0; i<N; i++) {
    int A;
    std::cin >> A;
    sum += A;
  }
  if (sum >= H) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int money(int m){
int money=1150;
if(m<=10)return money;
if(m<=20&&m>10)return money+125*(m-10);
if(m<=30&&m>20)return money+10*125+140*(m-20);
if(m>30)return money+10*125+10*140+160*(m-30);
}
int main(){
int w;
while(true){
cin>>w;
if(w==-1)return 0;
cout<<4280-money(w)<<endl;
}
}

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

int main()
{
    size_t N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int &pp : p)
    {
        cin >> pp;
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for (size_t i = 0; i < K; i++)
    {
        ans += p[i];
    }
    cout << ans << endl;
}


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

#define endl '\n'

long long n,k;
double a[200000];

bool can(double m){
    long long cost = 0;
    for (int i=0; i<n; i++){
        cost += (int)(ceil(a[i] / m)) - 1;
    }
    return cost <= k;
}

void solvetask(){
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> a[i];
    int l = 0, r = 1e9, ans = 1e9;
    while(l <= r){
        int m = (l+r)/2;
        if (can((double)m)){
            ans = m;
            r = m - 1;
        } else l = m + 1;
    }
    for (int i=max(0, ans-3); i<ans+3; i++){
        if (can((double(i)))){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 5292
Option Strict On
Module problemB

    Sub Main()
        Dim n As Integer = Integer.Parse(Console.ReadLine)
        Dim p As Integer = Convert.ToInt32(Math.Ceiling(n / 1.08))
        Dim ans As String

        If Math.Floor(p * 1.08) = n Then
            ans = p.ToString
        Else
            ans = ":("
        End If
        Console.WriteLine(ans)
    End Sub

End Module

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<bool> vb;
#define setp ios_base::sync_with_stdio(0); cin.tie(0);
#define usaco(a,b) ofstream cout(a); ifstream cin(b);
#define FOR(i, a, b) for (int i=a; i<(b); i++) 
#define F0R(i, a) for (int i=0; i<(a); i++) 
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--) 
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define sz(x) (int)(x).size() 
#define mp make_pair 
#define pb push_back 
#define fs first 
#define sc second 
#define lb lower_bound 
#define ub upper_bound 
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const ll MOD = 1000000007;
const ll INF = 1e18;
const int MAX = 1e6;


int main() {
	int N; cin>>N;
	vi arr(N);
	int x;
	F0R(i,N)cin>>arr[i];
	ll cnt=0;
	if(N<3){cout<<0<<endl; return 0;}
	for(int i=0;i<N-2;i++){
		for(int j=i+1;j<N-1;j++){
			for(int k=j+1;k<N;k++){
				if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k]){
					vi temp ={arr[i],arr[j],arr[k]};
					sort(all(temp));
					if(temp[2]<temp[0]+temp[1] && temp[2]>abs(temp[0]-temp[1])){
						cnt++;
					}
				}
			}
		}
	}
	cout<<cnt<<endl;
 	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli a[101];
lli dp[101][101][101];
lli rec(lli i,lli j,lli k){
	if(k==0)return 0;
	if(k<0)return INT_MIN;
	if(i>j)return 0;
	if(dp[i][j][k]!=-1)return dp[i][j][k];
	return dp[i][j][k]=max((lli)0,(max(max(a[i]+rec(i+1,j,k-1),rec(i+1,j,k-2)),max(a[j]+rec(i,j-1,k-1),rec(i,j-1,k-2)))));
}



int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n,k;
    cin>>n>>k;
    for(lli i=0;i<=100;i++)for(lli j=0;j<=100;j++)for(lli k=0;k<=100;k++)dp[i][j][k]=-1;
    for(lli i=0;i<n;i++)cin>>a[i];
    	lli mini=0;
    //for(lli i=0;i<=100;i++)for(lli j=0;j<=100;j++)for(lli k=0;k<=100;k++)mini=max(dp[i][j][k],mini);
    cout<<rec(0,n-1,k);

    return 0;
}




Measured memory_bytes: 8320
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    while(n>0){
        if(n%10==9){
            cout<<"Yes"<<endl;
            return 0;
        }
        n=n/10;
    }
    cout<<"No"<<endl;
    return 0;
    // Your code here!
    
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll n, m ,c;
    cin >> n >> m >> c;

    ll b[m];
    rep(i,m)
    {
    	cin >> b[i];
    }

    ll a[n][m];


    ll ans = 0;

    rep(i,n)
    {
    	ll sum = 0;

    	rep(j,m)
    	{
    		cin >> a[i][j];
    		sum = sum + (a[i][j]*b[j]);
    	}

    	sum = sum + c;

    	if(sum>0)
    		ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
w = []
v = []
for i in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
    
dp = [[0] *(W + 1) for i in range(N + 1)]

for i in range(N):
    for j in range(W + 1):
        if j < w[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
            
print(dp[N][W])

Measured memory_bytes: 120796
#include <bits/stdc++.h>
using namespace std;
int main (){
  int s1,s2,s3,S;
  cin>>S;
  s3=S%10;
  s2=(S%100-s3)/10;
  s1=(S-S%100)/100;
  cout<<s1+s2+s3<<endl;
}


Measured memory_bytes: 3652
n ,m = map(int, input().split())
ln = []
lm = []

for i in range(n):
    ln.append(input())
for i in range(m):
    lm.append(input())

lim = n - m + 1
for i in range(lim):
    for j in range(lim):
        l = 0
        for k in ln[i:i+m]:
            if k[j:j+m] != lm[l]:
                break
            l += 1
        else:
            print("Yes")
            break
    else:
        continue
    break

else:
    print("No")


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll n; std::cin >> n;
  n--;
  std::cout << n * (n+1) / 2 << "\n";
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N = int(input())
H = list(map(int,input().split()))

pre = H[0]
total = 0
max_total = 0
for i in range(1, N):
    if pre>=H[i]:
        total+=1
        if total>max_total:max_total=total
    else:total=0
    
    pre=H[i]
print(max_total)

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 20;
int A[MAX_N];
int n;

bool solve(int i, int m){
    if(m == 0) return true;
    if(i >= n) return false;
    bool res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main()
{
    cin >> n;
    rep(i,n){
        cin >> A[i];
    }
    int q; cin >> q;
    rep(_,q){
        int m; cin >> m;
        if(solve(0,m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int X, A;
    
    cin >> X >> A;

    if(X<A){
        cout << 0 << endl;
    }
    else{
        cout << 10 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();

        a = a.OrderByDescending(_a => _a).ToArray();

        long answer = 0;

        for (int i = 0; i < n; i++)
        {
            answer += (long)a[i * 2 + 1];
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 48028
'use strict';
(function(stdin) {
  //declare function

  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var line = inputs[1].split(' ').map(Number);
  console.log(line.reverse().join(' '));
  //main

  //display
  //console.log(inputs);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 15856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int x,y; cin>>x>>y;
  if(x==2||y==2)cout<<"No"<<endl;
  else{
  
  if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  
  else{
    if(y==4||y==6||y==9||y==11) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  
  

}
}


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

using namespace std;

int m, n;
int ct[26];
pair<int, int> pos[26][2];

char board[512][512];
bool done[26];

bool c(pair<int, int> a, pair<int, int> b, char ch)
{
	if (a.first > b.first) swap(a.first, b.first);
	if (a.second > b.second) swap(a.second, b.second);
	
	for (int i = a.first; i <= b.first; i++){
		for (int j = a.second; j <= b.second; j++){
			if (isalpha(board[i][j]) && board[i][j] != ch) return (false);
		}
	}
	
	return (true);
}

int main()
{
	scanf("%d %d", &m, &n);
	
	for (int i = 0; i < m; i++){
		scanf("%s", board[i]);
		for (int j = 0; j < n; j++){
			if (isalpha(board[i][j])) pos[board[i][j] - 'A'][ct[board[i][j] - 'A']++] = make_pair(i, j);
		}
	}
	
	for (int t = 0; t < 26; t++){
		for (int i = 0; i < 26; i++){
			if (done[i]) continue;
			if (abs(pos[i][0].first - pos[i][1].first) +
				abs(pos[i][0].second - pos[i][1].second) <= 1) continue;
			
			pair<int, int> tmp = make_pair(pos[i][0].first, pos[i][1].second);
			
			if (c(pos[i][0], tmp, i + 'A') + c(tmp, pos[i][1], i + 'A') == 2){
				done[i] = true;
				board[pos[i][0].first][pos[i][0].second] = '.';
				board[pos[i][1].first][pos[i][1].second] = '.';
			}
			
			tmp = make_pair(pos[i][1].first, pos[i][0].second);
			
			if (c(pos[i][0], tmp, i + 'A') + c(tmp, pos[i][1], i + 'A') == 2){
				done[i] = true;
				board[pos[i][0].first][pos[i][0].second] = '.';
				board[pos[i][1].first][pos[i][1].second] = '.';
			}
		}
	}
	
	int ret = 0;
	for (int i = 0; i < 26; i++) ret += 2 * done[i];
	
	printf("%d\n", ret);
	
	return (0);
}

Measured memory_bytes: 1444
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  ll res = 0;
  ll t = a[0];
  ll o = 1;
  for (int i = 1; i < n; i++){
    if (t != a[i]){
      res += o;
      t = a[i];
      o = 1;
    }
    else {
      o = 1 - o;
    }
  }
  res += o;

  cout << res << endl;

  return 0;
}


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

int main(){
    cin >> n >> s;
    int r = 0; int w = 0;
    for(int i=0; i<n; i++){
        if(s[i]=='R'){
            r++;
        }
    }
    int mn = n;
    for(int i=0; i<n; i++){
        mn = min(mn,max(r,w));
        if(s[i]=='R'){
            r--;
        }
        else{
            w++;
        }
    }
    mn = min(mn,max(r,w));
    cout << mn << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
//#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 998244353;
const double pi = acos(-1.0);



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    string s;
    cin>>s;
    ll n = s.length();
    if(s[n-1]=='s'){
        s += 'e';
        s += 's';
        cout<<s<<endl;
    }
    else{
        s += 's';
        cout<<s<<endl;
    }
    return 0;
}


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

int main() {
	int S, s, h, m;
	cin >> S;
	h = S / 3600;
	S = S - (h * 3600);
	m = S / 60;
	S = S - (m * 60);
 	s = S;
	cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) (m*n)/GCD(m,n)
# define mod 1000000007

int main()
{
    IOS;
    ll i,j,k,t,n,sum=0,prod=1,flag=0;
    cin >> n;
    string x;
    cin >> x;
    ll cnttotal=0;
    for(i=0;i<n;i++)
    {
        if(x[i]=='R')
            cnttotal++;
    }
    for(i=0;i<cnttotal;i++)
    {
        if(x[i]=='W')
            sum++;
    }
    cout << sum;
}


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

struct edge{
	int u, v, c;
	edge(){}
	edge(int u_, int v_, int c_){
		u = u_; v = v_; c = c_;
	}
};
bool operator<(const edge &a, const edge &b){
	return a.c < b.c;
}

struct union_find{
	vector<int> par, rank;
	
	union_find(int n){
		par = vector<int>( n );
		rank = vector<int>( n , 0 );
		for(int i=0 ; i < n ; i++ ){
			par[i] = i;
		}
	}
	int find(int x){
		return ( par[x] == x )? x : (par[x] = find(par[x]) ) ;
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if( x == y ) return;
		
		if( rank[x] < rank[y] ){
			par[x] = y;
		}else{
			par[y] = x;
			if( rank[x] == rank[y] )
				rank[x]++;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

const int INF = 1e+8;
int n, m;
vector<edge> e;

int solve(){
	int k = -1, cnt = 0;
	union_find uf(n);
	
	for(int i=0 ; i < e.size() ; i++ ){
		if( !uf.same(e[i].u, e[i].v) ){
			uf.unite(e[i].u, e[i].v);
			cnt++;
			k = i;
		}
	}
	return ( cnt == n-1 )? e[k].c - e[0].c : INF;
}

int main(){
	while( cin >> n >> m , n || m ){
		e.clear();
		for(int i=0 ; i < m ; i++ ){
			int a, b, w;
			cin >> a >> b >> w;
			a--; b--;
			e.push_back( edge(a, b, w) );
		}
		
		sort(e.begin(), e.end());
		int ans = INF;
		while( n-1 <= e.size() ){
			int res = solve();
			if( res == INF ) break;
			
			ans = min(ans, res);
			e.erase(e.begin());
		}
		if( ans == INF ) ans = -1;
		cout << ans << endl;
	}
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, k, c;
	string s;
	cin >> n >> k >> c >> s;

	vi greedy;
	int nxt = -1;
	for (int i = 0; i < n; i++) {
		if (i > nxt && s[i] == 'o') {
			greedy.push_back(i);
			nxt = i + c;
		}
	}
	//debug(greedy);
	assert(sz(greedy) >= k);

	vi remain(n+c+1);
	for (int i = n-1; i >= 0; i--) {
		remain[i] = remain[i+1];
		if (s[i] == 'o')
			remain[i] = max(remain[i], 1 + remain[i+c+1]);
	}
	//debug(remain);

	for (int i = 0; i < n; i++) {
		if (s[i] == 'x') continue;
		int done = lower_bound(all(greedy), i) - greedy.begin();
		if (done + remain[i+1] < k) cout << (i+1) << "\n";
	}
}


Measured memory_bytes: 3448
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        int BuyNum = sc.nextInt();
        int ans = 0;
        int[] price = new int[num];
        for (int i = 0; i < num; i++){
            price[i] = sc.nextInt();
        }
      	Arrays.sort(price);
        for (int i = 0; i < BuyNum; i++) {
            ans += price[i];
        }
        System.out.println(ans);
    }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    vector<int> cnt(10, 0);
    REP(i, 3){
        int a;
        cin >> a;
        cnt[a]++;
    }
    cout << (MAX(cnt) == 2 ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
    int c = 0;
    string  s;
    string  t;
    cin >> s;
    cin >> t;
    for(int i = 0; i < 3; i++) {
        if(t[i] == s[i]) c++;
    }
    cout << c << endl;
}



Measured memory_bytes: 256
import math
a,b,h,m=map(int,input().split())
min=m*6
hour=(h*30)+(m*0.5)
c=abs(min-hour)
if c>=180:
    c=abs(c-360)
ans=(a**2)+(b**2)-2*a*b*(math.cos(math.radians(c)))
print(math.sqrt(ans))

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define lp(x,y) for(ll i=x;i<y;i++)
#define pb push_back
 

  
// Driver code 
int main() 
{ 
    int arr[5],count=0;
    lp(0,5) { cin>>arr[i]; if(arr[i]==0) count=i+1;}
    cout<<count;
} 

Measured memory_bytes: 3588