akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H,W;
  cin >> H >> W;
  
  vector<char> g(H*W);
  int i;
  for(i=0;i<H*W;i++){
    cin >> g.at(i);
  }
  
  vector<int> y(H),x(W);
  for(i=0;i<H*W;i++){
    if(g.at(i) == '#'){
      y.at(i/W)+=1; x.at(i%W)+=1;
    } 
  }
  
  int j;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(y.at(i)!=0 && x.at(j)!=0){
        cout << g.at(i*W+j);
      }  
    }    
    if(y.at(i)!=0){
      cout << endl;
    }
  }
}



Measured memory_bytes: 256
namespace ProconLib{

    template<typename Int>
    Int extGCD(Int a,Int b,Int& x,Int& y){
        if(b==0){
            x=Int(1);
            y=Int(0);
            return a;
        }
        else{
            Int g=extGCD(b,a%b,x,y); 
            // translation
            // bx+(a%b)y==g
            // bx+(a-a/b*b)y=g
            // a*y+b*(x-a/b)=g
            Int tmp=x;
            x=y;
            y=tmp-a/b*y;
            return g;
        }
    }
}
#include<bits/stdc++.h>
using namespace std;
using namespace ProconLib;

using ll=long long;
int main(){
    ll a,b; cin>>a>>b;
    ll x,y;
    extGCD(a,b,x,y);
    cout<<x<<" "<<y<<endl;
    return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main(void) {
	int n=0;
	int x=0;
	int sum=0;
	while( scanf("%d",&n),n!=0){
	int i=0;
	sum=0;
	for(i=0;i<n/4;++i){
		scanf("%d",&x);
		sum=sum+x;
	}
	printf("%d\n",sum); }
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 1e5 + 10, inf = 1e9 + 10, mod = 1e9 + 7;
ll d[1010][1010];
char a[1010][1010];
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            cin >> a[i][j];
        }
    }
    d[1][1] = 1;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(i == 1 && j == 1)d[i][j] = 1;
            else if(a[i][j] == '.')d[i][j] = (d[i][j - 1] + d[i - 1][j]) % mod;
        }
    }
    cout << d[n][m];
}


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

float N,K;

int main(){
    int a;
    cin >> N >> K;
    vector<int> A;
    for(int i=0;i<N;i++){
        cin >> a;
        A.push_back(a);
    }
    
    int g=1;
    while (true){
        if(N<=K+(K-1)*(g-1)) break;
        else g++;
    }
    cout << g << endl;
    
    return 0;
}

Measured memory_bytes: 3936
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int main(){
  int n,a,b;
  string s;
  cin>>n>>a>>b>>s;

  int in=0,ex=0;
  rep(i,n){
    if(s[i]=='a' && (in+ex)<(a+b)){
      in++;
      cout<<"Yes"<<endl;
    }
    else if(s[i]=='b' && ex<b && (in+ex)<(a+b)){
      ex++;
      cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
#define vll vector<ll>
#define inf 1e18
#define pll pair<ll,ll>
#define ff first 
#define ss second 
#define PI acos(-1)
using namespace std;

int main() 
{
    fastio; 
    ll T=1;
    //cin>>T; 
    while(T--)
    { 	
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(max(a*c,b*d),max(a*d,b*c))<<endl;
	}
}
 

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    VLL A(N);
    map<ll, ll> count;
    rep(i,N){
        cin >> A[i];
        count[A[i]]++;
    }
    ll ans=1;
    if(N%2==0){
        stl_rep(itr, count){
            if(itr->S!=2){
                cout << 0 << endl;
                return 0;
            }
        }
        rep(i,N/2){
            ans*=2;
            ans%=MOD;
        }
    }
    else{
        //cout << "heloo" << endl;
        stl_rep(itr, count){
            if(itr->S!=1 && itr->S!=2){
                cout << 0 << endl;
                return 0;
            }            
            if(itr->S==1){
                if(itr->F!=0){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        if(count[0]==1){
            for(int i=0; i<(N-1)/2; i++){
                ans*=2;
                ans%=MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7804
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

    int a,b;
    cin>>a>>b;
    cout<<max(0ll,a-b-b)<<endl;
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string[] wether = { "Sunny", "Cloudy", "Rainy" };

            string x = Console.ReadLine();

            //for (int i = 0; i < wether.Length; i++)
            //{
                if(x == "Sunny")
                {
                    Console.WriteLine(wether[1]);
                }
                else if(x == "Cloudy")
                {
                    Console.WriteLine(wether[2]);
                }
                else if (x == "Rainy")
                {
                    Console.WriteLine(wether[0]);
                }
            //}

                
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int a[1010], c[1010];
int main() {
	int n, q;
	cin >> n;
	rep(i, n)cin >> a[i];
	cin >> q;
	while (q--) {
		int b, e, t;
		cin >> b >> e >> t;
		rep(i, e - b)swap(a[b + i], a[t + i]);
	}
	rep(i, n)cout << a[i] << (i == n - 1 ? "\n" : " ");
	return 0;
}


Measured memory_bytes: 3072
import sys
while 1:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  else:
    for h in range(H):
      for w in range(W):
         if (h + w) % 2 == 0:
           sys.stdout.write("#")
         else:
           sys.stdout.write(".")
      print ""
    print ""
 
  

Measured memory_bytes: 6440
// A - Expired?
#include <bits/stdc++.h>
using namespace std;

int main(){
	int x, a, b; cin>>x>>a>>b;
	int c = b - a;
	string ans = "safe";
	if(c > x) ans = "dangerous";
	if(c <= 0) ans = "delicious";
	cout<< ans <<endl;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

typedef long double R;
const R PI = acos(-1.0);
const R inf = -1e10;
const R ad = 5 * PI - 20;
const R los = 10 * PI - 20;
const R EPS = 1e-15;
const int INF = 1e9;

bool in(int x, int l, int r)
{
	return x >= l && x <= r;
}

const int MN = 200010;

int sx, sy, gx, gy;
int N;
pii pt[MN];
int lis[MN];

int main() {
	scanf("%d %d %d %d", &sx, &sy, &gx, &gy);

	if (sx > gx) {
		swap(sx, gx);
		swap(sy, gy);
	}

	scanf("%d", &N);
	rep(i, N) scanf("%d%d", &pt[i].fi, &pt[i].se);

	if (sy > gy) {
		gy = 2 * sy - gy;
		rep(i, N) {
			pt[i].se = 2 * sy - pt[i].se;
		}
	}

	vector<pii> pts;

	rep(i, N) if (in(pt[i].fi, sx, gx) && in(pt[i].se, sy, gy)) {
		pts.eb(pt[i]);
	}

	rep(i, MN) lis[i] = INF;
	lis[0] = -INF;

	sort(ALL(pts));

	rep(i, pts.size()) {
		int v = pts[i].se;
		int p = lower_bound(lis, lis + MN, v) - lis;
		lis[p] = v;
	}

	int u = lower_bound(lis, lis + MN, INF) - lis - 1;

	int md = min(gx - sx + 1, gy - sy + 1);

	R ret = (R)(-sy - sx + gy + gx) * 100;

	if (u < md) {
		ret += ad * u;
	} else {
		ret += ad * (u-1) + los;
	}

	printf("%.12Lf\n", ret);

	return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <queue> 
#include <map>

using namespace std;

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};
 
typedef struct Puzzle {
	int M[9];
	int space;
	string path;
	bool operator<(const Puzzle & p) const {
		for (int i=0;i<9;i++) {
			if (M[i] == p.M[i]) continue;
			return M[i] > p.M[i];
		}
		return false;
	}
} Puzzle;

bool check(Puzzle & p) {
	for (int i=0;i<8;i++) {
		if (p.M[i] != i+1) return false;
	}
	return true;
}

string bfs(Puzzle & p) { //广度优先搜索 
	queue<Puzzle> Q;
	map<Puzzle,bool> V; //标记该状态是否被访问
	Puzzle u,v;
	p.path = "";
	Q.push(p);
	V[p] = true;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		if (check(u)) return u.path;
		
		int sx = u.space / 3;
		int sy = u.space % 3;
		
		for (int r = 0;r<4;r++) {
			int tx = sx + dx[r];
			int ty = sy + dy[r];
			if (tx < 0 || ty < 0 || tx >= 3 || ty >= 3) continue;
			
			v = u;
			swap(v.M[u.space],v.M[tx * 3 + ty]);
			v.space = tx*3 + ty;
			
			if (!V[v]) {
				V[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
			
		}
	}	
	return "unsolvable";
}

int main() {
	Puzzle in;
	for (int i=0;i<9;i++) {
		cin >> in.M[i];
		if (in.M[i] == 0) {
			in.space = i;
		}
	}
	string ans = bfs(in);
	cout << ans.size() << endl;
	return 0;
}


Measured memory_bytes: 30588
#include <stdio.h>
#define NOT_FOUND -111
int line (int ,int *,int );

int main(){
  
  int i,a[10000],b[500],n,q,c=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&b[i]);
    if( line(n,a,b[i])!=NOT_FOUND)
      c++;
      
  }
  printf("%d\n",c);

  return 0;
} 
  line(int n,int a[],int key){
    int i = 0;
  a[n] = key;
  while (a[i]!= key) 
    i++;
  if (i ==n )
    return NOT_FOUND;
  return i;
  }



Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int n, k, p[200005], q[200005], l, r, ans;
bool small[200005], big[200005];

void push1(int x)
{
    r++;
    while (q[r - 1] >= x && r - 1 >= l) r--;
    q[r] = x;
}

void push2(int x)
{
    r++;
    while (q[r - 1] <= x && r - 1 >= l) r--;
    q[r] = x;
}

void pop(int x)
{
    if (q[l] == x) l++;
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> p[i];
    l = 1, r = 1, q[1] = p[1];
    for (int i = 2; i < k; i++) push1(p[i]);
    for (int i = k; i <= n; i++)
    {
        push1(p[i]);
        if (q[l] == p[i - k + 1]) small[i] = 1;
        pop(p[i - k + 1]);
    }
    l = r = 1, q[1] = p[1];
    for (int i = 2; i < k; i++) push2(p[i]);
    for (int i = k; i <= n; i++)
    {
        push2(p[i]);
        if (q[l] == p[i]) big[i] = 1;
        pop(p[i - k + 1]);
    }
    for (int i = k + 1; i <= n; i++) if (small[i - 1] && big[i]) ans++;
    int now = p[1], st = 1, cnt = 0;
    for (int i = 2; i <= n; i++)
    {
        if (p[i] > now) now = p[i];
        else
        {
            if (i - st >= k)
            {
                cnt++;
                ans++;
            }
            st = i;
            now = p[i];
        }
    }
    if (n + 1 - st >= k)
    {
        cnt++;
        ans++;
    }
    if (cnt >= 1) ans--;
    cout << n - k - ans + 1 << endl;
    return 0;
}

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

int main(){
  int temp,temp2;
  while(cin>>temp>>temp2){
    int sum=temp+temp2;
    int keta=1;
    while(sum/10>0){
      sum/=10;
      keta++;
    }
    cout<<keta<<endl;
  }

  return 0;
}

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

int findSomeOfDigits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(void) {
  int n;
  cin >> n;
  int ans = 1e9;
  rep(i,1,n){
    int A = i;
    int B = n - i;
    ans = min(findSomeOfDigits(A) + findSomeOfDigits(B),ans);
  }
  cout << ans <<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() { 
  long long a,b,v,w,t,sa=0;
  cin>>a>>v>>b>>w>>t;
  sa=b-a;
  if(sa<0){
    sa=sa*(-1);
  }
  if(sa<=(v-w)*t){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}
  
  


Measured memory_bytes: 3620
#include<bits/stdc++.h>
typedef long long ll;
const int N=1e5+5;
int n;
int d[105][3];
int main(){
    // freopen("a.in","r",stdin);
    // int T;scanf("%d",&T);for(int tttt=1;tttt<=T;tttt++){
    if(1){
    scanf("%d",&n);
    long long ans=0;
    for(int i=1;i<=n;i++){
        ans+=(n%i)?(n/i):(n/i-1);
    }
    printf("%lld\n",ans);
    }return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll N = 30;
ll a[N], b[N], c[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	FOR(i,1,n+1) cin >> a[i];
	FOR(i,1,n+1) cin >> b[i];
	FOR(i,1,n) cin >> c[i];
	
	ll res = 0;
	FOR(i,1,n+1) res += b[i];
	FOR(i,1,n) if (a[i]+1 == a[i+1]) res += c[a[i]];
	cout << res << endl;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    int rig=0;
    in cnt=0;
    int sum=0;
    for(int lef=0;lef<n;lef++){
        while(rig<n && (sum|a[rig])==(sum+a[rig])){
            sum +=a[rig];
            rig ++;
        }
        cnt +=(rig-lef);
        sum -=a[lef];
    }
    cout<<cnt<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = 0
ans = 0
for i in range(N):
    a, b = map(int, readline().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    ans = max(cnt,ans)
print('Yes' if ans >=3 else 'No')

Measured memory_bytes: 61848
/*author : Yashvardhan
Sunday, April 26, 2020
5:32 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int a,b,c,d;
	cin >> a >> b >> c >> d;

	int t = 0;
	while(a > 0 && c > 0){
		if(t%2 == 0) c -= b;
		else a -= d;
		debug(a,c);
		t = (t + 1) % 2;
	}

	

	if(c <= 0) cout << "Yes" << endl;
	else cout << "No" << endl; 
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 3612
/*17D8103001E Fukushima Emi persimmon8 c++ 19.10.24*/

#include<iostream>
#include<iomanip>
#include<cmath>
#define PI 3.14159265358979323846
using namespace std;

struct point{
    double x,y;
};

void print(point x){
    cout<<fixed<<setprecision(8)<<x.x<<" ";
    cout<<fixed<<setprecision(8)<<x.y<<endl;
}

double kock(int n,point p1,point p2){
    if(n==0) return 0;
//sin(do*PI/180.0)
    point s,t,u;
    s.x=(2*p1.x+1*p2.x)/3;
    s.y=(2*p1.y+1*p2.y)/3;
    t.x=(1*p1.x+2*p2.x)/3;
    t.y=(1*p1.y+2*p2.y)/3;
    u.x=(t.x-s.x)*cos(60*PI/180.0)-(t.y-s.y)*sin(60*PI/180.0)+s.x;
    u.y=(t.x-s.x)*sin(60*PI/180.0)+(t.y-s.y)*cos(60*PI/180.0)+s.y;
    kock(n-1,p1,s);
    print(s);
    kock(n-1,s,u);
    print(u);
    kock(n-1,u,t);
    print(t);
    kock(n-1,t,p2);
}

int main(){

    point s,g;
    s.x=0;
    s.y=0;
    g.x=100;
    g.y=0;

    int n;
    cin>>n;
    print(s);
    kock(n,s,g);
    print(g);

    return 0;
}


Measured memory_bytes: 3292
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc087.contest.atcoder.jp/tasks/arc087_b>
問題文============================================================
 二次元平面の原点にロボットが置かれています。 最初、ロボットは x 軸の正の向きを向いています。
 
 このロボットに命令列 s が与えられます。 s は次の 2 文字のみからなり、先頭から末尾まで順に実行されます。
 
 F : 今向いている向きに長さ 1 だけ移動する。
 T : 時計回りまたは反時計回りの好きな方向に 90 度だけ向きを変える。
 ロボットの目標は、命令列をすべて実行し終わった後に座標 (x,y) にいることです。
 この目標が達成可能か判定してください。
 
=================================================================

解説=============================================================

 Tによりロボットは時計回り or 反時計回りに必ず向きを変えるので
 この問題は x方向と y方向の移動座標をそれぞれ独立で考えることができる
 
 よって、 xとyに関して、その移動距離(T ~ T までの距離)を持った配列を用意しておき
 dp[i][j] := i番目の移動をするとき, 開始地点 j である
 
 と行ったdpを行えば良い
 
================================================================
*/

const int Base = 10000;
bool dpx[4050][2*Base];
bool dpy[4050][2*Base];

void solve(){
    string s; cin >> s;
    int x,y; cin >> x >> y;
    vector<int> xs,ys;
    
    bool dir = true;
    int cnt = 0;
    for(int i = 0; i < s.length();i++){
        if(s[i] == 'T'){
            if(dir){
                xs.push_back(cnt);
            }else{
                ys.push_back(cnt);
            }
            cnt = 0;
            dir = !dir;
        }else{
            cnt++;
        }
    }
    if(dir){
        xs.push_back(cnt);
    }else{
        ys.push_back(cnt);
    }
    
    dpx[1][xs[0] + Base] = true;
    for(int i = 1; i < (int)xs.size();i++){
        for(int j = 0; j < 2*Base;j++){
            if(!dpx[i][j]) continue;
            dpx[i+1][j+xs[i]] = dpx[i+1][j-xs[i]] = true;
        }
    }
    
    dpy[0][Base] = true;
    for(int i = 0; i < (int)ys.size();i++){
        for(int j = 0; j < 2*Base;j++){
            if(!dpy[i][j]) continue;
            dpy[i+1][j+ys[i]] = dpy[i+1][j-ys[i]] = true;
        }
    }
    if(dpx[xs.size()][Base + x] && dpy[ys.size()][Base + y]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 156416
#include<stdio.h>

#define N 100

int main(){
  int n,u,k,v;
  int M[N][N];
  
  scanf("%d",&n);
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      M[i][j] = 0;
    }
  }
  for(int i = 0; i < n; i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(int j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      printf("%d",M[i][j]);
      if(j != n-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  vector<int> a(3);
  rep(i,3) cin>>a[i];
  sort(all(a));
  cout<<(a[0]+a[1]==a[2]?"Yes":"No")<<endl;
  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 x = sc.nextInt();
    int ans = 1;
    for(int i = 2; i < 50; i++) {
      for(int j = 2; j < 10; j++) {
        if((int)Math.pow(i, j) <= x) ans = Math.max(ans, (int)Math.pow(i, j));
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21204
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define vll(A) vector<long lonh> A;
#define ivt(A,n,p) vector<long long> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair

const long long inf=(long long)1e18;
const long long mod=(long long)(1e9+7);

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1; 
    x = x % p;  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll a,ll p)
{
   return power(a,p-2,p);
}

int main()
{
    // #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
    fio;
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        char n;
        i(n);
        if(int(n)<97)
        {cout<<"A\n";}
        else
        {
            cout<<"a\n";
        }
        
    }
    return 0;
}

Measured memory_bytes: 3612
T = list(input())

# 単純に，周りの文字からきまると思われる
# 左端の？は特別
if T[0:2] == '?D':
    T[0] = 'P'
for i,t in enumerate(T):
    if t == '?':
        T[i] = 'D'
print(''.join(T))


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> As(N, 0);
    for (auto & a : As) cin >> a;
    int count_negative = 0;
    long long min_abs = 1e9;
    long long cum_sum = 0;
    for (const auto & a : As){
        if (a < 0) ++count_negative;
        if (abs(a) < min_abs) min_abs = abs(a);
        cum_sum += abs(a);
    }
    if (min_abs == 0 or (count_negative % 2 == 0)){
        cout << cum_sum << endl;
    }else{
        cout << cum_sum - min_abs - min_abs << endl;
    }
    return 0;
}

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

using namespace std;

int main(void){
  ll n, k;

  cin >> n >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());


  ll l = -1e18 - 1, r = 1000000000000000000, mid;
  while(l + 1 < r){
    mid = (l + r)/2;

    ll num = 0;
    for (int i = 0; i < n; i++){
      ll left, right, m;
      if (a[i] > 0){
        if (a[i] * a[0] > mid){
          left = -1;
        }
        else {
          left = 0;
          right = n;
          while(left + 1 < right){
            m = (left + right)/2;
            if (a[i] * a[m] <= mid)
              left = m;
            else
              right = m;
          }
        }
        num += left + 1;
      } else if (a[i] < 0){
        if (a[i] * a[n-1] > mid){
          right = n;
        }
        else {
          left = -1;
          right = n - 1;
          while(left + 1 < right){
            m = (left + right)/2;
            if (a[i] * a[m] <= mid)
              right = m;
            else
              left = m;
          }
        }

        num += n - right;
      }
      else{
        if (mid >= 0)
          left = n - 1;
        else
          left = -1;

        num += left + 1;
      }
      if (a[i] * a[i] <= mid)
        num--;

    }

    if (num/2 >= k)
      r = mid;
    else
      l = mid;
  }
 

  cout << r << endl;

  return 0;
}


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

if __name__ == "__main__":
    S = input()
    if S[0] != "A":
        print("WA")
        exit()

    count = 0
    for i in range(2, len(S)-1):
        if S[i] == "C":
            count += 1
            c_i = i
            continue
    if count != 1:
        print("WA")
        exit()

    for i in range(1, len(S)):
        if i == c_i:
            continue
        if not (97 <= ord(S[i]) and ord(S[i]) <= 122):
            print("WA")
            exit()

    print("AC")


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  string s;
  cin >> s;

  string t;
  forr(c, s) {
    if (c == 'T' && SZ(t) && t.back() == 'S') {
      t.pop_back();
    }
    else t.push_back(c);
  }

  _p("%d\n", SZ(t));
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


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

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

  int count[10][10] = {0};

  for(int i=1;i<=n;i++){
    if(i%10 == 0) continue;
    int a = i%10;
    int b = i;
    while(b>=10) b /= 10;
    count[a][b]++;
  }

  int ans = 0;

  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      ans += count[i][j] * count[j][i];
    }
  }

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

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

int main()
{
  double r;

  cin >> r;
  
  printf("%.6lf",r*r*3.141592653589);
  cout << " ";
  printf("%.6lf\n",2*r*3.141592653589);
  
  return 0;
}

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

using namespace std;

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

const double pi = acos(-1.0);

int main(){
    double n; cin >> n;
    vector<double> x(n), y(n);
    double p1=0, p2=0, p3= 0, pinf = -1;
    rep(i,n)cin >> x[i];
    rep(i,n){
        cin >> y[i];
        p1 += abs(x[i] - y[i]);
        p2 += (x[i] - y[i])*(x[i] - y[i]);
        p3 += pow(abs(x[i] - y[i]), 3);
        pinf = max(pinf, abs(x[i] - y[i]));
    }

    p2 = sqrt(p2);
    p3 = pow(p3, (double)1/(double)3);

    printf("%.10f\n%.10f\n%.10f\n%.10f\n", p1, p2, p3, pinf);
    return 0;
}


Measured memory_bytes: 3412
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            tri = [l[i], l[j], l[k]]
            if len(set(tri)) != 3:
                continue
            if 2*max(tri) < sum(tri):
                cnt += 1
print(cnt)

Measured memory_bytes: 9180
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << x * min(n, k) + y * max(0, n - k) << endl;
    return 0;
}

Measured memory_bytes: 256
//s勾p防盗专用语句
//学习使我快乐，让我的人生更加美好
#include<cstdio>
#include<iostream>
#include<cmath>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<vector>
#include<stack>//无敌缺省源
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	int ans=(n-1)*(m-1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi a(4), b(2);
  rep(i, 4) cin >> a[i];
  rep(i, 2) cin >> b[i];
  sort(rall(a)), sort(rall(b));
  cout << a[0] + a[1] + a[2] + b[0] << endl;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define start_routine int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define SPEED cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define endl '\n'
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end() 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

int dp[500+1][500+1];
int ct[500+1][500+1];
int rec (int i, int j) {
  if (j < i) return 0;

  if (dp[i][j] < inf) return dp[i][j];
  if (i == j) return ct[i][j];
  dp[i][j] = ct[i][j] + rec(i + 1, j) + rec(i, j - 1) - rec(i + 1, j - 1);
  return dp[i][j];
}

signed main () {
  start_routine;
  // SPEED;
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  #endif

  int n, m, q;
  cin >> n >> m >> q;

  for (int i = 0; i <= 500; i++) {
    for (int j = 0; j <= 500; j++) dp[i][j] = inf, ct[i][j] = 0;
  }
  for (int i = 0; i < m; i += 1) {
    int l, r;
    cin >> l >> r;
    ct[l][r]++;
  }
  for (int i = 0; i < q; i += 1) {
    int l, r;
    cin >> l >> r;
    cout << rec(l, r) << endl;
  }
  end_routine;
}


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

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int fac[100050];

int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	fac[0] = fac[1] = 1;
  	for(int i=2;i<=100050;i++) fac[i] = 1ll*fac[i-1]*i % mod;
  	int n,m,ans = 0;
  	cin >> n >> m;
  	if(n>=m+2 || n+2<=m){
  		cout << 0 << "\n";
		return 0;	
	}
	if(n==m){
		ans = 1ll*2*fac[n]*fac[m] % mod;
	}else{
		ans = 1ll*fac[n]*fac[m] % mod;
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

		final Scanner stdin = new Scanner( System.in );

		while ( true ) {

			final int n = stdin.nextInt();
			final int p = stdin.nextInt();
			if ( n == 0 && p == 0 ) break;

			int deck = p;
			final int[] hands = new int[ n ];
			int turn = 0;

			while ( true ) {
				if ( deck > 0 ) {
					hands[ turn ]++;
					deck--;
					if ( hands[ turn ] == p ) break;
				} else {
					deck = hands[ turn ];
					hands[ turn ] = 0;
				}
				turn = ( turn + 1 ) % n;
			}
			System.out.println( turn );
		}	
    }    
}

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

bool leap(int x){
  if(x % 400 == 0) return true;
  if(x % 100 == 0) return false;
  return x % 4 == 0;
}

int main(){
  int a, b;

  for(int SET = 1; cin >> a >> b, a || b; SET++){
    if(SET != 1){
      cout << endl;
    }

    bool ans = false;

    for(int i = a; i <= b; i++){
      if(leap(i)){
        cout << i << endl;
        ans = true;
      }
    }

    if(!ans) cout << "NA\n";
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u == NIL)return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL)return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    T[i].p = NIL;
  }

  for(i = 0;i < n;i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }

  for(i=0; i<n;i++)if(T[i].p == NIL)root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2112
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[2000][2000];
vector<H>e[2000][2000];
int siz[2000][2000];
int c[2000];
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n - 2; j++) {
			e[min(i, a[i][j])][max(i, a[i][j])].push_back(H{ min(i,a[i][j + 1]),max(i,a[i][j + 1]) });
			siz[min(i, a[i][j + 1])][max(i, a[i][j + 1])]++;
		}
	}
	vector<H>s;
	queue<H>q;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (siz[i][j] == 0) q.push(H{ i,j });
		}
	}
	while (!q.empty()) {
		H t = q.front(); q.pop();
		s.push_back(t);
		for (int i = 0; i < e[t.x][t.y].size(); i++) {
			if (--siz[e[t.x][t.y][i].x][e[t.x][t.y][i].y] == 0) {
				q.push(e[t.x][t.y][i]);
			}
		}
	}
	if (s.size() < n * (n - 1) / 2) {
		cout << -1 << endl;
		return 0;
	}
	int t = 1;
	for (int i = 0; i < s.size(); i++) {
		if (c[s[i].x] == t || c[s[i].y] == t) {
			t++;
		}
		c[s[i].x] = t; c[s[i].y] = t;
	}
	cout << t << endl;
}

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

int main() {
  int a, b, N;
  cin >> a >> b >> N;
  int ans=0;
  for(int i=0; i<N; i++){
    int s, f;
    cin >> s >> f;
    if(s < b && a < f) ans=1;
  }
  cout << ans << endl;
}

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

struct point {
    double x;
    double y;
};

double dist_from_origin(struct point a) {
    double distance = 0.0;

    distance = sqrt(a.x * a.x + a.y * a.y);

    return distance;
}

int main() {
    int n;
    double d;
    cin >> n >> d;

    struct point p[n];
    int ans = 0;
    rep(i, n) {
        cin >> p[i].x;
        cin >> p[i].y;
        if(dist_from_origin(p[i]) <= d) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6964
#include <bits/stdc++.h>
using namespace std;
int ct[105];
int main(){
    int n, k;
    scanf("%d%d",&n,&k);
    for (int i = 0; i < k; i++){
        int d;
        scanf("%d",&d);
        for (int j = 0; j < d; j++){
            int x;
            scanf("%d",&x);
            ct[x]++;
        }
    }
    int ans = 0;
    for (int i = 1 ; i <= n; i++){
        if (ct[i] == 0) ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 3816
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(rall(a));
    ll ans = a[0];
    if(!(n&1)) {
        ans += accumulate(a.begin()+1, a.begin()+n/2, 0LL)*2;
    } else {
        ans += accumulate(a.begin()+1, a.begin()+n/2, 0LL)*2+a[n/2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3972
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
bl = True
for x, y in zip(S[:], S[1:]):
    if x == y:
        bl = False

print('Good' if bl else 'Bad')
# 

Measured memory_bytes: 2940
def examA():
    A, B = LI()
    ans = max(A+B,A-B,A*B)
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 38384