akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}

 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r;
ll k,ans;
ll x[500005],y[500005],z[500005];
char s[500005];
bool dp[500005];



int main(){
    cin >> n >> s;
    if(n >= 3200){
        p(s);
    }else{
        p("red");
    }
    return 0;
}






Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <set>

using namespace std;

int main()
{
	int n, c, k; cin >> n >> c >> k;
	vector<int> v(n);

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

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

	int cnt = 1;
	int fr = v[0];
	int res = 0;
	for(int i=1; i<v.size(); i++)
	{
		if(cnt == c || v[i] - fr > k)
		{
			cnt = 0;
			res++;
			fr = v[i];
		}

		cnt++;
	}

	if(cnt > 0) res++;
	cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n;
ll a[200010];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	ll index=n-1;
	rep(i,0,n){
		printf("%lld ",a[index]);
		if(index%2!=n%2)index-=2;
		else index+=2;
		if(index<0)index=n%2;
	}
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

template <typename T>
class segmenttree
{
private:
    int n;

public:
    using F = function<T(T, T)>;

    T dif;
    F f;
    vector<T> st;

    segmenttree(int size, T init, F f) : f(f)
    {
        n = 1;

        while (n < size)
        {
            n *= 2;
        }

        st.assign(2 * n - 1, init);
    }

    void set(int i, T x)
    {
        st[i + n - 1] = x;
    }

    void build()
    {
        for (int i = n - 2; i >= 0; i--)
        {
            st[i] = f(st[i * 2 + 1], st[i * 2 + 2]);
        }
    }

    void update(int i, T x)
    {
        i += n - 1;
        st[i] = x;

        while (i > 0)
        {
            i = (i - 1) / 2;
            st[i] = f(st[2 * i + 1], st[2 * i + 2]);
        }
    }

    T query(int a, int b)
    {
        return query_(a, b, 0, 0, n);
    }

    T query_(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
        {
            return dif;
        }

        if (a <= l && r <= b)
        {
            return st[k];
        }
        else
        {
            T x = query_(a, b, 2 * k + 1, l, (l + r) / 2);
            T y = query_(a, b, 2 * k + 2, (l + r) / 2, r);

            return f(x, y);
        }
    }
};

//初期化例 segmenttree<bitset<26>> seg(n, 0, [](bitset<26> a, bitset<26> b) { return a | b; });

int main(void)
{
    int n, q;
    ll x, y;
    int i;
    vector<ll> a, ans;

    cin >> n >> q;

    a.resize(n);

    segmenttree<ll> seg(n, (1ll << 31) - 1, [](ll a, ll b) { return min(a, b); });

    seg.dif = (1ll << 31) - 1;

    for (i = 0; i < q; i++)
    {
        int c;
        cin >> c >> x >> y;

        if (c == 0)
        {
            seg.update(x, y);
        }
        else
        {
            y++;
            ans.push_back(seg.query(x, y));
        }
    }

    for (auto k : ans)
    {
        cout << k << endl;
    }
}


Measured memory_bytes: 6252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;} return 0;};

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    int x = h[k-1] - h[0];
    for (int i = 1; i <= n-k; i++) {
        chmin(x,h[k-1+i]-h[i]);
    }
    cout << x << endl;
}

Measured memory_bytes: 640
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map[T](converter)
  }

  implicit val idConverter: String => String = s => s
  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def primes(n: Long): ArrayBuffer[Long] = {
    val buf = ArrayBuffer.empty[Long]

    var v = n
    for (i <- 2 to Math.sqrt(n).toInt) {
      if (v == 1 || v == 0) {
        return buf
      } else {
        while (v % i == 0) {
          buf.append(i)
          v /= i
        }
      }
    }
    if (v > Math.sqrt(n).toInt) {
      buf.append(v)
    }
    buf
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = get[Long]

    val primeMap = mutable.HashMap.empty[Long, Int]
    for (p <- primes(n)) {
      val c = primeMap.getOrElse(p, 0)
      primeMap.update(p, c + 1)
    }

    var count = 0L
    for ((p, c) <- primeMap) {
      count += Math.floor((Math.sqrt(8 * c + 1) - 1) / 2).toLong
    }

    out.println(count)
    out.flush()
  }
}

Measured memory_bytes: 57420
import fractions
n=int(input())
a=list(map(int,input().split()))
l=[a[0]]
r=[a[-1]]
for i in range(n-1):
  l.append(fractions.gcd(l[i],a[i+1])) #l[i] は最初i個
for i in range(n-1):
  r.append(fractions.gcd(r[i],a[-2-i])) #r[i]は右i r[n-1]=全部 l[0]and r[n-3]
m=[l[n-2],r[n-2]]
for i in range(n-2):
  m.append(fractions.gcd(l[i],r[n-i-3]))
print(max(m))

Measured memory_bytes: 95968
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#include <functional>
#include<map>
#include<stack>
#define T long long

int n,m,x;
int c[12];
int a[12][12];
int understood[12]={0};
int cost = 0;
int search(int depth){
	if(depth == n){
		for(int i=0;i<m;i++){
			if(understood[i]<x){
				return 1e8;
			}
		}
		return cost;
	}
	int score = search(depth + 1);
	cost += c[depth];
	for(int i=0;i<m;i++){
		understood[i]+=a[depth][i];
	}
	int tmp = search(depth + 1);
	if(score > tmp){
		score = tmp;
	}
	cost -= c[depth];
	for(int i=0;i<m;i++){
		understood[i]-=a[depth][i];
	}
	return score;
}

int main(){
	std::cin >> n>>m>>x;

	for(int i=0;i<n;i++){
		std::cin >>c[i];
		for(int j=0;j<m;j++){
			std::cin >>a[i][j];
		}
	}
	int s = search(0);
	if(s<1e8){
		std::cout <<s << std::endl;
	}else{
		std::cout <<-1<< std::endl;
	}

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> gr(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    gr.at(a).push_back(b);
    gr.at(b).push_back(a);
  }
  vector<int> team(n, -1);
  int co = 0;
  while(co < n){
    int nx = -1;
    rep(i, n){
      if(team.at(i) == -1){
        nx = i;
        team.at(nx) = nx;
        co++;
        break;
      }
    }
    queue<int> q;
    q.push(nx);
    while(!q.empty()){
      auto now = q.front(); q.pop();
      for(auto i : gr.at(now)){
        if(team.at(i) != -1) continue;
        team.at(i) = nx;
        co++;
        q.push(i);
      }
    }
  }

  int q;
  cin >> q;
  rep(_, q){
    int a, b;
    cin >> a >> b;
    if(team.at(a) == team.at(b)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}


Measured memory_bytes: 8532
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string str;
	cin>>str;
	int mmax=0;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(str[i]=='I')
		{
			ans++;
		}
		else
		{
			ans--;
		}
		mmax=max(mmax,ans);
	}
	cout<<mmax<<endl;
	return 0;
} 

Measured memory_bytes: 256
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
al=[]
bo=[]
a=sorted(a)
a=a[::-1]
for i in range(n):
 if i%2==0:
  al.append(a[i])
 else:
  bo.append(a[i])
print(sum(al)-sum(bo))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;
const ll INFLL = 1e18l+5;
const int mod = 1e9+7;

void self_max(int &a, int b){
    a+=b;
    
}

int main(){
    int n; cin>>n;
    vector<double> dp(n+1);
    dp[0]=1; //probability that there are zero heads.

    for(int coin=0; coin<n; ++coin){
        double ph; cin>>ph;
        for(int i=coin+1; i>=0; --i){
            dp[i]=(i==0 ? 0 : dp[i-1]*ph)+dp[i]*(1-ph);
        }
    }
    double ans=0;
    for(int i=0; i<=n; i++){
        if(i>n-i) ans+=dp[i]; 
    }

    printf("%.10lf", ans);
}

Measured memory_bytes: 3784
N, W = map(int, input().split())
wv = [[0, 0]]
for _ in range(N):
    w, v = map(int, input().split())
    wv.append([w, v])

# dp[i][j]=(i番目までのアイテムを、重さがj以下になるように選んだときの価値の最大値)
dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(0, W + 1):
        # i番目のアイテムを入れることができる場合
        if j - wv[i][0] >= 0:
            # 実際にアイテムを入れる場合、入れない場合
            dp[i][j] = max(dp[i - 1][j - wv[i][0]] + wv[i][1], dp[i - 1][j])
        # i番目のアイテムを入れることができない場合
        else:
            dp[i][j] = dp[i - 1][j]

# print(dp)
print(max(dp[-1]))


Measured memory_bytes: 172888
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n, x;
    cin >> n >> x;
    vector<ll> a;
    a.push_back(x);
    for(ll i = 0; i < n; i++){
        ll b;
        cin >> b;
        a.push_back(b);
    }
    vector<ll> d;
    sort(a.begin(), a.end());
    for(ll i = 0; i < a.size()-1; i++){
        ll b = abs(a[i]-a[i+1]);
        d.push_back(b);
    }
    ll ans = d[0];
    for(ll i = 1; i < d.size(); i++){
        ans = __gcd(ans, d[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

int N;
char S[400000];
int C[400000];
int C1[400000];
int C2[400000];

int main(int argc, char** argv) {
    cin >> N >> S;
    for (int i = 2; i <= N; i++) {
        C1[i] = C1[i - 1];
        if (S[i - 2] == 'W') C1[i] += 1;
    }
    for (int i = N - 1; 0 <= i; i--) {
        C2[i] = C2[i + 1];
        if (S[i] == 'E') C2[i] += 1;
    }
    int ans = 1e9;
    for (int i = 1; i <= N; i++) {
        ans = min(ans, C1[i] + C2[i]);
    }
    cout << ans << endl;;
}

Measured memory_bytes: 4224
# これは, u749194f さんの改造です。
# オリジナルではございません。
# https://atcoder.jp/contests/abc162/submissions/11825963
n = int(input())
s = input()
flag = True
if len(set(s))<=2:
    print(0)
    flag = False
if flag:
    r = [i+1 for i in range(n) if s[i]=='R']
    b = [i+1 for i in range(n) if s[i]=='B']
    g = [i+1 for i in range(n) if s[i]=='G']
    minus = 0
    def cnt_cmb(a, b, c):
        cnt = 0
        set_c = set(c)
        for i in a:
            for j in b:
                if (i+j)/2 in set_c:
                    cnt += 1
        return cnt
    minus += cnt_cmb(r, b, g)
    minus += cnt_cmb(b, g, r)
    minus += cnt_cmb(g, r, b)
    print(len(r)*len(b)*len(g)-minus)

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

d1 = [0]*n
d2 = [0]*n

for i in range(n):
  d1[i], d2[i] = map(int, input().split())
  
for i in range(n-2):
  if d1[i] == d2[i]:
    if d1[i+1] == d2[i+1]:
      if d1[i+2] == d2[i+2]:
        print('Yes')
        exit(0)
        
print('No')

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110


signed main()
{
    int X;
    cin >> X;
    vector<int> cand;
    for(int i = 1; i <= 1000; ++i) {
        int base = i;
        for(int j = 0; j < 1000; ++j) {
            base *= i;
            if(base > 1000) { break; }
            cand.push_back(base);
        }
    }
    SORT(cand);
    for(int i = cand.size()-1; i >= 0; --i) {
        if(X >= cand[i]) {
            printf("%lld\n", cand[i]);
            return 0;
        }
    }
    printf("1\n");
    return 0;
}


Measured memory_bytes: 256
import sys
import queue
input = sys.stdin.readline
N, Q = map(int, input().split())

tree = [[] for i in range(N+1)]
values = [0] * (N+1)
visit = [False]*(N+1)
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    values[p] += x


q = [1]
visit[1] = True
while q:
    now = q.pop()
    for next in tree[now]:
        if not visit[next]:
            values[next] += values[now]
            visit[next] = True
            q.append(next)

print(" ".join(map(str, values[1:])))


Measured memory_bytes: 121928
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	ans := 1000000000
	for i := 0; i < n; i++ {
		a := readInt()
		cnt := 0
		for a > 0 {
			if a%2 == 1 {
				break
			}
			a /= 2
			cnt++
		}
		ans = min(ans, cnt)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		if(str.length() == 2) {
			System.out.println(str);
		}else {
			System.out.print(str.charAt(2));
			System.out.print(str.charAt(1));
			System.out.println(str.charAt(0));
			}
		
		sc.close();
	}

}


Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  ll X,Y; cin >> X >> Y;
  ll cnt = 1;
  ll power = 2;
  while(1) {
    if ( X*power <= Y ) {
      cnt++;
      power *= 2;
    }
    if ( X*power >Y ) break;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		char[] a = sc.next().toCharArray();
	//	Arrays.sort(a);
		int[] n = new int[3];
		for(int i = 0; i < a.length; i++) {
			if(a[i] == 'a') n[0]++;
			else if(a[i] == 'b') n[1]++;
			else n[2]++;
		}
		Arrays.sort(n);
		if(n[0] == 0 && (n[1] > 1 || n[2] > 1)) {
			System.out.println("NO");
		}else if(n[0] == 0 && n[1] == 0 && n[2] > 1){
			System.out.println("NO");
		}else if(n[0] == 0 && n[1] == 0 && n[2] == 1) {
			System.out.println("YES");
		}else if(n[2] - n[0] <= 1 && n[1] - n[0] <= 1) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

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

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


Measured memory_bytes: 35184
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 10010020030040056ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n - 1) / x + 1) * t << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;


signed main(){
    int N,M,Q;
    int L[214514],R[214514];
    int p[114514],q[114514];
    int D[501][501]={};
    cin >> N >> M >> Q;
    REP(i,M){
        cin >> L[i] >> R[i];;
    }
    REP(i,Q){
        cin >> p[i] >> q[i];p[i]--;
    }
    
    REP(i,M){
        D[L[i]][R[i]]++;
    }
    
    
    OREP(i,N){
        OREP(j,N){
            D[i][j]+=D[i][j-1];
            D[i][j]+=D[i-1][j];
            D[i][j]-=D[i-1][j-1];
        }
    }
    /*
    OREP(i,N){
        OREP(j,N){
            cout << D[i][j] << " ";
        }cout << endl;
    }cout << endl;*/
    
    REP(i,Q){
        cout << D[q[i]][q[i]]-D[p[i]][q[i]]-D[q[i]][p[i]]+D[p[i]][p[i]] << endl;
    }
    
    return 0;
}   


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

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int ans = 0;

    for(int i = 1; i <= N; i++) {
        ans += N/i - 1;
        if(N%i) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<next<int>()*next<int>()<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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


#define M 1000000007
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod 998244353
#define sz(v) (int)(v).size()

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

ll add(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a+b)%M;
	return (p+M)%M;
}

ll mul(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a*b)%M;
	return (p+M)%M;
}

vector<ll> lis1[200010],lis2[200010];

int main()
{
	fastio;
	ll t,l[200010],r[200010];
	
	cin>>t;
	while(t--)
	{
		ll i,j,n,ans=0;
		cin>>n;
		for(i=1;i<=n+1;i++)
		{
			lis1[i].clear();
			lis2[i].clear();
		}
		for(i=1;i<=n;i++)
		{
			ll k;
			cin>>k>>l[i]>>r[i];
			if(r[i]>l[i])
				lis1[k+1].pb(i);
			else if(l[i]>r[i])
				lis2[k].pb(i);
			ans += max(l[i],r[i]);
		}
		// cout<<ans<<endl;
		set<pair<ll,ll> > se;
		for(i=n+1;i>0;i--)
		{
			ll empty = n+1-i;
			for(j=0;j<sz(lis1[i]);j++)
				se.insert({r[lis1[i][j]]-l[lis1[i][j]],lis1[i][j]});
			while(sz(se)>empty)
			{
				pair<ll,ll> p = *se.begin();
				se.erase(se.begin());
				ans += l[p.s]-r[p.s];
			}
		}
		// cout<<ans<<endl;
		se.clear();
		for(i=1;i<=n;i++)
		{
			ll empty = i;
			for(j=0;j<sz(lis2[i]);j++)
				se.insert({l[lis2[i][j]]-r[lis2[i][j]],lis2[i][j]});
			while(sz(se)>empty)
			{
				pair<ll,ll> p = *se.begin();
				se.erase(se.begin());
				ans += r[p.s]-l[p.s];
			}
		}
		cout<<ans<<endl;
	}
    return 0;
}





Measured memory_bytes: 26968
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()

# Aでxの根を求める
def find(A, x):
    p = A[x]
    if p == x:
        return x
    a = find(A, p)
    A[x] = a
    return a

# Aでxとyの属する集合の併合
def union(A, x, y):
    if find(A, x) > find(A, y):
        bx, by = find(A, y), find(A, x)
    else:
        bx, by = find(A, x), find(A, y)
    # 根をbx(値の小さい方)に統一 
    A[by] = bx

V = [i for i in range(N)]
for i in range(M):
    x, y, z = lr()
    if find(V, x-1) != find(V, y-1):
        union(V, x-1, y-1)

answer = [find(V, x) for x in set(V)]
print(len(set(answer)))
# 36


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

string S;

bool solve(int l)
{
	int f = 0;
	for (int i = --l; i < S.size(); i++) f ^= (S[i - l] - '0') ^ f;
	for (int i = S.size() - l; i < S.size(); i++) if ((S[i] - '0') ^ f) return i > l;
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int s = 1, e;
	cin >> S;
	e = S.size();
	while (s <= e) {
		int m = (s + e) >> 1;
		if (solve(m)) {
			s = m + 1;
		}
		else {
			e = m - 1;
		}
	}
	cout << e << '\n';
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    sc.close();

    double ans = 0;

    double hDegrees = 30 * h + m / 2.0;
    double mDegrees = 6 * m;
    double inDegrees = Math.abs(hDegrees - mDegrees);
    if (inDegrees > 180) {
      inDegrees = 360 - inDegrees;
    }
    double inRadians = Math.toRadians(inDegrees);

    double sine = Math.sin(inRadians);
    double cosine = Math.cos(inRadians);


    ans = Math.sqrt(Math.pow(b * sine, 2) + Math.pow(b * cosine - a, 2));

    System.out.println(ans);
  }
}


Measured memory_bytes: 35936
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S, T; cin >> S >> T;
    int ans = 0;
    for(int i = 0; i < 3; i++) {
        if(S[i] == T[i]) ans++;
    }
    cout << ans;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int x = 0;
  vector<int> vec(N);
  for(int i = 0; i < N; ++i) {
    cin >> vec.at(i);
  }
  for(int i = 0; i < N; i = i+2) {
    if(vec.at(i) % 2 != 0) {
      x++;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(void){
        while(1){
                int a, b;
                char op;
                scanf("%d %c %d", &a, &op, &b);
                if(op=='?') break;
                if(op=='+') printf("%d\n", a+b);
                if(op=='-') printf("%d\n", a-b);
                if(op=='*') printf("%d\n", a*b);
                if(op=='/') printf("%d\n", a/b);
        }
        return 0;
}


Measured memory_bytes: 2116
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
int a[3005],b[3005];
int dp[3005][2]={};
int main()
{
	int n,t,s;
	scanf("%d %d %d",&n,&t,&s);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
	}
	int cur=0;
	int nex=1;
	dp[0][cur]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3005;j++)dp[j][nex]=0;
		for(int j=0;j<=t;j++)
		{
			dp[j][nex]=max(dp[j][nex],dp[j][cur]);
		}
		for(int j=0;j<=t-b[i];j++)
		{
			if(j<s && s<j+b[i]) continue;
			dp[j+b[i]][nex]=max(dp[j+b[i]][nex],dp[j][cur]+a[i]);
		}
		cur=1-cur; nex=1-nex;
	}
	int ret=0;
	for(int i=0;i<=t;i++) ret=max(ret,dp[i][cur]);
	printf("%d\n",ret);
}

Measured memory_bytes: 1236
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define all(x) x.begin(),x.end() 
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int INF = 1e15;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int m,sum,x;
    void solve()
    {
        cin>>n>>m;
        fo(i,0,m)
        {
            cin>>x;
            sum+=x;
        }
        if(sum<=n)
        {
            cout<<n-sum<<endl;
        }
        else
            cout<<-1<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(void) {
  int n;
  string a,b,ans;
  cin >> n >> a >> b;
  
  rep(i,n){
    ans += a[i];
    ans += b[i];
  }
  
  cout << ans << endl;
  
  return 0;
}

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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

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

    int ans = T;
    int c = T;

    int a;
    cin >> a;

    for(int i = 1;i<n;i++){
        int t;
        cin  >> t;

        if(t <= c){
            ans += T - (c - t);
            c = T + t;
        }else{
            ans += T;
            c = t + T;
        }
    }

    cout << ans;
    

    return 0;
}


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

struct Team {
  int point;
  string name;
  Team(string name, int win, int lose, int draw)
      : name(name), point(win * 3 + draw) {}
  void print() { cout << name << "," << point << endl; }
  bool operator>(const Team& t) const { return point > t.point; }
};

int main() {
  int n;
  int nlf = 0;
  while (scanf("%d", &n), n) {
    if (nlf++) puts("");

    vector<Team> ts;
    for (int i = 0; i < n; i++){
      string name;
      int win, lose, draw;
      cin >> name >> win >> lose >> draw;
      ts.push_back(Team(name, win, lose, draw));
    }
    stable_sort(ts.begin(), ts.end(), greater<Team>());
    for (int i = 0; i < n; i++) ts[i].print();
  }
  return (0);
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    int f[n][10], p[n][11];
    rep(i, n) rep(j, 10) cin >> f[i][j];
    rep(i, n) rep(j, 11) cin >> p[i][j];
    int ans = -1001001001;
    rep(bit, 1<<10) {
        int ta = 0;
        bool allZero = true;
        rep(i, n) {
            int cnt = 0;
            rep(j, 10) {
                if (bit>>j & 1) allZero = false;
                if (bit>>j & f[i][j]) cnt++;
            }
            ta += p[i][cnt];
        }
        if (allZero) continue;
        ans = max(ans, ta);
    }
    cout << ans << endl;
    return 0;
}

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

int main () {
 int A, B, C, D = 0;
  cin >> A >> B >> C >> D;
  if (A+B == C+D) {
  	cout << "Balanced" << endl;
  } else if (A+B > C+D) {
  	cout << "Left" << endl;
  } else {
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> x(n),l(n); 
  vector<pair<int,int>> rbt(n); 
  for(int i=0;i<n;i++){
    cin >> x.at(i) >> l.at(i);
    rbt.at(i).first=x.at(i)+l.at(i);
    rbt.at(i).second=x.at(i)-l.at(i);
  }
  sort(rbt.begin(),rbt.end());
  int ans=1;
  int k=rbt.at(0).first;
  for(int i=0;i<n;i++){  
    if(k<=rbt.at(i).second){
      ans++;
      k=rbt.at(i).first;
    }
  }
  cout << ans << endl;
}

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

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int[][] A = new int[3][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				A[j][i] = Integer.parseInt(sc.next());
			}
		}
		int[][] dp = new int[2][3];
		dp[0][0] = A[0][0];
		dp[0][1] = A[1][0];
		dp[0][2] = A[2][0];
		int t = 1;
		for (int i = 1; i < N; i++, t = 1 - t) {
			Arrays.fill(dp[t], 0);
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (k == j) continue;
					dp[t][k] = Math.max(dp[t][k], dp[1 - t][j] + A[k][i]);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			ans = Math.max(ans, dp[1 - t][i]);
		}
		System.out.println(ans);
	}

}


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

int main() {
  string a;
  int l;
  while(cin >> a >> l){
    if(l==0) return 0;
    vector<int> v;
    v.push_back(stoi(a));
    int i=0;
    bool good = false;
    while(not good){
      i++;
      string z;
      rep(j, l-a.size()) z += '0';
      a = z + a;

      sort(a.begin(), a.end());
      int small = stoi(a);
      sort(a.begin(), a.end(), greater<char>());
      int large = stoi(a);
      int t = large - small;
      rep(j, v.size()){
        if(v[j]==t){
          cout << j <<" " << t << " " << i-j << endl;
          good = true;
          break;
        }
      }
      v.push_back(t);
      a = to_string(t);
    }
  }
  return 0;
}


Measured memory_bytes: 3204
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <cctype>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, double> pid;
typedef pair<LL, int> pLi;
typedef pair<int, LL> piL;
typedef stringstream strstm;
#define PI acos(-1.0)
#define CLR(a) MST(a,0);
#define E 2.718281829459
#define pb(x) push_back(x)
#define CLR(a) MST(a,0);
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) << " ";
#define MST(a,b) memset(a,b,sizeof(a));
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define _ech(x,z) for(auto x = z.begin(); x != z.end(); ++x)





int main(int argc, char const *argv[])
{
	int a, b; cin >> a >> b;
	if((a*b) & 1 ) puts("Odd");
	else puts("Even");
	return 0;
}

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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
	#include "Debug.h"
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;
const int MOD=1000000007;

int n,m,k,p[13];
ll f[10][103];

void pre(){
	int t[13][2];
	memset(t,0,sizeof(t));
	p[0]=1;
	t[1][0]=1;
	t[1][1]=1;
	p[1]=2;
	for (int i=2;i<13;i++){
		t[i][0]=t[i-1][0]+t[i-1][1];
		t[i][1]=t[i-1][0];
		p[i]=t[i][0]+t[i][1];
	}
}

ll calc(int x){
	re (ll)p[max(0,x-2)]*(ll)p[max(0,n-x-2)]%MOD;
}

ll calcm(int x){
	re (ll)p[max(0,x-2)]*(ll)p[max(0,n-x-1)]%MOD;
}

int main(){
	pre();
	cin>>m>>n>>k;
	f[1][0]=1;
	for (int i=1;i<=m;i++){
		for (int j=1;j<=n;j++){
			f[j][i]+=f[j-1][i-1]*calc(j-1);
			f[j][i]%=MOD;
			f[j][i]+=f[j][i-1]*calcm(j);
			f[j][i]%=MOD;
			f[j][i]+=f[j+1][i-1]*calc(j);
			f[j][i]%=MOD;
		}
	}
	cout<<f[k][m];
	re 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
LL f[200000+10];
void init() {
    f[0] = 1;
    for(int i=1;i<=100000;i++) {
        f[i] = f[i-1] * (LL)i % MOD;
    }
}
int n, m;
int main() {
    init();
    cin >> n >> m;
    LL ans = 0;
    if(n == m) {
        ans = 2L * f[n] * f[n] % MOD;
    }
    if(abs(m-n) == 1) {
        ans = f[n] * f[m] % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
# least common multiple
def lcms(*numbers):
    from math import gcd
    from functools import reduce
    def lcm_base(x, y):
        return (x * y) // gcd(x, y)
    return reduce(lcm_base, numbers)

def resolve():
    A, B = list(map(int, input().split()))
    print(lcms(A, B))



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 9540
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

ll mfac(ll n) {
  if (n == 1) return 1;
  return n*mfac(n-1)%mod;
}

int main () {
  ll n, m;
  cin >> n >> m;

  ll ans;
  if (m<n-1||n+1<m) {
    ans = 0;
  }
  else {
    int c;
    if (m == n-1) c = 1;
    else if (m == n) c = 2;
    else c = 1;

    ans = mfac(n)*c%mod;
    ans = ans*mfac(m)%mod;
  }

  cout << ans << endl;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  for(int i=0;i<s.size();i+=2){
      if(s[i]!='h'||s[i+1]!='i'){
          cout<<"No"<<endl;
          return 0;
      }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
if int(n**(0.5))==n**(0.5):
    print(2*int(n**0.5)-2)
else:
    m=int(n**(0.5))
    i=m
    while not n%i==0:
        i-=1
    print(i+n//i-2)


    



Measured memory_bytes: 63324
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long ll;
ll n,s;
bool check(int x) {
	ll re=0,t=n;
	while(t) re+=t%x, t/=x;
	return re==s;
}
int main() {
	scanf("%lld%lld",&n,&s);
	if(n<s) {puts("-1");return 0;}
	int i;
	for(i=2;i<=400000;i++) if(check(i)) {
		printf("%d\n",i); return 0;
	}
	ll t=n-s,ans=-1;
	for(i=1;ll(i)*i<=t;i++) {
		if(t%i==0) {
			ll b=i+1;
			if(n/b<=b&&n%b+n/b==s) {
				printf("%lld\n",b); return 0;
			}
			b=t/i+1;
			if(n/b<=b&&n%b+n/b==s) ans=b;
		}
	}
	if(ans==-1&&n==s) ans=s+1;
	printf("%lld\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    bool f = false;
    rep(i, 1, n){
        if(a[i] - a[i - 1] >= 2) f = true;
    }
    if(a[0] != 0) f = true;
    if(f){
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    a.push_back(a[n - 1]);
    rep(i, 0, n){
        if(a[i] == 0) continue;
        if(a[i] >= a[i + 1]) ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
n, m = map(int, input().split())

k = []
s = []

for i in range(m):
    _k, *_s = map(int, input().split())
    k.append(_k)
    s.append(_s)

p = list(map(int, input().split()))

ans = 0

for i in range(2 ** n):
    bin_i = bin(i)[2:].zfill(n)
    flag = True
    for j in range(m):
        cnt = 0
        for _k in range(k[j]):
            if bin_i[s[j][_k] - 1] == "1":
                cnt += 1
        if cnt % 2 != p[j]:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

vector<int> v(3);
int main(){
  rep(i,0,2) cin >> v[i];
  sort(v.begin(),v.end());

  int A = v[0];
  int B = v[1];
  int C = v[2];

  int cnt = 0;
  cnt += A & 1;
  cnt += B & 1;
  cnt += C & 1;
  int ans = 0;
  if(cnt == 1){
    ans++;
    A += 1 - (A & 1);
    B += 1 - (B & 1);
    C += 1 - (C & 1);
  }
  if(cnt == 2){
    ans++;
    A += (A & 1);
    B += (B & 1);
    C += (C & 1);
  }
  cout << ans + (C - A) / 2 + (C - B) / 2 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	long a, b, c;
	boolean cond = true;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		a = Long.parseLong(tokens[0]);
		b = Long.parseLong(tokens[1]);
		c = Long.parseLong(tokens[2]);

	}

	void calc() {
		long temp = c - a - b;
		if (temp < 0) {
			cond = false;
			return;
		}
		temp *= temp;
		long temp2 = 4L * a * b;
		if (temp2 < temp) {
			cond = true;
		} else {
			cond = false;
		}

	}

	void showResult() {
		System.out.println((cond ? "Yes" : "No"));
	}

}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

vector<pair<int, int>> g[N];

long long bio[N];
void dfs(int u, long long d) {
	bio[u] = d;
	for (const auto &e: g[u]) {
		if (bio[e.first]) continue;
		dfs(e.first, d+e.second);
	}
}

void solve() {
	int n; scanf("%d", &n);
	for (int i = 0; i < n-1; ++i) {
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		g[--a].emplace_back(--b, c);
		g[b].emplace_back(a, c);
	}
	int q, k; scanf("%d%d", &q, &k);
	dfs(--k, 1);
	while (q--) {
		int a, b; scanf("%d%d", &a, &b);
		printf("%lld\n", bio[--a]+bio[--b]-2);
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>
int main(void){
    int n,i,j,l;
  double s[10020];
  double a2,m,a;
  while(1) {
    m=0;
    a2 = 0;
    scanf("%d" , &n);
    if(n == 0) {
      break;
    }
    for(i=0;i<n;i++) {
      scanf("%lf", &s[i]);
    m=m+s[i];
    }
    m=m/n;
    for(i=0; i<n; i++) {
      a2 =a2+(s[i]-m)*(s[i]-m);
    }
    a2 = a2/n;
    printf("%.11lf\n",sqrt(a2));
    }
 
    return 0;
}


Measured memory_bytes: 2112