akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s = "0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 5 4 3 2 1";
int n, start, goal;
string ans;

int main(){
	cin >> n;
	REP(i, n){
		cin >> start >> goal;
		bool f = 0;
		int lb = 0, ub = 0;
		REP(i, s.size()){
			string t;
			if (s[i] - '0' == start){
				lb = i;
				f = 1;
			}
			if (f&&s[i] - '0' == goal){
				ub = i;
				//cout << lb << " " << ub << endl;
				t = s.substr(lb, ub - lb+1);
				if (ans.empty())ans = t;
				else{
					if (ans.size() > t.size())ans = t;
				}
			}
		}
		cout << ans << endl;
		ans.clear();
	}
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	vector<int> pri(1000000);
	for(int i=0;i<1000000;i++)
		pri[i]=1;
	pri[0]=0;
	pri[1]=0;
	for(int i=0;i*i<n;i++){
		if(pri[i]){
			for(int j=i*2;j<1000000;j+=i)
				pri[j]=0;
		}
	}
	
	
	while(cin>>n){
	int i=0,k=0;
	while(k<=n)
	if(pri[k++])
	i++;
	
		cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int M;
int A[200000];
int B[200000];
void doit(int a, int b){
  A[M] = a;
  B[M++] = b;
}
int main(){
  int i, k;
  rd(N);
  k = 0;
  for(i=0;i<20;i++){
    if(N&1<<i){
      k = (1<<i);
    }
  }
  if(N==k){
    wt_L("No");
    wt_L('\n');
    return 0;
  }
  doit(1, 2);
  doit(2, 3);
  doit(3, 1+N);
  doit(1+N, 2+N);
  doit(2+N, 3+N);
  for(i=4;i<N;i+=2){
    doit(i, i+1);
    doit(N+i, N+i+1);
    doit(1, i);
    doit(1, N+i+1);
  }
  if(N%2==0){
    doit(k+1+N, N);
    doit(N-k, N+N);
  }
  wt_L("Yes");
  wt_L('\n');
  for(i=0;i<M;i++){
    wt_L(A[i]);
    wt_L(' ');
    wt_L(B[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190714-1

// --- original code ---
// int N;
// 
// int M, A[2d5], B[2d5];
// 
// void doit(int a, int b){
//   A[M] = a;
//   B[M++] = b;
// }
// 
// {
//   int i, k;
// 
//   rd(N);
// 
//   k = 0;
//   rep(i,20) if(N&1<<i) k = (1<<i);
// 
//   if(N==k){
//     wt("No");
//     return 0;
//   }
// 
//   doit(1, 2);
//   doit(2, 3);
//   doit(3, 1+N);
//   doit(1+N, 2+N);
//   doit(2+N, 3+N);
// 
//   for(i=4;i<N;i+=2){
//     doit(i, i+1);
//     doit(N+i, N+i+1);
//     doit(1, i);
//     doit(1, N+i+1);
//   }
//   if(N%2==0){
//     doit(k+1+N, N);
//     doit(N-k, N+N);
//   }
// 
//   wt("Yes");
//   rep(i,M) wt(A[i], B[i]);
// }


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

using namespace std;

typedef long long ll;

ll A[80];

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

    int N;  cin >> N;
    for(int i=0; i<N; i++)
        cin >> A[i];
    ll lo = A[0];
    ll money = 1000;
    for(int i=0; i<N-1; i++)
    {
        if(A[i] > A[i+1])   //A[i] is local high point
        {
            money += (money / lo) * (A[i] - lo);
            lo = A[i+1];
        }
    }
    if(lo <= A[N-1])
        money += (money / lo) * (A[N-1] - lo);

    cout << money;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int a,b;
int main()
{
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 )
      cout << "Possible\n";
    else
      cout << "Impossible\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int max = 0;
    
    max = A+B;
    if(max < A - B) {
      max = A-B;
    }
    if(max < A * B) {
      max = A*B;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 35588
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var dct = new Dictionary<char, long> { { 'M', 0 }, { 'A', 1 }, { 'R', 2 }, { 'C', 3 }, { 'H', 4 } };
            nums = new long[5];
            for (var i = 0; i < N; ++i)
            {
                var s = ReadLine();
                if (dct.ContainsKey(s[0])) ++nums[dct[s[0]]];
            }
            var ans = 0L;
            for (var i = 0; i < 3; ++i)
                ans += dfs(i, 1, nums[i]);
            WriteLine(ans);
        }
        static long[] nums;
        static long dfs(long c, long d, long num)
        {
            if (d == 3) return num;
            var sum = 0L;
            for (var i = c + 1; i < 5; ++i)
                sum += dfs(i, d + 1, num * nums[i]);
            return sum;
        }
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 31936
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main(){
	int cnt;
	cin >> cnt;
	double x1, y1, x2, y2, x3, y3;
	double a1, a2, b1, b2, c1, c2;
	double xp, yp, r;
	while (cnt > 0 && cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3) {
		// ?????\??????????????§?¨?????±???????
		a1 = 2 * (x2 - x1);
		b1 = 2 * (y2 - y1);
		c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		a2 = 2 * (x3 - x1);
		b2 = 2 * (y3 - y1);
		c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		xp = (double)((b1*c2 - b2*c1) / (a1*b2 - a2*b1) * 1000) / 1000.0;
		yp = (double)((c1*a2 - c2*a1) / (a1*b2 - a2*b1) * 1000) / 1000.0;

		// ?????\????????????????±???????
		r = hypot(xp - x1, yp - y1);

		cout << fixed << setprecision(3);
		cout << xp << " " << yp << " " << r << endl;
		cnt -= 1;
	}
	return 0;
}

Measured memory_bytes: 1300
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int d = 0;
        int ans = 1;
        for (int i = 0; i < n; i++) {
            int l = sc.nextInt();
            d += l;
            if(d <= x) ans++;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
s = input()
flag_1 = [i for i, si in enumerate(s) if i%2 == 0 and (si =='R' or si=='U' or si=='D')]
flag_2 = [i for i, si in enumerate(s) if i%2 == 1 and (si =='L' or si=='U' or si=='D')]
if len(flag_1) + len(flag_2)==len(s):
    output = 'Yes'
else:
    output = 'No'
print('{}'.format(output))


Measured memory_bytes: 3060
import Control.Applicative

readDigits = map read <$> words <$> getLine :: IO [Int]

main =
    putStrLn =<< fn <$> readDigits
    where
    fn [a,b]
        | a < b = "a < b"
        | a > b = "a > b"
        | a == b = "a == b"

Measured memory_bytes: 3656
n = int(input())
h = list(map(int,input().split()))
dp = [1e+10 for i in range(n)]
dp[0] = 0
for i in range(0,n):
    for j in range(1,3):
        p = i + j
        if p < n:
            dp[p] = min(dp[p],dp[i] + abs(h[i] - h[p]))
print(dp[n-1])

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

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

    auto div = enum_divisors(sum);
    sort(rall(div));
    for (auto d : div) {
        vector<int> rem(n);
        for (int i = 0; i < n; ++i) {
            rem[i] = a[i] % d;
        }
        sort(all(rem));
        vector<int> minus(n+1, 0);
        vector<int> plus(n+1, 0);
        for (int i = 0; i < n; ++i) {
            minus[i+1] += minus[i] + rem[i];
            plus[i+1] += plus[i] + (d - rem[i]);
        }
        for (int i = 0; i <= n; ++i) {
            if (minus[i] == plus[n] - plus[i] && minus[i] <= k) {
                cout << d << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
int n,k,a[200005],mx;
bool check(int x) {
    /*
    priority_queue<int,vector<int>,less<int> > pq;
    rep(i,1,n) pq.push(a[i]);
    rep(i,1,k) {
        int kk=pq.top();pq.pop();
        if(kk>x) pq.push(kk-x),pq.push(x);
        else return true;
    }
    while(!pq.empty()) {
        if(pq.top()>x) return false;
        pq.pop();
    }
    return true;*/
    int now=0;
    rep(i,1,n) {
        int kk=a[i]/x;
        if(a[i]%x==0) kk--;
        now+=kk;
        if(now>k) return false;
    }
    return true;
}
signed main(){
    scanf("%lld%lld",&n,&k);
    rep(i,1,n) scanf("%lld",&a[i]),mx=max(mx,a[i]);
    int l=1,r=mx;
    while(l<r) {
        int mid=(l+r)>>1;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    printf("%lld\n",r);
    return 0;
}

Measured memory_bytes: 5360
#include <iostream>

int main(int argc, const char * argv[]) {
    int n;
    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            std::cout << " " << i;
            continue;
        }
        for (int x = i; x != 0; x /= 10) {
            if (x % 10 == 3) {
                std::cout << " " << i;
                break;
            }
        }
    }
    std::cout << std::endl;
    return 0;
}

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



int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  vector<LL> A(n);
  for (int i = 0; i < n; ++i) cin >> A[i];
  LL sum = accumulate(A.begin(), A.end(), 0ll);
  int ans = 0, diff = 1e9;
  for (int i = 0; i < n; ++i) {
    if (diff > abs(sum - A[i] * n)) diff = abs(sum - A[i] * n), ans = i;
  }
  cout << ans << '\n';


}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
vector<ll>:: iterator it;
ll gc(ll a,ll b)
{
    if(b==0) return a;
    return gc(b,a%b);
}
void dfs(ll u,vector<ll>& p, vector<bool>& vis, vector<ll> adj[],vector<bool>& v)
{
    vis[u]=true;
    for( it=adj[u].begin();it!=adj[u].end();it++)
    {
        if(!vis[*it])
        {
            p[*it]=u;
           dfs(*it,p,vis,adj,v);
        }
        else if((*it)!= p[u])
        {
           v[*it]=true;
           ll node1=(*it);
           ll node2=(*it);
           while(p[node2]!=node1)
           {
               v[node2]=true;
               cout<<node2<<endl;
               node2=p[node2];
           }
           break;
        }
    }
    return;
}
vector<bool>prime(100005,true);
vector<ll>v;
void sieve(ll n)
{
    prime[1]=false;
   for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for(int i=2;i<=n;i++)
    {
        if(prime[i]==true)
            v.pb(i);
    }
}
int main()
{
  ll n,a,b;
cin>>n>>a>>b;
ll d=n/(a+b);
ll ans=d*a;
ll rem=n%(a+b);
ans=ans+min(rem,a);
cout<<ans<<endl;
}


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

int num = 0;

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

    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '+') {
            num += 1;
        } else {
            num -= 1;
        }
    }

    cout << num;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main()
{
	string s;
	cin>>s;
	if(s[s.length()-1]=='s')
		s=s+"es";
	else
		s=s+'s';
	cout<<s<<"\n";	
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x,i;
	char g[10000];
	while(1){
		scanf("%d",&a);
		b=1;
		c=2;
		d=3;
		x=1;
		if(a==0){
			break;
		}
		for(i=0;i<a;i++){
			scanf("%s",&g[0]);
			if(g[0]=='N'){
				x=x+c;
				e=b;
				b=c;
				c=7-e;
			}
			else if(g[0]=='E'){
				x=x+7-d;
				e=d;
				d=b;
				b=7-e;
			}
			else if(g[0]=='W'){
				x=x+d;
				e=b;
				b=d;
				d=7-e;
			}
			else if(g[0]=='S'){
				x=x+7-c;
				e=b;
				b=7-c;
				c=e;
			}
			else if(g[0]=='R'){
				x=x+b;
				e=c;
				c=d;
				d=7-e;
			}
			else if(g[0]=='L'){
				x=x+b;
				e=c;
				c=7-d;
				d=e;
			}
		}
	printf("%d\n",x);
	}
	return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>                                             
                                                                     
using namespace std;                                                 
                                                                     
int main() {                                                         
                                                                     
    int n, r, p, c;                                                  
                                                                     
    while(cin >> n >> r, n | r) {                                    
                                                                     
        int fuda[n];                                                 
                                                                     
        for(int i = 0; i < n; ++i) {                                 
            fuda[i] = n - i;                                         
        }                                                            
                                                                     
        for(int i = 0; i < r; ++i) {                                 
                                                                     
            cin >> p >> c;                                           
                                                                     
            int temp[p + c - 1];                                     
                                                                     
            for(int j = 0; j < p - 1; ++j) {                         
                temp[c + j] = fuda[j];                               
            }                                                        
                                                                     
            for(int j = 0; j < c; ++j) {                             
                temp[j] = fuda[p + j - 1];                           
            }                                                        
                                                                     
            for(int j = 0; j < p + c - 1; ++j) {                     
                fuda[j] = temp[j];                                   
            }                                                        
                                                                     
        }                                                            
                                                                     
        cout << fuda[0] << endl;                                     
                                                                     
    }                                                                
                                                                     
}                                                                    
                                                                     

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
  string s;
  cin >> s;
  if(s == "Sunny") cout << "Cloudy" << endl;
  else if(s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;

  return 0;
}


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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    int answer = -1;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            answer = i;
            break;
        }
    }
    if (0 <= answer) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    REP(i,S.size()-1){
        if(S[i] == S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;
}

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


import typing


# See:
# https://github.com/not522/ac-library-python/blob/master/atcoder/dsu.py
class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result: typing.List[typing.List[int]] = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))


def main():
    import sys
    input = sys.stdin.readline

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

    for i in range(m):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        dsu.merge(ai, bi)

    ans = 0

    for j in range(1, n):
        if not dsu.same(0, j):
            dsu.merge(0, j)
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

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

int main() {
    long long a, b, c, d; cin >> a >> b >> c >> d;
    long long e = c / gcd(c, d) * d;
    long long cnt = 0;
    cnt += b / c - (a-1) / c;
    cnt += b / d - (a-1) / d;
    cnt -= b / e - (a-1) / e;
    cout << b - (a-1) - cnt << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        int index = 0;

        while (index + 4 < s.Length)
        {
            //dream
            if (s[index] == 'd' && s[index + 1] == 'r' && s[index + 2] == 'e' && s[index + 3] == 'a' && s[index + 4] == 'm')
            {
                index += 5;
                if (index + 1 < s.Length && s[index] == 'e' && s[index + 1] == 'r')
                {
                    if (!(index + 2 < s.Length && s[index + 2] == 'a'))
                    {
                        index += 2;
                    }
                }
            }
            //erase
            else if (s[index] == 'e' && s[index + 1] == 'r' && s[index + 2] == 'a' && s[index + 3] == 's' && s[index + 4] == 'e')
            {
                index += 5;
                if (index < s.Length && s[index] == 'r')
                {
                    index += 1;
                }
            }
            else
            {
                break;
            }
        }
        if (index == s.Length)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 11232
using System;



    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(' ');
            int length = int.Parse(x[0]);
            int side = int.Parse(x[1]);

            int area = length * side;
            double circumference = 2 * (length + side);

            Console.WriteLine(area + " " + circumference);
        }
}



Measured memory_bytes: 9108
#include<stdio.h>
int main(void) 
{
	int p,n[101],n_p[101]={0},max=0,add;
	int a,b,c,d,f=0,lank=1,cnt,i,counter=0;
	scanf("%d",&p);
	for(cnt=0;cnt<p*(p-1)/2;cnt++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d){
			n_p[a]+=3;
		}
		else if(d>c){
			n_p[b]+=3;
		}
		else if(d==c){
			n_p[a]+=1;
			n_p[b]+=1;
		}
	}
	for(i=1;i<=p;i++){
		for(cnt=1;cnt<=p;cnt++){
			if(n_p[cnt]>max){
				max=n_p[cnt];
				add=cnt;
			}
		}
		n_p[add]=0;
		for(cnt=1;cnt<=p;cnt++){
			if(max==n_p[cnt]){
				f=1;
			}
		}
		n[add]=lank;
		max=0;
		if(f==0){
			lank=1+lank+counter;
			counter=0;
		}
		else if(f==1){
			counter++;
		}
		f=0;
	}
	for(cnt=1;cnt<=p;cnt++){
		printf("%d\n",n[cnt]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int> a(200100);
vector<int> b(200100);

int main() {
	int n, k;
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	rep(_, k) {
		rep(i, n) b[i] = 0;
		rep(i, n) {
			int l = max(0, i - a[i]), r = min(n + 3, i + a[i]);
			b[l] += 1;
			b[r + 1] -= 1;
		}
		int now = 0;
		rep(i, n) {
			now += b[i];
			a[i] = now;
		}
		int m = 1001001001;
		rep(i, n) m = min(a[i], m);
		if (m == n) break;
	}
	rep(i, n) cout << a[i] << (i == n - 1 ? '\n' : ' ');
}


Measured memory_bytes: 4676
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

ll N, M, Q;
ll a[100];
ll b[100];
ll c[100];
ll d[100];
ll A[100];

ll maxs = -1;

void dfs(ll deps, ll x)
{
  if (deps == N + 1)
  {
    ll sum = 0;
    REP(i, Q)
    {
      ll ii = i + 1;
      if (A[b[ii]] - A[a[ii]] == c[ii])
      {
        sum += d[ii];
      }
    }
    maxs = max(maxs, sum);
    return;
  }
  FOR(i, x, M)
  {
    A[deps] = i;
    dfs(deps + 1, i);
  }
}

signed main()
{

  cin >> N >> M >> Q;
  REP(i, Q)
  {
    ll ii = i + 1;
    ll ai, bi, ci, di;
    cin >> ai >> bi >> ci >> di;
    a[ii] = ai;
    b[ii] = bi;
    c[ii] = ci;
    d[ii] = di;
  }

  dfs(1, 1);
  cout << maxs << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    int n;
    cin >> n;
    ll ten = 1, nine = 1, eight = 1;
    for (int i = 0; i < n; i++) {
        ten = (ten * 10) % MOD;
        nine = (nine * 9) % MOD;
        eight = (eight * 8) % MOD;
    }
    cout << (ten - nine * 2 + eight + MOD * 2) % MOD << endl;
    return 0;
}

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

const ll INF = pow(10, 9) + 7;

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && A!=C){
    cout <<"Yes";
    return 0;
  }
   if(A==C && A!=B){
    cout <<"Yes";
    return 0;
  }
   if(C==B && A!=C){
    cout <<"Yes";
    return 0;
  }
  cout << "No";
}


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

#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  int n,s[1100]={};
  while(983294){
    cin >> n;
    if(n==0) break;
    int total = 0;
    rep(i,n){
      cin >> s[i];
      total+=s[i];
    }
    double ave = 1. * total / n;
    double sig = 0;
    rep(i,n){
      sig += pow(1.*s[i]-ave,2);
    }
    printf("%.10f\n", sqrt(sig/n));
  }
}



Measured memory_bytes: 3200
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main(){
	FIO
	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	indexed_set s;
	long long ans = 0;
	for(int i = 0; i < n; i++){
		s.insert(a[i]);
		long long pos = s.order_of_key(a[i]);
		pos = (long long)s.size() - pos - 1;
		ans += pos;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cmath>

using namespace std;

#define y1 roman_kaban
#define rank oryshych_konb
//const int mod = int(1e9) + 7;

const int MX = 20500;
int a[MX];
int b[MX];
int p[MX];

int main()
{
    //freopen("in.txt","r", stdin);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> p[i];
    for(int i = n - 1; i >= 0; i--){
        p[i]--;
        for(int j = p[i]; j < n; j++)
            a[j] += i + 1;
        for(int j = 0; j <= p[i]; j++)
            b[j] += i + 1;
    }
    for(int i = 0; i < n; i++)
        cout << a[i] <<' ';
    cout << "\n";
    for(int i = 0; i < n; i++)
        cout << b[i] <<' ';
    cout << "\n";
    return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int H = scn.nextInt();
		int W = scn.nextInt();
		int h = scn.nextInt();
		int w = scn.nextInt();
		System.out.println(H*W-(h*W+H*w-h*w));
		scn.close();
	}
}

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

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

  int ans = 0;
  for (int i = 0; i + 1 < S.size(); i++) {
    if (S[i] == S[i + 1]) {
      S[i + 1] = (S[i + 1] == '0' ? '1' : '0');
      ans++;
    }
  }

  cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'N') {
      a++;
    }
    else if (S.at(i) == 'W') {
      b++;
    }
    else if (S.at(i) == 'S') {
      c++;
    }
    else {
      d++;
    }
  }
  
  if (a > 0 && c == 0) {
    cout << "No" <<endl;
  }
  else if (a == 0 && c > 0) {
    cout << "No" <<endl;
  }
  else if (b > 0 && d == 0) {
    cout << "No" <<endl;
  }
  else if (b == 0 && d > 0) {
    cout << "No" <<endl;
  }
  else {
    cout << "Yes" <<endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define l(x) a[x].l
#define r(x) a[x].r
using namespace std;
void file(){
    freopen("read.in","r",stdin);
    freopen("write.out","w",stdout);
}
const int N=500010;
inline int read(){
    int sym=0,res=0;char ch=getchar();
    while (!isdigit(ch))sym|=(ch=='-'),ch=getchar();
    while (isdigit(ch))res=(res<<3)+(res<<1)+(ch^48),ch=getchar();
    return sym?-res:res;
}
struct node{
    int l,r;
}a[N];
int n,m,ans=1,now;
bool cmp(node a,node b){
    return a.r==b.r?a.l>b.l:a.r<b.r;
}
int main(){
    n=read();
    for (int i=1;i<=n;i++){
        int x=read(),y=read();
        l(i)=x-y;r(i)=x+y;
    }
    sort(a+1,a+n+1,cmp);now=r(1);
    for (int i=2;i<=n;i++){
        if (l(i)>=now)ans++,now=r(i);
    }
    printf("%d",ans);
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    ll n, a[200010], sum[200010];
    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
        if (i == 0)
            sum[i] = a[i];
        else
            sum[i] = sum[i - 1] + a[i];
    }

    ll ans = 10000000000;
    for (int i = 0; i < n - 1; i++)
    {
        ll sunuke = sum[i];
        ll arai_san = sum[n - 1] - sum[i];
        ans = min(ans, abs(sunuke - arai_san));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct node {
    int id = -1;
    node* parent;
    node* left;
    node* right;
    int _depth = -1;
    int _height = -1;
    
    void setLeft(node* child) {
        this->left = child;
        child->parent = this;
    }
    void setRight(node* child) {
        this->right = child;
        child->parent = this;
    }
    
    int depth() {
        if(_depth>=0) return _depth;
        if(parent==NULL) return _depth = 0;
        return _depth = parent->depth() + 1;
    }
    
    int height() {
        if(_height>=0) return _height;
        if(left==NULL && right==NULL) return _height = 0;
        if(left==NULL) return _height = right->height() + 1;
        if(right==NULL) return _height = left->height() + 1;
        return _height = max(left->height(), right->height()) + 1;
    }
    
    int parent_id() const {
        if(parent==NULL) return -1;
        return parent->id;
    }
    
    int sibling_id() const {
        if(parent==NULL) return -1;
        if(parent->left==NULL || parent->right==NULL) return -1;
        if(parent->left->id==this->id) return parent->right->id;
        if(parent->right->id==this->id) return parent->left->id;
        return -1;
    }
    
    int degree() const {
        return int(left!=NULL) + int(right!=NULL);
    }
    
    string type() const {
        if(parent==NULL) return "root";
        if(left==NULL && right==NULL) return "leaf";
        return "internal node";
    }
};

ostream& operator<<(ostream& os, node& e) {
    os << "node " << e.id << ": parent = " << e.parent_id() << ", sibling = " << e.sibling_id() << ", degree = " << e.degree() << ", depth = " << e.depth() << ", height = " << e.height() << ", " << e.type();
    return os;
}

int main() {
    int n;
    cin >> n;
    vector<node> tree(n);
    for(int i=0; i<n; i++) {
        int id, l, r;
        cin >> id >> l >> r;
        tree[id].id = id;
        if(l>=0) tree[id].setLeft(&tree[l]);
        if(r>=0) tree[id].setRight(&tree[r]);
    }
    for(auto e : tree) cout << e << endl;
    
}


Measured memory_bytes: 3224
import java.util.Scanner;

public class Main
{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = a*2+b*2;
        System.out.println(area +" "+ length);
        if(sc!=null){
            sc.close();
        }
    }
}


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

int main(void)
{
    int N, K;
    cin >> N >> K;

    int ans;
    if (N % K == 0)
    {
        ans = 0;
    }
    else
    {
        ans = 1;
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXM = 200000;
const int MAXN = 300000;

int N, M;
struct edge{
	int u, v, c;
}edges[MAXM + 5];
bool operator < (edge a, edge b) {
	return a.c < b.c;
}
vector<int>G[MAXN + 5];
void addedge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}
int vcnt, fa[MAXN + 5], con[MAXN + 5], vis[MAXN + 5];
int dis[MAXN + 5];
int Find(int x) {
	if( fa[x] == x ) return x;
	return fa[x] = Find(fa[x]);
}
void Union(int x, int y) {
	int fx = Find(x), fy = Find(y);
	if( fx != fy ) fa[fx] = fy;
}
void bfs(int s) {
	for(int i=0;i<=min(vcnt*2,MAXN);i++) dis[i]=-1;
	//memset(dis,-1,sizeof dis);
	queue<int>que; que.push(s);
	dis[s] = 0;
	while( !que.empty() ) {
		int f = que.front(); que.pop();
		for(int i=0;i<G[f].size();i++) {
			if( dis[G[f][i]] == -1 ) {
				dis[G[f][i]] = dis[f] + 1;
				que.push(G[f][i]);
			}
		}
	}
}
int main() {
	while(~scanf("%d%d", &N, &M)){
        for(int i=0;i<=min(3*N,MAXN);i++) G[i].clear();
        edges[M+1].u=edges[M+1].v=edges[M+1].c=0;
        for(int i=1;i<=M;i++)
            scanf("%d%d%d", &edges[i].u, &edges[i].v, &edges[i].c);
        sort(edges+1, edges+M+1);
        vcnt = N; int lst = 1;
        for(int i=2;i<=M+1;i++) {
            if( edges[i].c != edges[i-1].c ) {
                for(int j=lst;j<i;j++) {
                    fa[edges[j].u] = edges[j].u;
                    fa[edges[j].v] = edges[j].v;
                    con[edges[j].u] = con[edges[j].v] = 0;
                    vis[edges[j].u] = vis[edges[j].v] = false;
                }
                for(int j=lst;j<i;j++)
                    Union(edges[j].u, edges[j].v);
                for(int j=lst;j<i;j++) {
                    if( fa[edges[j].u] == edges[j].u )
                        if( con[edges[j].u] == 0 )
                            con[edges[j].u] = (++vcnt);
                    if( fa[edges[j].v] == edges[j].v )
                        if( con[edges[j].v] == 0 )
                            con[edges[j].v] = (++vcnt);
                }
                for(int j=lst;j<i;j++) {
                    if( !vis[edges[j].u] ) {
                        addedge(edges[j].u, con[Find(edges[j].u)]);
                        vis[edges[j].u] = true;
                    }
                    if( !vis[edges[j].v] ) {
                        addedge(edges[j].v, con[Find(edges[j].v)]);
                        vis[edges[j].v] = true;
                    }
                }
                lst = i;
            }
        }
        bfs(1);
        if( dis[N] == -1 ) puts("-1");
        else printf("%d\n", dis[N] / 2);
	}
}


Measured memory_bytes: 24192
#include <stdio.h>
signed main(){
    int N,M,i,j,count=0;
    double sum=0;
    scanf("%d %d",&N,&M);
    int A[100];
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        sum+=A[i];
    }
    sum/=4*M;
    for(i=0;i<N;i++){
        if(A[i]>=sum){
            count++;
        }
    }
    if(count>=M){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return(0);
}

Measured memory_bytes: 1632
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = n / (a + b);
        long s = c * a;
        long d = n % (a + b);
        if(d > a){
            s = s + a;
        }else{
            s = s + d;
        }
        System.out.println(s);
        sc.close();
    }
}

Measured memory_bytes: 35788
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int dp[2020][2020];
int dpX[2020];
int dpY[2020];
int a[2020];
int N, Z, W;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Z >> W;
    for(int i=1; i<=N; i++) cin >> a[i];
    for(int i=0; i<=N; i++)
        for(int j=0; j<=N; j++)
            dp[i][j] = -1;

    dp[0][N] = abs(Z-a[N]);
    dp[N][0] = abs(W-a[N]);
    for(int i=1; i<N; i++){
        dp[i][N] = abs(a[i]-a[N]);
        dp[N][i] = abs(a[i]-a[N]);
    }

    for(int i=0; i<N; i++){
        dpX[i] = dp[i][N];
        dpY[i] = dp[N][i];
    }

    for(int i=N-1; i>=0; i--){
        for(int j=N-1; j>=0; j--){
            if(i==j) continue;
            if(i < j){
                dp[i][j] = dpY[j];
                dpX[i] = min(dpX[i], dp[i][j]);
            }else{
                dp[i][j] = dpX[i];
                dpY[j] = max(dpY[j], dp[i][j]);
            }
        }
    }
    int ans = 0;
    for(int i=1; i<=N; i++)
        ans = max(ans, dp[i][0]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16128
from itertools import product
s = input()
x, y = map(int,input().split())
L = [len(i) for i in s.split('T')]
X = {L[0]}
Y = {0}
for i in L[2::2]:
    X = {j + k for j, k in product(X, [-i, i])}
for i in L[1::2]:
    Y = {j + k for j, k in product(Y, [-i, i])}
if x in X and y in Y:
    print('Yes')
else:
    print('No')

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class union_find{
	vector<int> a;
public:
	union_find(int n):a(n,-1){}
	int find(int x){
		if(a[x]<0) return x;
		return a[x]=find(a[x]);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x!=y){ a[x]+=a[y]; a[y]=x; }
	}
	int size(int x){ return -a[find(x)]; }
};

const int L=100000;

int main(){
	int n; scanf("%d",&n);

	union_find U(2*L);
	vector<int> x(n),y(n);
	rep(i,n){
		scanf("%d%d",&x[i],&y[i]); x[i]--; y[i]--;
		U.unite(x[i],y[i]+L);
	}

	map<int,pair<int,int>> Cnt;
	set<int> Sx,Sy;
	rep(i,n){
		if(Sx.count(x[i])==0){
			++Cnt[U.find(x[i])].first;
			Sx.emplace(x[i]);
		}
		if(Sy.count(y[i])==0){
			++Cnt[U.find(y[i]+L)].second;
			Sy.emplace(y[i]);
		}
	}

	long long res=0;
	for(auto a:Cnt){
		res+=1LL*a.second.first*a.second.second;
	}
	printf("%lld\n",res-n);

	return 0;
}


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

long long power(long long a, long long b, long long MOD) {
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    long long x = power(a, b / 2, MOD);
    x *= x;
    x %= MOD;
    if(b & 1) {
        x *= a;
        x %= MOD;
    }
    return x;
}

void Solve() {
    long long n, MOD = 1e9 + 7;
    cin >> n;
    long long ans = power(10, n, MOD);
    ans -= power(9, n, MOD);
    ans -= power(9, n, MOD);
    ans += power(8, n, MOD);
    while(ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3592
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
#include<math.h>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
#define hayai cin.tie(0);ios::sync_with_stdio(false);
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;
ll mod=998244353;

int main(){
    hayai
    int n,m,k;
    cin>>n>>m>>k;
    rep0(i,n+1){
      rep0(j,m+1){
        if(k==i*j+(n-i)*(m-j)){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
    cout<<"No"<<endl;
      return 0;
}

Measured memory_bytes: 892
import sys
from itertools import product
from collections import Counter
input = sys.stdin.readline

H, W, N = map(int, input().split())
udlr = [-1, 0, 1]
center = []

for _ in range(N):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    for i, j in product(udlr, repeat=2):
        if 0 < a + i < H - 1 and 0 < b + j < W - 1:
            center.append((a + i, b + j))

black = Counter(list(Counter(center).values()))
black[0] = (H - 2) * (W - 2) - sum(list(black.values()))

for i in range(10):
    if black.get(i):
        print(black[i])
    else:
        print(0)

Measured memory_bytes: 198528
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll mod=1e9+7;
const ll inf=1e17+500;
const ll maxn=5e5+500;

ll a[4][maxn];
set<ll> st[2][2];

ll fen[maxn];
ll find(ll a){
    ll ans=0;
    for(a++;a>0;a-=(a&(-a))){
        ans+=fen[a];
    }
    return ans;
}
void update(ll a){
    for(a++;a<maxn;a+=(a&(-a))){
        fen[a]++;
    }
}
ll inv(vector<ll> vec){
    fill(fen,fen+maxn,0);
    reverse(vec.begin(),vec.end());
    ll ans=0;
    for(auto v:vec){
        ans+=find(v);
        update(v);
    }
    return ans;
}
int main(){
    ll n;
    cin>>n;
    for(ll i=1;i<=3;i++){
        for(ll j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    for(ll i=1;i<=3;i++){
        for(ll j=1;j<=n;j++){
            st[i%2][j%2].insert(a[i][j]);
        }
    }
    for(ll i=1;i<=3;i++){
        for(ll j=1;j<=n;j++){
            st[i%2][j%2].erase(i+3*j-3);
        }
    }
    ll v=st[0][0].size()+st[0][1].size()+st[1][0].size()+st[1][1].size();
    if(v>0){
        cout<<"No";
        return 0;
    }
    ll paino=0;
    ll paine=0;
    vector<ll> vec[2];
    for(ll j=1;j<=n;j++){
        vector<ll> sr;
        sr.pb(a[1][j]);
        sr.pb(a[2][j]);
        sr.pb(a[3][j]);
        sort(sr.begin(),sr.end());
        if(sr[1]!=sr[0]+1 || sr[2]!=sr[1]+1){
            cout<<"No";
            return 0;
        }
        if(sr[0]==a[3][j]){
            if(j%2==1){
                paino++;
            }else{
                paine++;
            }
        }
        vec[j%2].pb(sr[0]);
    }
    ll invo=inv(vec[1]);
    ll inve=inv(vec[0]);
    if(invo%2!=paine%2 || inve%2!=paino%2){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
}




Measured memory_bytes: 30720
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


lint N, A, B, C, D;
map<pair<lint, bool>, lint> mp;

__int128 rec(lint x, bool ok_add)
{
    if (x == 0) return 0;
    if (x == 1) return D;
    if (mp.count(make_pair(x, ok_add))) return mp[make_pair(x, ok_add)];

    __int128 ret = __int128(D) * x;

    if (x % 2)
    {
        if (ok_add) chmin(ret, rec(x / 2 + 1, false) + A);
        else chmin(ret, rec(x / 2, true) + A + D);
    }
    else
    {
        chmin(ret, rec(x / 2, false) + A);
    }

    int mod3 = x % 3;
    if (mod3 == 1 and ok_add)
    {
        chmin(ret, rec(x / 3, true) + B + D);
    }
    else if (mod3 <= 1)
    {
        chmin(ret, rec(x / 3, false) + B + D * mod3);
    }
    else
    {
        chmin(ret, rec(x / 3 + 1, false) + B + D * (3 - mod3 - ok_add));
    }
    int mod5 = x % 5;
    if (mod5 == 2 and ok_add)
    {
        chmin(ret, rec(x / 5, true) + C + D * mod5);
    }
    else if (mod5 <= 2)
    {
        chmin(ret, rec(x / 5, false) + C + D * mod5);
    }
    else
    {
        chmin(ret, rec(x / 5 + 1, false) + C + D * (5 - mod5 - ok_add));
    }

    mp[make_pair(x, ok_add)] = ret;
    return ret;
}

lint Sol()
{
    mp.clear();
    cin >> N >> A >> B >> C >> D;
    return rec(N, false);
}

int main()
{
    int T;
    cin >> T;
    while (T--) cout << Sol() << '\n';
}


Measured memory_bytes: 4176