akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;
const int M = 1e5;
int ar[M][3];
ll sum[M][3];

ll dp(int i, int lc){
    if(i == 0){
        if(lc == 0) return ar[0][0];
        else if(lc == 1) return ar[0][1];
        else return ar[0][2];
    }
    if(sum[i][lc] != -1) return sum[i][lc];
    if(lc == 0){
        sum[i][0] = ar[i][0] + max(dp(i-1,1),dp(i-1,2));
        return sum[i][0];
    }
    else if(lc == 1) {
       sum[i][1] = ar[i][1] + max(dp(i-1,0), dp(i-1,2));
        return sum[i][1];
    }
    else {
        sum[i][2] = ar[i][2] + max(dp(i-1,1), dp(i-1,0));
        return sum[i][2];
    }

}

int main() {FIN;
    int n;
    cin >> n;
    fore(i,n,M) {ar[i][0]=0 ; ar[i][1]=0; ar[i][2]=0;}
    fore(i,0,M) {sum[i][0]=-1 ; sum[i][1]=-1; sum[i][2]=-1;}
    fore(i,0,n) cin >> ar[i][0] >> ar[i][1] >> ar[i][2];
    sum[0][0]=ar[0][0],sum[0][1]=ar[0][1],sum[0][2]=ar[0][2];
    dp(n-1,0);
    dp(n-1,1);
    dp(n-1,2);
    int m = max(sum[n-1][0], max(sum[n-1][1], sum[n-1][2]));
    cout << m;
    return 0;
}



Measured memory_bytes: 8448
n,m = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
y = list(map(int, input().split(' ')))

x = [x[i+1]-x[i] for i in range(len(x)-1)]
y = [y[i+1]-y[i] for i in range(len(y)-1)]

total_x =0
for i in range(n-1):
    buf = min([i+1,n-1-i])
    buf = buf*(n-1)-buf*buf+buf
    total_x += x[i]*buf
    total_x %= 1000000007


total_y =0
for i in range(m-1):
    buf = min([i+1,m-1-i])
    buf = buf*(m-1)-buf*buf+buf
    total_y += y[i]*buf
    total_y %= 1000000007

print(total_x*total_y%1000000007)


Measured memory_bytes: 18576
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;
int main()
{
    int r, d, x;

    cin >> r >> d >> x;


    for (int i = 0; i < 10; i++) 
  {
        x = r * x -d;
        cout << x << endl;
    }

    return 0;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    u32 N, M;
    cin >> N >> M;
    Vec<u64> H(N + 1);
    for (u32 i = 1; i <= N; i++) cin >> H[i];
    Vec<u64> MH(N + 1, 0);
    for (int i = 0; i < M; i++) {
        u32 A, B;
        cin >> A >> B;
        MH[A] = max(H[B], MH[A]);
        MH[B] = max(H[A], MH[B]);
    }
    u32 sum = 0;
    for (int i = 1; i <= N; i++) {
        sum += H[i] > MH[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 4720
import heapq
from collections import defaultdict

dict = defaultdict(list)
n,m = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    dict[a].append(b)

h = []
ans = 0
for i in range(1,m+1):
    for j in dict[i]:
        heapq.heappush(h,-j)
    if len(h) > 0:
        ans += heapq.heappop(h)*(-1)

print(ans)

Measured memory_bytes: 27800
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int D;
	cin >> D;

	string rsl = "Christmas";
	rep(i, 0, 25 - D) rsl += " Eve";
	cout << rsl << endl;
}


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

  int n; cin >> n;
  int nn = 0;
  bool ans = true;
  for(int i = 0; i < n; i++){
    int h; cin >> h;
    nn = max(nn,h);
    if(h < nn - 1){ans = false;}
  }
  if(ans == true){cout << "Yes" << endl;}
  else {cout << "No" << endl;}
  
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define n_max 55

int main(){
    int n,a;
    cin >> n >> a;
    int X[n_max];
    REP(i,n){
        cin >> X[i+1];
        X[i+1] -= a;
    }

    llong dp[n_max][53*n_max];
    REP(i,n_max) REP(j,53*n_max) dp[i][j]=0;
    dp[0][2500] = 1;
    FOR(i,1,n+1){
        int x = X[i];
        REP(j,50*n_max){
            dp[i][j] = dp[i-1][j-x] + dp[i-1][j];
        }
            
    }
    cout << dp[n][2500] -1<< endl;


}

Measured memory_bytes: 1536
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
typedef long long llong;
using namespace std;
const llong DIV = 1000000007;

int main(){
  llong Q;
  cin>>Q;
  llong f_b = 0;
  priority_queue<llong,priority_queue<llong>::container_type , greater<llong>> rlower;
  priority_queue<llong> lhigher;
  int size = 0;
  vector<llong> as;
  llong prev_ans =-1;
  llong prev_val =-1;
  int not_updated = 1;
  llong s = 0;
  for (int i=0;i<Q;i++){
    llong c,a,b;
    cin>>c;
    if(c==1){
      not_updated = 0;
      cin>>a>>b;
      as.push_back(a);
      f_b += b;
      if(lhigher.size()==0 || a <= lhigher.top()){
        
        lhigher.push(a);
        s += lhigher.top()-a;
        if (lhigher.size()-rlower.size()>=2){
          rlower.push(lhigher.top());
          lhigher.pop();
        }
      }else{
        rlower.push(a);
        s+= a- lhigher.top();
        if (rlower.size()> lhigher.size()){
          s+= lhigher.top()-rlower.top();
          lhigher.push(rlower.top());
          rlower.pop();
        }
      }
    }else{
      std::cout<< lhigher.top()<<" "<<(s+f_b)<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 4972
package main

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

func main() {
	sc := NewScanner()
	S := sc.NextLine()

	ans := ""
	for _, v := range S {
		switch v {
		case 'b':
			ans = "d" + ans
		case 'd':
			ans = "b" + ans
		case 'p':
			ans = "q" + ans
		case 'q':
			ans = "p" + ans
		}
	}
	if S == ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}




Measured memory_bytes: 16000
n,m=map(int,input().split())
xyz=[list(map(int,input().split()))for _ in range(n)]
def f(fx,fy,fz):
  t=[]
  for x,y,z in xyz:t.append(x*fx+y*fy+z*fz)
  t.sort(reverse=1)
  return sum(t[:m])
ans=0
ans=max(ans,f(1,1,1))
ans=max(ans,f(1,1,-1))
ans=max(ans,f(1,-1,1))
ans=max(ans,f(1,-1,-1))
ans=max(ans,f(-1,1,1))
ans=max(ans,f(-1,1,-1))
ans=max(ans,f(-1,-1,1))
ans=max(ans,f(-1,-1,-1))
print(ans)

Measured memory_bytes: 3316
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN [IUT CSE(SWE)-19]
 
#include<bits/stdc++.h>
using namespace std;
 
#define fastio          ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define read            freopen("blue.txt","r",stdin);
#define write           freopen("red.txt","w",stdout);
 
using ll=long long;
using ull=unsigned long long;
const double pi = 2*acos(0.0);
 
int  main()
{
 
    fastio;
 
    int x,n;
    cin>>x>>n;
 
    int a[n+1];
 
    map<int,int>mp;
 
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
 
    int min=99999999;
    int p,q;
    for(int i=0; i<=x ;i++)
    {
        if(mp[i]>0)
            continue;
        int r=abs(x-i);
        if(r<=min)
        {
            p=i;
            min=r;
        }
    }
    min=9999999;
     for(int i=101; i>x ;i--)
    {
        if(mp[i]>0)
            continue;
        int r=abs(x-i);
        if(r<=min)
        {
            q=i;
            min=r;
        }
    }
    if(abs(p-x)==abs(q-x))
        cout<<p<<endl;
    else if(abs(p-x)<abs(q-x))
         cout<<p<<endl;
         else
            cout<<q;
 
 
    return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)1e5 + 3;
const int MOD = (int)1e9 + 7;
vector<int> T[N];

int k;
int res = 1;

void mult(int a){
    a = max(0, a);
    res = (res * 1ll * a) % MOD;
}

void dfs(int u, int pr, int take){
    mult(k - take);
    take = 1;
    if(pr != -1) take ++ ;
    for(auto x : T[u]){
        if(x == pr) continue;
        dfs(x, u, take);
        take ++ ;
    }
}

int main(){
    fastIO;
    int n;
    cin >> n >> k;
    int a, b;
    for(int i = 1; i < n; i ++ ){
        cin >> a >> b;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    dfs(1, -1, 0);
    cout << res;
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
  int a,m=0,s=0;
  rep(i,0,3){
    cin>>a;
    s+=a;
    if(m<a) m=a;
  }
  cout<<s+9*m;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
#define prl cerr<<"called: "<< __LINE__ << endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 2020;
const int M = 1e9 + 7;
// long long?

ll fat[N],inv[N];
ll C(int n,int k){
  if(k>n)return 0;
  return mod(fat[n]*mod(inv[k]*inv[n-k],M),M);
}

void init(){
  fat[0] = inv[0] = 1;
  for(int i=1;i<N;i++){
    fat[i] = (1LL*fat[i-1]*i)%M;
  }
  inv[N-1] = exp(fat[N-1],M-2,M);
  for(int i=N-2;i>=0;i--){
    inv[i] = (inv[i+1]*(i+1))%M;
  }
}
int32_t main(){
  fastio;
  init();
  int S;
  cin >> S;
  ll cur=0;
  for(int k=1;k<=S;k++){
    int tem = k*3;
    if(tem > S)break;
    int need = S - tem;
    cur = mod(cur + C(need + k - 1, need),M);
  }
  cout << cur << endl;
  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3688
import java.util.*;
public class Main {
    public static void main(String[] args){
    
        Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashSet<Integer> a = new HashSet<>();
		int A = 0;
		
		for(int i = 0; i < N; i++) {
			A=sc.nextInt();
			a.add(A);
		}
		
		if(a.size() == N) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
    }
}

Measured memory_bytes: 69964
List=[list(map(int,input().split())) for i in range(4)]

a=sum(List[2])
b=int(len(List[1]))

for i in range(b-1):
  if List[1][i+1]-List[1][i] == 1:
    a+=List[3][List[1][i]-1]

print(a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int p,q,r;
  cin >>p>>q>>r;
  
  int pq,qr,rp;
  pq=p+q;
  qr=q+r;
  rp=r+p;
  
  int tmp;
  tmp = min(pq,qr);
  cout <<min(tmp,rp)<<endl;
}

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

public class Main {
    public static void main(String args[]) throws IOException{
        process();
    }
    public static void process() throws IOException{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(in.readLine());
        int arr[]=new int[n];
        int dp[]=new int[n];
        StringTokenizer st=new StringTokenizer(in.readLine()," ");
        for(int i=0;i<n;i++)
            arr[i]=Integer.parseInt(st.nextToken());
        dp[0]=0;
        dp[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<n;i++)
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 33368
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
#define LL long long
const int MaxN = 1e5 + 7;
LL a[MaxN], b[MaxN];
LL x[MaxN], v[MaxN];

int main()
{
    LL n, c;
    scanf("%lld %lld", &n, &c);
    for(int i = 1; i <= n; i++)
        scanf("%lld %lld", &x[i], &v[i]);

    for(LL i = 1; i <= n; i++)
        a[i] = a[i - 1] + v[i] - (x[i] - x[i - 1]);  // 顺时针走到i点时的能量
    x[n + 1] = c;
    for(LL i = n; i >= 1; i--)
        b[i] = b[i + 1] + v[i] - (x[i+1] - x[i]);  // 逆时针走到i点时的能量

    for(LL i = 2; i <= n; i++)
        a[i] = max(a[i-1], a[i]);  //走或者不走（和走之前的值进行比较）
    for(LL i = n-1; i >= 1; i--)
        b[i] = max(b[i], b[i + 1]);

    LL ans = max(0LL,max(a[n],b[1]));
    for(LL i = 1; i <= n; i++) {
        ans = max(ans, a[i] - x[i] + b[i + 1]);  // 顺时针走后并返回一次的值
        ans = max(ans, b[i] - (c - x[i]) + a[i - 1]);  // 逆时针走后返回一次的值
        //ans = max(ans, a[i]);  // 顺时针的最大值
        //ans = max(ans, b[i]); //逆时针的最大值
    }

    printf("%lld\n", ans);
}


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

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << (x) << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

const int N = 307, inf = 1e9;
int n, k, f[N][N][N];
char s[N];
bool v[N][N][N];

int F(int l, int r, int k) {
	if (k < 0) return -inf;
	if (r - l < 1) return r - l + 1;
	if (v[l][r][k]) return f[l][r][k];
	v[l][r][k] = 1;
	return f[l][r][k] = max(max(F(l + 1, r, k), F(l, r - 1, k)), F(l + 1, r - 1, k - (s[l] != s[r])) + 2);
}

int main() {
	rds(s, n), rd(k), print(F(1, n, k));
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){

	llong n, R, T;
	cin>> n >> R >> T;
	
	vector<llong> v(n);
	for(int i = 0; i < n; ++i){
		cin >> v[i];
	}


	int pos[1000] = {}, water[1000] = {}, emp1[1000] = {}, emp2[1000] = {};
	for(int i = 0; i < n; i++) pos[i] = v[i];
	for(int t = 1; t <= T; ++t){
		int tmp = 0;

		for(int i = 0; i < R; ++i){
			if(t % 2 == 0){
				water[i] += emp1[i];
				emp1[i] = 0;
			}else{
				water[i] += emp2[i];
				emp2[i] = 0;
			}
			//tmp += water[i];
		}

		//cout << tmp << endl;
		for(int i = 0; i < n; ++i){
			if(water[pos[i]] > 0){
				water[pos[i]]--;
				pos[i] = (pos[i] + v[i]) % R;
				if(t % 2 == 0)
					emp1[pos[i]]++;
				else
					emp2[pos[i]]++;
			}else{
				pos[i] = (pos[i] + v[i]) % R;
				if(t % 2 == 0)
					emp1[pos[i]]++;
				else
					emp2[pos[i]]++;
			}
		}
	}

	llong ans = 0;
	for(int i = 0; i < R; ++i){
		ans += water[i] + emp1[i] + emp2[i];
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3108
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(defun is-numeric (x)
  (and (char<= #\0 x) (char<= x #\9)))

(let ((a (read))
	  (b (read))
	  (s (read-line)))
  (princ
	(if (and
		  (char= (aref s a) #\-)
		  (every #'is-numeric (subseq s 0 a))
		  (every #'is-numeric (subseq s (1+ a))))
	  "Yes"
	  "No")))


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10 , OO = 0x3f3f3f3f ;
const int mod = 1e9 + 7;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

ll a;
int ba , bb;

int main()
{
   // startTime = (double)clock();
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
        //freopen("out.in", "w", stdout);
    #endif
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    

    scanf("%lld %d.%d" , &a , &ba, &bb);
    int b = (ba * 100) + bb;
    ll ans = (a * b) / 100;
    printf("%lld\n" , ans);


    return 0;
}

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

//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << p.first << " " << p.second;return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if (it != v.begin())os << " ";os << *it;
  }return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void print(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void print(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


//DFS: 全ての点から深さ優先探索して、その帰りがけ順
class TopologicalSort{
public:
	int n;
	vector<int> ans, used;
	vector<vector<int> > G;
	void init(int N){
		n = N;
		used.resize(n);G.resize(n);
	}
	void add_edge(int from, int to){	//DAG
		G[from].pb(to);
	}
	void dfs(int v){
		if(used[v])return;
		used[v] = 1;
		for(int u: G[v])dfs(u);
		ans.pb(v);
	}
	bool sort(){
		rep(i,n)dfs(i);
		reverse(all(ans));
		return ans.size() == n;		//できなかった場合falseが返る
	}
};


int v[200];
vector<int> rec[200];
map<string, int> zip;
void init(){
	rep(i,200)v[i] = 0;
	rep(i,200)rec[i].resize(0);
	zip.clear();
}

signed main(){
	while(1){
		int n, m;
		cin >> n;
		if(n == 0)break;
		init();
		TopologicalSort T;T.init(n);
		rep(i,n){
			string str;int tmp;
			cin >> str >> tmp;
			zip[str] = i;v[i] = tmp;
		}
		cin >> m;
		rep(i,m){
			string str1, str2;int N;
			cin >> str1;cin >> N;
			rep(j,N){
				cin >> str2;
				T.add_edge(zip[str2], zip[str1]);
				rec[zip[str1]].pb(zip[str2]);
			}
		}
		
		T.sort();
		vector<int> order = T.ans;
		rep(i,n){
			int sum = 0, idx = order[i];
			if(rec[idx].size() == 0)continue;
			rep(j,rec[idx].size()){
				int r = rec[idx][j];
				sum += v[r];
			}
			chmin(v[idx], sum);
		}
		string t;cin >> t;
		cout << v[zip[t]] << endl;
		
	}
	return 0;
}







Measured memory_bytes: 3036
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <stdbool.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <chrono>
using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    int p = 0;

    for (int i=0; i<n; i++) {
        int l;
        cin >> l;
        p += l;
        if ( p > x ) {
            cout << i+1 << endl;
            break;
        }
        if ( i == n-1 ) {
            cout << n+1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
/*
Author: Sanskar Agarwal
Nick: sanskarag
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second

int main()
{
    fast
    int k,a,b;
    cin>>k>>a>>b;
    int c= a/k;
    if(k*c<a)
        c++;
    if(k*c<=b)
        cout<<"OK"<<endl;
    else 
        cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3652
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int A,B;
    private void solve() {
        A = nextInt();
        B = nextInt();

        int ans = 0;
        if (A > B) {
            ans = 2 * A - 1;
        } else if (A < B) {
            ans = 2 * B - 1;
        } else {
            ans = A + B;
        }
        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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


int main(){
  int n,m,c;
  cin >> n >> m >> c;
  VI b(m);
  VVI a(n,VI(m));
  rep(i,m) cin >> b[i];
  rep(i,n){
    rep(j,m){
      cin >> a[i][j];
    }
  }
  ll sum = 0,ans = 0;
  rep(i,n){
    sum = 0;
    rep(j,m){
      sum += a[i][j]*b[j];
    }
    if(sum + c > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX=5e5+5;
bool a[MAX];


int main()
{
        LL a,b;
        cin>>a>>b;
        if(a>=13)
        {
                cout<<b<<endl;
        }
        else if(a>=6 && a<=12)

        {
              cout<<b/2<<endl;  
        }
        else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <iomanip>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;

int main() {
	int D;
	std::cin >> D;
	if (D == 25) {
		std::cout << "Christmas" << std::endl;
	}
	else if (D == 24) {
		std::cout << "Christmas Eve" << std::endl;
	}
	else if (D == 23) {
		std::cout << "Christmas Eve Eve" << std::endl;
	}
	else if (D == 22) {
		std::cout << "Christmas Eve Eve Eve" << std::endl;

	}
}

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

int main() {
  string w; cin >> w;
  map<char,int> m;
  for (auto wi : w) {
    m[wi]++;
  }
  string ans = "Yes";
  for (auto mi : m) {
    if (mi.second % 2 == 1) {
      ans = "No";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+2,0);
    for(int i=1;i<=N;i++) cin >> A[i];

    vector<int> S;
    int sum = 0;
    for(int i=1;i<=N+1;i++){
        S.push_back(abs(A[i]-A[i-1]));
        sum += S[i-1];
    }

    vector<int> ans;
    for(int i=1;i<=N;i++){
        ans.push_back(sum+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])));
    }

    for(int x : ans){
        cout << x << endl;
    }
}


Measured memory_bytes: 2552
#include<stdio.h>
 
void main(void)
{
  int n,k,x[101],i,ans=0;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++)
    {
      scanf("%d",&x[i]);
      if(k-x[i] < x[i])
	{
	  ans += (k-x[i]) * 2;
	}
      else
	{
	  ans += x[i] * 2;
	}
    }
  printf("%d\n",ans);
  int ret = 0;
  ret = ret * 414;
  __asm__("mov $0x0,%rax");
}

Measured memory_bytes: 128
n = int(input())
w = []
ng = 0

for i in range(n):
    w.append(input())

for i in range(1,n):
    if w[i-1][-1] != w[i][0]:
        ng += 1
        break
    if w.count(w[i-1]) > 1:
        ng += 1
        break

if ng > 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iostream>
#include<iterator>
int main()
{
	long long int n, k, x, sum = 0;
	std :: cin >> n >> k;
	std :: vector<long long int> h;
	std :: vector<long long int> :: iterator it;
	for(long int i = 0 ; i < n; i++)
	{
		std :: cin >> x;
		h.push_back(x);
	}
	std :: sort(h.begin(), h.end(), [](long long int x, long long int y){return x < y;});
	it = h.end()-1;
	if(n <= k)
		std :: cout << "0";
	else
	{
		for(long long int i = 0; i < k; i++)
		{
			h.erase(it);
			it--;
		}
		for(long long int i = 0; i < h.size(); i++)
		{
			sum = sum + h[i];
		}
		std :: cout << sum;
	}
}

Measured memory_bytes: 4860
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t N;
  cin >> N;
  unordered_set<string> goods;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    goods.emplace(s);
  }
  cout << goods.size() << endl;
  return 0;
}



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

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

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

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  int ans = -1;
  for (int i = 1; i*i <= m; ++i) {
    if (m%i) continue;
    if (m/i >= n) ans = max(ans, i);
    if (i >= n) ans = max(ans, m/i);
  }
  printf("%d", ans); 
}

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


Measured memory_bytes: 256
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto size = readln.chomp.to!int;
  auto lucky = cast(byte[])readln.chomp;
  lucky[] -= '0';

  void solve() {
    int count;
    bool[byte] ava;
    foreach(a; lucky) ava[a] = true;

    foreach(x; ava.keys) foreach(y; ava.keys) foreach(z; ava.keys) {
      auto after = lucky.findSplitAfter([x]);
      if (!after[1].canFind(y)) continue;
      after = after[1].findSplitAfter([y]);
      if (!after[1].canFind(z)) continue;
      count++;
    }
    writeln(count);
  }

  solve();
}


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

lli apSum(lli a1, lli n, lli q)
{
  return (a1+a1+(n-1)*q)*n / 2LL;
}

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

  lli ans = apSum(1, n - 1, 1);
  printf("%lld\n", ans);

  return(0);
}

Measured memory_bytes: 256
def grouping(data, n):
  return _grouping(data, n, 0)
  
    
def _grouping(data, n, c):
  if c==len(data):
    return [tuple([] for _ in range(n))]
  else:
    tg = data[c]
    b  = _grouping(data, n, c+1)
    a  = [] 
    for i in range(n):
      for t in b:
        a.append(tuple(e + [tg] if idx==i else e for idx, e in enumerate(t)))
    return a

n, a, b, c = map(int, input().split(" "))
reqs = (a, b, c)
ls = [int(input()) for _ in range(n)]
gr = filter(lambda x: len(x[0])!=0 and len(x[1])!=0 and len(x[2])!=0, grouping(ls, 4))
print(min(sum(10*(len(es)-1) + abs(sum(es)-r)for es, r in zip(t, reqs))for t in gr))

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;


int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> gri(n);
    for(int i=0; i<n; i++){
        cin >> gri[i];
    }
    int xx[] = {1, -1, 0, 0};
    int yy[] = {0, 0, 1, -1};
    queue<pi> qu;
    int dis[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(gri[i][j] == '#'){
                qu.push({i, j});
                dis[i][j] = 0;
            }
        }
    }
    while(!qu.empty()){
        pi u = qu.front();
        qu.pop();
        int x = u.first;
        int y = u.second;
        for(int i=0; i<4; i++){
            int gx = x+xx[i];
            int gy = y+yy[i];
            if(gx<n && gx>=0 && gy>=0 && gy<m && gri[gx][gy] == '.'){
                dis[gx][gy] = dis[x][y]+1;
                gri[gx][gy] = '#';
                qu.push({gx, gy});
            }
        }
    }
    int mx = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            mx = max(mx, dis[i][j]);
        }
    }
    cout << mx << "\n";

    return 0;
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, d, x;

double f(int n) {
    if (n == 1)
        return 1;
    return 1 + f(n - 1) * (2.0 * n + 2.0) / (2.0 * n);
}

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N >> d >> x;
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    cout << f(N) * (d + (2 * N - 1) / 2.0 * x) << endl;

    solve();
    return 0;
}


Measured memory_bytes: 6920
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0

def gcd(a, b):
    # 大きい方を被除数、小さい方を除数とする
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    # 最大公約数を見つけるまで繰り返す
    while dividend % divider != 0:
        # 除算を行い、その除数を次回の被除数、剰余を次回の除数として処理を繰り返す
        r = dividend % divider
        dividend = divider
        divider = r

    # 一方がもう一方を割り切れた時点で、その除数を最大公約数とみなせる
    return divider


def lcm(a, b):
    return (a * b) // gcd(a, b)

def modinv(x):
    return pow(x, mod-2, mod)

b = list(set(a))
# for i in range(n):

# L = reduce(lcm, a)
L = reduce(lcm, b)

# print(L)

for i in range(n):
    # ans += (L // a[i])
    ans += L * modinv(a[i])

print(ans % mod)

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

int main() {
  int K;
  int N;
  cin >> K >>N;
  vector<int>A(N);
  int a=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N-1;i++){
    a = max(a,A.at(i+1)-A.at(i));
  }  
    a = max(a,K-A.at(N-1)+A.at(0));
	cout<< K-a << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  rep(i,365){
    cout<<rand()%26+1<<endl;
  }
}


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

int main() {
    int a, b; cin >> a >> b;
    if (a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if (a > 0) cout << "Positive" << endl;
    else {
        int num = b - a + 1;
        if (num % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
vector<int> g[100005];

bool ans;
bool dfs(int v,int p){
  int ch=0,win=0;
  for(auto to:g[v]){
    if(to==p) continue;
    if(dfs(to,v)) ++win;
    ++ch;
  }
  if(win==0){
    return true;
  }else if(win>=2){
    ans=true;
    return true;
  }else{
    return false;
  }
}
int main(){
  cin>>n;
  REP(i,n-1){
    int a,b;scanf("%d%d",&a,&b);--a;--b;
    g[a].pb(b);
    g[b].pb(a);
  }
  if(n>2){
    int r=0;
    REP(i,n) if(g[i].size()>1) r=i;
    dfs(r,-1);
  }
  if(ans){
    puts("First");
  }else{
    puts("Second");
  }

  return 0;
}





Measured memory_bytes: 5888
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n;
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

ll dp[60][60][3000];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a;
  cin>>n>>a;
  vector<int> x(n);
  rep(i,n) cin>>x[i];
  dp[0][0][0]=1;
  rep(i,n)rep(j,i+10)rep(k,3000){
    if(j>=1 && k>=x[i]) dp[i+1][j][k]=dp[i][j][k]+dp[i][j-1][k-x[i]];
    else dp[i+1][j][k]=dp[i][j][k];
  }
  ll ans=0;
  rep(j,n+1) ans+=dp[n][j][a*j];
  cout<<ans-1<<endl;
}

Measured memory_bytes: 72192
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(),v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p,a,b) for(ll p=a ; p<b ; p++)
#define F first
#define S second
using namespace std;

typedef vector <int> vi;
typedef pair< int, int > pii;


int main()
{
    ll t,i,j,k,ans,n;

    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        if (n%2)cout<<n*2;
        else cout<<n;
    }
    
    return 0;
}


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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << b / c - (a > 0 ? (a - 1) / c : -1) << endl;

    return 0;
}


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

const long long int M=1e9+7;

int main()
{
    int N;
    while(cin>>N)
    {
        int a[1010];
        memset(a,0,sizeof(a));
        for(int i=2;i<=N;i++)
        {
            int t=i;
            while(t!=1)
            {
                for(int j=2;j<=t;j++)
                {
                    if(t%j==0)
                    {
                        a[j]++;
                        t/=j;
                        break;
                    }
                }
            }
        }
        long long sum=1;
        for(int i=2;i<=N;i++)
        {
            sum*=a[i]+1;
            sum%=M;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  int cnt = 0;
  for(int i = A; i <= B; ++i){
    if(i%10 == i/10000){
      int tmp1 = i/10;
      int tmp2 = i/1000;
      if(tmp1%10 == tmp2%10) cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  string A,B;
  cin >> A >> B;
  int a = A.size();
  int b = B.size();
  if(a > b){
    cout << "GREATER" << endl;
    return 0;
  }
  if(a < b){
    cout << "LESS" << endl;
    return 0;
  }
  rep(i,a){
    if(A[i] > B[i]){
      cout << "GREATER" << endl;
      return 0;
    }
    if(A[i] < B[i]){
      cout << "LESS" << endl;
      return 0;
    }
  }
  cout << "EQUAL" << endl;
}

Measured memory_bytes: 256