akhauriyash/Code-Regression huggingface dataset:
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連


int N;
VI A;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}


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


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int X;
	cin >> X;
	bool ok = false;
	int a = 0;
	for (int i = 1; i * (i + 1) <= 2 * X; ++i)
	{
		if (i * (i + 1) == 2 * X) {cout << i << endl; return 0;}
		a = i;
	}
	cout << a + 1 << endl;






}







Measured memory_bytes: 3580
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> sum(n+1,0);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        sum[a]++;
        sum[b+1]--;
    }
    for(int i = 1; i < n; i++){
        sum[i] += sum[i-1];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(sum[i] == m) ans++;
        //cout << sum[i] << " ";
    }
    cout << ans << endl;
}

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

int main() {
	string s1, s2, s;
	int a, b;
	
	cin>>s1>>s2>>a>>b>>s;
	if(s==s1)a--;
	else b--;
	
	cout<<a<<' '<<b<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll n;

void init(){
	cin>>n;
}

int main(void){
	init();
	cout<<180*(n-2)<<endl;
	return 0;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	vector<int>V(N), C(N);
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (V[i] > C[i]) {
			ans += V[i] - C[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
a, b, c, x = 4.times.map{gets.to_i}
cnt = 0
(0..a).each do |i|
    (0..b).each do |j|
		t = x - 500 * i - 100 * j
      	if t >= 0 && t % 50 == 0 && t / 50 <= c
          cnt += 1
        end
    end
end
puts cnt

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

int main(){
  int i,n,min,max,a;
  long long int sum;

  cin>>n>>a;

  min=a;
  max=a;
  sum=a;

  for(i=0;i<n-1;i++){
    cin>>a;
    if(min>a){
      min=a;
    }
    if(max<a){
      max=a;
    }
    sum+=a;
  }

  cout<<min<<" "<<max<<" "<<sum<<endl;

  return 0;
}

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

int main(){
    int n, i, h1 = 0, h2, count = 0, result = 0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> h2;
        if(h1 < h2){
            result = max(count, result);
            count = 0;
        }else{
            count++;
        }
        h1 = h2;
    }
    cout << max(count, result);
    return 0;
}

Measured memory_bytes: 256
import math

a,b,s = map(float,input().split())
radian_s = math.radians(s)

print(a*b/2*math.sin(radian_s))
print((a+b)+(math.sqrt((a**2+b**2)-(a*b*2*math.cos(radian_s)))))
print(b*math.sin(radian_s))



Measured memory_bytes: 5692
#include <iostream>

using namespace std;

int main(){
    int a,b,out;
    char op;

    cin >> a >> op >> b;

    if( op == '+'){
        out = a + b;
    }
    else if( op == '-'){
        out = a - b;
    }
    else{
        out = 0;
    }

    cout << out << endl;

}



Measured memory_bytes: 256
def solve():
    N = int(input())
    S = [0]*N
    for i in range(N):
        S[i] = input().split()
        S[i][1] = int(S[i][1])
    T = sorted(S, key=lambda x:(x[0],-x[1]))
    ans = []
    for t in T:
        ind = S.index(t)
        ans.append(ind+1)
    return ans
print(*solve(),sep='\n')

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Integer s = scan.nextInt();
		List<Integer> numList = new ArrayList();
		OUT:for(int i = 1;; i++) {
			if(i==1) {
				numList.add(s);
			}
			Integer currentValue = null;
			if(i>1) {
				Integer prevValue = numList.get(i-2);
				if(prevValue%2==0) {
					currentValue = prevValue/2;
				}else {
					currentValue = 3*prevValue+1;
				}
				for(Integer num:numList) {
					if(currentValue == num) {
						System.out.println(i);
						break OUT;
					}
				}
				numList.add(currentValue);
			}
		}
	}
}

Measured memory_bytes: 23252
#include"stdio.h"
int main(){
  int n;
  scanf("%d",&n);
  int count;
 if(1<=n&&n<2) 
   count=1;
 if(2<=n&&n<4)
   count=2;
  if(4<=n&&n<8)
    count=4;
  if(8<=n&&n<16)
    count=8;
  if(16<=n&&n<32)
    count =16;
  if(32<=n&&n<64)
    count=32;
  if(64<=n&&n<101)
    count=64;
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  map<string,int> cnt;
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    cnt[s]++;
  }
  cout << cnt.size() << endl;
}

Measured memory_bytes: 19220
package main

import (
	"os"
	"fmt"
	"bufio"
	"strings"
	"strconv"
)

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	HW   := strings.Split(sc.Text(), " ")
	H, _ := strconv.Atoi(HW[0])
	W, _ := strconv.Atoi(HW[1])
	var grid = make([][]string, H)
	for i := 0; i < H; i++ {
		sc.Scan()
		grid[i] = make([]string, W)
		grid[i] = strings.Split(sc.Text(), "")
	}
	
	cnt := 0
	for i := 0; i < len(grid); i++ {
		for j := 0; j < len(grid[i]); j++ {
			if (grid[i][j] == "#") &&
				(i != 0 && grid[i - 1][j] != "#") &&
				(i != len(grid) - 1 && grid[i + 1][j] != "#") && 
				(j != 0 && grid[i][j - 1] != "#") && 
				(j != len(grid[i]) - 1 && grid[i][j + 1] != "#") {
				cnt++
			}
		}
	}

	if cnt == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 768
import Control.Monad
import Data.Maybe
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as BS

topWords :: [BS.ByteString] -> [BS.ByteString]
topWords = reverse . takeTops . sortBySnd . makePairs . sort
   where
      makePairs :: [BS.ByteString] -> [(BS.ByteString,Int)]
      makePairs = countPairs 1
      sortBySnd :: [(BS.ByteString,Int)] -> [(BS.ByteString,Int)]
      sortBySnd list = reverse $ sortBy (comparing snd) list
      takeTops :: [(BS.ByteString,Int)] -> [BS.ByteString]
      takeTops [x] = [fst x]
      takeTops (x:y:s)
         |snd x == snd y = [fst x] ++ (takeTops (y:s))
         |otherwise      = [fst x]
      countPairs :: Int -> [BS.ByteString] -> [(BS.ByteString,Int)]
      countPairs n [a] = [(a,n)]
      countPairs n (x:y:s)
         | x==y     = countPairs (n+1) (y:s)
         |otherwise = [(x,n)] ++ (countPairs 1 (y:s))

main = do
   n <- fst . fromJust . BS.readInteger <$> BS.getLine
   ss <- replicateM (fromIntegral n) BS.getLine
   mapM_ BS.putStrLn $ topWords ss

Measured memory_bytes: 81020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  unsigned long long x;
  cin >> x;
  unsigned long long c = 100;
  for(int i = 1; i < 10e5; i++) {
    ll b = c / 100;
    c = c + b;
    if(c >= x) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
int main(){
	int n,m,i,j;
	std::cin>>n>>m;
	int A[n][m],b[m];
	int ans[n];
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			std::cin>>A[i][j];
		}
	}	
	for(j=0;j<m;j++){
		std::cin>>b[j];
	}	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(j==0)ans[i]=0;
			ans[i]+=A[i][j]*b[j];
		}
	}
	for(i=0;i<n;i++){
			std::cout<<ans[i]<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1196
N,Y=map(int,input().split())
for x in range(0,N+1):
    for y in range(0,N+1):
        if(N-x-y>=0):
            if(10000*x+5000*y+1000*(N-x-y)==Y):
                print(x,y,N-x-y)
                exit()
print('-1 -1 -1')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
const int N=2005;
int n,k;
long long dp[N][N],ans;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	dp[1][1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=i;j++)dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
	}
	ans=dp[n][k];
	for(int i=1;i<n-k;++i)(ans*=2ll)%=MOD;
	cout<<ans<<endl;
	return 0;
}

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


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string len = Console.ReadLine();

            if(int.Parse(len) == 1)
            {
                Console.WriteLine("Hello World");
                return;
            }
            else
            {
                string len2 = Console.ReadLine();
                string len3 = Console.ReadLine();

                Console.WriteLine(int.Parse(len2) + int.Parse(len3));
                return;

            }



        }
    }
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

int main() {
	ll time, n, a[5], t[6], i, j, k;

	cin >> n;
	rep(i, 5) {
		cin >> a[i];
	}
	k = a[0];
	j = 0;
	repj(i, 1, 5) {
		if (k > a[i]) {
			k = a[i];
			j = i;
		}
	}

	time = j;
	if (n%a[j] == 0) {
		time += n / a[j];
	}
	else {
		time += n / a[j] + 1;
	}
	time += 4 - j;
	
	cout << time;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>

using namespace std;

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

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

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

ll N, K;
ll cnt[112345];

int main() {
	cin >> N >> K;
	REP(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		cnt[a] += b;
	}
	
	ll now = 0;
	REP(i, 112345) {
		if (now + cnt[i] >= K) {
			printf("%d\n", i);
			break;
		}
		now += cnt[i];
	}
	return 0;
}

Measured memory_bytes: 1024
//??????????¨????????????????????¬¬??????????¢?
//??????????´¢+DFS ??????
#include <iostream>
#define MAX_N 10
#define MAX_M 10000
using namespace std;
bool ex[MAX_N][MAX_M];
int n,m,ans;
void Dfs(int x)
{
    if(x==n)
    {
        int sum=0;
        for(int j=0;j<m;j++) {
            int right=0;
            for(int i=0;i<n;i++) {
                if(ex[i][j]) right++;
            }
            sum+=(right>(n-right))?right:(n-right);
        }
        ans=max(ans,sum);
        return;
    }
        //????????¢????????¬
    Dfs(x+1);

        //????????¢?????¬
    for(int i=0;i<m;i++)
        ex[x][i]=!ex[x][i];
    Dfs(x+1);
}

int main()
{
    while(true)
    {
        ans=0;
        cin>>n>>m;
        if(n!=0&&m!=0)
        {
            for(int i=0;i<n;i++)
                for(int j=0;j<m;j++)
                cin>>ex[i][j];
            Dfs(0);
            cout<<ans<<endl;
        }
        else break;
    }
    return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>

int main(void){
    int n,max=0,min=10000000000;
    int i;

    scanf("%d",&n);

    int a;

    for(i = 0;i<n;i++){
        scanf("%d",&a);
        if(max < a){
            max = a;
        }
        if(min > a){
            min = a;
        }
    }

    printf("%d",max-min);
    
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string s,t; cin >> s >> t;
    cout << t << s << endl;
}

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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll xmin, xmax;
    ll ymin, ymax;
    xmin = a; xmax = b;
    ymin = c; ymax = d;
    ll a1 = a * c;
    ll a2 = a * d;
    ll a3 = b * c;
    ll a4 = b * d;
    ll ans = a1;
    if (ans < a2) {
        ans = a2;
    }
    if (ans < a3) {
        ans = a3;
    }
    if (ans < a4) {
        ans = a4;
    }
    cout << ans << endl;



}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int n, m;
    cin >> n >> m;
    cout << (n - 1)*(m - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1000000007;
int main() {
	int N, M;
	cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}
  long long ans1 = 1, ans2 = 1;
		
		for (int i = N; i > 0; i--) {
			ans1 *= i;
			ans1%= INF;
		}
		for (int i =M; i > 0; i--) {
			ans2 *= i;
			ans2 %= INF;
		}
	if(N==M) cout<< (ans1*ans2*2) % INF<<endl; 
	else{ 
     cout << (ans1*ans2) % INF << endl;
    }
      return 0;
}

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

vector<long long int>X;

void init( long long int N ) {
	if( N > 1000000000000000000LL ) {
		return;
	}
	if( N ) {
		X.emplace_back( N );
	}
	N *= 10;
	init( N + 2 );
	init( N + 8 );
}

long long int saiki( long long int now, long long int p ) {
	if( now == 1 ) {
		return 0;
	}
	long long int ret = -1;
	for( size_t i = p; i < X.size(); i++ ) {
		if( now%X[i] == 0 ) {
			long long int memo = saiki( now / X[i], i );
			if( memo != -1 ) {
				ret = max( ret, memo + 1 );
			}
		}
	}
	return ret;
}

int main() {
	init( 0LL );
	sort(X.rbegin(),X.rend());
	long long int N;
	cin >> N;
	if( N == 1 ) {
		cout << -1 << endl;
	} else {
		cout << saiki( N, 0 ) << endl;
	}
}

Measured memory_bytes: 6880
import java.util.*;

/**
 * year -> orderの変換を作る
 * 
 * @author glycine
 *
 */
public class Main {
	private static class Node {
		int p;
		long y;
		int order = -1;

		public Node(int p, long y) {
			this.p = p;
			this.y = y;
		}
	}

	int N, M;
	int[] indexes;
	List<Node> nodes;
	Map<Long, Node> maps = new TreeMap<>();
	List<String> results;

	public Main() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		M = in.nextInt();
		indexes = new int[N];
		Arrays.fill(indexes, 0);
		nodes = new ArrayList<>(M);
		for (int i = 0; i < M; ++i) {
			int p = in.nextInt();
			long y = in.nextLong();
			Node node = new Node(p, y);
			nodes.add(node);
			maps.put(node.y, node);
		}
		in.close();
	}

	private void calc() {
		for (Node city : maps.values()) {
			int i = city.p - 1;
			++indexes[i];
			city.order = indexes[i];
		}
	}

	private void show() {
		for (int i = 0; i < nodes.size(); ++i) {
			Node node = nodes.get(i);
			int p = node.p;
			int order = node.order;
			String line = String.format("%06d%06d", p, order);
			System.out.println(line);
		}
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		ins.show();
	}
}

Measured memory_bytes: 152600
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
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);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	facto();
	int n,m;
	cin>>n>>m;
	int sum=0;
	if(n>=2)
		sum+=ncr(n,2);
	if(m>=2)
		sum+=ncr(m,2);
	cout<<sum<<endl;
}










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

int main()
{
  //  freopen("in.txt","r",stdin);
        string ss;
        cin>>ss;

        int rem=0;

        for(int i=0;i<ss.size();i++)
        {
                rem=rem+ (ss[i]-48);
                rem=rem%9;
        }
        if(rem==0)
            cout<<"Yes";
        else
            cout<<"No";

    return 0;
}

Measured memory_bytes: 3688
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<sstream>
#include<bitset>
#include<numeric>
#include<climits>
using namespace std;

typedef long long ll;

template<int N,typename T,T INF>
struct segment_tree_rmq {
	vector<pair<T, int>>mini, maxi;
	segment_tree_rmq() :mini(1 << (N + 1)), maxi(1 << (N + 1)) {
		for (int i = 0; i < 1 << N; i++) {
			mini[i + (1 << N) - 1] = { INF,i };
			maxi[i + (1 << N) - 1] = { -INF,i };
		}
		for (int i = (1 << N) - 2; i >= 0; i--) {
			mini[i] = min(mini[i * 2 + 1], mini[i * 2 + 2]);
			maxi[i] = max(maxi[i * 2 + 1], maxi[i * 2 + 2]);
		}
	}
	void update(int k, T x) {
		k += (1 << N) - 1;
		mini[k].first = maxi[k].first = x;
		while (k) {
			k = (k - 1) / 2;
			mini[k] = min(mini[k * 2 + 1], mini[k * 2 + 2]);
			maxi[k] = max(maxi[k * 2 + 1], maxi[k * 2 + 2]);
		}
	}

	pair<T, int>get_min(int a, int b, int k = 0, int l = 0, int r = 1 << N) {
		if (r <= a || b <= l)return{ INF,-1 };
		if (a <= l&&r <= b)return mini[k];
		return min(get_min(a, b, k * 2 + 1, l, (l + r) / 2), get_min(a, b, k * 2 + 2, (l + r) / 2, r));
	}

	pair<T, int>get_max(int a, int b, int k = 0, int l = 0, int r = 1 << N) {
		if (r <= a || b <= l)return{ -INF,-1 };
		if (a <= l&&r <= b)return maxi[k];
		return max(get_max(a, b, k * 2 + 1, l, (l + r) / 2), get_max(a, b, k * 2 + 2, (l + r) / 2, r));
	}

	T get_min_val(int a, int b) { return get_min(a, b).first; }
	T get_max_val(int a, int b) { return get_max(a, b).first; }
	int get_min_idx(int a, int b) { return get_min(a, b).second; }
	int get_max_idx(int a, int b) { return get_max(a, b).second; }
};


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

	int n, q;
	cin >> n >> q;
	segment_tree_rmq<17, ll, INT_MAX>seg;
	for (int i = 0; i < q; i++) {
		int t, x, y;
		cin >> t >> x >> y;
		if (t == 0) {
			seg.update(x, y);
		}
		else {
			cout << seg.get_min_val(x, y + 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 11028
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int A, B, C;
    cin >> A >> B >> C;
    cout << C - min(C, A - B) << endl;
    return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  int ans = 0;
  string s;

  cin >> N;

  if(N < 1200){
    s = "ABC";
  }else if(N < 2800){
    s = "ARC";
  }else{
    s = "AGC";
  }

  cout << s << endl;

}


Measured memory_bytes: 256
import numpy as np

n, m = map(int, input().split())

h = {}
for k, v in zip(range(1,n+1),[k for k in map(int, input().split())]):
    h[k] = v 

miti = []
for i in range(m):
    temp = [k for k in map(int, input().split())]
    miti.append(temp)

x = np.zeros(n)

for i in range(m):
    if h[miti[i][0]] < h[miti[i][1]]:
        x[miti[i][0]-1] =+1
    elif h[miti[i][0]] > h[miti[i][1]]:
        x[miti[i][1]-1] =+1
    elif h[miti[i][0]] == h[miti[i][1]]:
        x[miti[i][0]-1] =+1
        x[miti[i][1]-1] =+1

print(sum(x == 0))


Measured memory_bytes: 56248
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>

using ll = long long;

int main()
{
  ll N;
  std::cin >> N;
  std::string s;
  std::cin >> s;

  ll a = 0;
  ll b = 0;
  for (ll i = 0; i < N; i++) {
    if (s[i] == '(') b++;
    if (s[i] == ')') b--;

    if (b < 0) {
      a++;
      b = 0;
    }
  }
  for (ll i = 0; i < a; i++) {
    std::cout << '(';
  }
  std::cout << s;
  for (ll i = 0; i < b; i++) {
    std::cout << ')';
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define f(i,a,b) for (ll i=(a); i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define mem(a,n) memset(a,n,sizeof a)
#define ln(a) a.length()
#define sz(a) (ll)a.size()
#define endl "\n"
#define pi 3.14159265358979

const ll M=1e9+7;
const int P=31;
const int MaxM=200005;
/*__________________________________________________________________________________________________________________*/
int n,m;
int x1,y11,x2,y2;
char s[1005][1005];
int vis[1005][1005];
int st[1000005];
vector<pair<int,int> >v[1000005];
struct trip{
    int a;int b;int c;
};
void dfs(int i,int j,int k)
{
    if(vis[i][j]!=0)return;
    vis[i][j]=k;
    v[k].pb({i,j});
    if(i+1<n && s[i+1][j]=='.')dfs(i+1,j,k);
    if(i-1>=0 && s[i-1][j]=='.')dfs(i-1,j,k);
    if(j-1>=0 && s[i][j-1]=='.')dfs(i,j-1,k);
    if(j+1<m && s[i][j+1]=='.')dfs(i,j+1,k);

    return;
}

void bfs(int i,int j,int val)
{
    queue<trip>q;
    q.push({i,j,val});
    while(!q.empty()){
    trip tmp=q.front();
    q.pop();
    int p=vis[tmp.a][tmp.b];
    if(st[p]!=-1)continue;
    st[p]=tmp.c;
    for(auto it:v[p])
    {
         int x=it.F,y=it.S;
         for(int i1=x-2;i1<=x+2;i1++)
         {
            for(int j1=y-2;j1<=y+2;j1++)
            {
                if(i1>=0 && j1>=0 && i1<n && j1<m && s[i1][j1]=='.' && st[vis[i1][j1]]==-1)
                    q.push({i1,j1,tmp.c+1});
            }
         }

    }}
    return;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);  
   
      
  cin>>n>>m;
  cin>>x1>>y11;
  x1--;y11--;
  cin>>x2>>y2;
  x2--;y2--;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
    {
        cin>>s[i][j];
    }
  }

  memset(vis,0,sizeof(vis));
  memset(st,-1,sizeof(st));
 // f(i,0,1000005)v[i].clear();

  int k=0;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
    {
        if(s[i][j]=='.' && vis[i][j]==0)
            {
                k++;
                dfs(i,j,k);
            }
    }
  }

  bfs(x1,y11,0);
  cout<<st[vis[x2][y2]]<<endl;

} 


Measured memory_bytes: 42580
import java.util.*;

class Main{
	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		for(int i=1;i<=9;++i) {
			for(int j=1;j<=9;++j) {
				if(i*j==n) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int main() {
  int n;
  	cin>>n;
  long long int sum=0;
  vector<long long int>vec(n);
  
  for(int i=0;i<n;i++){
	long long int a;
    	cin>>a;
    vec[i]=a;
  }
  //ここまではいい
  
  //sort(vec.begin(), vec.end());
  
  vector<long long int>nowA(n);
  vector<long long int>nowB(n);
  //ここまではいい
  
  //bec[0]=vec[0];
  //cout<<bec[0]<<endl;
  
  
  for(int i=1;i<n;i++){
	nowA[i]=__gcd(nowA[i-1],vec[i-1]);
     }
     //cout<<bec[i]<<endl;  
  
  for(int i=n-2;i>=0;i--){
    nowB[i]=__gcd(nowB[i+1],vec[i+1]);
  }
  vector<long long int>nowC(n);
  for(int i=0;i<n;i++){
    nowC[i]=__gcd(nowB[i],nowA[i]);
}
  sort(nowC.begin(), nowC.end());
  cout<<nowC[n-1]<<endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 333;
int Q;
int x[MC];
bool p[MC];
vector<P2> V;
int ans = 0;

void solve(int a , LL b){
	if(a<(int)V.size()){
		repp(i,0,V[a].second){
			solve(a+1,b);
			b *= V[a].first;
		}
		return;
	}
	int s = 0;
	repp(i,1,MC){
		if(b%i) continue;
		s += x[i];
	}
	repp(i,19,MC){
		if(!p[i]) continue;
		int t = 0;
		repp(j,1,MC){
			if(i*j>=MC) break;
			if(b%j) continue;
			t += x[i*j];
		}
		if(t>0) s += t;
	}
	ans = max(ans , s);
}

int main(){
	cin >> Q;
	repp(i,0,Q){
		int m;
		cin >> m;
		cin >> x[m];
	}
	fill(p+2,p+MC,1);
	for(int i = 2 ; i * i < MC ; ++i){
		if(!p[i]) continue;
		for(int k = i * i ; k < MC ; k += i) p[k] = 0;
	}
	V.PB(MP(2,9));
	V.PB(MP(3,6));
	V.PB(MP(5,4));
	V.PB(MP(7,3));
	V.PB(MP(11,3));
	V.PB(MP(13,3));
	V.PB(MP(17,3));
	solve(0,1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
a,b = input().split(" ")
line = []
num_list = []
for num in range(int(a)):
    iline = input().split(" ")
    ilist = [int(c) for c in iline]
    kei = 0
    for num1 in range(0,int(b)):
        kei += ilist[num1]
    num_list.append(kei)
num_list.sort()
print(num_list[int(a) - 1])


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

int main()
{
    int n, t;
    cin >> n >> t;
    int a[100010];
    int max_val[100010];
    int min_val[100010];
    max_val[n + 1] = 0;
    min_val[0] = 2000000000;
    int delta_val[100010];
    delta_val[0] = 0;
    int number = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        min_val[i] = min(min_val[i - 1], a[i]);
    }
    for(int i = n; i >= 1; i--){
        max_val[i] = max(max_val[i + 1], a[i]);
    }
    for(int i = 1; i <= n; i++){
        if(a[i] - min_val[i] > delta_val[i - 1]){
            number = 1;
        }
        if(a[i] - min_val[i] == delta_val[i - 1]){
            number++;
        }
        delta_val[i] = max(delta_val[i - 1], a[i] - min_val[i]);
    }
    cout << number << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
#define int long long
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define ss second
#define ff first
 
const int N=2e5+5;

void solve()
{
	int n,k;
	cin>>n>>k;
	int a[n+5];
	for(int i=1;i<=n;i++)
			cin>>a[i];
	for(int i=k;i<n;i++)
	{
		if(a[i-k+1] < a[i+1])
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}	
}
 
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	IOS;
 
	int t=1;
	while(t--)
		solve();
 
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
    sum += v.at(i);
  }
  
  if(sum %10 != 0){
    cout << sum << endl;
  } else { 
    sort(v.begin(), v.end());
    bool flg = false;
    for(auto x : v){
      if( (sum - x) % 10 != 0){
        cout << sum - x << endl;
        flg = true;
        break;
      }
    }
    if(!flg){
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 25

typedef struct{
  int p, s, deg, dep, h, left, right;
}Node;

int depth(Node *, int);
int height(Node *, int);

int main(){
  int i, n, id;
  Node T[MAX], tmp;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = -1;
    T[i].dep = 0;
    T[i].deg = 0;
    T[i].s = -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d",&id);
    scanf("%d%d", &T[id].left, &T[id].right);
    T[T[id].left].p = id;
    T[T[id].right].p = id;
    if(T[id].left != -1){
      T[id].deg++;
      T[T[id].left].s = T[id].right;
    }
     if(T[id].right != -1){
      T[id].deg++;
      T[T[id].right].s = T[id].left;
    }
  }

  for(i = 0; i < n; i++){
    T[i].dep = depth(T, i);
    T[i].h = height(T, i);
  }
  
  for(i = 0; i < n; i++){
    if(T[i].p == -1){
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", i, T[i].p, T[i].s, T[i].deg, T[i].dep, T[i].h);
    }
    else if(T[i].deg != 0){
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n" , i, T[i].p, T[i].s, T[i].deg, T[i].dep, T[i].h);
    }
    else{
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n" , i, T[i].p, T[i].s, T[i].deg, T[i].dep, T[i].h);
    }
  }

  return 0;
}

int depth(Node *T, int i){

  if(T[i].p == -1) return 0;

  return depth(T, T[i].p) + 1;
  
}

int height(Node *T, int i){
  int righth = 0, lefth = 0;

  if(T[i].right != -1) righth = height(T, T[i].right) + 1;

  if(T[i].left != -1) lefth = height(T, T[i].left) + 1;

  if(righth >= lefth) return righth;
  else return lefth;
}

Measured memory_bytes: 600
N = int(input())
h_list = list(map(int, input().split())) # "1 2 3"と入力

made=0
water=0
h_list.append(0)

while len(h_list)!=0:
    made=h_list.index(0)
    if made==0:
        h_list.pop(0)
    else:
        water+=1
        h_list[0:made]=[i-1 for i in h_list[0:made]]
print(water)

Measured memory_bytes: 3064
use std::vec::Vec;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (a, b ,q) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1], v[2])
    };

    let mut s: Vec<i64> = Vec::new();
    let mut t: Vec<i64> = Vec::new();
    let mut x: Vec<i64> = Vec::new();

    for i in 0..a {
      s.push(read());
    }
    s.push(std::i64::MAX/2);


    for j in 0..b {
      t.push(read());
    }
    t.push(std::i64::MAX/2);

    for k in 0..q {
      x.push(read());
    }


    for i in 0..q {
      println!("{}", calc(a, &s, b, &t, x[i]));
    }

}

fn binary_search(p: i64, n: usize, v: &Vec<i64>) -> usize {
  let mut ub: usize = n;
  let mut lb: usize = 0;

  let mut m;

  while ub - lb > 1 {
    m = (ub + lb) / 2;
    if v[m] > p {
      ub = m
    }
    else {
      lb = m
    }
  }
  return lb;
}

fn calc(n:usize, s: &Vec<i64>, m: usize, t: &Vec<i64>, x: i64) -> i64 {
  let mut res: i64 = std::i64::MAX;
  for i in 0..2 {
    for j in 0..2 {
      for k in 0..2 {
        if i % 2 == 0 {
          // sから先に探索する
          let indxs: usize = binary_search(x, n, s) + j;
          let indxt: usize = binary_search(s[indxs], m, t) + k;
          res = cmp::min(res, (x - s[indxs]).abs() + (s[indxs]- t[indxt]).abs());
        }
        else {
          // tから先に探索する
          let indxt: usize = binary_search(x, m, t) + j;
          let indxs: usize = binary_search(t[indxt], n, s) + k;
          res = cmp::min(res, (x - t[indxt]).abs() + (s[indxs]- t[indxt]).abs());
        }
      }
    }
  }
  return res;
}


Measured memory_bytes: 9468
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int N=200005;
int n,m,a[N];LL b[N],tot;
int main( )
{
  int i,s,t,x;
  n=read( );m=read( );
  for(i=1;i<=n;i++) a[i]=read( );
  for(i=1;i<n;i++) 
    {
      s=a[i];t=a[i+1];
      if(t<s) t+=m;x=t-s;tot+=x;
      b[s+2]--;b[t+1]+=x;b[t+2]-=(x-1);
    }
  t=m*2;
  for(i=1;i<=t;i++) b[i]=b[i-1]+b[i];
  for(i=1;i<=t;i++) b[i]=b[i-1]+b[i];
  LL ans=tot;
  for(i=1;i<=m;i++) ans=min(ans,tot+b[i]+b[m+i]);
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 2176
xs,ys,xe,ye=map(int,input().split())
n=int(input())
xyr=[tuple(map(int,input().split())) for _ in range(n)]
xyr.append((xs,ys,0))
xyr.append((xe,ye,0))
d=[[0]*(n+2) for _ in range(n+2)]
for i in range(n+1):
  for j in range(i+1,n+2):
    x,y,r=xyr[i]
    nx,ny,nr=xyr[j]
    tmp=((x-nx)**2+(y-ny)**2)**0.5
    tmp-=r+nr
    tmp=max(tmp,0)
    d[i][j]=tmp
    d[j][i]=tmp



inf=float('inf')
seen=[inf]*(n+2)
seen[-2]=0
mi=set(range(n+2))
# n->n+1
while mi:
  min_idx=0
  min_d=inf
  for v in mi:
    if min_d>seen[v]:
      min_d=seen[v]
      min_idx=v
  v=min_idx
  mi.discard(v)
  if v==n+1:break
  for nv in mi:
    seen[nv]=min(seen[nv],seen[v]+d[v][nv])
print(seen[-1])



Measured memory_bytes: 84024
/*  
   |\_/|
   |* *|
   \_+_/
          */
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a,b;

  cin>>a>>b;

  if(a+b==15){
    cout<<"+"<<endl;
  }else if(a*b==15){
    cout<<"*"<<endl;
  }else{
    cout<<"x"<<endl;
  }
  
  return 0;

}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    getline(cin , s);
    int len = s.length();
    cout << s[0];
    for(int i = 0; i < len; i++)
    {
        if(s[i] == ' ')
            cout << s[i+1];
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
s=list(s)
N=len(s)

def check(s):
    n=len(s)
    if n%2==1:
        lefts=s[:n//2]
        rights=s[n//2+1:]
    else:
        lefts=s[:n//2]
        rights=s[n//2:]
    if lefts!=rights[::-1]:
        return False
    else:
        return True

if check(s) and check(s[:(N-1)//2]) and check(s[(N+3)//2-1:]):
    print('Yes')
else: 
    print('No')

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  for(int i = 0; i < N; i++) {
    cout << S.at(i);
  }
}



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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	char c;
	cin >> c;
	if(65<=int(c) && int(c)<=90)
		cout<<"A"<<endl;
	else
		cout<<"a"<<endl;
	return 0;	
}


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

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

  vector<double> x(n);
  vector<double> y(n);

  for(int i=0;i<n;i++) {
    double a, b;
    cin >> a >> b;

    x[i] = a;
    y[i] = b;
  }

  // 全ての距離の合計
  float d = 0;
  for(int i=0;i<n;i++) {
    for(int j=i+1;j<n;j++) {
      d += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
    }
  }

  cout << setprecision(20) << d * 2 / n << endl;
}


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

int main(){
    ll n, m;
    cin >> m >> n;
    ll ans = 0;
    if(m >= n/2) ans = n/2;
    else{
        ans = m;
        n -= m*2;
        ans += n/4;
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
 
int d;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26));
 
int get_score(vector<int> t){
    vector<int> cnt(26, 0);
    int ans = 0;
    rep(i, t.size()){
        int l = i + 1 - cnt[t[i]];
        ans -= (l * (l-1) / 2) * c[t[i]];
        ans += s[i][t[i]];
        cnt[t[i]] = i+1;
    }
    rep(i, 26){
        int l = t.size() + 1- cnt[i];
        ans -= (l * (l-1) / 2)* c[i];
    }
    return ans;
}
 
int main() {
    cin >> d;
    rep(i, 26)cin >> c[i];
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------//
    vector<int> t(d);
    rep(i, d){cin >> t[i]; t[i]--;}
    int m;
    cin >> m;
    rep(i, m){
        int D, q;
        cin >> D >> q;
        t[D-1] = q-1;
        cout << get_score(t) << endl;
    }
}


Measured memory_bytes: 3640
#pragma GCC optimize "03"
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

vector<int> a[27];

signed main() {
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);	
	#endif
	IOS;
	string s, t;
	cin >> s >> t;
	for(int i = 0; i < s.length(); i++)
		a[s[i]-'a'].push_back(i+1);
	int cur = 0, ans = 0;
	for(int i = 0; i < t.length(); i++){
		int tx = t[i] - 'a';
		if(a[tx].empty())
			return cout << -1, 0;
		int x = upper_bound(a[tx].begin(), a[tx].end(), cur) - a[tx].begin();
		if(x != a[tx].size()){
			ans += (a[tx][x] - cur);
			cur = a[tx][x];
		}
		else{
			x = upper_bound(a[tx].begin(), a[tx].end(), 0) - a[tx].begin();
			ans += ((int)s.length() - cur + a[tx][x]);
			cur = a[tx][x];
		}
	}	
	cout << ans;
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
void solve(){
	ll n, ans=0;
	cin>>n;
	rep(i,1,n+1){
		rep(j,1,n+1){
			rep(k,1,n+1){
				ans+=__gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3648