akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  int N;
  Tmp(int N): N(N){};
  void rec(string& str, int n) {
    if (n == N+1) {
      cout << str << CRLF;
      return;
    }
    int inf = 1;
    if (!str.empty()) {
      auto max = *boost::max_element(str) - 'a';
      inf = std::min(max+1, n) + 1;
    }
    for (int i = 0; i < inf; ++i) {
      str.push_back('a' + i);
      rec(str, n+1);
      str.pop_back();
    }
  }
};

void solve(void)
{
  int N; cin >> N;
  Tmp t(N);
  string s{};
  t.rec(s, 1);
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
  int n;
  char s[105];
  char t[105];
  
  scanf("%d %s %s", &n, s, t);
  
  for (int i = 0; i < n; i++) {
    putchar(s[i]);
    putchar(t[i]);
  }
    
  return 0;
}

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

int main()
{
    int num;
    int ten;
    int tmp;

    cin >> num;
    ten = 100;
    tmp = num;
    for (int i = 0; i < 3;i++)
    {
        //cout << "first" << tmp/ten << endl;
        if (tmp/ten == 7)
        {
            cout << "Yes";
            return 0;
        }
        tmp = tmp % ten;
        //cout << tmp << endl;
        ten = ten/10;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL<<31) - 1;
const ll mod = 1e9 + 7;

ll H, W,K,brack,ans;
char S[7][7];


int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> H >> W >> K;
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			cin >> S[i][j];
			if (S[i][j] == '#')brack++;
		}
	}

	FOR(i, 0, (1 << H)) {
		FOR(j, 0, (1 << W)) {
			ll cur = brack;

			FOR(tate, 0, H) {
				FOR(yoko, 0, W) {
					if ((i >> tate)&1 == 1 || (j>>yoko)&1==1) {
						if (S[tate][yoko] == '#')cur--;
					}
				}
			}

			if (cur == K)ans++;

		}
	}

	cout << ans << endl;



}


Measured memory_bytes: 3584
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    vector<ll >a,b;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;

        a.pb(x);
        b.pb(y);
    }
    ll already = 0;
    for(int i=n-1;i>=0;i--){
        ll rem = (a[i]+already)%b[i];
        if(rem)already+=(b[i]-rem);
    }
    cout<<already<<"\n";
}


Measured memory_bytes: 2036
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		string ans = "Yes";
		for(var i=0;i<str.Length;i++){
			if(i%2==0){
				if(str.Substring(i,1)=="L"){
					ans = "No";
				}
			} else {
				if(str.Substring(i,1)=="R"){
					ans = "No";
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
N = int(input())
a = [int(input()) for i in range(N)]
b = [0]*N
for i in range(N):
    b[a[i] - 1] = i
b.append(-1)
count = 1
max = 0
for i in range(N):
    if b[i+1] - b[i] > 0:
        count = count + 1
    else:
        if count > max:
            max = count
        count = 1

print(N - max)



Measured memory_bytes: 18996
#include<bits/stdc++.h>
#define ll long long 
#define pii pair<int,int>
#define iiii pair<int,pii >
#define ld double 
#define MAXN 100100
#define inf 1000000000000000000ll
using namespace std;

ll treeA[4*MAXN],treeB[4*MAXN],Dp[MAXN],e,t,a[MAXN],b[MAXN];
int n,p[MAXN],m;

void fModify(int x,ll y,ll tree[])
{
	x+=m-1;
	tree[x]=y;
	while(x>0)
	{	
		x=(x-1)/2;
		tree[x]=min(tree[2*x+1],tree[2*x+2]);
	}
}

void fInit()
{
	a[0]=0;
	Dp[0]=0;
	n++;m=1;
	while (m<n)m*=2;
	fModify(0,0,treeA);
	fModify(0,-2*a[1],treeB);
}

ll fQuery(int x,int y,int l,int r,int k,ll tree[])
{                       
	if(x>=y)return inf;
	if(l>=y||r<=x)return inf;
	if(x<=l&&r<=y)return tree[k];
	else
	{
		int mid=(l+r)/2;
		ll lx=fQuery(x,y,l,mid,2*k+1,tree);
		ll ly=fQuery(x,y,mid,r,2*k+2,tree);
		return min(lx,ly);
	}
}

void fChange(int x)
{
	Dp[x]+=a[x];
	int P=p[x];                        
	ll res1=fQuery(0,P,0,m,0,treeB)+b[x];
	ll res2=fQuery(max(P,0),x,0,m,0,treeA)+t;

	Dp[x]+=min(res1,res2);
	fModify(x,Dp[x]-a[x],treeA);
	
	fModify(x,Dp[x]-a[x]-a[x+1]*2,treeB);
}


int main()
{
	scanf("%d%lld%lld",&n,&e,&t);
	for(int i=1;i<=n;i++)scanf("%lld",a+i);
	
	fInit();
	for(int i=0;i<n;i++)b[i]=2*a[i];
	for(int i=1;i<n;i++)p[i]=lower_bound(b,b+i+1,b[i]-t)-b-1;
	for(int i=1;i<n;i++)fChange(i);//cout<<Dp[i]<<" "<<i<<endl;
	
	 
	printf("%lld\n",Dp[n-1]-a[n-1]+e);

	
	return 0;
}

Measured memory_bytes: 8448
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]

    ans = 0.0
    if K == 1:
        print 1
        return
    for x in range(1, N + 1):
        #t = (K)/(2 * (x)) + (1 if (K)%(2 * (x)) == 0 else 0)
        if x >= K:
            ans += float(N - x + 1)/float(N)
            break;
        t = math.ceil(math.log(float(K)/float(x), 2))

        ans += (1.0/(2 ** t))/float(N)

    #ans += float(N - x + 1)/float(N)
    print ("%20.15f" % ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6000
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner s  = new Scanner(System.in);
		String a = s.next();
		String b = s.next();
		int count = 0;
		for(int i=0;i<a.length();i++) {
			if(a.charAt(i)!=b.charAt(i)) count++;
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 41016
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool prime[1000006];
ll d[1000006];
void sieve()
{
    for(int i=1; i<=1000000; i++)d[i]= 1;
    for(int i=2; i<=1000000; i++)
    if(!prime[i])
    {
        d[i]*= 2;
        for(int j=2*i; j<=1000000; j+= i)
        {
            prime[j]= 1;
            int x= j, c= 1;
            while(!(x%i))x/= i, c++;
            d[j]*= c;
        }
    }
    return;
}
int main()
{
    sieve();
    int n;
    scanf("%d", &n);
    ll res= 0;
    for(int i=1; i<n; i++)res+= d[i];
    printf("%lld\n", res);
    return 0;
}


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

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

    vector<vector<int>> map(501, vector<int> (501, 0));
    // vector<int> l(m);
    // vector<int> r(m);
    vector<int> res(q);
    int x, y;
    for(int i = 0; i < m; i++){
        cin >> x >> y;
        map.at(x).at(y)++;
    }
    vector<vector<int>> add(501, vector<int> (501, 0));
    for(int i = 1; i < 501; i++){// 和を求めておく
        for(int j = 1; j < 501; j++){
            add.at(i).at(j) = map.at(i).at(j) + add.at(i).at(j - 1);
        }
    }
    /*
    for(int i = 0; i < n + 1; i++){
        for(int j = 0; j < n + 1; j++){
            cout << map.at(i).at(j);
            // cout << add.at(i).at(j);
        }
        cout << endl;
    }
    cout << endl;
    */
    /*for(int i = 0; i < n + 1; i++){
        for(int j = 0; j < n + 1; j++){
            // cout << map.at(i).at(j);
            cout << add.at(i).at(j);
        }
        cout << endl;
    }*/
    
    int sum = 0;
    for(int i = 0; i < q; i++){
        sum = 0;
        cin >> x >> y;
        for(int j = x; j < 501; j++){
            sum += add.at(j).at(y);
        }
        /* for(int j = x; j < n + 1; j++){
            for(int k = 0; k <= y; k++){
                sum += map.at(j).at(k);
            }
        }*/
        // cout << sum << endl;
        res.at(i) = sum;
    }

    for(int i = 0; i < q; i++){
        cout << res.at(i) << endl;
    }

}

Measured memory_bytes: 5616
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}
fn enumerate_divisors(n: usize) -> Vec<usize> {
    let mut ret = Vec::new();
    let mut i = 1;
    while i * i <= n {
        if n % i == 0 {
            ret.push(i);
            if i != 1 && i * i != n {
                ret.push(n / i);
            }
        }
        i += 1;
    }
    ret
}
use std::collections::BTreeSet;
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let mut arr: Vec<usize> = sc.vec(n);

    arr.sort();
    let mut sames = BTreeSet::new();
    let mut xs = vec![];
    let mut prev = 0usize;
    let mut same = false;
    for (i, &a) in arr.iter().enumerate() {
        if a != prev {
            xs.push(a);
            prev = a;
        } else {
            sames.insert(a);
        }
    }

    let mut cnt: usize = 0;
    let mut set = BTreeSet::new();
    for a in xs {
        let divs = enumerate_divisors(a);
        let mut ok = true;
        for d in divs {
            if set.contains(&d) {
                ok = false;
            }
        }

        if ok {
            set.insert(a);
            cnt += 1;
        }
    }
    for s in sames {
        if set.contains(&s) {
            cnt -= 1;
        }
    }
    println!("{}", cnt);
}


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

int main() {
    long long x; cin >> x;
    for(int i = 0; i < 200; i++) {
        for(int j = -100; j < 200; j++) {
            if(i*i*i*i*i - j*j*j*j*j == x) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  vector<int> vec(pow(10, 5)+1, 0);
  REP(i, N) {
    int x;
    cin >> x;
    vec[x]++;
  }
  vector<int> seq(pow(10, 5)+1, 0);
  for(int i = 1; i <= seq.size(); i++) {
    seq[i] = seq[i-1] + vec[i];
  }
  int ans = 0;
  REP(i, seq.size()) {
    if (seq[i] == N / 2) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using i64 = long long int;

int main() {
    i64 n, a, b;
    cin >> n >> a >> b;
    vector<i64> h(n);
    i64 m = 0;
    for(int i = 0; i < n; ++i){
        cin >> h[i];
        m = max(m, h[i]);
    }
    i64 left = 0, right = m / b + 1;
    while (right - left > 1) {
        i64 mid = left + (right - left) / 2;
        i64 cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (h[i] - mid * b > 0) {
                i64 tmp = h[i] - mid * b;
                i64 d = a - b;
                cnt += (tmp + d - 1) / d; 
            }
        }
        if(cnt <= mid) right = mid;
        else left = mid;
    }
    cout << right << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

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

  int t[n]={},ans=n-1;
  for(int i=1;i<n;i++){
    if(s[i]=='W') t[0]++;
  }
  ans=n-t[0]-1;
  for(int i=1;i<n;i++){
    if(s[i]=='W'){
      if(s[i-1]=='E'){
        t[i]=t[i-1];
      }else{
        t[i]=t[i-1]-1;
      }
    }else{
      if(s[i-1]=='E'){
        t[i]=t[i-1]+1;
      }else{
        t[i]=t[i-1];
      }
    }
    ans=min(ans,n-t[i]-1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
#define EPS 1e-7
int main()
{
  double a, b, c, d, e, f;
  while(cin >> a >> b >> c >> d >> e >> f) {
    // x = (c - by) / a
    // x = (f - ey) / d
    double x = (c * e - f * b) / (e * a - d * b);
    // y = (c - ax) / b
    double y = (c - a * x) / b;

    bool flag = x <= -EPS;
    int xx = (int)(x * 1000.0 + 0.5 * -flag + EPS * -flag);
    bool flag2 = y <= -EPS;

    int yy = (int)(y * 1000.0 + 0.5 * -flag2 + EPS * -flag2);
    printf("%.3lf %.3lf\n", (double)xx / 1000.0 + EPS * -flag, (double)yy / 1000.0 + EPS * -flag2);
  }
}

Measured memory_bytes: 1236
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        for (int I = 0; I < N; I++)
        {
            int gx, gy;
            string[] str = Console.ReadLine().Split(' ');
            gx = int.Parse(str[0]);
            gy = int.Parse(str[1]);
            int[,] tatemove = new int[gx + 1, gy + 1];
            int[,] yokomove = new int[gx + 1, gy + 1];
            int[,] T = new int[gx + 1, gy + 1];
            for (int i = 0; i <= gx; i++)
            {
                for (int j = 0; j <= gy; j++)
                {
                    tatemove[i, j] = 0;
                    yokomove[i, j] = 0;
                    T[i, j] = 0;
                }
            }
            int m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                int mx1, my1, mx2, my2;
                string[] str2 = Console.ReadLine().Split(' ');
                mx1 = int.Parse(str2[0]);
                my1 = int.Parse(str2[1]);
                mx2 = int.Parse(str2[2]);
                my2 = int.Parse(str2[3]);
                if (mx1 == mx2)
                {
                    tatemove[mx1, (my1 > my2) ? my1 : my2] = 1;
                }
                if (my1 == my2)
                {
                    yokomove[(mx1 > mx2) ? mx1 : mx2, my1] = 1;
                }
            }
            for (int i = 0; i < gx + 1; i++)
            {
                for (int j = 0; j < gy + 1; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        T[i, j] = 1;
                    }
                    else if (i == 0)
                    {
                        T[i, j] = (tatemove[i, j] == 1) ? 0 : T[i, j - 1];
                    }
                    else if (j == 0)
                    {
                        T[i, j] = (yokomove[i, j] == 1) ? 0 : T[i - 1, j];
                    }
                    else
                    {
                        T[i, j] = ((tatemove[i, j] == 1) ? 0 : T[i, j - 1]) + ((yokomove[i, j] == 1) ? 0 : T[i - 1, j]);
                    }
                }
            }
            if (T[gx, gy] == 0)
            {
                Console.WriteLine("Miserable Hokusai!");
            }
            else
            {
                Console.WriteLine(T[gx, gy]);
            }
        }
    }
}


Measured memory_bytes: 5824
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  int a,b,c,ans;
  cin>>a>>b>>c;
  int maxa=max(a,b);
  maxa=max(maxa,c);
  ans=a+b+c-maxa+10*maxa;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
sclist=[]
for i in range(m):
    sclist.append(list(map(int,input().split())))

for i in range(m):
    if n != 1 and sclist[i][0] == 1 and sclist[i][1] == 0:
        print(-1)
        sys.exit()
    for j in range(i+1,m):
        if sclist[i][0] == sclist[j][0] and sclist[i][1] != sclist[j][1]: 
            print(-1)
            sys.exit()

outlist=["0" for _ in range(n)]
if n != 1:
    outlist[0]="1"

for sc in sclist:
    outlist[sc[0]-1] = str(sc[1])

print("".join(outlist))



Measured memory_bytes: 3064
package main

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

func cost(a []int, i, j int) int {
	c := a[i] - a[j]
	if c < 0 {
		return -c
	}
	return c
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanInt := func() int {
		scanner.Scan()
		num, err := strconv.Atoi(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}
		return num
	}

	n, k := scanInt(), scanInt()
	a, memo := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}

	memo[0] = 0
	for i := 1; i < n; i++ {
		memo[i] = math.MaxInt32
		for j := 1; j <= k; j++ {
			if i-j < 0 {
				break
			}
			memo[i] = min(memo[i-j]+cost(a, i-j, i), memo[i])
		}
	}

	fmt.Println(memo[n-1])
}


Measured memory_bytes: 2816
#include<iostream>
#include<string>

using namespace std;

int main()
{
	// 文字列入力
	char S[3];
	for(int i=0;i<3;i++) cin >> S[i];

	//値段
	int sum = 700;

	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') sum += 100;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
 
 
    
    int k;
    cin>>k;
    int sum=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int l = 1;l<=k;l++)
            {
                int dd = gcd(i,j);
                sum+=gcd(l,dd);
            }
        }
    }
    cout<<sum<<"\n";
 
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


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

int main()
{
    int N; cin >> N;
    ll A[N];
    int minus = 0;
    ll MIN_abs = 100000000000;
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if(A[i]<0) minus++;
        MIN_abs = min(MIN_abs,abs(A[i]));
        ans += abs(A[i]);
    }
    if(minus%2==1) ans -= 2*MIN_abs;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    
    vector<int> v(n);
    
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    
    long double b = v[0];
    for (int i = 1; i < n; i++)
    {
        b = (b + v[i]) / 2.0;
        
    }
    
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<int> s(5);
	for(int i=0; i<5; i++){
		cin>>s.at(i);
	}
	for(int i=0 ; i<5;i++){
		if(s.at(i)==0){
			cout<<i+1<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
N = int(input())
cnts = [[0] * 10 for _ in range(10)]
ans = 0
for i in range(N + 1):
    if i % 10 == 0:
        continue
    s = str(i)
    cnts[int(s[0])][int(s[-1])] += 1

for i in range(N + 1):
    if i % 10 == 0:
        continue
    s = str(i)
    ans += cnts[int(s[-1])][int(s[0])]

print(ans)


Measured memory_bytes: 41436
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
// 標準入力からデータを読み込む準備
        int i,j;
        Scanner sc = new Scanner(System.in);
// 最初の文字の固まりを整数値と想定して読み込む
        while (true) {
            int H = sc.nextInt();
            int W= sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
// 二重ループ(forの中にfor)を書いて、H x W個の # を表示しよう！

            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if((i==0 || i==H-1)||(j==0 || j==W-1))System.out.printf("#");
                    else System.out.printf(".");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 54760
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	string s;
	string t;
	cin >> s >> t;
	int flag = 0;
	for (i = s.length() - t.length();i != -1;i--) {
		flag = 1;
		rep(j,0,t.length()){
			if (s[i + j] != t[j]) {
				if (s[i + j] != '?') {
					flag = 0;
				}
			}
		}
		if (flag) {
			int n = 0;
			for (j = s.length() - 1;j != -1;j--) {
				if (i <= j&&j < i + t.length()) {
					s[j] = t[j - i];
				}
				else if (s[j] == '?') {
					s[j] = 'a';
				}
			}
			break;
		}
	}
	if (flag) {
		cout << s << endl;
	}
	else {
		cout << "UNRESTORABLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
ans = False
if len(s) < 1 or len(s) >10:
    ans = False
if len(s) >= 1 or len(s) <= 10:
    if s == 'hi' or s == 'hihi' or s == 'hihihi' or s == 'hihihihi' or s == 'hihihihihi':
        ans =True
    else:
        ans =False
if ans:
    print ('Yes')
else:
    print('No')

Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))

q = int(input())

m = {}

for i in range(1000000):
  m[i] = 0

for e in a:
  m[e] += 1
  
ans = sum(a)

for i in range(q):
  b,q = map(int,input().split())
  diff = (q-b) * m[b]
  
  m[q] += m[b]
  m[b] = 0
  
  ans += diff
  print(ans)
  

Measured memory_bytes: 97892
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],4)[0];
  var A = myconv(input[0],4)[1];
  var B = myconv(input[0],4)[2];
  var count = 0;
  var tmpB = 0;
  var list = myconv(input[1],6);
  var output = [];
  for(var i = 0; i < N; i++){
    var tmp = list[i];
    if(tmp == "a"){
       if(count < A+B){
          count++;
         output.push("Yes");
       }else{
         output.push("No");
       }
    }else if(tmp == "b"){
       if(count < A+B && tmpB < B){
          count++;
         tmpB++;
         output.push("Yes");
       }else{
         output.push("No");
       }      
	}else{
      output.push("No");
    }
  }
  myout(output.join("\n"));
}
Main(myin());

Measured memory_bytes: 15308
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n;
LL a[100010];
char op[100010];
LL dp[100010][3];

void init() {
}

void input() {
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		if (i < n-1) cin >> op[i+1];
	}
}

void solve() {
	REP(i, 100010) REP(j, 3) dp[i][j] = -1e15;
	dp[0][0] = a[0];
	FOR(i, 1, n){
		if(op[i] == '+'){
			dp[i][0] = max({
				dp[i-1][0]+a[i], 
				dp[i-1][1]+a[i], 
				dp[i-1][2]+a[i]
				});
			dp[i][1] = max({
				dp[i-1][1]-a[i], 
				// dp[i-1][2]-a[i]
				});
			dp[i][2] = max({
				dp[i-1][2]+a[i]
				});
		}
		else{
			// dp[i][0] = max({
			// 	dp[i-1][0]-a[i], 
			// 	dp[i-1][1]-a[i], 
			// 	dp[i-1][2]-a[i]
			// 	});
			dp[i][1] = max({
				dp[i-1][0]-a[i], 
				// dp[i-1][1]+a[i], 
				// dp[i-1][2]+a[i]
				});
			dp[i][2] = max({
				dp[i-1][1]+a[i], 
				// dp[i-1][2]-a[i]
				dp[i-1][2]+a[i]
				});
		}
	}
	cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
}

int main() {
	init();
    input();
    solve();
	return 0;
}








Measured memory_bytes: 3456
#include <stdio.h>

int main(void){
  int a[3];
  int i,j,tmp;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);

  for (i=0; i<=2;i++){
    for (j=2; j>i; j--){
      if(a[j]<a[j-1]){
        tmp=a[j];
        a[j]=a[j-1];
        a[j-1]=tmp;
      }    
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
}


Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k;
int a[222222];
int cnt[222222];
int sans[222222];
string s;
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n){
		cnt[a[i]]++;
	}
	int ans=0,sum=0;
	rep(i,n+1){
		sans[i]=cnt[i]*(cnt[i]-1)/2;
		sum+=sans[i];
	}
	rep(i,n){
		ans=sum;
		ans=ans-sans[a[i]]+(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 7168
#include <stdio.h>
int main(void){
    int a,b,k,i;
    scanf("%d%d%d",&a,&b,&k);
    for(i=0;i<k;i++){
        if(i%2==0){
            if(a%2 != 0){
                a--;
                b+= a/2;
                a=a/2;
            }else{
                b+= a/2;
                a=a/2;
            }
        }else{
            if(b%2 != 0){
                b--;
                a+= b/2;
                b=b/2;
            }else{
                a+= b/2;
                b=b/2;
            }
        }
    }
    printf("%d %d",a,b);
}


Measured memory_bytes: 128
from collections import defaultdict
import math

def sieve_of_eratosthenes(n):
    sieve = list(range(n+1))
    m = int(math.sqrt(n))
    for i in range(2, m + 1):
        if sieve[i] < i:
            continue
        for j in range(i * i, n + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve

def factorize_by_sieve(x, sieve):
    factor = dict()
    while x != 1:
        if sieve[x] in factor:
            factor[sieve[x]] += 1
        else:
            factor[sieve[x]] = 1
        x //= sieve[x]
    return factor

mod = 10 ** 9 + 7
n = int(input())
if n == 1:
    print(1)
    quit()

sieve = sieve_of_eratosthenes(n)
dic = defaultdict(int)
for i in range(2, n+1):
    factor = factorize_by_sieve(i, sieve)
    for p, dim in factor.items():
        dic[p] += dim

ans = 1
for _, dim in dic.items():
    ans = ans * (dim + 1) % mod
print(ans)


Measured memory_bytes: 68856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

#define intt long long
#define PI 3.14159265358979323846

using Graph = std::vector<std::vector<intt>>;
Graph G;

int main() {
    intt N; std::cin >> N;
    for (intt i = 0; i < 100000000; ++i) {
        intt D = N - (4 * i);
        intt j = D / 7;
        if (4 * i + 7 * j == N) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
        if (4 * i > N)
            break;
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>

int main(){
   char k[100];
   int s;
   char t[100];
   scanf("%d",&s);
   scanf("%s",k);
   if(strlen(k)<=s){
      printf("%s",k);
   }else{
      strncpy(t,k,s);
      t[s]='\0';
      printf("%s...",t);
   }
   return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ans = (1000-n%1000)%1000;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  int a[100] = {};
  while (cin >> n) a[n - 1]++;

  int maxa = 0;
  while (true) {
    int maxb = maxa;
    maxa = 0;

    int max_val = 0;
    for (int i = 0; i < 100; i++) {
      if (a[i] > maxa) {
        maxa = a[i];
        max_val = i + 1;
      }
    }
    if (maxa < maxb) break;

    cout << max_val << endl;
    a[max_val - 1] = 0;
  }

  return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
int main(void){
    
    int a, b, c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    
    if(a < b && b < c)
     printf("Yes\n");
    else
     printf("No\n");
     
     return 0;
}



Measured memory_bytes: 2048
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int main(void) {
  int k, s;
  cin >> k >> s;
  int res = 0;
  REP(x, k+1) {
    REP(y, k+1) {
      int z = s - (x+y);
      if(0 <= z && z <= k) {
        ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, r: f64);
    println!("{}", 2. * r * std::f64::consts::PI);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2144
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN];
int main()
{
    scanf("%d%d",&n,&k);
    if(k*2<=n+1) puts("YES"); else puts("NO");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define pf pop_front
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

const ll N=2e5+5;
ll a[N],b[N];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,m,k;cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
        b[i]+=b[i-1];
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        if(k>=a[i]){
            ll r=upper_bound(b+1,b+1+m,k-a[i])-b-1;
            ans=max(ans,r+i);
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 6728
#include <iostream>
using namespace std;
#define ll long long int  

int main() {
	// your code goes here
	
	ll i,j,k,n,m,t;
	cin>>n>>m;
	m*=m;
	ll ans =0 ;
	while(n--){
	    ll x,y;
	    cin>>x>>y;
	    ll val = x*x + y*y;
	    if(val <= m) ans+=1;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll t1,t2,a1,a2,b1,b2;cin>>t1>>t2>>a1>>a2>>b1>>b2;
    /*ll dif = t1*a1+t2*a2-t1*b1-t2*b2;
    if(dif==0){cout<<"infinity";return 0;}*/

    /*ll dif2 = t1*a1-t1*b1;
    ll ans = 0;
    if((dif>0&&dif2<0)||(dif<0&&dif2>0))ans++;
    //dif2 -= dif;
    ans += -(dif2+1)/dif*2+(dif2%dif==0);
    //ll ans = -dif2/dif*2+(dif2%dif==0)+1;
    cout<<ans<<endl;*/

    ll A1 = t1*a1-t1*b1,A2=t2*a2-t2*b2;
    /*if((A1>0&&A2>0)||(A1<0&&A2<0)){cout<<0;return 0;}
    ll ans = (abs(A1)+abs(A1+A2)-1)/abs(A1+A2)*2+(abs(A1)%abs(A1+A2)==0)-1;*/
    if(A1>0){A1*=-1;A2*=-1;}
    if(A1+A2<0){cout<<0;return 0;}
    if(A1+A2==0){cout<<"infinity";return 0;}
    ll S = -A1/(A1+A2);
    ll T = -A2%(A1+A2);
    if(T!=0)cout<<S*2+1;
    else cout<<S*2;


    return 0;
}

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

int main () {;
	int x, i;
	
	i = 1;
	while(1){
    cin >> x;
    if ( x == 0 ) {
		break;
    }
		cout << "Case " << i << ": " << x << endl;
		i++;
	}
	return 0;
}

Measured memory_bytes: 3008
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){
	int k, s;
	cin >> k >> s;
	int cnt = 0;
	FORI(0, k + 1) {
		FORJ(0, k + 1) {
			int z = s - i - j;
			if (z >= 0 && z <= k)
				cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
using System;



class Program
{
    static void Main(string[] args)
    {
        Input CInput = new Input();
        int[] input = new int[(int)Input.Define.MAX_ArraySize];
        int num = 0;
        input = CInput.Multiline_int(ref num);

        for (int i = 0; i < num; i++)
        {
            Console.WriteLine("Case {0}: {1}",i+1,input[i]);
        }
    }

    class Input
    {
        public enum Define
        {
            MAX_ArraySize = 1000000
        }

        public string Line1_string()
        {
            return Console.ReadLine();
        }

        public int Line1_int()
        {
            var input = Console.ReadLine();
            return int.Parse(input);
        }

        public int[] Line1_int(int chr, int num)
        {
            var input = Console.ReadLine();
            var split = input.Split(' ');
            int[] spliti = new int[10];
            for (int i = 0; i < num; i++)
            {
                spliti[i] = int.Parse(split[i]);
            }
            return spliti;
        }

        public int[] Multiline_int(ref int num)
        {
            int i = 0;
            int[] data = new int[(int)Input.Define.MAX_ArraySize];
            while (true)
            {
                var input = Console.ReadLine();
                var value = int.Parse(input);
                if (value == 0) break;
                data[i] = value;
                i++;
            }
            num = i;
            return data;
        }
    }
}

Measured memory_bytes: 20940
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <cfloat>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    else {
        return d < 0? -1 : 1;
    }
}

struct Vector {
    double x, y;
    Vector(double x = 0, double  y = 0):x(x), y(y) {
    }
     
    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

double dist(const Point& a, const Point& b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

bool cmpY(const Point& a,  const Point& b) {
    return dcmp(a.y - b.y) < 0 || (dcmp(a.y - b.y) == 0 && dcmp(a.x - b.x) < 0);
}

double combine(vector<Point>& p, int l, int m, int r, double leftSmall, double rightSmall) {
    double d = min(leftSmall, rightSmall);
    double x = (p.at(m).x + p.at(m + 1).x)/2;
    
    vector<Point> strip;
        
    for (int i = m; i >= l && dcmp(x - p.at(i).x - d) <= 0; i--) {
        strip.push_back(p.at(i));
    }
    for (int j = m + 1; j <= r &&dcmp(p.at(j).x - x - d) <= 0; j++) {
        strip.push_back(p.at(j));
    } 
    
    sort(strip.begin(), strip.end(), cmpY);
    
    int size = strip.size();
    
    for (int i = 0; i < size; i++) {
        for (int j = i+1; j < size && dcmp(strip[j].y - strip[i].y - d) < 0; j++) {
            if (dcmp(dist(strip[i], strip[j]) - d) < 0) {
                d = dist(strip[i], strip[j]);
            }
        }
    }
    return d;
}

//naive n^2 method
double combine1(vector<Point>& p, int l, int m, int r, double leftSmall, double rightSmall) {
    double d = min(leftSmall, rightSmall);
    double x = (p.at(m).x + p.at(m + 1).x)/2;
    
    double best = DBL_MAX;
    
    for (int i = m; i >= l && dcmp(x - p.at(i).x - d) <= 0; i--) {
        for (int j = m + 1; j <= r &&dcmp(p.at(j).x - x - d) <= 0; j++) {
            best = min(best, dist(p.at(i), p.at(j)));
        } 
    }
    return min(best, d);
}


double solve(vector<Point>& p, int l, int r) {
    if (l >= r) {
        return DBL_MAX;
    }
    int m = (l + r) / 2;
    
    double leftSmall = solve(p, l, m);
    double rightSmall = solve(p, m + 1, r);
    
    return combine(p, l, m, r, leftSmall, rightSmall);
}

int main() {
    int n; 
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    
    sort(p.begin(), p.end());
    
    double ans = solve(p, 0, n - 1);
    
    cout << fixed << setprecision(8) << ans << endl;
    
    return 0;
}

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


using namespace std;
constexpr long long int mod = 1000000007, MOD = 998244353;
constexpr double PI = 3.14159265358979323846;

int main() {
	long long N;
	cin >> N;
	vector<long long>U(N+1),Usum(N+2);
	for (long long i = 0; i <= N; i++)
	{
		cin >> U.at(i);
	}
	for (long long i = 1; i <= N+1; i++)
	{
		Usum.at(i) = Usum.at(i - 1) + U.at(i - 1);
	}
	
	
	vector<long long>maxe(N+1);//たれてるふんどし
	maxe.at(0) = 1;

	for (long long i = 0; i < N; i++)
	{
		if (maxe.at(i) < U.at(i)) { cout << -1; return 0; }
		else {
			//cout << Usum.at(N)-Usum.at(i) << endl;
			maxe.at(i + 1) =min((maxe.at(i)- U.at(i) )*2,Usum.at(N+1)-Usum.at(i+1));//早いうちに広げる，でも広げすぎると片付けられなくなる
			if(maxe.at(i+1)==0) { cout << -1; return 0; }
		}
		maxe.at(N) = 0;
	}
	long long ans = 0;
	for (long long i = 0; i <= N-1; i++)
	{
		//cout << maxe.at(i) << endl;
		ans += maxe.at(i);
	}
	
	ans += U.at(N);
	if (N == 0 && U.at(0) != 1)ans = -1;
	if (N!=0&&((maxe.at(N - 1) - U.at(N - 1)) * 2 < U.at(N) || U.at(N) <= 0))ans = -1;
	cout << ans;
}

Measured memory_bytes: 5640