akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> l(M), r(M), x(M);
  for (int i = 0; i < M; i++){
    cin >> l[i] >> r[i] >> x[i];
    l[i]--;
    r[i]--;
  }
  vector<vector<vector<long long>>> dp(N + 1, vector<vector<long long>>(N + 1, vector<long long>(N + 1, 0)));
  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++){
    for (int j = 0; j <= N; j++){
      for (int k = 0; k <= N; k++){
        dp[i + 1][j][k] += dp[i][j][k];
        dp[i + 1][i][k] += dp[i][j][k];
        dp[i + 1][i][j] += dp[i][j][k];
      }
    }
    int j_min = 0;
    int j_max = i + 1;
    int k_min = 0;
    int k_max = i + 1;
    for (int j = 0; j < M; j++){
      if (x[j] == 1){
        if (l[j] <= i && i <= r[j]){
          j_max = min(j_max, l[j]);
        }
      }
      if (x[j] == 2){
        if (l[j] <= i && i <= r[j]){
          k_max = min(k_max, l[j]);
          if (i == r[j]){
            j_min = max(j_min, l[j] + 1);
          }
        }
      }
      if (x[j] == 3){
        if (l[j] <= i && i == r[j]){
          k_min = max(k_min, l[j] + 1);
        }
      }
    }
    for (int j = 0; j <= N; j++){
      for (int k = 0; k <= N; k++){
        if (j_min <= j && j <= j_max && k_min <= k && k <= k_max){
          dp[i + 1][j][k] %= MOD;
        } else {
          dp[i + 1][j][k] = 0;
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i <= N; i++){
    for (int j = 0; j <= N; j++){
      ans += dp[N][i][j];
    }
  }
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 219956
import java.util.*;

public class Main {
    public static int MAX = 1000001;
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int TC = sc.nextInt();
        String line = sc.nextLine();
        
        while (TC-- > 0) {
            line = sc.nextLine();
            District d = new District(getDistrictSubstring(line), 0);
            System.out.println(d.getMinVotes());
        }
    }
    
    public static String getDistrictSubstring(String str) {
        int count = 1;
        for (int i = 1; i < str.length(); i++) {
            if (str.charAt(i) == '[') {
                count++;
            }
            else if (str.charAt(i) == ']') {
                count--;
                if (count == 0) {
                    return str.substring(1, i);
                }
            }
        }
        return null;
    }
    
    public static class District {
        Vector<District> districts;
        boolean isBase;
        int num;
        int level;
        
        public District(String str, int level) {
            this.level = level;
            if (Character.isDigit(str.charAt(0))) {
                this.isBase = true;
                this.num = Integer.parseInt(str, 10);
            } else {
                this.isBase = false;
                districts = new Vector<District>();
                parseDistricts(str);
            }
        }
        
        public void parseDistricts(String str) {
            for (int i = 0; i < str.length(); ) {
                String temp = getDistrictSubstring(str.substring(i));
                districts.add(new District(temp, level + 1));
                i += temp.length() + 2;
            }
        }
        
        public int getMinVotes() {
            if (isBase) {
                return num / 2 + 1;
            }
            int sz = districts.size();
            int[] arr = new int[sz];
            for (int i = 0; i < sz; i++) {
                arr[i] = districts.get(i).getMinVotes();
            }
            Arrays.sort(arr);
            int total = 0;
            for (int i = 0; i < sz / 2 + 1; i++) {
                total += arr[i];
            }
            return total;
        }
    }
    
}




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

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << ":" << x << endl

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
    
    const int LIMIT = 1000000256;
    const int tenfive = 100000;
    
    
}

using namespace atcoder;

int main(void) {
    ios::sync_with_stdio(false);
    string str;
    cin >> str;
    //TLE
    /*
    int ans = 1;
    for(int i=0;i<str.size();i++){
        for(int j=i+1;j<str.size();j++){
            if(str[i] != str[j]){
                ans++;
            }
        }
    }
    */
    array<lli,27> num = {};
    for(int i=0;i<str.size();i++){
        num[str[i]-'a']++;
    }
    lli ans = str.size() * (str.size()-1) / 2 + 1;
    for(int i=0;i<27;i++){
        ans -= (num[i] * (num[i]- 1) / 2);
    }
    
    cout << ans << endl;
	return 0;
}


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

vector<string> C(8), ans; 

void fill_comma(int r, int c, vector<string>& D) {
    rep(i, 8) {
        if (D[i][c] == '0') D[i][c] = '.';
        if (D[r][i] == '0') D[r][i] = '.';
        if (min(r, c) - i >= 0 && D[r-i][c-i] == '0') D[r-i][c-i] = '.';
        if (max(r, c) + i < 8 && D[r+i][c+i] == '0') D[r+i][c+i] = '.';
        if (r-i>=0 && c+i<8 && D[r-i][c+i] == '0') D[r-i][c+i] = '.';
        if (r+i<8 && c-i>=0 && D[r+i][c-i] == '0') D[r+i][c-i] = '.';
    }
}

bool put_queen(int r, int c, int num, vector<string>& D) {
    bool ok = false;
    vector<string> E;
    copy(D.begin(), D.end(), back_inserter(E));
    E[r][c] = 'Q';
    fill_comma(r, c, E);

    if (num==8) {
        copy(E.begin(), E.end(), back_inserter(ans));
        return true;
    } else {
        rep(i, 8) {
            rep(j, 8) {
                if (E[i][j] == '0') ok = put_queen(i, j, num+1, E);
                if (ok) break;
            }
            if (ok) break;
        }
        return ok;
    }
}

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

    rep(i, 8) C[i] = "00000000";
    
    int r, c;
    rep(k, K) {
        cin >> r >> c;
        C[r][c] = 'Q';
        fill_comma(r, c, C);
    }

    if (K < 8) {
        rep(i, 8) rep(j, 8) if (C[i][j]=='0' && put_queen(i, j, K+1, C)) break;
        rep(i, 8) cout << ans[i] << endl;
    } else {
        rep(i, 8) cout << C[i] << endl;
    }

    return 0;
}




Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n,ans,co;
    co=0;
    ans=0;
    cin>>n;
    rep(i,n+1){
      for(int j=1;j<=i;j++){
        if(i%j==0){
          co++;
        }
      }
      if(co==8&&i%2==1){
        ans++;
      }
      co=0;
    }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  string a, b; cin >> a >> b;
  a += b;
  int x = stoi(a);
  for(int i = 1; i <= 10000; i++){
    if(i * i == x){
      cout << "Yes\n";
      return;
    }
  }
  cout << "No\n";
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
N, X, Y = list(map(int,input().split()))
X -= 1
Y -= 1
out = [0]*N #最低距離が1からNまでの個数を表示するリストを作る
for i in range(N-1):
  for j in range(i+1,N):
    out[min(j-i, abs(i-X)+1+abs(j-Y))] += 1 #各最低距離の個数カウント
for i in range(1,N):
  print(out[i])

Measured memory_bytes: 3444
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a=0,b=0,c=0;
  scanf("%ld",&a);
  long int d[a];
  for (int i = 0; i < a; i++) {
    scanf("%ld",&d[i]);
    if (d[i]%2!=0) {
      d[i]=3;
    }
    if ((d[i]%3!=0)&&(d[i]%5!=0)) {
      c=1;
    }
  }
  if (c==0) {
    printf("APPROVED" );
  }else{
    printf("DENIED\n" );
  }

}


Measured memory_bytes: 128
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

n = i()
v = wi()
v.sort()
k = v[0]

for i in range(1, n):
    k = (k + v[i]) / 2

print(k)

Measured memory_bytes: 6216
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))

int main() {

	int n, i, max;
	scanf("%d", &n);

	unsigned short A[n+1];
	unsigned short B[n+1];

	max = (1<<30)*-1;
	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		max = MAX(max, A[i+1]);
	}
	int C[max+1];
	memset(C, 0, sizeof(C));

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= max; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 10492
#include <stdio.h>
int main(void){
	float a,b,c,d,e,f,x,y;
	while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f) != EOF){
		x = (c*e-b*f)/(a*e-b*d) ? (c*e-b*f)/(a*e-b*d) :0;
		y = (a*f-c*d)/(a*e-b*d) ? (a*f-c*d)/(a*e-b*d) :0;
		printf("%.3f %.3f\n",x,y);
		}
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

    int A, B, C;
    cin >> A >> B >> C;

    set<int> nlist;
    nlist.insert(A);
    nlist.insert(B);
    nlist.insert(C);

    if (nlist.size() == 2)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int n = pow(2, N);
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];

  for (int i = 1; i < n; i *= 2) {
    for (int j = 0; j < n - 1; j += i) {
      if (a[j] > a[j+i]) {
        a[j] = a[j] - a[j+i];
      } else if (a[j] < a[j+i]) {
        a[j] = a[j+i] - a[j];
      }
    }
  }

  // 解答
  cout << a[0] << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll solve()
{
    int n;

    cin >> n;

    cout << 3 * n * n << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < K; i++) ans += p[i];
  cout << ans << endl;
}

Measured memory_bytes: 3628
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
A = l[0] * 1
B = l[1] * 1
C = l[2] * 1
D = l[3] * 1
console.log(Math.abs(C - A) <= D || (Math.abs(B - A) <= D && Math.abs(C - B) <= D) ? 'Yes' : 'No')

Measured memory_bytes: 7372
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  ll a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  ll mid = (n + 1) / 2;
  ll midNum = a[mid];
  for (int i = 0; i < n; i++) {
    if (b[i] < midNum) cout << a[mid] << endl;
    else cout << a[mid - 1] << endl;
  }
}

Measured memory_bytes: 5248
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var R = int.Parse(Console.ReadLine());
            var G = int.Parse(Console.ReadLine());
            Console.WriteLine(2 * G - R);
        }
    }
}


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

int main(){
  ll n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  ll f=min(min(a,b),min(c,min(d,e)));
  cout<<(n+f-1)/f+4<<endl;
}

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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

bool isPrime[10010];

void Prime()
{
    rep(i, 10010) isPrime[i] = true;

    isPrime[0] = false;
    isPrime[1] = false;

    for(int i = 2; i <= sqrt(10010); i ++)
    {
        if(isPrime[i])
        {
            for(int j = i * 2; j <= 10010; j += i)
                isPrime[j] = false;
        }
    }
}

int main()
{
    Prime();

    int N;
    while(cin >> N, N)
    {
        for(int i = N; 0 < i; i--)
        {
            if(isPrime[i] && isPrime[i - 2])
            {
                cout << i - 2<< " " << i << endl;
                break;
            }
        }   
    }

    return 0;
}


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

vector<int>E[100];
bool used[200];
int match[200];

bool dfs(int u) {
	used[u] = true;
	for (int v : E[u]) {
		int w = match[v];
		if (w == -1 || (!used[w] && dfs(w))) {
			match[u] = v; match[v] = u;
			return true;
		}
	}
	return false;
}
int x[100], y[100], z[100], a[100], b[100];
double d[100][100];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)scanf("%d%d%d", &x[i], &y[i], &z[i]);
		rep(i, m)scanf("%d%d", &a[i], &b[i]);
		rep(i, n)rep(j, m)d[i][j] = hypot(x[i] - a[j], y[i] - b[j]) / z[i];
		double l = 0, r = 14143;
		rep(i, 42) {
			double t = (l + r) / 2;
			rep(j, n) {
				E[j].clear();
				rep(k, m) {
					if (d[j][k] <= t)E[j].push_back(n + k);
				}
			}
			int cnt = 0;
			memset(match, -1, sizeof(match));
			rep(j, n) {
				if (match[j] == -1) {
					memset(used, 0, sizeof(used));
					cnt += dfs(j);
				}
			}
			if (cnt == m)r = t;
			else l = t;
		}
		printf("%.14lf\n", l);
	}
}

Measured memory_bytes: 3380
#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<set>
#include<string.h>
#include<vector>
using namespace std;

#define int long long

void fastio()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
  fastio();
  int a;
  long double b;
  cin >> a >> b;
  int ans = a * b;
  cout << ans;
  return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main()
{
    int N, M, X0, Y0;
    cin >> N >> M >> X0 >> Y0;

    vector<int> X(N), Y(M);
    for (auto &x : X) cin >> x;
    for (auto &y : Y) cin >> y;

    X.push_back(X0);
    Y.push_back(Y0);
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());

    bool f = (X.back() >= Y.front());
    cout << (f ? "War" : "No War") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

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

	return gcd(b, a % b);
}

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

int
main(int argc, char **argv)
{
	while (true)
	{
		int a1, a2, a3;
		int m1, m2, m3;

		scanf("%d %d %d %d %d %d", &a1, &m1, &a2, &m2, &a3, &m3);

		if (a1 == 0 && m1 == 0 && a2 == 0 && m2 == 0 && a3 == 0 && m3 == 0)
			break;

		int x = 1;
		long cx = 0;
		do
		{
			x = (a1 * x) % m1;
			cx++;
		} while (x != 1);

		int y = 1;
		long cy = 0;
		do
		{
			y = (a2 * y) % m2;
			cy++;
		} while (y != 1);

		int z = 1;
		long cz = 0;
		do
		{
			z = (a3 * z) % m3;
			cz++;
		} while (z != 1);

		printf("%ld\n", lcm(lcm(cx, cy), cz));
	}

	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
  ll x,y;cin >>x>>y;
  ll ans=0;
  if(abs(x)==abs(y)){
      if(x*y<0)ans=1;
      else ans=0;
  }
  else if(abs(x)<abs(y)){
      if(x<0)ans++;
      ans+=abs(y)-abs(x);
      if(y<0)ans++;
  }
  else {
      if(x>0)ans++;
      if(y>0)ans++;
      ans+=abs(x)-abs(y);
  }
  cout <<ans <<endl;
  return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	MOD := int(math.Pow10(9)) + 7

	var N, M int
	fmt.Scan(&N, &M)
	if M > N {
		N, M = M, N
	}

	ans := 1
	if N-M > 1 {
		fmt.Println(0)
		return
	} else if N-M == 0 {
		ans = 2
	}

	for i := 1; i <= N; i++ {
		ans = (ans * i) % MOD
	}
	for i := 1; i <= M; i++ {
		ans = (ans * i) % MOD
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1836
#define P(s,t) printf("%d"s,t);
#define F(i,c) for(i=0;i<c;i++)
main(r,c,i,j,v,p){int*q;scanf("%d%d",&r,&c);q=calloc(c+1,4);F(i,r){p=0;F(j,c)scanf("%d",&v),p+=v,q[j]+=v,P(" ",v)q[c]+=p;P("\n",p)}F(j,c)P(" ",q[j])P("\n",q[c])exit(0);}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

#define DIV 1000000007

long long S;
long long memo[2005];


long long dfs(long long num) {
	if(num < 3) {
		return 0;
	} 
	if(num == 3) {
		return 1;
	}
	if(memo[num] > 0) {
		return memo[num];
	}

	//全部ここで撮る場合の1
	long long ret = 1;
	//ここで撮る数字
	for(long long i = 3; i < num; i++) {
		ret += dfs(num - i);
		ret %= DIV;
	}

	memo[num] = ret;
	return ret;
}

int main(){
	cin >> S;
	cout << dfs(S) << endl;
}


Measured memory_bytes: 3600
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  string s;
  cin >> s;
  s= " "+s;
  if(s[3]==s[4] && s[5]==s[6]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


return 0;
}
///....


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

using namespace std;



int main(int argc, char* argv[])
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int A, B;
  cin >> A >> B;
  bool check = false;
  for (int C = 1; C <= 3; ++C)
  {
    if ((A*B*C) & 1) check = true;
  }
  cout << (check ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    int N;cin>>N;
    vector<ll> A(N);
    vector<ll> accum(N+1,0);
    REP(i,N){
        cin>>A[i];
        accum[i+1] = accum[i] + A[i];
    }
    map<ll,ll> nums;
    REP(i,N+1) nums[accum[i]]++;
    ll ans = 0;
    for (auto it :nums){
        ll num = it.second;//
        ans += num * (num-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
 
  long long int H, W;
  cin >> H >> W;
  if(H<2 || W<2){
    cout << "1";
  }else if(W%2==0){
    cout << W/2*H;
  }else{
    long long int ans=0;
    for(int i=0; i<H; i++){
      ans+=W/2;
      if(i%2==0){
        ans++;
      }
    }
    cout << ans;
  }
 
 
 
 
  return 0;
}

Measured memory_bytes: 256
using System;
namespace atcoder_practice1
{
    class _085Ccs
    {
        static void Main()
        {
            NewMethod();
        }

        private static void NewMethod()
        {
            int N, Y;
            int no;
            string input;
            string[] input_array;

            input = Console.ReadLine();
            input_array = input.Split(' ');

            N = int.Parse(input_array[0]);
            Y = int.Parse(input_array[1]);


            for (int hu = 0; hu <= Y / 10000; hu++)
            {
                for (int hi = 0; hi <= (Y - 10000 * hu) / 5000; hi++)
                {
                    no = N - hu - hi;
                    if (10000 * hu + 5000 * hi + 1000 * no == Y)
                    {
                        Console.WriteLine("{0} {1} {2}", hu, hi, no);
                        return;
                    }
                }
            }
            Console.WriteLine("{0} {1} {2}", -1, -1, -1);
            return;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int n, m; cin >> n >> m;
  vector<int> c(n+1, 0);
  REP(i, m){
    int l, r; cin >> l >> r;
    --l; --r;

    c[l] += 1;
    c[r+1] -= 1;
  }

  REP(i, n) c[i + 1] += c[i];

  int ans = 0;
  REP(i, n){
    if(c[i] == m) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define N 2000006
using namespace std;
const int inf=0x3f3f3f3f;
int n,l,maxn=0,b[N],c[N],ans1,ans2=inf;
map <int,int> mp;
struct node
{
	int l,r;
}a[N];
bool cmp(node a,node b)
{
	if (a.l==b.l) return a.r>b.r;
	else return a.l<b.l;
}
signed main()
{
	scanf("%lld%lld",&n,&l);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].l,&a[i].r);
		b[2*i-1]=a[i].l;
		b[2*i]=a[i].r;
	}
	sort(b+1,b+2*n+1);
	int cnt=unique(b+1,b+2*n+1)-b-1;
	l=lower_bound(b+1,b+cnt+1,l)-b;
	for (int i=1;i<=n*2;i++)
	{
		a[i].l=lower_bound(b+1,b+cnt+1,a[i].l)-b;
		a[i].r=lower_bound(b+1,b+cnt+1,a[i].r)-b;
		c[a[i].l]++;
		c[a[i].r]--;
	}
	for (int i=1;i<cnt;i++)
	{
		if (i) c[i]+=c[i-1];
		ans2=min(ans2,c[i]);
	}
	sort(a+1,a+n+1,cmp);
	ans1=0;
	int r=0;
	for (int i=1;i<=n;i++)
	{
		int j=i,tmp=a[i].r;
		while (a[j+1].l<=r && j<n) tmp=max(tmp,a[j+1].r),j++;
		i=j;
		r=max(tmp,r);
		ans1++;
		if (r==l) break;
	}
	printf("%lld %lld\n",ans1,n-ans2+1);
	return 0;
}


Measured memory_bytes: 15212
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int N, K;
  cin >> N >> K;
  int h[N];
  REP(i, N)
      cin >> h[i];

  int cost[N];
  REP(i, N)
  cost[i] = INF;
  cost[0] = 0;

  int a;
  REP(i, N - 1)
  {
    FOR(j, i + 1, min(i + 1 + K, N))
    {
      a = cost[i] + abs(h[i] - h[j]);
      if (a < cost[j])
        cost[j] = a;
    }
  }

  cout << cost[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

using et = tuple<int, int, int>;


int main() {
	int N, Q;
	cin >> N >> Q;
	priority_queue<et, vector<et>, greater<>> pq;
	for (int i = 0; i < N; i++) {
		int s, t, x;
		cin >> s >> t >> x;
		pq.push(et(s - x - 1, x, 0));
		pq.push(et(t - x - 1, x, -1));
	}

	for (int i = 0; i < Q; i++) {
		int d;
		cin >> d;
		pq.push(et(d, -1, -2));
	}
	set<int> closed;
	while (!pq.empty()) {
		auto t = pq.top(); pq.pop();
		//cerr << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << endl;
		switch (get<2>(t)) {
		case 0:
			closed.insert(get<1>(t));
			break;
		case -1:
			closed.erase(get<1>(t));
			break;
		case -2:
			//cerr << "closed : ";
			//for (auto num : closed) {
			//	cerr << num << ", ";
			//}cerr << endl;
			if (closed.size() == 0) {
				cout << -1 << endl;
			}
			else {
				cout << (*closed.begin()) << endl;
			}
		}

	}
	return 0;
}

Measured memory_bytes: 18152
#include <stdio.h>

int main(void){
	long N,M;
	scanf("%ld %ld",&N,&M);
	long ans;
	if(N==1 && M==1){
		ans = 1;
	}else if(N==1 || M==1){
		ans = N*M-2;
	}else{
		ans = (N-2)*(M-2);
	}
	printf("%ld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    string c = "No";
    int h,w;
    cin >> h >> w;
    char a[h][w];
    map<char,int> mp;
    rep(i,h)rep(j,w){
        cin >> a[i][j];
        mp[a[i][j]]++;
    } 
    if(h>1&&w>1){
        int cnt = ((h-h%2)*(w-w%2))/4;
        for(auto i:mp){
            int x,y;
            tie(x,y)=i;
            while(4<=y&&cnt>0){
                y -= 4;
                cnt--;
                mp[x] -= 4;
            }
        }
        if(cnt==0){
            if(h%2==0&&w%2==0) c = "Yes";
            int cnt1 = (w+h)/2-(h/2)*(h%2)-(w/2)*(w%2)+(h+w)%2-1;
            for(auto i:mp){
                int x,y;
                tie(x,y)=i;
                while(2<=y&&cnt1>0){
                    y -= 2;
                    cnt1--;
                    mp[x] -= 2;
                }
            }
            if(cnt1==0) c = "Yes";
        }
    }
    else{
        int cnt1 = max(h,w)/2;
        for(auto i:mp){
            int x,y;
            tie(x,y)=i;
            while(2<=y&&cnt1>0){
                y -= 2;
                cnt1--;
                mp[x] -= 2;
            }
        }
        if(cnt1==0) c = "Yes";
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int DIM = 5e1 + 5;
 
long long dp[DIM][DIM * DIM];
 
int main( void ) {
    
    int n, a;
    cin >> n >> a;
    
    dp[0][0] = 1;
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        for( int j = i - 1; j >= 0; j -- )
            for( int k = 0; k <= DIM * j; k ++ )
                dp[j + 1][k + x] += dp[j][k];
    }
    
    long long ans = 0;
    for( int i = 1; i <= n; i ++ )
        ans += dp[i][a * i];
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    K--;
    string str;
    cin >> str;
    if(str[K] == 'A') str[K] = 'a';
    else if(str[K] == 'B') str[K] = 'b';
    else str[K] = 'c';
    cout << str << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int a[100000];

int main() {
    int n = gi();
    ll as = 0, bs = 0;
    for (int i = 0; i < n; i++) {
        a[i] = gi();
        as += a[i];
    }

    vector<int> g;
    ll r = 0;
    int res = 0;;
    for (int i = 0; i < n; i++) {
        int b = gi();
        bs += b;
        a[i] -= b;
        if (a[i] > 0)
            g.push_back(a[i]);
        else if (a[i] < 0) {
            r -= a[i];
            res++;
        }
    }

    if (as < bs) {
        printf("-1\n");
        return 0;
    }

    sort(g.begin(), g.end(), greater<int>());

    for (int e : g) {
        if (r <= 0)
            break;
        r -= e;
        res++;
    }

    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
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 main()
{
    ll a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(c<=a+b)printf("No\n");
    else
    {
        if(4*a*b<(c-a-b)*(c-a-b))printf("Yes\n");
        else printf("No\n");
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
#include <queue>
 
using namespace std;
using ll = long long int;
 
int h, w;
 
ll bfs(vector<string> &s, vector<vector<bool>> &flag, int i, int j)
{
  //bfs
  queue<pair<int, int>> q;
  q.push({i, j});
  flag[i][j] = true;
  ll pw = 0;
  ll pb = 0;
  if(s[i][j] == '.')
  {
    pw++;
  }else{
    pb++;
  }
  while(!q.empty())
  {
    pair<int, int> current = q.front();
    q.pop();
    if(current.first > 0){
      if(s[current.first][current.second] != s[current.first - 1][current.second] && !flag[current.first - 1][current.second])
      {
        q.push({current.first - 1, current.second});
        flag[current.first - 1][current.second] = true;
        if(s[current.first - 1][current.second] == '.')
        {
          pw++;
        }else{
          pb++;
        }
      }
    }
    if(current.first < h - 1){
      if(s[current.first][current.second] != s[current.first + 1][current.second] && !flag[current.first + 1][current.second])
      {
        q.push({current.first + 1, current.second});
        flag[current.first + 1][current.second] = true;
        if(s[current.first + 1][current.second] == '.')
        {
          pw++;
        }else{
          pb++;
        }
      }
    }
    if(current.second > 0){
      if(s[current.first][current.second] != s[current.first][current.second - 1] && !flag[current.first][current.second - 1])
      {
        q.push({current.first, current.second - 1});
        flag[current.first][current.second - 1] = true;
        if(s[current.first][current.second - 1] == '.')
        {
          pw++;
        }else{
          pb++;
        }
      }
    }
    if(current.second < w - 1)
    {
      if(s[current.first][current.second] != s[current.first][current.second + 1] && !flag[current.first][current.second + 1])
      {
        q.push({current.first, current.second + 1});
        flag[current.first][current.second + 1] = true;
        if(s[current.first][current.second + 1] == '.')
        {
          pw++;
        }else{
          pb++;
        }
      }
    }
  }
  return pw * pb;
}
 
int main(){
  cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++)
  {
    cin >> s[i];
  }
  vector<vector<bool>> flag(h, vector<bool>(w, false));
  ll result = 0;
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      if(flag[i][j]) continue;
      result += bfs(s, flag, i, j);
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 1016
#include <cstdio>

void swap(short &a, short &b)
{
    short tmp = b;
    b = a;
    a = tmp;
}

int main()
{
    short a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if(b > c)
    {
        swap(b, c);
    }
    if(a > b)
    {
        swap(a, b);
    }
    if(b > c)
    {
        swap(b, c);
    }
    printf("%d %d %d\n", a, b, c);

}


Measured memory_bytes: 2748
import math
a,b,C=map(int,input().split())
print(f'{a*b*math.sin(math.radians(C))*1/2:.5f}')
print(f'{a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C))):.5f}')                
print(f'{b*math.sin(math.radians(C)):.5f}')


Measured memory_bytes: 5720
#include <stdio.h>
int main(){
	int h, w, i, j;
	while(1){
	scanf("%d %d", &h, &w);
	if (h ==0 && w == 0){
		break;
	}
	for (i = 1; i <= h; i++){
		for (j = 1; j <= w; j++)
			printf("#");
		printf("\n");
	}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int k,a,b,i,c=0;
	cin>>k>>a>>b;
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			printf("OK\n");
			c=1;
			break;
		}
	}
	if(c==0)
		{
			printf("NG\n");
		}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)1e9+7;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

void solve(){
	
	ll n,k,a;
	vector < ll > v;
	cin >> n >> k;
	f1(n) cin >> a, v.pb(a);
	sort(v.begin(), v.end());
	ll ans= 0;
	for(ll i = 0; i < k ; i++) ans += v[i];
	cout << ans;
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 3652
l, r = map(int,input().split())
arr = []
if r-l < 2019**2:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      arr.append(a)
    if 0 in arr:
      break
  print(min(arr))
else:
  print(0)

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

int main()
{
	int n;

	cin >> n;
	vector<int> a(n);

	for (int i = 0; i < n; i++)
		cin >> a[i];

	vector<int> b(a);

	if (prev_permutation(a.begin(), a.end())) {
		for (int i = 0; i < n - 1; i++)
			cout << a[i] << " ";
		cout << a[n - 1] << endl;
	}

	for (int i = 0; i < n - 1; i++)
		cout << b[i] << " ";
	cout << b[n - 1] << endl;

	if (next_permutation(b.begin(), b.end())) {
		for (int i = 0; i < n - 1; i++)
			cout << b[i] << " ";
		cout << b[n - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include<string>
#include<vector>
using ll = long long;
using namespace std;
int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    ll set = n / 15;
    ans += 60 * set * set;
    ll rest = n % 15;
    ll count = 0;
    for (ll i = 1; i <= rest; i ++){
        if(i % 3 != 0 && i % 5 != 0)    {
            ans += i;
            count ++;
        }
    }
    ans += 15 * count * set; // この時点でrestは15以下なのであとはwhile loopで足し算
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3188
import sys

def cross(a, b):
	return (a.conjugate() * b).imag
def dot(a, b):
	return (a.conjugate() * b).real

def ccw(a, b, c):
	x = b - a
	y = c - a;
	if cross(x, y) > 0: return 1
	if cross(x, y) < 0: return -1
	if dot(x, y) < 0: return 2
	if abs(x) < abs(y): return -2
	return 0

def solve(l, p):
	x = ccw(l[0][0], l[0][1], p)
	if x == 0: x = 1
	else: x = int(x / abs(x))
	for i in l[1:]:
		y = ccw(i[0], i[1], p)
		if y == 0: y = 1
		else: y = int(y / abs(y))
		if x != y:
			print "NO"
			return
	print "YES"

for line in sys.stdin:
	try:
		ax, ay, bx, by, cx, cy, px, py = map(float, line.split())
	except ValueError:
		sys.exit(0)
	a = complex(ax, ay)
	b = complex(bx, by)
	c = complex(cx, cy)
	p = complex(px, py)
	solve([(a, b), (b, c), (c, a)], p)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int t, d, l; cin >> t >> d >> l;
    if(t == 0) break;
    int now = 0;
    int ans = 0;
    REP(i, t) {
      int tmp; cin >> tmp;
      if(i == t-1) break;
      if(tmp >= l) {
        now = d-1;
        ans++;
      } else if(now > 0) {
        ans++;
        now--;
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3092
import sys
from collections import defaultdict

n = int(input())
s = [sys.stdin.readline().rstrip() for _ in range(n)][::-1]

d = defaultdict(int)

result = 0
for i in range(n):
    num = ''.join(sorted(s[i]))
    result += d[num]
    d[num] += 1

print(result)

Measured memory_bytes: 68700
import itertools 
n = int(input())
s = list(map(int,input().split()))
q = list(map(int,input().split()))
z = 0
l = [i for i in  range(1,n+1)]
l1 = itertools.permutations(l)
for i in l1:
  z += 1
  if list(i)==s:
    a =z
  if list(i)==q:
    c = z
print(abs(c-a))

Measured memory_bytes: 3064
mod = 10**9+7
S = int(input())
dp = [[0]*(S+1) for _ in range(S//3+2)]
dp[0][0] = 1
ans = 0
for i in range(1,S//3+1):
    for j in range(3,S+1):
        dp[i][j] = dp[i][j-1]+dp[i-1][j-3] % mod
    ans += dp[i][S]
    ans %= mod
print(ans)

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

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    int tmp;
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2 - i; j++)
        {
            if (a[j] > a[j+1])
            {
                tmp = a[j];
                a[j] = a[j+1];
                a[j+1] = tmp;
            }
        }
    }

    cout << a[0] << " " << a[1] << " " << a[2] << endl; 
    return 0;
}



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

int main() {
  vector<int> v(3);
  rep(i,3){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  vector<int> h = {5,5,7};
  if(v==h){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
n, x = map(int, input().split())
if 1 < x < 2 * n - 1:
	print("Yes")
else:
	print("No")
	exit()
t = list(range(2, 2 * n - 1))
t.remove(x)
ans = t[:n - 2] + [2 * n - 1, x, 1] + t[n - 2:]
print(*ans, sep="\n")


Measured memory_bytes: 17688
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int n,max_num = -1000001,min_num = 1000001,tmp;
    long long int sum = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&tmp);
        sum += tmp;
        max_num = max(max_num,tmp);
        min_num = min(min_num,tmp);
    }
    printf("%d %d %lld\n",min_num,max_num,sum);
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, d, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;
map<ll, ll> m;


int main() {
	//Code Line
	cin >> n >> a;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < n - a; i++) {
		if (A[i + a] > A[i])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 5208
import java.util.*;

class Main {
	
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int rept = in.nextInt();
		while(rept-- > 0){
			double x1 = in.nextDouble(), y1 = in.nextDouble(),
					x2 = in.nextDouble(), y2 = in.nextDouble(),
					x3 = in.nextDouble(), y3 = in.nextDouble(),
					x4 = in.nextDouble(), y4 = in.nextDouble();
			double p1 = x2 - x1, p2 = y2 - y1, q1 = x4 - x3, q2 = y4 - y3,
			r1 = x3 - x1, r2 = y3 - y1, s1 = x4 - x1, s2 = y4 - y1;
//			if(Math.abs(p1*q2 - p2*q1)<1e-9 && Math.abs(p1*r2 - p2*r1)>1e-9 && Math.abs(p1*s2 - p2*s1)>1e-9 
//					&& p1*p1 + p2*p2>1e-9 && q1*q1 + q2*q2 > 1e-9)
			if(Math.abs(p1*q2 - p2*q1)<1e-9)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}

}

Measured memory_bytes: 12000
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int X, A;
    cin >> X >> A;

    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

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

#define int long long

using namespace std;

const int MAXN = 1e6 + 100;

int criba[MAXN];

void cribar()
{
	for(int i = 0 ; i < MAXN ; i++)criba[i] = i;

	for(int i = 2 ; i < MAXN ; i++)
	{
		if(criba[i] == i)
		{
			for(int j = i ; j < MAXN ; j += i)
			{
				criba[j] = i;
			}
		}
	}
}

int fff[MAXN];

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

    cribar();

    int N;
    cin >> N;

    int G = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	int n;
    	cin >> n;
    	G = __gcd(G,n);

    	set<int> st;

    	while(n != 1)
    	{
    		st.insert(criba[n]);
    		n /= criba[n];
    	}

    	for(auto x : st)
    	{
    		fff[x]++;
    	}
    }

    bool flag = true;

    for(int i = 0 ; i < MAXN ; i++)
    {
    	if(fff[i] > 1)flag = false;
    }

    if(flag == true)
    {
    	cout << "pairwise coprime" << '\n';
    }
    else
    {
    	if(G == 1)
    	{
    		cout << "setwise coprime" << '\n';
    	}
    	else
    	{
    		cout << "not coprime" << '\n';
    	}
    }

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll Q, H, S, D;
    ll N;
    cin >> Q >> H >> S >> D >> N;
    S = min(S, min(2*H, 4*Q));
    cout << min(2*S, D)*(N/2) + (N%2)*S << endl;



    return 0;
}

Measured memory_bytes: 3596