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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

i32 b[2010][2010];
i32 w[2010][2010];

i64 calc(int i1, int j1, int i2, int j2, bool black) {
  // cerr << i1 << " " << j1 << " " << i2 << " " << j2 << " -> ";
  if (black) {
    i64 ret = b[i2][j2] - b[i1][j2] - b[i2][j1] + b[i1][j1];
    // cerr << ret << endl;
    return ret;
  } else {
    i64 ret = w[i2][j2] - w[i1][j2] - w[i2][j1] + w[i1][j1];
    // cerr << ret << endl;
    return ret;
  }
}

i64 calcs(int i, int j, int k, bool black) {
  // cerr << "=" << endl;
  i32 i1 = i, j1 = j;
  i32 i2 = i + k, j2 = j + k;
  i32 k2 = 2 * k;
  i64 sum = 0;

  sum += calc( 0,  0, i1, j1, black);
  sum += calc( 0, j2, i1, k2, black);
  sum += calc(i1, j1, i2, j2, black);
  sum += calc(i2,  0, k2, j1, black);
  sum += calc(i2, j2, k2, k2, black);

  sum += calc( 0, j1, i1, j2, !black);
  sum += calc(i1,  0, i2, j1, !black);
  sum += calc(i1, j2, i2, k2, !black);
  sum += calc(i2, j1, k2, j2, !black);

  return sum;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i64 n, k;
  cin >> n >> k;
  rep(i, n) {
    i64 x, y;
    char c;
    cin >> x >> y >> c;
    x = x % (2 * k) + 1;
    y = y % (2 * k) + 1;
    if (c == 'B') b[x][y]++;
    if (c == 'W') w[x][y]++;
  }
  reps(i, 2005) reps(j, 2005) b[i][j] += b[i - 1][j];
  reps(i, 2005) reps(j, 2005) b[i][j] += b[i][j - 1];
  reps(i, 2005) reps(j, 2005) w[i][j] += w[i - 1][j];
  reps(i, 2005) reps(j, 2005) w[i][j] += w[i][j - 1];
  i64 ans = 0;
  rep(i, k + 1) rep(j, k + 1) {
    amax(ans, calcs(i, j, k, true));
    amax(ans, calcs(i, j, k, false));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31872
var x = require('fs').readFileSync('/dev/stdin', 'utf8');

var input = x.split("\n");

for (var k = 0 ; k < input.length; k++) {

    var arr = input[k].split(" ").map(Number);
    var H = arr[0];
    var W = arr[1];
 
    if(H === 0 && W === 0) break;
    var result = "";
    for( var i = 0; i < H; i++){
        for( var j = 0; j < W; j++) {
            result += "#"
            
        }
        result += "\n";        
    }
        console.log(result);

}




Measured memory_bytes: 17780
#include <iostream>

using namespace std;

int main(){
	long long x;
	while(cin >> x){
		long long res = x/11 * 2;
		long long m = x%11;
		if(0 < m && m <= 6) res += 1;
		if(6 < m && m <= 10) res += 2;
		cout << res << endl;
	}
}



Measured memory_bytes: 764
#include<stdio.h>

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

	int i = 1;
	while (i++ < n){
		int x = i;
		if (x % 3 == 0){
			printf(" %d", i);
		}
		else{
			while (x){
				if (x % 10 == 3){
					printf(" %d", i);
					break;
				}
				x = x / 10;
			}
		}
	}
	putchar('\n');


	return 0;
}


Measured memory_bytes: 2116
N = int(input())
num_list = [int(item) for item in input().split()]

def bubbleSort(A, N):
    is_flag = 1
    cnt = 0

    while is_flag:
        is_flag = 0
        for i in range(N-1):
            if A[i] > A[i+1]:
                A[i], A[i+1] = A[i+1], A[i]
                is_flag = 1
                cnt += 1
    print(*A)
    print(cnt)

bubbleSort(num_list, N)


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

using namespace std;

typedef long long lli;

const int N = 300000 + 10;
const int MOD = 1000000007;

lli a[N];

int main()
{
	int res, n, x, y, i, j;
	cin>>n;
	for (i=0; i<n; i++) cin>>a[i];
	res = 0;
	for (i=0; i<60; i++)
	{
		x = y = 0;
		for (j=0; j<n; j++) if (a[j]&(1LL<<i)) x ++; else y ++;
		res = (res + 1LL * x * y % MOD * ((1LL<<i) % MOD) % MOD) % MOD;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define SQR(a) ((a)*(a))
using namespace std;
typedef long long int ll;
typedef pair<int,int> pr;
typedef pair<pr,ll> ppr;
typedef vector<pr> vpr;
const int INF=1<<30;
int main() {
	
	int n,m;
	while(cin >> n>> m && n){
	int now=0,mass[2001]={},dice[1001]={};
	REP(i,n)
		cin >> mass[i];
	REP(i,m)
		cin >> dice[i];
	REP(i,m){
	now+=dice[i];
	now+=mass[now];
	if(now+1>=n){
		cout << i+1 << endl;
		break;
	}
	}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1168
#include <stdio.h>

int main()
{
	int matrix[100][100], i, j, input, n, m, matrix1[100], sum = 0;
	scanf("%d %d", &n, &m);
	for (i = 0; i<n; i++) {
		for (j = 0; j<m; j++) {
			scanf("%d", &matrix[i][j]);
		}
	}
	for (i = 0; i<m; i++) {
		scanf("%d", &matrix1[i]);
	}
	for (i = 0; i<n; i++) {
		sum = 0;
		for (j = 0; j<m; j++) {
			sum += matrix[i][j] * matrix1[j];
		}
		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 1984
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    int X = 0, Y = 0;
     
    while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
        if(a * a + b * b == c * c) X++;
        else if(a == b) Y++;
    }
    cout << X << endl;
    cout << Y << endl;
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <math.h>
#define P pow(4,j++)
#define R printf
#define S scanf
main(){
  int i,j,n,c; char m[7],o,d[314159];
  for(i=0,S("%d %s",&n,m);i<n;i++,S("%s",m)){
    for(j=c=o=0;o!='\n';S("%c",&o))
      if(o=='A')c+=1*P;
      else if(o=='C')c+=2*P;
      else if(o=='G')c+=3*P;
      else if(o=='T')c+=4*P;
    m[0]=='i'?d[c]=1:(d[c]?R("yes\n"):R("no\n"));
  }
  return 0;
}

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

signed main() {
  int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    	string s(a,'0');
    	string t(w-a,'1');
        s+=t;
  		string S(a,'1');
  		string T(w-a,'0');
  		S+=T;
  for(int i=0;i<h;i++){
    if(i<b){
    	//printf("%s\n",ans);
        cout<<s<<endl;
    }
    else{
    	//printf("%s\n",ans);
        cout<<S<<endl;
    }
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int d, g;
    cin >> d >> g;
    g /= 100;

    vs32 p(d);
    vs32 c(d);
    rep (i, d) { cin >> p[i] >> c[i]; c[i] /= 100; }

    int lim = 1 << d;
    int ans = (int)1e9;
    rep (i, lim)
    {
        int temp = i;
        int score = 0;
        int sum = 0;
        rep (j, d)
        {
            if (temp & 1)
            {
                score += p[j] * (j + 1) + c[j];
                sum += p[j];
            }
            temp >>= 1;
        }
        temp = i;
        for (int j = d - 1; score < g && j >= 0; --j)
        {
            if (!((temp >> j) & 1))
            {
                sum += MIN(CEIL((g - score), (j + 1)), p[j]);
                score += MIN(CEIL((g - score), (j + 1)), p[j]) * (j + 1);
            }
        }
        ans = MIN(ans, sum);
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		int A = 0;
		int B = 0;

		int gap = b-a;

		for (int i = 1; i <= gap - 1; i ++) {
			A = A + i;
		}

		System.out.println(A - a);

	}
}

Measured memory_bytes: 23764
N = int(input())
W = list(map(int, input().split()))

S1 = 0
S2 = 0
ans = []

for i in range(N-1):
  S1 = sum(W[:i+1])
  S2 = sum(W[i+1:])
  ans.append(abs(S1-S2))
print(min(ans))

Measured memory_bytes: 3064
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_sum = sum(A)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors

cand = make_divisors(A_sum)
temp = 0
for i in range(len(cand)):
    c = cand[i]
    abs_sum = 0
    temp = []
    for j in range(len(A)):
        temp.append(A[j] % c)
        
    temp_sum = sum(temp)
    num = temp_sum // c
    temp.sort(reverse=True)
    for i in range(num):
        temp[i] = c - temp[i]

    abs_sum = sum(temp)
    if abs_sum <= 2*K:
        print(c)
        exit()

print(1)


Measured memory_bytes: 42604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
int main(){
    LL k,n;
    cin >> k >> n ;
    vector<LL> a_ary(n);
    rep(i,n){
        cin >> a_ary[i];
    }
    sort(a_ary.begin(),a_ary.end());
/*
    rep(i,n){
        cout << i <<"a_ary[i] :" << a_ary[i] << endl;
    }
*/
    LL len_abs = 0;
    LL a_i;
    for (int i = 1; i < n; i++) {
        if(len_abs < max(a_ary[i] - a_ary[i-1],len_abs)) a_i = i;
        len_abs = max(a_ary[i] - a_ary[i-1],len_abs);

    }
    if(len_abs < (a_ary[0] + (k - a_ary[a_ary.size()-1])) ){
        a_i = 0;
        len_abs = (a_ary[0] + (k - a_ary[a_ary.size()-1]));

    } 
//    cout << (a_ary[0] + (k - a_ary[a_ary.size()-1])) << endl;
//    cout << len_abs << endl;
//    cout << "a_i :" << a_i << endl;

//    (20 -a_ary[a_i]) + (a_ary[a_i-1])
    LL ans = 0;
    ans += (a_ary[a_ary.size()-1] - a_ary[a_i]);
//    cout << "ans :" << ans << endl;    
    if(a_i != 0) ans += (a_ary[a_i-1]);
    if(a_i != 0) ans += (k - a_ary[a_ary.size()-1]);
//    cout << "ans :" << ans << endl;    
/*
    if(a_i == 0) ans += a_ary[a_ary.size()-1];
    else ans += (a_ary[a_i-1]);
*/
    cout << ans << endl;
/*
30 4
0 5 25 30
30 6
0 1 2 3 4 5
*/

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a[10001],i;
	for (i = 1; i <= 10000; i++){ scanf("%d", &a[i]); };
	for (i = 1; i<= 10000;i++){
	printf("Case %d: %d\n",i,a[i]);
};
return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


string s;
int n;

bool check(string ans){
  vector<vector<bool>> dp(101010,vector<bool>(2,false));

  if(ans[0] == 'S'){
    dp[0][0] = true;
  }else{
    dp[0][1] = true;
  }

  if(ans[1] == 'S'){
    dp[1][0] = true;
  }else{
    dp[1][1] = true;
  }

  FOR(i,1,n){

    if('o' == s[i]){
      //両方 Seep
      if(dp[i-1][0] && dp[i][0]){
        dp[i+1][0] = true;
        ans += 'S';
        continue;
      }
      if(dp[i-1][1] && dp[i][0]){
        dp[i+1][1] = true;
        ans += 'W';
        continue;
      }
      //片方はSeep
      if(dp[i-1][0] && dp[i][1]){
        dp[i+1][1] = true;
        ans += 'W';
        continue;
      }
      if(dp[i-1][1] && dp[i][1]){
        dp[i+1][0] = true;
        ans += 'S';
        continue;
      }
    }
    if('x' == s[i]){
      //片方はwolf
      if(dp[i-1][0] && dp[i][0]){
        dp[i+1][1] = true;
        ans += 'W';
        continue;
      }
      if(dp[i-1][1] && dp[i][0]){
        dp[i+1][0] = true;
        ans += 'S';
        continue;
      }
      //両方同じ
      if(dp[i-1][0] && dp[i][1]){
        dp[i+1][0] = true;
        ans += 'S';
        continue;
      }
      if(dp[i-1][1] && dp[i][1]){
        dp[i+1][1] = true;
        ans += 'W';
        continue;
      }
    }


  }

  bool flag = false;
  if(dp[n][0] && dp[0][0]){//Sheep
    if(s[0] == 'o'){//Sheep
      if(ans[1] == ans[n-1]) flag = true;
    }
    else{
      if(ans[1] != ans[n-1]) flag = true;
    }
  }

  if(dp[n][1] && dp[0][1]){
    if(s[0] == 'o'){//wolf
      if(ans[1] != ans[n-1]) flag = true;
    }
    else{
      if(ans[1] == ans[n-1]) flag = true;
    }
  }
  if(flag){
    cout << ans.substr(0,n) << endl;
  }
  return flag;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    cin >> s;
    if(check("SS")) return 0;
    if(check("SW")) return 0;
    if(check("WS")) return 0;
    if(check("WW")) return 0;

    cout << -1 << endl;

    return 0;
}


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

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

  int aa = 0, bb = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a' && aa + bb < a + b) {
      cout << "Yes" << endl;
      aa++;
    } else if (s[i] == 'b' && aa + bb < a + b && bb < b) {
      cout << "Yes" << endl;
      bb++;
    } else if ((s[i] == 'a' || s[i] == 'b') && (aa + bb >= a + b || bb >= b)) {
      cout << "No" << endl;
    } else if (s[i] == 'c') {
      cout << "No" << endl;
    }
  }
}

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

int main() {
    /* 入力受け取り */
    int n, Q;
    cin >> n >> Q;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    /* Q 回分のクエリを処理 */
    for (int j = 0; j < Q; ++j) {
        long long x; cin >> x; // 各クエリ x

        /* 合計値 */
        long long res = 0;

        /* 区間の左端 left で場合分け */
        int right = 0;     // 毎回 right を使い回すようにする
        long long sum = 0; // sum も使い回す
        for (int left = 0; left < n; ++left) {
            /* sum に a[right] を加えても大丈夫なら right を動かす */
            while (right < n && sum + a[right] <= x) {
                sum += a[right];
                ++right;
            }

            /* break した状態で right は条件を満たす最大 */
            res += (right - left);

            /* left をインクリメントする準備 */
            if (right == left) ++right; // right が left に重なったら right も動かす
            else sum -= a[left]; // left のみがインクリメントされるので sum から a[left] を引く
        }

        cout << res << endl;
    }
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

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

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

int main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll l;
    if(c < d){
        l = lcm(c, d);
    }else{
        l = lcm(d, c);
    }
    ll x = (b / c - (a - 1) / c) + (b / d - (a - 1) / d) - (b / l - (a - 1) / l);
    cout << b - a + 1 - x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    ll a = inp1;
    double b = inp1;
    ll tb = b * 100 + 0.01;

    ll ans = a * tb;

    ans /= 100;

    Cout(ans);

    return 0;
}


Measured memory_bytes: 3724
#include<stdio.h>

int main(){
	int n;		//入力される情報の数
	int b,f,r,v;//入力される情報
	int house[4][3][10] = {//部屋の数だけの要素をもつ配列
		{
			{0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0}
		},
		{
			{0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0}
		},
		{
			{0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0}
		},
		{
			{0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0},
			{0,0,0,0,0,0,0,0,0,0}
		}
	};
	
	scanf("%d",&n);//情報の数を入力
	
	for(int i = 0;i < n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);//情報を入力
		house[b - 1][f - 1][r - 1] += v;//情報を基に各部屋に人数を格納
	}
	
	for(int j = 0;j < 4;j++){//棟の数だけループ
		for(int k = 0;k < 3;k++){//棟の階数だけループ
			for(int l = 0;l < 10;l++){//階毎の部屋の数だけループ
				printf(" %d",house[j][k][l]);//部屋毎の人数を出力
			}
			printf("\n");//階毎に改行
		}
		if(j != 3){
			printf("####################\n");//棟の間に区切りを出力
		}
	}
	
	return 0;
}



Measured memory_bytes: 2108
import java.util.*;
public class Main {

public static void main(String[] args)
{
  Scanner sc=new Scanner(System.in);
  fact=new long[100002];
  fact[0]=1;
  for(int i=1;i<100002;i++) {
    fact[i]=(1l*fact[i-1]%mod*i%mod+mod)%mod;
  }
 int n=sc.nextInt();
 int m=sc.nextInt();
 if(Math.abs(n-m)>=2) {
   System.out.println(0);
 }
 else {
 if((n%2==0&&m%2==0)||(n%2!=0&&m%2!=0))
 System.out.println((fact[n]%mod*fact[m]%mod*2l%mod+mod)%mod);
 else
   System.out.println((fact[n]%mod*fact[m]%mod+mod)%mod);
 }
}


   
static long modInverse(long fac, int p) 
{ 
    return pow(fac, p - 2); 
} 


static long nCr(int n, int r, 
                         int p) 
{ 

  
    if (r == 0) 
        return 1; 


    long [] fac = new long [n + 1]; 
    fac[0] = 1; 

    for (int i = 1; i <= n; i++) 
        fac[i] = fac[i - 1] * i % p; 

    return (fac[n] * modInverse(fac[r], p) 
            % p * modInverse(fac[n - r], p) 
            % p) 
        % p; 
} 


public static long[] fact;
public static long[] invfact;
public static long ncr(int n, int r){
  if(r > n) return 0;
  return ((((fact[n]) * (invfact[r])) % mod)* invfact[n-r]) % mod;
}
static int mod=(int)1e9+7;
static long pow(long x,long y) {
 long res=1l;
 while(y!=0) {
   if(y%2==1) {
     res=x*res%mod;
   }
   y/=2;
   x=x*x%mod;
 }
 return res;
}


}
 








Measured memory_bytes: 36264
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,en,a=0,b=0;
	char c[50000];
	gets(c);
	en=strlen(c);
	for(i=0;i<=en;++i){
		if(c[i]=='C')a++;
		if(c[i]=='F'&&a!=0)b++;
	}
    if(a>0&&b>0)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		//int n=sc.I;
		int[] s=sc.Ia;
		int ans=0;
		int[] h=new int[s[0]+2];
		for(int i = 0;i<s[1];i++) {
			int[] e=sc.Ia;
			h[e[0]]++;
			h[e[1]+1]--;
		}
		for(int i = 1;i<=s[0];i++) {
			h[i]+=h[i-1];
			if(h[i]==s[1]){ans++;}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}


Measured memory_bytes: 15448
use std::cmp::{max, min};
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let (n, k): (usize, usize) = input_two().unwrap();
    let mut ans = k;
    ans *= vec![k-1; n].iter().take(n-1).product::<usize>();

    println!("{}", ans);
}

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf.trim().parse().ok().unwrap())
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>())
}

fn input_two<T: FromStr>() -> Result<(T, T), T::Err> {
    let tmp = input_vec::<String>().unwrap();
    Ok((tmp[0].parse()?, tmp[1].parse()?))
}

fn input_three<T: FromStr + Clone>() -> Result<(T, T, T), T::Err> {
    let tmp = input_vec::<T>().ok().unwrap();
    // println!("{:?}", tmp);
    Ok((tmp[0].clone(), tmp[1].clone(), tmp[2].clone()))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define si size
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define er erase
#define in insert
#define em empty
#define ft front
#define fo(i,n) for(i = 0; i < n; i++)
#define ro(i,n) for(i = n - 1; i >= 0; i--)
#define fr(i,j,n) for(i = j; i < n; i++)
#define rf(i,j,n) for(i=n-1;i>=j;i--)
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<std::string> vs;
typedef double dl;
typedef long double ld;
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> vll;
#define filename ""
using namespace std;
const int N=(int)1e5;
    vector<int> v[N];
    int was[N];
    int a[N];
    vector<int> d[N];
    int co[N];
    int gwas=0;
bool sss(int x,int y)
{
    if (a[x]==a[y]) re x<y;
    re a[x]<a[y];
}
bool so(vector<int> &x,vector<int> &y)
{
    if (x.size()==y.size()) re x<y;
    re x.size()>y.size();
}
set<int,bool (*)(int,int)> s1(sss);
set<int,bool (*)(int,int)> s2(sss);
int f(int x)
{
    int i;
    was[x]=1;
    d[gwas].pb(x);
    fo(i,v[x].size())
    {
        if (!was[v[x][i]])
        {
            f(v[x][i]);
        }
    }
}
int main()
{
    /*
	freopen(filename".in","r",stdin);
	freopen(filename".out","w",stdout);
	*/
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    */
    int n,m,c,t;
    cin>>n>>m;
    int i;
    fo(i,n)
    {
        scanf("%d",&a[i]);
    }
    fo(i,m)
    {
        scanf("%d%d",&c,&t);
        v[t].pb(c);
        v[c].pb(t);
    }
    int b;
    fo(i,n)
    {
        if (!was[i])
        {
            f(i);
            gwas++;
        }
    }
    sort(d,d+gwas,so);
    fo(i,d[0].size())
    {
        s1.in(d[0][i]);
        co[d[0][i]]=0;
    }
    int j;
    fr(i,1,gwas)
    {
        fo(j,d[i].size())
        {
            s2.in(d[i][j]);
            co[d[i][j]]=i;
        }
    }
    ll o=0;
    int r;
    fo(i,gwas-1)
    {
        if (s2.empty()||s1.empty())
        {
            cout<<"Impossible\n";
            re 0;
        }
        r=*s2.begin();
        o+=a[*s1.begin()];
        s1.er(s1.begin());
        o+=a[*s2.begin()];
        fo(j,d[co[r]].size())
        {
            s1.in(d[co[r]][j]);
            s2.er(d[co[r]][j]);
        }
        s1.er(r);
    }
    cout<<o<<endl;
    re 0;
}

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

#define ll long long
const ll mod = 1000000007;

struct UnionFind {
    std::vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) std::swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main()
{
    int n, m;
    std::cin >> n >> m;
    UnionFind uf(n);
    for(int i=0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }
    int ans = 0;
    for(int i=0; i < n; i++) ans = ans > uf.size(i) ? ans : uf.size(i);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 200005

int main(){

    int n,ch;
    cin >> n >> ch;
    vector<int> s(n),t(n),c(n);

    REP(i,n){
        cin >> s[i] >> t[i] >> c[i];
    }

    int imos[ARRAY_MAX];
    int ans[ARRAY_MAX];
    REP(i,ARRAY_MAX){
        ans[i] = 0;
    }

    for(int i = 1;i <= ch;i++){

        REP(j,ARRAY_MAX){
            imos[j] = 0;
        }

        REP(j,n){
            if(c[j] == i){
                imos[s[j]*2-1]++;
                imos[t[j]*2+1]--;
            }
        }
        REP(j,ARRAY_MAX-1){
            imos[j+1] += imos[j];
        }
        //累積和
        REP(j,ARRAY_MAX){
            //チャンネルを使用中
            if(imos[j]>0){
                ans[j]++;
            }
        }       
    }
    int maxi = -1;
    REP(i,ARRAY_MAX){
        maxi = max(maxi,ans[i]);
    }

    cout << maxi << endl;




    return 0;
}

Measured memory_bytes: 2944
#include<string>
#include<list>
#include<iostream>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=data.begin(),l=data.end();it!=l;++it){
	if(*it == x){
	  data.erase(it);
	  break;
	}
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it) cout << *it << " ";
  cout << *it << endl;
}



Measured memory_bytes: 34280
#include <iostream>
#include <cstring>

using namespace std;

int main() {
  int N;
  string S;
  int calc_1[10], calc_2[10], calc_3[10];
  int flg_1 = 0, flg_2 = 0, flg_3 = 0;
  int n;
  int total = 0;

  cin >> N;
  cin >> S;

  memset(calc_1, 0, sizeof(calc_1));
  for (int i = 0; i < N-2; i++) {
    n = (int)(S[i]-'0');
    if (calc_1[n] > 0) continue;
    calc_1[n]++;
    flg_1 += n+1;
    memset(calc_2, 0, sizeof(calc_2));
    flg_2 = 0;

    for (int j = i+1; j < N-1; j++) {
      n = (int)(S[j]-'0');
      if (calc_2[n] > 0) continue;
      calc_2[n]++;
      flg_2 += n+1;
      memset(calc_3, 0, sizeof(calc_3));
      flg_3 = 0;

      for (int k = j+1; k < N; k++) {
        n = (int)(S[k]-'0');
        if (calc_3[n] > 0) continue;
        calc_3[n]++;
        flg_3 += n+1;

        total++;

        if (flg_3 == 55) break;
      }
      if (flg_2 == 55) break;
    }
    if (flg_1 == 55) break;
  }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 
                   2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 10500
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e16;
//__gcd(a,b), __builtin_popcount(a);

int a[MAX][MAX];
int main(){
	int n, m, y, x, d;
	scanf("%d%d", &n, &m);
	for(int i = 0;i < m;i++){
		scanf("%d%d%d", &y, &x, &d);
		x = 5002-y-1+2*(x-1);
		a[y][x]++;a[y][x+2]--;
		a[y+d+1][x-d-1]--;a[y+d+2][x-d]++;
		a[y+d+1][x-d-1+2*(d+2)]++;a[y+d+2][x-d+2*(d+1)]--;
	}
	
	for(int i = 1;i <= n+3;i++){
		for(int j = 2;j < MAX;j++){
			a[i][j] += a[i][j-2];
		}
	}
	
	for(int i = 1;i <= n+3;i++){
		for(int j = 1;j < MAX;j++){
			a[i][MAX-j] += a[i-1][MAX-j+1];
		}
	}
	
	int ans = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j < MAX;j++){
			a[i][j] += a[i-1][j-1];
			if(a[i][j] != 0)ans++;
		}
	}
	//int ans = 0;
	
	/*for(int i = 1;i < 10;i++){
		for(int j = 4990;j < 5010;j++)printf("%2d ", a[i][j]);
		printf("\n");
	}*/
	printf("%d\n", ans);
	return 0;
}






Measured memory_bytes: 208396
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 1005
int a, b, c, d;

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

    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0){
        c -= b;
        //if(c <= 0) break;
        a -= d;
    }
    if(c <= 0) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstdio>
using ll = long long;
using namespace std;
int main(){
    ll n,m=0,num,a,b;
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> a >> b;
        if(a>m){
             m=a;
             num=b;
        }
    }
    cout << m+num << endl;
    return 0;
}




Measured memory_bytes: 256
#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 N;
    cin >> N;
    cout << 48 - N << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,k,sum,n2,n1;
    cin>>a>>b>>c>>k;
    if(k>=a){
        n1=k-a;
    }
    if(n1==0)
        sum=k;
    else if(n1>0){
        n2=n1-b;
        sum=a-n2;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ios::sync_with_stdio(false);
  ll x;
  cin >> x;
  ll ans = x/11*2;
  ll nokori = x%11;
  if(nokori>=7) ans += 2;
  else if(nokori>=1) ans+=1;

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
print("R"*dx + "U"*dy + "L"*dx + "D"*dy + "L" + "U"*(dy+1) + "R"*(dx+1) + "D" + "R" + "D"*(dy+1) + "L"*(dx+1) + "U")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  string s,t;
  cin>>s>>t;
  cout<<t+s<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n)
{
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++)
  {
    if ((n % i) != 0)
      continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0)
    {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }
  if (n != 1)
    p.push_back(make_pair(n, 1));
  return p;
}
string alphabet() { return "abcdefghijklmnopqrstuvwxyz"; }
int main()
{
  string Sx, T;
  cin >> Sx >> T;
  string result = "";
  int idx = -1, count = 0;
  string t0 = T.substr(0, 1);
  /*****/
  repeat(i, Sx.length() - T.length() + 1)
  {
    repeat(j, T.length())
    {
      if (Sx[i+j] == T[j] || Sx[i+j] == '?')
      {
        if (j == T.length() - 1)
        {
          idx = i; 
        }
      }else break;
    }
  }
  /****/
  repeat(i, Sx.length())
  {
    if (i == idx)
    {
      result += T;
      i += T.length() - 1;
    }
    else
    {
      string s1 = Sx.substr(i, 1);
      if (s1 == "?")
        result += "a";
      else
        result += s1;
    }
  }
  cout << ((idx >= 0) ? result : "UNRESTORABLE") << endl;
  return 0;
}

Measured memory_bytes: 256
m,a[9][2],S[9999];
D(d,s){int i=0;if(d==m)S[s]++;else for(;i<=a[d][1];i++)D(d+1,s+i**a[d]);}
main(i){for(;scanf("%d",&m),m;){
for(i=0;i<m;i++)scanf("%d%d",a[i],a[i]+1);
memset(S,0,sizeof(S));D(0,0);
for(scanf("%d",&i);i;i--)scanf("%d",&m),printf("%d\n",S[m]);
}exit(0);}

Measured memory_bytes: 644
from collections import deque
s=deque(input())
q=int(input())
turn=True
 
for i in range(q):
    qq=input().split()
    if qq[0]=='1':
        turn=not turn
    else:
        if turn==bool(int(qq[1])-2):
            s.appendleft(qq[2])
        else:
            s.append(qq[2])
 

text="".join(s)
print(text if turn else text[::-1])

Measured memory_bytes: 8428
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        k: usize,
    }

    let mut rem = vec![0; k+1];
    rem[1] = 7 % k;
    for i in 2..=k {
        rem[i] = (rem[i-1] * 10 + 7) % k;
    }

    for i in 1..=k {
        if rem[i] == 0 {
            println!("{}", i);
            return
        }
    }
    println!("{}", -1);
}


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


int n, x[200];

int main(){
  cin >> n;
  rep(i, n){
    cin >> x[i];
  }
  int res = 1e9;
  for(int p = 0; p <= 100; p++){
    int sum = 0;
    rep(i, n){
      sum += pow(x[i] - p, 2);
    }
    res = min(sum, res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),c= 0;
		int[] b = new int[a];
		for(int i = 0;i<a;i++){
			b[i] = sc.nextInt();
		}
		for(int i = 0;i<a;i++){
			for(int j = i+1;j<a;j++){
				c += b[i]*b[j];
			}
			
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 21460
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <algorithm>
#include <stdexcept>
#include <vector>
#include <string>
#include <set>

const std::string OPS="+-*/";
#define fprintf(...) void(0)

int parse_int(const std::string &s, size_t &i) {
  int res=s[i]-'0';
  while (++i < s.length() && isdigit(s[i])) {
    res = res*10+s[i]-'0';
  }
  return res;
}

int apply(int lhs, char op, int rhs) {
  switch (op) {
  case '+': return lhs+rhs;
  case '-': return lhs-rhs;
  case '*': return lhs*rhs;
  case '/': return lhs/rhs;
  }
  assert(false);
}

void debug_set(const std::set<int> &s) {
  fprintf(stderr, "{");
  for (int x: s)
    fprintf(stderr, " %d", x);
  fprintf(stderr, " }\n");
}

std::set<int> apply(const std::set<int> &lhs, char op, const std::set<int> &rhs) {
  std::set<int> res={};
  for (int xl: lhs) {
    for (int xr: rhs) {
      if (op == '/' && xr == 0) continue;
      res.emplace(apply(xl, op, xr));
    }
  }
  return res;
}

std::set<int> parse(std::string &s, size_t &i, int prec=0) {
  fprintf(stderr, "\"%s\"[%zu] p: %d\n", s.c_str(), i, prec);
  if (prec == 1) {
    if (s[i] == '(') {
      std::set<int> res=parse(s, ++i, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    } else if (isdigit(s[i])) {
      return {parse_int(s, i)};
    }
    assert(false);
  }

  const size_t si=i;
  std::set<int> res={};
  {
    std::set<int> lhs=parse(s, i, 1);
    if (i == s.length() || s[i] == '$' || s[i] == ')')
      return lhs;
  }

  while (i < s.length()) {
    char op=s[i];
    if (!std::count(OPS.begin(), OPS.end(), op)) break;
    size_t ii=i;
    s[ii] = '$';
    size_t il=si, ir=++i;
    std::set<int> lhs=parse(s, il, 0), rhs=parse(s, ir, 0);
    std::set<int> cur=apply(lhs, op, rhs);
    res.insert(cur.begin(), cur.end());
    s[ii] = op;
    (void)parse(s, i, 1);
  }
  debug_set(res);
  return res;
}

int testcase_ends() {
  char buf[256];
  scanf("%s", buf);
  std::string s=buf;
  if (s == "#")
    return 1;

  size_t i=0;
  std::set<int> res=parse(s, i, 0);
  for (int x: res)
    fprintf(stderr, " %d", x);
  fprintf(stderr, "\n");
  printf("%zu\n", res.size());
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2984
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String b = scan.next();

		if (b.equals("A")) {
			System.out.println("T");
		} else if (b.equals("T")) {
			System.out.println("A");
		} else if (b.equals("C")) {
			System.out.println("G");
		} else {
			System.out.println("C");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 20560
def judge(string):
    start = 0
    end = len(string) // 2

    flag = True
    for i in range(start, end):
        if string[i] != string[len(string)-i-1]:
            flag = False
            break
    return flag
    

if __name__ == '__main__':
    a, b = map(int, input().split())

    count = 0
    for n in range(a, b+1):
        string = str(n)
        if judge(string):
            count += 1
    print(count)

Measured memory_bytes: 3060
/*input
100000 5
*/

#include <bits/stdc++.h>

using namespace std;

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

	int n, k;
	cin >> n >> k;

	long double x = 0;

	for(int i = 1; i <= n; i++) {
		int j = i;
	    long double cur = 1;
		while(j < k) {
			j = j * 2;
			cur = cur * 2;
		}
		x += (1 / cur);
	}

	cout << fixed << setprecision(15) << (x / n) << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(((double)a+b)/2-((a+b)/2) >= 0.5){
    cout << (a+b)/2+1 << endl;
  }else{
    cout << (a+b)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int iCount, iIndex = 0;
    int iInputX[3000], iInputY[3000];
    int iSwapTmp;

    while (1)
    {
        scanf("%d %d", &iInputX[iIndex], &iInputY[iIndex]);

        if (iInputX[iIndex] == 0 && iInputY[iIndex] == 0) {
            break;
        }

        if (iInputX[iIndex] > iInputY[iIndex]) {
            iSwapTmp = iInputX[iIndex];
            iInputX[iIndex] = iInputY[iIndex];
            iInputY[iIndex] = iSwapTmp;
        }

        iIndex++;
    }

    for (iCount = 0; iCount < iIndex; iCount++) {
        printf("%d %d\n", iInputX[iCount], iInputY[iCount]);
    }
    
    return 0;
}


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

int main() {
  int N = 3;
  vector<int> A(N);
  cin >> A.at(0) >> A.at(1)>> A.at(2); 
 sort(A.begin(), A.end());
 cout << A.at(0) << " " << A.at(1) << " " << A.at(2) << endl; 
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int H,W;
    string S[60];
    cin>>H>>W;
    for (int i = 0; i < H; i++)cin>>S[i];

    int dx[]={1,1,0,-1,-1,-1,0,1};
    int dy[]={0,-1,-1,-1,0,1,1,1};

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (S[i][j]=='.')
            {
                int count=0;
                for (int k = 0; k < 8; k++)
                {
                    int y=i+dy[k];
                    int x=j+dx[k];
                    if (y>=0&&y<H&&x>=0&&x<W){
                    if (S[y][x]=='#'){++count;}
                    }
                    
                }
                S[i][j]='0'+count;
                
            }
            
        }
        
    }
    for (int i = 0; i < H; i++)
    {
        cout<<S[i]<<endl;
    }
    


    return 0;
}

Measured memory_bytes: 256
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define   ll  long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
#define   eps 1e-8
// Creates a min heap
//priority_queue <int, vector<int>, greater<int> > pq;
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll lcm(ll a, ll b)
{
    return (a * b) / __gcd(a, b);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll a, b, c, d, e, f = 0, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
    ll cnt = 0, ans = 0, l1, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
    ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
    string str, str1, str2,str3="",str4="";
    
    scll(x);
    if(x>=30)
    	cout<<"Yes\n";
    else
    	cout<<"No\n";

return 0;
}

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

using namespace std;

#define int long long

signed main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	
	if(n%2 == 1){
		cout<<"0\n";
		return 0;
	}
	
	sort(a, a+n);
	
	int mid = n/2 - 1;
	cout<<(a[mid + 1] - a[mid])<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#ABC-139-C
N = int(input())
H = list(map(int, input().split()))

i = 0
ans = 0
max_ans = 0

while i + 1 <=  N-1:
    if H[i] >= H[i+1]:
        ans += 1
        max_ans = max(max_ans, ans)
    else:
        max_ans = max(max_ans, ans)
        ans = 0
    i += 1

print(max_ans)

Measured memory_bytes: 14224