akhauriyash/Code-Regression huggingface dataset:
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=200;
int n,a[N];

VI sol;
void go( int k ) {
    sol.PB(k);
    REP1(i,k,n-1) swap(a[i],a[i-k]);
    // dump(VI(a,a+n));
}

void main() {
    R(n);
    REP(i,n) R(a[i]);
    while ( !is_sorted(a,a+n) ) {
        if ( a[0] && a[0]<a[n-1] ) go(n-1);
        go(1);
        // if ( SZ(sol)>20 ) break;
    }
    W(SZ(sol));
    for ( int i:sol ) W(i);
    dump(SZ(sol));
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


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

using namespace std;

#define ll long long

int main() {
    int n, q, a, t, x;
    cin >> n >> q;
    vector< priority_queue<ll> > que(n);
    while (q--) {
        cin >> a;
        switch (a) {
            case 0:
                cin >> t >> x;
                que[t].push(x);
                break;
            case 1:
                cin >> t;
                if (!que[t].empty())
                    cout << que[t].top() << endl;
                break;
            case 2:
                cin >> t;
                if (!que[t].empty())
                    que[t].pop();
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 5084
#include<bits/stdc++.h>
using namespace std;
const int N = 505;
int x[N*N], y[N*N];
int n;
 
int d[N][N];
bool del[N][N];
const int xx[4]={1,0,-1,0};
const int yy[4]={0,1,0,-1};
 
void extend(int x,int y){
	// cout << x << " " << y << ":" << d[x][y] << endl;
	for(int i=0;i<4;i++){
		int nx=x+xx[i], ny=y+yy[i];
		int nd=d[x][y]+1-del[nx][ny];
		if(d[nx][ny]>nd){
			d[nx][ny]=nd;
			extend(nx,ny);
		}
	}
}
 
int main()
{
	cin >> n;
	for(int i=1;i<=n*n;i++){
		int p;scanf("%d",&p);
		x[i] = (p+n-1)/n,y[i] = p-(x[i]-1)*n;
		// cout << x[i] << ":" << y[i] << endl;
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)d[i][j]=min(min(i,j),min(n-i+1,n-j+1));
	int ans=0;
	for(int i=1;i<=n*n;i++){
		ans+=d[x[i]][y[i]]-1;
		del[x[i]][y[i]]=1;
		for(int j=0;j<4;j++){
			int nx=x[i]+xx[j],ny=y[i]+yy[j];
			d[x[i]][y[i]] = min(d[x[i]][y[i]], d[nx][ny]);
		}
		extend(x[i],y[i]);
		
	}
	cout << ans << endl;
}

Measured memory_bytes: 22332
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    ret = 1
    p = 10**9+7
    for i in range(k, n+1):
        ret += (n+(n-i+1))*i//2
        ret -= (i*(i-1)//2-1)
        ret %= p

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9200
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

if sum(A) < sum(B):
    print(-1)
    exit(0)

t = 0
m = 0
L = []
for k in range(N):
    if A[k] > B[k]:
        L.append(A[k]-B[k])
    else:
        m += B[k] - A[k]
        t += 1

if m == 0:
    print(0)
    exit(0)

L = (sorted(L))[::-1]
for e in L:
    m -= e
    t += 1
    if m <= 0:
        break
print(t)

Measured memory_bytes: 82224
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
signed main() {
	int a, b;
	cin >> a >> b;
	cout << a / gcd(a, b) * b << endl;
}

Measured memory_bytes: 256
def nums(n)
  return n - (n / 3) - (n / 5) + (n / 15)
end
def calc(n)
  res = 0
  res = res + (n / 3) * 4
  res = res + (n / 5) * 4
  bs = 1
  k = 1
  while bs * 10 < n
    res = res + (nums(bs*10-1)-nums(bs-1)) * k 
    bs = bs * 10
    k = k + 1
  end
  res = res + (nums(n)-nums(bs-1)) * k 
  return res
end

s = gets.to_i - 1
l = 0
r = 100000000000000000000
while l + 1 < r
  m = (l + r) / 2
  if calc(m) <= s
    l = m
  else
    r = m
  end
end
a = ""
for i in l+1..(l+100)
  if i % 3 == 0
    a = a + "Fizz"
  end
  if i % 5 == 0
    a = a + "Buzz"
  end
  if i % 3 != 0 && i % 5 != 0
    a = a + i.to_s
  end
end

puts a[s - calc(l),20]

Measured memory_bytes: 8764
n, m = gets.split.map(&:to_i)

a = []
n.times do
  a << gets.split.map(&:to_i)
end

b = []
m.times do
  b << gets.to_i
end

c = []
n.times do |n_i|
  cdx = 0
  m.times do |m_i|
    cdx += a[n_i][m_i] * b[m_i]
  end
  c << cdx
end

c.each do |v|
  puts v
end



Measured memory_bytes: 6996
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = 10*a+b+c;
    int tmp = 10*b+a+c;
    if(tmp > ans) ans = tmp;
    tmp = 10*c+a+b;
    if(tmp > ans) ans = tmp;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// 0308
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

bool dislike[10];

bool ok(int n) {
    while(n) {
        if(dislike[n % 10]) return false;
        n /= 10;
    } 
    return true;
}
 
int32_t main()
{
    fast;
    int n, k; cin >> n >> k;
    For(i, 0, k) {
        int d; cin >> d;
        dislike[d] = true;
    }

    for(int i = n; ; ++i) {
        if(ok(i)) {
            cout << i << "\n";
            break;
        }
    }


    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    long long int n,k,i=1;
    cin>>n>>k;
    if(n==k)
    {
        cout<<"2";
        return 0;
    }
    if(n<k)
    {
        cout<<"1";
        return 0;
    }
    while(n>pow(k,i))
    {
        i++;
        if(n<pow(k,i))
        {
            cout<<i;
            return 0;
        }
        if(n==pow(k,i))
        {
            cout<<i+1;
            return 0;
        }
    }
}

Measured memory_bytes: 3984
#include<iostream>
#include<stdio.h>
const int nn = 10;
int a[nn];
using namespace std;
bool dfs()
{
	int left = -1;
	int right = -1;
	
	int T = 0;
	while (T<nn)
	{
		if (right < a[T])
		{
			right = a[T++];
			continue;
		}
		if (left < a[T])
		{
			left = a[T++];
			continue;
		}
		return false;
	}
	return true;
}
int main()
{
	//freopen("in.txt", "r", stdin);
	int N;
	scanf("%d", &N);
	while (N--)
	{
		for (int i = 0; i < nn; i++)
			scanf("%d", &a[i]);
		if (dfs())
			printf("YES\n");
		else
			printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 1168
from math import ceil

n = int(input())
c = []
s = []
f = []
for _ in range(n-1):
    i, j, k = [int(i) for i in input().split()]
    c.append(i)
    s.append(j)
    f.append(k)

for i in range(n):
    if i != n-1:
        time = 0
        for k in range(i, n-1):
            if time < s[k]:
                time += s[k] - time
            else:
                time += s[k] + ceil((time-s[k])/f[k])*f[k] - time
            time += c[k]
        print(time)
    else:
        print(0)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll d; cin>>d;
    vl cs(26); cin>>cs;
    vvl ss(d, vl(26)); cin>>ss;
    vl ts(d);
    rep(i, d) {
        ll t; cin>>t; t--;
        ts[i] = t;
    }

    ll ans = 0;
    vl last(26, -1);
    rep(i, d) {
        ans += ss[i][ts[i]];
        last[ts[i]] = i;
        rep(j, 26) {
            ans -= cs[j] * (i - last[j]);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3736
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] S ={ sc.next(), sc.next(), sc.next()};
        
        int i = 0;
        while(S[i].length() != 0){
                int turn = S[i].charAt(0) - 'a';   //先頭の文字を取得（ASCIIコードの差を取る）
                S[i] = S[i].substring(1);          //先頭の文字を削除
                i = turn;
        }
        
        //char型にキャストし、ASCIIコードと対応させる。
        System.out.println((char)('A' + i));
    }
}


Measured memory_bytes: 23252
package main

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

const INF = 1000000000

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,m := input.NextInts()
  g := NewGraph(n)
  for i:=0;i<m;i++ {
    a,b := input.NextInts()
    g.Add(a-1,b-1,1)
    g.Add(b-1,a-1,1)
  }
  s,t := -1,-1
  for i:=0;i<n;i++ {
    l := len(g[i])/2
    if l%2 == 1 { fmt.Println("No");return }
  }
  for i:=0;i<n;i++ {
    l := len(g[i])/2
    if l >= 6 { fmt.Println("Yes");return }
    if l == 4 {
      if s < 0 { s = i;continue }
      if t < 0 { t = i;continue }
      fmt.Println("Yes");return
    }
  }
  if t < 0 { fmt.Println("No");return }
  if g.FordFulkerson(s,t) == 2 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

func min(n,m int) int {
  if n < m { return n }
  return m
}

type Edge struct { to,capa,rev int }
type Graph [][]Edge
func NewGraph(n int) Graph { return make([][]Edge,n) }
func(g Graph) AddEdge(fm int,e Edge) { g[fm] = append(g[fm],e) }
func(g Graph) Add(fm,to,capa int) {
  g.AddEdge(fm,Edge{to,capa,len(g[to])})
  g.AddEdge(to,Edge{fm,0,len(g[fm])-1})
}
func(g Graph) FordFulkerson(s,t int) int {
  used := make([]bool,len(g))
  var dfs func(int,int,int) int
  dfs = func(v,t,f int) int {
    if v == t { return f }
    used[v] = true
    for i,e := range g[v] {
      if used[e.to] || e.capa <= 0 { continue }
      d := dfs(e.to,t,min(f,e.capa))
      if d > 0 {
        g[v][i].capa -= d
        g[e.to][e.rev].capa += d
        return d
      }
    }
    return 0
  }
  for flow:=0;; {
    for i:=0;i<len(used);i++ { used[i] = false }
    f := dfs(s,t,INF)
    if f == 0 { return flow }
    flow += f
  }
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 32640
#include <iostream>
#define N_MAX 10
#define M_MAX 100001
#define f first
#define s second
using namespace std;
typedef pair<bool,int> P;
int Binary_Search();
bool DP_Check(int);
int N,M,c[N_MAX];

int main(){
  while(1){
    cin>>N>>M;
    if(!N&&!M) break;
    for(int i=0;i<N;i++) cin>>c[i];
    cout<<Binary_Search()<<endl;
  }
  return 0;
}

int Binary_Search(){
  int l=0,r=M+1,m;
  while(l<r){
    m=(l+r)/2;
    DP_Check(m)?r=m:l=m+1;
  }
  return l;
}

bool DP_Check(int k){
  P dp[M+1];
  for(int i=0;i<=M;i++) dp[i].f=false,dp[i].s=0; 
  dp[0].f=true;
  for(int i=0;i<N;i++){
    for(int j=c[i];j<=M;j++){
      if(dp[j].f) continue;
      if(dp[j-c[i]].f&&dp[j-c[i]].s<k){
	dp[j].f=true;
	dp[j].s=dp[j-c[i]].s+1;
      }
    }
    for(int j=0;j<=M;j++) dp[j].s=0;
  }
  if(dp[M].f==true) return true;
  return false;
}

Measured memory_bytes: 1940
long N,A[1<<17],B[1<<17],sum;
main()
{
	scanf("%ld",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%ld",A+i);
		sum+=A[i];
		if(i>0)
		{
			B[i-1]=A[i]-A[i-1];
		}
	}
	B[N-1]=A[0]-A[N-1];
	long all=(N+1)*N/2;
	if(sum%all)
	{
		puts("NO");
		return 0;
	}
	long K=sum/all;
	for(int i=0;i<N;i++)
	{
		B[i]-=K;
		if(B[i]>0||B[i]%N)
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		string s=sc.S;
		int c=sc.I;
		int n=s.Length;
		long ans=0;
		var dp=new long[n+1,2,c+2];
		dp[0,0,0]=1;
		for(int i=0;i<n;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<=c;k++){
					int lm=j==0?s[i]-'0':9;
					for(int d=0;d<=lm;d++){dp[i+1,(j==1||d<lm)?1:0,d==0?k:k+1]+=dp[i,j,k];}
				}
			}
		}
		for(int j=0;j<2;j++){
			ans+=dp[n,j,c];
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;
 
 
int main() {
	int n, k; cin >> n >> k;
	vector<double> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	double s = 0;
	for (int i = 0; i < k; i++) s += (p[i] + 1) / 2;
	double ans = s;
	for (int i = k; i < n; i++) {
		s -= (p[i - k] + 1) / 2;
		s += (p[i] + 1) / 2;
		ans = max(ans, s);
	}
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 1920
n=int(input())
h=list(map(int,input().split()))
cost=[0]*n
cost[0]=0
cost[1]=abs(h[0]-h[1])
def compare(i):
    cost[i]=min(cost[i-2]+abs(h[i]-h[i-2]),cost[i-1]+abs(h[i]-h[i-1]))
for j in range(2,n):
    compare(j)
print(cost[-1])

Measured memory_bytes: 13928
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Console.ReadLine();
        var counta = 0;
        var countb = 0;

        for (int i = 0; i < s.Length; i++)
        {
            if (i % 2 == 0 && s[i] == '0')
                counta++;
            else if (i % 2 != 0 && s[i] == '1')
                counta++;
        }
        for (int i = 0; i < s.Length; i++)
        {
            if (i % 2 == 0 && s[i] == '1')
                countb++;
            else if (i % 2 != 0 && s[i] == '0')
                countb++;
        }
        if (counta > countb)
            Console.WriteLine(s.Length - counta);
        else
            Console.WriteLine(s.Length - countb);






        Console.Out.Flush();
    }
}

Measured memory_bytes: 11232
// AtCoder Beginner Contest 138
// Practice
// A - Red or Not
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string> 
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
const ll mxsize = 1e5 + 15;
const ll linf = 1e9;
const long double inf = 10000000000.0;
#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
const ll mod = 1e9 + 7;
/******************************************* IMPORTANT CODE SNIPPETS ************************************************/ 
 
ll pow(ll x, ll n) {
  if (n == 0)
    return 1ll;
  ll temp;
  temp = pow(x, n / 2);
  if (n % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
 
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
 
int sum_digit(int val) {
  if (val < 0)
    return -1;
  if (val == 0)
    return 0;
  int ans = 0;
  while (val > 0) {
    ans = ans + val % 10;
    val = val / 10;
  }
  return ans;
}
 
ll count_div(ll l, ll r, ll val) {
  if (l % val == 0)
    return (((r / val) - (l / val)) + 1);
  else
    return ((r / val) - (l / val));
}
 
int powmod(int x, int y, int m) {
  int res = 1;
  // x = x % mod;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % m;
    cout << res << endl;
    y = y / 2;
    cout << x << endl;
    x = (x * x) % m;
  }
  // cout << res << endl;
  return res;
}
/******************************************** CODE STARTS FROM HERE *************************************************/ 
 
int main()
{
  fastIO;
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
		}
		int C = A[0];
		int ans = 1;
		for(var i=1;i<N;i++){
			if(A[i]<C){
				ans++;
			}
			C = Math.Min(C,A[i]);
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 31068
#include <stdio.h>

/* 2ツ点ツづーツ津環づゥツ陳シツ静シツづ個傾ツつォツづーツ仰づ淞づゥ */
void calc_slope(double x1, double y1, double x2, double y2, double* a, double* b)
{
  *a = (y2 - y1) / (x2 - x1);
  *b = y1 - ((*a) * x1);
  return;
}

int main(void)
{
  int n, i;
  double x[4], y[4], a[2], b[2];
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      int i;
      for(i = 0; i < 4; i++)
	{
	  scanf("%lf", x + i);
	  scanf("%lf", y + i);
	}
      for(i = 0; i < (4 / 2); i++)
	{
	  calc_slope( x[i*2], y[i*2], x[i*2+1], y[i*2+1], &a[i], &b[i]);
	}
      if(a[0] == a[1])
	{
	  printf("YES\n");
	}
      else
	{
	  printf("NO\n");
	}
    }
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, e, k int

	fmt.Scan(&a, &b, &c, &d, &e, &k)

	diff := e - a
	if diff <= k {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(whole(a));
    int ans = a[2]-a[0];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m; cin>>n>>m;
	priority_queue<ll> que;
	for(int i=0; i<n; i++){
		ll a; cin>>a;
		que.push(a);
	}
	for(int i=0; i<m; i++){
		ll x=que.top(); que.pop();
		que.push(x/2);
	}
	ll ans=0;
	while(!que.empty()){
		ans+=que.top(); que.pop();
	}
	cout<<ans<<endl;
	return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;






int main() {
    string s; cin >> s;
    int n = s.size();

    ll counter = 0;
    ll res = 0;
    bool f = false;
    rep(i, n) {
        if (s[i] == 'A') {
            if (f) counter = 0;
            f = false;
            counter++;
        }
        else if (s[i] == 'B' && !f) {
            f = true;
        }
        else if (s[i] == 'C' && f) {
            f = false;
            res += counter;
        }
        else {
            f = false;
            counter = 0;
        }
    }

    cout << res << endl;
}



Measured memory_bytes: 720
#include <iostream>
using namespace std;
int a,b,c,d,arr[200],sum;
int main() {
	// your code goes here
	cin>>a>>b>>c>>d;
	for(int i=a;i<b;i++) arr[i]++;
	for(int i=c;i<d;i++) arr[i]++;
	sum=0;
	for(int i=0;i<200;i++) 
		if(arr[i]>=2)sum++;
	cout<<sum<<endl;
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int N;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N;
	int ans = 800 * N;
	ans -= N / 15 * 200;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 892
#include<stdio.h>

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

    if (n%2==0){
        a=n/2;
        printf("%d\n",a);
    }else{
        b=(n+1)/2;
        printf("%d\n",b);
    }
   return 0; 
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(n-1):
    if a[i] + 1 == a[i+1]:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll  mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

ll dp[2005][2005];


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; 
	cin >> n;
	vector<pair<ll, ll>> a(n);
	for (ll i = 0; i < n; i++) {
		ll t; cin >> t;
		a[i] = { t, i + 1 };
	}
	sort(all(a)); 
	reverse(all(a));

	for (ll i = 0; i < n - 1; i++) {
		for (ll j = 0; j <= i; j++) {
			ll A = a[i].X;
			ll id = a[i].Y;
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + A * abs(id - (j + 1)));
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A * abs(id - (n - (i - j))));
			ll tt = 0;
		}
	}
	int i = n - 1;
	for (ll j = 0; j <= i; j++) {
		ll A = a[i].X;
		ll id = a[i].Y;
		dp[n][n] = max(dp[n][n], dp[i][j] + A * abs(id - (j + 1)));
	}


	cout << dp[n][n] << endl;

	return 0;
}

/*

*/

Measured memory_bytes: 26296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,a,b,c;
    cin>>a>>b;
   if(b==1)
    cout<<0<<endl;
   else{
   c=1; i=a;
    while(i<b)
    {
       i+=a-1;
       c++;
    }
   cout<<c<<endl;
   }
}


Measured memory_bytes: 256
fn read<T: ::std::str::FromStr>() -> T {
    let mut s = String::new();
    ::std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: ::std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    ::std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

pub fn main() {
    let ABC = read_vec();
    let A: i32 = ABC[0];
    let B: i32 = ABC[1];
    let C: i32 = ABC[2];
    if (A <= C && B >= C) || (A >= C && B <= C) {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
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)*}
    };
}
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)*}
    };
}
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")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;


fn main() {
    let alphabets = vec!['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'];
    input!{
        N: usize,
        S: chars,
        K: usize,
    }
    let ch = S[K-1];
    let ans = S.into_iter().map(|s| if s != ch { '*' } else { s }).collect::<Vec<_>>();

    for l in ans.into_iter() {
        print!("{}", l);
    }
    println!("");
}

Measured memory_bytes: 4352
# F - Strivore
import sys
MOD = 10**9+7
K = int(input())
S = input()
l = len(S)
ans = 0

tmp = pow(26,K,MOD)
ans = tmp
waru = pow(26,-1,MOD)

for i in range(1,K+1):
    tmp = (tmp*25*waru)%MOD
    tmp = (tmp*(l-1+i)*pow(i,-1,MOD))%MOD
    ans = (ans+tmp)%MOD

print(ans)

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

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            if (N % 2 == 0) {
                Console.WriteLine(N);
            } else {
                Console.WriteLine(N * 2);
            }
        }

    }
}


Measured memory_bytes: 11092
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#pragma endregion

const int N = 200005;

int n, arr[N], k;

bool verify(int g) {
    int count = 0;
    for (int i=0; i<n; i++) {
        int gg = arr[i];
        count += ceil(double(gg)/g)-1;
        if (count > k) return false;
    }
    return true;
}

pls give {
    AC;
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> arr[i];
    int l=1, r=INT_MAX;
    while (l<r) {
        int m = (l+r)/2;
        if (verify(m)) r = m;
        else l = m+1;
    }
    cout << l << nl;
}

Measured memory_bytes: 5212
#include <iostream>
#include <array>
#include <cmath>
using namespace std;

int main() {
    array<long long, 31> stairs{};
    {
        stairs[0] = 1;
        for (auto step = 0; step <= 30; step++)
            for (auto walk = 1; walk <= 3; walk++) 
                if (step + walk <= 30)
                    stairs[step + walk] += stairs[step];
    }
    int n;
    while (cin >> n, n)
        cout << ceil(static_cast<double>(stairs[n]) / 3650.) << endl;
    return 0;
}

Measured memory_bytes: 3232
// E
// DeP
#pragma GCC optimize(3, "inline", "Ofast")
#include <cmath>
#include <cctype>
#include <cstdio>
#include <algorithm>
using namespace std;

namespace IO {
    const int MAXSIZE = 1 << 18 | 1;
    char buf[MAXSIZE], *p1, *p2;

    inline int Gc() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2)? EOF: *p1++; }
    template<typename T> void read(T& x) {
        x = 0; int f = 0, ch = Gc();
        while (!isdigit(ch)) { f |= ch == '-'; ch = Gc(); }
        while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = Gc(); }
        if (f) x = -x;
    }
}
using IO::read; using IO::Gc;

const int MAXM = 5e5 + 5, MAXA = 256;
int block;

struct Query {
    int idx, L, R, Time;
    bool operator < (const Query& rhs) const {
        return L/block == rhs.L/block? (R/block == rhs.R/block? Time < rhs.Time: R < rhs.R): L < rhs.L;
    }
} asks[MAXM];

struct Update { int pos; char col; } updates[MAXM];

int n, m, qidx, uidx;
char A[MAXM];
int Ans[MAXM];

namespace MoAlgorithm {
    int L, R, Time, now, cnt[MAXA];

    inline void Add(int val) { now += !cnt[val]++; }
    inline void Del(int val) { now -= !(--cnt[val]); }

    inline void modify(int x) {
        if (L <= updates[x].pos && updates[x].pos <= R) {
            Del(A[updates[x].pos]);
            Add(updates[x].col);
        }
        swap(updates[x].col, A[updates[x].pos]);
    }

    inline void solve() {
        block = (int) ceil( exp((log(n) + log(qidx)) / 3.0) );
        sort(asks+1, asks+qidx+1);
        L = asks[1].L, R = L-1;
        for (int i = 1; i <= qidx; ++i) {
            const Query& q = asks[i];
            while (q.L < L) Add(A[--L]);
            while (q.L > L) Del(A[L++]);
            while (q.R > R) Add(A[++R]);
            while (q.R < R) Del(A[R--]);
            while (Time < q.Time) modify(++Time);
            while (Time > q.Time) modify(Time--);
            Ans[q.idx] = now;
        }
    }
}

int main() {
    // input
    scanf("%d%s", &n, A+1);
    read(m);
    for (int i = 1; i <= m; ++i) {
        static int opt, L, R, val;
        read(opt), read(L);
        switch (opt) {
            case 1:
                val = Gc();
                while (isspace(val)) val = Gc();
                updates[++uidx] = (Update){ L, char(val) };
                break;
            case 2:
                read(R);
                ++qidx, asks[qidx] = (Query){ qidx, L, R, uidx };
                break;
            default: fprintf(stderr, "ERR\n");
        }
    }
    // aogharg aeioh 
    MoAlgorithm::solve();
    // output
    for (int i = 1; i <= qidx; ++i) printf("%d\n", Ans[i]);
    return 0;
}

Measured memory_bytes: 6656
import sys

sys.setrecursionlimit(100000)


def dfs(s, mx):
    if len(s) == N:
        print(s)
        return 0
    for c in range(ord("a"), mx + 2):
        t = s
        t += chr(c)
        dfs(t, max(mx, c))


N = int(input())
dfs("", ord("a") - 1)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    
    ll n, a, b;
    cin >> n >> a >> b;
    if (a <= 0) {
        cout << 0 << endl;
        return 0;
    }
    
    ll c = n / (a + b);
    ll ans = a * c;
    ll amari  = n % (a + b);
    if (amari <= a) {
        ans += amari;
    } else {
        ans += a;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
N, M = gets.split.map(&:to_i)
T = Array.new(N + 1, 1)
H = Array.new(N + 1, 0);
gets.split.map(&:to_i).each_with_index{|h,i| H[i + 1] = h }

M.times do 
  a,b = gets.split.map(&:to_i)
  if H[a] > H[b]
    T[b] = 0
  elsif H[a] < H[b]
    T[a] = 0
  else
    T[a] = T[b] = 0
  end
end
puts (1 .. N).count{|i| T[i] > 0 }



Measured memory_bytes: 23184
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int a,b,c;
  cin>>a>>b>>c;
  if(((a==b)&&(a!=c))||((b==c)&&(b!=a))||((c==a)&&(c!=b)))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return 0;
  }


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

int main() {
	
int n, m;
cin >> n >> m;
vector < vector <int> > vec(m+1);
int k, s;
for(int i = 1; i < m+1; i++)
{
  cin >> k;
  vec[i].resize(k);
  for(int j = 0; j < k; j++)
  {
    cin >> vec[i][j];
    vec[i][j]--;
  }
}

int p[m+1];
for(int i =1; i < m+1; i++)
  cin >> p[i];
int ans = 0;
for(int i = 0; i < (1 << n); i++)
{
	int flag = 0;
	for(int j = 1; j < m+1; j++)
	{
		int c = 0;
		for(int k : vec[j])
		{
			if( (i & (1 << k) ) != 0)
				c++;
		}

		if(c%2 != p[j])
			flag = 1;
	}
	if(flag == 0)
		ans++;
}

cout << ans ;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MMAX 2147483647
typedef long long llong;
void merge(int *array, int left, int med, int right, llong &ans)
{
    int lside = med - left;
    int rside = right - med;
    int L[lside + 1], R[lside + 1];
    copy(&array[left], &array[med], L);
    copy(&array[med], &array[right], R);
    L[lside] = MMAX;
    R[rside] = MMAX;
    /*for (int i = left; i < med; ++i)
    {
        for (int j = med; j < right; ++j)
        {
            if (array[j] < array[i])
                ans++;
        }
    }*/
    int li = 0, ri = 0;
    for (int i = left; i < right; ++i)
    {
        if (L[li] <= R[ri])
            array[i] = L[li++];
        else
        {
            array[i] = R[ri++];
            ans += (lside - li);
        }
    }
}
void mgst(int *array, int left, int right, llong &ans)
{
    int med = (left + right) / 2;
    if (left + 1 < right)
    {
        mgst(array, left, med, ans);
        mgst(array, med, right, ans);
        merge(array, left, med, right, ans);
    }
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    llong ans(0);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    mgst(a, 0, n, ans);
    cout << ans << endl;
}


Measured memory_bytes: 4708
#include <iostream>
#include <vector>
using namespace std;
int n, s, a[3000];
const long m = 998244353;
int main()
{
    cin >> n >> s;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int64_t> dp(s + 1);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = s; j >= 0; j--)
        {
            dp[j] += dp[j];
            if (j >= a[i])
            {
                dp[j] += dp[j - a[i]];
            }
            if (j == a[i])
            {
                ++dp[j];
            }
            if (j == 0)
            {
                ++dp[j];
            }
            if (dp[j] >= m)
            {
                dp[j] %= m;
            }
        }
    }
    cout << dp[s] << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
   int a,b;
  
  cin >> a >> b;
  
  if ((a <= 0) &&  (b >= 0)){
    cout << "Zero" << endl;
  }else if((a>0) &&(b >0)){
    cout << "Positive" << endl;
  }else if((a<0) && (b<0)){
    if((b-a+1)%2==1){
      cout << "Negative" << endl;
    }else{
      cout << "Positive" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int n; cin >> n;
	vi a(n); rep(i,n) cin >> a[i];
	SORT(a);
	bool yes = true;
	rep2(i,1,n){
		if(a[i-1]==a[i]){ 
			yes = false;
			break;
		}
	}
	if(yes) cout << "YES" << endl;
	else cout << "NO" << endl;
}




Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
string arr[20];
int main()
{
int a,b,c;
cin>>a>>b>>c;
if (a!=b&&a!=c){
cout<<a;
}
else if (b!=a&&b!=c){
cout<<b;
}
else{
cout<<c;
}
 return 0;
}

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

namespace A43 {
    class Program {
        static void Main(string[] args) {

            int n = int.Parse(Console.ReadLine());
            int result = Method(n);
            Console.WriteLine(result);
        }

        private static int Method(int n) {

            return n * (n + 1) / 2; 
        }
    }
}


Measured memory_bytes: 11092
# -*- coding: utf-8 -*-
# 整数の入力
import math
 
a = float(input())
 
gusu = a / 2
ngusu = math.floor(gusu)
 
if gusu > ngusu:
  kisu = ngusu + 1
else:
  kisu = ngusu
kaku = kisu / a 

print(kaku)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define int long long
signed main()
{
    int n;
    cin >> n;
    int m[n+1],h[n],sum=0;
    for(int i=0;i<=n;i++) cin >> m[i];
    for(int i=0;i<n;i++)
        cin >> h[i];
    for(int i=0;i<n;i++)
    {
        sum += min(m[i]+m[i+1],h[i]);
        m[i]>=h[i]?h[i]=0:m[i+1]-=h[i]-m[i];
      //  m[i+1] -= h[i]-m[i];
        if(m[i+1]<0) m[i+1]=0;
    }
    cout << sum;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x)end()
#define sz(x) (int)(x).size
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main ()
{
	int n;
	scanf("%d",&n);
	int four = 0,two = 0,one = 0;
	rep(i,0,n) {
	    int t;
        scanf("%d",&t);
        if (t % 4 == 0) four++;
        else if (t % 2 == 0) two++;
        else one++;
	}
	if (one + (two > 0) - 1 > four ) printf("No\n");
	else printf("Yes\n");


    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int c[3][3] = {};
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			int a;
			cin >> a;
			c[i][j] = a;
		}
	}
	for (int i = 1; i < 3; i++) {
		if ((c[i][0] - c[i - 1][0] != c[i][1] - c[i - 1][1]) || (c[i][1] - c[i - 1][1] != c[i][2] - c[i - 1][2])) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256