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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n, m, c;
    cin >> n >> m >> c;
    vector<ll> a(m), b(m);
    ll res = 0;
    REP(i, m)
    {
        cin >> b[i];
    }
    REP(i, n)
    {
        ll cnt = 0;
        REP(j, m)
        {
            cin >> a[j];
            cnt += (a[j] * b[j]);
        }
        // dump(cnt + c);
        if (cnt + c > 0)
        {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(A: Long, B: Long){
    if (Math.max(A,B)> 8) println(":(")
    else println("Yay!")
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    solve(A, B)
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

vector<int64> po, podd;
vector<int64> dp(1e6+1, INF), dpdd(1e6+1, INF);

void init(){
	for(int64 i = 1;i*(i+1)*(i+2)/6 <= 1000000;i++){
		int64 x = i*(i+1)*(i+2)/6;
		po.push_back(x);
		if(x%2) podd.push_back(x);
	}

	dp[0] = 0; dpdd[0] = 0;
	REP(i, po.size()){
		for(int32 j = 0;j+po[i] < dp.size();j++){
			dp[j+po[i]] = min(dp[j+po[i]], dp[j]+1);
		}
	}
	REP(i, podd.size()){
		for(int32 j = 0;j+podd[i] < dpdd.size();j++){
			dpdd[j+podd[i]] = min(dpdd[j+podd[i]], dpdd[j]+1);
		}
	}
}

int main(void){
	init();
	int32 N;
	while(cin >> N && N){
		cout << dp[N] << " " << dpdd[N] << endl;
	}
}


Measured memory_bytes: 18156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
vector<long long> divisor(long long n){
    vector<long long> res;
    for(long long i = 1; i*i <= n; i++){
        if(n%i==0){
            res.push_back(i);
            if(n/i != i)res.push_back(n/i);
        }
    }
    return res;
}
int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  unordered_map<int,int> mp;
  rep(i,n) {
    cin >> a[i];
    mp[a[i]]++;
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    auto div = divisor(a[i]);
    bool ok = true;
    mp[a[i]]--;
    for (auto e : div) if (mp[e] > 0) ok = false;
    if (ok) res++;
    mp[a[i]]++;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 32492
import itertools as it

S = input()
R = [(k,len(list(g))) for k,g in it.groupby(S)]
#print(R)

tot = 0
n = 0
for k,val in R:
  if k == "<":
    n = val
    tot += n*(n+1)/2
  elif k == ">":
    tot += max(0,val-n)
    tot += val*(val-1)/2
    n = 0
  
print(int(tot))

Measured memory_bytes: 27524
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int a,b,c,s;
    cin >>a>>b;
    
    c=(int)pow(10.0,(double)((int)log10(b))+1)*a+b;
    s=(int)sqrt((double)c);
    Yn(((s*s==c)||((s+1)*(s+1)==c)));


    return 0;
}





Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
using namespace std;

int main()
{
    int n;
    set<string> dict;
    string op, key, str;
    cin >> n;
    for (int i=0; i<n; ++i){
        cin >> op;
        if(op == "insert"){
            cin >> str;
            dict.insert(str);
        }
        else if(op == "find"){
            cin >> key;
            if(dict.find(key) != dict.end()){
                cout << "yes" << endl;
            }
            else {
                cout << "no" << endl;
            }
        }
    }
}


Measured memory_bytes: 32216
using System;
using System.Linq;

namespace C
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var a_s = Console.ReadLine().Split(" ").Select(s => long.Parse(s)).ToArray();
			int mod = (int)(1e9 + 7);

			var asCumsum = new long[n];
			asCumsum[0] = a_s[0];
			for (int i = 1; i < n; i++)
			{
				asCumsum[i] = asCumsum[i - 1] + a_s[i];
				asCumsum[i] %= mod;
			}

			long ans = 0;
			for (int i = 1; i < n; i++)
			{
				ans += asCumsum[i - 1] * a_s[i];
				ans %= mod;
			}

			Console.WriteLine((ans + mod) % mod);
		}
	}
}


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

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(40) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,n,a) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef pair<long long, long long> pll;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion

int main() {
	int n, k; put n >> k;
	vi a(n); rep(i, n) put a[i];
	int dp[101][101][256];
	rep(i, 101) {
		rep(j, 101) {
			rep(m, 256) {
				dp[i][j][m] = 0;
			}
		}
	}
	dp[0][0][0] = 1;
	rep(i, n) {	
		rep(m, n) {
			rep(j, 256) {
				dp[i + 1][m+1][j^a[i]] += dp[i][m][j];
				dp[i + 1][m][j] += dp[i][m][j];
				dp[i + 1][m+1][j^a[i]] %= MOD;
				dp[i + 1][m][j] %= MOD;
			}
		}
	}
	ll ans = 0;
	ll rui = 1;
	rep(i, n+1) {
		ans += rui * dp[n][i][k];
		ans %= MOD;
		rui = ( rui  * (i+1)) % MOD;
	}
	putans(ans);
END:

	return 0;
}

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

namespace ConsoleApplication83
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            char[] b = new char[2];
            b[0] = a[0];
            int c = a.Length - 2;
            b[1] = a[a.Length - 1];
            Console.WriteLine("{0}{1}{2}", b[0], c, b[1]);
        }
    }
}


Measured memory_bytes: 13140
#include<cstdio>
long long int lty=0,yzl=1000000001,yzly,hymk;
int main(){
	scanf("%d",&yzly);
	for(int mqx=1;mqx<=yzly;++mqx){
		scanf("%d",&hymk);
		if(hymk>lty){
			lty=hymk;
		}
		if(yzl>hymk){
			yzl=hymk;
		}
	}
	printf("%d",lty-yzl);
}

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

using namespace std;

class S{
public:
  int y, x, d;
  S(){}
  S(int y, int x, int d) : y(y), x(x), d(d) {}
  bool operator < (const S &s) const {
    if(y == s.y){
      if(x == s.x){
        return d < s.d;
      }
      return x < s.x;
    }
    return y < s.y;
  }
};

typedef pair<int, S> P;

const int N = 1000;
const int M = 1000001;
const int MAX_V = N * N * 4;
const int INF = 1 << 28;

int V, h, w, n, gx, gy;
int G[M][4];
int d[N][N][4];
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
char dat[N][N];

bool dijkstra(S s){
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d[0][0], d[N][0], INF);
  d[s.y][s.x][s.d] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    S v = p.second;
    if(v.y == gy && v.x == gx) return true;
    if(d[v.y][v.x][v.d] < p.first) continue;
    for(int i=0;i<4;i++){
      int cost = G[p.first][i];
      if(cost == -1) continue;
      int ny = v.y + dy[i];
      int nx = v.x + dx[i];
      if(ny < 0 || ny >= h) continue;
      if(nx < 0 || nx >= w) continue;
      if(dat[ny][nx] == '#') continue;
      if(d[ny][nx][i] > cost){
        d[ny][nx][i] = cost;
        que.push(P(d[ny][nx][i], S(ny, nx, i)));
      }
    }
  }
  return false;
}

int main(){
  while(cin >> h >> w >> n && (h|w|n)){
		fill(G[0], G[M], -1);
    string L;
    cin >> L;
    int sy, sx;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> dat[i][j];
        if(dat[i][j] == 'S'){
          sy = i;
          sx = j;
          dat[i][j] = '.';
        }
        if(dat[i][j] == 'G'){
          gy = i;
          gx = j;
          dat[i][j] = '.';
        }
      }
    }
    vector<int> vec[4];
    vec[0].push_back(0);
		vector<int> dir;
		dir.push_back(0);
    for(int i=0;i<n;i++){
			int cdir = dir.back();
      if(L[i] == 'L') dir.push_back((cdir + 3) % 4);
      else dir.push_back((cdir + 1) % 4);
      vec[dir.back()].push_back(i+1);
    }
		for(int i=0;i<=n;i++){
			for(int j=0;j<4;j++){
				int p = lower_bound(vec[j].begin(), vec[j].end(), i) - vec[j].begin();
				if(p < (int)vec[j].size()) G[i][j] = vec[j][p];
			}
    }
		/*
		for(int i=0;i<=n;i++){
			for(int j=0;j<4;j++){
				cout << G[i][j] << ' ';
			}
			cout << endl;
		}
		*/
		cout << (dijkstra(S(sy, sx, 0)) ? "Yes" : "No") << endl;
  }
	return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    vec E(N, 0), W(N, 0);
    ll cntE = 0, cntW = 0;
    REP(i,0,N) {
        if(S[i] == 'W') ++cntW;
        E[i] = cntW;
    }
    REP(i,0,N) {
        if(S[N-i-1] == 'E') ++cntE;
        W[N-i-1] = cntE;
    }

    ll m = N;
    REP(i,0,N) m = MIN(m,E[i]+W[i]-1);
    PR(m);
    

    return 0;
}

/*



*/

Measured memory_bytes: 8244
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

def check(i, s, m):
    if s == m:
        return True
    if s > m or i == n:
        return False
    if s + sum(A[i:]) < m:
        return False    
    return check(i+1, s, m) or check(i+1, s+A[i], m)

for m in M:
    if check(0, 0, m):
        print("yes")
    else:
        print("no")


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

using namespace std;


int32_t main(){

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

	int k,x;
	cin>>k>>x;
	if(k==1) cout<<x<<endl;
	else {
		for(int i=k-1;i>=1;i--){
			cout<<x-i<<' ';
		}
		cout<<x<<' ';
		for(int i=1;i<k;i++){
			cout<<x+i<<' ';
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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


Measured memory_bytes: 19124
#include <iostream>
using namespace std;
int main(){
    int cnt;
    long long dist;
    int n = 0;
    cin >> cnt >> dist;
    for(int i=0; i<cnt; i++){
        long long x, y;
        cin>>x>>y;
        if (x*x + y*y <= dist*dist){
            n ++;
        }
    }
    cout << n << endl;

}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
vector<char> convert(int n) {
    vector<char> v(3, '0');
    int i = 2;
    while(n != 0) {
        v[i] = (n % 10) + '0';
        i--;
        n /= 10;
    }
    return v;
}
int main(){
    speed;
    int n; cin >> n;
    if(n <= 999) {
        cout << "ABC";
        // vector<char> v = convert(n);
        // for(int i = 0; i < v.size(); i++) {
        //     cout << v[i];
        // }
    }   
    else {
        cout << "ABD";
        // vector<char> v = convert(n - 999);
        // for(int i = 0; i < v.size(); i++) {
        //     cout << v[i];
        // }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int gcd(int x,int y){
    return(x%y)?gcd(y,x%y):y;
}
int main(void){
    int K,x;
    long sum=0;
    scanf("%d",&K);
    for(int i=1; i<=K; i++){
        for(int j=i; j<=K; j++){
            x=gcd(j,i);
            for(int l=j; l<=K; l++){
                if(i!=j&&j!=l)
                    sum+=gcd(l,x)*6;
                else if(i!=j||j!=l)
                    sum+=gcd(l,x)*3;
                else
                    sum+=x;
            }
        }
    }
    printf("%ld",sum);
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            Console.WriteLine(N.Reverse().SequenceEqual(N)?"Yes":"No");
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define INF (1LL<<60)
#define MAX_N 100001

struct edge{ll to,cost;};
struct state{
  ll cost,pos,h;
  bool operator < (const state& p)const{
    return cost > p.cost;
  }
};

vector<edge> G[MAX_N];
ll h[MAX_N];
ll N,M,X;

void dijkstra(){
  ll ans=INF;
  ll d[MAX_N];
  priority_queue< state > Q;
  for(int i=0;i<MAX_N;i++)d[i]=INF;
  d[1]=0;
  Q.push( (state){0,1,X} );

  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.pos==N)ans=min(ans,s.cost+h[N]-s.h);

    if(s.cost>d[s.pos])continue;
    for(int i=0;i<(int)G[s.pos].size();i++){
      edge &e = G[s.pos][i];
      ll ncost=s.cost+e.cost;
      ll nh=s.h-e.cost;
      if(nh>h[e.to])ncost+=(nh-h[e.to]),nh=h[e.to];
      else if(nh<0)ncost+=(-nh),nh=0;
      if(ncost>=d[e.to])continue;
      d[e.to]=ncost;
      Q.push((state){ncost,e.to,nh});
    }
  }
  cout<<(ans==INF?-1:ans)<<endl;
}

void init(){
  for(int i=0;i<MAX_N;i++)G[i].clear();
}

int main(){
  init();
  cin>>N>>M>>X;
  for(int i=0;i<N;i++)cin>>h[i+1];
  for(int i=0;i<M;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    if(h[a]-c>=0)G[a].push_back( (edge){b,c} );
    if(h[b]-c>=0)G[b].push_back( (edge){a,c} );
  }
  dijkstra();
  return 0;
}

Measured memory_bytes: 22060
import sys
input=sys.stdin.readline
n,k,q=map(int,input().split())
win=[0]*n
for i in range(q):
    a=int(input())
    win[a-1]+=1
for i in range(n):
    if k>q-win[i]:
        print('Yes')
    else:
        print('No')




            



Measured memory_bytes: 46940
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0519
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct Edge {
	int s, t;
	Edge(int s, int t) :s(s), t(t) {}
};

vector<int> ans;

void dfs(int i,vector<vector<int>>& G,vector<bool>& f) {
	if (f[i]) return;
	f[i] = true;
	for (auto next : G[i]) {
		if (f[next]) continue;
		dfs(next, G, f);
	}
	ans.push_back(i);
	cout << i << endl;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<vector<int>> G(n + 1);
	vector<bool> f(n + 1, false);
	for (int i = 0; i < m; i++) {
		int s, t; cin >> s >> t;
		G[t].push_back(s);
	}
	for (int i = 1; i <= n;i++) {
		dfs(i, G, f);
	}
	for (int i = 0; i < n - 1; i++) {
		int s = ans[i + 1], t = ans[i];
		if (find(G[s].begin(), G[s].end(), t) == G[s].end()) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
    return 0;
}


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

int main(){
  int num;
  cin>>num;
  for(int i=0;i<num;i++){
    int a[3];
    for(int j=0;j<3;j++){
      cin>>a[j];
    }
    sort(a,a+3,greater<int>());
    if(a[0]*a[0]==a[1]*a[1]+a[2]*a[2])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x4, y4;
  if (x2>x1){
    y4 = y1 + abs(x1-x2);
  }
  else y4 = y1-abs(x1-x2);
  if (y2>y1){
    x4 = x1 - abs(y1-y2);
  }
  else x4 = x1 + abs(y1-y2);
  
  int x3, y3;
  x3 = x4 + (x2-x1);
  y3 = y4 + (y2-y1);
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec h(n);
	rep(i, n) cin >> h[i];

	Vec dp(n, LINF);
	dp[0] = 0;
	repn(i, n-1){
		repn(j, k) if(j <= i) chmin(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
	}
	co(dp[n-1]);

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;


signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a;
	rep(i, n) {
		int x;
		cin >> x;
		a.pb(x);
	}
	int sum = 0;
	int ans1 = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0 and sum <= 0) {
			//数列の偶数の時に合計の符号をプラスにしてみる
			ans1 += abs(sum) + 1;
			sum = 1;
		}
		else if (i % 2 != 0 and sum >= 0) {
			//数列の奇数の時に合計の符号をマイナスにしてみる
			ans1 += abs(sum) + 1;
			sum = -1;
		}
	}
	sum = 0;
	int ans2 = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0 and sum >= 0) {
			//数列の偶数の時に合計の符号をマイナスにしてみる
			ans2 += abs(sum) + 1;
			sum = -1;
		}
		else if (i % 2 != 0 and sum <= 0) {
			//数列の奇数の時に合計の符号をプラスにしてみる
			ans2 += abs(sum) + 1;
			sum = +1;
		}
	}

	cout << min(ans2,ans1) << endl;
 	return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

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

typedef long long LL;

const int N = 105;

LL dp[N];

int a[N];

int n;

void solve() {
    scanf("%d", &n);
    for (int i=1; i<=n; ++i)
        scanf("%d", &a[i]);

    dp[0] = 1000;
    for (int i=1; i<=n; ++i) {
        dp[i] = max(dp[i], dp[i-1]);
        for (int j=1; j<i; ++j) {
            dp[i] = max(dp[i], dp[j] % a[j] + (LL)(dp[j] / a[j]) * a[i]);
        }
    }
    printf("%lld\n", dp[n]);
}

int main() {
    solve();

    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T,typename U>void chmax(T &a,const U &b){if(a<b){a=b;}}

const int MAX=101;

int dp[MAX][MAX][MAX]={};//rg,up,dw
int rowsum[MAX][MAX]={};
int colsum[MAX][MAX]={};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W;
  cin>>H>>W;
  vector<string> A(H);
  cin>>A;
  int ex,ey;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(A[i][j]=='E'){ex=i; ey=j;}
      else if(A[i][j]=='o'){rowsum[i+1][j]=colsum[i][j+1]=1;}
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=0;j<=W;j++){
      rowsum[i][j]+=rowsum[i-1][j];
    }
  }
  for(int i=0;i<=H;i++){
    for(int j=1;j<=W;j++){
      colsum[i][j]+=colsum[i][j-1];
    }
  }
  
  //[lf,rg),[up,dw)
  for(int lf=0;lf<W;lf++){
    for(int rg=W;rg>lf;rg--){
      for(int up=0;up<H;up++){
        for(int dw=H;dw>up;dw--){
          int a=max(ex-(H-dw),up);
          int b=min(ex+up+1,dw);
          int c=max(ey-(W-rg),lf);
          int d=min(ey+lf+1,rg);
          //cout<<lf<<" "<<rg<<" "<<up<<" "<<dw<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
          if(c<=rg-1 && rg-1<d){
            chmax(dp[rg-1][up][dw],dp[rg][up][dw]+rowsum[b][rg-1]-rowsum[a][rg-1]);
          }
          if(a<=up && up<b){
            chmax(dp[rg][up+1][dw],dp[rg][up][dw]+colsum[up][d]-colsum[up][c]);
          }
          if(a<=dw-1 && dw-1<b){
            chmax(dp[rg][up][dw-1],dp[rg][up][dw]+colsum[dw-1][d]-colsum[dw-1][c]);
          }
        }
      }
    }
    for(int rg=W;rg>lf;rg--){
      for(int up=0;up<H;up++){
        for(int dw=H;dw>up;dw--){
          /*
          if(dp[rg][up][dw]>=10){
            cout<<lf<<" "<<rg<<" "<<up<<" "<<dw<<" "<<dp[rg][up][dw]<<endl;
          }
          */
          int a=max(ex-(H-dw),up);
          int b=min(ex+up+1,dw);
          int c=max(ey-(W-rg),lf);
          int d=min(ey+lf+1,rg);
          if(c<=lf && lf<d){
            chmax(dp[rg][up][dw],dp[rg][up][dw]+rowsum[b][lf]-rowsum[a][lf]);
          }
        }
      }
    }
  }
  int ans=0;
  for(int rg=W;rg>=0;rg--){
    for(int up=0;up<=H;up++){
      for(int dw=H;dw>=up;dw--){
        chmax(ans,dp[rg][up][dw]);
      }
    }
  }
  cout<<ans<<endl;

  
  return 0;
}


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

ll ans, n;
int main() {
  cin>>n;
  ll a[n+1];
  for (int i=1; i<=n; i++) {
    cin>>a[i];
    if (i%2==1&&a[i]%2==1) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

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

using ll = long long;


int main(){
  int N; cin >> N;
  vector<int> b(N);
  rep(i,N){
     cin >> b[i];
     if(b[i] > i+1){
        cout << -1 << endl;
        return 0;
     }
  }
  vector<int> ans;
  rep(i,N){
     for(int j = b.size()-1; j >= 0; j--){
        if(b[j] == j+1){
           ans.push_back(b[j]);
           b.erase(b.begin() + j);
           break;
        }
     }
  }
  if(ans.size() == N){
     for(int i = N-1; i >= 0; i--){
      cout << ans[i] << endl;
     }
  }

}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(){
    char S[11];
    scanf("%s",S);
    int d = 1000;
    for(int i = 0;i < strlen(S) - 2;i++){
        int bring = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0');
        if(d > abs(bring - 753))d = abs(bring - 753);
    }
    printf("%d\n",d);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<queue>//队列
#include<stack>//栈
#include<set>//集合
using namespace std;
#define maxn 1000000000
//sort(a,a+n);a数组排列,长度n;升序
//sort(a,a+n,greater<int>());int是数组类型;降序
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=n; i>=1; i--)
    {
        if(sqrt(i)-(int)sqrt(i)==0)
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}




Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		if (A<B) {
			int tmp = A;
			A = B;
			B = tmp;
		}
		System.out.println(Math.max(2*A-1, A+B));

	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

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

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

using namespace std;

int f(int n){
    int a_new;
    if(n%2==0){
        a_new=n/2;
    }
    else if(n%2==1){
        a_new=3*n+1;
    }

    return a_new;
}

int main(){
    int s;
    cin >> s;
    int i;
    vector<int> a(100000);

    a[0] = s;

    for(i=1;i<a.size();i++){
        a[i]=f(a[i-1]);

        for(int j=0;j<i;j++){
            
            if(a[i]==a[j]){
                goto next;
            }

        }
    }

    next:
    cout << i+1 << endl;
}

Measured memory_bytes: 640
#define inf 9223372036854775807
#define ll long long
#define pii pair<ll,ll>
#define m_p  make_pair
#define ull unsigned long long
#define spd  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
int main()
{
    spd

    ll d,t,s;

    cin>>d>>t>>s;

    if(t*s<d)
    {
        cout<<"No"<<endl;
    }

    else
        cout<<"Yes"<<endl;
}


Measured memory_bytes: 3664
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    let n = s.len();

    let mut ox = vec!['0'; n];
    let mut xo = vec!['1'; n];
    let mut c0 = 0;
    let mut c1 = 0;
    for i in 0..n {
        if i & 1 == 1 {
            ox[i] = '1';
            xo[i] = '0';
        }
        if ox[i] != s[i] {
            c0 += 1;
        }
        if xo[i] != s[i] {
            c1 += 1;
        }
    }

    println!("{}", std::cmp::min(c0, c1));
}


Measured memory_bytes: 4352
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ll n;
    cin >> n;
    vll a(n);
    f(i,0,n-1)
        cin >> a[i];
    sort(a.begin(),a.end());
    f(i,1,n-1)
        if(a[i]==a[i-1])
        {
            cout << "NO";
            return;
        }
    cout << "YES";            
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

#define ll long long

using namespace std;

int main(int argc, char* argv[]){
  string k;
  cin >> k;
  if(k.length()==2){
    cout << k << endl;
  }else{
    for(int i=0; i<3; i++) {
        cout << k[2-i];
    }
        cout << endl;
  }
  return 0;
}


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

class union_find  // union find.
{
    int* U;
public:
    union_find(int n){ U = new int [n]; for(int i = 0; i < n; i++) U[i] = i; }
    int root(int a){ if(U[a] == a){ return a; } U[a] = root(U[a]); return U[a]; }
    bool same(int a, int b){ return root(a) == root(b); }
    void join(int a, int b){ int x = root(a), y = root(b); U[x] = y; }
    ~union_find(){ delete [] U; }
};

struct edge{
    int v1, v2, w;
    bool operator < (const edge &e) const{ return w < e.w; }  // const?????????????????????
};

edge init(int ver_1, int ver_2, int weight)
{
    edge e;
    e.v1 = ver_1, e.v2 = ver_2, e.w = weight;
    return e;
}

int main()
{
    int i, j, k, w, n, q;
    scanf("%d %d", &n, &q);

    edge *ES;
    ES = new edge [q];
    union_find VS(n);

    for(k = 0; k < q; k++){
        scanf("%d %d %d", &i, &j, &w);
        ES[k] = init(i, j, w);
    }
    sort(ES, ES + q);

    int size = 0, sum = 0;
    edge e;
    for(k = 0; k < q; k++){
        e = ES[k];
        if(!VS.same(e.v1, e.v2)){
            VS.join(e.v1, e.v2);
            sum += e.w;
            size++;
        }
        if(size == n - 1) break;
    }
    printf("%d\n", sum);
    delete [] ES;

    return 0;
}

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

int main()
{
    string str;
    int res = 0;

    while (cin >> str) {
        bool flag = true;
        for (int i = 0; i < str.size(); i++)
            if (str[i] != str[str.size() - i - 1])
                flag = false;

        if (flag) res++;
    }

    cout << res << endl;

    return 0;
}

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

const double EPS = 1e-7;
void solve (int r, int n) {
  double lx[30] = {0}, rx[30] = {0};
  for (int i = 0; i < n; ++i) {
    int a, b;
    double h;
    cin >> a >> b >> h;

    for (int x = -20; x < 0; ++x) {
      if (a <= x && x < b) {
        lx[-x - 1] = max(lx[-x - 1], h);
      }
    }
    for (int x = 0; x <= 20; ++x) {
      if (a <= x && x < b) {
        rx[x] = max(rx[x], h);
      }
    }
  }
/*
  for (int i = 20; i >= 0; --i) {
    cout << lx[i] << " ";
  }
  for (int i = 0; i < 20; ++i) {
    cout << rx[i] << " ";
  }
  puts("");
*/
  double lch = -r, rch = 20.0;
  while (rch - lch > EPS) {
    double m = (lch + rch) / 2.0;
    bool f = true;

//    cout << m << endl;

    for (int i = 0; i < r; ++i) {
      double nowh = sqrt(r * r - i * i) + m - (double)r;
      if (lx[i] - nowh < EPS) f = false;
      if (rx[i] - nowh < EPS) f = false;
//      cout << f << " ";
    }
//    puts("");

    if (f) {
      lch = m;
    } else {
      rch = m;
    }
  }

  printf("%.4lf\n", lch);
}

int main() {
  int r, n;

  while (cin >> r >> n, r) {
    solve(r, n);
  }
}

Measured memory_bytes: 3196
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

const int N_MAX = 10000003, mod = 998244353;
int fac[N_MAX], iFac[N_MAX], bin[N_MAX];
int power(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1)
      ret = 1ll * x * ret % mod;
    x = 1ll * x * x % mod, y >>= 1;
  }
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  fac[0] = 1, bin[0] = 1;
  for (int i = 1; i <= n; ++i)
    fac[i] = 1ll * i * fac[i - 1] % mod, bin[i] = 2 * bin[i - 1] % mod;
  iFac[n] = power(fac[n], mod - 2);
  for (int i = n; i > 0; --i)
    iFac[i - 1] = 1ll * i * iFac[i] % mod;
  int ans = 0;
  for (int i = 0; i < n / 2; ++i)
    ans = (1ll * iFac[i] * iFac[n - i] % mod * bin[i] + ans) % mod;
  ans = (power(3, n) - 2ll * fac[n] * ans % mod) % mod;
  printf("%d\n", (ans + mod) % mod);
  return 0;
}


Measured memory_bytes: 117376
#!/usr/bin/env python3

import sys
import numpy as np

n = int(input())
aa = list(map(int, input().split()))

if 0 in aa:
    print(0)
    sys.exit()

a = [s for s in aa if s != 1]
a.sort(reverse=True)

# keta = 0
# for item in a:
#     k = len(str(item))
#     keta += k-1
#     if keta>18:
#         print(-1)
#         sys.exit()

prod = 1
for item in a:
    prod*=item
    if prod>10**18:
        print(-1)
        sys.exit()

# arr = np.array(a)
# ans = arr.prod()
# if ans>10**18:
#     print(-1)
#     sys.exit()

print(prod)


Measured memory_bytes: 40168
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,k;
  cin >>n >> k;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int num[n+1]={0};
  for(int i=0;i<n;i++){
    num[a[i]]++;
  }
  int x=0;//整数の種類
  for(int i=1;i<=n;i++){
    if(num[i]>0) x++;
  }
  int ans=0;
  if(x<=k){
    cout << ans << endl;
    return 0;
  }
  else{
    sort(num,num+n+1);
    for(int i=n-x+1;i<n-k+1;i++){
      ans+=num[i];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){return x%y==0?y:gcd(y,x%y);}
int main(){
  int N,K;cin>>N>>K;int M=0;
  vector<int>A(N);for(int i=0;i<N;i++){cin>>A[i];M=max(A[i],M);if(A[i]==K){cout<<"POSSIBLE";return 0;}}
  if(N==1){cout<<(K==A[0]?"POSSIBLE":"IMPOSSIBLE");return 0;}
  int g=gcd(A[0],A[1]);
  for(int i=2;i<N;i++)g=gcd(g,A[i]);
  cout<<(K%g==0&&K<=M?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 640
a,b,c = map(int,input().split())
k = int(input())
cnt = 0
for i in range(k):
  if a<b:
    break
  b *= 2
  cnt += 1
if (a >= b) or (k-cnt<0):
  print("No")
else:
  for i in range(k-cnt):
    if b<c:
      break
    c *= 2
  if b<c:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9120
require "bigdecimal"
require "bigdecimal/util"

def gi() gets.to_i end
def gs() gets.chomp end
def gmi() gets.split.map(&:to_i) end
def gms() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end

def comb(n,k)
  return nil if k > n
  result = 1
  1.upto() do |d|
    result *= n
    result /= d
    n -= 1
  end
  result
end

def perm(n,k)
  return nil if k > n
  result = 1
  k.times do
    result *= n
    n -= 1
  end
  result
end

def kaibun(str)
  str == str.reverse
end

#####

n = gi
as = gmi
res = 0
(1..(n-1)).each do |i|
  if as[i] == as[i-1]
    as[i] = -1
    res += 1
  end
end
print res

Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	char c[a][b];
	for(int i = 0; i < a; i++){
		for(int j = 0; j < b; j++)
			cin >> c[i][j]; 
	}
	
	for(int i = -1; i <= a; i++){
		for(int j = -1; j <= b; j++){
			if(i == -1 || i==a|| j==-1||j==b){
				cout << '#';
			}
			else{
				cout << c[i][j];
			}
		}
		cout << endl;
	}
	
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  //cin >> A;
  //cin >> A >> B;
  //cin >> A >> B >> C;
  cin >> A >> B >> C >> D >> E;
  A=A*60+B;
  C=C*60+D;
  C-=A+E;
  Out(C);
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
	string key[] = {"apple", "peach"};
	string input;
	while(getline(cin, input)){
		if(cin.eof()) break;

		stack<int> a, p;
		int k = input.find(key[0]);
		while(true){
			if(k != string::npos) a.push(k);
			else break;
			k = input.find(key[0], k + 5);
		}
		k = input.find(key[1]);
		while(true){
			if(k != string::npos) p.push(k);
			else break;
			k = input.find(key[1], k + 5);
		}

		while(!a.empty()){
			int o = a.top();
			a.pop();
			input.replace(o, 5, key[1]);
		}
		while(!p.empty()){
			int o = p.top();
			p.pop();
			input.replace(o, 5, key[0]);
		}
		
		cout << input << endl;
	}

	return 0;
}

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

const int maxn = 2000009;
int f[maxn], g[maxn], n, m, a, b;

int main(){
	scanf("%d%d", &n, &m);
	for (int i=1; i<=m; i++){
		scanf("%d%d", &a, &b);
		if (a == 1) f[b] = 1;
		if (b == 1) f[a] = 1;
		if (a == n) g[b] = 1;
		if (b == n) g[a] = 1;
	}
	for (int i=2; i<=n-1; i++) if (f[i] && g[i]) { puts("POSSIBLE"); return 0; }
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 5120
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toInt)
    val ansArray = Array(n+1){0}
    for(i in 0 until n){
        ansArray[aList[i]] = i+1
    }
    for(i in 1..n){
        print("${ansArray[i]} ")
    }
    println()
}

Measured memory_bytes: 62260
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64

int d;
double e;
int main(){
while(cin>>d>>e,d||e){
double ans=10000.0;
for(int i=0;i<=d;i++){
	double x=i;
	double y=d-i;
	double k=sqrt(x*x+y*y)-e;
	if(k<0)k*=-1;
	ans=min(ans,k);
}
printf("%.10lf\n",ans);
}
	return 0;
}


Measured memory_bytes: 3192
# 参考： https://atcoder.jp/contests/abc083/submissions/4034949
S = gets.chomp
n = S.length
ans = n
(1..(n -1)).each do |k|
  if S[k] != S[k - 1]
    tmp = [k, n - k].max
    ans = tmp if tmp < ans
  end
end
p ans

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

#define REP(i, n) for (int i = 0; i < (int)n; i++)
int N;
int a[1000000];

int main()
{
  cin >> N;
  REP(i, N) { cin >> a[i]; a[i]--; }

  set<pair<int, int>> S;

  REP(i, N) {
    if (i == a[a[i]]) {
      int m = min(i, a[i]);
      int M = max(i, a[i]);
      S.insert(make_pair(m, M));
    }
  }

  cout << S.size() << endl;

  return 0;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
#define debug(x) cout << #x << "=" << x << endl;
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); cout << (i>0 ? " ":"") << v[i++]); cout << "\n"; return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi v(n);
    cin >> v;
    map<int,int> cnt;
    ll ans = 0;
    for(int i = n-1;i>=0;i--){
        ans += cnt[i+v[i]];
        cnt[i - v[i]]++;
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 20996
N, X, Y =map(int , input().split())
ans=[0]*(N-1)
for i in range(N):
    for j in range(i+1,N):
        d = min(abs(j-i),abs(i-(X-1)) +abs(j-(Y-1))+1)
        ans[d-1]+=1

[print(l) for l in ans]

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n)cin >> v[i];
    sort(v.begin(), v.end());
    int ans = v[v.size()-1] - v[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256