akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
// queue: first in first out
// stack: first in last out
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
const ll NUM = 1e5+1;
// ll dp[100005][13];
ll dp[10005];

ll Query[NUM];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(void) {
  ll X;
  cin >> X;
  ll ans = 0;
  ll tmp = X/500;
  ans += tmp * 1000;
  X -= tmp * 500;
  tmp = X/5;
  ans += tmp*5;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;

ll A[10010], B[10010];

int main()
{
	int i, j, k;
	scanf("%d", &N);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &A[i]);
	}
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &B[i]);
	}
	ll a, b;
	a = b = 0LL;
	for (i = 1; i <= N; ++i) {
		if (A[i] > B[i]) {
			b += (A[i] - B[i]);
		}
		else if (A[i] < B[i]) {
			ll tmp = B[i] - A[i];
			if (tmp % 2 == 1) {
				b++;
				a += (tmp + 1) / 2;
			}
			else a += tmp / 2;
		}
	}
	if (a >= b) printf("Yes");
	else printf("No");

}

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

template<class T>
void prvec(vector<T> &vec) 
{
    for (T &ele: vec) {
        cout << ele << "";
    }
    cout << endl;
    return;
}

template<class T>
void prvecvec(vector<vector<T>> &vecvec) 
{
    for (int i = 0; i < (int)vecvec.size(); ++i) {
        prvec(vecvec[i]);
    }
    return;
}

const int MAXN = 200005;
int A[MAXN];
int N;
int pow2[32];
multiset<int> ms;

int main() 
{
	// freopen("./input.txt", "r", stdin);
    cin >> N;
    ms.clear();
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        ms.insert(A[i]);
    }
    sort(A, A + N);
    pow2[0] = 1;
    for (int i = 1; i < 32; ++i) {
        pow2[i] = 2 * pow2[i - 1];
    }
    int ans = 0;
    for (int i = N - 1; i >= 0; --i) {
        auto pos = ms.find(A[i]);
        if (pos == ms.end()) {
            continue;
        }
        ms.erase(pos);
        int j;
        for (j = 0; j < 32; ++j) {
            if (pow2[j] > A[i]) {
                break;
            }
        }
        int diff = pow2[j] - A[i];
        pos = ms.find(diff);
        if (pos != ms.end()) {
            ++ans;
            ms.erase(pos);
        }
    }
    cout << ans << endl;    
    
	return 0;
}



Measured memory_bytes: 12032
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>

using namespace std;

typedef long long ll;

#ifdef ONPC
    mt19937 rnd(228);
#else
    mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s = "";
    char c;
    while (cin >> c) s += c;
    sort(s.begin(), s.end());
    if (s == "1479")
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s, t;
    cin>>s>>t;
    int lenS=s.length();
    int lenT=t.length();
    int ans=1e4;
    for (int i=0; i+lenT<=lenS; i++){
        int change=0;
        for (int j=0; j<lenT; j++){
            if (s[i+j]!=t[j]){
                change++;
            }
        }
        ans = min(ans, change);
    }
    cout<<ans<<"\n";
return 0;
}

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

#define int long long

using namespace std;



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

    int N, D;

    cin >> N >> D;

    int res = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	int x, y;
    	cin >> x >> y;

    	if(x*x + y*y <= D*D)res++;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> P;
P sum[1000001];
int N;
main(){
  while(1){
    scanf("%d",&N);
    if(!N) break;
    for(int i=0;i<N;i++){
      int c;
      scanf("%d",&c);
      sum[i].first=0;
      sum[i].second=c;
      for(int j=0;j<4;j++){
	int m,s;
	scanf("%d %d",&m,&s);
	sum[i].first += m*60+s;
      } 
    }
    sort(sum,sum+N);
    printf("%d\n%d\n%d\n",sum[0].second,sum[1].second,sum[N-2].second);
  }
}

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

using ReversedMultiSet = std::multiset<uint64_t, std::greater<uint64_t> >;

int main() {
    int n, m;
    std::cin >> n >> m;

    auto works = std::vector<ReversedMultiSet>(m, ReversedMultiSet());

    for(int i = 0; i < n; ++i) {
        int a, b;
        std::cin >> a >> b;
        --a;
        if(a < m) {
            works[a].insert(b);
        }
    }

    auto available_works = ReversedMultiSet();

    uint64_t answer = 0;

    for(const auto w: works) {
        for(auto b: w) {
            available_works.insert(b);
        }

        auto b = available_works.cbegin();
        if(b != available_works.cend()) {
            answer += *b;
            available_works.erase(b);
        }
    }

    std::cout << answer << std::endl;

    return 0;
}


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

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;

    if ((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ||
        (s[0] == s[2] && s[3] == s[1] && s[0] != s[3]) ||
        (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

string S;

signed main(){

    in(S);
    Yn(S[0]==S[2]);

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
dic = {}
for i in range(0, N):
    Ak = list(map(int, input().split()))[1:]
   # print(Ak)
    for v in Ak:
        if v in dic.keys():
            dic[v] += 1
        else:
            dic[v] = 1    
result = 0
for vals in dic.values():
    if vals == N:
        result += 1

print(result)

Measured memory_bytes: 3060
N=int(input())
A,B,C=[input() for i in range(3)]
ans=0
for i in range(N):
    if A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]:
        ans+=2
    elif A[i]!=B[i] or A[i]!=C[i]:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
const int IMAX = 1001;
ll fac[IMAX + 1], ifac[IMAX + 1];
ll dp[2][1001];

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


	fac[0] = 1;
	rep1(i, IMAX) fac[i] = fac[i - 1] * i % mod;
	ifac[IMAX] = modpow(fac[IMAX], mod - 2);
	for (int i = IMAX; i > 0; i--) ifac[i - 1] = ifac[i] * i % mod;

	int N, A, B, C, D;
	scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
	dp[1][0] = fac[N];
	for (int i = A; i <= B; i++) {
		rep(j, N + 1) dp[0][j] = (dp[1][j] %= mod);
		int d = min(D, N / i);
		ll tmp = modpow(ifac[i], d) * ifac[d] % mod;
		for (int j = d; j >= C; j--) {
			for (int k = 0; k + i * j <= N; k++) {
				dp[1][k + i * j] += dp[0][k] * tmp % mod;
			}
			tmp = tmp * fac[i] % mod * j % mod;
		}
	}
	printf("%lld", dp[1][N] % mod);

	Would you please return 0;
}

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

int main() {
	string s;
	cin >> s;
	int counter = 0;
	if (s[0] == '1') ++counter;
	if (s[1] == '1') ++counter;
	if (s[2] == '1') ++counter;
	cout << counter << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A, B, C, D;

  cin >> A >> B >> C >> D;

  if (A != C) {
    puts("1");
  } else {
    puts("0");
  }



  return 0;
}


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

int main(){
  ll N, M;
  cin >> N >> M;
  ll ans = 0;
  if(N == 1 && M == 1) ans = 1;
  else if(N == 1) ans = M - 2;
  else if(M == 1) ans = N - 2;
  else ans = N*M - (2*M + 2*N - 4);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
int mul[214514];
int divi[214514];
#define inf 1000000007
int bit[114514],n;
struct edge{int u,v,cost;};
edge es[214514];
int zero=0;
string alph("abcdefghijklmnopqrstuvwxyz");
int fi[2005][2005]={};
signed main(){
    int x,a,b;cin>>x>>a>>b;
    int c=x-a;
    cout<<c%b<<endl;
    return 0;
}


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

const int _ = 2e5 + 7 , MOD = 1e9 + 7;
int dp[_] , sum[_] , arr[_] , pos , N;

int main(){
	scanf("%d" , &N); int pre = 0;
	for(int i = 1 , x ; i <= N ; ++i){
		scanf("%d" , &x);
		if(pre != x) arr[++pos] = pre = x;
	}
	dp[1] = sum[arr[1]] = 1;
	for(int i = 2 ; i <= pos ; ++i) sum[arr[i]] = (sum[arr[i]] + (dp[i] = sum[arr[i - 1]])) % MOD;
	cout << sum[arr[pos]]; return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pie 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
#define pl pair<ll,ll>
#define pi pair<int,int>
#define pll pair< ll, pair<ll,ll> > 
#define pii pair< int, pair<int,int> >
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,n,m,x,b,y,q,z;
    cin>>n;
    ll x1 = INT_MAX;
    ll x2 = INT_MIN;
    ll y1 = INT_MAX;
    ll y2 = INT_MIN;
    while(n--){
    	cin>>x>>y;
    	x1 = min(x1,x+y);
    	x2 = max(x2,x+y);
    	y1 = min(y1,x-y);
    	y2 = max(y2,x-y);
	}
	cout<<max(x2-x1,y2-y1);
}

Measured memory_bytes: 3600
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

z = list(range(-2,105))
x,n = inpl()
a = inpl()
for i in a:
    if i in z:
        z.remove(i)
res = -1
sa = INF
for i in z:
    if abs(x-i) < sa:
        res = i
        sa = abs(x-i)
print(res)

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

int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, k; cin >> h >> w >> k;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    string S[h];
    for (int i = 0; i < h; i++) cin >> S[i];
    constexpr int inf = 1e9;
    vector<vector<int>> D(h, vector<int>(w, inf));
    D[x1][y1] = 0;
    queue<tuple<int, int>> Q; Q.emplace(x1, y1);
    auto in = [&](int x, int y) {
        return 0 <= x && x < h && 0 <= y && y < w && S[x][y] != '@';
    };
    while (!Q.empty()) {
        auto [x, y] = Q.front(); Q.pop();
        int d = D[x][y] + 1;
        for (int i = 0; i < 4; i++) {
            int s = x, t = y;
            for (int j = 0; j < k; j++) {
                s += dx[i], t += dy[i];
                if (!in(s, t)) break;
                if (D[s][t] < d) break;
                if (D[s][t] > d) {
                    D[s][t] = d;
                    Q.emplace(s, t);
                }
            }
        }
    }
    if (D[x2][y2] == inf) D[x2][y2] = -1;
    cout << D[x2][y2] << "\n";
    return 0;
}

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

int main() {
    bool ans = false;
    vector<int> bingo(9);
    map<int, bool> tf;
    for (int i = 0; i < 9; i++) {
        cin >> bingo.at(i);
        tf[i] = false;
    }
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 9; j++) {
            if (a.at(i) == bingo.at(j)) {
                tf[j] = true;
            }
        }
    }
    if (tf[0] && tf[4] && tf[8]) ans = true;
    else if (tf[2] && tf[4] && tf[6]) ans = true;
    for (int i = 0; i < 3; i++) {
        if (tf[0 + i] && tf[3 + i] && tf[6 + i]) ans = true;
        if (tf[i * 3] && tf[i * 3 + 1] && tf[i * 3 + 2]) ans = true;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){
    while(1){
        string cards;
        cin >> cards;
        if (cards == "-") break;
        int times;
        cin >> times;
        for(int i=0; i < times; i++){
            int shuffle;
            cin >> shuffle;
            string former, latter;
            former = cards.substr(0, shuffle);
            latter = cards.substr(shuffle);
            cards = latter + former;
        }
        cout << cards << endl;
    }
    return 0;
}


Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = Integer.parseInt(scanner.next());
        int S = Integer.parseInt(scanner.next());
        scanner.close();

        int ans = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    ans++;
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
using System;
using System.Linq;

namespace _1608
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Array.Sort(x);
                int a = 1000000;
                for (int i = 1; i < n; i++)
                {
                    if (a > x[i] - x[i - 1])
                    {
                        a = x[i] - x[i - 1];
                    }
                }
                Console.WriteLine(a);
            }
        }
    }
}

Measured memory_bytes: 9980
#include <stdio.h>

int n;

/*
\sum_{i<j} di dj = ((sum_i di)^2 - \sum_i di^2) / 2
*/

int main(){
  int i, r;
  char c;
  scanf("%d\n",&n);
  c = -1;
  r = 0;
  for(i = 0; i < n; i++){
    char cc;
    scanf("%c",&cc);
    if(cc != c){
      c = cc;
      r++;
    }
  }
  printf("%d\n", r);

  return 0;
}


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

using namespace std;
long long mod = 1000000007;
int main()

{
    int n,k;
    cin>>n>>k;
    vector<long long> a(n+1);
    vector<vector<long long>> dp(n+1, vector<long long> (k+1,0));
    vector<long long> pre(k+1, 0);
    
    for(int i=1; i<=n ;i++)
        cin>>a[i];

    dp[0][0]=1;

    for(int i=1; i<=n; i++)
    {
        pre.clear();
        pre[0] = dp[i-1][0];
        for(int j = 1; j<=k; j++)
             pre[j] = (pre[j-1] + dp[i-1][j])%mod;

        for(int j=0; j<=a[i]; j++)
           dp[i][j] = pre[j];

       for(int j = a[i]+1; j<=k; j++)
          dp[i][j] = (pre[j] - pre[j-a[i]-1] + mod)%mod;

    }

    cout<<dp[n][k];
    return 0;
}


Measured memory_bytes: 80256
using System;

namespace B___One_Clue
{
    class Program
    {
        static void Main(string[] args)
        {
            var kx = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var result = new int[2 * kx[0] - 1];
            for (int i = 0; i < 2 * kx[0] - 1; i++) result[i] = kx[1] - kx[0] + 1 + i;
            Console.WriteLine(string.Join(" ", result));
        }
    }
}


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

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

    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    // 後ろから[now - 1], [now]を比較
    // …前からやると、[3, 2]のとき3を下げたら3以前の数列に影響する場合がある
    // 後ろからやるとどんどんくだっていけばいいのでOK
    for(int i = n - 1; i >= 1; i--){
        if(A[i - 1] <= A[i]) continue;
        A[i - 1]--;
    }

    for(int i = 0; i < n - 1; i++){
        if(A[i] > A[i + 1]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1024
s = input()
k = int(input())

_all = []

for i in range(1, min(k+1, len(s)+1)):
	for j in range(len(s)-i+1):
		sub = s[j:j+i]
		if sub not in _all:
			_all.append(sub)

print(sorted(_all)[k-1])

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

const ll INF = pow(10, 9) + 7;

int main() {
  string s;
  cin >> s;
  if(s=="Sunny") cout << "Cloudy" << endl;
  if(s=="Cloudy") cout << "Rainy" << endl;
  if(s=="Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		if((N % 500) <= A) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int main() {
  int N,M;
  string S;
  cin>>N>>M>>S;
  vector<int> r;
  int now=N;
  while(now>0){
    int dice=M;
    if(now<dice) {
      r.push_back(now);
      break;
    }
    while(S[now-dice]!='0'&&now-dice>=0){
      dice--;
      if(dice<=0){
        cout<<-1<<endl;
        return 0;
      }
    }
    r.push_back(dice);
    now -=dice;

  }

for(int i=r.size()-1;i>=0;i--){
  if(i!=0)cout<<r[i]<<" ";
  else cout<<r[i];
}
cout<<endl;
}


Measured memory_bytes: 1144
#include<stdio.h>

int main(void){
  int i , j;
  int H , W;

  /* true でもできるんじゃないの？ */
  
  while(1){
    scanf("%d %d",&H,&W);

    if(H == 0 && W == 0){
      break;
    }
  
    for(i = 0; i < H;i++){
      
      for(j = 0; j < W; j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2052
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[,]A = new int[N,N];
		for(var i=0;i<N;i++){
			for(var j=i+1;j<N;j++){
				long c = 1;
				for(var k=0;k<40;k++){
					long a = i/c%2;
					long b = j/c%2;
					if(a+b==1){
						A[i,j] = k+1;
						break;
					}
					c *= 2;
				}
			}
		}
		for(var i=0;i<N-1;i++){
			Console.Write(A[i,i+1]);
			for(var j=i+2;j<N;j++){
				Console.Write(" "+A[i,j]);
			}
			Console.WriteLine();
		}
	}
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool flag=false;
  for(int i=1;i<=b;++i){
    if((i*a)%b==c){
      flag=true;
      break;
    }
  }

  if(flag) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main (void){
    char s[101] = {"\0"};
    scanf("%s",s);
    for(int i = 0; i < 100; i++){
        if(s[i] == 'C' || s[i] == 'F'){
            continue;
        } else {
            for(int j = i; j < 100; j++){
                if(s[j] == 'C' || s[j] == 'F'){
                    i = j - 1;
                    break;
                }
                s[j] = '\0';
            }
        }
    }
    for(int i = 0; i < 101; i++){
        if(s[i] == 'C'){
            for(int j = i+1; j < 101; j++){
                if(s[j] == 'F'){
                    printf("Yes\n");
                    return 0;
                }
            }
        }
    }
    printf("No\n");
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<int, int> > towns(n);
    vector<int> v;
    for(int i = 0; i < n; i++){
        int x,y;
        cin >> x >> y;
        towns[i] = make_pair(x,y);
        v.push_back(i);
    }

    double sum = 0;
    int count = 0;
    do{
        count++;
        for(int i = 0; i < n-1; i++){
            int dx = towns[v[i]].first - towns[v[i+1]].first;
            int dy = towns[v[i]].second - towns[v[i+1]].second;
            sum += pow(dx*dx + dy*dy, 0.5);
        } 
    }while(next_permutation(v.begin(), v.end()));

    cout << setprecision(10) << sum / count << endl;
}

Measured memory_bytes: 256
import sys
def calc(x, y, xp, yp):
    a = [(y[i] - y[i -1]) * (xp - x[i]) - (x[i] - x[i - 1]) * (yp - y[i]) for i in range(3)]
    print("YES" if (a[0] > 0 and a[1] > 0 and a[2] > 0) or (a[0] < 0 and a[1] < 0 and a[2] < 0) else "NO")
for s in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, s.split())
    x = [x1, x2, x3]
    y = [y1, y2, y3]
    calc(x, y, xp, yp)


Measured memory_bytes: 5588
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
AC
*/

ll n,a[200010],dp[200010],ans=0;
map<ll,ll> m;

int main(void){
	dp[0]=0;
	m[0]++;
	cin>>n;
	reg(i,1,n){
		cin>>a[i];
		dp[i]=dp[i-1]+a[i];
		m[dp[i]]++;
	}
	reg(i,0,n){
		ans+=m[dp[i]]*(m[dp[i]]-1)/2;
		m[dp[i]]=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;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()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    cout << ceil(double(n)/2)<< endl;
    return 0;

}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  long long Q,H,S,D;

  cin>>Q>>H>>S>>D;

  double N;

  cin>>N;

  long long ans=0;

  long long cnt2=min(min(min(Q*8,H*4),S*2),D);

  long long cnt1=min(min(Q*4,H*2),S);

  long long cnt5=min(Q*2,H);

  long long cnt25=Q;
  
  int i=4;

  while(1){

    if(N==0){
      break;
    }

    if(i==4){
      if(N>=2){
	ans+=int(N/2)*cnt2;
	N-=(int(N/2)*2);
	
      }else{
	i-=1;
      }
    }
    else if(i==3){
      
      if(N>=1){
	
	ans+=int(N/1)*cnt1;
	N-=(int(N/1)*1);
	
      }else{
	i-=1;
      }
      
    }else if(i==2){
      
      if(N>=0.5){
	ans+=int(N/0.5)*cnt5;
	N-=(int(N/0.5)*0.5);

	
      }else{
	i-=1;
      }
    }else if(i==1){

      if(N>=0.25){
	ans+=int(N/0.25)*cnt25;
	N-=(int(N/0.25)*0.25);
      }else{
	i-=1;
      }
    }
  
  }
  cout<<ans<<endl;
  
  

  return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define x first
#define y second

int main(){
    int n,K; cin >> n >> K;
    vector<pair<long long,long long> > v(n);
    rep(i,n) cin >> v[i].x >> v[i].y; 
    long long ans = LLONG_MAX;
    rep(i,n) rep(j,n) rep(k,n) rep(l,n){
        long long int upper = v[i].y, lower = v[j].y;
        long long int left = v[k].x, right = v[l].x;
        if(upper < lower || left > right) continue;
        int c = 0;
        rep(m,n){
            if(upper >= v[m].y && lower <= v[m].y && left <= v[m].x && right >= v[m].x) c++;
        }
        if(c >= K){
            ans = min(ans, (upper - lower) * (right - left));
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    set<int> A;
    rep(i, 3) {
        int a;
        cin >> a;
        A.insert(a);
    }
    if (A.size() == 2) {
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }


}

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


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

#pragma optimize(2)

#define Reg register

using namespace std;

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

int n,k,h[MAXN],f[MAXN]={0};

inline int qr() {
	Reg char c=getchar();
	for(; !isdigit(c); c=getchar());
	Reg int num=c-48;
	for(c=getchar(); isdigit(c); num=(num<<1)+(num<<3)+c-48,c=getchar());
	return num;
}

inline void qw(const int &x) {
	if(x>9) qw(x/10);
	putchar(x%10+48);
	return ;
}

int main() {
	n=qr(),k=qr(),h[1]=qr();
	for(Reg int i=2,j,lim; i<=n; ++i) {
		scanf("%d",&h[i]);
		for(j=i-1,f[i]=INF,lim=max(1,i-k); j>=lim; --j) f[i]=min(abs(h[i]-h[j])+f[j],f[i]);
	}
	qw(f[n]),putchar('\n');
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int r,c,i,l,j,x[100][100],y[100];
    scanf("%d%d",&r,&c);
   for(i=0;i<r;i++){
        for(j=0;j<c;j++){
        scanf("%d",&x[i][j]);
        }
    }
    for(i=0;i<c;i++){

        scanf("%d",&y[i]);

    }
    int z[r],k=0;
    for(i=0;i<r;i++){
        int sum=0;
        for(j=0;j<c;j++){
          sum=sum+x[i][j]*y[j];
        }
         z[k]=sum;
        k++;
    }
    for(i=0;i<r;i++)
    printf("%d\n",z[i]);

    return 0;
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
long long int b[1000][3];
long long int d[109][1000000];
long long int dp(int x,long long int w){
    if(d[x][w] != -1){
        return d[x][w];
    }
    else if(w < b[x][1]){
        if( x == 1 ){
            d[x][w] = 0;
            return 0;
        }
        else {
            d[x][w] = dp(x-1,w);
            return d[x][w];
        }
    }
    else if( x == 1){
        return b[x][2];
    }
    else {
        d[x][w] = max(dp(x-1,w-b[x][1])+b[x][2],dp(x-1,w));
        return d[x][w];
    }
}
int main(){
    int x;
    long long int w;
    cin >> x >> w;
    for(int i=0; i <109;i++){
        for(int j=0; j<1000000;j++){
            d[i][j]=-1;
        }
    }
    for(int i=1;i<x+1;i++){
        cin >> b[i][1];
        cin >> b[i][2]; 
    }
    cout << dp(x,w);
}
 

Measured memory_bytes: 851840
import Data.List

solve :: [Int] -> Int -> Int -> Int
solve [] a h = (h+a-1) `div` a
solve (b:bs) a h = if max a b >= h
                      then 1
                      else if a >= b
                          then (h+a-1) `div` a
                          else 1 + (solve bs a (h-b)) 

main = do
    [n,h] <- map read . words <$> getLine :: IO[Int]
    co <- getContents
    let ab = map (map read) $ map words $ lines co :: [[Int]]
    let (as,bs) = foldl (\ (as,bs) [a,b] -> (a:as, b:bs)) ([],[]) ab
    print $ solve (sortBy (flip compare) bs) (maximum as) h



Measured memory_bytes: 125180
#include <bits/stdc++.h>
int G[500][500];
using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>G[i][j];
    }
  }
  stringstream s;
  int ans=0;
  for(int j=0;j<W;j++){
    for(int i=0;i<H-1;i++){
      if(G[i][j]%2){
        G[i][j]--;
        G[i+1][j]++;
        s<<i+1<<" "<<j+1<<" "<<i+2<<" "<<j+1<<endl;
        ans++;
      }
    }
  }
  for(int j=0;j<W-1;j++){
    if(G[H-1][j]%2){
      G[H-1][j]--;
      G[H-1][j+1]++;
      s<<H<<" "<<j+1<<" "<<H<<" "<<j+2<<endl;
      ans++;
    }
  }
  cout<<ans<<endl<<s.str();
}


Measured memory_bytes: 6916
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n, max=0, ans=1;
	cin >> n;
	for(int i=1; i<=n; i++){
		int num=i, count=0;
		while(!(num%2)){
			count++;
			num/=2;
		}
		if(count > max){
			max = count;
			ans = i;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl;
	return 0;
}


Measured memory_bytes: 256
use std::collections::*;

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    let a = if a < 2 { 0 } else { (a * (a - 1)) / 2 };
    let b = if b < 2 { 0 } else { (b * (b - 1)) / 2 };

    println!("{}", a + b);
}

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

a = int(input())
print(a**3 + a**2 + a)

Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int x[4] = { 1,0,-1,0 };
int y[4] = { 0,1,0,-1 };

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>>mp(H, vector<int>(W, -1));
	rep(i, H) {
		rep(j, W) {
			char a; cin >> a;
			if (a == '#')mp[i][j] = 0;
		}
	}
	rep(i, H) {
		rep(j, W) {
			if (mp[i][j] == 0) {
				rep(k, 4) {
					int ny = i + y[k], nx = j + x[k];
					if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
					if (mp[ny][nx] == 0 || mp[ny][nx] == INF) {
						mp[ny][nx] = INF;
						mp[i][j] = INF;
					}
				}
			}
		}
	}
	rep(i, H) {
		rep(j, W) {
			if (mp[i][j] == 0) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");

	return 0;
}

Measured memory_bytes: 256
n = int(input())
if n >= 400 and n <= 599:
	print('8')
elif n >= 600 and n <= 799:
	print('7')
elif n >= 800 and n <= 999:
	print('6')
elif n >= 1000 and n <= 1199:
	print('5')
elif n >= 1200 and n <= 1399:
	print('4')
elif n >= 1400 and n <= 1599:
	print('3')
elif n >= 1600 and n <= 1799:
	print('2')
else:
	print('1')

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

a = sorted(a)

mins = 0
for i in range(1, len(a)):
    if a[i] -  a[i-1] > mins:
        mins = a[i] - a[i-1]
if k - a[n-1] + a[0] > mins:
    mins = k - a[n-1] + a[0] 

print(k-mins)



Measured memory_bytes: 78540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  rep(i,n) cin>>h[i];
  int ans=0;
  int mx=0;
  int cnt=0;
  while(true){
    if(cnt==n){
      break;
    }
    cnt=0;
    rep(j,n){
      if(h[j]==0){
        cnt++;
        continue;
      }
      ans++;
      if(h[j]!=0){
        while(h[j]!=0){
          h[j]--;
          j++;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.contest190629
{
    class ProblemB
    {
        static int num = 0;
        static List<long> values = new List<long>();
        static int answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            num = int.Parse(Console.ReadLine());
            values = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            int tmp = 0;
            for (int i = 0; i < num-1; i++)
            {
                if (IsSecondalySmallest(i))
                {
                    tmp++;
                }
            }
            answer = tmp;
        }


        static bool IsSecondalySmallest(int index)
        {
            if (index < 1 || index > num - 1)
            {
                return false;
            }
            if (values[index-1] < values[index] && values[index] <= values[index+1])
            {
                return true;
            }
            if (values[index - 1] >= values[index] && values[index] > values[index + 1])
            {
                return true;
            }
            return false;
        }

        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 13268
def square(n, height):
    if n == 0:
        yield ()
    else:
        for i in range(min(n, height),0, -1):
            for x in square(n-i, i):
                yield ('%d'%(i,),) + x 

def chunker(f):
    while True:
        line = f.readline()
        line = line.strip()
        n = int(line)
        if n == 0:
            raise StopIteration
        for s in square(n, n):
            yield s

import sys
for s in chunker(sys.stdin):
    print ' '.join(s)

Measured memory_bytes: 4244
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long int

int main(void)
{

    ll a, b, n;
    ll max = 0;
    ll ans, i, ch;
    scanf("%lld %lld %lld", &a, &b, &n);
    if (b <= n)
    {
        max = (a * (b - 1)) / b;
    }
    else
    {
        max = (a * n) / b;
    }
    printf("%lld\n", max);

    return 0;
}

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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            var list = new List<int> { a + b, a - b, a * b };

            Console.WriteLine(list.Max());
        }
    }
}

Measured memory_bytes: 13268
N, K = map(int,input().split())
V = list(map(int,input().split()))
ans = 0
for L in range(N+1):
    for R in range(N+1):
        if L+R <= min(N,K):
            S = max(0,K-(L+R))
#            print(S,V[:L],V[N-R:])
            A = sorted(V[:L]+V[N-R:])
            for k in range(len(A)):
                if A[k] < 0 and S > 0:
                    A[k] = 0
                    S -= 1
            ans = max(ans,sum(A))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

int main(void){
  int A,B,C;cin >> A >> B >> C;
  int ans = min(abs(A-C),abs(A-B))+abs(B-C);
  ans = min(ans,min(abs(B-C),abs(B-A))+abs(C-A));
  ans = min(ans,min(abs(C-A),abs(C-B))+abs(B-A));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = map(int, input().split())
temp = sorted(zip(x, range(n)))
ans = [None] * n
for i in range(n):
    idx = n//2
    if i >= idx:
        idx -= 1
    ans[temp[i][1]] = temp[idx][0]
for item in ans:
    print(item)

Measured memory_bytes: 105816
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

#define MAX 55

int H,W,D,N,r[10],X,Y;
char field[MAX][MAX];
bool visited[MAX][MAX];
bool treasure[MAX][MAX];
bool possible[MAX][MAX];
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};
typedef pair<int,int> P;

bool inField(int y,int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

bool check(int y,int x,int r){
  int x1 = x - r, x2 = x + r;
  int y1 = y - r, y2 = y + r;
  return x1 <= X && X <= x2 && y1 <= Y && Y <= y2;
}

void search(int y,int x,int s){
  if(visited[y][x]) return;
  visited[y][x] = true;

  if(s == 0){
    if(check(y,x,r[0]) && field[y][x] != '#'){
      treasure[y][x] &= true;
    }else{
      treasure[y][x] &= false;
    }
  }else if(s == D){
    if(!check(y,x,r[D-1]) && field[y][x] != '#'){
      treasure[y][x] &= true;
    }else{
      treasure[y][x] &= false;
    }
  }else{
    if(!check(y,x,r[s-1]) && check(y,x,r[s]) && field[y][x] != '#'){
      treasure[y][x] &= true;
    }else{
      treasure[y][x] &= false;
    }
  }

  for(int i = 0 ; i < 4 ; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(!inField(ny,nx)) continue;    
    search(ny,nx,s);
  }
}

void bfs(int y,int x){
  memset(possible,false,sizeof(possible));
  queue<P> Q; Q.push(P(y,x));
  while(!Q.empty()){
    P now = Q.front(); Q.pop();
    x = now.second; y = now.first;
    if(possible[y][x]) continue;
    possible[y][x] = true;
    for(int i = 0 ; i < 4 ; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(!inField(ny,nx) || field[ny][nx] == '#') continue;
      Q.push(P(ny,nx));
    }
  }
}

int main(){
  int sx,sy;
  cin >> H >> W >> D >> N;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> field[i][j];
      if(field[i][j] == 'D'){
        sx = j; sy = i;
      }
      treasure[i][j] = true;
    }
  }
  bfs(sy,sx);
  for(int i = 0 ; i < D ; i++){
    cin >> r[i];
  }
  for(int i = 0 ; i < N ; i++){
    int x,y,s;
    cin >> x >> y >> s; 
    memset(visited,false,sizeof(visited));
    X = x, Y = y; 
    search(y,x,s);
  }
  int cnt = 0;
  bool broken = true, c1 = false, c2 = false;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      if(treasure[i][j]) broken = false;
      if(possible[i][j] && treasure[i][j]) c1 = true;
      if(!possible[i][j] && treasure[i][j]) c2 = true;
    }
  }

  if(broken){
    cout << "Broken" << endl;
  }else if(c1 && c2){
    cout << "Unknown" << endl;
  }else{
    cout << (c1 ? "Yes" : "No") << endl;
  }

  return 0;
}

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

typedef vector<lli> vi;

lli mincost(int* h,lli* cost, lli n)
{
    if(n<=1 || cost[n]!=INT_MAX)
    {
        return cost[n];
    }
    
    lli a=mincost(h,cost,n-1);
    lli b=mincost(h,cost,n-2);
    cost[n]=min(cost[n],min(a+(abs(h[n]-h[n-1])) , b+(abs(h[n]-h[n-2]))));
    
    return cost[n];
    
  
}



int main() {
	lli n;
	cin>>n;
	//vi h(n+1,0);
	int* h=new int[n+1];
	
	for(lli i=1;i<=n;i++)
	{
	    cin>>h[i];
	}
	
	
	h[0]=INT_MAX;
	lli* cost=new lli[n+1];
	//memset(cost,-1,sizeof(cost));
	for(int i=0;i<=n;i++)
	{
	    cost[i]=INT_MAX;
	}
	
	cost[0] = cost[1] = 0;
	lli ans=mincost(h,cost,n);
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7680
import java.util.*;

public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[]args) {
	while(kbd.hasNext()){
	    int tl = kbd.nextInt();
	    int hl = kbd.nextInt();
	    if(tl!=0 && hl!=0){
		int[] t = new int[tl+1];
		int[] h = new int[hl+1];
		for(int i=1; i<t.length; i++){
		    t[i] = kbd.nextInt();
		    t[0] += t[i];
		}
		for(int i=1; i<h.length; i++) {
		    h[i] = kbd.nextInt();
		    h[0] += h[i];
		}
		solve(t, h);
	    }
	}
    }

    static void solve(int[]t, int[]h) {
	int a, b;
	int c=t[0], d=h[0];
	int x=100, y=100;
	for(a=1; a<t.length; a++){
	    for(b=1; b<h.length; b++){
		c = c-t[a]+h[b];
		d = d-h[b]+t[a];
		if(c==d && x+y>t[a]+h[b]){
		    x = t[a];
		    y = h[b];
		}
		c = t[0];
		d = h[0];
	    }
	}
	if(check(t, h, x, y)) System.out.println(x+" "+y);
	else System.out.println(-1);
    }

    static boolean check(int[] t, int[] h, int x, int y){
	boolean p = t[0]-x+y==h[0]-y+x;
	boolean q = false;
	for(int i=1; i<t.length; i++){
	    for(int j=1; j<h.length; j++){
		if(t[i]==x && h[j]==y) q = true;
	    }
	}
	return q;
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin >> n;
    //cout<<n<<endl;
    int dp[100010];
    rep(i,100010) dp[i]=inf;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        //cout<<"Yes"<<n<<endl;
        dp[i]=dp[i-1]+1;
        for(int j=6;j<=i;j*=6){
            if(i-j>=0){
                dp[i]=min(dp[i-j]+1,dp[i]);
            }
        }
        for(int j=9;j<=i;j*=9){
            if(i-j>=0){
                dp[i]=min(dp[i-j]+1,dp[i]);
            }
        }
    }
    //cout<<endl;
    //cout<<"dp end"<<n<<endl;
    //ep(i,n+1) cout<<dp[i]<<" ";
    //cout<<endl<<n<<endl;
    //cout<<endl;
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
from sys import stdin


def calc_cost(p, x):
    return (x - p)**2


def min_cost(n, data):
    cost = 1000000
    for p in range(1, 100 + 1):
        tmp_cost = sum([calc_cost(p, x) for x in data])
        if tmp_cost < cost:
            cost = tmp_cost
    return cost


def main():
    N = [int(x) for x in stdin.readline().rstrip()]
    CORP = [int(x) for x in stdin.readline().rstrip().split()]
    cost = min_cost(N, CORP)
    print(cost)


if __name__ == "__main__":
    main()


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

// ABC120A - Favorite Sound
// https://atcoder.jp/contests/abc120/tasks/abc120_a
void ABC120A() {
	int A, B, C;
	cin >> A >> B >> C;

	int tmp = B / A;
	if (tmp > C) {
		cout << C << endl;
	}
	else {
		cout << tmp << endl;
	}

}

int main() {
	ABC120A();

	return 0;
}

Measured memory_bytes: 256