akhauriyash/Code-Regression huggingface dataset:
//Author: AnandRaj uux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
    		}
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3&&i%5) sum+=i;
	}
	cout<<sum<<endl;
}		

Measured memory_bytes: 3592
while True:
    n=int(input())
    x=[]
    for i in range(n):
        a=int(input())
        x.append(a)
        i+=1
    if n==0:
        break
    x.sort()
    sum=0
    l=len(x)
    for i in range(1,l-1):
        sum+=x[i]
    y=sum//(l-2)
    print(y)



Measured memory_bytes: 5600
N=int(input())
A=list(map(int,input().split()))
A.append(10**9+1)
count=0
ans=0
for i in range(N):
  if A[i]>=A[i+1]:
    count+=1 
  else:    
    ans=max(ans,count)
    count=0
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

char u[3] = {'R', 'G', 'B'};

void solve() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	if (n <= 2) {
		cout << 0 << endl;
		return;
	}
	int r = 0, g = 0, b = 0;
	rep(i,n) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}

	int ng = 0;
	for (int i = 1; i < n - 1; i++) {
		for (int j = 0; j < i; j++) {
			char c1 = s[i];
			char c2 = s[j];
			int k = i + (i - j);
			if (c1 == c2) continue;
			if (k >= n) continue;
			if (c1 != s[k] && c2 != s[k]) ng++;
		}
	}
	cout << (ll) r * g * b - ng << endl;
}

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

Measured memory_bytes: 3636
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int H, W, i, j;
	for (;;) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if (i == 0 || i+1 == H || j == 0 || j+1 == W) {
					putchar('#');
				} else {
					putchar('.');
				}
			}
			putchar('\n');
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 572
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[0]+list(map(int,input().split()))
    ans=0
    for i in range(len(l)-1):
        x=l[i+1]-l[i]
        if x>0:
            ans+=x
    print(ans)
resolve()

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

void Main()
{
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

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

int main(){
    string a, b;
    cin >> a >> b;

    if(a.substr(0,1) == b.substr(2,1) && a.substr(1,1) == b.substr(1,1) && a.substr(2,1) == b.substr(0,1)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,vector<ll> > P;
typedef pair<P,ll>Q;



int main(void){
    ll x;
    cin>>x;
    for(ll a=0;a*a*a*a*a<=x;a++){
        for(ll b=0;b*b*b*b*b<=x;b++){
            if(a*a*a*a*a+b*b*b*b*b==x){
                cout<<a<<" "<<-b<<endl;
                return 0;
            }
        }
    }
    vector<ll>pre,bak;
    ll y = (ll)INF;
    for(ll a=0;a*a*a*a*a<=y;a++){
        pre.push_back(a*a*a*a*a);
        bak.push_back(a*a*a*a*a);
    }
    for(int i=0;i<pre.size();i++){
        auto itr = lower_bound(bak.begin(),bak.end(),pre[i]-x);
        if(itr==bak.end())continue;
        ll B = *itr;
        if(pre[i]-B==x){
            for(ll a=0;a*a*a*a*a<=pre[i];a++){
                if(a*a*a*a*a==pre[i]){
                    cout<<a<<endl;
                    break;
                }
            }
            for(ll a=0;a*a*a*a*a<=pre[i];a++){
                if(a*a*a*a*a==B){
                    cout<<a<<endl;
                    break;
                }
            }
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double h = x / (a * a);
  double ans;
  double degree = (180.0/3.141592653589793238463);
  if(((a*a)*b) / 2 <= x){
    ans = atan(-((2 * (h-b))/a));
  }else{
    ans = atan(b/((2 * a * h)/b));
  }

  ans = ans * degree;
  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    println(test(readLine()!!.split(" ").map(String::toInt),
            false, 0))
}

fun test(A : List<Int>, flag : Boolean, count : Int) : Int {
    var tmp : MutableList<Int> = mutableListOf()
    if (flag) {
        return count
    }
    for (Ai in 0..A.size.minus(1)) {
        if (A[Ai] % 2 != 0) {
            return test(tmp, true, count)
        } else {
            tmp.add(Ai, A[Ai] / 2)
        }
    }
    return test(tmp, false, count.plus(1))
}

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

void solve(long long N, std::vector<long long> A){
    ll money = 1000;
    ll stock = 0;
    for(int i=0;i<N;i++){
        if(i == N-1){
            money += stock* A[i];
            stock =0;
            break;
        }
        if(A[i] < A[i+1]){
            ll bought = money/A[i];
            stock += bought;
            money%=A[i];
        }else{
            money += stock* A[i];
            stock =0;
        }
    }
    cout << money << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3700
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += - P[j][1]*P[j+1][0] + P[j+1][1] * P[j][0]
print(s*0.5)

Measured memory_bytes: 7732
import sys, math, re
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    N = ii()
    d = make_divisors(N)
    ans = 0

    for a in d:
        m = (N-a)//a
        if a < m:
            ans += m

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9960
#include<bits/stdc++.h>
#define int long long

using namespace std;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k, t;
    vector<int> v;
    cin >> n >> k;
    while (n--)
        cin >> t, v.push_back(t);
    sort(v.begin(), v.end());

    while (!v.empty() && k--)
        v.pop_back();

    int ans = 0;
    for (int i : v)
        ans += i;
    cout << ans << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 2420
#include <stdio.h>
int i,j,RB[51][51],N,M,ans,a[8][2]={-1,0,1,0,0,-1,0,1,-1,-1,-1,1,1,-1,1,1};void bfs(int x, int y) {RB[x][y]=0;for (int q=0,nx,ny;q<8;q++) {nx=x+a[q][0],ny=y+a[q][1];if (nx>=0 && nx<N && ny>=0 && ny<M && RB[nx][ny]) bfs(nx,ny);}}
int main() {while (1) {scanf("%d %d",&M,&N);if (!N && !M) return 0;ans=0;for (i=0;i<N;i++) for (j=0;j<M;scanf("%d",&RB[i][j++]));for (i=0;i<N;i++) for (j=0;j<M;j++) if (RB[i][j]) bfs(i,j),ans++;printf("%d\n",ans);}}

Measured memory_bytes: 0
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let A = scan.list::<usize>(N + 1);

    let mut ok = true;

    // B[d] = (深さ d の内部ノードの個数)
    let mut B = vec![0; N + 1];

    // 最大値を計算する。子ノードの個数が常に1のとき最大。
    for d in (0..N).rev() {
        B[d] = A[d + 1] + B[d + 1];
    }

    // 深さ 0 の頂点は最大 1 個。
    ok = ok && A[0] <= 1;
    B[0] = 1_usize.saturating_sub(A[0]);

    #[cfg(debug_assertions)]
    eprintln!("\x1B[33m{}\x1B[0m = {:?}", "B", B);

    let mut modified;
    while ok {
        modified = false;

        for d in 1..N {
            // 二分木の条件: ある世代のノードの個数の上限は親世代の内部ノードの個数の2倍
            let k = (B[d - 1] * 2).saturating_sub(A[d]);
            if B[d] > k {
                B[d] = k;
                modified = true;
            }
        }

        for d in (0..N).rev() {
            let k = A[d + 1] + B[d + 1];
            if B[d] > k {
                B[d] = k;
                modified = true;
            }
        }

        #[cfg(debug_assertions)]
        eprintln!("\x1B[33m{}\x1B[0m = {:?}", "B", B);

        // 条件を再確認する。
        ok = ok && (0..N).all(|d| B[d] <= A[d + 1] + B[d + 1]);
        ok = ok && (1..=N).all(|d| A[d] + B[d] <= B[d - 1] * 2);

        if !modified {
            break;
        }
    }

    if ok {
        let total = (0..=N).map(|d| A[d] + B[d]).sum::<usize>();
        println!("{}", total);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 5428
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] p = {1, 100, 10000, 1000000 };
        int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(p[ab[0]] * (ab[1] + ab[1] / 100));
    }
}

Measured memory_bytes: 13268
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Thu Jan 17 15:51:53 2019
//
package main

import (
	"fmt"
	"strings"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)

	fmt.Println(strings.Repeat("#", W+2))
	for i := 0; i < H; i++ {
		var s string
		fmt.Scan(&s)
		fmt.Println("#" + s + "#")
	}
	fmt.Println(strings.Repeat("#", W+2))
}


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

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

    if(str == "Sunny")
    {
        std::cout << "Cloudy" << std::endl;
    }
    else if(str == "Cloudy")
    {
        std::cout << "Rainy" << std::endl;
    }
    else
    {
        std::cout << "Sunny" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

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

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
        	String line = reader.readLine();
        	int x = Integer.parseInt(line);
        	System.out.println(x * x * x);
        }
        catch (IOException e) {
          System.out.println(e);
        } 
      }
    }
    

Measured memory_bytes: 24316
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
        	string s;
        	cin>>s;
        	ll n=s.size(),sum=0;
        	REP(i,0,n-1){
        		sum+=(s[i]-'0');
        	} 
        	sum%9==0?cout<<"Yes\n":cout<<"No\n";
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, t;
    cin >> x >> t;
    cout << max(0LL, x - t) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ALDS1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = scan[0];
            var A = scan;
            var T = new Dictionary<int,int>();
            var temp = A.OrderBy(i => i).ToArray();
            for (int i = 0; i < n; i++) T[temp[i]] = i;
            var V = new bool[n];
            var s = A.Min();
            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (V[i]) continue;
                int cur = i;
                int sum = 0;
                int min = A[cur];
                int an = 0;
                while (!V[cur])
                {
                    V[cur] = true;
                    an++;
                    if (min > A[cur]) min = A[cur];
                    sum += A[cur];
                    cur = T[A[cur]];
                }
                ans += Math.Min(sum + (an - 2) * min, min + sum + (an + 1) * s);
            }
            Console.WriteLine(ans);
        }

        static int[] scan
        {
            get { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
        }
    }
}

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

using namespace std;

int btoi(string s)
{
	int n=0;
	for(int i=0;i<7;i++){
		n<<=1;
		if(s[i]=='1')
			n++;
	}
	return n;
}
string itob(int n)
{
	string s;
	for(int i=0;i<7;i++)
		s+='0'+(n>>i&1);
	reverse(begin(s),end(s));
	return s;
}

int main()
{
	int ss[]={
		btoi("0111111"), // 0
		btoi("0000110"), // 1
		btoi("1011011"), // 2
		btoi("1001111"), // 3
		btoi("1100110"), // 4
		btoi("1101101"), // 5
		btoi("1111101"), // 6
		btoi("0100111"), // 7
		btoi("1111111"), // 8
		btoi("1101111"), // 9
	};
	
	for(int n;cin>>n,~n;){
		int c=0;
		while(n--){
			int x; cin>>x;
			to_string(x);
			cout<<itob(c^ss[x])<<endl;
			c=ss[x];
		}
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s,t,str,a[105];int tot=0;
int change(int pos)
{
	str="";
	for(int i=0;i<s.length();i++)
	if(i<pos||i>=pos+t.length())
	{
		str+=s[i];
		if(s[i]=='?') str[i]='a';
	}
	else
	{
		str+=t[i-pos];
		if(s[i]!=t[i-pos]&&s[i]!='?') return 0;
	}
	return 1;
}
int main()
{
    cin>>s>>t;
    for(int i=0;i<s.length()-t.length()+1;i++)
    if(change(i)) a[tot++]=str;
    sort(a,a+tot);
    if(!tot) printf("UNRESTORABLE\n");
    else cout<<a[0]<<endl;
    return 0;
}

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

(defun solve-2 (n i bricks start)
  (let ((next (position i bricks :start start :test #'=)))
    (if next
        (+ (- next start) (solve-2 n (1+ i) bricks (1+ next)))
        (- n start))))

(defun solve (n bricks)
  (let ((res (solve-2 n 1 bricks 0)))
    (if (= n res)
        -1
        res)))

#-swank
(let* ((n (read))
       (bricks (make-array n :element-type 'integer)))
  (loop for i from 0 below n
        do (setf (aref bricks i) (read)))
  (format t "~A~%" (solve n bricks)))


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

INF = float('inf')
dp = [[INF] * (n+10) for _ in range(n)]

for i in range(n):
    for k in range(n):
        if k == 0:
            dp[i][k] = a[i]
        else:
            dp[i][k] = min(dp[i][k-1], a[(i-k)%n])

ans = INF

for k in range(n):
    tmp = x * k
    for i in range(n):
        tmp += dp[i][k]
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 139228
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N, K, X, Y;
  cin >> N >> K >>  X >> Y;
  if(N < K) cout << N * X << endl;
  else cout << K*X + (N-K) * Y << endl;

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ii pair<int, int>
#define iill pair <ii, ll>
#define ill pair<int, ll>
#define MAXN 
#define EPS 1e-9
#define MAXLOG 
#define MOD 
#define prt(a) printf("%d\n", a)
#define prt2(a, b) printf("%d %d\n", a, b)
#define prt3(a, b, c) printf("%d %d %d\n", a, b, c)
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d %d", &a, &b)
#define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define readArr(arr, n) for (int i=0; i<n; i++) scanf("%d", &arr[i]);
#define EPS 1e-9
#define ll long long
using namespace std;


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

	for (int i=n-k+1; i<=n+k-1; i++) {
		printf("%d%c", i, " \n"[i==n+k-1]);
	}

	return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC070
{
    class Program
    {
        static void Main()
        {
            var n = Console.ReadLine();
            var result = "No";
            if (n[0] == n[2]) result = "Yes";
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
s=s0()

a=[0]*1000
for i in range(1000):
    num=str(i).zfill(3)
    j=0
    for x in s:
        if x==num[j]:
            j+=1
        if j==3:
            a[i]=1
            break
print(sum(a))

Measured memory_bytes: 41052
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

func prime(maximum int) [] bool {
	sieve := make([]bool, maximum)
	for i := range sieve {
		sieve[i] = true
	}

	sieved := func(prime int) {
		for i := prime + prime; i < maximum; i += prime {
			sieve[i] = false
		}
	}

	sieve[0] = false; sieve[1] = false
	sieved(2)
	end := int(math.Pow(float64(maximum), 0.5) + 1)
	for i := 3; i < end; i += 2 {
		if sieve[i] {
			sieved(i)
		}
	}
	return sieve
}

func solve(q int64, ls []int64, rs []int64) []int64 {
	ps := prime(100001)
	lls := make([]int64,  100001)
	c := int64(0)
	for i, _ := range lls {
		if (i % 2) != 0 && ps[i] && ps[(i + 1) / 2] {
			c ++
		}
		lls[i] = c
	}
	res := make([]int64, q)
	for i, _ := range res {
		res[i] = lls[rs[i]] - lls[ls[i] -1]
	}
	return res
}

func main() {
	defer out.Flush()

	q := nextInt()
	ls := make([]int64, q)
	rs := make([]int64, q)
	for i, _ := range ls {
		ls[i] = nextInt()
		rs[i] = nextInt()
	}
	res := solve(q, ls, rs)
	for _, r := range res {
		fmt.Fprintln(out, r)
	}
}

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

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	ll N,M;
   	cin>>N>>M;
   	ll sum=0,temp;
   	for(int i=0;i<M;i++)
   	{
   		cin>>temp;
   		sum+=temp;
   	}
   	if(N>=sum)
   		cout<<N-sum<<endl;
   	else
   		cout<<-1;
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	
	int n, m; cin >> n >> m;
	vector<pii> a(n);
	for (auto& p : a) cin >> p.fi >> p.se;

	set<int> days;
	for (int i = 1; i <= m; i++) days.emplace(i);

	sort(a.begin(), a.end(), [](pii const& x, pii const& y) {
		return x.se == y.se ? x.fi < y.fi: x.se > y.se;
	});

	ll ans = 0;
	for (auto p : a) {
		if (days.empty()) break;
		auto it = days.upper_bound(m - p.fi + 1);
		if (it != days.begin()) {
			it--;
			days.erase(it);
			ans += p.se;
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 5760
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		
		int ret = 0;
		
		int[] xi = new int[n];
		int[] yi = new int[n];
		int[] ai = new int[n];
		
		for( int i = 0 ; i < n ; i++  ) {
			xi[i] = sc.nextInt();
			yi[i] = sc.nextInt();
			ai[i] = sc.nextInt();
		}
		
		
		ret = w*h;
		for( int y = 0 ; y < h ; y++  ) {
			for( int x = 0 ; x < w ; x++  ) {
				boolean isPainted = extracted(n, xi, yi, ai, y, x);
				if( isPainted )
					ret--;
			}
		}
		
		System.out.println(ret);
	}

	private static boolean extracted(int n, int[] xi, int[] yi, int[] ai, int y, int x) {
		boolean isPainted = false;
		for( int i=0 ; i < n ; i++ ) {
			int xii = xi[i];
			int yii = yi[i];
			int aii = ai[i];
			switch(aii) {
			case 1:
				if( x < xii ) return true;
				break;
			case 2:
				if( x >= xii ) return true;
				break;
			case 3:
				if( y < yii ) return true;
				break;
			case 4:
				if( y >= yii ) return true;
				break;
			}
		}
		return isPainted;
	}
}

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

#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int MAXN = 5e5+5;
const int MOD= 998244353;
int a[50]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    int n;
    while(cin>>n){
        n--;
        cout<<a[n]<<endl;
    }
}


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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int n;

int main()
{
	n=read();
	int ans=0;
	for ( int i=1;i<=n;i++ ) 
		for ( int j=1;j<=n;++j ) 
			for ( int k=1;k<=n;k++ ) 
				ans=(ans+__gcd(__gcd(i,j),k));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long
static const ll INF = 1000000000000000000LL;

using namespace std;

int main(){
    int N, C;
    cin >> N >> C;

    vector <vector <int > > d(C, vector<int>(C, 0));
    vector <vector <int > > t(3, vector<int>(C, 0));


    //(i+j)%3=(x+y)%3ならば(i,j)の色と(x,y)の色は同じ
    //(i+j)%3≠(x+y)%3ならば(i,j)の色と(x,y)の色は異なる

    //任意のますについてのルール

    //->結局どれか3色に塗らないといけなさそう

    REP(i,C)
    {
        REP(j,C)cin >> d[i][j];
    }

    REP(i,N)
    {
        REP(j,N)
        {
            int c;
            cin >> c;
            --c;
            //それぞれ(あまり)の色をカウントする
            //差し替える前の色の個数を覚えておく
            ++t[(i+j)%3][c];
        }
    }

    //(1,1) -> 2
    //30色なので、全通り試す
    ll res = INF;
    for(int i = 0; i < C; ++i)
    {
        for(int j = 0; j < C; ++j)
        {
            if(i == j)continue;
            for(int k = 0; k < C; ++k)
            {
                if(i == k || j == k)continue;
                ll tmp = 0;
                for(int l = 0; l < C; ++l)
                {
                    tmp += d[l][i] * t[0][l];
                }
                for(int l = 0; l < C; ++l)
                {
                    tmp += d[l][j] * t[1][l];
                }
                for(int l = 0; l < C; ++l)
                {
                    tmp += d[l][k] * t[2][l];
                }

                res = min(res, tmp);
            }
        }
    } 

    cout << res << endl;

}


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

int main(){
    int N;
    cin >> N;
    int counter2=0;

    for(int h = 1; h < N+1; h++){
        if(h%2==1){
        int counter1 = 0;
        for(int i = 1; i < h+1; i++ )if(h%i == 0) counter1++;
        
        if(counter1 == 8) counter2++;
    }
    }
    cout << counter2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dy[4] = {0, 1, 0, -1};
//const int dx[4] = {1, 0, -1, 0};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

void solve(){
    ll n; cin >> n;
    ll cntp = 0, cntn = 0, cntz = 0, sum = 0, mi = 100000000010;
    REP(i, n){
        ll ain; cin >> ain;
        sum += abs(ain);
        mi = min(mi, abs(ain));
        if(ain > 0) cntp++;
        if(ain < 0) cntn++;
        if(ain == 0) cntz++;
    }
    if(cntn % 2 == 0) cout << sum << endl;
    else{
        if(cntz > 0) cout << sum << endl;
        else cout << sum - 2*mi << endl;
    }
}

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

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0041
"""
import sys
from itertools import permutations, product




def has_possibility(digits):
    """
    ??°????????????????????????10?????????????????§??????????????????????????????
    ??°????????§?????????????????????????????????????????????????????????????????°??????0 or 1?????´??????????????????????????????
    ????????????????????§??????????????????????????§???????????§???10????????§????????°???????????£??????10?????????????????????
    """
    result = False
    digits.sort(reverse=True)
    total = digits[0]
    for i in digits[1:]:
        if i < 2:
            total += i
        else:
            total *= i
    if total >= 10:
        result = True
    return result


def make_ten(digits):
    result = '0'
    for a, b, c, d in permutations(digits, 4):
        if result != '0':
            break
        for op1, op2, op3 in product(['+', '-', '*'], repeat=3):
            # 1, 2, 3
            exp = '((({} {} {}) {} {}) {} {})'.format(a, op1, b, op2, c, op3, d)
            if eval(exp) == 10:
                result = exp
                break
            # 1, 3, 2
            exp= '(({} {} {}) {} ({} {} {}))'.format(a, op1, b, op2, c, op3, d)
            if eval(exp) == 10:
                result = exp
                break
            # 2, 1, 3
            exp = '(({} {} ({} {} {})) {} {})'.format(a, op1, b, op2, c, op3, d)
            if eval(exp) == 10:
                result = exp
                break
            # 3, 1, 2
            exp = '({} {} (({} {} {}) {} {}))'.format(a, op1, b, op2, c, op3, d)
            if eval(exp) == 10:
                result = exp
                break
            # 3, 2, 1
            exp = '({} {} ({} {} ({} {} {})))'.format(a, op1, b, op2, c, op3, d)
            if eval(exp) == 10:
                result = exp
                break
            # 2, 3, 1
            exp =  '(({} {} {}) {} ({} {} {}))'.format(a, op1, b, op2, c, op3, d)
            if eval(exp) == 10:
                result = exp
                break
    return result


def do_calc(x, y, op):
    result = None
    if op == '+':
        result = x + y
    elif op == '-':
        result = x - y
    elif op == '*':
        result = x * y
    return result


# ????????°????????????????????????10?????????????????????????????¢?????°????????§?????????????????????????????°??????????????¨???????????????????????¨??????????´????????????????
Memo = {}
def solve(digits):
    global Memo
    digits.sort(reverse=True)
    data = ''.join(map(str, digits))
    if data in Memo:
        pass
    else:
        Memo[data] = make_ten(digits)
    return Memo[data]



def main(args):
    while True:
        digits = [int(x) for x in input().strip().split(' ')]
        # digits = [int(x) for x in '{:04d}'.format(count)]
        if digits[0] == 0 and digits[1] == 0 and digits[2] == 0 and digits[3] == 0:
            break
        result = solve(digits)
        print(result)
        #print('count={}, {}'.format(count, result))



if __name__ == '__main__':
    main(sys.argv[1:])

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

int main() {
	int k, even, odd;
	cin >> k;
	even = k/2;
	if(k % 2 == 1){
		odd = (k+1)/2;
	}
	else{
		odd = k/2;
	}
	cout << even*odd << endl;

	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<class T>
struct Edge {
    int src, to;
    T cost;

    Edge (int to, T cost):
        src(-1), to(to), cost(cost) {};
    Edge (int src, int to, T cost):
        src(src), to(to), cost(cost) {};

    operator int() const {
        return to;
    };
};

template <class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using UnWeightedGraph = vector<vector<int> >;
//===

llong n;
WeightedGraph<llong> t;
vector<llong> d;

void dfs(llong u, llong par) {
    for (auto e:t[u]) {
        if (e.to == par) continue;
        d[e.to] += d[u] + e.cost;
        dfs(e.to, u);
    }

    return;
}

int main() {
    cin >> n;
    t.resize(n + 1);
    d.resize(n + 1, 0);

    for (int i = 0; i < n - 1; i++) {
        llong u, v, w;
        cin >> u >> v >> w;

        t[u].emplace_back(v, w);
        t[v].emplace_back(u, w);
    }

    dfs(1, 0);

    for (int i = 1; i <= n; i++) {
        cout << d[i] % 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAX 100001

int main() {

    int N, M;
    int P[MAX], Y[MAX];
    vector<int> G[MAX];

    cin >> N >> M;

    for(int i=0; i<M; i++) {
        cin >> P[i] >> Y[i];
        G[P[i]].push_back(Y[i]);
    }

    for(int i=0; i<N; i++) {
        sort(G[i+1].begin(), G[i+1].end());
    }

    for(int i=0; i<M; i++) {
        printf("%06d%06d\n", P[i], int(lower_bound(G[P[i]].begin(), G[P[i]].end(), Y[i]) - G[P[i]].begin() +1));

    }
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

int main(){

  char alpha;

  cin >> alpha;

  if(alpha>=65&&alpha<=90)
    cout << "A" << endl;
  else
    cout << "a" << endl;

  return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define f first
#define s second
#define endl "\n"
#define F(i,n) for(ll i=0;i<n;i++)
#define mem(x,val) memset(x,val,sizeof(x))
#define mod 1000000007
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cerr.tie(NULL)
vector<vector<ll>> dp;
ll rec(vector<ll>& a,vector<ll>& b,ll h,ll i){
	if(h<=0) return 0;
	if(i==a.size()) return INT_MAX;
	if(dp[i][h]!=-1) return dp[i][h];
	return dp[i][h] = min(rec(a,b,h-a[i],i)+b[i],rec(a,b,h,i+1));
}

int main()
{
    crap;
    ll T = 1;
    //cin>>T;
    while(T--){
    	ll h,n; cin>>h>>n;
    	vector<ll> a(n),b(n);
    	F(i,n) cin>>a[i]>>b[i];
    	dp.resize(n,vector<ll>(h+1,-1));
    	cout<<rec(a,b,h,0)<<endl;
        //ll n; cin>>n;
        //vector<ll> a(n); F(i,n) cin>>a[i];
    }
}

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

int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    //最終的な答えで二分探索
    double ok = INT_MAX, ng = 0;
    for (int64_t i = 0; i < 1000; i++) {
        double mid = (ok + ng) / 2;

        //各丸太を何回切る必要があるかを数えていく
        int64_t cut_count = 0;
        for (int64_t j = 0; j < N; j++) {
            int64_t curr_cut_num = floor((double)A[j] / mid);
            cut_count += curr_cut_num;
        }

        (cut_count <= K ? ok = mid : ng = mid);
    }

    constexpr double eps = 1e-6;
    int64_t r = round(ok);
    if (r - eps < ok && ok < r + eps) {
        cout << r << endl;
    } else {
        cout << (int64_t)ceil(ok) << endl;
    }
}

Measured memory_bytes: 4900
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;
ll dp[100005][4];
vi a(100005),b(100005),c(100005);
ll n;
ll solve(ll taken,ll i,ll j)
{
    if(i>=n)return 0;
    if(dp[i][j]!=-1)return dp[i][j];

    if(taken!=1) dp[i][1]=a[i]+max(solve(1,i+1,2),solve(1,i+1,3));
    if(taken!=2)dp[i][2]=b[i]+max(solve(2,i+1,1),solve(2,i+1,3));
    if(taken!=3)dp[i][3]=c[i]+max(solve(3,i+1,1),solve(3,i+1,2));

    if(taken==1)return max({dp[i][2],dp[i][3]});
    if(taken==2)return max({dp[i][1],dp[i][3]});
    if(taken==3)return max({dp[i][2],dp[i][1]});
    else return max({dp[i][2],dp[i][1],dp[i][3]});
}



int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    fr(i,0,n)cin>>a[i]>>b[i]>>c[i];

    cout<<solve(0,0,0)<<endl;


   /* fr(i,1,4)
    {
        fr(j,0,n)cout<<dp[j][i]<<" ";
        cout<<endl;
    }
*/

}



























Measured memory_bytes: 14844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Mehvix
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc167_b solver = new abc167_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc167_b {
        public void solve(int testNumber, Scanner fin, PrintWriter fout) {
            int a = fin.nextInt();
            int b = fin.nextInt();
            int c = fin.nextInt();
            int k = fin.nextInt();

            int sum = 0;

            sum += Math.min(a, Math.max(k, 0));
            k -= a;
            k -= b;
            sum -= Math.min(c, Math.max(k, 0));

            fout.println(sum);
        }

    }
}



Measured memory_bytes: 27044
def InsertionSort(seq):
    print(*seq)
    for i in range(len(seq) - 1):
        j = i

        while j >= 0:
            if seq[j + 1] < seq[j]:
                seq[j + 1], seq[j] = seq[j], seq[j + 1]
                
            j -= 1 

        print(*seq)

def main():
    n = int(input())
    seq = [int(a) for a in input().split()]
    InsertionSort(seq)

main()


Measured memory_bytes: 5980
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vvll vector<ll>
#define vll(a) vector<ll> a(MAXN)
#define pb push_back
#define fo(a) for(auto&a1:(a))
#define fd(a,b) for(int i=(a);i>=(b);i--)
#define fk(a,b) for(int k=(a);k<(b);k++)
#define fj(a,b) for(int j=(a);j<(b);j++)
#define f(a,b) for(ll i=(a);i<(b);i++)
#define forni(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define fdk(a,b) for(int k=(a);k>=(b);k--)
#define fdj(a,b) for(int j=(a);j>=(b);j--)
#define ri(n) scanf("%d",&(n));
#define rll(n) scanf("%lld",&(n));
#define T(t) int t;scanf("%d",&(t));while((t)--)
#define MAXN 100005
#define MAXN2 10000005
#define pll pair<ll,ll>
#define PI 3.14159265
#define mset(a) memset((a),0,sizeof((a)))
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll mod=1000000007;
int main()
{
    ll n,mw;
    cin>>n>>mw;
    ll w[n+1]={0},v[n+1]={0};
    f(1,n+1)
    cin>>w[i]>>v[i];
    ll dp[n+1][MAXN];
    mset(dp);
    f(0,n)
    {
        dp[i+1][v[i+1]]=w[i+1];
        fj(1,MAXN)
        {
            if(dp[i][j])
            {
                if(dp[i+1][j+v[i+1]])
                dp[i+1][j+v[i+1]]=min(dp[i+1][j+v[i+1]],dp[i][j]+w[i+1]);
                else
                dp[i+1][j+v[i+1]]=dp[i][j]+w[i+1];
                if(dp[i+1][j])
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
                else
                dp[i+1][j]=dp[i][j];
            }
        }
        //cout<<"\n";
    }
    ll ans=0;
    f(0,n+1)
    {
        fj(0,MAXN)
        {
            //cout<<dp[i][j]<<" ";
            if(dp[i][j]!=0 && dp[i][j]<=mw)
            ans=max(ans,(ll)j);
        }
        //cout<<"\n";
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 82492
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int a[]=new int[N];
		int b[]=new int[100001];
		int z=0,max=0;
		while(z<N){
			a[z]=stdIn.nextInt();
			b[a[z]]++;
			z++;
		}z=0;
		while(z<99999){
			if(b[z]+b[z+1]+b[z+2]>max)
				max=b[z]+b[z+1]+b[z+2];
			z++;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 63108
F = 10000
mod = 10**9+7
fact = [1]*F
inv = [1]*F
for i in range(2,F):
    fact[i]=(fact[i-1]*i)%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(F-2,1,-1):
    inv[i] = (inv[i+1]*(i+1))%mod

def comb(n,k):
    ans=(fact[n]*inv[n-k])%mod
    return (ans*inv[k])%mod
def H(n,k):
    return comb(n+k-1,k)

s=int(input())
ans=0

# s=15-17 なら k=1,2,3,4,5 
for k in range(1,s//3+1):
    ans+=H(s-3*k+1,k-1)
    #print(k,H(s-3*k,k-1))
    ans%=mod

print(ans)

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

struct Dice
{
	Dice(int d[6]){
		for(int i = 0; i < 6; ++i)
			n[i] = d[i];
	}
	int getIndex( int a ){
		for(int i = 0; i < 6; ++i){
			if( n[i] == a )
				return i;
		}
		return -1;
	}
	int getRightNumberOfTopFront( int t, int f ){
		return n[getRightIndexOfTopFront( getIndex(t), getIndex(f) )]; 
	}
	int getRightIndexOfTopFront( int t, int f ){
		switch( t )
		{
		case 0:
			switch( f )
			{
			case 1: return 2;
			case 2: return 4;
			case 3: return 1;
			case 4: return 3;
			}
		case 1:
			switch( f )
			{
			case 0: return 3;
			case 2: return 0;
			case 3: return 5;
			case 5: return 2;
			}
		case 2:
			switch( f )
			{
			case 0: return 1;
			case 1: return 5;
			case 4: return 0;
			case 5: return 4;
			}
		case 3:
			switch( f )
			{
			case 0: return 4;
			case 1: return 0;
			case 4: return 5;
			case 5: return 1;
			}
		case 4:
			switch( f )
			{
			case 0: return 2;
			case 2: return 5;
			case 3: return 0;
			case 5: return 3;
			}
		case 5:
			switch( f )
			{
			case 1: return 3;
			case 2: return 1;
			case 3: return 4;
			case 4: return 2;
			}
		}
		return -1;
	}
	int n[6];
};

int main()
{
	int n, i, t, f, d[6] = {};
	for(i = 0; i < 6; ++i)
		cin >> d[i];

	Dice dice(d);
	cin >> n;
	for(i = 0; i < n; ++i){
		cin >> t >> f;
		cout << dice.getRightNumberOfTopFront( t, f ) << "\n";
	}

	return 0;
}

Measured memory_bytes: 1160
import sys, os, random, math

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

def solve(N, M):
        L = math.sqrt(M) + 0.5
        i = N
        while i <= L:
                if M % i == 0:
                        return M / i
                i = i + 1
        i = N-1
        while i >= 1:
                if M % i == 0 and M / i >= N:
                        return i
                i = i - 1
        assert 0

N, M = rdi()
print solve(N, M)

Measured memory_bytes: 4588
#include<bits/stdc++.h>
#define fori(j,n) for(ll i=j;i<n;i++)
#define forb(n,j) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define pb push_back
#define ll long long
#define mp make_pair
#define ff first
#define ss second
#define vec vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll sgn(ll x){
    if(x>0)
        return 1;
    if(x==0)
        return 0;
    return -1;
}
//const ll N = 2e5 + 5;
int32_t main()
{
    IOS;
    string s1,s2;
    cin>>s1;
    cin>>s2;
       ll c=0;
    if(s1==s2)
    {
        cout<<0;
    }
    else{
        fori(0,s1.length())
        {
            if(s1[i]!=s2[i])
            {
                c++;
            }
        }
        cout<<c;
    }

    return 0;
}




Measured memory_bytes: 3888