akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e13
using namespace std;

const int maxn = 210;
const int maxm = 110000;

int n,st,ed;
int s[maxn];

struct edge{int y,nex;ll c;}a[maxm]; int len,fir[maxn];
inline void ins(const int x,const int y,const ll c)
{
	a[++len]=(edge){y,fir[x],c};fir[x]=len;
	a[++len]=(edge){x,fir[y],0};fir[y]=len;
}

queue<int>q;
int h[maxn];
bool bfs()
{
	for(int i=1;i<=ed;i++) h[i]=0;
	h[st]=1; q.push(st);
	while(!q.empty())
	{
		const int x=q.front(); q.pop();
		for(int k=fir[x],y=a[k].y;k;k=a[k].nex,y=a[k].y) if(a[k].c&&!h[y])
			h[y]=h[x]+1,q.push(y);
	}
	return h[ed]>0;
}
ll dfs(const int x,const ll flow)
{
	if(x==ed) return flow;
	ll delta=0;
	for(int k=fir[x],y=a[k].y;k;k=a[k].nex,y=a[k].y) if(a[k].c&&h[y]==h[x]+1)
	{
		ll mink=dfs(y,min(a[k].c,flow-delta));
		a[k].c-=mink; a[k^1].c+=mink;
		delta+=mink;
		if(delta==flow) return delta;
	}
	if(!delta) h[x]=0;
	return delta;
}
ll flow()
{
	ll re=0;
	while(bfs()) 
		re+=dfs(st,LLONG_MAX);
	return re;
}

ll re;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&s[i]);
		if(s[i]>0) re+=(ll)s[i];
	}
	len=1; //
	st=n+1,ed=st+1;
	for(int i=1;i<=n;i++)
	{
		if(s[i]>0) ins(i,ed,(ll)s[i]);
		if(s[i]<0) ins(st,i,(ll)-s[i]);
		for(int j=i+i;j<=n;j+=i) ins(i,j,inf);
	}
	printf("%lld\n",re-flow());
	
	return 0;
}


Measured memory_bytes: 256
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=list(map(int, input().split()))  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）

n, w = list(map(int, input().split()))
wl = [0] * n
vl = [0] * n
v = 100001
for i in range(n):
    wl[i], vl[i] = map(int, input().split())

INF = float("inf")
dp = [[INF]*(v+1)for _ in range(n+1)]  # h:item w:value dp:weight
dp[0][0] = 0
for i in range(n):
    for j in range(v+1):
        if j-vl[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-vl[i]]+wl[i])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for i in range(v+1):
    if dp[n][i] <= w:
        ans = i
print(ans)


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c<=21){
        P("win");
    }else{
        P("bust");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define xx first
#define yy second

pll a[2009];
ll dp[2009][2009],n;

ll solve(ll i,ll j)
{
    if(i==(n+1)) return 0LL;
    if(dp[i][j]!=-1) return dp[i][j];
    ll k = n-(i-j);
    ll ans1 = a[i].xx * (abs(a[i].yy-j)) + solve(i+1,j+1);
    ll ans2 = a[i].xx * (abs(a[i].yy-k)) + solve(i+1,j);
    return dp[i][j]=max(ans1,ans2);
}

int main()
{
    cin >> n;
    for(ll i=1;i<=n;i++)
    {
        cin >> a[i].xx;
        a[i].yy=i;
    }
    sort(a+1,a+n+1,greater<pll>());
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++) dp[i][j]=-1LL;
    }
    cout << solve(1,1) << endl;

}


Measured memory_bytes: 35148
import math
a, b, x = map(int, input().split())
if 2 * (x / (a ** 2)) > b:
    print(math.degrees(math.atan((2 * b - 2 * (x / (a ** 2))) / a)))
else:
    print(math.degrees(math.atan(b / (2 * x / a / b))))

Measured memory_bytes: 3060
import math
k=int(input())


sum=k*(k+1)/2

for l in range(1,k):
  for m in range(l+1,k+1):
    sum=sum+6*math.gcd(l,m)


for l in range(1,k-1):
  for m in range(l+1,k):
    for n in range(m+1,k+1):
      sum=sum+6*math.gcd(l,math.gcd(m,n))
      
print(int(sum))

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  char prev = 'n';
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == prev) cnt++;
    else {
      prev = s[i];
      cnt = 0;
    }
    if (cnt >= 2) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

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

  ll ans = 0;
  FOR(i, 1, n) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  ANS(ans);
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int q;
	while(cin>>q,q!=-1) 
	{
		double x=q/2;
		while(abs(x*x*x-q)>=0.00001*q)
		{
			x=x-(x*x*x-q)/(3*x*x);
		}
		printf("%lf\n",x);
	}
  return 0;
}

Measured memory_bytes: 1188
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int a[2333];
	for(int i=1;i<=3;i++)
	cin>>a[i];
	sort(a+1,a+3+1);
	cout<<a[1]+a[2]; 
	return 0;
} 

Measured memory_bytes: 256
function Main(input) {
    const A = parseInt(input[0]);
    const E = parseInt(input[4]);
    const K = parseInt(input[5]);
    console.log((E-A > K) ? ":(" : "Yay!");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


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

    vector<int> v(n);
    REP(i,n)cin >> v[i];
    int ans = 0;

    REP(i,n-1){
        FOR(j,i+1,n){
            ans += v[i] * v[j];
        }
    }
    cout << ans <<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

N = int(input())

l = [i for i in range(1, N + 1)]

max_count = 0
max_number = l[0] 
for number in l:
    n = number
    count = 0
    while (n % 2 == 0):
        n /= 2
        count += 1
    if count > max_count:
        max_count = count
        max_number = number

print(max_number)


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

int main()
{
	int N, A, B,a,b;

	cin >> N >> A >> B;

	a = A*N;
	b = B;

	if (a < b)
		cout << a << endl;
	else
		cout << b << endl;

	return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.split("\n");
var nq=arr[0].split(" ").map(Number);
var str = arr[1];
var a=[0,0];
var cnt=0;
for(var i=1;i<str.length;i++){
   if(str[i]=="C" && str[i-1]=="A")cnt++;
   a.push(cnt);
}
var ans=[];
for(var i=2;i<nq[1]+2;i++){
   var lr=arr[i].split(" ");
   ans.push(a[lr[1]-0]-a[lr[0]-0]);
}
console.log(ans.join("\n"));

Measured memory_bytes: 34640
#include<iostream>
long a,b,c,d,M=1e9+7,w[1001][1001],e[1001],P[1001][1001],n,i,j,k;long p(long a,int b){return b?b%2?p(a*a%M,b/2)*a%M:p(a*a%M,b/2)%M:1;}main(){for(std::cin>>n>>a>>b>>c>>d;i<=n;)w[i++][0]=1;for(*e=i=1;i<=n;i++)e[i]=e[i-1]*i%M;for(i=0;i++<n;)for(j=i;~j;)P[i][j]=e[i]*p(e[i-j--],M-2)%M;for(;i--;)e[i]=p(e[i],M-2);for(i=a;i<=b;i++)for(j=-1;j++<n;)for(w[i][j]=w[i-1][j],k=c;k<=d&&k<=j/i;k++)(w[i][j]+=w[i-1][j-i*k]*P[n-j+i*k][i*k]%M*p(e[i],k)%M*e[k]%M)%=M;std::cout<<w[b][n]<<"\n";}

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

int main() {
  int64_t k, n;
  cin >> k >> n;
  vector<int64_t> as(n);
  for (auto &&a : as) {
    cin >> a;
  }
  
  int64_t ans = (1LL << 60);
  for (int64_t i = 0; i < n - 1; i++) {
    ans = min(ans, k - (as[i + 1] - as[i]));
  }
  ans = min(ans, k - as[0] - (k - as[n - 1]));
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

const yes = "Yes"
const no = "No"

func solve(a int64, b int64, c int64) [] int {
	ret:=make([] int,3)
        ret[0] = int(a)
        ret[1] = int(b)
        ret[2] = int(c)
        sort.Ints(ret)
        return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	a := nextInt()
	b := nextInt()
	c := nextInt()
        res := solve(a, b, c)

	fmt.Fprintln(out, res[0], res[1], res[2])
}

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

func nextStringAsBytes(n int64) []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: 1120
function Main(input) {
  var input = input[0].split(' ')
  var a = input[0]
  var b = input[1]

  var t = b - a
  var tall = 0;
  for (var i = 0; i < t; i++) {
    tall += i + 1
  }
  console.log(tall - b)
}


Main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));


Measured memory_bytes: 14924
#include<cstring>
#include<algorithm>
#include<string>
#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
int T,n,m;
int a[2010][2010];
int read()
{
	int f=1,x=0;
	char ch=getchar();
	while(ch>'9'||ch<'0')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int main()
{
	int x,y,z;
	n=read();
	m=read();
	x=read();
	y=read();
	if(x>m/2||y>n/2)
	{
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=x;j++)
	{
		a[i][j]=1;
	}
	for(int i=1;i<=y;i++)
	for(int j=1;j<=m;j++)
	{
		a[i][j]=(a[i][j]==0)?1:0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			printf("%d",a[i][j]);
		printf("\n");
	}
	
	return 0;
}

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

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

int main() {
  ll A, B, M;
  cin >> A >> B >> M;
  vector<ll> a(A), b(B);
  vector<vector<ll>> m(M, vector<ll>(3));
  rep(i, A) cin >> a[i];
  rep(i, B) cin >> b[i];
  rep(i, M) {
    cin >> m[i][0] >> m[i][1] >> m[i][2];
  }

  ll ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());

  rep(i, M) {
    ll tmp = a[m[i][0]-1] + b[m[i][1]-1] - m[i][2];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7296
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l;
    string s;
    cin>>s;
    for(i=0; i<s.length(); i++)
    {
        if(s[i]=='?')
               s[i]='D';

    }

    cout<<s<<endl;



    return 0;
}





Measured memory_bytes: 3728
while(1):
    n, w, h = map(int, input().split())
    if not n+w+h:
        break
    t = [[w, h]]
    for i in range(n):
        p, s = map(int, input().split())
        cur = t.pop(p-1)
        W = cur[0]
        H = cur[1]
        s %= 2*W+2*H
        if s < W:
            a = min(s, W-s)
            t.extend([[a, H], [W-a, H]])
        elif s < W+H:
            a = min(s-W, W+H-s)
            t.extend([[W, a], [W, H-a]])
        elif s < 2*W+H:
            a = min(s-W-H, 2*W+H-s)
            t.extend([[a, H], [W-a, H]])
        else:
            a = min(s-2*W-H, 2*W+2*H-s)
            t.extend([[W, a], [W, H-a]])
    ans = []
    for i in t:
        ans.append(i[0]*i[1])
    ans.sort()
    print(' '.join([str(i) for i in ans]))


Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=mod_pow(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(8000000);

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll a,c,b,d; cin >> a >> c >> b >> d;
	cout << ((p.comb(a+c,a)-p.comb(a+d+1,a)-p.comb(b+c+1,b+1)+p.comb(b+d+2,b+1))%mod+mod)%mod << endl; 
}

Measured memory_bytes: 125312
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    string s;
    string z,y;
    cin>>s;
    int n;
    cin>>n;
    int flag=1;
    while(n--)
    {
        int a,b,c;
        char op;
        cin>>a;
        if(a==1)//reverse flag
        {
            if (flag==1)
                flag=0;
            else
                flag=1;
        }
        else
        {
            if(flag==1)
            {
                string op;
                cin>>b>>op;
                if(b==1)
                    z=op+z;
                if(b==2)
                    y=y+op;
            }
            else
            {
                string op;
                cin>>b>>op;
                if(b==2)
                    z=op+z;
                if(b==1)
                    y=y+op;
            }
        }
    }
    s=z+s;
    s=s+y;
    if(flag==0)
        reverse(s.begin(),s.end());
    cout<<s<<endl;
}


Measured memory_bytes: 1436
#include <stdio.h> 

 int main(){ 
     int i, j, k; 
     int n, x; 
     int count; 
 

     while(1){ 
         scanf("%d %d ", &n, &x); 
         if(n==0&&x==0)break; 
         count=0; 
         for(i=1;3*i+3<=x;i++){ 
             for(j=i+1;i+2*j+1<=x;j++){ 
                 for(k=n;k>j;k--){ 
                     if(x==i+j+k){
                        count++; 
                         break; 
                     }else if(x>=i+j+k){ 
                         break; 
                     } 
                 } 
             } 
         } 
         printf("%d\n", count); 
     } 
     return 0; 
 } 



Measured memory_bytes: 2060
def is_same(A,B):
    for rot in range(4):
        for i in range(4):
            if A == B: return True
            B = [[y,-x] for x,y in B]
        B = [[x-B[-1][0],y-B[-1][-1]] for x,y in B][::-1]
    return False
    
while 1:
    n = int(raw_input())
    if n == 0: break
    poly = []
    for loop in xrange(n+1):
        m = int(raw_input())
        xy = [map(int,raw_input().split()) for _ in xrange(m)]
        xy = [[x-xy[0][0],y-xy[0][1]] for x,y in xy]
        poly.append(xy)
    for i in xrange(1,n+1):
        if is_same(poly[0],poly[i]):
            print i
    print "+++++"
    

Measured memory_bytes: 4268
program main
  implicit none
  integer(8) :: n, i, l(0:86)
  read(*, *) n
  l(0) = 2
  l(1) = 1
  do i = 2, 86
    l(i) = l(i - 1) + l(i - 2)
  end do
  write(*, "(i0)") l(n)
end program main


Measured memory_bytes: 256
import java.util.*;

class Main {

  static class Info {
    private int acCount, acTime;
    public Info(int count, int time) {
      this.acCount = count;
      this.acTime = time;
    }
    public int getCount() {
      return acCount;
    }
    public int getTime() {
      return acTime;
    }
  }

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    while (true) {
      int M = sc.nextInt();
      int T = sc.nextInt();
      int P = sc.nextInt();
      int R = sc.nextInt();
      if (M == 0 && T == 0 && P == 0 && R == 0) return;

      Map<Integer, Info> info_map = new HashMap<>();
      int waCount[][] = new int[T][P];

      for (int i = 0; i < T; i++) {
        info_map.put(i, new Info(0, 0));
      }

      for (int i = 0; i < R; i++) {
        int m = sc.nextInt();
        int t = sc.nextInt()-1;
        int p = sc.nextInt()-1;
        int j = sc.nextInt();
        if (j != 0) {
          waCount[t][p]++;
        }
        else {
          int count = info_map.get(t).getCount() + 1;
          int time = info_map.get(t).getTime() + m + (waCount[t][p]*20);
          info_map.put(t, new Info(count, time));
        }
      }

      List<Map.Entry<Integer, Info>> info_list = new ArrayList<>(info_map.entrySet());
      Collections.sort(info_list, new MyComparator());

      /*
      for (Map.Entry<Integer, Info> entry : info_list) {
        System.out.println("Team" + (entry.getKey() + 1) + " : " +
                          entry.getValue().getCount() + "AC, " +
                          entry.getValue().getTime() + "time");
      }
      */

      for (int i = 0; i < T; i++) {
        if (i == 0) {
          System.out.print(info_list.get(0).getKey() + 1);
        }
        else {
          String s = "";
          Info xInfo = info_list.get(i-1).getValue();
          Info yInfo = info_list.get(i).getValue();
          if (xInfo.getCount() == yInfo.getCount()
           && xInfo.getTime() == yInfo.getTime()) s = "=";
           else s = ",";
           System.out.print(s + (info_list.get(i).getKey() + 1) );
        }
      }
      System.out.println();
    }
  }

  static class MyComparator implements Comparator<Map.Entry<Integer, Info>> {
    public int compare(Map.Entry<Integer, Info> x, Map.Entry<Integer, Info> y) {
      int xCount = x.getValue().getCount();
      int yCount = y.getValue().getCount();
      int xTime = x.getValue().getTime();
      int yTime = y.getValue().getTime();
      int xTeamNo = x.getKey();
      int yTeamNo = y.getKey();

      if (xCount == yCount) {
        if (xTime == yTime) return yTeamNo - xTeamNo;
        else return xTime - yTime;
      }
      return yCount - xCount;
    }
  }
}



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

const int nm = 1e5;
int n, p[nm + 1], q;

int main() {
	cin >> n;
	long long s = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		s += a;
		++p[a];
	}
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int b, c;
		cin >> b >> c;
		s += (long long) p[b] * (c - b);
		p[c] += p[b];
		p[b] = 0;
		cout << s << endl;
	}

}


Measured memory_bytes: 4020
L, R = map(int, input().split())
MOD = 2019

m = float('inf')
if L + MOD < R :
    for i in range(MOD) :
        for j in range(MOD) :
            m = min(m, i*j%MOD)
else :
    for i in range(L, R) :
        for j in range(i+1, R+1) :
            m = min(m, i*j%MOD)
            
print(m)

Measured memory_bytes: 40812
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord
import qualified Data.Vector.Unboxed           as UV

import System.IO

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  s <- getLine
  putStrLn $ if s == "ABC" then "ARC" else "ABC"


Measured memory_bytes: 3696
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a,b,c;
    scan(a,b,c);
    auto t =[a + b, a + c, b + c];
    t.reduce!(min).writeln();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
auto in = [](auto &&... args) { (cin >> ... >> args); };


signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int n;
  cin >> n;
  vector<pair<int,int>> P(n);

  for(int i = 0;i < n; i++) {
    int x , L;
    cin >> x >> L;
    P[i].first = x - L;
    P[i].second = x + L;
  }

  sort(P.begin() , P.end() , [](const pair<int,int> &a , const pair<int,int> &b) {
     if(a.second != b.second) {
       return a.second < b.second;
     }
     return a.first < b.first;
  });

  int ans = 0;
  int curR = -24242424345342424;

  for(int i = 0; i < n; i++) {
    if(P[i].first >= curR) {
      ans++;
      curR = P[i].second;
    }
  }
  cout << ans << '\n';


}

Measured memory_bytes: 4736
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

		Map<Integer, Integer> mp = new HashMap<>();

		for (int i = 0; i < N; i++) {
			mp.put(i, K);
		}

		for (int i = 0; i < Q; i++) {
			int A = sc.nextInt() - 1;
			mp.put(A, mp.get(A) + 1);
		}
		sc.close();

		for (int i = 0; i < N; i++) {
			int hp = mp.get(i);
			if (hp - Q > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 94892
#include <stdio.h>

int main(){
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    if((a==1 && b==2)|| (a==2 && b==1)){
        printf("3\n");
    }
    
    else if((a==2 && b==3) || (a==3 && b==2)){
        printf("1\n");
    }
    
    else if((a==3 && b==1) || (a==1 && b==3)){
        printf("2\n");
    }
    
    return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((a+b) > (c+d)) {
        cout << "Left" << endl;
    }
    else if ((a+b) == (c+d)) {
        cout << "Balanced" << endl;
    }
    else {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
S = input()
T = input()
def count(x, y):
    cnt = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            cnt += 1
    return cnt

ans = 0
l_T = len(T)
l_S = len(S)
for i in range(l_S - l_T + 1):
    tmp_str = S[i:i+l_T]
    tmp_ans = count(T, tmp_str)
    ans = max(ans, tmp_ans)
ans = l_T - ans
print(ans)

Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e+5+10;

int a[N];
int A,B,n;

LL minll(LL x,LL y){
	if (x<y)return x;
	return y;
}

int main(){
	n=get();A=get();B=get();
	fo(i,1,n)a[i]=get();
	LL ans=0;
	fo(i,2,n)
	ans=ans+minll(LL(A)*(a[i]-a[i-1]),B);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

        int left = 1;
        int right = N;
        for(int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            left = Math.max(left,a);
            right = Math.min(right,b);
        }
        System.out.println(Math.max(right-left+1, 0));
    }
}


Measured memory_bytes: 60464
fun main(args:Array<String>) {
	val x = readLine()!!.toInt()
	
	(1..32).map{ b->
		(2..10).map{ p-> Math.pow(b.toDouble(),p.toDouble()) } }
			.flatten()
			.filter { it.toInt()<=x }
			.max()!!.toInt()
			.let { println(it) }
}

Measured memory_bytes: 33660
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e ,n, k, x,l,r;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> re;
    vector<ll> de;

    cin >> s;

    ll co = 0;

    rep(i,s.size()){
        char c = s[i];

        if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
            co++;

        }
        else {
            co = 0;
        }
        ans = max(ans, co);
    }
    
    std::cout << ans << endl; 

    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define re(i,a,n) for(i=a;i<=n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second


ll binpow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return binpow(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0,k,x,r,l,t;
    string s,s1;
    cin >> s >> s1 ;
    n=s.size();
    m=s1.size();
    string temp=s;
    ans=m;
    ll t1;
    x=0;
    rep(i,temp.size())
    {
          if(i+m-1>=temp.size()) break;
          t1=m;
          rep(j,m)
          {
                if(temp[i+j]==s1[j]) t1--;
          }
          ans=std::min(ans,t1);
    }
    cout << ans ;
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;
class Main{
    static int n;
    static int x;
    static int y;
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        x = scanner.nextInt();
        y = scanner.nextInt();
        int[][] dis = new int[n][n];
        int[] ans = new int[n];
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                dis[i-1][j-1] = Math.min(Math.abs(i-j), Math.min(Math.abs(i-x)+1+Math.abs(j-y), Math.abs(i-y)+1+Math.abs(j-x)));
                if(dis[i-1][j-1] < n-1){ans[dis[i-1][j-1]]++;}
                
            }
        }
        for(int i = 1; i < n; i++){
            System.out.println(ans[i]/2);
        }
    }
}



Measured memory_bytes: 53588
sx,sy,tx,ty = map(int,input().split())

ans = ""

ans += (ty-sy)*"U"
ans += (tx-sx)*"R"
ans += (ty-sy)*"D"
ans += (tx-sx+1)*"L"
ans += (ty-sy+1)*"U"
ans += (tx-sx+1)*"R"
ans += "D"
ans += "R"
ans += (ty-sy+1)*"D"
ans += (tx-sx+1)*"L"
ans += "U"

print(ans)

Measured memory_bytes: 3064
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve(){
    string s; cin >> s;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3 << nl;
    else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) cout << 2 << nl;
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1 << nl;
    else cout << 0 << nl;
}

int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


Measured memory_bytes: 3600
#include <cstdio>
#include <algorithm>
using namespace std;

int sum=0, tmp;

int main(){
	for (int i = 0; i < 5; i++) {
		scanf("%d", &tmp);
		sum += max(40, tmp);
	}
	printf("%d\n", sum / 5);

	return 0;
}

Measured memory_bytes: 2736
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int mod=998244353;
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int fpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return ans;
}
int lim,len,rev[1000005];
void getlim(int dep)
{
	lim=1,len=0;
	while(lim<=dep) lim<<=1,len++;
	for(int i=1;i<lim;i++)
		rev[i]=(rev[i>>1]>>1)|((i&1)<<(len-1));
}
void ntt(int *a,int fl)
{
	for(int i=1;i<lim;i++)
		if(i<rev[i]) swap(a[i],a[rev[i]]);
	for(int k=1;k<lim;k<<=1)
	{
		int wn=fpow(3,(mod-1)/(k*2));
		for(int i=0,r=k*2;i<lim;i+=r)
		{
			int w=1;
			for(int j=0;j<k;j++,w=1ll*w*wn%mod)
			{
				int x=a[i+j],y=1ll*w*a[i+j+k]%mod;
				a[i+j]=addmod(x+y);
				a[i+j+k]=submod(x-y);
			}
		}
	}
	if(fl==-1)
	{
		reverse(a+1,a+lim);
		int inv=fpow(lim,mod-2);
		for(int i=0;i<lim;i++)
			a[i]=1ll*inv*a[i]%mod;
	}
}
int n,h[100005],a[100005],at,g[1000005];
int tmp[1000005],tmp2[1000005];
int fr[500005],infr[500005],pw[500005],pn=5e5;
vector<int> f[100005];
void getmul(int len,int len2)
{
	getlim(len+len2);
	for(int i=len;i<lim;i++)
		tmp[i]=0;
	for(int i=len2;i<lim;i++)
		tmp2[i]=0;
	ntt(tmp,1);
	ntt(tmp2,1);
	for(int i=0;i<lim;i++)
		tmp[i]=1ll*tmp[i]*tmp2[i]%mod;
	ntt(tmp,-1);
}
vector<int> solve(int l,int r)
{
	if(l==r) return f[l];
	int mid=(l+r)/2;
	vector<int> ls,rs,ans;
	ls=solve(l,mid);
	rs=solve(mid+1,r);
	int lsz=ls.size(),rsz=rs.size();
	for(int i=0;i<lsz;i++)	
		tmp[i]=ls[i];
	for(int i=0;i<rsz;i++)	
		tmp2[i]=rs[i];
	getmul(lsz,rsz);
	ans.resize(lsz+rsz-1);
	for(int i=0;i<lsz+rsz-1;i++)
		ans[i]=tmp[i];
	return ans;
}
int main()
{
	int inv2=fpow(2,mod-2);
	fr[0]=infr[0]=1;
	pw[0]=1;
	for(int i=1;i<=pn;i++)
	{
		pw[i]=1ll*inv2*pw[i-1]%mod;
		fr[i]=1ll*i*fr[i-1]%mod;
		infr[i]=fpow(fr[i],mod-2);
	}
	scanf("%d",&n);
	n*=2;
	for(int i=0;2*i<=n;i++)
		g[2*i]=1ll*fr[2*i]*infr[i]%mod*pw[i]%mod;
	/*for(int i=0;2*i<=n;i++)
		tmp[2*i]=1ll*fr[2*i]*infr[i]%mod*pw[i]%mod*infr[2*i]%mod;
	for(int i=0;i<=n;i++)
		tmp2[i]=infr[i];
	getmul(n,n);
	for(int i=0;i<=n;i++)
	{
		g[i]=1ll*tmp[i]*fr[i]%mod;
		printf("%d ",g[i]);
	}
	printf("\n");*/
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	sort(h+1,h+n+1);
	for(int l=1,r;l<=n;l=r+1)
	{
		r=l;
		while(r<n&&h[r+1]==h[l]) r++;
		a[++at]=r-l+1;
	}
	for(int i=1;i<=at;i++)
	{
		int u=a[i]/2;
	//	printf("i=%d,a=%d\n",i,a[i]);
		for(int j=0;j<=u;j++)
		{
			f[i].push_back(1ll*fr[a[i]]*infr[a[i]-2*j]%mod*infr[j]%mod*pw[j]%mod);
		//	printf("%d ",f[i][f[i].size()-1]);
		}
	//	printf("\n");
	}
	vector<int> ans;
	int sz,tans=0;
	ans=solve(1,at);
	sz=ans.size();
	for(int i=0;i<sz;i++)
	{
	//	printf("i=%d,ans=%d\n",i,ans[i]);
		if(i%2==0) tans=addmod(tans+1ll*ans[i]*g[n-i*2]%mod);
		else tans=submod(tans-1ll*ans[i]*g[n-i*2]%mod);
	}
	printf("%d\n",tans);
	return 0;
}

Measured memory_bytes: 15696
N = int(input())
csf = [list(map(int, input().split())) for _ in range(N-1)]

for i in range(N-1):
  time = 0
  for c, s, f in csf[i:]:
    if time <= s:
      time = s + c
    else:
      if time % f == 0:
        time += c
      else:
        time += c + f - time % f
  print(time)
print(0)

Measured memory_bytes: 3188
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[2*100002];
int main()
{
	ll n,k,s=0;
	cin>>n>>k;

	forn(i,n)
	cin>>a[i];

	sort(a,a+n);

	for(ll i=0;i<(n-k);i++) s+=a[i];
	cout<<s;
}

Measured memory_bytes: 1792
a, b, c, d = map(int, input().split())

if ((b <= 0) and (d < 0)):
    print(a * c)
elif ((b <= 0) and (d > 0)):
    print(max(a * c, b * c))
elif ((b >= 0) and (d < 0)):
    print(max(a * c, a * d))
else:
    print(max(a*c, b*d))

Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        int count = 0;
        for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        }
        
        if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35796
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k;   cin >> n >> k;
    int *p = new int[n];
    for (int i = 0; i < n; i++)
        cin >> p[i];
    
    sort(p, p+n);
    int ans = 0;
    for (int i = 0; i < k; i++)
        ans += p[i];
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    l = list(map(int, input().split()))
    ans = 0
    
    for i in range(len(l) - 2):
        for j in range(i + 1, len(l) - 1):
            for k in range(j + 1, len(l)):
                if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
                    continue
                if (l[i] + l[j]) <= l[k] or (l[i] + l[k]) <= l[j] or (l[j] + l[k]) <= l[i]:
                    continue
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68072
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<4;i++){
    if(s.at(i)=='+'){
      ans++;
    }
    if(s.at(i)=='-'){
      ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> C(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        C[i] = a+b;
        sum += a;
    }
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());
    for (int i = 1; i < N; i+=2) sum -= C[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

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

ll div2(ll n) {
    ll cnt = 0;
    while (n % 2 == 0) {
        n /= 2;
        cnt++;
    }
    return cnt;
}

ll solve() {
    ll N, M;
    cin >> N >> M;
    V<ll> A(N);
    for (ll &e : A) {
        cin >> e;
        e /= 2;
    }
    {
        ll tmp = div2(A[0]);
        for (ll i = 1; i < N; i++) if (tmp != div2(A[i])) return 0;
    }
    ll cur = A[0];
    for (ll i = 1; i < N; i++) {
        ll g = gcd(cur, A[i]);
        cur = cur / g * A[i];
        if (M < cur) return 0;
    }

    DEBUG(cur);
    ll max_k = M / cur;
    DEBUG(max_k);
    return (max_k + (max_k & 1)) / 2;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main() {
    ll N; 
    cin >> N;
    vector <ll> a(N);
    REP(i,N)cin >> a[i];

    vector <vector <int> >  x(3, vector<int>(N+1, 0));

    REP(i,N)
    {
        REP(j,3)
        {
            x[j][i+1] = x[j][i];
        }
        bool flg = false;
        REP(j, 3)
        {
            //なるなら上げる
            if(a[i] == x[j][i])
            {
                ++x[j][i+1];
                flg = true;
                break;
            }
        }

        if(!flg)
        {
            cout << 0 << endl;
            return 0;
        }
    }

#if DEBUG
    REP(i,N + 1)
    {
        REP(j, 3)
        {
            cout << x[j][i] << endl;
        }
    }
#endif

    ll res = 1;
    for(int i = 1; i <= N; ++i)
    {
        //今回の対象:次のターンにこれになれるやつをさがす
        int kon;
        for(int j = 0; j < 3; ++j)
        {
            if(x[j][i] != x[j][i-1])
            {
                kon = x[j][i];
            }
        }
        //cout << kon-1 << endl;
        int cnt = 0;
        for(int j = 0; j < 3; ++j)
        {
            //cout << x[j][i-1] << " ";
            if(kon - 1 == x[j][i-1])
            {
                ++cnt;
            }
        }
        //cout << endl;

        res *= cnt;
        //cout << res << endl;
        res %= MOD;
    }

    cout << res << endl;
}


Measured memory_bytes: 2560