akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var ab = CRL().ArrayInts();
        if (ab[0] <= 5)
        {
            CWL(0);
        }
        else if (ab[0] <= 12)
        {
            CWL(ab[1] / 2);
        }
        else
        {
            CWL(ab[1]);
        }
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = new[] {0, -1, 0, 1};
    public static readonly int[] Dy = new[] {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(0)=='S'){
    cout << "Cloudy" << endl;
  }else if(S.at(0)=='C'){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int days_sum[12];

int f(int l, int r, int L, int R){
	int res = 0;
	if(l > L){swap(L, l); swap(R, r);}
	return max(0, min(R - L, r - L));
}

int main(){
	int n;
	rep(i, 1, 12) days_sum[i] = days_sum[i - 1] + days[i - 1];
	while(cin >> n, n){
		int M[1010], D[1010], h[1010], m[1010], p[1010];
		char e[1010];
		vector<int> data[1010];
		rep(i, 0, n){
			scanf("%d/%d %d:%d %c %d", &M[i], &D[i], &h[i], &m[i], &e[i], &p[i]);
			M[i]--; D[i]--;
			int tmp = (days_sum[M[i]] + D[i]) * 3600 + h[i] * 60 + m[i];
			data[p[i]].push_back(tmp);
			//cout << p[i] << " " << tmp << endl;
			//cout << M[i] << " " << D[i] << " " << h[i] << " " << m[i] << " " << e[i] << " " << p[i] << endl;
		}
		int MAX = 0;
		rep(i, 1, 1000){
			if(data[i].size() == 0) continue;
			/*cout << i << endl;
			rep(j, 0, data[i].size()){
				cout << data[i][j] << " ";
			}
			cout << endl;	*/
			int tmp = 0;
			rep(j, 0, data[i].size() / 2){
				rep(k, 0, data[0].size() / 2){
					tmp += f(data[i][2 * j], data[i][j * 2 + 1], data[0][2 * k], data[0][2 * k + 1]);
				}
			}
			MAX = max(MAX, tmp);
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3252
#input
x1,y1,x2,y2 = map(int,input().split())
#solve
x4,y4 = x1-(y2-y1), y1+(x2-x1)
x3,y3 = x4+(x2-x1),y4+(y2-y1)
print("{} {} {} {}".format(x3,y3,x4,y4))

Measured memory_bytes: 2940
ticket = input()
a = [int(t) for t in ticket]
op = ["" for i in range(3)]
for i in range(8):
    ans = a[0]
    for j in range(3):
        if format(i, "03b")[j] == "1":
            op[j] = "+"
            ans = ans + a[j+1]
        else:
            op[j] = "-"
            ans = ans - a[j+1]
    if ans == 7:
        for k in range(3):
            print(str(a[k])+op[k], end="")
        print(str(a[3])+"=7")
        break

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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if N % 2 == 0:
        B = A[1::2]
        B.reverse()
        B += A[0::2]
    else:
        B = A[0::2]
        B.reverse()
        B += A[1::2]
    print(" ".join(map(str, B)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 117592
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5+10;
long long a[maxn];
long long sum[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> a[i];
		a[i] = a[i] - i - 1;
	}
	sort(a, a+n);
	for(int i=0;i<n;i++) {
		sum[i+1] = sum[i] + a[i];
	}
	long long res = 0;
	for(int i=1;i<n;i++) {
		res += a[i] - a[0];
	}
	for(int i=1;i<n;i++) {
		long long t = a[i] * i - (sum[i]);
		t += (sum[n] - sum[i+1]) - a[i] * (n-i-1);
		res = min(res, t);
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 5888
/*abc110a*/
import java.io.PrintWriter;
import java.util.*;

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

        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int[] arr = new int[3];
        arr[0] = scanner.nextInt();
        arr[1] = scanner.nextInt();
        arr[2] = scanner.nextInt();
        Arrays.sort(arr);

        int max = arr[2]*10+arr[1]+arr[0];

        out.println(max);
        out.flush();
    }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int D;
vector<int> c(26);
vector<vector<int>> s;

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

  cin >> D;

  rep(i, 26) { cin >> c[i]; }

  s.resize(D, vector<int>(26));
  rep(i, D) rep(j, 26) { cin >> s[i][j]; }

  const int width = 10;

  vector<vector<int16_t>> last;
  vector<int> parent;
  vector<char> kind;

  using P = pair<int64_t, int>;
  priority_queue<P, vector<P>, greater<P>> q;

  last.push_back(vector<int16_t>(26, -1));
  parent.push_back(-1);
  kind.push_back(-1);
  q.push(P(0, 0));

  mt19937 rng(111);
  uniform_int_distribution<int> dist(0, 500 - 1);

  rep(i, D) {
    priority_queue<P, vector<P>, greater<P>> nxt;
    queue<P> mutant;

    while (!q.empty()) {
      int64_t z;
      int idx;
      tie(z, idx) = q.top();
      q.pop();

      int64_t penalty = 0;
      rep(j, 26) { penalty += c[j] * (i - last[idx][j]); }

      rep(j, 26) {
        int nidx = last.size();
        int64_t w = z + s[i][j] - penalty + c[j] * (i - last[idx][j]);
        nxt.push(P(w, nidx));
        if (nxt.size() > width) {
          if (dist(rng) == 0) {
            mutant.push(nxt.top());
          }
          nxt.pop();
        }

        last.push_back(last[idx]);
        last[nidx][j] = i;
        parent.push_back(idx);
        kind.push_back(j);
      }
    }

    q = move(nxt);
    while (!mutant.empty()) {
      q.push(mutant.front());
      mutant.pop();
    }
  }

  while (q.size() > 1) {
    q.pop();
  }

  int64_t score;
  int idx;
  tie(score, idx) = q.top();
  vector<int> sln;
  while (idx != 0) {
    sln.push_back(kind[idx]);
    idx = parent[idx];
  }
  rrep(i, D) { cout << sln[i] + 1 << "\n"; }
  // cerr << score << "\n";

  return 0;
}

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

using ll = long long;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rrep(i,n) for(ll i = (n-1); i >= 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
ll mods = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    //print(fixed << setprecision(10));
    
    ll n,k,now=0;
    cin >> n >> k;
    vector<ll> a(n+1);
    rep(i,n) cin >> a[i+1];
    a[0]=1;

    unordered_set<ll> t;
    queue<ll> q;
    rep(i,k+1){
        if(t.count(a[now])){
            ll cnt=0;
            rep(j,(ll)t.size()){
                if(q.front()==a[now]) break;
                q.pop();
                cnt++;
            }
            rep(j,(ll)((k-cnt)%(t.size()-cnt))) q.pop();
            break;
        }
        t.insert(a[now]);
        q.push(a[now]);
        now = a[now];
        if(i==k){
            rep(j,k) q.pop();
            break;
        }
    }
    print(q.front());
    return 0;
}

Measured memory_bytes: 13128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int a,b,c,d;

int main() {
    ios::sync_with_stdio(false);
    cin>>a>>b>>c>>d;
    int res1=(a-1)/d+1;
    int res2=(c-1)/b+1;
    if(res1>=res2) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  vector<string> vec={"Sunny","Cloudy","Rainy","Sunny"};
  string s;
  cin>>s;
  for(ll i=0;i<4;i++) {
    if(s==vec[i]) {
cout<<vec[i+1]<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1050000000

const int maxn = 1e5 + 10;


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

	ll a, b;
	cin >> a >> b;

	int c[15];

	c[1] = c[3] = c[5] = c[7] = c[8] = c[10] = c[12] = 1;
	c[2] = 2;
	c[4] = c[6] = c[9] = c[11] = 3;

	if (c[a] == c[b])Yes;
	else No;

	return 0;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef vector<Int> vInt;
typedef pair<int,int> pint;
typedef pair<Int,Int> pInt;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef vector<pInt> vpInt;
typedef stringstream SS;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

vstring m;
vpint p[10];
vector<pair<int, pint> > a, b;

int main() {
	int x, y;
	IL {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		m.clear();
		rep (i, y) {
			string s;
			cin >> s;
			m.PB(s);
		}
		int sx, sy, gx, gy;
		rep (i, 10) p[i].clear();
		rep (i, y) rep (j, x) {
			if (m[i][j] == 'S') {
				sx = j;
				sy = i;
			}
			if (m[i][j] == 'G') {
				gx = j;
				gy = i;
			}
			if (isdigit(m[i][j])) {
				p[m[i][j] - '1'].PB(MP(i, j));
			}
		}
		int res = INF, type;
		rep (i, 5) {
			a.clear();
			a.PB(MP(0, MP(sy, sx)));
			repn (j, 1, 5) {
				b.clear();
				rep (l, sz(p[(i + j) % 5])) {
					int mn = INF;
					rep (k, sz(a)) {
						chmin(mn, a[k].first + abs(a[k].second.first - p[(i + j) % 5][l].first) + abs(a[k].second.second - p[(i + j) % 5][l].second));
					}
					b.PB(MP(mn, p[(i + j) % 5][l]));
//cout << i <<" " << j << " " << mn << " " << p[(i + j) % 5][l].first << " " << p[(i + j) % 5][l].second << endl;
				}
				a = b;
			}
			rep (j, sz(b)) {
				int dis = b[j].first + abs(b[j].second.first - gy) + abs(b[j].second.second - gx);
				if (dis < res) {
					res = dis;
					type = i;
//cout << i << " " << dis << endl;
				}
			}
		}
		if (res == INF) cout << "NA\n";
		else cout << type + 1 << " " << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1992
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;

typedef struct dice {
  int a[6];
  void change(char ch) {
    if(ch == 'E') {
      int temp = a[0];
      a[0] = a[3];
      a[3] = a[5];
      a[5] = a[2];
      a[2] = temp;
    }
    if(ch == 'N') {
      int temp = a[0];
      a[0] = a[1];
      a[1] = a[5];
      a[5] = a[4];
      a[4] = temp;
    }
    if(ch == 'S') {
      int temp = a[0];
      a[0] = a[4];
      a[4] = a[5];
      a[5] = a[1];
      a[1] = temp;
    }
    if(ch == 'W') {
      int temp = a[0];
      a[0] = a[2];
      a[2] = a[5];
      a[5] = a[3];
      a[3] = temp;
    }
  }
  int query(int x) { return a[x]; }
} dice;

bool check(int a[6], int b[6]) {
  dice x;
  for(int i = 0; i < 6; i++) {
    x.a[i] = a[i];
  }
  string d = "EEEENEEEENEEEENEEEEWSEEEENNEEEE";
  for(int i = 0; i < d.length(); i++) {
    x.change(d[i]);
    bool flag = true;
    if(x.query(0) != b[0])
      flag = false;
    if(x.query(1) != b[1])
      flag = false;
    if(x.query(2) != b[2])
      flag = false;
    if(x.query(3) != b[3])
      flag = false;
    if(x.query(4) != b[4])
      flag = false;
    if(x.query(5) != b[5])
      flag = false;
    if(flag)
      return true;
  }
  return false;
}

int main(void) {
  int a[6], b[6];
  for(int i = 0; i < 6; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < 6; i++) {
    cin >> b[i];
  }
  if(check(a, b))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3184
import java.util.Scanner;

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
      
        
        if (a < b&&a>=0 && b < c&&c<=100) {
            System.out.println("Yes");
        } else {
            System.out.println("No");

        }
    }
}

Measured memory_bytes: 26148
sx, sy, tx, ty = map(int,input().split())

width = tx - sx
height = ty - sy

ans_str = ''

ans_str += 'R' * width
ans_str += 'U' * height
ans_str += 'L' * width
ans_str += 'D' * height

ans_str += 'D'
ans_str += 'R' * (width+1)
ans_str += 'U' * (height+1)
ans_str += 'L'

ans_str += 'U'
ans_str += 'L' * (width+1)
ans_str += 'D' * (height+1)
ans_str += 'R'

print(ans_str)

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

int main(){
  int N, x, sum;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<a.size(); i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  x = 1;
  sum = 0;
  for (int i=0; i<a.size(); i++) {
    sum += a.at(i)*x;
    x *= -1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    isGood = False
    if S[0] == S[1]:
        if S[2] == S[3] and S[0] != S[2]:
            isGood = True
    elif S[0] == S[2]:
        if S[1] == S[3] and S[0] != S[1]:
            isGood = True
    elif S[0] == S[3] and S[0] != S[1]:
        if S[1] == S[2]:
            isGood = True
    else:
        isGood = False
    if isGood:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x)
#define debug(x)
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

vvint vv;
vint d;

void dfs(int x, int p, int c) {
    d[x] = c;
    for (int y: vv[x]) {
        if (y == p) {
            continue;
        }
        dfs(y, x, c+1);
    }
}

int dfs2(int x, int p, int limit) {
    int ret = d[x];
    for (int y: vv[x]) {
        if (y == p || d[y] < limit) {
            continue;
        }
        maxs(ret, dfs2(y, x, limit));
    }

    return ret;
}

void mainmain(){
    int N;
    cin >> N;
    int u, v;
    cin >> u >> v;
    u--, v--;
    vv = vvint(N);
    d = vint(N, -1);
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        vv[a].PB(b);
        vv[b].PB(a);
    }
    // 3 2
    // 4 3
    // 5 3
    dfs(v, -1, 0);
    int ans = dfs2(u, -1, d[u]/2+1) - 1;
    cout << ans << endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 500

long long dep[mx][mx];
long long n, c, a[mx], b[mx], pref[mx][mx], pang[mx][mx];

long long dp(int now, int sisa){
	if(now == n + 1 && sisa == 0)
		return 1;
	if(now == n + 1)
		return 0;
	long long &ret = dep[now][sisa];
	if(ret != -1)
		return ret;
	ret = 0;
	for(int i = 0; i <= sisa; i++){
		long long pre = pref[b[now]][i] - pref[a[now] - 1][i];
		pre %= MOD;
		if(pre < 0)
			pre += MOD;
		ret = (ret + dp(now + 1, sisa - i) * pre % MOD) % MOD;
		// if(now == 1 && sisa == c){
		// 	debug(i);
		// 	debug(pre);
		// 	debug(dp(now + 1, sisa - i));
		// }
	}
	return ret;
}

int main(){
	reset(dep, -1);
	cin >> n >> c;
	for(int i = 0; i < n; i++)
		cin >> a[i + 1];
	for(int i = 0; i < n; i++)
		cin >> b[i + 1];
	for(int i = 1; i <= 400; i++)
		pang[i][0] = 1;
	for(int i = 1; i <= c; i++){
		for(int x = 1; x <= 400; x++)
			pang[x][i] = pang[x][i - 1] * x % MOD;
	}
	for(int i = 0; i <= c; i++)
		for(int x = 1; x <= 400; x++)
			pref[x][i] = (pref[x - 1][i] + pang[x][i]) % MOD;
	cout << dp(1, c) << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	int t = 1;
	//cin >> t;
	while(t--){
		char n;
		cin >> n;
		if(n < 96)
			cout << 'A' << endl;
		else
			cout << 'a' << endl;
	}
	return 0;
}

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

using namespace std;

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

    int cnt[100010] = {0};
    for(int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);

        cnt[num]++;
    }
    
    int mx = cnt[0] + cnt[1] + cnt[2];
    int sum = mx;
    for(int i = 1; i < 100010 - 2; i++) {
        sum += cnt[i + 2];
        sum -= cnt[i - 1];

        mx = max(mx, sum);
    }
    printf("%d\n", mx);

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
using namespace std;

int main(){
  stack<string> s;
  string str;
  while(cin >> str){
    if(str == "+" || str == "-" || str == "*"){
      int b = stoi(s.top());
      s.pop();
      int a = stoi(s.top());
      s.pop();
      int res;
      if(str == "+") res = a + b;
      else if(str == "-") res = a - b;
      else if(str == "*") res = a * b;
      s.push(to_string(res));
    }
    else{
      s.push(str);
    }
    if(cin.get() == '\n') break;
  }
  int output = stoi(s.top());
  s.pop();
  cout << output << endl;
  return 0;
}

Measured memory_bytes: 3280
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << power(n, 3) << endl;
    return 0;
}

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0;i < 4;i++){
        if(s.at(i) == '+'){
            ans++;
        }
        else{
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b; cin >> a >> b;
  if (a > b) cout << a - 1 << endl;
  else cout << a << endl;
  return 0;
}

Measured memory_bytes: 3172
#include<stdio.h>
int main(void){
    int a,b,c,d,x;
    int e,f,g,h,y;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    scanf("%d %d %d %d",&e,&f,&g,&h);
    x=a+b+c+d;
    y=e+f+g+h;
    if(x<y){
        printf("%d\n",y);
    }
    else if(y<x){
        printf("%d\n",x);
    }
    else if(x==y){
        printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 1824
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, j, n, m = -1, k, ans;
int a[1000];
string s, t;
string store[50];

int gcd(int p, int q) {
    if (p % q == 0) return p;
    return gcd(q, p%q);
}

int main() {
    cin >> s;
    cin >> t;
    bool resortable = false;
    int sl = s.length();
    int tl = t.length();
    for (i=sl-1;i>=tl-1;i--) {
        bool fit = true;
        for (j=0;j<tl;j++) {
            if (t[j] != s[i-tl+1+j] && s[i-tl+1+j] != '?') fit = false;
        }
        if (fit)  {
            m++;
            store[m] = s;
            for (j=0;j<=i-tl;j++) if (store[m][j] == '?') store[m][j] = 'a';
            for (j=0;j<tl;j++) store[m][i-tl+1+j] = t[j];
            for (j=i+1;j<sl;j++) if (store[m][j] == '?') store[m][j] = 'a';
        }
    }
    if (m == -1) cout << "UNRESTORABLE" << endl;
    else {
        string stmp = store[0];
        for (i=0;i<=m;i++) {
            stmp = stmp < store[i] ? stmp : store[i];
        }
        cout << stmp << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int d[10][10];

int main() {
    int h, w;
    cin >> h >> w;
    REP(i,10) REP(j,10) cin >> d[i][j];
    REP(k,10) REP(i,10) REP(j,10) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    long ans = 0;
    REP(i,h) {
        REP(j,w) {
            int a;
            cin >> a;
            if (a != -1) ans += d[a][1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
sum = 0
for i in range(0,n):
    if v_list[i] - c_list[i] > 0:
        sum += v_list[i] - c_list[i]
print(sum)

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

k_bin = "{:040b}".format(k)
A_bin = list(map(lambda x: '{:040b}'.format(x), A))

X = ''
limited = 1
for i, col in enumerate(zip(*A_bin)):
    if k_bin[i] == '0' and limited:
        X += '0'
        continue

    zero_cnt = col.count('0')
    one_cnt = n-zero_cnt
    if one_cnt < zero_cnt:
        X += '1'
    else:
        X += '0'
        limited = 0

X = int(X, 2)
print(sum(X ^ a for a in A))

Measured memory_bytes: 26508
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int N;
int main(){
	cin>>N;
	vector<pair<ll,int> > A;
	vector<ll> B(N);
	ll a;
	for(int i=0;i<N;i++){
		cin>>a;
		A.pb(mp(a,i));
	}
	sort(A.begin(),A.end());
	for(int i=0;i<N;i++){
		int x=A[i].second;
		if(i<=(N-1)/2)B[x]=A[(N+1)/2].first;
		else B[x]=A[(N-1)/2].first;
	}
	for(int i=0;i<N;i++){
		cout<<B[i]<<endl;
	}
}

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

#define TEN 10
int main(){
  int n;
  cin >> n;
  if(n%TEN == 3){
    cout << "bon";
  }
  else if(n%TEN == 0 || n%TEN == 1 || n%TEN == 6 || n%TEN == 8){
    cout << "pon";
  }
  else{
    cout << "hon";
  }
  return 0;
}

Measured memory_bytes: 3632
import Data.List
import Data.Ord

main = do 
    [n,m] <- map read . words <$> getLine :: IO [Int]
    xs <- sort . map read . words <$> getLine :: IO [Int]
    let xs' = sortBy (comparing Down) $ map abs $ zipWith (-) xs (tail xs)
    print $ sum xs' - (sum $ take (n-1) xs')

Measured memory_bytes: 33404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
using ll = long long;
int main(){
  int n,m;
  cin>>n>>m;
  if(n==m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() <= k) {
        cout << s << endl;
    } else {
        forn(k) {
            cout << s[i];
        }
        cout << "...\n";
    }
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

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

using bts = bitset<1<<20>;

bts dp[80][80];
int a[80][80];

int shift = 1<<19;

int main() {
  int n, m; cin >> n >> m;
	for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
    cin >> a[i][j];
	}
	for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
    int b; cin >> b;
    a[i][j] -= b;
    a[i][j] = abs(a[i][j]);
	}
  dp[0][0][shift + a[0][0]] = 1;
  dp[0][0][shift - a[0][0]] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (i) {
        dp[i][j] |= dp[i - 1][j] << a[i][j];
        dp[i][j] |= dp[i - 1][j] >> a[i][j];
      }
      if (j) {
        dp[i][j] |= dp[i][j - 1] >> a[i][j];
        dp[i][j] |= dp[i][j - 1] << a[i][j];
      }
    }
  }
  int ans = 1<<20;
  for (int i = 0; i < (1<<20); ++i) {
    if (dp[n - 1][m - 1][i]) {
      ans = min(ans, abs(i - shift));
    }
  }
  cout << ans << '\n';
}




Measured memory_bytes: 819584
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <numeric>

    using namespace std;
     
    int main() {
      int n,k;
      cin >> n >> k;
      
      vector<int> v(n);

      for (int i=0;i<n;i++){
        cin >> v[i];
      }
      
      std::sort(v.begin(),v.end());
      
      vector<int> vc(n-k+1);
      for(int i=0;i<n-k+1;i++){
        vc[i] = v[i+k-1] - v[i];
      }
      
      int min = *std::min_element(vc.begin(), vc.end());
      cout << min << endl;

      return 0;
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  ll a,b,c,d;
  cin >> a >> b >> c;
  string s="No";
  if(c-a-b<0) cout << s << endl;
  else {
    d=(c-a-b);
    if(4*a*b<d*d) s="Yes";
    cout << s << endl;
  }
}

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

int n;
int m[28];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n;
    rep(i, 26) m[i] = 100;
    rep(i, n) {
        string S; cin >> S;
        rep(j, 26) {
            int cnt = 0;
            rep(k, S.size()) if (S[k]-'a'==j) cnt++;
            m[j] = min(m[j], cnt);
        }
    }
    string ans;
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    rep(i, 26) rep(j, m[i]) ans += alpha[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
def aaa(n):
    ans = 0
    for i in range(1, int(n ** (1/2)) + 1):
        if n % i == 0:
            ans = [i, n // i]
    return ans
            
n = int(input())
a, b = aaa(n)
print((a - 1) + (b - 1))


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>

using namespace std;

// #define DEBUG 1
#define DFILE "t1.1"

typedef struct
{
  long long v;
  int k;
} TT;

void merge_data(TT a[], TT b[], int low, int mid, int high)
{
  int h, i, j, k;
  h = low;
  i = low;
  j = mid + 1;

  while ((h <= mid) && (j <= high)) {
    if (a[h].v <= a[j].v) {
      b[i] = a[h];
      h++;
    } else {
      b[i] = a[j];
      j++;
    }
    i++;
  }
  if (h > mid) {
    for (k = j; k <= high; k++) {
      b[i] = a[k];
      i++;
    }
  } else {
    for (k = h; k <= mid; k++) {
      b[i] = a[k];
      i++;
    }
  }
  for (k = low; k <= high; k++)
    a[k] = b[k];
}

void merge_sort(TT data[], TT temp[], int left, int right)
{
  if (left < right) {
    int mid = left + (right - left) / 2;
    merge_sort(data, temp, left, mid);
    merge_sort(data, temp, mid + 1, right);
    merge_data(data, temp, left, mid, right);
  }
}

void dbg(TT* a, int n, const string s)
{
  cout << s;
  for (int i = 0; i < n; i++) {
    cout << a[i].v;
    if (i < n - 1)
      cout << " ";
  }
  cout << endl;
}

int main()
{
#ifdef DEBUG
#define cin fin
  fstream fin(DFILE);
#endif
  int n, k;
  cin >> n >> k;
  TT* a;
  TT* b;
  TT* t;
  a = new TT[n];
  b = new TT[n];
  t = new TT[n];
  int i, j, h;
  for (i = 0; i < n; i++) {
    cin >> a[i].v;
    a[i].k = i;
  }
  long long val = 0;
  long long v = 0;
  int n_take, n_give;
  for (h = 0; h <= k; h++) {
    n_take = min(n, k - h);  // 取る数はk - hだけどn以上は取れない
    n_give = min(h, n_take); // 捨てる数はhだけど取った数以上は捨てられない
    // cout << "take:" << n_take << " give:" << n_give << endl;
    for (j = 0; j <= n_take; j++) {  // 枠を左にずらす数を決める
      for (i = 0; i < n_take; i++) { // 右に舐めるループ
        b[i] = a[(i - j + n) % n];
      }
      // dbg(b, n_take, "D1:");
      merge_sort(b, t, 0, n_take - 1);
      // dbg(b, n_take, "D2:");
      v = 0;
      for (i = 0; i < n_give; i++) {
        if (b[i].v < 0)
          b[i].v = 0;
      }
      // dbg(b, n_take, "D3:");
      for (i = 0; i < n_take; i++)
        v += b[i].v;
      // cout << "V:" << v << endl;
      val = max(val, v);
    }
  }
  cout << val << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    set<int> have;
    for(int i = 0; i<k;i++){

        int d;cin >> d;
        for(int i = 0;i<d;i++){
            int a; cin >> a;
            have.insert(a);
        }
    }
    cout << n - have.size() << endl;
}

Measured memory_bytes: 3664
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>=b)
	{
		while(a--!=0)
		{
			printf("%d",b);
		}
	}
	else 
	{
		while(b--!=0)
		{
			printf("%d",a);
		}
		
	}
	putchar('\n'); 
	return 0;
 } 

Measured memory_bytes: 128
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Stack<Integer> s = new Stack<Integer>(){};
        int L = sc.nextInt();
        for(int i = 1 ; i <= L ; i++){
            int c = sc.nextInt();
            if(c > 0){
                if(s.search(c) != -1){
                    System.out.println(i);
                    break;
                }
                else
                    s.push(c);
            }
            else{
                if(s.empty() || (-c != s.peek()) ){
                    System.out.println(i);
                    break;
                }
                else
                    s.pop();
            }
            if(i == L)
                System.out.println("OK");
        }
    }
}


Measured memory_bytes: 29940
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

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

	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8)
		cout << ":(\n";
	else
		cout << "Yay!\n";
}


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

int main() {
  double a;
  cin>>a;
  
  int x,y,z;
  
  x=a/100;
  
  y=(a-100*x)/10;
  
  z=a-100*x-10*y;
  
  cout<<x+y+z<<endl;
  
  
  
}


Measured memory_bytes: 3680
N, M = map(int, input().split())
ab = [[int(a) for a in input().split()] for _ in range(N)]
cd = [[int(a) for a in input().split()] for _ in range(M)]
for i in range(N):
    min_distance = float('inf')
    check_point = 0
    for j in range(M):
        manhattan_distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if min_distance > manhattan_distance:
            min_distance = manhattan_distance
            check_point = j+1
    print(check_point)


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int a,b,c,d,s,v;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	s=a*b;
	v=c*d;
	if(s>=v)
	printf("%d\n",s);
	else
	printf("%d\n",v);

	
	return 0;
}

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

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

    int l = 1000, r = 0, a;
    for(int i = 0; i < n; i++){
        cin >> a;
        l = min(l, a);
        r = max(r, a);
    }

    cout << r-l << endl;
    return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;
#define ALL(c) (c).begin(), (c).end()
#define REP(i,n) for(ll i=0; i < (n); ++i)
#define FOR(i,s,n) for(ll i=s; i < (n); ++i)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
int main(){
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cout << fixed << setprecision(8);
	ll n; cin >> n;
	ll x, y; cin >> x >> y;
	vl a(n), b(n), c(n), d(n);
	REP(i, n) cin >> a[i] >> b[i] >> c[i] >> d[i];

	vvvl dp(n+1, vvl(301, vl(1001, -1)));
	dp[0][x][y+350] = 0;
	REP(i, n) REP(j, 301) REP(k, 1001) if(dp[i][j][k]!=-1){
		if (j >= a[i])
			dp[i + 1][j - a[i]][k + b[i]] =
				max(dp[i + 1][j - a[i]][k + b[i]], dp[i][j][k]);
		if (k >= c[i])
			dp[i + 1][j][k - c[i]] =
				max(dp[i + 1][j][k - c[i]], dp[i][j][k] + d[i]);
		dp[i + 1][j][k] = max(dp[i][j][k], dp[i + 1][j][k]);
	}

	ll ma = 0;
	REP(i, 301) FOR(j, 350, 1001) ma = max(ma, dp[n][i][j]);
	
	cout << ma << endl;
}

Measured memory_bytes: 243700
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
//#define i_7 998244353
//#define i_5 i_7-2
ll i_7=(ll)(1E9+7);
ll i_5=i_7-2;
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////


ll p;
vector<ll>mul(vector<ll>&a, ll t){//(x+t)をかける
    ll as=a.size();
    vector<ll>res(as+1,0);
    rep(i,0,as-1){
        Add(res[i+1],a[i]);
        Add(res[i],a[i]*t);
    }
    return res;
}
vector<ll>rev(vector<ll>a,ll t){//(x+t)で割る
    ll as=a.size();
    vector<ll>res(as-1,0);
    for(ll i=as-1;i>=1;i--){
        res[i-1]=mod(a[i]);
        Add(a[i-1],-(res[i-1]*t));
    }
    return res;
}
ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll a){
    return po(a,p-2);
}
#define P 3005
ll a[P];
void calans1(){
    vector<ll>up[p];
    up[0].pb(1);
    rep(i,1,p-1){
        //vector<ll>re;re.pb(-i);re.pb(1);
        up[0]=mul(up[0],-i);
    }
    //for(auto x:up[0])cout<<x<<" ";cout<<endl;
    rep(i,1,p-1){
        up[i]=rev(up[i-1],-i);
        //vector<ll>re;re.pb(-(i-1));re.pb(1);
        up[i]=mul(up[i],-(i-1));
    }
    /*
    rep(i,0,p-1){
        cout<<i<<":";
        rep(j,0,p-1){
            cout<<up[i][j]<<" ";
        }cout<<endl;
    }*/
    
    ll dn[p];rep(i,0,p-1)dn[i]=1;
    rep(i,0,p-1){
        rep(j,0,p-1){
            if(i==j)continue;
            dn[i]=mod(dn[i]*(i-j));
        }
    }
    //rep(i,0,p-1)cout<<dn[i]<<" ";cout<<endl;
    
    rep(i,0,p-1)dn[i]=bunbo(dn[i]);
    
    vector<ll>ans(p,0);
    rep(k,0,p-1){
        if(a[k]==0)continue;
        rep(j,0,p-1){
            Add(ans[j],up[k][j]*dn[k]);
        }
    }
    rep(i,0,p-1)cout<<ans[i]<<" ";
}

int main(){fastio
    cin>>p;
    i_7=p;
    i_5=p-2;
    rep(i,0,p-1)cin>>a[i];
    calans1();
    return 0;
}


Measured memory_bytes: 70784