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

int main () {
  
  string S;
  long long K;
  cin >> S >> K;
  
  long long N = S.size();
  
  // Sの文字が一種類のとき
  
  int flag = 0;
  for (long long i = 0; i < N - 1; i++) {
    if (S[i] != S[i + 1]) {
      flag = 1;
      break;
    }
  }
  
  
  if (flag == 0) {
    cout << N * K / 2 << endl;
    return 0;
  }
  
  // 2種類以上
  
  long long count = 1;
  
  vector<long long> vec(100, 0);
  
  for (long long i = 0; i < N - 1; i++) {
    
    if (S[i] == S[i + 1]) {
      count++;
    }
    
    else {
      vec[count]++;
      count = 1;
    }
    
  }
  
  vec[count]++;
  
  // Sの両端が異なる文字
  
  if (S[0] != S[N - 1]) {
    
    long long ans = 0;
    for (long long i = 0; i < 100; i++) {
      ans += (i / 2) * vec[i];
    }
    
    cout << ans * K << endl;
    return 0;
    
  }
  
  // Sの両端が同じ文字
  
  else {
    
    long long front = 1;
    long long back = 1;
    
    for (long long i = 0; ; i++) {
      if (S[i] == S[i + 1]) front ++;
      else break;
    }
    
    for (long long i = N - 1; ; i--) {
      if (S[i] == S[i - 1]) back++;
      else break;
    }
    
    vec[front]--;
    vec[back]--;
    
    long long ans = 0;
    for (long long i = 0; i < 100; i++) {
      ans += (i / 2) * vec[i];
    }
    
    cout << ans * K + front / 2 + back / 2 + (front + back) / 2 * (K - 1) << endl;
    return 0;
    
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

int main() {
	int N, M;
	cin >> N;
	vector<int> T(N);
	for (int i = 0; i < N; i++)
		cin >> T[i];
	cin >> M;
	vector<int> P(M), X(M);
	for (int i = 0; i < M; i++)
		cin >> P[i] >> X[i];
	long long sum = accumulate(T.begin(), T.end(), 0LL);
	for (int i = 0; i < M; i++)
		cout << sum - T[P[i] - 1] + X[i] << endl;
}

Measured memory_bytes: 256
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	defer out.Flush()

	h := nextInt()
	nextInt()

	for i := int64(0); i < h; i++ {
		s := next()
		fmt.Fprintln(out, s)
		fmt.Fprintln(out, s)
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 1784
import sys
sys.setrecursionlimit(10**5)
v = 100005
visited = [False]*(2*v)
count = [0, 0]

def dfs(a):
    visited[a] = True
    count[a//v] += 1
    for i in vertex[a]:
        if not visited[i]:
            dfs(i)

input = sys.stdin.readline
N = int(input())
vertex = [[] for _ in range(v*2)]
for _ in range(N):
    x, y=map(int, input().split())
    y += v
    vertex[x].append(y)
    vertex[y].append(x)

ans = 0
for i in range(v):
    if not visited[i]:
        count = [0, 0]
        dfs(i)
        ans += count[0]*count[1]

print(ans-N)

Measured memory_bytes: 85040
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    int d=b-a;
    int da=n-a,db=b-1;
    int res=inf;
    if(d%2==0){
        cout<<d/2<<endl;
        return 0;
    }
    int t=0;
    int x=a,y=b;
    t+=x-1;
    x=1;
    y-=t;
    t+=(y-x+1)/2;
    res=min(res,t);
    t=0;
    x=a,y=b;
    t+=n-b;
    y=n;
    x+=t;
    t+=(y-x+1)/2;
    res=min(res,t);
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    ll n;
    vector<ll> a(5);
    cin >> n;
    ll tmp = 1000000000000005;
    rep(i,5){
        cin >> a[i];
        tmp = min(a[i], tmp);
    }
    cout << 5 + (n-1) / tmp << endl;
}

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

struct MyElem {
  int val;
  MyElem *next;
  MyElem *prev;

  MyElem(int val) : val(val), next(NULL), prev(NULL) {}
};

class MyList {
  public:
    MyList() : head(NULL), tail(NULL) {}

    ~MyList() {
      MyElem *e = head;
      while (e) {
        MyElem *n = e->next;
        delete e;
        e = n;
      }
    }

    void myInsert(int x) {
      MyElem *n = new MyElem(x);
      if (head) {
        head->prev = n;
      }
      n->next = head;
      head = n;
      if (!tail) {
        tail = n;
      }
    }

    void myDelete(int x) {
      MyElem *e = head;
      while (e) {
        if (e->val == x) {
          erase(e);
          break;
        }
        e = e->next;
      }
    }

    void myDeleteFirst() {
      if (head) {
        erase(head);
      }
    }

    void myDeleteLast() {
      if (tail) {
        erase(tail);
      }
    }

    void myPrint() {
      MyElem *e = head;
      while (e) {
        if (e == head) {
          cout << e->val;
        } else {
          cout << " " << e->val;
        }
        e = e->next;
      }
      cout << endl;
    }

  private:
    MyElem *head;
    MyElem *tail;

    void erase(MyElem *e) {
      if (e->prev == NULL) {
        head = e->next;
      } else {
        e->prev->next = e->next;
      }
      if (e->next == NULL) {
        tail = e->prev;
      } else {
        e->next->prev = e->prev;
      }
      delete e;
    }
};

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

  MyList l;
  for (int i = 0; i < N; ++i) {
    string c;
    cin >> c;
    if (c == "insert") {
      int x;
      cin >> x;
      l.myInsert(x);
    } else if (c == "delete") {
      int x;
      cin >> x;
      l.myDelete(x);
    } else if (c == "deleteFirst") {
      l.myDeleteFirst();
    } else if (c == "deleteLast") {
      l.myDeleteLast();
    }
  }
  l.myPrint();
  return 0;
}



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

int main() {
  int n = 0;
  cin >> n;
  vector<int> v(n, 0);
  vector<int> c(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for(int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  int sum = 0;
  for(int i = 0; i < n; ++i) {
    int earn = v[i] - c[i];
    if(earn <= 0) {
      continue;
    }
    sum += earn;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#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 {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	set<int>s;
	int n;
	cin >> n;
	for (int i = 2; i < LIMIT; i++) {
		s.insert(n);
		if (n % 2 == 0) {
			n /= 2;
		}
		else {
			n = 3 * n + 1;
		}
		if (s.count(n) != 0) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


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

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, m = 0, kiroku = 0, sum = 0, MASK = 0;
ll A[500000][3] = {}, B[500000] = {}, dp[200000][3] = {}, rui[500000] = {}, dpi[1 << 12] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = true, check2 = false;

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;
}

int main() {
	//Code Line
	cin >> n;
	for (int i = 0; i < n; i++)for (int j = 0; j < 3; j++)cin >> A[i][j];

	for (int i = 0; i < n; i++) {
		dp[i + 1][1] = max(dp[i][2] + A[i][1], dp[i][0] + A[i][1]);
		dp[i + 1][2] = max(dp[i][1] + A[i][2], dp[i][0] + A[i][2]);
		dp[i + 1][0] = max(dp[i][1] + A[i][0], dp[i][2] + A[i][0]);

	}

	cout << max({ dp[n][0], dp[n][1], dp[n][2], }) << endl;
	return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <cstdio>

bool search(const int array[], const int size, const int key)
{
    bool flag = false;
    int left = 0;
    int right = size;
    int mid;
    while(left < right)
    {
        mid = (left + right) / 2;
        if(array[mid] == key)
        {
            flag = true;
            break;
        }
        else if(key < array[mid])
            right = mid;
        else
            left = mid + 1;
    }
    return flag;
}

int main()
{
    int n;
    scanf("%d", &n);
    int S[n];
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &S[i]);
    }

    int q;
    scanf("%d", &q);
    int counter = 0;
    int key;
    for(int i = 0; i < q; i++)
    {
        scanf("%d", &key);
        if(search(S, n, key))
            counter++;
    }

    printf("%d\n", counter);
}


Measured memory_bytes: 3484
lis = []
dic = {}

N = int(input())
maxi = 0

for i in range(N):

    S = input()

    if S not in dic:
        lis.append(S)
        dic[S] = 1
    else:
        dic[S] += 1

    maxi = max(maxi , dic[S])

lis.sort()

ans = []

for i in lis:
    if dic[i] == maxi:
        ans.append(i)


print ("\n".join(ans))


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

signed main(){
    int X,Y,Z,K;
    cin >>X >>Y >>Z >>K;
    vector<int> A(X),B(Y),C(Z);
    for(auto&& a:A)cin>>a;
    for(auto&& b:B)cin>>b;
    for(auto&& c:C)cin>>c;

    sort(A.rbegin(),A.rend());
    sort(B.rbegin(),B.rend());
    sort(C.rbegin(),C.rend());
    vector<int> u;

    // for(int a:A)cout<<a<<endl;
    // for(int b:B)cout<<b<<endl;
    // for(int c:C)cout<<c<<endl;
    

    for(int a=0;a<X;a++){
        for(int b=0;b<Y;b++){
         //   if((a+1)*(b+1)>K)break;
            for(int c=0;c<Z;c++){
                if((a+1)*(b+1)*(c+1)>K)break;
                u.push_back(A[a]+B[b]+C[c]);
            }
        }
    }
    sort(u.rbegin(),u.rend());

    for(int i=0;i<K;i++)cout<<u[i]<<endl;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << min((int)b / a, c) << "\n";
  return 0;
}


Measured memory_bytes: 256
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

S = input()
a = 0
c = S.count("C")
ql = 0
qr = S.count("?")
ans = 0
mod = 10**9 + 7
ql3 = 1
qr3 = 1
for i in range(qr):
    qr3 *= 3
    qr3 %= mod
for s in S:
    if s == "C":
        c -= 1
    elif s == "?":
        qr -= 1
        qr3 *= modinv(3, mod)
        qr3 %= mod

    if s == "B" or s == "?":
        ans += ((ql * ql3 * modinv(3, mod) + a * ql3) % mod) * ((qr * qr3 * modinv(3, mod) + c * qr3) % mod)
        ans %= mod

    if s == "A":
        a += 1
    elif s == "?":
        ql += 1
        ql3 *= 3
        ql3 %= mod

print(ans)


Measured memory_bytes: 3316
def main():
    from math import gcd
    _ = int(input())
    A = [int(i) for i in input().split()]
    maxA = max(A)

    def Eratosthenes(sup: int) -> set:
        primes = [True]*(sup+1)
        primes[0] = False
        primes[1] = False
        for i in range(2, sup+1):
            if primes[i]:
                MINFact[i] = i
                mul = 2
                while i*mul <= sup:
                    primes[i*mul] = False
                    if MINFact[i*mul] == -1:
                        MINFact[i*mul] = i
                    mul += 1

    def prime_factor(n):
        while n != 1:
            prime = MINFact[n]
            while MINFact[n] == prime:
                n //= prime
            B[prime] += 1

    MINFact = [-1] * (maxA + 1)
    MINFact[0] = 0
    MINFact[1] = 1
    Eratosthenes(maxA)

    g = A[0]
    for a in A:
        g = gcd(g, a)

    B = [0]*(maxA+1)
    for a in A:
        prime_factor(a)

    if g != 1:
        print("not coprime")
    elif max(B) <= 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")


if __name__ == '__main__':
    main()


Measured memory_bytes: 212892
#include<iostream>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main(void)
{
string s;
cin >> s;
 
sort(s.begin(), s.end());
 
if (s[0] == s[1])
{
	if (s[2] == s[3] && s[1] != s[2])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}
  else
  {
    cout << "No";
  }
  
  return 0;
}

Measured memory_bytes: 256
from collections import deque

K = int(input())

def calculate(n):
    q = deque()
    for i in range(1, 10):
        q.append(i)

    result = []

    while len(result) <= n:
        x = q.popleft()
        result.append(x)
        m = x % 10
        if m == 0:
            q.append(x * 10 + m)
            q.append(x*10+ m +1)
        elif m == 9:
            q.append(x*10 + m - 1)
            q.append(x * 10 + m)
        else:
            q.append(x*10 + m - 1)
            q.append(x * 10 + m)
            q.append(x*10 + m + 1)

    print(result[n-1])


calculate(K)


Measured memory_bytes: 16048
#include <bits/stdc++.h>
#include <utility>
using namespace std;
 
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
#define rfor(i, a, b) for(int i = a - 1; i >= b; i--)
 
ll dp[3010][3010];
string s,t;
 
void solve(){ 
    for (int i = 0; i <= s.size(); i++) { 
        for (int j = 0; j <= t.size(); j++){ 
            if (i == 0 || j == 0){
                dp[i][j] = 0; 
            }else if (s[i - 1] == t[j - 1]){
                dp[i][j] =  dp[i - 1][j - 1] + 1;
            }else{
              dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        } 
    }     
    
    string ans = "";
    int i = s.size(),j = t.size();
    while(i >= 1 && j >= 1){
        if(s[i-1] == t[j-1]){
            ans = ans + s[i-1];
            i--;j--;
        }else if(i >= 1 && j > 1 &&dp[i-1][j] < dp[i][j-1]){
            j--;
        }else if(i > 1 && j >= 1 &&dp[i-1][j] >= dp[i][j-1]){
            i--;
        }else if(i == 1 && j > 1){
            j--;
        }else if(j == 1 && i > 1){
            i--;
        }
        if(s[i-1] != t[j-1] && i == 1 && j == 1){
            break;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
} 
int main(){ 
    cin>>s;
    cin>>t;
    solve();
    return 0; 
} 

Measured memory_bytes: 70784
// 4/3/2020 8:00:11 PM
#include <bits/stdc++.h>  
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long    
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"  
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 
using namespace std ; 
// 2020-04-01
// using namespace __gnu_pbds;
// typedef tree<int,null_type,less<int>,
// rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+20;
const int mod = 1e9+7;  
int tests() {  
  int a,b,c ;
  cin >>a  >> b >> c ; 
  swap(a,b);
  swap(a,c);
  cout <<a << ' '  << b << ' ' << c << '\n' ;



  return 0;  
} 
int main(){
    I__O ;            
    int cases = 1 ; 
    // cin >> cases ;  
    for(int  _ = 1 ; _ <= cases ; _++ ){   
    // cout << "Case #" << _ << ": ";
      tests(); 
    }
    return 0 ; 
}

// -Wall -Weptra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 256
#include <stdio.h>

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

	if (data % 1000 == 0) {
		printf("%d\n", 0);
	} else {
		int x;
		x = 1000 - data % 1000;
		printf("%d\n", x);
	}
}

Measured memory_bytes: 1696
#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;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll h;
    cin >> h;
    ll num = 0;
    ll count = 0;
    while (h > 1) {
        num += pow(2, count);
        h /= 2;
        count++;
    }
    num += pow(2, count);
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++){
    cin >> a.at(i);
  }
  int count = 0;
  map<int, int> b;
  for (int x: a){
    b[x] += 1;
    if (x < b[x]){
      count++;
    }
  }
  for (int x: a){
    if ( x > b[x]){
      count += b[x];
      b[x] = 0;
    }
  }
  cout << count << endl;
}

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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  
  int time = 0;
  if (a < 0) {
    time += -a * c;
    a = 0;
  }
  if (a == 0) {
    time += d;
  }
  if (a >= 0) {
    time += (b - a) * e;
  }
  cout << time << endl;
  
  return 0;
  
}



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

namespace practice6
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());
            int K = Int32.Parse(Console.ReadLine());
            int X = Int32.Parse(Console.ReadLine());
            int Y = Int32.Parse(Console.ReadLine());
            int x;
            if (N > K)x = K * X + (N - K) * Y;
            else
                x = N * X;
            Console.WriteLine(x.ToString());
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#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() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

bool check(string s){
  int n = s.length();
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n/2+i]) return false;
  }
  return true;
}

int main(void){

    int n;
    cin >> n;
    cout << ((n+999)/1000)*1000 - n << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
  int x,y,i;
  for(i=0;;i++){
  	scanf("%d %d",&x,&y);
  	if(x == 0 && y == 0){
  		break;
  	}
  	if(y>=x){
  		printf("%d %d\n",x,y);
  	}
  	else{
  		printf("%d %d\n",y,x);
  	}
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.*

fun main(args: Array<String>) {
    val mod = 1000000007L
    val N = readLine()!!.toInt()
    val (T,A) = readLine()!!.split(" ").map { it.toInt() }
    val H = readLine()!!.split(" ").map { it.toInt() }.toList()
//    val N = readLine()!!.toInt()

    var ans = -1
    var min = 1000000.0

    for ((i,h) in H.withIndex()) {
        val tmp = Math.abs(T-h*0.006 - A)
        if (min > tmp) {
            min = tmp
            ans = i
        }
    }

    println(ans+1)
}

Measured memory_bytes: 37872
#!/usr/bin/python3

import sys
import heapq
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

Q = []
for a in A:
    heapq.heappush(Q, -a)

for _ in range(M):
    a = heapq.heappop(Q)
    a = (-a)//2
    heapq.heappush(Q, -a)



print(-sum(Q))


Measured memory_bytes: 14184
#include <iostream>
#include <string>
using namespace std;
int main() {
    string S; cin>>S;
    if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = in.nextInt();
        }

        int[] q = Arrays.copyOf(p, n);

        Arrays.sort(p);

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (p[i] != q[i]) {
                count++;
            }
        }

        if (count <= 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include<cmath>
using namespace std;
int main(){
	int a,b,c,d,ab,bc;
	cin>>a>>b>>c>>d;
	ab=abs(a-b);
	bc=abs(b-c);
	int ac=abs(a-c);
	if(ab<=d&&bc<=d || ac<=d){
		cout<<"Yes";
	}
	else{
		cout<<"No"; 
	} 
} 


Measured memory_bytes: 3616
#include<stdio.h>

#define N 100

void SelectionSort(int[],int);
/*スワップ数*/
int count=0;
int main(){
  int i,n;
  int A[N];
  scanf("%d",&n);
  /*配列格納*/
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  /*SelectionSort*/
  SelectionSort(A,n);
  /*スワップ後の数&とスワップ数表示*/
  for(i=0;i<n-1;i++)
    
  printf("%d ",A[i]);
  
  printf("%d\n",A[n-1]);
 
  printf("%d\n",count);
  return 0;}
/*SelectionSort*/
void SelectionSort(int A[],int n)
{
  int i,j,mini,temp,hit=0;
 
  
  for(i=0;i<n;i++){
    mini=i;
    hit=0;
    for(j=i+1;j<n;j++){
      if(A[j]<A[mini]){
	mini=j;
	hit=1;
      }
      
    }
    temp=A[i];
    A[i]=A[mini];
    A[mini]=temp;
    if(hit==1)
    count++;
  }
  

}



Measured memory_bytes: 2744
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	vector<ll> cnt(4);
	for (int i = 0;i < 3;i++) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		cnt[a]++;
		cnt[b]++;
	}
	bool flag = true;
	for (int i = 0;i < 4;i++)
		if (cnt[i] >= 3)
			flag = false;
	if (flag)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  string s1,s2,t1,t2,u1,u2;
  cin >> s1;
  s2 = s1;
  reverse(s1.begin(),s1.end());
  
  t1 = s2.substr(0,(s2.size()-1)/2);
  t2 = t1;
  reverse(t1.begin(),t1.end());
  
  u1 = s2.substr((s2.size()+3)/2 - 1);
  u2 = u1;
  reverse(u1.begin(),u1.end());

  if(s1 == s2 & t1 == t2 & u1 == u2)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  
  int N, M;
  cin >> N >> M;

  vector<pair<int, int>> P(N);
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    P.at(i) = make_pair(A, B);
  }

  sort(P.begin(), P.end());

  int num = 0;
  long long ans = 0;

  int cnt = 0;
  while (num < M) {
    if(P.at(cnt).second > 0) {
      ans += P.at(cnt).first;
      P.at(cnt).second--;
      num++;
    }
    else cnt++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int result = a;
        if (a == b) {
            result = c;
        } else if (a == c) {
            result = b;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(const pair<int , int> &a, const pair<int , int > &b)
{
    if (a.first != b.first)
    {
        return a.first < b.first;
    }
    else
    {
        return a.second < b.second;
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    vector<pair<int, int> > vec(n);
    int a, b;

    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &a, &b);
        vec[i] = make_pair(a, b);
    }

    sort(vec.begin(), vec.end(), cmp);
    for (int i = 0; i < n; i++)
    {
        printf("%d %d\n", vec[i].first, vec[i].second);
    }

    return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	vi h(n + 1, 0); zip(i, 0, n)  cin >> h[i];
	int ans = 0;

	zip(i, 0, n)
	{
		int j = i;
		int x = inf;

		while (h[j] > 0 && j < n)
		{
			x = min(x, h[j]);
			j++;
		}
		rep(k, i, j - 1)
		{
			if (x != inf)
			{
				h[k] -= x;
			}
		}
		if (x != inf)
		{
			ans += x;
			i = -1;
		}
	}
	cout << ans << en;
	// zip(i, 0, n)
	// {
	// 	zip(j, i, n)
	// 	{
	// 		int x = 1e9;
	// 		int y = 0;
	// 		zip(k, i, j + 1)
	// 		{
	// 			x = min(h[k], x);
	// 			y = max(h[k], y);
	// 		}
	// 		if ((i == 0 || h[i - 1] == 0) && (j == n - 1 || h[j + 1] == 0) && y > 0)
	// 		{
	// 			zip(k, i, j + 1)
	// 			{
	// 				h[k] -= x;
	// 			}
	// 			ans += x;
	// 			i = -1;
	// 			//j = 0;

	// 		}
	// 	}
	// }




	return 0;
}



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

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

  ll K; cin >> K;
  string S; cin >> S;
  if (S.size() <= K) {
    cout << S << '\n';
    return 0;
  }
  for (ll i = 0; i < K; i++) {
    cout << S[i];
  }
  cout << "...";
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl '\n'
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define IT set<node>::iterator
#define mem(a) memset(a,0,sizeof(a))
typedef long long LL;
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
struct node{
    string name;
    ll val;
}a[N];
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i].name >> a[i].val;
    }
    string al;
    cin >> al;
    ll ans = 0;
    int flag = 0;
    for(int i = 1; i <= n; i++){
        if(flag){
            ans += a[i].val;
        }
        if(a[i].name == al){
            flag = 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3456
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;

	for (int i = 0; i < s.size()-1; i++) {
		
		if (s[i] == s[i+1]) {
			cout << "Bad" << endl;
			return 0;
		}
		
	}

	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, n) for(int i = 1; i < n; ++i)

int gcd(int a, int b) {
  while( b ) {
    int t = a % b;
    a = b;
    b = t;
  }
  return a;
}

int main(void) {
  int x, y;
  scanf("%d%d", &x, &y);
  printf("%d\n", gcd(x, y));
  return 0;
}


Measured memory_bytes: 2688
import sys  
input = sys.stdin.readline
 
N, M = list(map(int, input().split()))
 
A = list(map(int, input().split()))
 
 
 
BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])
 
BC=sorted(BC, reverse=True, key=lambda x:x[1])
 
cnt = 0
com = []
for b, c in BC:
    cnt += b
    if cnt > N:
        add = N-cnt+b
        com.extend([c]*add)
        break
    else:
        x = [c]*b 
        com.extend(x)
 
A.extend(com)
A = sorted(A, reverse=True)   
 
print(sum(A[:N]))

Measured memory_bytes: 29848
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(void) {
  int n, r;
  cin >> n >> r;

  if(n<10){
    cout << r+(100*(10-n)) << endl;
  }
  else {
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,a[100],result=0;

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n-1;i++) for(int j=n-2;j!=i-1;j--) if(a[j]>a[j+1]){
	swap(a[j],a[j+1]);
	result++;
      }
  for(int i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl<<result<<endl;

  return 0;
  
}



Measured memory_bytes: 3096
N = gets.to_i
xys = N.times.map { gets.split.map(&:to_i) }

def dfs(cand, pos)
  return 0 if cand.empty?
  sum = 0.to_f
  x1, y1 = pos
  cand.each do |pos2|
    tmp = cand.dup
    tmp.delete(pos2)
    x2, y2 = pos2
    d = Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    sum += d * (1..([cand.size - 1, 1].max)).reduce(:*)
    sum += dfs(tmp, pos2)
  end
  sum
end

sum = 0.to_f
xys.each do |pos|
  tmp = xys.dup
  tmp.delete(pos)
  sum += dfs(tmp, pos)
end
ans = sum / (1..N).reduce(:*)
puts ans


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

#define rep(i,n) for(int i=0;i<n;i++)
#define all(v,a,b) v.begin(a),v.end(b)
#define in cin>>
#define out cout<<
#define end <<endl
#define INF 100000000000

int main()
{
	int N;
	in N;
	vector<vector<int>> abc(N,vector<int>(3));
	rep(i, N) 
	{
		in abc.at(i).at(0) >> abc.at(i).at(1) >> abc.at(i).at(2);
	}
	vector<vector<int>> ans(N + 1, vector<int>(3));
	rep(i, N)
	{
		rep(j, 3)
		{
			rep(x, 3)
			{
				if (j == x)
				{
					continue;
				}
				ans.at(i + 1).at(x) = max(ans.at(i).at(j) + abc.at(i).at(x), ans.at(i + 1).at(x));
			}
		}
	}
	int l = 0;
	rep(i, 3)
	{
		l = max(l, ans.at(N).at(i));
	}
	out l end;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int a,b,a2,b2;
  cin>>a>>b>>a2>>b2;
  cout<<a2-b2+b<<" "<<b2-a+a2<<' '<<a-b2+b<<" "<<b-a+a2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
const int SIZE=5+1e6;
const int INF=10+1e9;
const LL p=7+1e9;
bool A[SIZE];
bool ans[SIZE];
LL N;
bool dx[]={0,0,1,1},dy[]={0,1,0,1};
bool issure(bool x[SIZE]){
	REP(i,N){
		if(x[i] == A[i]) if(x[(i+1)%N]!=x[(i-1+N)%N]) return false;
		if(x[i] != A[i]) if(x[(i+1)%N]==x[(i-1+N)%N]) return false;
	}
	return true;
}
int main(){
	cin >> N;
	string s;
	cin >> s;
	REP(i,N){
		A[i]=s[i]=='o';
	}
	bool answer=false;
	REP(i,4){
		ans[0]=dx[i];
		ans[1]=dy[i];
		FOR(j,2,N){
			if(ans[j-1] == A[j-1]) ans[j]=ans[j-2];
			else ans[j]=!ans[j-2];
		}
		if(issure(ans)){
			REP(j,N)
				cout << (ans[j]?'S':'W');
			cout << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
        	
            if(H == 0 && W == 0)break;

            for(int i = 1; i <= H; i++){
                if(i % 2 != 0){
                    for(int j = 1; j <= W; j++){
                        if(j % 2 != 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }
                }else{
                    for(int j = 1; j <= W; j++){
                        if(j % 2 != 0){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}



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

int main()
{
    int maxLen = 0, strCount = 0;
    std::string s;
    
    std::cin >> s;

    for (int i = 0; i < s.size(); i++) {
        switch(s[i]) {
            case 'A':
            case 'T':
            case 'G':
            case 'C':
                strCount++;
                maxLen = std::max(maxLen, strCount);
                break;
            default:
                maxLen = std::max(maxLen, strCount);
                strCount = 0;
        }
    }
    std::cout << maxLen << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    for(int i=1; i<=5; i++){
      int x; cin >> x;
      if(x==0) {
        cout << i << endl;
        break;
      }
    }
  
    return 0;
}

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

int main(){
	int n,i;
	double x1,x2,x3,y1,y2,y3,a1,b1,c1,a2,b2,c2,x,y,r;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
	scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
	a1=2*(x2-x1);
	b1=2*(y2-y1);
	c1=x1*x1-x2*x2+y1*y1-y2*y2;
	a2=2*(x3-x1);
	b2=2*(y3-y1);
	c2=x1*x1-x3*x3+y1*y1-y3*y3;
	x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
	y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
	r=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
	printf("%.3lf %.3lf %.3lf\n",x,y,r);
	}
	
	return 0;
}

Measured memory_bytes: 656
import math

n, m = map(int, input().split())
if abs(n-m) > 1:
	print(0)
	exit()
s = 2 if n == m else 1
np = math.factorial(n)
mp = math.factorial(m)
r = (mp*np*s) % (10**9 + 7)
print(r)

Measured memory_bytes: 55152
#define _GCLIBCXX_DEBUG
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>

typedef long long ll;

ll dp[2*100000+7];

int main(int argc, char* argv[])
{
  ll n;
  std::cin >> n;
  std::vector< ll > va(n, 0);

  ll sum = 0;
  for (ll i = 0; i < n; i++) {
    std::cin >> va[i];
    sum += va[i];
  }

  ll ans = 1e10;
  dp[0] = 0;
  for (ll i = 0; i < n-1; i++) {
    dp[i+1] = va[i] + dp[i];
    ans = std::min(ans, (ll)std::fabs(sum - dp[i+1] * 2));
    //std::cout << ans << " " << sum << " " << dp[i+1] << std::endl;
  }

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


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  vector<int>P(N);
  map<int,int>k;
  k[0]=0,k[1]=0,k[2]=0;
  for(int i=0;i<N;i++){
    cin>>P[i];
    if(P[i]<=A){k[0]++;}
    else if(P[i]>A&&P[i]<=B){k[1]++;}
    else{k[2]++;}
  }
  int MIN=999;
  for(auto c:k){
    MIN=min(MIN,c.second);
  }
  cout<<MIN<<endl;
  return 0;
}

Measured memory_bytes: 3536
// https://atcoder.jp/contests/abc110/tasks/abc110_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> v;
    REP(i, 3) {
        int t;
        cin >> t;
        v.push_back(t);
    }
    sort(ALLR(v));
    cout << v[0] * 10 + v[1] + v[2] << endl;

    return 0;
}


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

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;
		int m[][] = new int[12][12];
		int d[][] = new int[12][12];
		for (int i=0;i<12;i++) Arrays.fill(d[i],0);
		int count = 1;

		try {
			while (true) {
				for (int i=0;i<12;i++) {
					buf = br.readLine();
					for (int j=0;j<12;j++) m[i][j] = Character.getNumericValue(buf.charAt(j));
				}
				for (int i=0;i<12;i++) {
					for (int j=0;j<12;j++) {
						int check = Existed(d,j,i);
						if (m[i][j]==1) {
							if (check==-1) {
								d[i][j] = count;
								count += 1;
							} else if (m[i][j]==1) {
								if (i>0&&j>0&&d[i-1][j]>0&&d[i][j-1]>d[i-1][j]) {
									for (int k=j-1;k>=0&&d[i][k]>d[i-1][j];k--) {
										if (d[i][k]==0) break;
										d[i][k] = d[i-1][j];
									}
									d[i][j] = d[i-1][j];
									count -= 1;
								} else  {
									d[i][j] = check;
								}
							}
						}
					}
				}
				System.out.println(count-1);
				count = 1;
				for (int i=0;i<12;i++) Arrays.fill(d[i],0);
				if (br.readLine()==null) break;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static int Existed(int[][] m,int x,int y) {
		if (x>0&&m[y][x-1]>0) return m[y][x-1];
		else if (x<11&&m[y][x+1]>0) return m[y][x+1];
		else if (y>0&&m[y-1][x]>0) return m[y-1][x];
		else if (y<11&&m[y+1][x]>0) return m[y+1][x];
		else return -1; 
	}
}

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

long long c = 0;

void merge(int A[], int left, int mid, int right) {
  int i,j,k;

  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1];
  int R[n2];

  for (i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }

  for (i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = 1000000001;
  R[n2] = 1000000001;

  i = 0;
  j = 0;
  for (k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
      c += n1 - i;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  int i = 0;
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

  int n;
  int A[200000];

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  mergeSort(A, 0, n);

  cout << c <<endl;

  return 0;
}

Measured memory_bytes: 4640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string a[] = {"Sunny", "Cloudy", "Rainy"};

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	int p = 0;
	while(a[p] != s) p++;
	p++;
	p %= 3;
	cout << a[p] << endl;

	return 0;
}


Measured memory_bytes: 256