akhauriyash/Code-Regression huggingface dataset:
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N);
  vector<int64_t> B(N);
  vector<int64_t> C(N);
  enum Options : int64_t { kA = 0, kB, kC, kNumOfOptions };
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i] >> B[i] >> C[i];
  }
  vector<vector<int64_t>> happy(N, vector<int64_t>(kNumOfOptions, 0));
  happy[0][kA] = A[0];
  happy[0][kB] = B[0];
  happy[0][kC] = C[0];
  for (int64_t i = 1; i < N; ++i) {
    happy[i][kA] = A[i] + max(happy[i - 1][kB], happy[i - 1][kC]);
    happy[i][kB] = B[i] + max(happy[i - 1][kA], happy[i - 1][kC]);
    happy[i][kC] = C[i] + max(happy[i - 1][kA], happy[i - 1][kB]);
  }
  cout << max(max(happy[N - 1][kA], happy[N - 1][kB]), happy[N - 1][kC]) << endl;
  return 0;
}


Measured memory_bytes: 8064
var
  a, now: array [1..15] of longint;
  p, s: array [1..15, 1..14] of longint;
  n, i, j, cnt, ans: longint;
function max(x, y: longint): longint; inline;
begin
  if x > y then exit(x) else exit(y);
end;
function check: boolean; inline;
var
  i, j, unkind: longint;
begin
  for i := 1 to n do
  begin
    unkind := 1;
    for j := 1 to a[i] do
      if now[p[i, j]] <> s[i, j] then
      begin
        unkind := 0;
        break;
      end;
    if now[i] <> unkind then exit(false);
  end;
  exit(true);
end;
procedure dfs(d: longint);
begin
  if d = n + 1 then
  begin
    if check then ans := max(ans, cnt);
    exit;
  end;
  now[d] := 0;
  dfs(d + 1);
  now[d] := 1;
  inc(cnt);
  dfs(d + 1);
  dec(cnt);
end;
begin
  read(n);
  for i := 1 to n do
  begin
    read(a[i]);
    for j := 1 to a[i] do read(p[i, j], s[i, j]);
  end;
  dfs(1);
  writeln(ans);
end.

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll H, W, K;
	cin >> H >> W >> K;

	vector<string> Ss(H);
	for (ll i = 0; i < H; ++i) {
		cin >> Ss[i];
	}

	vector<vector<ll>> res(H, vector<ll>(W, -1));
	ll first_cake_row = -1;
	ll area_name = 0LL;
	for (ll i = 0; i < H; ++i) {
		bool cake_found = false;
		for (ll j = 0; j < W; ++j) {
			if (Ss[i][j] == '#') {
				cake_found = true;
				break;
			}
		}
		if (!cake_found) {
			if (first_cake_row != -1) {
				for (ll j = 0; j < W; ++j) {
					res[i][j] = res[i - 1][j];
				}
			}
		}
		else {
			if (first_cake_row == -1) {
				first_cake_row = i;
			}
			++area_name;
			bool first_cake_found = false;
			for (ll j = 0; j < W; ++j) {
				if (Ss[i][j] == '#') {
					if (!first_cake_found) {
						first_cake_found = true;
					}
					else {
						++area_name;
					}
				}
				res[i][j] = area_name;
			}
		}
	}

	for (ll i = first_cake_row - 1; i >= 0; --i) {
		for (ll j = 0; j < W; ++j) {
			res[i][j] = res[i + 1][j];
		}
	}

	for (ll i = 0; i < H; ++i) {
		for (ll j = 0; j < W; ++j) {
			cout << res[i][j];
			if (j + 1LL < W) {
				cout << " ";
			}
		}
		cout << endl;
	}

	return 0;
}

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

	solve();

	return 0;
}


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

string s;
char ta[26] = {};

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

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 1e9 + 7;
const int N = 1e5 + 10, M = 1e3 + 10;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;

#define pi acos(-1)


int main()
{
    string s;
    cin >> s;
    int len = s.size();
    if(len & 1)
        puts("No");
    else
    {
        for(int i = 1; i < len; i += 2)
        {
            if(s[i] == 'i' && s[i - 1] == 'h')
                continue;
            else
            {
                puts("No");
                return 0;
            }
            
        }
        puts("Yes");
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    const int col = 3;
    const int row = 3;
    int mn1 = INF;
    int mn2 = INF;
    int mn3 = INF;
    vector<vector<int>> box(col, vector<int>(row));
    for (int i = 0; i < col; i++)
    {
        for (int j = 0; j < row; j++)
        {
            cin >> box[i][j];
            if (i == 0)
            {
                mn1 = min(mn1, box[i][j]);
            }
            if (i == 1)
            {
                mn2 = min(mn2, box[i][j]);
            }
            if (i == 2)
            {
                mn3 = min(mn3, box[i][j]);
            }
        }
    }
    // cij = ai + bj
    // -> cij - ai = bj
    // -> 各cijからaiを引いた数がすべて同じbjであれば成立する

    // aiを可能性のある最小値0に設定して、各行が同じ値であればOK
    for (int i = 0; i < col; i++)
    {
        for (int j = 0; j < row; j++)
        {
            if (i == 0)
            {
                box[i][j] -= mn1;
            }
            if (i == 1)
            {
                box[i][j] -= mn2;
            }
            if (i == 2)
            {
                box[i][j] -= mn3;
            }
        }
    }

    for (int i = 0; i < row; i++)
    {
        for (int j = col - 1; j >= 1; j--)
        {
            if (box[j][i] != box[j - 1][i])
            {
                cout << "No" << endl;
                return (0);
            }
        }
    }
    cout << "Yes" << endl;
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int a;
    cin >> a;
    if(i % 2 && a % 2) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	string S;
	cin >> S;

	int res = S.compare("2019/04/30");
	if (res <= 0) {
		cout << "Heisei" << endl; 
	} else {
		cout << "TBD" << endl; 
	}
	return 0;
}



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

const int MX = 6400, N = 82;
bitset<2*MX> pos[N][N];
int a[N][N], b[N][N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

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

    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin>>a[i][j];


    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin>>b[i][j];


    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            int d = abs(a[i][j] - b[i][j]);
            if (i == 1 && j == 1)   pos[i][j][MX+d] = 1;
            if (i > 1)  pos[i][j] |= (pos[i-1][j] << d) | (pos[i-1][j] >> d);
            if (j > 1)  pos[i][j] |= (pos[i][j-1] << d) | (pos[i][j-1] >> d);

//            cout<<i<<" "<<j<<" "<<d<<" ---> ";
//            for (int x=0; x<2*MX; x++)
//                if (pos[i][j][x])   cout<<x-MX<<" "; cout<<endl;
        }
    }

    for (int i=0; i<MX; i++) {
        if (pos[n][m][MX + i] || pos[n][m][MX - i]) {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 10624
n = int(input())
s = input()[::-1]
cnt = s.count('1')

p1 = sum(pow(2, i, cnt+1) * (s[i] == '1') for i in range(n))
if cnt > 1:
    m1 = sum(pow(2, i, cnt-1) * (s[i] == '1') for i in range(n))

def op(n):
    popcnt = bin(n).count('1')
    return n%popcnt

pre = [0]*1000000
for i in range(1,1000000):
    pre[i] = pre[op(i)] + 1

def solve(i):
    if s[-i] == '0':
        r = (p1 + pow(2, n-i, cnt+1))%(cnt+1)
    else:
        if cnt == 1:
            return 0
        r = (m1 - pow(2, n-i, cnt-1))%(cnt-1)
    return 1 + pre[r]

for i in range(n):
    print(solve(i+1))


Measured memory_bytes: 17324
A, B, C, D = map(int, input().split())

nC = B // C - A // C
if A % C == 0:
    nC += 1

nD = B // D - A // D
if A % D == 0:
    nD += 1


def gcd(x, y):
    if x > y:
        x, y = y, x
    while x != 0:
        x, y = y % x, x
    return y


lcm = C * D // gcd(C, D)
nLCM = B // lcm - A // lcm
if A % lcm == 0:
    nLCM += 1

remain = (B - A + 1) - (nC + nD - nLCM)
print(remain)


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B ,C;
    cin >> A >> B >> C;

    if(A == B){
        cout << C << endl;
        return 0;
    }

    if(B == C){
        cout << A << endl;
        return 0;
    }

    if(C == A){
        cout << B << endl;
        return 0;
    }
    return 0;
}

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

#define int long long

signed main() {
#ifdef _DEBUG
	freopen("in", "r", stdin);
#endif
	int n, k;
	cin >> n >> k;
	n %= k;
	while (abs(n - k) <= n) n = abs(n - k);
	cout << n << '\n';
}


Measured memory_bytes: 256
// problem: longest distance from 0 to V-1, checking for positive cycle only on this path
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF = 1 << 30;

struct Tadj {
	int id, w;
};
vector<vector<Tadj>> adjList;
int V;

vector<ll> ld;

vector<bool> visited;
void dfs(int u) {
   if (visited[u]) return;
   visited[u] = 1;
   for (Tadj v : adjList[u])
      dfs(v.id);
}

/* O(V*E) - retorna true se há um ciclo positivo entre 0 e V-1 */
bool belmman_ford(int s) {
   ld.assign(V, -INF); ld[s] = 0;

   ll first0, first1;
   for (int i = 0; i < V; i++) {
      // para cada aresta u --v.w--> v.id
      for (int u = 0; u < V; u++)
         for (Tadj v : adjList[u]) {
            if (ld[u] + v.w > ld[v.id] && ld[u] > -INF) {
               ld[v.id] = ld[u] + v.w;

               // se ainda conseguiu relaxar depois das V-1 vezes anteriores
               if (i == V-1) {
                  visited.assign(V, 0);
                  dfs(v.id);
                  if (visited[0] || visited[V-1]) return true;
               }
            }
         }
   }

   return false;
}

int main() {
   int E, P; cin >> V >> E >> P;
   adjList.assign(V, vector<Tadj>());
   while (E--) {
      int u, v, w; cin >> u >> v >> w; u--; v--; w -= P;
      adjList[u].push_back({v, w});
   }

   cout << (belmman_ford(0)? -1 : max(ld[V-1], 0ll)) << endl;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,0,a.size()){
        cin>>a[i];
    }
    rep(i,0,b.size()){
        cin>>b[i];
    }
    rep(i,0,n/2){
        swap(b[i],b[n-i-1]);
    }
    bool ok = true;
    rep(i,0,a.size()){
        if ( a[i] == b[i] ){
            ok = false;
            break;
        }
    }
    if(!ok){
        ok = !ok;
    }
    else{
        cout<<"Yes"<<endl;
        rep(i,0,b.size()){
            cout<<b[i]<<" ";
        }
        cout<<endl;
        return;
    }
    rep(i,0,n/4){
        swap(b[i],b[n/2-i-1]);
    }
    rep(i,0,a.size()){
        if ( a[i] == b[i] ){
            ok = false;
            break;
        }
    }
    if(!ok){
        ok = !ok;
    }
    else{
        cout<<"Yes"<<endl;
        rep(i,0,b.size()){
            cout<<b[i]<<" ";
        }
        cout<<endl;
        return;
    }
    rep(i,(n&1)?n/2 + 1:n/2,3*n/4){
        swap(b[i],b[3*n/2 - 1 - i]);
    }

    rep(i,0,b.size()){
        if (a[i] == b[i]){
            ok = false;
            break;
        }
    }
    if ( !ok){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
        rep(i,0,b.size()){
            cout<<b[i]<<" ";
        }
        cout<<endl;
    }
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    FAST_IO;
	int h,a;
    cin>>h>>a;

    if (h%a == 0)
    {
        cout<<h/a<<endl;
    }
    else
    {
        int x = h/a;
        cout<<x+1<<endl;
    }
    
}

Measured memory_bytes: 256
def minesweeper(grid, x, y):
    if grid[x][y] == '.':
        cnt = 0
        for i in range(x-1, x+2): 
            if i < 0 or H-1 < i:
                pass
            else :
                for j in range(y-1, y+2):
                    if j < 0 or W - 1 < j:
                        pass
                    else :
                        if grid[i][j] == '#':
                            cnt += 1
        grid[x][y] = str(cnt)
    return grid


H, W = [int(i) for i in input().split()]

grid = []
for h in range(H):
    grid.append([l for l in input()])
    
for x in range(H):
    for y in range(W):
        grid = minesweeper(grid, x, y)
        
for row in grid:
    print(''.join(row))

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
struct UnionFind {
  UnionFind(int n) : data(n, -1) {}

  int root(int ver) { return data[ver] < 0 ? ver : data[ver] = root(data[ver]); }

  void unite(int ver1, int ver2) {
    ver1 = root(ver1);
    ver2 = root(ver2);
    if (ver1 != ver2) {
      if (data[ver1] > data[ver2]) swap(ver1, ver2);
      data[ver1] += data[ver2];
      data[ver2] = ver1;
    }
  }

  bool same(int ver1, int ver2) { return root(ver1) == root(ver2); }

  int size(int ver) { return -data[root(ver)]; }

private:
  vector<int> data;
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  UnionFind uf(100001);
  int n; cin >> n;
  vector<vector<int> > x(100001), y(100001);
  REP(i, n) {
    int xx, yy; cin >> xx >> yy;
    x[xx].emplace_back(yy);
    y[yy].emplace_back(xx);
  }
  FOR(i, 1, 100001) {
    int sz = x[i].size();
    FOR(j, 1, sz) uf.unite(x[i][j - 1], x[i][j]);
  }
  vector<int> nanbon(100001, 0), cnt(100001, 0);
  vector<set<int> > st(100001);
  FOR(i, 1, 100001) if (!y[i].empty()) {
    int root = uf.root(i);
    ++nanbon[root];
    for (int e : y[i]) {
      st[root].emplace(e);
      ++cnt[root];
    }
  }
  long long ans = 0;
  FOR(i, 1, 100001) if (nanbon[i] >= 2) {
    ans += (long long)nanbon[i] * st[i].size() - cnt[i];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 16256
while true
  h, w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  for i in 1..h
    if i % 2 == 0
      w.times do |j|
        if j % 2 == 0
          print "."
        else
          print "#"
        end
      end
      print "\n"
    else
      w.times do |j|
        if j % 2 == 0
          print "#"
        else
          print "."
        end
      end
      print "\n"
    end
  end
  print "\n"
end

Measured memory_bytes: 8744
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

# X = int(input())
# if 599 >= X:
#     ans = 8
# elif 600 <= X <= 799:
#     ans = 7
# elif 800 <= X <= 999:
#     ans = 6
# elif 1000 <= X <= 1199:
#     ans = 5
# elif 1200 <= X <= 1399:
#     ans = 4
# elif 1400 <= X <= 1599:
#     ans = 3
# elif 1600 <= X <= 1799:
#     ans = 2
# else:
#     ans = 1
# print(str(ans))

X = int(input())
print(8 - (X - 400) // 200)

Measured memory_bytes: 10900
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n, a, b;
    cin >> n >> a >> b;
    
    ll ans = (n/(a+b)) * a;
    n %= (a+b);

    if (n >= a) ans += a;
    else ans += n;


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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()
ans = ""
for i in range(len(s)):
    if s[i] == "0":
        ans += "0"
    elif s[i] == "1":
        ans += "1"
    else:
        if i !=  0:
            ans = ans[:-1]
        
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD          1000000007
#define PI           3.14159265358979
#define rep(i, n)    for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)   for (auto i : v)
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define pb(x)       push_back(x)
#define mp(x, y)     make_pair((x), (y))
#define fi           first
#define se           second
#define setp(x)      setprecision(x)
#define mset(m, v)   memset(m, v, sizeof(m))
//#define int          long long
//static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
static const int INF =        0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long             ll;
typedef vector<int>           vi;
typedef vector<double>        vd;
typedef vector<long long>     vll;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef pair<int, int>        pii;
typedef pair<long, long>      pll;
typedef vector<pii>           vpii;
typedef vector<pll>           vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

int main() { 
        int n, x;
        cin >> n >> x;
        vi mid;
        vi side;
        if (x >= 2 * n - 1 || x == 1) cout << "No";
        else {
                rer(i, 1, 2 * n - 1) {
                        if (i == x - 1 || i == x || i == x + 1) mid.pb(i);
                        else side.pb(i);
                }
                int i = 0;
                cout << "Yes" << endl;
                while (i < n - 2) cout << side[i] << endl, i ++;
                rep(j, 3) cout << mid[j] << endl;
                while (i < side.size()) cout << side[i] << endl, i ++;
        }
        return 0;
}



Measured memory_bytes: 2420
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;

public class Main {
	char[] c;
	int id;

	int exp() {
		if ('0' <= c[id] && c[id] <= '9') {
			return num();
		}
		ArrayList<Integer> list = new ArrayList<Integer>();
		id++;
		while (c[id] != ']') {
			if (c[id] == '[') {
				list.add(exp());
			} else {
				list.add(num());
			}
		}
		id++;
		int count = list.size() + 1;
		count /= 2;
		Collections.sort(list);
		int res = 0;
		for (Integer I: list) {
			res += I;
			count--;
			if (count == 0) {
				break;
			}
		}
		return res;
	}

	int num() {
		int res = 0;
		while ('0' <= c[id] && c[id] <= '9') {
			res *= 10;
			res += c[id] - '0';
			id++;
		}
		res += 1;
		res /= 2;
//		System.out.println(res);
		return res;
	}

	void run() {
		MyScanner sc = new MyScanner();

		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			c = sc.next().toCharArray();
			id = 0;
			System.out.println(exp());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

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

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

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

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}

Measured memory_bytes: 50200
// AOJ 1245: Gap
// 2017.10.18 bal4u@uu

#include <stdio.h>
//#include <stdlib.h>
#include <string.h>

#define HASHSIZ 120011
unsigned hash[HASHSIZ+2], *hashend = hash + HASHSIZ;

// for hash tabel
int insert(unsigned x)
{
	unsigned *p = hash + x % HASHSIZ;
	while (*p) {
		if (*p == x) return 1;
		if (++p == hashend) p = hash;
	}
	*p = x;
	return 0;
}

typedef struct { char r, c; } P;
#define QMAX 70000
typedef struct { P gap[4]; char tbl[4][8]; int s; } Q;
Q q[QMAX+3]; int top, end;

char tbl[4][8];
P gap[4];

// check if finished, and calc hash value
unsigned check(char tbl[4][8])
{
	int r, c, v, f;
	unsigned x;

	for (x = 0, f = 0, v = 11, r = 0; r < 4; r++, v += 10) {
		for (c = 1; c < 7; c++) {
			x = (x << 1) + tbl[r][c];
			if (tbl[r][c] != v+c) f = 1;
		}
		x = (x << 1) + tbl[r][7];
	}
	if (f) return x;
	return 0;
}

int main()
{
	int t, i, r, c, r2, c2, v, s, ans;
	unsigned x;

	scanf("%d", &t);
	while (t-- > 0) {
		memset(hash, 0, sizeof(hash));
		for (r = 0; r < 4; r++) for (c = 1; c < 8; c++) scanf("%d", &v), tbl[r][c] = v;

		// initial layout
		for (i = 0, v = 11, r = 0; r < 4; r++, v += 10) {
			tbl[r][0] = v;
			for (c = 1; c < 8; c++)	if (tbl[r][c] % 10 == 1) {
				tbl[r][c] = 0, gap[i].r = r, gap[i++].c = c;
			}
		}
		if ((x = check(tbl)) == 0) { puts("0"); continue; }
		insert(x);

		ans = -1, top = 0, end = 1;
		memcpy(q[0].gap, gap, sizeof(gap)), memcpy(q[0].tbl, tbl, sizeof(tbl)), q[0].s = 0;

		while (top < end) {
			for (i = 0; i < 4; i++) {
				memcpy(gap, q[top].gap, sizeof(gap)),
				memcpy(tbl, q[top].tbl, sizeof(tbl)), s = q[top].s + 1;
				r = gap[i].r, c = gap[i].c;
				v = tbl[r][c-1]; if (v == 0 || v % 10 == 7) continue;
				v++;
				for (r2 = 0; r2 < 4; r2++) for (c2 = 1; c2 < 8; c2++) if (tbl[r2][c2] == v) {
					tbl[r2][c2] = 0, tbl[r][c] = v, gap[i].r = r2, gap[i].c = c2;
					goto next;
				}
		next:
				if ((x = check(tbl)) == 0) { ans = s; goto done; }
				if (insert(x)) continue;
				memcpy(q[end].gap, gap, sizeof(gap)), memcpy(q[end].tbl, tbl, sizeof(tbl)), q[end++].s = s;
			}
			++top;
		}
done:	printf("%d\n", ans);
	}
 	return 0;
}

Measured memory_bytes: 5024
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n][3],dp[n][3];
	for(int i = 0;i<n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		dp[i][0]=dp[i][1]=dp[i][2] = 0;
	}
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for(int i = 1;i<n;i++){
		dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = a[i][2] + max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007

int main() {
  int n;
  string s1, s2;
  cin >> n;
  cin >> s1 >> s2;
  vector<int> s;
  int count = 0;

  for (int i = 0; i < n; i++) {
    if (s1[i] == s2[i]) {
      s.push_back(1);
      count = 0;
    } else {
      if (count % 2 == 0) {
        s.push_back(2);
      }
      count++;
    }
  }

  // for (int i = 0; i < s.size(); i++) {
  //   cerr << s[i] << " ";
  // }
  // cerr << endl;

  long long ans = 3 * s[0];

  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] == 1 && s[i] == 1) {
      ans *= 2;
    } else if (s[i - 1] == 1 && s[i] == 2) {
      ans *= 2;
    } else if (s[i - 1] == 2 && s[i] == 1) {
      ans *= 1;
    } else if (s[i - 1] == 2 && s[i] == 2) {
      ans *= 3;
    }
    ans = ans % INF;
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  long long c[3][3];
  for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cin >> c[i][j];
  long long a[3] = {0};
  bool ans = false;
  for(a[0] = 0; a[0] <= 100; a[0]++) for(a[1] = 0; a[1] <= 100; a[1]++) for(a[2] = 0; a[2] <= 100; a[2]++) {
    int d[3][3] = {0};
    for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) d[i][j] = c[i][j] - a[i];
    bool h = true;
    for(int i = 0; i < 3; i++) if(d[0][i] <= 100 && d[0][i] >= 0 && d[0][i] == d[1][i] && d[1][i] == d[2][i]);
    else h = false;
    if(h) ans = true;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

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

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int main(){
    int n;
    double d;
    cin >> n >> d;
    int ans = 0;
    while(n--){
        double x, y;
        cin >> x >> y;
        double dist = sqrt(x*x + y*y);
        ans += (dist <= d);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3804
import java.util.*;

public class Main {
  private static int getLongest(String str) {
    int maxLength = 0;
    int length = 0;
    for (char c : str.toCharArray()) {
      switch (c) {
        case 'A':
        case 'T':
        case 'C':
        case 'G':
          length++;
          maxLength = Math.max(maxLength, length);
          break;
        default:
          length = 0;
      }
    }
    return maxLength;
  }
  
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    String in = s.next();
    System.out.println(getLongest(in));
  }
}



Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<iterator>

using namespace std;

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  cout << ((a%2 && b%2 && c%2)==0 ? 0: min(min(a*b,b*c),a*c));
  cout <<endl;
  return 0;
}


Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)

canvas = []

H.times do
  canvas << gets.chomp.chars
end

DY = [-1, 0, 1, 0]
DX = [0, 1, 0, -1]

H.times do |y|
  W.times do |x|
    next if canvas[y][x] == '.'

    cnt = 0

    4.times do |i|
      ny = y + DY[i]
      nx = x + DX[i]

      next if ny < 0 || nx < 0 || H <= ny || W <= nx

      cnt += 1 if canvas[ny][nx] == '#'
    end

    if cnt == 0
      puts 'No'
      exit
    end
  end
end

puts 'Yes'


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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    int aa, bb, cc;
    if (a == b && b == c) {
        ans = (a % 2 == 0) ? -1 : 0;
    } else {
        while ((a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0)) {
            aa = (b + c) / 2;
            bb = (c + a) / 2;
            cc = (a + b) / 2;
            a = aa;
            b = bb;
            c = cc;
            ans++;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll A, B, N; cin >> A >> B >> N;
  ll x = std::min(B-1, N);
  ll ans = (A*x / B) - A * (x / B);
  for (ll i = 1; i <= A; ++i) {
    if (i > N) { break; }
    auto r = (A*i / B) - A * (i / B);
    chmax(ans, r);
  }
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 3652
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 600, OO = 724249387, T = 1e6 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
string s[N];

int32_t main() {
	use_fast;
	int n, m;
	cin >> n >> m;
	for(int y = 0; y < n; y++) 
    	cin >> s[y];
  	for(int i = 0; i < n; i++) {
    		for(int j = 0; j < m; j++) {
      		char c = '.';
    	 	if(j == 0) 
				c = '#';
      		if(1 <= i && i <= n - 2 && i % 2 == 1 && j != m - 1) 
       	 		c = '#';
      		if(s[i][j] == '#') 
      	 		c = '#';
      		cout << c;
    	}
    	cout << endl;
  	}
 	cout << endl;
 	for(int i = 0; i < n; i++) {
    	for(int j = 0; j < m; j++) {
      		char c = '.';
      		if(j == m - 1) 
				c = '#';
      		if(1 <= i && i <= n - 2 && i % 2 == 0 && j != 0) 
        		c = '#';
      		if(s[i][j] == '#') 
        		c = '#';
      		cout << c;
    	}
    	cout << endl;
	}
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string N;
    cin >> N;
    if(N[0] == '7' || N[1] == '7' || N[2] == '7'){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

'''def factmod(n):
    u=1
    for i in range(1,n+1):
        u=u*i%mod
    return u'''
factmod=[0 for i in range(100000)]
factmod[0]=1
for i in range(100000-1):
    factmod[i+1]=factmod[i]*(i+2)%mod
#print(factmod)
        
n,m=MI()
if n>m+1 or m>n+1:
    print(0)
    sys.exit()
elif n==m:
    ans=2*factmod[n-1]**2
else:
    if m>n:
        m,n=n,m
    ans=factmod[n-1]*factmod[m-1]
print(ans%mod)

Measured memory_bytes: 7472
n=int(input())

h=[int(x) for x in input().split()]

height=[]

result=0
tmp=0

for i in range(max(h)):
    buf=[]
    for j in range(n):
        if h[j] > i:
            buf.append(1)
        else:
            buf.append(0)
    height.append(buf)

for val in height:
    while(tmp < len(val)):
        if val[tmp]==0:
            tmp+=1
        else:
            result+=1
            while(tmp<len(val)):
                if(val[tmp]==0):
                    break
                tmp+=1;
    tmp=0
#print(height)
print(result)

Measured memory_bytes: 3064
# _*_ codng:utf-8 _*_

num = input()
temp,target = map(int,input().split())

i = 0
ans = -500
j = 0
for height in map(int,input().split()):
  i += 1
  hoge = temp - 0.006 * height
  if(abs(target - hoge) < abs(target - ans)):
    ans = hoge
    j = i

print(j)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    vector<long long> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    if ( A[0] != 0 ) { cout << -1 << endl; return 0; }

    long long ans = 0;
    for ( int i = 1; i < N; i++ ) {        
        // if ( A[i] < A[i-1] && A[i] > 1 ) { cout << -1 << endl; return 0; }
        if ( A[i] > A[i-1] && A[i]-A[i-1] > 1 ) { cout << -1 << endl; return 0; }


        if ( i == N-1 ) { ans += A[i]; }
        else {
            if ( A[i] == A[i+1] || A[i] > A[i+1] ) { ans += A[i]; }
        }
        // cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int w,ans;
  while(1){
    cin >> w;
    if(w==-1){
      break;
    }
    ans=1150;
    while(w>10){
      if(w>30){
	ans+=160;
	w--;
      }
      else if(w>20){
	ans+=140;
	w--;
      }
      else if(w>10){
	ans+=125;
	w--;
      }
    }
    ans=4280-ans;
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
inline char nc()
{
    return getchar();
    static char buf[100000], * l = buf, * r = buf;
    if(l == r) r = (l = buf) + fread(buf, 1, 100000, stdin);
    if(l == r) return EOF;
    return *l++;
}
template<class T> void readin(T & x)
{
    x = 0; int f = 1, ch = nc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
    x *= f;
}
int n, x;
int a[105];
void solve()
{
    sort(a + 1, a + n + 1);
    int c = 0;
    for(int i = 1; i < n; i++)
    {
        if(x >= a[i])
        {
            x -= a[i];
            c++;
        }
    }
    if(c == n - 1 && x == a[n]) c++;
    cout << c << endl;
}
int main()
{
    readin(n);
    readin(x);
    for(int i = 1; i <= n; i++)
    {
        readin(a[i]);
    }
    solve();
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        var st = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var bul = new StringBuilder();
        for (var j = 0; j < 2; j++)
        {
            for (var i = st[0] + 1; i <= st[2]; i++)
                if (j == 0)
                    bul.Append("R");
                else bul.Append("L");
            for (var i = st[1] + 1; i <= st[3]; i++)
                if (j == 0) bul.Append("U");
                else bul.Append("D");
        }
        
        for(var j = 0; j < 2; j++)
        {
            if (j == 0) bul.Append("D");
            else bul.Append("U");
            for (var i = st[0]; i <= st[2]; i++)
                if (j == 0) bul.Append("R");
                else bul.Append("L");
            for (var i = st[1]; i <= st[3]; i++)
                if (j == 0) bul.Append("U");
                else bul.Append("D");
            if (j == 0) bul.Append("L");
            else bul.Append("R");
        }
        WriteLine(bul.ToString());
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 11176
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M];
  P war[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    war[i] = P(b[i] - 2, a[i] - 1);
  }
  
  sort(war, war + M);
  
  int broken = war[0].first;
  int rid = 1;
  
  for (int i = 0; i < M; i++) {
    if (broken < war[i].second) {
      broken = war[i].first;
      rid++;
    }
  }
  
  cout << rid << endl;
}

Measured memory_bytes: 1792