akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int INF = (1<<29);
int N, R, ans;
int r[9], d[201][201];
bool used[9];

void dfs(int cnt, int last, int dist){
    if(cnt == R){
        ans = min(ans, dist);
        return;
    }

    for(int i=1; i<=R; i++) if(!used[i]){
        used[i] = true;
        if(last == -1) dfs(cnt+1, i, 0);
        else dfs(cnt+1, i, dist+d[r[last]][r[i]]);
        used[i] = false;
    }
}

void floyd(){
    for(int k=1; k<=N; k++){
        for(int i=1; i<=N; i++){
            if(d[i][k] == INF) continue;

            for(int j=1; j<=N; j++){
                if(d[k][j] == INF) continue;

                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    int M; cin >> N >> M >> R;
    int a, b, c;
    for(int i=1; i<=R; i++) cin >> r[i];

    for(int i=1; i<=N; i++) for(int j=1; j<=N; j++) d[i][j] = ((i == j)? 0 : INF);
    for(int i=1; i<=M; i++){
        cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
    }
    floyd();

    ans = INF;
    dfs(0, -1, 0);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

struct BIT0{
    vector<int> data;
    BIT0(int n): data(n + 1){ }
    void add(int idx, int num){
        // idx = max(0, min((int)data.size() - 1, idx));
        idx++;
        for(; idx < (int)data.size(); idx += idx & -idx){
            data[idx] += num;
        }
    }
    int sum(int idx){
        // idx = max(0, min((int)data.size() - 1, idx));
        idx++;
        int ret = 0;
        for(; idx; idx -= idx & -idx){
            ret += data[idx];
        }
        return ret;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<int> as(n); cin >> as;
    auto as2 = as;
    sort(as2.begin(), as2.end());
    vector<int> as3(n);
    int in = 0, out = n;
    while(in + 1 < out){
        int piv = (in + out) / 2,
            num = as2[piv];
        for(int i = 0; i < n; i++){
            as3[i] = as[i] < num ? -1 : 1;
        }
        for(int i = 1; i < n; i++){
            as3[i] += as3[i - 1];
        }
        BIT0 bt(n * 2 + 1);
        ll acc = 0;
        bt.add(0 + n, 1);
        for(int i = 0; i < n; i++){
            acc += bt.sum(as3[i] + n);
            bt.add(as3[i] + n, 1);
        }
        printde(as3);
        printde(piv, acc, n * (n + 1) / 4);
        if(acc >= n * (n + 1) / 4){
            in = piv;
        }else{
            out = piv;
        }
    }
    cout << as2[in] << '\n';
}


Measured memory_bytes: 2188
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
elif k == 1 or k == 7:
    print(1)
else:
    t = 2
    ex = 77
    for i in range(10 ** 8):
        if ex % k == 0:
            break
        ex = (ex % k) * 10 + 7
        t += 1
    print(t)

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

// 素数
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

vector<int> a(100010);

int main(){
    for(int i=1;i<100010;i+=2){
        if(is_prime(i) && is_prime((i+1)/2)){
          a[i]=1;
        }
    }

    vector<ll> s(100010,0);
    rep(i,100010){
      s[i+1]=s[i]+a[i];
    }
    ll q;
    cin>>q;
    while(q--){
        ll l,r;
        cin>>l>>r;
        r++;
        cout<<s[r]-s[l]<<endl;
    }
    return 0;
}


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

int main(){
  int a,b,c,x,cnt=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x) cnt++;
      }
    }
  }
  cout<<cnt;
}


Measured memory_bytes: 256
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> cnt(5);
    rep(i,n){
        string s;cin >> s;
        if(s[0] == 'M')cnt[0]++;
        if(s[0] == 'A')cnt[1]++;
        if(s[0] == 'R')cnt[2]++;
        if(s[0] == 'C')cnt[3]++;
        if(s[0] == 'H')cnt[4]++;    
    }

    ll ans = 0;
    rep(i, (1LL << 5)){
        bitset<5> bs(i);
        if(bs.count() != 3)continue;
        ll temp = 1;
        rep(j,5){
            if(bs[j]){
                temp *= cnt[j];
            }
        }
        ans += temp;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if(r <= x && x <= W - r && r <= y && y <= H - r){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
return 0;
}


Measured memory_bytes: 2684
import Data.List
import Data.Bits
import Data.Bool
import Control.Monad

main = do
  [h,w] <- map read.words<$>getLine
  a <- map length.group.sort.concat<$>replicateM h getLine
  putStrLn $ bool "No" "Yes" $ solve h w a

solve h w a
  | even h && even w = x == 0 && y == 0
  | even h && odd w = x == 0 && y <= div h 2
  | odd h && even w = x == 0 && y <= div w 2
  | odd h && odd w = x == 1 && y <= div (h+w) 2 - 1
  where
    x = length $ filter (==1) m4
    y = length $ filter (==2) m4
    m4 = map (`mod` 4) a

Measured memory_bytes: 2428
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int h = scan.nextInt();

		int w = scan.nextInt();

		scan.nextLine();

		List<String> arr = new ArrayList<>();

		for (int i = 0 ; i < h; i++) {
			arr.add(scan.nextLine());
		}

		for (int i = 0; i < w + 2; i++) {
			System.out.print("#");
		}

		System.out.println();

		for (String aaa : arr) {
			System.out.println("#"+aaa+"#");
		}

		for (int i = 0; i < w + 2; i++) {
			System.out.print("#");
		}

	}

}


Measured memory_bytes: 22612
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);


void solve(){
  int n,k;  cin>>n>>k;
  int a[n]; f(i,0,n) cin>>a[i];
  vector<bool> dp(k+1);
    for(int stones=0;stones<=k;++stones)
      for(int i=0;i<n;++i)
      if(stones>=a[i] && !dp[stones-a[i]]) dp[stones]=1;
  dp[k] ? cout<<"First\n" : cout<<"Second\n";
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!


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

int main(){
  int H,W;

  while(1){
  cin >> H >> W;
  if(H==0&&W==0){break;} 

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if((i + j)%2==0){
        printf("#");
      }else{
        printf(".");
      }
    }
   printf("\n");
  }

   printf("\n");

  }

}

Measured memory_bytes: 3000
local a = {}
for i = 1, 9 do a[i] = io.read("*n") end
if(a[1] + a[5] == a[2] + a[4] and a[1] + a[8] == a[2] + a[7] and a[1] + a[6] == a[3] + a[4] and a[1] + a[9] == a[3] + a[7]) then
    print("Yes") else print("No")
end

Measured memory_bytes: 256
from sys import stdin

n,c,k = [int(x) for x in stdin.readline().rstrip().split()]
li = [int(stdin.readline().rstrip()) for _ in range(n)]
li.sort()
time = li[0]
people = 0
bus_num = 1

for i in li:
    people += 1
    if i-time > k or people > c:
        bus_num += 1
        time = i
        people = 1
print(bus_num)

Measured memory_bytes: 7488
/**
*    created: 04.05.2020 02:49:20
**/

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

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    ll x = 0;
    map<ll,int> m;
    rep(i,n){
        x += m[i-a[i]];
        m[i+a[i]]++;
    }

    cout << x << endl;
}

Measured memory_bytes: 27716
#include <stdio.h>
 
int main(){

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

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define jaxis 100001
LL weight[102];
LL value[102];
LL dp[101][jaxis];
LL n, weightlimit = 0;

LL cal(LL now, LL remaining)
{
    //cout << "NOW IS " << now << " and remaining is " << remaining << endl;
    if (now <1 || remaining <= 0)
    {
        return 0;
    }

    if (dp[now][remaining] == -1)
    {
        if (dp[now -1][remaining] == -1)
        {
            dp[now -1][remaining] = cal(now -1, remaining);
        }

        if (remaining - weight[now] >=0)
        {

            if (dp[now -1][remaining - weight[now]] == -1)
            {
                dp[now-1][remaining - weight[now]] = cal(now-1, remaining - weight[now]);
            }

            dp[now][remaining] = max(value[now] + dp[now -1][remaining - weight[now]], dp[now-1][remaining]);
        }
        else
        {
            dp[now][remaining]=dp[now-1][remaining];
        }
        
    }
    //cout << "dp[" << now << "][" << remaining << "] is " << dp[now][remaining] << endl;
    return dp[now][remaining];
}

int main()
{

    cin >> n >> weightlimit;

    LL i, j, k;
    for (i = 1; i <= n; i++)
    {
        cin >> weight[i] >> value[i];
    }

    //cout << "STUFF ENTERED" << endl;

    for (i = 1; i <= n; i++)
    {
        //cin>>weight[i]>>value[i];
        for (j = 1; j <= jaxis - 1; j++)
        {
            dp[i][j] = -1;
        }
    }

    //cout << "INITIALIZATION ENTERED" << endl;

    LL max = cal(n, weightlimit);

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 78336
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
static const int HMAX = 1401;
static const int WMAX = 1401;

int tiles[HMAX][WMAX] = {0};

void print_tiles(int h, int w) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << tiles[i][j] << " ";
    }
    cout << endl;
  }
}

// side-effects (to tiles)
int leargest_square(int height, int width, int ans_init) {
  int ans = ans_init;
  for (int i = 1; i < height; i++) {
    for (int j = 1; j < width; j++) {
      if (tiles[i][j] != 0) {
        tiles[i][j] =
            min({tiles[i - 1][j], tiles[i][j - 1], tiles[i - 1][j - 1]}) + 1;
        ans = max(ans, tiles[i][j]);
      }
    }
  }
  return ans * ans;
}

struct Rect {
  int height;
  int left;
};

// side-effects (to tiles)
int leargest_rectanble(int height, int width) {
  // mkae histgrams
  for (int i = 1; i < height; i++) {
    for (int j = 0; j < width; j++) {
      if (tiles[i][j] != 0) {
        tiles[i][j] = tiles[i - 1][j] + 1;
      }
    }
  }

  int maxsize = 0;
  stack<Rect> st;
  for (int i = 0; i < height; i++) {
    // calc the rectangle size of the i-th histgram
    tiles[i][width] = 0; // sentinel
    for (int j = 0; j < width + 1; j++) {
      auto rect = Rect{tiles[i][j], j};
      if (st.empty() || st.top().height < rect.height) {
        st.push(rect);
      } else if (st.top().height > rect.height) {
        Rect r;
        int left_store;
        while (!st.empty()) {
          r = st.top();
          if (r.height <= rect.height)
            break;
          int size = r.height * (rect.left - r.left);
          maxsize = max(size, maxsize);
          left_store = r.left;
          st.pop();
        }
        if (r.height < rect.height) {
          rect.left = left_store;
          st.push(rect);
        }
      }
    }
  }

  return maxsize;
}

#define BLOCK 1
int main() {
  int height, width;
  int ans_init = 0;
  cin >> height >> width;
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      int tmp;
      cin >> tmp;
      tiles[i][j] = tmp == BLOCK ? 0 : 1;
      ans_init = max(ans_init, tiles[i][j]);
    }
  }
  cout << leargest_rectanble(height, width) << endl;
}

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

string padding (string str);

int main () {

    int N, M;
    scanf("%d %d", &N, &M);

    vector<tuple<int, int, int>> PY;
    for (int i = 0; i < M; i++) {
        int p, y;
        scanf("%d %d", &p, &y);

        PY.emplace_back(p, y, i);
    }

    sort(PY.begin(), PY.end());

    vector<string> ID(M);
    int cnt = 1;

    ID[get<2>(PY[0])] = padding(to_string(get<0>(PY[0]))) + padding(to_string(cnt));

    for (int i = 1; i < M; i++) {
        if (get<0>(PY[i]) != get<0>(PY[i-1])) cnt = 1;
        else cnt++;

        ID[get<2>(PY[i])] = padding(to_string(get<0>(PY[i]))) + padding(to_string(cnt));
    }

    for (int i = 0; i < M; i++) {
        printf("%s\n", ID[i].c_str());
    }

    return 0;
}

string padding (string str) {

    int zeros = 6 - (int)str.size();

    for (int i = 0; i < zeros; i++) {
        str = "0" + str;
    }

    return str;
}

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

using namespace std;

class Solution {
public:
	void solve() {
		int x, y, a, b, c;
		cin >> x >> y >> a >> b >> c;
		vector<int> p(a, 0), q(b, 0), r(c, 0);
		for (int i = 0; i < a; i++) cin >> p[i];
		for (int i = 0; i < b; i++) cin >> q[i];
		for (int i = 0; i < c; i++) cin >> r[i];
		sort(p.begin(), p.end(), greater<typeof(*p.begin())>());
		sort(q.begin(), q.end(), greater<typeof(*q.begin())>());
		sort(r.begin(), r.end(), greater<typeof(*r.begin())>());
		long long ans = 0;
		for (int i = 0; i < x; i++) ans += p[i];
		for (int i = 0; i < y; i++) ans += q[i];
		x--, y--;
		for (int i = 0; i < c; i++) {
			if (((x == -1) || (p[x] > r[i])) && ((y == -1) || (q[y] > r[i]))) break;
			if (x == -1)
				ans += r[i] - q[y--];
			else if (y == -1)
				ans += r[i] - p[x--];
			else if (p[x] > q[y])
				ans += r[i] - q[y--];
			else
				ans += r[i] - p[x--];
		}
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1408
from collections import Counter
N=int(input())
A=Counter(map(int,input().split()))

if len(A)==1:
  if 0 in A:
    print("Yes")
  else:
    print("No")
elif len(A)==2:
  if A[0]==N/3:
    print("Yes")
  else:
    print("No")
elif len(A)==3:
  if list(A.values())==[N/3]*3 and list(A.keys())[0]^list(A.keys())[1]^list(A.keys())[2]==0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 15524
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

bool isP(ll x){
	for(ll i=2; i*i <= x; i++)
		if(x%i == 0)
			return false;
	return true;
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	for(ll i=6; i<=55555; i+=5){
		if(isP(i)){
			cout << i << " ";
			n--;
		}
		if(n == 0)
			break;
	}
	return 0;
}

Measured memory_bytes: 3596
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var N = Console.ReadLine().Split();
            var a = N[0];
            var b = N[1];
            Console.WriteLine(b + a);
        }



    }

    /// <summary>
    /// 入力受付
    /// </summary>
    static class Inputer
    {
        /// <summary>
        /// A B C の複数整数からなる1行を受け取る
        /// </summary>
        /// <returns></returns>
        public static int[] IntArray1Line()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }

        /// <summary>
        /// 整数N　のような１つの整数からなる入力を受け取る
        /// </summary>
        /// <returns></returns>
        public static int Int1Char()
        {
            return int.Parse(Console.ReadLine());
        }

        /// <summary>
        /// 大きい整数N　のような１つの整数からなる入力を受け取る
        /// </summary>
        /// <returns></returns>
        public static long Long1Char()
        {
            return long.Parse(Console.ReadLine());

        }

    }

    /// <summary>
    /// 順列を出すやつ
    /// </summary>
    /// <typeparam name="T"></typeparam>
    static class Permutation<T>
    {
        private static void Search(List<T[]> perms, Stack<T> stack, T[] a)
        {
            int N = a.Length;
            if (N == 0)
            {
                perms.Add(stack.Reverse().ToArray());
            }
            else
            {
                var b = new T[N - 1];
                Array.Copy(a, 1, b, 0, N - 1);
                for (int i = 0; i < a.Length; ++i)
                {
                    stack.Push(a[i]);
                    Search(perms, stack, b);
                    if (i < b.Length) { b[i] = a[i]; }
                    stack.Pop();
                }
            }
        }
        public static IEnumerable<T[]> All(IEnumerable<T> src)
        {
            var perms = new List<T[]>();
            Search(perms, new Stack<T>(), src.ToArray());
            return perms;
        }
    }
    
    /// <summary>
    /// 素因数分解
    /// </summary>
    static class PrimeFactors
    {
        public static IEnumerable<long> PrimeFactor(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) 
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }

    }

}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,k;
	cin>>n>>k;
	vi h(n);
	rep(i,n)cin>>h[i];

	sort(all(h));
	int ans=INF;
	rep(i,n-k+1){
		chmin(ans,h[k+i-1]-h[i]);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  double A, B, H, M, ans; cin >> A >> B >> H >> M;
  double pi = 3.14159265358979323846264338327950288;
  double lH = (H+M/60)/6 *pi, lM = M/30 *pi;
  double c = cos(lH - lM);
  
  ans = sqrt(A*A + B*B - 2*A*B*c);
  
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

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

using pii = pair<string, int>;

int N;

vector<pair<pii, int>> v;

signed main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		string s;
		int p;
		cin >> s >> p;
		v.push_back(make_pair(make_pair(s, -p), i+1));
	}

	sort(v.begin(), v.end());

	for (int i = 0; i < N; i++) {
		cout << v[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    adj_sum = [2 * a for a in A]
    water_sum = sum(A)

    sum_for_odd = 0
    for i in range(N):
        if i % 2 == 1:
            sum_for_odd += adj_sum[i]

    W = [0] * N
    W[0] = water_sum - sum_for_odd

    for i in range(1, N):
        W[i] = adj_sum[i-1] - W[i-1]

    print(' '.join(map(str, W)))

main()


Measured memory_bytes: 23108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int a;
  string s;
  cin >> a >> s;
  cout << ((a < 3200)? "red" : s) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;



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


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

vector<int> G[100100];
int path[100100];

bool seen[100100];

int cnt = 1;

void dfs(int node, int &finish){
    for(auto child: G[node]){
        if(!seen[child]){
            seen[child] = true;
            path[child] = node;
            finish = child;
            cnt++;
            dfs(child, finish);
            return;
        }
    }
}

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

    #ifdef magUNbos
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
    #endif // magUNbos

    int N, M;
    cin>>N>>M;
    for(int i = 0 ; i < M ; i++){
        int u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int start = 1, finish;
    seen[start] = true;
    dfs(start, finish);
    int newStart = start;
    dfs(start, newStart);
    vector<int> ans;
    stack<int> st;
    while(path[finish]){
        st.push(finish);
        finish = path[finish];
    }
    while(path[newStart]){
        ans.push_back(newStart);
        newStart = path[newStart];
    }
    ans.push_back(newStart);
    while(!st.empty()){
        ans.push_back(st.top());
        st.pop();
    }
    cout<<ans.size()<<endl;
    for(int x: ans){
        cout<<x<<" ";
    }
}



Measured memory_bytes: 7536
import sys
sys.setrecursionlimit(10000000)

N = None
As = None
used_plus = 0
used_minus = 0

def make_leaf():
    return [True, None, None, None]

def make_branch(left, right):
    return [False, None, left, right]

def count(nminus):
    global N, As
    res = 0
    for i in range(N):
        if i < nminus:
            res -= As[i]
        else:
            res += As[i]
    return res

def make_tree(a, b):
  if a + b == 1:
      if a == 1:
        return make_leaf()
      else:
          raise Exception("tukurenai")
  else:
      x = 1
      z = 1
      y = b - z
      w = a - x
      return make_branch(make_tree(x, y), make_tree(z, w))


def f(node, minus):
    global N, As, used_plus, used_minus
    [leaf, value, left, right] = node
    if leaf:
        if minus:
            node[1] = As[used_minus]
            used_minus += 1
        else:
            node[1] = As[N - 1 - used_plus]
            used_plus += 1
    else:
        f(left, minus)
        f(right, not minus)

def g(node):
    [leaf, value, left, right] = node
    if leaf:
        return value;
    else:
        x = g(left);
        y = g(right);
        print(str(x) + " " + str(y))
        return x - y

def show(nminus):
    node = make_tree(N - nminus, nminus)
    f(node, False)
    g(node)

def main():
    global N, As
    N = int(input())
    As = list(map(int,input().split()))
    As.sort()
    best = 0
    for i in range(N):
        if As[i] < 0: best = i
    m = -1
    argmax = 0
    for i in range(-1, 2):
        j = min(max(best + i, 1), N - 1)
        c = count(j)
        if c > m:
            m = c
            argmax = j
    print(m)
    show(argmax)

main()

Measured memory_bytes: 111924
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int mod = 1000000007;

bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a);//a進数におけるNの各桁の和、計算量はloga(N)
ll mpow(ll x, ll n);
ll inv_mod(ll a){return mpow(a,mod-2);}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

int main(){
    int A,B,C,D;
    int s;
    cin>>s;
    D=s%10;
    s/=10;
    C=s%10;
    s/=10;
    B=s%10;
    s/=10;
    A=s;
    if(A+B+C+D==7) cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
    else if(A-B+C+D==7) cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
    else if(A+B-C+D==7) cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
    else if(A+B+C-D==7) cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
    else if(A-B-C+D==7) cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
    else if(A-B+C-D==7) cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
    else if(A+B-C-D==7) cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
    else  cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
    return 0;
}

int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
/*
class Factorial{//階乗とその逆元を求めて計算に利用するクラス
private:
    vector<ll> fac;
public:
    
    Factorial(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};
*/

/*
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
*/

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  cout << fixed << setprecision(16) << endl;
  long double n, m, d;
  cin >> n >> m >> d;
  if(d==0){
    cout << (m - 1) / n << endl;
  }else{
    cout << (n - d) * 2 / n / n * (m - 1) << endl;
  }
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FOR(a,b,c) for(int a = (b); a <= (c); a++)
#define RFOR(a,b,c) for(int a = (b); a >= (c); a--)
#define all(x) (x).begin(), (x).end()
#define vi vector <int>
#define vvi vector <vi>
#define ll long long
#define vll vector <ll>
#define vvl vector <vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ep emplace
#define fs first
#define sd second
using namespace std;

int main() {
	FIO;
	string s; cin >> s;
	int a = 0, b = 0;
	for (auto i : s) {
		if (i == 'A') a++;
		else b++;
	}
	cout << ((a && b) ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>
#include<queue>
#include<bitset>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	auto A = a + b;
	auto B = c + d;

	if (A == B) {
		cout << "Balanced" << endl;
	}else if (A > B) {
		cout << "Left" << endl;
	}
	else if (A < B) {
		cout << "Right" << endl;
	}
}

Measured memory_bytes: 3596
cost=0
N = gets.to_i
A = gets.split.map &:to_i
min = A.min
sorted = Array.new(N, false)
sortedA = A.sort

A.each_with_index {|e, i|
    index = sortedA.index(e)
    next if sorted[i] or index == i
    sorted[i] = true
    sum = e
    cycleMin = e
    num = 1
    value = e
    until sorted[index]
        sorted[index] = true
        num+=1
        value = A[index]
        sum += value
        if value < cycleMin
            cycleMin = value
        end
        index = sortedA.index(value)
    end
    cost1 = cycleMin * (num - 3)
    cost2 = min * (num + 1)
    cost += sum + cycleMin + (cost1<=cost2 ? cost1 : cost2)
}
puts cost

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

#define DEBUG(x) do {std::cerr << #x << ": " << x << std::endl; } while (0)


int main(int argc, const char ** argv){
	int n, l;
	std::cin >> n >> l;
	std::cin.ignore();

	std::vector<std::string> containers (n, "");

	for (auto &i: containers) std::cin >> i;

	std::sort(containers.begin(), containers.end());

	for (auto &i: containers) std::cout << i;
	std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	ms := make([]int, n)
	for i := range ms {
		fmt.Scan(&ms[i])
	}

	min := 1000
	for _, m := range ms {
		x -= m
		if m < min {
			min = m
		}
	}
	fmt.Println(len(ms) + x/min)
}

Measured memory_bytes: 512
n=int(input())
a=input()
import collections 
e=a.count("E")
w=0
mini=n
for i in range(n):
    if a[i]=="E":
        e-=1
    if i!=0 and a[i-1]=="W":
        w+=1
    mini=min(mini,e+w)
print(mini)

Measured memory_bytes: 3676
#include <iostream>
#include <set>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 10000
using namespace std;

int main () {
  std::cin.tie(0); // tie
  std::ios::sync_with_stdio(false); // sync
  int n, q, val;
  int count = 0, m, i;
  set<int> S;

  cin >> n;
  rep(i,n) {
    cin >> val;
    S.insert(val);
  }

  cin >> q;
  rep(i,q) {
    cin >> m;
    if (S.find(m) != S.end())  count++;
  }
  cout << count << endl;
  return 0;
}
  

Measured memory_bytes: 1244
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	int n = in();
	vector<int>a(n);
	int a_min = 200, a_max = -200;
	REPC(&i, a) {
		i = in();
		a_min = min(a_min, i);
		a_max = max(a_max, i);
	}
	int res = 5000000;
	for (int i = a_min; i <= a_max; ++i) {
		int temp = 0;
		REPC(j, a) {
			temp += (j - i) * (j - i);
		}
		res = min(res, temp);
	}
	cout << res << endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N+1);
    long long int sumOdd = 0, sumEven = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
        if (i % 2 == 1)
            sumOdd += a[i];
        else
            sumEven += a[i];
    }
    
    for (int i = 1; i <= N; ++i) {
        cout << sumOdd - sumEven << " ";
        sumOdd = sumOdd - a[i];
        auto temp = sumEven;
        sumEven = sumOdd;
        sumOdd = temp + a[i];
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {

	int n;
	cin >> n;
	vector<int>b(n - 1);

	rep(i, n - 1) cin >> b[i];

	int ans = 0;
	rep(i, n - 2)
		ans += min(b[i], b[i + 1]);

	ans += b[0] + b[b.size() - 1];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String str2 = str.replace(",", " ");

		System.out.println(str2);


	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;
#define MOD 1000000007

int main(){
    
    ll N; cin>>N;
    vector<ll> A(N);
    REP(i,N)cin>>A[i];
    
    vector<ll> diff(N);
    REP(i,N)diff[i] = A[(i+1)%N] - A[i];
    
    ll sum = 0;
    REP(i,N)sum+=A[i];
    
    if(sum%(N*(N+1)/2)!=0){
        cout<<"NO"<<endl;
        return 0;
    }
    
    ll k = sum / (N*(N+1)/2);
    REP(i,N)diff[i] -= k;
    
    REP(i,N){
        if(!(abs(diff[i])%N==0 && diff[i]<=0)){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout<<"YES"<<endl;
    
    return 0;
}

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

int main() {
    int x = 1, y = 1;
    while (x != 0 || y != 0) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x > y) swap(x, y);
        
        cout << x << ' ' << y << endl;
    }
}


Measured memory_bytes: 3008
def calc_score(cnt_left, cnt_right, cnt_back, deq):
  got = deq[0:cnt_left]
  got.extend(deq[len(deq) - cnt_right:])
  sort = sorted(got)
  score = sum(sort[cnt_back:])
  return score

  
  
def main():
  n, k = [int(v) for v in input().split()]
  max_act = k

  deq = [int(v) for v in input().split()]

  high_score = 0
  for cnt_act in range(max_act + 1):
    for cnt_get in range(cnt_act + 1):
      #取得回数がでキューサイズを超えていたら実行不能
      #今後取得回数が増えるだけなのですべて実行不能なのでbreak
      if cnt_get > len(deq):
        break
        
      #戻し回数
      cnt_back = cnt_act - cnt_get
      #戻し回数が取得回数より大きいのは実行不能なのでcontinue
      if cnt_back >= cnt_get:
        continue
        
      #左取得、右取得に分割してスコアを求める
      for cnt_get_left in range(cnt_get + 1):
        cnt_get_right = cnt_get - cnt_get_left
        score = calc_score(cnt_get_left, cnt_get_right, cnt_back, deq)
        high_score = max(high_score, score)
       
  print(high_score)
  
main()

Measured memory_bytes: 3192
n = int(input())
a_list = [0] + [int(x) for x in input().split()] + [0]
d1_list = [abs(a_list[i + 1] - a_list[i]) for i in range(n + 1)]
d2_list = [abs(a_list[i + 2] - a_list[i]) for i in range(n)]
travel_all = sum(d1_list)
for i in range(n):
    print(travel_all - d1_list[i] - d1_list[i + 1] + d2_list[i])

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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long
#define mod int(1e9+7)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi (acos(-1))
#define S second
#define F first
ll fp(ll n , ll p )
{
    if(p==0)
        return 1;
    if(p==1)
        return n ;
    ll res = fp(n,p/2) ;
    res=((res)*(res)) ;
    if(p%2)
        res=(res*n) ;
    return res ;
}

int main()
{
    ENGZ;
    bool f = 0;
    int n , a ;
    cin>>n ;
    while(n--)
    {
        cin>> a ;
        if(a%2==0)
        {
            if(a%3 == 0)continue;
            if(a%5 == 0)continue;
            f = 1 ;
        }
    }
    if(f==0)cout<<"APPROVED" <<endl ;
    else cout<<"DENIED"<<endl ;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, x, y = map(int, input().split())
    ans = [0] * (n - 1)
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            d = min(j - i, abs(i - x) + abs(j - y) + 1, abs(i - y) + abs(j - x) + 1)
            ans[d - 1] += 1
    print(*ans, sep='\n')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 45020
/***********************************************
#
#      Filename: e.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-06-10 17:31:11
***********************************************/
#include <bits/stdc++.h>
using namespace std;

int N, K;

int lowbit(int x) {
    return x & (-x);
}

long long compute(const vector<long long>& a) {
    int n = a.size();
    vector<long long> b ( a );
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    unordered_map<long long, int> dic;
    for (int i = 0; i < b.size(); ++ i) {
        dic[b[i]] = i + 1;
    }

    long long res = 0;
    vector<int> count(b.size() + 1, 0);
    for (auto val : a) {
        int index = dic[val];
        while (index > 0) {
            res += count[index];
            index -= lowbit(index);
        }
        index = dic[val];
        while (index <= b.size()) {
            count[index] ++;
            index += lowbit(index);
        }
    }
    return res;
}

int main()
{
    cin >> N >> K;
    int x;
    vector<int> a;
    for (int i = 0; i < N; ++ i) {
        cin >> x;
        a.push_back(x);
    }
    vector<long long> b(a.size() + 1, 0);
    long long sum = a[0];
    for (int j = 1; j <= N; ++ j) {
        b[j] = sum - j * 1LL * K ;
        sum += a[j];
    }
    cout << compute(b) << endl;
    return 0;
}


Measured memory_bytes: 13208
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N;
int A[200010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	int sum=0;
	REP(i,N){
		sum+=A[i];
	}
	DEB(sum)END
	int sum2=0;
	vector<int> v;
	REP(i,N-1){
		sum2+=A[i];
		v.push_back(abs(sum2-(sum-sum2)));
	}
	cout<<MIN(v.begin(),v.end())<<endl;
	return 0;
}


Measured memory_bytes: 3956
#include <stdio.h>
#include <limits.h>

typedef long long ll;

ll x[100005];

ll min(ll a,ll b){
	if(a<b){return a;}
	else{return b;}
}

int main() {

	int N,K;

	scanf("%d %d",&N,&K);

	int i;

	for(i=0;i<N;i++){
		scanf(" %lld",&x[i]);
	}

	ll ans=LLONG_MAX;

	for(i=0;i<=N-K;i++){

	if(x[i+K-1]>=0 && x[i]>=0){
		ans=min(ans,x[i+K-1]);
	}
	else{
		if(x[i+K-1]<=0 && x[i]<=0){
			ans=min(ans,-x[i]);
		}
		else{
			ll sum=-x[i];
			sum+=x[i+K-1]-x[i];

			ans=min(ans,sum);

			sum=x[i+K-1];
			sum+=x[i+K-1]-x[i];

			ans=min(ans,sum);
		}
	}

	}
	printf("%lld\n",ans);


	return 0;
}

Measured memory_bytes: 896
h,w = (int(x) for x in input().split())
ab = []
count = 0
for _ in range(h):
    a = input()
    a = a+'#'
    ab.append(list(a))
    for i in a:
        if i == '.':
            count += 1
ab.append(list('#'*w))
dp = [[0 for i in range(w)] for j in range(h)]
 
step = [[0, 0]]
dp[0][0] = 1

while len(step) > 0:
    y, x = step.pop(0)
    if y == h-1 and x == w-1:
        print(count-dp[y][x])
        exit()
    if ab[y+1][x] == '.' and dp[y+1][x] == 0 :
        step.append([y+1, x])
        dp[y+1][x] = dp[y][x] + 1
    if ab[y][x+1] == '.' and dp[y][x+1] == 0 :
        step.append([y, x+1])
        dp[y][x+1] = dp[y][x] + 1
    if ab[y-1][x] == '.' and dp[y-1][x] == 0 :
        step.append([y-1, x])
        dp[y-1][x] = dp[y][x] + 1
    if ab[y][x-1] == '.' and dp[y][x-1] == 0 :
        step.append([y, x-1])
        dp[y][x-1] = dp[y][x] + 1


print(-1)    


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,T; cin >> N >> T;
    vi A[4];
    int ww;
    rep(i,N){
        int a,b; cin >> a >> b;
        if(!i) ww = a;
        A[a-ww].eb(b);
    }
    rep(i,4){
        sort(all(A[i]),greater<int>());
    }
    int ans=0;
    rep(i,A[0].size()+1){
        rep(j,A[1].size()+1){
            rep(k,A[2].size()+1){
                rep(l,A[3].size()+1){
                    if(ww*i+(ww+1)*j+(ww+2)*k+(ww+3)*l > T) continue;
                    else {
                        int pos=0;
                        rep(n,i) pos+=A[0][n];
                        rep(m,j) pos+=A[1][m];
                        rep(o,k) pos+=A[2][o];
                        rep(p,l) pos+=A[3][p];
                        ans=max(ans,pos);
                    }
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256