akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int const MAXn = 1e5 + 2, MOD = 1e9 + 7;

ll dp[102][MAXn];

int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        int ai;
        cin>>ai;
        if(i == 1){
            for(int j = 0; j <= ai; j++)
                dp[1][j] = 1;
            continue;
        }
        for(int j = k; j >= 0; j--){
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
            if(j + ai + 1 <= k)
                dp[i][j + ai + 1] = (dp[i][j + ai + 1] - dp[i - 1][j] + MOD) % MOD;
        }
        for(int j = 1; j <= k; j++){
            dp[i][j] = (dp[i][j - 1] + dp[i][j]) % MOD;
        }
    }
    cout<<dp[n][k];
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,m;
  cin >> n >> m;
  vector<bool> wa(n,false);
  vector<bool> ac(n,false);
  vl nwa(n,0);

  REP(i,m){
    ll pi;
    string res;
    cin >> pi;
    cin >> res;
    pi--;
    if(!ac[pi]){
      if(res=="AC") ac[pi] = true;
      else {
        wa[pi] = true;
        nwa[pi]++;
      }
    }
  }

  ll np = 0;
  ll na = 0;
  REP(i,n){
    if(ac[i]){
      na++;
      if(wa[i]){
        np += nwa[i];
      }
    }
  }
  
  //cout << fixed << setprecision(10);
  cout << na << " " << np << endl;
  return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
a=[0]*n
a=list(map(int,input().split()))

List=[0]*n
pattern=[1]
now=0
nex=0
List[0]=1
end_flag=0

while end_flag==0:
    nex=a[now]
    if (List[nex-1]==1):
        target1=nex
        end_flag=1
        break
    else:
        List[nex-1]+=1
        pattern.append(nex)
        now=nex-1

left=pattern.index(target1)
right=len(pattern)
kaisu=right-left
kaisu2=(k-right)%kaisu


if (k<=right-1):
    print(pattern[k])
else:
    print(pattern[left+kaisu2])

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

using namespace std;

int main(void){
string S[2], U;
int N[2];

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

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

cin >> U;

if(U == S[0]) cout << N[0] - 1 << " " << N[1]<<endl;
if(U == S[1]) cout << N[0] << " " << N[1] - 1<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    vector<ll> A(4);
    rep(i,4) cin >> A[i];
    sort(ALL(A));
    if(A[0] == 1 && A[1] == 4 && A[2] == 7 && A[3] == 9) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, M = LI()
AB = LRI(M)

visited = [False] * N

root = [[] for _ in range(N)]
for a, b in AB:
    root[a-1].append(b-1)
    root[b-1].append(a-1)

ret = [-1] * N
Q = collections.deque([[0,0]])
while Q:
    qs = Q.popleft()
    b = qs[0]
    q = qs[1]

    if visited[q]:
        continue
    else:
        visited[q] = True
    
    ret[q] = b

    for r in root[q]:
        Q.append([q, r])

if -1 in ret:
    print("No")
else:
    print("Yes")
    for i, r in enumerate(ret):
        if i == 0:
            continue

        print(r+1)


Measured memory_bytes: 149268
package main

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

const Inf = 1 << 60

func main() {
	N, K := ReadInt(), ReadInt()
	V := ReadInts(N)

	max := -Inf
	for a := 0; a <= K && a <= N; a++ {
		for b := 0; a+b <= K && a+b <= N; b++ {
			sum := 0
			tmp := make([]int, a+b)
			for i := 0; i < a; i++ {
				sum += V[i]
				tmp = append(tmp, V[i])
			}
			for i := N - 1; i >= N-b; i-- {
				sum += V[i]
				tmp = append(tmp, V[i])
			}
			sort.Ints(tmp)
			maxC := K - (a + b)
			for i := 0; i < a+b && i < maxC; i++ {
				if tmp[i] >= 0 {
					break
				}
				sum -= tmp[i]
			}
			if sum > max {
				max = sum
			}
		}
	}
	fmt.Println(max)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main(){
  int N;
  cin >> N;
  int A[N+1];
  int B[N+1]={0};
  for(int i=2;i<N+1;i++){
    cin >> A[i];
  }
  for(int i=2;i<N+1;i++){
    B[A[i]]++;
  }
  for(int i=1;i<N+1;i++)cout << B[i] << endl;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
#define ll long long int
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
    
    return 0;
}


Measured memory_bytes: 3572
K = int(input())

def calculate(k):

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    res = 1

    m = (((10 ** res) - 1) // 9) * 7


    while m % k > 0:
        res += 1
        m = m % k
        m = m * 10 + 7

    print(res)


calculate(K)



Measured memory_bytes: 9080
object Main extends App {
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
    var cnt = 0
      for {
        i <- 0 to a
        c0 = 500*i
        if c0 <= x
        j <- 0 to b
        c1 = 100*j
        if c0 + c1 <= x
        k <- 0 to c
        if c0 + c1 + 50*k == x
      } cnt += 1
    cnt
  }

  println(ans)
}

Measured memory_bytes: 27340
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define CLR(A, X) memset(A, X, sizeof(A))
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
int dcmp(double x) { if(fabs(x) < eps) return 0; return x>0?1:-1; }
const LL MOD = 1e9+7;
const int N = 2e5+5;
const int INF = 0x3f3f3f3f;

int d[2][N][32], a[2][N], pos[N];

void RMQ_init(int n, int v) {
    for(int i = 0; i < n; i++) d[v][i][0] = a[v][i];
    for(int j = 1; (1<<j) <= n; j++)
        for(int i = 0; i+(1<<j)-1 < n; i++)
            d[v][i][j] = min(d[v][i][j-1], d[v][i+(1<<(j-1))][j-1]);
}

int RMQ(int L, int R, int v) {
    int k = 0;
    while((1<<(k+1)) <= R-L+1) k++;
    return min(d[v][L][k], d[v][R-(1<<k)+1][k]);
}

struct node {
    int x, L, R;
    bool operator < (const node& A) const {
        return x > A.x;
    }
};

int main() {
    int n, x;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        a[i&1][i] = x;
        a[(i&1)^1][i] = INF;
        pos[x] = i;
    }
    RMQ_init(n, 0); RMQ_init(n, 1);
    priority_queue<node> Q;
    x = RMQ(0, n-1, 0);
    Q.push({x, 0, n-1});
    while(!Q.empty()) {
        node x = Q.top(); Q.pop();
        int v1 = x.x, v2 = RMQ(pos[x.x]+1, x.R, (pos[x.x]&1)^1);
        printf("%d %d ", v1, v2);
        v1 = pos[v1], v2 = pos[v2];
        if(x.L != v1) Q.push({RMQ(x.L, v1-1, x.L&1), x.L, v1-1});
        if(v1+1 != v2) Q.push({RMQ(v1+1, v2-1, (v1+1)&1), v1+1, v2-1});
        if(v2 != x.R) Q.push({RMQ(v2+1, x.R, (v2+1)&1), v2+1, x.R});
    }
    return 0;
}


Measured memory_bytes: 54392
#include <stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d", &W);
	scanf("%d", &H);
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &r);

	if (W<(x+r)) {
		printf("No\n");
	}
		
	else if (H<(y+r)) {
		printf("No\n");
	}

	else if (0 >= (x + r)) {
		printf("No\n");
	}

	else if (0 >= (y + r)) {
		printf("No\n");
	}

	else {
		printf("Yes\n");
	}


    return 0;
}


Measured memory_bytes: 2108
n=int(input())
t=list(map(int,[input() for i in range(n)]))

def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)

if n==1:
    print(t[0])
else:
    ans=lcm(t[0],t[1])
    for i in range(n-1):
        ans=lcm(ans,lcm(t[i],t[i+1]))
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  ll n,a,b;cin>>n>>a>>b;
  ll c=a+b;
  ll d=n/c;
  ll amari;
  amari=n%c;
  ll nokori;
  if(amari>=a){
    nokori=a;
  }else{
    nokori=amari;
  }
  cout<<d*a+nokori<<endl;
}

Measured memory_bytes: 256
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();
        String c = String.valueOf(b);
        for (int i = 0; i < c.length(); i++) {
            a *= 10;
        }
        int check = b + a;

        for (int i = 1; i <= 1000; i++) {
            if (check == i*i) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <queue>
#include <stack>

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define vb vector<bool>
#define vvb vector<vb>
#define vstr vector<string>
#define pll pair<ll, ll>
#define pb pair<bool, bool>

using namespace std;



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

	for (ll i = 0; i < str.size(); i++)
	{
		if (str[i] == '?') cout << "D";
		else cout << str[i];
	}
	cout << endl;
}


Measured memory_bytes: 3484
def saiki(n,d,r,x2000):
    if n==2000:
        return x2000
    
    else:
        return r*saiki(n-1,d,r,x2000)-d

r,d,x2000 = map(int,input().split())
for n in range(2001,2011):
    print(saiki(n,d,r,x2000))

Measured memory_bytes: 2940
N , M = (int(a) for a in input().split())
A = list(map(int,input().split()))
BC = [[int(a) for a in input().split()] for l in range(M)]
A =sorted(A)
BC = sorted(BC , key = lambda x: - x[1])
s = 0

for i in range(N*M) :
    if A[i] < BC[s][1] :
        A[i] = BC[s][1]
    else : break
    BC[s][0] -= 1
    if BC [-1][0] == 0 or i == N-1 :
        break
    if BC[s][0] == 0 :
        s += 1

print(sum(A))





Measured memory_bytes: 31036
package main

import "fmt"

func main() {
	var a, b, k int
	var small int
	var arr []int
	fmt.Scan(&a, &b, &k)

	if a >= b {
		small = b
	} else {
		small = a
	}

	for i:=1; i <= small; i++ {
		if a%i == 0 && b%i == 0 {
				arr = append(arr, i)
		}
	}
		num := len(arr) - k
		fmt.Println(arr[num])
}

Measured memory_bytes: 512
import math
N = int(input())
Nlist = [list(map(int, input().split())) for i in range(N)]
total = 0
for i in range(N-1):
    for j in range(i+1, N):
        total += math.sqrt((Nlist[i][0]-Nlist[j][0])
                           ** 2+(Nlist[i][1]-Nlist[j][1])**2)
ans = total*2/N
print(ans)


Measured memory_bytes: 9160
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	int a,b;
  cin>>a>>b;
  cout<<(a+b-3)/(a-1);
}

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

int main() {

    int L, m, n, res;

    for (; ;) {
        scanf("%d", &L);
        res = -1;
        if (L == 0) break;
        for (int i = 0; i < 12; i++) {
            scanf("%d %d", &m, &n);
            L-= m-n;
            if (L <= 0 && res < 0) res = i+1;
        }
        (L > 0) ? printf("NA\n") : printf("%d\n", res);
    }
    return 0;
}



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

namespace abc161_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadLong();
      var K = CIn.ReadLong();

      var mod = N % K;
      var ans = Math.Min(mod, K - mod);

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

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

int main(){
  int m,d;
  cin >> m >> d;
  int ans = 0;
  for(int i = 1; i < m + 1; i++){
    for(int j = 10; j < d + 1; j++){
      if(j % 10 >= 2 && j / 10 >= 2 && (j % 10) * (j / 10) == i){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
from sys import stdin
def main():
    n = int(stdin.readline())
    a = [int(stdin.readline()) for _ in xrange(n)]
    a.sort()
    h = n / 2
    def solve(l, m):
        res = sum(m) - sum(l)
        res *= 2
        if len(l) < len(m):
            res -= m[0] + m[1]
        else:
            res += l[-1] + l[-2]
        return res
    if n % 2:
        print max(solve(a[:h], a[h:]), solve(a[:h+1], a[h+1:]))
    else:
        ans = 0
        for i in xrange(n / 2):
            ans += a[i+h] - a[i]
        ans = ans * 2 + a[h-1] - a[h]
        print ans
main()


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

const int maxn = 1e6 + 5;
int n;
vector<int> v[maxn];
int cnt_son[maxn];
#define ll long long 
ll ans[maxn];

ll cal(ll x) {
    return x* (x + 1) / 2;
}

int col[maxn];
int num[maxn];

void dfs(int x, int pre) {
    cnt_son[x] = 1;
    int c = col[x];
    int temp = num[c];
    for (auto &y : v[x]) {
        if (y != pre) {
            int now = num[c];
            dfs(y, x);
            now = num[c] - now;
            ans[c] -= cal(cnt_son[y] - now);
            cnt_son[x] += cnt_son[y];
        }
    }
    num[c] = temp + cnt_son[x];
    return ;
}


int main() {
    cin >> n;
    int x, y;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &col[i]);
    }
    for (int i = 1; i < n; ++i) {
        scanf("%d %d", &x, &y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for (int i = 1; i <= n; ++i) {
        ans[i] = cal(n);
    }
    dfs(1, 0);
    for (int i = 1; i <= n; ++i) {
        ans[i] -= cal(n -num[i]);
        printf("%lld\n", ans[i]);
    }
}

Measured memory_bytes: 56180
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define f first
#define s second
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<=k)
	{
		cout<<x*n<<endl;
	}
	else
	{
		ll h = k*x+(n-k)*y;
		cout<<h<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main(void) {
	int n, k, i, j, l, x, y;
	ll ans = 1e20, s, h;
	vector<P> p;

	cin >> n >> k;
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		p.push_back(P(x, y));
	}

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

	for (i = 0; i < n; i++) for (j = i + k - 1; j < n; j++) {
		vector<ll> yp;
		for (l = i; l <= j; l++) {
			yp.push_back(p[l].second);
		}
		sort(yp.begin(), yp.end());
		h = 2e9;
		for (l = 0; l + k - 1 < j - i + 1; l++) {
			h = min(h, yp[l + k - 1] - yp[l]);
		}
		s = ((ll)p[j].first - p[i].first) * h;
		ans = min(ans, s);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in); 
		while(sc.hasNext())
		{
		
		BigInteger x = sc.nextBigInteger();
		BigInteger y = sc.nextBigInteger();

		BigInteger gcd = x.gcd(y);
		BigInteger lcm = x.multiply(y).divide(gcd);
		System.out.print(gcd+" ");
		System.out.println(lcm);
		}
	}
	/*public static int  gcd(int x, int y) //ユークリッド互除法
	{
		int div=-1;
		while(true)
		{
			div = x%y;
			if(div==0)
				break;
			x=y;
			y=div;
		}	
		return y;
	}
	 */


}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main(){
	int sum = 0;
	rep(i,5){
		int x;
		cin >> x;
		sum += x;
	}
	cout << 15 - sum << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int N, max=0;
	vector<int> a, b;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		b.push_back(tmp);
	}

	for (int i = 0; i < N; i++)
	{
		int sum = 0;
		for (int j = 0; j <= i; j++)
		{
			sum += a.at(j);
		}
		for (int k = i; k < N; k++)
		{
			sum += b.at(k);
		}
		if (max < sum) {
			max = sum;
		}
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
/*
ACplease
　　 ●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#include <cassert>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------------------------------------
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
    srand((unsigned)time(NULL));
    
    int d,t,s;
    cin >> d >> t >> s;
    if(d%s > 0){
    	if(d/s+1 > t)No;
      	else Yes;
    }else{
    	if(d/s > t)No;
      	else Yes;
    }

    return 0;
}

Measured memory_bytes: 3640
//Resting_Prince
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b)    for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    ll n,h,w,i,j,k,l,o,p;
    char b;bool a[1005][1005];
    cin>>h>>w;
    rep(i,0,h-1)rep(j,0,w-1)cin>>b,a[i][j]=(b=='#')?1:0;
    ll dp[1005][1005]={0};
    dp[0][0]=0;
    rep(i,1,h-1){if(a[i][0]==1)break;dp[i][0]=1;}
    rep(i,1,w-1){if(a[0][i]==1)break;dp[0][i]=1;}
    rep(i,1,h-1)
    {
        rep(j,1,w-1)
        {
            if(a[i][j]==0)
            dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
            else
            dp[i][j]=0;
        }
    }//rep(i,0,h-1){rep(j,0,w-1)cout<<dp[i][j]<<" ";cout<<en;}
    cout<<dp[h-1][w-1]%mod;
    return 0;
}


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

int main(void){
 
  long num1,num2,mul,gcd,lcm;
  
  while(cin >> num1 >> num2){
    mul = num1 * num2;

    /*GCD*/
    if(num1 >= num2){
      while(num2 != 0){
	gcd = num1 % num2;
	num1 = num2;
	num2 = gcd;
      }
      gcd = num1;
    }else{
      while(num1 != 0){
	gcd = num2 % num1;
	num2 = num1;
	num1 = gcd;
      }
      gcd = num2;
    }

    /*LCM*/
    lcm = mul / gcd;

    /*PRINT*/
    cout << gcd << " " << lcm << endl;      
  }
  return 0;

}

Measured memory_bytes: 1160
#B
N = int(input())
T, A = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
#print(N, T, A)#
#print(H)#

def dif(h):
    return abs(T - h*0.006 - A)

neari = 0
nearDif = dif(H[0])
for i in range(N):
    #print(i, H[i])#
    idif = dif(H[i])
    if idif<nearDif:
        neari = i
        nearDif = idif
        #print(i, nearDif)
print(neari+1)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int n;
vector<int> p;
vector<int> f;
int ma = 0;
bool bs(int i, int mid, vector<int> tmpp) {
  int cnt = 0;
  if(f[mid] > p[0]) cnt++;
  int pos = 0;
  for(int j=0;j<n-i-1;++j) {
    while(pos == mid || (pos != n-i && f[pos] <= tmpp[j])) {
      pos++;
    }
    if(pos == n-i) break;
    cnt++;
    pos++;
  }
  return cnt == ma;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> n;
  p.clear();
  f.clear();
  p.resize(n);
  f.resize(n);
  for(int i=0;i<n;++i) {
    cin >> p[i];
  }
  for(int i=0;i<n;++i) {
    cin >> f[i];
  }
  vector<int> tmpp = p;
  sort(tmpp.begin(), tmpp.end());
  sort(f.begin(), f.end());
  ma = 0;
  int pos = 0;
  for(int i=0;i<n;++i) {
    while(pos < n && f[pos] <= tmpp[i]) {
      pos++;
    }
    if(pos == n) break;
    ma++;
    pos++;
  }
  vector<int> ans;
  for(int i=0;i<n;++i) {
    tmpp = p;
    tmpp.erase(tmpp.begin());
    sort(tmpp.begin(), tmpp.end());
    auto it = upper_bound(f.begin(), f.end(), p[0]);
    int pos = distance(f.begin(), it);
    int l1 = 0, r1 = pos;
    while(r1 - l1 > 1) {
      int mid = (l1 + r1) / 2;
      if(bs(i, mid, tmpp)) {
        l1 = mid;
      } else {
        r1 = mid;
      }
    }
    int l = l1;
    if(pos < n-i) {
      int l2 = pos, r2 = n - i;
      while(r2 - l2 > 1) {
        int mid = (l2 + r2) / 2;
        if(bs(i, mid, tmpp)) {
          l2 = mid;
        } else {
          r2 = mid;
        }
      }
      if(pos < n - i && bs(i, l2, tmpp)) l = l2;
    }
    if(f[l] > p[0]) ma--;
    ans.push_back(f[l]);
    p.erase(p.begin() + 0);
    f.erase(f.begin() + l);
  }
  printv(ans);
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll x, y;
	cin >> x >> y;
	if (x == y) {
		cout << -1 << endl;
		return 0;
	}
	REP(i, 10000000) {
		if ((x * i) % y != 0) {
			cout << x * i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}



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

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

int main() {

    int N,A,B;
    cin >> N >> A >> B;
    
    int ans = min(N*A,B);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int k;
  cin >> k;
  if(k%2==0 || k%5==0){
    cout << -1 << endl;
    return 0;
  }
  int a=7;
  for(int i=1;i<1000000;i++){
    if(a%k==0){
      cout << i << endl;
      return 0;
    }
    else{
      a=10*(a%k)+7;
    }
  }
  cout << -1 << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n;
  cin>>n;
  vector<string>s(n);
  rep(i,n) cin>>s[i];
  map<string,int>dic;
  int cnt=0;
  rep(i,n)
    dic[s[i]]++;
  for(mp:dic){
    cnt=max(cnt,mp.second);
  }
  for(mp:dic){
    if(cnt==mp.second)
      cout<<mp.first<<endl;
  } 
}


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


int main()
{
        int k;
        cin>>k;
        double d;
        cin>>d;
        int ats=0;
        for(int i=0;i<k;i++){
            long long x;
            long long y;
            cin>>x>>y;
            if(sqrt(x*x+y*y)<=d){
                ats++;
            }
        }
        cout<<ats<<endl;

}


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

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    printf("Possible");
  else
    printf("Impossible");
}


Measured memory_bytes: 256
S = input("")
k = 0
if len(S) % 2 == 1:
    print("No")
else:
    for i in range(0,len(S),2):
        if S[i:i+2] != "hi":
            print("No")
            k = 1
            break
    if k == 0:
        print("Yes")

Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
  int n,count;
  scanf("%d",&n);
  count=n%10;
  
  switch(count)
  {
    case 2:
    case 5:
    case 7:
    case 9:
    case 4:puts("hon");
      		break;
    case 0:
    case 6:
    case 8:
    case 1:puts("pon");
      	break;
    case 3:puts("bon");
      		break;
  }
}

Measured memory_bytes: 1664
<?php
fscanf(STDIN, '%d%d', $H, $W);
for($y = 0; $y < $H; $y++){
    $map[$y] = str_split(fgets(STDIN));
    for($x = 0; $x < $W; $x++){
        if($map[$y][$x] == '#'){
            $list[$y][$x] = 1;
        }
    }
}
$count = 0;
while($list){
    $nextList = [];
    foreach($list as $y => $xs)foreach($xs as $x => $_){
        if($x && $map[$y][$x-1] == '.')$nextList[$y][$x-1] = $map[$y][$x-1] = 1;
        if($y && $map[$y-1][$x] == '.')$nextList[$y-1][$x] = $map[$y-1][$x] = 1;
        if($x < $W - 1 && $map[$y][$x+1] == '.')$nextList[$y][$x+1] = $map[$y][$x+1] = 1;
        if($y < $H - 1 && $map[$y+1][$x] == '.')$nextList[$y+1][$x] = $map[$y+1][$x] = 1;
    }
    $list = $nextList;
    if($list)$count++;
}
echo $count;


Measured memory_bytes: 123384
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from math import *
from heapq import *

def dijkstra(s, edges, INF = 10 ** 20):
    dist = [INF for _ in range(len(edges))]
    dist[s], h = 0, []
    heappush(h, (0, s))
    while (len(h)):
        dv, v = heappop(h)
        if dv > dist[v]:
            continue
        for u, cost in edges[v]:
            if dv + cost < dist[u]:
                dist[u] = dv + cost
                heappush(h, (dist[u], u))
    return dist

K = int(input())
es = [[] for i in range(K)]
for i in range(1, K):
    k = i*10
    for j in range(10):
        es[i].append([(k+j)%K, j])
print(dijkstra(1, es)[0]+1)

Measured memory_bytes: 165400
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, m, X, c[20], a[20][20];
int tmp[20];
void init(){
    n = read(), m = read(), X = read();
    for (int i = 0; i < n; ++i){
        c[i] = read();
        for (int j = 0; j < m; ++j)
            a[i][j] = read();
    }
}
void solve(){
    int ans = INT_MAX;
    for (int i = 0; i < (1 << n); ++i){
        memset(tmp, 0, sizeof(tmp));
        int cc = 0;
        for (int j = 1, t = 0; t < n; ++t, j <<= 1){
            if (j & i){
                cc += c[t];
                for (int u = 0; u < m; ++u)
                    tmp[u] += a[t][u];
            }
        }
        bool flag = true;
        for (int j = 0; j < m; ++j){
            if (tmp[j] < X) {
                flag = false;
                break;
            }
        }
        if (flag) ans = min(ans, cc);
    }
    printf("%d\n", (ans == INT_MAX ? -1: ans));
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>

int main(){
	std::vector<bool> cards;
	for (int i = 0; i < 52; i++){
		cards.push_back(false);
	}
	int n;
	std::cin >> n;
	for (int i = 0;i < n; i++){
		char type;
		int num;
		std::cin >> type >> num;
		switch(type){
			case 'S':
				cards[num-1] = true;
				break;
			case 'H':
				cards[num+13-1] = true;
				break;
			case 'C':
				cards[num+26-1] = true;
				break;
			case 'D':
				cards[num+39-1] = true;
				break;
		}
	}
	for (int i = 0; i < cards.size(); i++){
		if (cards[i] == false){
			switch(i / 13){
				case 0:
					std::cout << "S " << (i%13)+1 << '\n';
					break;
				case 1:
					std::cout << "H " << (i%13)+1 << '\n';
					break;
				case 2:
					std::cout << "C " << (i%13)+1 << '\n';
					break;
				case 3:
					std::cout << "D " << (i%13)+1 << '\n';
					break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3044
N, M = list(map(int, input().split(' ')))
p = []
for ct in range(2, 10000000):
    if M % ct == 0:
        p.append(ct)
        p.append(M//ct)
p.append(M)
# 14 => [1, 2, 7, 14]
# 3, 14 => 2 + 4 + 8 = 14, 2 * (1 + 2 + 4)
# 2. 14 => 7 + 7 ~> 7 * (1 * 1)
# 1, 14 => 14 => 14 * (1)
 
# 12 => [1, 2, 3, 4, 6, 12]
# 3, 12 => 4 + 4 + 4 = 12, 4 * (1 + 1 + 1)
 
# 125 => [1, 5, 25, 125]
# 1, 125 = 125 = 125 * (1)                                          => 125
# 2, 125 = 100 + 25 = 25 * (4 + 1)                                  => 25  (!)
# 3, 125 = 75 + 25 + 25 = 25 * (3 + 1 + 1)                          => 25
# 4, 125 = 50 + 25 + 25 + 25 = 25 * (2 + 1 + 1 + 1)                 => 25
# 5, 125 = 25 + 25 + 25 + 25 + 25 = 25 * (1 + 1 + 1 + 1 + 1)        => 25
# 6, 125 = 25 + 25 + 25 + 25 + 20 + 5 = 5 * (5 + 5 + 5 + 5 + 4 + 1) => 5   (!)
ans = 1
for t in sorted(p):
    if M / N >= t:
        ans = t
print(ans)

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

using namespace std ;
#define int long long int

const int maxn = 1e3 + 5;


int32_t main(){
    //#ifndef ONLINE_JUDGE
      //freopen("input.txt", "r", stdin);
      //freopen("output.txt", "w", stdout);
    //#endif
    int n , K;
    cin >> n >> K;
    vector<int>h(n);
    for(int i =0; i < n ; i++ ) cin >> h[i];
    vector<int>dp(n, 1e9);
    dp[0] = 0;
    for(int i = 1 ; i < n ; i++ ){
        for(int k = 1; k <= K ; k++ ){
            if(i-k >= 0 ){
                dp[i] = min(dp[i], dp[i-k] + abs(h[i]- h[i-k]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  f80 W, H, x, y;
  cin >> W >> H >> x >> y;

  f80 ans1 = W * H / 2;
  cout << ans1 << " ";

  cout << int(W/2==x and H/2==y) << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

char S[MAX_N]; int N, Nt[MAX_N], Pr[MAX_N];
bool Chk[MAX_N]; int Ans;
int main() {
	scanf("%s", S+1); N = strlen(S+1); Ans = N;
	for(int i=1; i<=N; i++) Nt[i] = i+1, Pr[i] = i-1;
	for(int i=1; i<=N; ) {
		if(Chk[i]) continue;
		int a = i, b = Nt[i];
		if(b > N) break;
		if(S[a] == 'S' && S[b] == 'T') {
			Chk[a] = Chk[b] = true;
			Ans -= 2;
			Nt[Pr[a]] = Nt[b];
			Pr[Nt[b]] = Pr[a];
			i = Pr[a];
		}else i = Nt[a];
	}
	printf("%d\n", Ans);
	return 0;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
bool judge(int i,int j,int k){
    if(i==0&&j==1&&k==2)return true;
    return false;
}
int main(){
    vector<vector<vector<vector<ll>>>>dp(110,vector<vector<vector<ll>>>(4,vector<vector<ll>>(4,vector<ll>(4,0))));
    rep(i,4){
        rep(j,4){
            rep(k,4){
                if(judge(i,k,j)||judge(i,j,k)||judge(j,k,i))continue;
                dp[3][i][j][k]++;
            }
        }
    }
    for(int x=3;x<109;x++){
        rep(i,4){
            rep(j,4){
                rep(k,4){
                    rep(l,4){
                        if(judge(i,k,j)||judge(i,j,k)||judge(j,k,i)||judge(i,l,j)||judge(j,l,k)||judge(i,l,k)||judge(k,l,j)||judge(j,k,l))continue;
                        dp[x+1][j][k][l]=(dp[x+1][j][k][l]+dp[x][i][j][k])%mod;
                    }
                }
            }
        }
    }
    ll ans=0;int n;cin>>n;
    rep(i,4){
        rep(j,4){
            rep(k,4){
                ans=(ans+dp[n][i][j][k])%mod;
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");

        double a = Double.parseDouble(input[0]); //??????a
        double b = Double.parseDouble(input[1]);
        double c = Double.parseDouble(input[2]); //?§????c

        double h = b * Math.sin(Math.toRadians(c));
        double S = a * h / 2;
        double L = a + b + Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(c)));

        System.out.print(S + "\n" + L + "\n" + h + "\n");
    }
}

Measured memory_bytes: 24372
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000

int main(){
  int N;
  cin>>N;
  vector<int> D(N);
  for(int i=0;i<N;i++){
    cin>>D.at(i);
  }
  if(D.at(0)!=0){
    cout<<0<<endl;
  }else{
    map<int,int> m;
    int k=0;
    for(int i=0;i<N;i++){
      if(m.count(D.at(i))==0){
        m[D.at(i)]=0;
      }
      m[D.at(i)]++;
      k=max(D.at(i),k);
    }
    if(m[0]>1){
      cout<<0<<endl;
    }else{
      ll ans=1;
      for(int i=1;i<=k;i++){
        for(int j=0;j<m[i];j++){
          ans*=(ll)m[i-1];
          ans%=MOD;
        }
      }
      cout<<ans<<endl;
    }

  }
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
string n;
cin >> n;
for(int i = 0; i < 3; i++){ 
   if(n.at(i) == '1') n.at(i) = '9';
   else n.at(i) = '1';
}
print(n);

}


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

const int NMAX = 100010;
const long long INF = 1LL << 60;

int N, K;
vector<int> H(NMAX);

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> H[i];

    // dp配列を初期化
    vector<long long> dp(NMAX, INF);
    dp[0] = 0;

    // dp配列を緩和
    for (int i = 1; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            if (i >= j) {
                dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]));
            }
        }
    }

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

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

typedef long long ll;

const int MOD = 2019;

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

    int L, R;
    cin >> L >> R;

    int ans = MOD;
    if (R - L + 1 >= MOD) {
        ans = 0;
    } else {
        unordered_map<int, int> mod_cnt;
        for (int i = L; i <= R; ++i) {
            mod_cnt[i % MOD] += 1;
        }

        vector<int> mods;
        for (auto e : mod_cnt) {
            mods.push_back(e.first);
            if (e.second > 1) mods.push_back(e.first);
        }


        int n = mods.size();
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                ans = min(ans, (mods[i]*mods[j]) % MOD);
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

int main(){
    int x,y,z;
    double rad;
    double s,l,h;
    scanf("%d %d %d",&x,&y,&z);
    rad=z*(M_PI/180);
    s=x*y*sin(rad)/2;
    l=x+y+sqrt(x*x+y*y-2*x*y*cos(rad));
    h=y*sin(rad);
    printf("%lf\n%lf\n%lf\n",s,l,h);
    return 0;
}


Measured memory_bytes: 2940
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64, m: u64, d: u64
    }
    let nf = n as f64;
    let mf = m as f64;
    let df = d as f64;
    let e = if d == 0 {
        1.0 / nf
    } else {
        2.0 * (nf - df) / nf / nf
    };
    println!("{}", e * (mf - 1.0));
}


Measured memory_bytes: 4352
k = int(input())
a = list(map(int, input().split()))

child = 2
cmin = 2
cmax = 2
for ai in a[::-1]:
    if cmin % ai:
        cmin = (cmin // ai + 1) * ai
    cmax = cmax // ai * ai + ai - 1
    if cmin > cmax:
        print(-1)
        exit()

print(cmin, cmax)


Measured memory_bytes: 14228
a, b = map(int, input().split())
def gcd(a, b):
    '''ユークリッド互除法を使った最大公約数の求め方'''
    while b != 0:
        a, b = b, a % b
    return(a)
 
def lcm(a, b):
    '''最小公倍数の求め方'''
    return a * b // gcd(a, b)
print(lcm(a, b))

Measured memory_bytes: 2940