akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int t,p,r;

struct Team{
    int solved=0,penalty=0,teamid=0;
    Team(){}
    Team(int s,int p,int t) : solved(s),penalty(p),teamid(t){}

    bool operator < (const Team &te){
        if(solved != te.solved) return ( solved < te.solved );
        else if(penalty != te.penalty) return (penalty > te.penalty);
        else return(teamid > te.teamid);
    }
};

void solve(){
    vector<ll> tid(r),pid(r),ti(r);
    vector<string> message(r);
    rep(i,r){
        cin >> tid[i] >> pid[i] >> ti[i] >> message[i];
        tid[i]--;
        pid[i]--;
    }

    vector<vi> fa(t+10,vi(p+10,0));

    vector<Team> team(t);
    rep(i,t) team[i].teamid=i;
    rep(i,r){
        int teamid = tid[i];
        assert(teamid < t);
        if(message[i]=="CORRECT"){
            team[teamid].solved++;
            team[teamid].penalty += ti[i] + 1200 * fa[teamid][pid[i]];
        }else{
            fa[teamid][pid[i]]++;
        }
    }
    sort(all(team));

    for(int i=t-1;i>=0;i--){
        cout << team[i].teamid+1 << " " << team[i].solved << " " << team[i].penalty << endl;
    }
}

int main(){
    while(1){
        cin >> t >> p >> r;
        if(t==0 and p==0 and r==0) break;
        solve();
    }
}

Measured memory_bytes: 3252
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	char cs[5] = "ACGT";
	string s;
	cin >> s;
	int i, max = 0, cnt = 0;
	for (i = 0; i < s.length(); i++) {
		bool flg = 0;
		for (int j = 0; j < 4; j++) {
			if (s[i] == cs[j]) {
				cnt++;
				flg = 1;
				break;
			}
		}
		if (!flg&&cnt>max) {
			max = cnt;
			cnt = 0;
		}
		
	}
	if (cnt > max) {
		max = cnt;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    a,c,b=input().split()
    if c=="?":
        break
    else:
        if c=="+":
            print(int(a)+int(b))
        elif c=="-":
            print(int(a)-int(b))
        elif c=="*":
            print(int(a)*int(b))
        elif c=="/":
            print(int(a)//int(b))

Measured memory_bytes: 7640
n=int(input())
t,a=map(int,input().split())
l=list(map(int,input().split()))
cal=(t-a)/0.006
tmp=abs(cal-l[0])
pl=1
for i in range(1,n):
  if tmp>abs(cal-l[i]):
    pl=i+1
    tmp=abs(cal-l[i])
print(pl)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int k, x; cin >> k >> x;
	if (k * 500 >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(17);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 16640
from collections import defaultdict
N=int(input())
ans=[]
d=defaultdict(int)
for _ in range(N):
    d[input()]+=1
maxv=max(d.values())
for i in d.keys():
    if d[i]==maxv:
        ans.append(i)
ans.sort()
[print(i) for i in ans]


Measured memory_bytes: 100996
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 2e5 + 7;
int dp[3][3000]; //状态dp[i][j]表示以第i字符结尾的数字中对2019取模为j的数字有多少个
char s[maxx];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    LL ans = 0;
    for(int i = 1; i <= n; i++) {
        int x = s[i] - '0';
        for(int j = 0; j < 2019; j++) {
            dp[1][(j * 10 + x) % 2019] += dp[0][j];
        }
        dp[1][x]++;
        for(int j = 0; j < 2019; j++) {
            dp[0][j] = dp[1][j];
            dp[1][j] = 0;
        }
        ans += dp[0][0];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3984
/*input
13 17
29 7 5 7 9 51 7 13 8 55 42 9 81
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int n,m;
ll a[maxn];
ll pre[maxn];

map<ll,ll> mp;

int main()
{
	IOS;
	cin>>n>>m;
	REP(i,n) cin>>a[i];
	REP(i,n) pre[i+1]=pre[i]+a[i];

	REP(i,n+1) mp[pre[i]%m]++;
	ll ans=0;
	for(auto i:mp){
		ans+=i.S*(i.S-1)/2;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 7040
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
using namespace std;
int main(){

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

  for(int i=1;i<n-1;i++){
    if(p[i-1]<p[i]&&p[i]<p[i+1])count++;
    else if(p[i-1]>p[i]&&p[i]>p[i+1])count++;
  }
cout<<count;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

            final int M = (int) 1e7;
            long[] numDivisors = new long[M + 1];
            for (int divisor = 1; divisor <= M; divisor++) {
                for (int j = divisor; j <= M; j += divisor) {
                    numDivisors[j]++;
                }
            }

            long sum = 0;
            for (int k = 1; k <= N; k++) {
                sum += k * numDivisors[k];
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 106864
s = input()
l = len(s)
def test(s):
    l = len(s)
    sub = l//2
    return s[:sub][::-1] == s[-1*sub:]
if test(s[:(l-1)//2]) and test(s):
    print('Yes')
elif l == 3 and test(s):
    print('Yes')
else:
    print('No')

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

int main()
{
	int d,n;
	cin >> d >> n;
	int ans = 1;
	for(int i = 0;i<d;i++)
	{
		ans *= 100;
	}
	ans *= n == 100 ? 101:n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e16;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

ModInt func[2000003];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
ModInt comb(ModInt n, ModInt r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 1;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}
int main() {
	string s;
	lint K;
	cin >> K >> s;
	ModInt ans = 0;
	funcinit(2000003);
	REP(i, K + 1) {
		ModInt inst = mod_pow(25, i);
		inst *= mod_pow(26, K - i);
		ModInt cb = comb(i + SZ(s) - 1, i);
		inst *= comb(i + SZ(s) - 1, i);
		ans += inst;
	}
	cout << ans.a << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int d;
  for (int i = 0; i < N; i++) {
    cin >> d;
    vec.at(i) = d;
  }
  sort(vec.begin(), vec.end(), greater<int>() );
  int counter = 1;
  int A = vec.at(0);
  for (int i = 0; i < N; i++) {
    if (vec.at(i) < A) {
      A = vec.at(i);
      counter++;
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <numeric>

using namespace std;

int minCostFrom(int curr, const vector<int>& h, vector<int>& memo) {
    int N = h.size();
    if (memo[curr] >= 0) {
        return memo[curr];
    }
    if (curr == N - 1) {
        return 0;
    }
    else if (curr == N - 2) {
        memo[curr] = abs(h[N - 1] - h[N - 2]);
        return memo[curr];
    }
    int ip1 = minCostFrom(curr + 1, h, memo) + abs(h[curr] - h[curr + 1]);
    int ip2 = minCostFrom(curr + 2, h, memo) + abs(h[curr] - h[curr + 2]);
    memo[curr] = min(ip1, ip2);
    return memo[curr];
}

int main() {
    int N;
    cin >> N;
    vector<int> h(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    vector<int> memo(N, -1);
    memo[N - 1] = 0;
    int ans = minCostFrom(0, h, memo);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    a = list(map(int,input().split()))
    p.append(a[0])
    x.append(a[1])

St = sum(t)

for i in range(m):
    print(St+x[i]-t[p[i]-1])

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll nmax  = 50;
vll a(nmax+1), p(nmax+1);
ll solve(ll n, ll x){
    if(a[n]==x) return  p[n];
    if(x==0) return 0LL;
    if(n==0) return 1LL;
    if(x>=a[n-1]+2){
        return 1LL + solve(n-1, x-a[n-1]-2) + solve(n-1, a[n-1]);
    }else{
        return solve(n-1, x-1);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin >> n >> x;
    REP(i,n+1){
        ll t = 1;
        t <<= (i+1);
        p[i] = t-1;
        t <<= 1;
        a[i] = t-3;
    }
    ll ans = solve(n, x);
    cout << ans << endl;
    return 0;
}

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

int main() {
  uint32_t N = 0;
  std::cin >> N;

  std::map<int64_t, uint32_t> dict;
  int64_t sum = 0;
  dict[0]++;
  uint64_t ans = 0;
  for (size_t i = 0; i < N; i++) {
    int64_t A = 0;
    std::cin >> A;
    sum += A;
    ans += dict[sum]++;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<stdio.h>
#include<cmath>

using namespace std;

int main(){

    int A,B,C,M;

    cin >> A >> B >> C;

    if(A>B && A>C){
        M=10*A+B+C;
    }
    else if(B>A && B>C){
        M=10*B+A+C;
    }
    else if(C>A && C>B){
        M=10*C+A+B;
    }
    else{
        M=10*A+B+C;
    }

    cout << M << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,i,j,sum,ans;
map<long long,long long> cnt;
int main()
{
	cnt[0]=1;
	ios_base::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++)
	{
		long long x;
		cin>>x;
		sum+=x;
		ans+=cnt[sum];
		cnt[sum]++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long

int main()
{
    ll a, b, c, d;
    std::cin >> a >> b >> c >> d;

    ll max_num = -1000000000000000000;

    max_num = (max_num > (a*c)) ? max_num : (a*c);
    max_num = (max_num > (a*d)) ? max_num : (a*d);
    max_num = (max_num > (b*c)) ? max_num : (b*c);
    max_num = (max_num > (b*d)) ? max_num : (b*d);
    
    std::cout << max_num << std::endl;
}

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

int main(){
  string S;
  cin >> S;
  
  int a,b,c,d,N;
  N = S.size();
  a = 0;
  b = (N-3)/2;
  c = (N+1)/2;
  d = N-1;
  
  int result = 1;
  
  for (int i = 0; i < (N-1)/2 ; i++) {
    if(S.at(a+i)==S.at(d-i)){
    }else{
      result = 0;
      break;
    }
  }
  for (int i = 0; i < (N-1)/4 ; i++) {
    if(S.at(a+i)==S.at(b-i)){
    }else{
      result = 0;
      break;
    }
  }
  for (int i = 0; i < (N-1)/4 ; i++) {
    if(S.at(c+i)==S.at(d-i)){
    }else{
      result = 0;
      break;
    }
  }
  
  if(result == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
    return 0;
}


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

int main() {
  int K, S;
  cin >> K >> S;
  int sum = 0;
  for(int i = 0; i <= K; i++) {
    for(int j = 0; j <= K; j++) {
      if(S-i-j >= 0 && S-i-j <= K) {
        sum++;
      }
    }
  }
  cout << sum;
}


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

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

  if( (A + B) > (C + D) )                        //左天秤の方が重いケース
    cout << "Left" << endl;
  else if( (A + B) == (C + D) )           //釣り合っているケース
    cout << "Balanced" << endl;
  else                                                          //残りは右天秤が重いケース   
    cout << "Right" << endl;

}


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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int t,p,r;
    cin >> t >> p >> r;
    if(!t&&!p&&!r) return 0;
    vector<vector<int> > act;
    // t,p: -1200*wa
    act.resize(t);
    REP(i,t) act[i].assign(p,0);
    REP(i,r){
      int tid,pid,time;
      string mes;
      cin >> tid >> pid >> time >> mes;
      tid--;pid--;
      if(act[tid][pid]>0) continue;
      if(mes=="WRONG") act[tid][pid]-=1200;
      if(mes=="CORRECT") act[tid][pid]=time-act[tid][pid];
    }
    vector<pair<pair<int,int>,int> > score;
    // -AC,penalty,team
    REP(i,t) score.PB(MP(MP(0,0),i+1));
    REP(i,t) REP(j,p) if(act[i][j]>0){
      score[i].first.first-=1;
      score[i].first.second+=act[i][j];
    }
    SORT(score);
    REP(i,t) cout << score[i].second << ' ' << -score[i].first.first << ' ' << score[i].first.second << endl;
  }
}

Measured memory_bytes: 1228
H, W, D = map(int, input().split())
A = [None]*(H*W+1)
for i in range(H):
    a = [int(i) for i in input().split()]
    for j, v in enumerate(a):
        A[v] = (i+1, j+1)

Q = int(input())
LR = [[int(i) for i in input().split()] for _ in range(Q)]

c = [0]*(H*W+1)
for i in range(1+D, W*H+1):
    c[i] = c[i-D]+abs(A[i][0]-A[i-D][0])+abs(A[i][1]-A[i-D][1])

for l, r in LR:
    print(c[r]-c[l])


Measured memory_bytes: 75100
N, K = map(int, input().split())
INF = 10**9 + 7
def powmod(a, n, mod):
    p = 1
    while n > 0:
        if n % 2 == 0:
            a = a**2 % mod
            n /= 2
        else:
            p *= a
            p %= mod
            n -= 1
    return p

def invmod(a, mod):
    return powmod(a, mod-2, mod)

fac = [1] * 2002
inv = [1] * 2002
for i in range(2002):
    if i == 0:
        fac[i] = 1
        inv[i] = 1
    else:
        fac[i] = fac[i-1] * i % INF
        inv[i] = inv[i-1] * invmod(i, INF) % INF


def combmod(n, k, mod):
    if n < k : return 0
    else:
        bunsi = fac[n]
        bunbo = inv[k] * inv[n-k]
        return bunsi * bunbo % mod

for i in range(1, K+1):
    print((combmod(K-1, i-1, INF) * combmod(N-K+1, i, INF))%INF)

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

struct edge{int to; ll cost;};

vector<edge>tree[100010];
vector<ll>dist;

void dfs(int v, int p, ll d){
    dist[v]=d;
    for(edge u:tree[v]){
        if(u.to==p)continue;
        dfs(u.to,v,d+u.cost);
    }
}

int main(){
    int n;
    cin>>n;
    dist.resize(n);
    rep(i,n-1){
        int a,b,c;
        cin>>a>>b>>c;
        a--; b--;
        tree[a].push_back({b,c});
        tree[b].push_back({a,c});
    }
    int q,k;
    cin>>q>>k;
    k--;
    dfs(k,-1,0);
    vector<int>x(q),y(q);
    rep(i,q){
        cin>>x[i]>>y[i];
        x[i]--; y[i]--;
    }
    rep(i,q){
        cout<<dist[x[i]]+dist[y[i]]<<endl;
    }
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
  double a,b,c;
  cin>>a>>b;
  c=(a*b)/(a+b);
  printf("%.10f\n",c);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string s;
  while(cin>>s){
    char a;
    bool f=true;
    for(int i=0;i<4;i++){
      a=s[i];
      if(i==0&&a!='s'){
	if(a==s[1]&&a==s[2]||a==s[3]&&a==s[6]||a==s[4]&&a==s[8]){
	  cout<<a;
	  f=false;
	  break;
	}
      }
      else if(i==1&&a!='s'){
	if(a==s[4]&&a==s[7]){
	  cout<<a;
	  f=false;
	  break;
	}
      }
      else if(i==2&&a!='s'){
	if(a==s[4]&&a==s[6]||a==s[5]&&a==s[8]){
	  cout<<a;
	  f=false;
	  break;
	}
      }
      else if(a!='s'){
	if(a==s[4]&&a==s[5]){
	  cout<<a;
	  f=false;
	}
      }
    }
    if(s[6]!='s'){
      a=s[6];
      if(a==s[7]&&a==s[8]){
	cout<<a;
	f=false;
      }
    }
    if(f) cout<<'d';
    cout<<endl;
  }   
  return 0;
}

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

int main() {
  int x; cin >> x;
  
  int ans = 1;
  for (int i = 2; i <= sqrt(x); ++i) {
    int tmp = i;
    while(tmp * i <= x) tmp *= i;
    ans = max(ans, tmp);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import math
s = input()
s = s[0:-2]
ans = 0
for i in range(len(s)):
    if not len(s)%2 == 0:
        s = s[0:-2]
        continue
    x  = math.floor(len(s)/2-1)
    if s[0:x] == s[x+1:-1]:
        ans = len(s)
        break
    s = s[0:-2]

print(ans)


Measured memory_bytes: 3060
END { load __FILE__ unless $stdin.eof? }

h, w = gets.split.map! { |s| s.to_i + 4 }
c = gets.then { |s| j, i = s.split.map!(&:to_i); (j + 1) * w + i + 1 }
d = gets.then { |s| j, i = s.split.map!(&:to_i); (j + 1) * w + i + 1 }

maze = Array.new(h - 4) do
  "###{gets.chomp}##".chars.map! { |c| c == '.' ? 99999999 : -1 }
end
wall = Array.new(w, -1)
maze.unshift(wall, wall).push(wall, wall)
maze.flatten!

pq = Hash.new { |h, k| h[k] = [] }
pq[0] << c

until pq.empty?
  k = pq.keys.min
  q = pq[k]
  q.uniq!

  while (pos = q.pop)
    next if maze[pos] <= k
    maze[pos] = k
  
    [pos - w, pos - 1, pos + 1, pos + w].each do |x|
      if k < maze[x]
        q << x
      end
    end

    k2 = k + 1
    q2 = pq[k2]
    (-2..2).each do |j|
      (-2..2).each do |i|
        x = pos + (j * w + i)
        if k2 < maze[x]
          q2 << x
        end
      end
    end
  end

  pq.delete(k)
end

cnt = maze[d]
puts (cnt < 99999999) ? cnt : -1


Measured memory_bytes: 38520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,k; cin>>n>>k;
	vll a(n);
	forn(i,n) cin>>a[i];
	int id1 = 0, id2 = k;
	while(id2<n)
	{
		if(a[id2]>a[id1]) cout<<"Yes\n";
		else cout<<"No\n";
		id2++; id1++;
	}

	return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int d; cin >> d;
  string ev = "";
  rep(i,25-d){
    ev += " Eve";
  }
  string ans = "Christmas";
  ans+=ev;

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


Measured memory_bytes: 3576
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, m, dp[200]; pair<int, int> a[200];
int main() {
	while(true) {
		scanf("%d", &n);
		if(n == 0) break;
		for(int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);
		scanf("%d", &m);
		for(int i = 0; i < m; i++) scanf("%d%d", &a[n + i].first, &a[n + i].second);
		sort(a, a + n + m);
		int ret = 0;
		for(int i = 0; i < n + m; i++) dp[i] = -1;
		for(int i = 0; i < n + m; i++) {
			bool flag = false;
			for(int j = 0; j < ret; j++) {
				if(dp[j] >= a[i].second) {
					dp[j] = a[i].second; flag = true; break;
				}
			}
			if(!flag) {
				dp[ret] = a[i].second, ret++;
				int ptr = i;
				while(a[ptr].first == a[i].first) i++; i--;
			}
		}
		//for(int i = 0; i < n + m; i++) printf("%d %d\n", a[i].first, a[i].second);
		//for(int i = 0; i < ret; i++) printf("%d\n", dp[i]);
		printf("%d\n", ret);
	}
}

Measured memory_bytes: 2592
#include<iostream>
#include<algorithm>

using namespace std;
int cnt[108000];
int n, p;
int main(){
	while(cin >> n >> p, n | p){
		fill(cnt, cnt + n, 0);
		int win = p;
		for(int i = 0;i <= 1000000;i++){
			if(p){
				p--;
				cnt[i%n]++;
				if(cnt[i%n] == win){
					cout << i%n << endl;
					break;
				}
			}
			else{
				p = cnt[i%n];
				cnt[i%n] = 0;
			}
		}
	}
	return 0;
}

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

typedef long long ll;

#define REP(i,m,n) for(int i=(int)m; i < (int)n; ++i)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()

const int MOD = 1e9+7;


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

    string s; cin >> s;
    int N = s.size();
    // dp[i][j] : i 文字目まで見たときに作れる数で、13 で割ったあまりが j のものの個数
    ll dp[101010][13] = {};
    dp[0][0] = 1;

    rep(i, N) {
        rep(j, 13) {
            if(s[i] == '?') {
                for(int k = 0; k <= 9; k++) {
                    int j2 = (j*10+k)%13;
                    dp[i+1][j2] = (dp[i+1][j2]+dp[i][j])%MOD;
                }
            } else {
                int k = s[i]-'0';
                int j2 = (j*10+k)%13;
                dp[i+1][j2] = (dp[i+1][j2]+dp[i][j])%MOD;
            }
        }
    }

    cout << dp[N][5] << '\n';
    return 0;
}

Measured memory_bytes: 10708
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define bod 100000007
/****************************/
string s;
int main()
{
	ios::sync_with_stdio(0);
	cin>>s;
	rep(i,SZ(s))
	{
		cout<<'x';
	}
	return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
  int n, ans = 0;
  cin >> n;

  vector<int> l(n);
  for (int i = 0; i < n; i++)
    cin >> l[i];
  sort(l.begin(), l.end());
  // for (int i = 0; i < n; i++)
  //   cout << l[i] << " ";
  // cout << endl;
  for (int i = 0; i < n - 2; i++)
  {
    // while (i < n - 2 && l[i] == l[i + 1])
    //   i++;
    for (int j = i + 1; j < n - 1; j++)
    {
      // while (j < n - 1 && l[j] == l[j + 1])
      //   j++;
      for (int k = j + 1; k < n; k++)
      {
        if (l[i] == l[j] || l[i] == l[k] || l[j] == l[k])
          continue;
        if (l[i] + l[j] <= l[k] || l[i] + l[k] <= l[j] || l[j] + l[k] <= l[i])
        continue;
        
        // cout << i << " " << j << " " << k << endl;
        ans++;
        
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define N 200005
pii p[N];
int x[N],n,a[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>x[i],p[i]=pii(x[i],i);
	sort(p+1,p+1+n);
	for(int i=1;i<=n;i++)
	a[p[i].se]=i;
	for(int i=1;i<=n;i++)
	if(a[i]<=n/2)cout<<p[n/2+1].fi<<endl;
	else cout<<p[n/2].fi<<endl;
	return 0;
} 

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

using namespace std;

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;

	int A, B;
	cin >> A >> B;

	for (int i = A; i <= B; ++i)
	{
		if (i % N == 0)
		{
			printf("OK\n");
			return 0;
		}
	}
	printf("NG\n");
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007
#define rev(v) reverse(v.begin(), v.end());

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n);
    double sum = 0;
    string ans = "Yes";
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) sum += a[i];
    sort(a.begin(), a.end(), greater<int>());

    int dev = 4*m;
    REP(i,0,m){
        if(a[i]<(sum/dev)){
            ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.util.stream.*;
import static java.util.Comparator.*;

public class Main{
  public static void main(String[] args) throws Exception{
	Scanner sc = new Scanner(System.in);
    char[] s = sc.nextLine().toCharArray();
    char[] t = sc.nextLine().toCharArray();
    List<Character> charListS = new ArrayList<>();
    List<Character> charListT = new ArrayList<>();
    for(char x : s){
        charListS.add(x);
    }
    for(char y : t){
        charListT.add(y);
    }
    String str1 = charListS.stream().sorted(naturalOrder()).collect(StringBuilder::new,StringBuilder::append,StringBuilder::append).toString();
    String str2 = charListT.stream().sorted(reverseOrder()).collect(StringBuilder::new,StringBuilder::append,StringBuilder::append).toString();
    String result = str1.compareTo(str2) < 0 ? "Yes" : "No";
    System.out.println(result);
  }
}

Measured memory_bytes: 27088
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
  int r,g,b;
  scanf("%d%d%d",&r,&g,&b);
  
  int num = 0;
  num = 100*r + 10*g + b;
  if((num%4) == 0){
    printf("YES");
  }else{
    printf("NO");
  }
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  vector<string> p(n);
  vector<int> q(n);
  
  rep(i,n){
  cin>>p[i]>>q[i];
  }
  
  string s;
  cin>>s;
  int ans=0;
  bool sleep =false;
  rep(i,n){
    if(sleep) ans+=q[i];
    if(s==p[i]) sleep = true;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def solve():
    s = getS()
    if s[-1] == "s":
        print(s + "es")
    else:
        print(s + "s")

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 10396
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll A, B, C;
        cin >> A >> B >> C;
        ll ans = inf;
        rep(i, 1, 2) {
                ll l = A / 2;
                ll r = A - l;
                ll tmp1 = l * B * C;
                ll tmp2 = r * B * C;
                chmin(ans, abs(tmp1 - tmp2));
        }
        rep(i, 1, 2) {
                ll l = B / 2;
                ll r = B - l;
                ll tmp1 = l * A * C;
                ll tmp2 = r * A * C;
                chmin(ans, abs(tmp1 - tmp2));
        }
        rep(i, 1, 2) {
                ll l = C / 2;
                ll r = C - l;
                ll tmp1 = l * A * B;
                ll tmp2 = r * A * B;
                chmin(ans, abs(tmp1 - tmp2));
        }
        cout << ans << endl;
}

Measured memory_bytes: 3588
S = input()[::-1]

S_mod = [0] * (len(S)+1)
S_mod[0] = int(S[0])

d = 10

for i in range(len(S)-1):
    S_mod[i + 1] = (S_mod[i] + int(S[i+1])*d)%2019
    d = d * 10 % 2019

mod_count = [0] * 2019
for i in range(len(S_mod)):
    mod_count[S_mod[i]] += 1
    
count = 0
for i in range(2019):
    count += mod_count[i] * (mod_count[i] - 1) / 2

print(int(count))

Measured memory_bytes: 16048
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    XY = []
    for i in range(n):
        x,y = readInts()
        XY.append([x,y])
    a = 0
    for i in range(n):
        for j in range(i):
            a += ((XY[i][0] - XY[j][0]) ** 2 + (XY[i][1] - XY[j][1]) ** 2) ** 0.5
    print(a / (n * (n-1) * 0.5) * (n-1))
if __name__ == '__main__':
  main()


Measured memory_bytes: 3188
from functools import reduce
from fractions import gcd
N = int(input())
T = []
for i in range(N):
    Ti = input()
    if Ti == '':
        break
    else:
        T.append(int(Ti))

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm(*T))

Measured memory_bytes: 5384
#include "bits/stdc++.h"
using namespace std;

using  ll =          long long;
using ull = unsigned long long;
const char en = '\n';
const ll INFL = 810000001919114514;
const int INF =         1919114514;

#define REP(i  ,n) for(int i=0;i<n;i++)
#define FOR(i,s,g) for(int i=s;i<g;i++)


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


	int n;
	cin>>n;

	cout<<(n*800-(n/15)*200)<<en;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
#define T tuple<int,int,int>

int main(){
	string s;
	cin>>s;
	int i,j;
	loop(i,0,s.size()){
		loop(j,i+1,s.size()){
			if(s[i]==s[j]){
				cout<<"no"<<endl;
				return 0;
			}
		}
	}
	cout<<"yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
def combination(n, a, mod):
    x = 1
    y = 1
    for i in range(a):
        x = x * (n-i)%mod
        y = y * (a-i)%mod

        #x *= (n-i)
        #x %=mod
        #y *= (a-i)
        #y %=mod
    return x * pow(y, mod-2, mod)%mod

n, m = map(int, input().split())

ans = combination(n,2,pow(10,9)+7) + combination(m, 2, pow(10,9)+7)
print(ans)


Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BBattle {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int A, B, C, D;
        cin >> A >> B >> C >> D;
        int anum = C / B;
        if (C % B != 0) anum++;

        int bnum = A / D;
        if (A % D != 0) bnum++;
        if (anum <= bnum) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BBattle solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val a = sc.nextInt
  val b = sc.nextInt
  val c = sc.nextInt
  val d = sc.nextInt

  val intersect = (a to b) intersect (c to d)

  val res = if(intersect.isEmpty) 0 else intersect.size - 1

  println(res)


}

Measured memory_bytes: 25524
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;

int main()
{
    IO;
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    while (n)
    {
        ans++;
        n /= k;
    }
    cout << ans << endl;
}

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

long gcd(long a, long b) {
  return a % b == 0 ? b : gcd(b, a % b);
}

int main(void) {
  long A, B;
  cin >> A >> B;

  long g = gcd(A, B);
  long a = A / g;
  long b = B / g;
  long ans = a * b * g;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

int list[3];
int main(){
	cin >> list[0] >> list[1] >> list[2];

	sort(list, list + 3);

	printf("%d %d %d\n", list[0], list[1], list[2]);

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int n;
cin >> n;
string s;
set<string> set;
rep(i,n) {
    cin >> s;
    set.insert(s);
}
 cout << set.size() << endl;

return 0;

}


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

// types
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,m;
  cin >> n >> m;
  vector<vll> to(n);
  REP(i, m){
    ll u,v;
    cin >> u >> v;
    u--; v--;
    to[u].push_back(v);
  }

  ll s,t;
  cin >> s >> t;
  s--; t--;
  ll dp[n][3];
  REP(i, n)REP(j, 3)dp[i][j]=INF;

  queue<pll> que;
  que.push(pll(s, 0));
  dp[s][0] = 0;
  while(!que.empty()){
    ll v = que.front().FI;
    ll l = que.front().SE;
    que.pop();

    ll nl = (l+1)%3;
    REP(i, to[v].size()){
      ll nv = to[v][i];
      if(dp[nv][nl] != INF)
        continue;

      dp[nv][nl] = dp[v][l]+1;
      que.push(pll(nv, nl));
    }
  }

  ll ans = dp[t][0];
  if(ans==INF)
    ans = -1;
  else
    ans = dp[t][0]/3;

  cout << ans << endl;


}


Measured memory_bytes: 8064
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i, n){
    cin>>a[i];a[i]--;
  }
  int ans=0;
  rep(i, n-1){
    if(a[i]==i){
      swap(a[i], a[i+1]);
      ans++;
    }
  }
  if(a[n-1]==n-1)ans++;
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

int main(void)
{
	int H[100], W[100];
	int h, w;
	int a = 1,b = 1;
	for (;;) {
		cin >> H[a] >> W[a];
		if (H[a] == 0 && W[a] == 0) {
			break;
		}
		a = a + 1;
	}
	for(int i=1;i<=a;i++){
		for (int i = 1; i <= W[b]; i++) {
			cout << "#";
		}
		cout << endl;
		h = H[b] - 2;
		w = W[b] - 2;
		for (int i = 1; i <= h; i++) {
			cout << "#";
			for (int i = 1; i <= w; i++) {
				cout << ".";
			}
			cout << "#" << endl;
		}
		for (int i = 1; i <= W[b]; i++) {
			cout << "#";
		}
		cout<<endl;
	b = b + 1;
	if(a == b){
	    cout<<endl;
	    return 0;
	    } else{
	    cout << endl;
	    }
	}
}


Measured memory_bytes: 3076