akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007;
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
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; }

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

int n, k;
vector<vi> e(2020);

int dfs(int x, int p, int d) {
        int ans = 1;
        if (d < k / 2) {
                for (int y : e[x]) {
                        if (y == p) {
                                continue;
                        }
                        ans += dfs(y, x, d + 1);
                }
        }
        return ans;
}

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

        rep(i, n - 1) {
                int a, b;
                cin >> a >> b, -- a, -- b;
                e[a].pub(b);
                e[b].pub(a);
        }

        int ans = 0;

        if (!(k & 1)) {
                rep(i, n) {
                        amax(ans, dfs(i, -1, 0)); 
                }
        } else {
                rep(i, n) {
                        for (int j : e[i]) {
                                amax(ans, dfs(i, j, 0) + dfs(j, i, 0));
                        }
                }
        }

        D(n - ans);
        return 0;
}


Measured memory_bytes: 384
N,K =map(int,input().split())
Pi = 1/N
for i in range(100):
    if N*(2**i) >= K:
        fre = i
        break
    else:
        continue
Sum = 0
for j in range(N):
    Nu = N - j
    if (Nu*(2**fre)) >= K:
        Sum += Pi*((1/2)**fre)
    else:
        for k in range(100):
            fre += 1
            if (Nu*(2**fre)) >= K:
                Sum += Pi*((1/2)**fre)
                break
print(Sum)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
using namespace std;
int n;
long long f[45];
int main(){
	scanf("%d",&n);
	f[0]=2;
	for(int i=1;i<=n;i++) f[i]=f[i-1]*2+2;
	cout<<f[n]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,ans=0;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)ans++;
    }
    for(int i=0;i<m;i++)
    {
        for(int j=i+1;j<m;j++)ans++;
    }
    cout<<ans;

}



Measured memory_bytes: 256
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


"""def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)"""

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    r,g,b=map(int,input().split())
    k=int(input())
    ct=0
    if(g<=r):
        while(g<=r):
            ct+=1
            g*=2
    if (b <= g):
        while(b<=g):
            ct+=1
            b*=2
    if(ct<=k):
        print('Yes')
    else:
        print('No')



BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 67468
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	n%=10;
	if (n==2||n==4||n==5||n==7||n==9) cout << "hon" << endl;
	else if (n==3) cout << "bon" << endl;
	else cout << "pon" << endl;
	return 0; 
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_V 200000

struct edge{
	int to;
	double cost;
};

vector<edge> G[MAX_V];
double d[MAX_V];

// O(ElogV)

void shortest_path(int s, int V){
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

double x[1100], y[1100], r[1100];

int main(){
    long long int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> x[i] >> y[i] >> r[i];
    }
    edge e;
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            if(i == j){
                continue;
            }
            e.to = j;
            e.cost = max(0.0, sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - r[i] - r[j]);
            G[i].push_back(e);
        }
        e.cost = max(0.0, sqrt((x[i] - xs) * (x[i] - xs) + (y[i] - ys) * (y[i] - ys)) - r[i]);
        e.to = i;
        G[0].push_back(e);
        e.cost = max(0.0, sqrt((x[i] - xt) * (x[i] - xt) + (y[i] - yt) * (y[i] - yt)) - r[i]);
        e.to = N + 1;
        G[i].push_back(e);
    }
    e.cost = sqrt((xt - xs) * (xt - xs) + (yt - ys) * (yt - ys));
    e.to = N + 1;
    G[0].push_back(e);
    shortest_path(0, N + 2);
    printf("%.10f\n", d[N + 1]);
    return 0;
}

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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n; 
	int d[n];
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			sum += d[i] * d[j];
		}
	}
	cout << sum;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int n, m; cin >> n >> m;
    vvi adj(n);
    vi indeg(n, 0);
    F0R (i, m) {
        int x, y; cin >> x >> y;
        adj[x - 1].pb(y - 1);
        indeg[y - 1]++;
    }

    vi dist(n, 0);
    queue<int> q;
    vb vis(n, false);
    F0R (i, n) if (indeg[i] == 0) {
        q.push(i);
    }

    while (!q.empty()) {
        int node = q.front(); q.pop();
        if (vis[node]) continue;
        vis[node] = true;
        for (int next : adj[node]) {
            indeg[next]--;
            if (indeg[next] == 0) {
                dist[next] = dist[node] + 1;
                q.push(next);
            }
        }
    }

    int ans = 0;
    F0R (i, n) {
        ans = max(ans, dist[i]);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans=0;
    for(int i=0;i<=n/r;i++){
        for(int k=0;k<=n/g;k++){
            if((n-(i*r+k*g))%b==0 && n-(i*r+k*g)>=0) ans++;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
typedef pair<int , int > P;
const int maxn=5005;
const LL INF=1e13+5;
using i64 = long long;
int n, k, i, j, x, p[maxn], c[maxn];
LL a[maxn], b[maxn];
int main() {
    cin >> n >>k;
    LL ans=-INF;
    for (i = 1; i <= n; ++i)
        cin >> p[i];
    for (i = 1; i <= n; ++i)
        cin >> c[i];
    for(int i=1;i<=n;i++)
        for(int x=p[i], cnt=1;cnt<=k;cnt++, x=p[x])
    {
        a[cnt]=a[cnt-1]+c[x];
        b[cnt]=max(b[cnt-1], a[cnt]);
        ans=max(ans, a[cnt]);
        if(cnt==k)
            break;
        if(i==x)
        {
            ans=max(ans, a[cnt]*(k/cnt)+b[k%cnt]);
            ans=max(ans, a[cnt]*(k/cnt-1)+b[cnt]);
            break;
        }
    }



    cout <<ans;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  
  int b,c;
  
  for(int i=0;i<X;i++){
    if(A<B){
      break;
    }
    else{
      B*=2;
      b++;
    }
  }
  
  c=X-b;
  
  for(int i=0;i<c;i++){
    C*=2;
  }
  
  if(B<=A){
    cout << "No" << endl;
  }
  else if(B>=C){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}




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

int main(){

    int n,m;
    cin >> n >>m;

    cout << (n*(n-1)+m*(m-1))/2 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

class Main {
   public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       int    a = in.nextInt();
       int    b = in.nextInt();
       int    x = a*b;
       int    y = 2*a+2*b;
       System.out.println(x + " " + y);
   }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  for (int i = 0; i < h; i++) cin >> s[i];

  vector<vector<int>> yoko(h, vector<int>(w));
  vector<vector<int>> tate(h, vector<int>(w));

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (s[y][x] == '.') {
        int count = 0, b = x;
        while (x < w && s[y][x] == '.') {
          count++;
          x++;
        }
        for (int i = 0; b + i < x; i++) {
          yoko[y][b + i] = count;
        }
      }
    }
  }

  for (int x = 0; x < w; x++) {
    for (int y = 0; y < h; y++) {
      if (s[y][x] == '.') {
        int count = 0, b = y;
        while (y < h && s[y][x] == '.') {
          count++;
          y++;
        }
        for (int i = 0; b + i < y; i++) {
          tate[b + i][x] = count;
        }
      }
    }
  }

  int ans = 0;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      ans = max(ans, tate[y][x] + yoko[y][x] - 1);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 35712
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

int main(){
  long long n;
  cin >> n;
  string s;
  long long m=0;
  long long a=0;
  long long r=0;
  long long c=0;
  long long h=0;
  for(int i=0;i<n;i++){
  cin >> s;
  if(s[0]=='M')m++;
  if(s[0]=='A')a++;
  if(s[0]=='R')r++;
  if(s[0]=='C')c++;
  if(s[0]=='H')h++;
  }
  long long ans = 0;
  ans += m*a*r;
  ans += m*a*c;
  ans += m*a*h;
  ans += m*r*c;
  ans += m*r*h;
  ans += m*c*h;
  ans += a*r*c;
  ans += a*c*h;
  ans += a*r*h;
  ans += r*c*h;
  cout << ans << endl;
  // cout << m <<endl;
  // cout << a <<endl;
  // cout << r <<endl;
  // cout << c <<endl;
  // cout << h << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n;
char a[N];
int l[N],r[N],cnt,vis[N],f[N];
char q[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++){
    f[i]=i;
    cin>>a+1;cnt=0;
    int n=strlen(a+1);
    for(int j=1;j<=n;j++){
      if(a[j]=='('){
        q[++cnt]='(';
      }else{
        if(q[cnt]=='(')--cnt;
        else q[++cnt]=')';
      }
    }
    for(int j=1;j<=cnt;j++){
      if(q[j]=='(')l[i]++;
      else r[i]++;
    }
 
  }
  int L=0,R=0;
  sort(f+1,f+1+n,[](int x,int y){
    if(l[x]>=r[x] && l[y]<r[y])return 1;
    if(l[x]<r[x] && l[y]>=r[y])return 0;
    if(l[x]>=r[x] && l[y]>=r[y])return (int)(r[x]<r[y]);
    if(l[x]<=r[x]&&l[y]<=r[y])return (int)(l[x]>l[y]);
  });
  for(int i=1;i<=n;i++){
    if(L<r[f[i]])return cout<<"No\n",0;
    L-=r[f[i]];
    L+=l[f[i]];
  }
  if(!L)cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 15296
# AOJ 0289: Infinite Express
# Python3 2018.6.23 bal4u

def calc(s, d):
	if s == d: return 0;
	ans = 0
	if s & 1:
		ans += 1
		s += 1
	if d & 1:
		ans += 1
		d -= 1
	return ans + calc(s>>1, d>>1);

n = int(input())
for i in range(n):
	s, d = map(int, input().split())
	print(calc(s, d))


Measured memory_bytes: 5604
using System;

namespace _0047
{
    class Program
    {
        static void Main(string[] args)
        {
            char ball = 'A';
            while (true)
            {
                string now = Console.ReadLine();
                if (now == null)
                {
                    break;
                }
                if (now[0] == ball)
                {
                    ball = now[2];
                }
                else if (now[2] == ball)
                {
                    ball = now[0];
                }
            }
            Console.WriteLine(ball);
        }
    }
}

Measured memory_bytes: 8716
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int x, y;
    scan(x, y);
    for (size_t i = 0; i <= x; i++) {
        int j   = x - i;
        int sum = 2 * i + 4 * j;
        if (sum == y) {
            print("Yes");
            return 0;
        }
    }
    print("No");

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string N;
  cin >> N;
  
  if (N[0] == N[2]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> A(N), B(N);
	for (int i=0; i<N; i++)
		cin>>A[i]>>B[i];
	sort(A.begin(),A.end()); sort(B.begin(),B.end());
	if(N%2) cout<<B[(N+1)/2 - 1] - A[(N+1)/2 - 1] + 1<<"\n";
	else cout<<B[N/2]+B[N/2 - 1] - A[N/2]-A[N/2 - 1] + 1<<"\n";
	return 0;
}

Measured memory_bytes: 4788
#include<iostream>
#include<queue>
#define N 100
#define INFTY (1<<21)
using namespace std;

int n,M[N][N];
int d[N];

void bfs(int s)
{
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i]=INFTY;
  d[s]=0;
  int u;
  while(!q.empty())
    {
      u=q.front(); q.pop();
      for(int v=0;v<n;v++)
	{
	  if(M[u][v]==0) continue;
	  if(d[v]!=INFTY) continue;
	  d[v]=d[u]+1;
	  q.push(v);
	}
    }
  for(int i=0;i<n;i++)
    {
      cout<<i+1<<" "<<((d[i]==INFTY) ? (-1) : d[i]) <<endl;
    }
}

int main()
{
  int u,k,v;

  cin>>n;

  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++) M[i][j]=0;
    }

  for(int i=0;i<n;i++)
    {
      cin >> u >> k;
      u--;
      for(int j=0;j<k;j++)
	{
	  cin >> v;
	  v--;
	  M[u][v]=1;
	}
    }

  bfs(0);

  return 0;
}
		     



Measured memory_bytes: 3136
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1000000000;
const long long lmx=1999999999999999999;
int d,k;
int a[100003],s=lmax;
int main(){std::ios::sync_with_stdio(false);
cin>>d>>k;
for(int i=0;i<d;i++)
{
	cin>>a[i];
}
sort(a,a+d);
for(int i=0;i+k-1<d;i++)
{
	s=min(s,a[i+k-1]-a[i]);
}
cout<<s<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





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

using namespace std;

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

  unordered_set<int> connectedWith1, connectedWithN;

  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if(a == 1) {
      connectedWith1.insert(b);
    }
    if(b == N) {
      connectedWithN.insert(a);
    }
  }

  for(int i: connectedWith1) {
    if(connectedWithN.find(i) != connectedWithN.end()) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }


  cout << "IMPOSSIBLE" << endl;
  return 0;

}


Measured memory_bytes: 8520
#include<bits/stdc++.h>
#define pi 3.1415
#define ll long long
#define pii pair<int,int>
#define debug(a) cout<<a<<'\n'
#define maxn 200009
#define MOD 200009
#define inp freopen("input.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
using namespace std;
ll segt[4*maxn];
ll vet[maxn];
void build(int id,int l,int r){
    if(l==r){
        segt[id]=vet[l];
    }
    else{
        int md=(l+r)>>1;
        build(id<<1,l,md);
        build(id<<1|1,md+1,r);
        segt[id]=max(segt[id<<1],segt[id<<1|1]);
    }
}
ll query(int id,int l,int r,int x,int y){
    if(x<=l && r<=y)return segt[id];
    if(l>y || r<x)return -1;
    else{
        int md=(l+r)>>1;
        return max(query(id<<1,l,md,x,y),query(id<<1|1,md+1,r,x,y));
    }
}
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>vet[i];
    }
    build(1,1,n);
    for(int i=1;i<=n;i++){
        if(i==1)cout<<query(1,1,n,2,n)<<endl;
        else if(i==n)cout<<query(1,1,n,1,n-1)<<endl;
        else cout<<max(query(1,1,n,1,i-1),query(1,1,n,i+1,n))<<endl;
    }
    return 0;
}   


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

vector<long long int> a;
vector<vector<long long int>> dp;

long long int f(int left, int right){
    if(dp[left][right] != -1) return dp[left][right];
    if(left == right)         return dp[left][right] = 0;

    long long int ans = 1e18;// INF
    for(int i=left; i<right; i++){
        ans = min(ans, f(left, i) + f(i+1, right));
    }
    return dp[left][right] = ans + a[right] - a[left-1];
}

int main(){
    int n;
    cin >> n;
    a.resize(n+1);
    dp.assign(n+1, vector<long long int>(n+1,-1));

    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        a[i+1] += a[i];
    }

    cout << f(1,n) << endl;
    return 0;
}

Measured memory_bytes: 1536
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////
#define int long long

const int mod = 1e9 + 7;

const int N = 2e6 + 4;
int fact[N];
void init(){

	fact[0] = 1;
	for(int i = 1 ; i < N ; ++i)
		fact[i] = fact[i-1]*i%mod;
}

int power(int a , int n){

	int res = 1;
	while(n){

		if(n&1)
			res*=a , res%=mod;
		a*=a;
		a%=mod;
		n/=2;
	}
	return res;
}

int ncr(int n , int r){

	int val = fact[n];
	int x = fact[r]*fact[n-r]%mod;

	val*=power(x , mod-2);

	val%=mod;
	return val;
}
void solve(){

	init();
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n = s.size();


	int ans = power(26 , n + k);

	for(int i = 0 ; i < n ; ++i){

		int val = ncr(n + k , i)*power(25LL ,n + k - i);
		val%=mod;
		ans-=val;
		if(ans < 0)
			ans += mod;
	}

	cout<<ans<<endl;
}

signed main(){

	fast;
	int t = 1;
	//cin>>t;
	for(int i = 1 ; i <= t ; ++i)
		solve();
}

Measured memory_bytes: 19864
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string a, b;
    cin >> a >> b;
    string ra(a), rb(b);
    reverse(ra.begin(), ra.end());
    reverse(rb.begin(), rb.end());

    if (a == rb && b == ra) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
void calc(string s,map<pair<ll,ll>,int> &m){
    int n = s.size();
    for(int i=0;i<1<<n;i++){
        ll x = 0, y = 0;
        for(int j=0;j<n;j++){
            if(i>>j&1) x = x * 233 + (s[j]-'a'+1);
            else y = y * 233 + (s[j]-'a'+1);
        }
        m[{x,y}]++;
    }
}
int main(){
    int n; string s; cin>>n>>s;
    string a,b;
    for(int i=0;i<2*n;i++){
        if(i<n) a += s[i];
        else b += s[i];
    }
    reverse(b.begin(),b.end());
    map<pair<ll,ll>,int> m1,m2;
    calc(a,m1);
    calc(b,m2);
    ll ans = 0;
    for(auto i: m1){
        ans += 1ll * i.second * m2[i.first];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 49408
//template
import java.util.*;
import java.util.stream.*;
import java.io.*;
public class Main{
	static BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	private static final int HUNDRED = 100;
	public static void main(String[] args) throws IOException{
		
		String s=in.readLine();
		String t=in.readLine();
		int ans=99999;
		int size=s.length()-t.length()+1;
		for(int i=0;i<size;i++) {
			int cont=0;
			for(int j=0;j<t.length();j++) {
				if(s.charAt(j+i)==t.charAt(j))
					continue;
				cont++;
			}
			ans=Math.min(ans, cont);
		}
		out.append(ans+"");
		
		out.flush();
		in.close();
		out.close();
	}
	private static int modulo(int S, int N) { return ((S) & (N - 1)); } // returns S % N, where N is a power of 2
	private static int isPowerOfTwo(int S) { return (S & (S - 1)) == 0 ? 1 : 0; }
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}
	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}
	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}
	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}
	 
}


Measured memory_bytes: 36824
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

using lint = long long;

constexpr int INF = (1 << 30) - 1;

struct star{
    int x, y, b;

    bool operator<(const star& rhs) const {
        return b < rhs.b;
    }
};

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

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

    int n, d;
    cin >> n >> d;

    vector<star> v;
    for(int i = 0 ; i < n ; ++i){
        int x, y, b;
        cin >> x >> y >> b;
        v.push_back({x, y, b});
    }

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

    lint ans = 0;
    int l = 0;
    int r = 0;
    multiset<int> stx;
    multiset<int> sty;
    while(r < n){
        if(v[r].b - v[l].b <= d){
            stx.insert(v[r].x);
            sty.insert(v[r].y);
            ++r;
        }else{
            chmax(ans, (lint)(*stx.rbegin() - *stx.begin()) * (*sty.rbegin() - *sty.begin()));
            auto itx = stx.lower_bound(v[l].x);
            auto ity = sty.lower_bound(v[l].y);
            stx.erase(itx);
            sty.erase(ity);
            ++l;
        }
    }
    chmax(ans, (lint)(*stx.rbegin() - *stx.begin()) * (*sty.rbegin() - *sty.begin()));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 23716
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,t,a,b,ans=mod;
  cin>>n>>t;
  while (n--) {
  	cin>>a>>b;
    if (b<=t) ans = min(ans,a);
  }
  if (ans!=mod) cout<<ans;
  else cout<<"TLE";
}


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

void insertionSort(int A[], const int n, const int g, int *cnt)
{
    for( int i = g; i < n; ++i ){
        int tmp = A[i];
        int j = i - g;
        while( -1 < j && tmp < A[j] ){

            A[j+g] = A[j];
            j = j - g;
            ++*cnt;
        }
        A[j+g] = tmp;
    }
}

void shellSort(int A[], const int n)
{
    int cnt = 0;
    int m;
    int G[100];
    for( int i = 0; i < 100; ++i ){
        if( i == 0 ) G[i] = n / 2 + 1;
        else G[i] = G[i-1] / 2 - 1;
        if( G[i] < 0 ){
            G[i-1] = 1;
            G[i] = 0;
            m = i;
            break;
        }
    }

    for( int i = 0; i < m; ++i )
        insertionSort(A, n, G[i], &cnt);


    printf("%d\n", m);
    for( int i = 0; i < m; ++i ){
        if( i ) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n%d\n", cnt);
    for( int i = 0; i < n; ++i )
        printf("%d\n", A[i]);
}

int main()
{

    int n;
    scanf("%d", &n);
    int A[n];
    for( int i = 0; i < n; ++i )
        scanf("%d", &A[i]);



    shellSort(A, n);

    return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  int x = (2*X) - (Y/2);
  int y = (Y/2) - X;
  
  if (Y%2 == 0) {
    if (x >= 0 && y >= 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
N, M = gets.strip.split(/ /).collect(&:to_i)

pairs = (0..N).collect{ {} }

appeared = []
not_appeared = N

M.times{
	x, y, z = gets.strip.split(/ /).collect(&:to_i)
	
	pairs[x][y] = true
	pairs[y][x] = true
	
	unless appeared[x]
		appeared[x] = true
		not_appeared -= 1
	end
	unless appeared[y]
		appeared[y] = true
		not_appeared -= 1
	end
}

def count(appeared, pairs)
	i = 1
	group_count = 0
	while true
		while appeared[i] == nil
			if i > N
				return group_count
			end
			i += 1
		end
		appeared[i] = nil
		queue = [i]
		while cur = queue.pop
			pairs[cur].keys.each{|v|
				if appeared[v]
					appeared[v] = nil
					queue << v
				end
			}
		end
		
		group_count += 1
	end
end

puts not_appeared + count(appeared, pairs)


Measured memory_bytes: 50040
#include <bits/stdc++.h>
using namespace std;
int n,k;
int ans[507][507];
int main()
{
    scanf("%d",&k);
    if (k<=500)
    {
        n=k;
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
            {
                ans[i][j]=(i+j-1)%n;
                if (ans[i][j]==0) ans[i][j]=n;
            }
    } else
    {
        n=500;
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
            {
                ans[i][j]=(i+j-1)%n;
                if (ans[i][j]==0) ans[i][j]=n;
            }
        int pos=2;
        for (int t=n+1;t<=k;t++)
            for (int i=2;i<=n;i+=2)
                for (int j=1;j<=n;j++)
                    if (ans[i][j]==t-n) ans[i][j]=t;
    }
    printf("%d\n",n);
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n;j++)
            printf("%d ",ans[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 4780
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

def calc(p):
    ret = 0
    # 各条件を満たしていれば、dを加算していく
    for a, b, c, d in abcd:
        if p[b-1] - p[a-1] == c:
            ret += d
    return ret

ans = [0]
def dfs(s):
    if len(s) == N:
        ans[0] = max(ans[0], calc(s))
        return
    for i in range(s[-1],M+1):
        dfs(s+[i])

for i in range(1, M+1):
    dfs([i])

print(ans[0])



Measured memory_bytes: 77772
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
 
int main()
{
	int n, a ,c = 0;
	cin >> n;
 
	for (int i = 0; i < n; i++) {
		cin >> a;
      	if (a % 2 == 0 ){
          if ( a % 3 == 0 || a % 5 == 0 ){
          } else {
            cout << "DENIED" << endl;
            return 0;
          }  
        }
	}
      cout << "APPROVED" << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
long long n, m;
string s;
int main() {
	cin >> n;
    vector<long long> v;
    for(long long i=1; i<=n; ++i){
        long long a; cin >> a;
        v.push_back(a-i);
    }
    sort(v.begin(), v.end());
    long long cen=0;
    if(n%2!=0){
        cen = v[n/2];
    }else{
        cen = (v[n/2] + v[n/2-1])/2;
    }
    long long ans =0;
    for(int i=0; i<n; ++i){
        ans += abs(v[i] -cen);
    }
    
    cout << ans << endl;
	return 0;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	ll d, n; cin >> d >> n;
	if (d == 0 && n == 100) cout << 101;
	else if (d == 1 && n == 100) cout << 10100;
	else if (d == 2 && n == 100) cout << 1010000;
	else cout << (ll)(pow(100, d) * n) << endl;
}

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


Measured memory_bytes: 3824
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int i, n;
    int *a;
    
    scanf("%d", &n);
    
    a = (int*)malloc(sizeof(int)*n);
    
    for(i=0;i <n;i++){
        scanf("%d", &a[i]);
    }
    
    for(i=n-1; i>=0; i--){
        if(i==0) printf("%d\n", a[i]);
        else printf("%d ", a[i]);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	string s; cin>>s;
	char a=s[0],b=s[s.size()-1];
	int ans=s.size()-2;
	if(a==b) ans++;
	if(ans%2==0){
		cout<<"Second"<<endl;
	}else{
		cout<<"First"<<endl;
	}
	
}


Measured memory_bytes: 512
H,W=map(int,input().split())
s=[input() for _ in range(H)]
cells=[(i,j) for i in range(H) for j in range(W)]
di=[1,0,-1,0]
dj=[0,1,0,-1]

for i,j in cells:
    if s[i][j]=='.':
        continue
    flag=False
    for k in range(4):
        ni=i+di[k]
        nj=j+dj[k]
        if ni<0 or nj<0 or ni>=H or nj>=W:
            continue
        if s[ni][nj]=='#':
            flag=True
    if not flag:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 9224
#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 ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,M,Q;
int A[100010],B[100010],X[100010];

signed main(){
	cin>>N>>M>>Q;
	for(int i=1;i<=N;i++){
		cin>>A[i];
	}
	for(int i=1;i<=M;i++){
		cin>>B[i];
	}
	REP(i,Q){
		cin>>X[i];
	}
	A[0]=-INF,B[0]=-INF;
	A[N+1]=INF,B[M+1]=INF;
	REP(i,Q){
		int s1,s2,t1,t2;
		int ok=N+1,ng=0;
		while(abs(ok-ng)>1){
			int mid=(ok+ng)/2;
			if(X[i]<=A[mid]){
				ok=mid;
			}
			else{
				ng=mid;
			}
		}
		s2=ok;
		if(0<s2)s1=s2-1;
		else s1=s2;
		ok=M+1,ng=0;
		while(abs(ok-ng)>1){
			int mid=(ok+ng)/2;
			if(X[i]<=B[mid]){
				ok=mid;
			}
			else{
				ng=mid;
			}
		}
		t2=ok;
		if(0<t2)t1=t2-1;
		else t1=t2;
		int e[10]={};
		DEB(s1)DEB(s2)DEB(t1)DEB(t2)END
		e[0]=abs(X[i]-A[s1])+abs(A[s1]-B[t1]);
		e[1]=abs(X[i]-A[s1])+abs(A[s1]-B[t2]);
		e[2]=abs(X[i]-A[s2])+abs(A[s2]-B[t1]);
		e[3]=abs(X[i]-A[s2])+abs(A[s2]-B[t2]);
		e[4]=abs(X[i]-B[t1])+abs(B[t1]-A[s1]);
		e[5]=abs(X[i]-B[t1])+abs(B[t1]-A[s2]);
		e[6]=abs(X[i]-B[t2])+abs(B[t2]-A[s1]);
		e[7]=abs(X[i]-B[t2])+abs(B[t2]-A[s2]);
		cout<<*min_element(e,e+8)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3712
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, k;
    cin >> n >> k;
    k = min(n, k);
    vector<i64> h_s(n);
    rep(i, n)
    {
        cin >> h_s[i];
    }
    sort(h_s.begin(), h_s.end());
    auto ans = accumulate(h_s.begin(), h_s.begin() + n - k, 0LL);
    cout << ans << endl;

    return 0;
}


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

int main(){
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int w[n], s[n] = {};
  rep(i,n) {
    cin >> w[i];
    if(i > 0) s[i] += s[i-1];
    s[i] += w[i];
  }
  int ans = 114514810;
  rep(i,n-1) ans = min(ans,abs(s[n-1]-2*s[i]));
  cout << ans << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    int P[200050];
    for (int i=0; i < N; ++i) cin >> P[i];
    
    int Q[200050];
    for (int i=0; i < N; ++i){
        Q[P[i]] = i;
    }
    
    int m = 1;
    int i = 1;
    int temp = 1;
    
    while (i < N){
        if (Q[i] < Q[i+1]) {
            ++temp;
            ++i;
        } else {
            if (temp > m){
                m = temp;
            }
             ++i;
             temp = 1;
        }
    }
    if (temp > m) m = temp; // when the last numbers form a block
    
    cout << N - m << endl;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=3003;
ll dp[N][N][2];

void solve(){
	int n;
	cin>>n;
	ll arr[n];
	fr(i,0,n)
	cin>>arr[i];
	fr(i,0,n){
		if(n&1)
			dp[i][i][0]=arr[i];
		else
			dp[i][i][1]=-arr[i];
	}
	fr(l,2,n+1){
		fr(i,0,n-l+1){
			int j=i+l-1;
			if((l&1)==(n&1)){
				dp[i][j][0]=max(arr[i]+dp[i+1][j][1],arr[j]+dp[i][j-1][1]);
			}
			else{
				dp[i][j][1]=min(dp[i+1][j][0]-arr[i],dp[i][j-1][0]-arr[j]);
			}
		}
	}
	cout<<dp[0][n-1][0]<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 85436
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
string s[55];int t[55];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i]>>t[i];
	}
	string cmp;cin>>cmp;
	int ans=0;
	for(int i=n;i>=1;i--){
		if(s[i]==cmp)break;
		ans+=t[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math

def str_input():
    S = raw_input()
    if S[len(S)-1] == "\r":
        return S[:len(S)-1]
    return S

def float_to_str(num):
    return str("{:.10f}".format(num))

def list_input(tp):
    return map(tp, str_input().split())

# # # # # # # # # # # # # # # # # # # # # # # # #

n = input()

cnt = 0

for i in xrange(n):
    m = input()
    for j in xrange(2, int(math.sqrt(m))+1):
        if m % j == 0:
            break
    else:
        cnt += 1

print cnt

Measured memory_bytes: 6484
import numpy as np
import itertools

NMX = input()
NMX = NMX.split()
N = int(NMX[0])
M = int(NMX[1])
X = int(NMX[2])

CA = []
for i in range(N):
    ca = input()
    ca = ca.split()
    CA.append(ca)

CA = np.array(CA, dtype = int)
C = CA[:,0]
A = CA[:,1:]

bb = np.array(list(itertools.product([0, 1], repeat = N)))


cost = 9999999
for b in bb:
    AA = (A.T * b).T
    ss = np.sum(AA, axis=0)
    if np.all(ss >= X):
        CC = np.sum(C.T * b)
        if CC < cost:
            cost = CC

if cost == 9999999:
    print(-1)
else:
    print(cost)
    

Measured memory_bytes: 27784
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}


int main(void){
    int a,b,c; cin >> a >> b >> c;
	if (a == b+c){
		print("Yes");
	}else if(b == a+c){
		print("Yes");
	}else if(c == a+b){
		print("Yes");
	}else{
		print("No");
	}
}


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

using namespace std;

int main()
{
    int n;
    int p[100010];
    int cnt = 0;

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

    for (int i = 1; i < n-1; i++) {
        if ((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])) {
            cnt++;
        }
    }

    cout << cnt << endl;


}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <stack>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
   int a[4][4],b[12],c[4][4];
   memset(c,0,sizeof(c));
   for(int i=1;i<=3;i++)
        for(int j=1;j<=3;j++)
        scanf("%d",&a[i][j]);
   int n,ans=0;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
    scanf("%d",&b[i]);
   for(int r=1;r<=n;r++)
   {
       for(int i=1;i<=3;i++)
       {
           for(int j=1;j<=3;j++)
           {
               if(b[r]==a[i][j])
               {
                   c[i][j]=1;
                   ans+=1;
               }
           }
       }
   }
   //cout<<ans<<endl;
   if(ans<3)
    printf("No\n");
   else
   {
    if(c[1][1]==1&&c[1][2]==1&&c[1][3]==1)
        printf("Yes\n");
    else if(c[2][1]==1&&c[2][2]==1&&c[2][3]==1)
        printf("Yes\n");
    else if(c[3][1]==1&&c[3][2]==1&&c[3][3]==1)
        printf("Yes\n");
    else if(c[1][1]==1&&c[2][1]==1&&c[3][1]==1)
        printf("Yes\n");
      else if(c[1][2]==1&&c[2][2]==1&&c[3][2]==1)
        printf("Yes\n");
    else if(c[1][3]==1&&c[2][3]==1&&c[3][3]==1)
        printf("Yes\n");
    else if(c[1][1]==1&&c[2][2]==1&&c[3][3]==1)
        printf("Yes\n");
     else if(c[3][1]==1&&c[2][2]==1&&c[1][3]==1)
        printf("Yes\n");
     else
        printf("No\n");
   }
    return 0;
}




Measured memory_bytes: 128