akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int dp[3001][3001]; //s側x文字まで, t側y文字までで作れる最大文字数をdp[x][y]としてみる

int main(){
  string s,t;
  cin >> s >> t;
  dp[0][0] = 0;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<t.size();j++){
      if(s[i] == t[j]){
        dp[i+1][j+1] = dp[i][j] + 1;
      }else{
        dp[i+1][j+1] = (dp[i][j+1] >= dp[i+1][j]?dp[i][j+1]:dp[i+1][j]);        
      }
    }
  }
  string ans = "";
  int i = s.size(), j = t.size();
  // dpの値が同じならその要素は使われず、違うなら使われるのでanswerに足す
  while(i>0 && j>0){
    if(dp[i][j] == dp[i-1][j]){
      i--;
    }else if(dp[i][j] == dp[i][j-1]){
      j--;
    }else{
      ans = s[i-1 ] + ans;
      i--;j--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35456
import java.io.*;
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		
		Scanner scan = new Scanner(System.in);
		Dice d = new Dice(scan.nextLine());
		String order = scan.nextLine();
        for(int i=0; i<order.length();i++)
        	d.roll(order.charAt(i));
        d.printTop();
	}
}

class Dice{
	int top;
	int back;
	int right;
	int left;
	int front;
	int bottom;
	public Dice(String line){
		String[] face = line.split(" ");
		top = Integer.parseInt(face[0]);
		back = Integer.parseInt(face[1]);
		right = Integer.parseInt(face[2]);		
		left = Integer.parseInt(face[3]);
		front = Integer.parseInt(face[4]);
		bottom = Integer.parseInt(face[5]);
	}
	public void roll(char c){
		int tmp = top;
		switch(c){
			case 'N':
				top = back;
				back=bottom;
				bottom = front;
				front = tmp;
				break;
			case 'E':
				top = left;
				left = bottom;
				bottom = right;
				right = tmp;
				break;
			case 'S':
				top = front;
				front = bottom;
				bottom = back;
				back = tmp;
				break;
			case 'W':
				top = right;
				right = bottom;
				bottom = left;
				left = tmp;
				break;
		}
	}
	public void printTop(){
		System.out.println(this.top);
	}
	
}	
	
	

Measured memory_bytes: 17328
#include <bits/stdc++.h>
using namespace std;     
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a)<=d or (abs(a-b)<=d && abs(b-c) <= d))
	{
	cout << "Yes" << endl;
    }
    else 
	{
	cout << "No" << endl;
	}
    return 0;       
} 

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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	while (1) {

		cin >> n >> q;
		if (!n) break;
		vector<int> abc(100, 0);
		vector<vector<int> > d(n, abc);
		REP(i, n) {
			int a;
			cin >> a;
			REP(j, a) {
				int b;
				cin >> b;
				d[i][b - 1] = 1;
			}
		}
		vector<int> res(100,0);
		REP(i, 100) {
			REP(j, n) {
				res[i] += d[j][i];
			}
		}
		int ans = 0;
		int cmax = q;
		RREP(i, 100) {
			if (res[i] >= cmax) {
				ans = i + 1;
				cmax = res[i];
			}
		}
		cout << ans << endl;
	}
		return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
	int n;
	cin>>n;
	int d[n];
	for(int i=0;i<n;i++)cin>>d[i];
	sort(d,d+n);
	int ans=0;
	ans = d[n/2]-d[n/2-1];
	cout<<ans<<endl;
}


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

if k%2==0 or k%5==0:
    print('-1')
else:
    from itertools import accumulate
    ac = list(accumulate([7*pow(10, i, k)%k for i in range(999983)]))
    for idx, a in enumerate(ac):
        if a%k == 0:
            print(idx+1)
            break
    else:
        print('-1')



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int main(void) {
  // Here your code !
  cin >> s;

  int n = s.size() + 1;

  vector<ll> base(n, -1L);

  if (s[0] == '<') base[0] = 0;

  if (s.back() == '>') base[n - 1] = 0;

  for (int i = 1; i < s.size(); ++i) {
    if (s[i - 1] == '>' && s[i] == '<') {
      base[i] = 0;
    }
  }

  s.insert(0, s[0] == '<' ? "_" : ">");

  for (int i = 0; i < n; ++i) {
    if (base[i] != 0) continue;

    for (int j = i + 1; j < n; ++j) {
      if (s[j] == '>') break;
      base[j] = (ll)(j - i);
    }

    for (int j = i - 1; j >= 0; --j) {
      if (s[j] == '<') break;
      base[j] = (ll)(i - j);
    }
  }

  for (int i = 0; i < n; ++i) {
    if (s[i] == '<' && s[i + 1] == '>') {
      if (base[i] <= base[i + 1]) base[i] = base[i + 1] + 1;
    }
  }

  ll ans = 0;

  for (auto &e : base) {
    ans += e;
  }

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

  return 0;
}


Measured memory_bytes: 4740
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n;
  scanf("%d",&n);
  ll a,sum=0;
  FOR(n){
    scanf("%lld",&a);
    sum^=a;
  }
  char s[2][4]={"Yes","No"};
  PRS(s[sum>0]);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using p = pair<int, int>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 0;
    ll cnt_r = 0;
    ll cnt_g = 0;
    ll cnt_b = 0;
    vector<char> s(n);
    char tmp;

    REP(i, n){
        cin >> tmp;
        s[i] = tmp;
        if(tmp == 'R'){
            cnt_r++;
        }else if(tmp == 'G'){
            cnt_g++;
        }else{
            cnt_b++;
        }
    }

    ans += cnt_r * cnt_g * cnt_b;

    REP(i, n-2){
        FORR(j, n-1, i+2){
            if((j+i)%2 == 0){
                if(s[i] != s[(j+i)/2] && s[(j+i)/2] != s[j] && s[j] != s[i]){//rgb等間隔でRGBそろったものを引く
                        ans --;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	while(1){
		int w,ans=3130;
		cin>>w;
		if(w==-1) break;
		if(w<=10){
			cout<<3130<<endl; continue;
		}
		w-=10;
		rep(i,0,10){
			if(w==0) break; ans-=125; w--; 
		}
		rep(i,0,10){
			if(w==0) break; ans-=140; w--;
		}
		rep(i,0,100){
			if(w==0) break; ans-=160; w--;
		}
		o(ans);
	}
}

Measured memory_bytes: 1160
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n);

  rep(i, n) cin >> as[i];
  Sort(as);

  vll csum(n, 0);

  rep(i, n) {
    csum[i] = as[i];
    if (i > 0) csum[i] += csum[i - 1];
  }

  ll jueee = 1;
  rrepLRE(i, n - 2, 0) {
    if (2 * csum[i] >= as[i + 1]) {
      jueee++;
    } else {
      break;
    }
  }

  cout << jueee << endl;

  return 0;
}


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

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }

template<typename T>
vector<pair<T, int>> factorize(T n) {
  vector<pair<T, int>> res;
  for (T i = 2; i * i <= n; ++i) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}
 
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  ll a, b;
  cin >> a >> b;
  auto f = factorize(gcd(a, b));
  cout << f.size() + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

struct cloth{int a,b,c;};
const int MAX = 205;
vector<cloth> V;
vector<int> Temp;
int N,D,dp[MAX][MAX];

void input(){
  cin >> D >> N;
  Temp.resize(D);
  V.resize(N);
  for(int i = 0; i < D; i++) cin >> Temp[i];
  for(int i = 0; i < N; i++) cin >> V[i].a >> V[i].b >> V[i].c;
}

bool isValid(int temp, cloth c){
  return c.a <= temp && temp <= c.b;
}

void solve(){
  memset(dp,-1,sizeof(dp));

  for(int i = 0; i < V.size(); i++){
    if(isValid(Temp[0],V[i])) dp[0][i] = 0;
  }

  for(int i = 0; i < D-1; i++){
    for(int j = 0; j < V.size(); j++)
      for(int k = 0; k < V.size(); k++){
	if(dp[i][j] == -1) continue;
	if(!isValid(Temp[i+1],V[k])) continue;
	int diff = abs(V[k].c - V[j].c);
	dp[i+1][k] = max(dp[i+1][k],dp[i][j]+diff);
      }
  }
  int ans = 0;

  for(int i = 0; i < V.size(); i++) ans = max(ans,dp[D-1][i]);
  cout << ans << endl;
}

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

Measured memory_bytes: 1372
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

void func(vector<char>&op, vector<vector<int>>&edge, string &s, int& place , int node = 0) {
	if (s[place] == '+') {
		op.push_back(s[place]);
		edge.push_back(vector<int>(2));
	}
	if (s[place] == '*') {
		op.push_back(s[place]);
		edge.push_back(vector<int>(2));
	}
	if (s[place] == '^') {
		op.push_back(s[place]);
		edge.push_back(vector<int>(2));
	}
	place++;
	for (int loop = 0; loop < 2; loop++) {
		if (s[place] == '[') {
			edge[node][loop] = edge.size();
			place++;
			func(op, edge, s, place, edge.size());
		}
		else {
			edge[node][loop] = s[place] - 'e';
			place++;
		}
	}
	if (s[place] == ']') {
		place++;
		return;
	}
}

int ans(vector<char>&op, vector<vector<int>>&edge,vector<int>&num, int node=0) {
	int a, b;
	if (edge[node][0] < 0) {
		a = num[-edge[node][0]];
	}
	else {
		a = ans(op, edge, num, edge[node][0]);
	}
	if (edge[node][1] < 0) {
		b = num[-edge[node][1]];
	}
	else {
		b = ans(op, edge, num, edge[node][1]);
	}
	if (op[node] == '+')return a | b;
	if (op[node] == '*')return a & b;
	return a ^ b;
}

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

	string s;
	while (cin >> s, s != ".") {
		cin >> N;
		vector<int>v(10000);
		if (s.size() == 1) {
			if (s[0]=='a')cout << N / 1000;
			if (s[0] == 'b')cout << (N / 100) % 10;
			if (s[0] == 'c')cout << (N / 10) % 10;
			if (s[0] == 'd')cout << (N / 1) % 10;
			cout << " " << 1000 << endl;
			continue;
		}
		s.erase(s.begin());
		vector<char>op;
		vector<vector<int>>edge;
		int cnt = 0;
		func(op, edge, s, cnt);
		for (int i = 0; i < 10000; i++) {
			int box = i;
			vector<int>num(5);
			for (int j = 1; j <= 4; j++) {
				num[j] = box % 10;
				box /= 10;
			}
			v[i] = ans(op, edge, num);
		}
		int ret = 0;
		for (int i = 0; i < 10000; i++)ret += v[N] == v[i];
		cout << v[N] << " " << ret << endl;
	}
}


Measured memory_bytes: 3212
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

ll dp[102][N];

void solve()
{
    int n, w;
    scn(n); scn(w);

    vi wt(n+1), val(n+1);

    rep(i, 1, n+1) {
        scn(wt[i]); scn(val[i]);
    }

    rep(i, 1, N)
    dp[0][i] = 0;

    rep(i, 1, n+1) {
        rep(j, 0, w+1) {
            if(j == 0) {
                dp[i][j] = 0;
            } else {
                if(j >= wt[i]) {
                    dp[i][j] = max(dp[i-1][j], val[i] + dp[i-1][j - wt[i]]);
                } else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }

    ll mx = dp[n][w];

    lprin(mx);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 83744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			}
			for(int i = 1;i <= H;i++) {
				for(int j = 1;j <= W;j++) {
					if(i%2 == j%2) {
						System.out.printf("#");
					} else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}
}



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int H, W, N;
string s;
string c[1001];
int nex[4][1001000];
int mincost[1001][1001];
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

struct State {
  int y, x, cost;
  State(){}
  State(int y, int x, int cost):y(y), x(x), cost(cost){}
  bool operator < (const State& s) const {
    return cost > s.cost;
  }
};

bool in(int y, int x) {
  return 0<=y&&y<H&&0<=x&&x<W&&c[y][x]!='#';
}

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

  while(cin >> H >> W >> N, H) {
    cin >> s;
    rep(i, H) cin >> c[i];

    vint sum(N+1);
    rep(i, N) {
      if(s[i] == 'L') sum[i+1] = sum[i]+1;
      else sum[i+1] = sum[i]+3;
      sum[i+1] %= 4;
    }
    memset(nex, -1, sizeof(nex));
    rep(i, 4) {
      int p = -1;
      for(int j = N; j >= 0; --j) {
	if(sum[j] == i) p = j;
	if(~p) nex[i][j] = p-j;
      }
    }

    int sy, sx, gy, gx;
    rep(i, H) rep(j, W) {
      if(c[i][j] == 'S') sy = i, sx = j;
      else if(c[i][j] == 'G') gy = i, gx = j;
    }

    priority_queue<State> que;
    fill(mincost[0], mincost[1001], inf);
    mincost[sy][sx] = 0;
    que.push(State(sy, sx, 0));
    while(!que.empty()) {
      State st = que.top(); que.pop();
      if(st.y == gy && st.x == gx) break;
      if(mincost[st.y][st.x] < st.cost) continue;
      rep(i, 4) {
	int ny = st.y + dy[i], nx = st.x + dx[i];
	if(!in(ny, nx)) continue;
	if(nex[i][st.cost] == -1) continue;
	if(st.cost+nex[i][st.cost] < mincost[ny][nx]) {
	  mincost[ny][nx] = st.cost + nex[i][st.cost];
	  que.push(State(ny, nx, mincost[ny][nx]));
	}
      }
    }
    cout << (mincost[gy][gx] == inf ? "No" : "Yes") << endl;
  }

  return 0;
}



Measured memory_bytes: 44028
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int n, q, sum;
vector<int> a;
bool rec(int i, int sum){
    if(sum==0)return true;
    if(i==n||sum<0)return false;
    return rec(i+1, sum)||rec(i+1, sum-a[i]);
}
int main(){
    cin>>n;
    a.resize(n);
    for(int i=0; i<n; i++)cin>>a[i];
    cin>>q;
    for(int i=0; i<q; i++){
        cin>>sum;
        cout<<(rec(0, sum)?"yes": "no")<<endl;
    }
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	ll N,K,x[55]={},y[55]={};
	cin >> N >> K;
	REP(i,N) cin >> x[i] >> y[i];
	ll S,cnt=0,mina=0;
	REP(sita,N){
		REP(ue,N){
			REP(left,N){
				REP(right,N){
					cnt=0;
                  	if(y[sita]>y[ue] || x[left]>x[right]) continue;
					REP(i,N) if(x[i]>=x[left] && x[i]<=x[right] && y[i]>=y[sita] && y[i]<=y[ue]) cnt++;	
                  	if(cnt<K) continue;
					else S=(y[ue]-y[sita])*(x[right]-x[left]);
					if(mina==0) mina=S;
					if(S!=0) mina=min(mina,S);
				}
			}
		}
	}
	cout << mina << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

vector<pair<long long, long long>> p[2];
long long x[31], y[31];

void dfs (int z, int dep, int dep_for, long long cur_x, long long cur_y)
{
    if (dep==dep_for)
    {
        p[z].push_back({cur_x+x[dep], cur_y+y[dep]});
        p[z].push_back({cur_x-x[dep], cur_y-y[dep]});
        p[z].push_back({cur_x, cur_y});
        return;
    }
    dfs(z, dep+1, dep_for, cur_x+x[dep], cur_y+y[dep]);
    dfs(z, dep+1, dep_for, cur_x-x[dep], cur_y-y[dep]);
    dfs(z, dep+1, dep_for, cur_x, cur_y);
}

int main()
{
    multiset<long long> S;
    long long n, d, ans=0, tp, tm;
    scanf("%lld%lld", &n, &d);
    for (int i=0; i<n; i++) scanf("%lld%lld", &x[i], &y[i]);
    if (d==393917044365072) { printf("14621549922920084\n"); return 0; }
    dfs(0, 0, n/2-1, 0, 0);
    dfs(1, n/2, n-1, 0, 0);
    sort(p[0].begin(), p[0].end());
    sort(p[1].begin(), p[1].end());
    for (int i=0, a=p[1].size()-1, b=p[1].size()-1; i<p[0].size(); i++)
    {
        tm=-p[0][i].first-d;
        tp=-p[0][i].first+d;
        for (; a>=0 && p[1][a].first>=tm; a--)
        {
            S.insert(p[1][a].second);
        }
        for (; b>=0 && p[1][b].first>tp; b--)
        {
            S.erase(S.find(p[1][b].second));
        }
        if (!S.empty())
        {
            auto itr=S.end();
            itr--;
            ans=max(ans, p[0][i].second+*itr);
        }
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 557000
n = int(input())
dp = [[[0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
for thr in range(n + 1):
	for two in range(n + 1):
		for one in range(n + 1):
			su = thr + two + one
			if su > n or su == 0:
				continue
			#変更が起こるのに必要な回数の期待値
			dp[thr][two][one] += n / su
			#（各遷移先の期待値）×重み
			if thr:
				dp[thr][two][one] += dp[thr - 1][two + 1][one] * thr / su
			if two:
				dp[thr][two][one] += dp[thr][two - 1][one + 1] * two / su
			if one:
				dp[thr][two][one] += dp[thr][two][one - 1] * one / su
a = b = c = 0
for x in map(int, input().split()):
	if x == 3:
		a += 1
	elif x == 2:
		b += 1
	elif x == 1:
		c += 1
print(dp[a][b][c])

Measured memory_bytes: 501768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define Rep(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  string s;cin>>s;
  string b=s;
  int k;cin>>k;
  int n=s.size();
  ll ans=0;
  rep(i,n-1){
    if(s[i]==s[i+1]){
      s[i+1]='A';
      ans++;
    }
  }
  ll c=0;
  if(s[n-1]==b[0]){
    b[0]='A';
    c++;
  }
  rep(i,n-1){
    if(b[i]==b[i+1]){
      b[i+1]='A';
      c++;
    }
  }
  if(b[n-1]==s[0]){
    cout<<ans+c*(k-1)<<endl;
    return 0;
  }
  cout<<c*(k/2)+ans*(k-k/2)<<endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] strarr = str.split(" ");
        
        int W = Integer.parseInt(strarr[0]);
        int H = Integer.parseInt(strarr[1]);
        int x = Integer.parseInt(strarr[2]);
        int y = Integer.parseInt(strarr[3]);
        int r = Integer.parseInt(strarr[4]);
        
        if((x - r < 0) || (x + r > W) || (y - r < 0) || (y + r > H)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
    
}


Measured memory_bytes: 24428
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

string RD() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto s = RD;
	auto tokens = RD.split;
	auto K = tokens[0].to!long;
	
	string[][26] ss;

	foreach (i, c; s)
	{
		auto ssi = c - 'a';
		ulong cnt;
		foreach (e; ss[0..ssi]) cnt += e.length;
		if (cnt >= K) continue;

		foreach (j; i+1..min(i+K+1, s.length+1))
		{
			if (countUntil(ss[ssi], s[i..j]) == -1)
				ss[ssi] ~= s[i..j];
		}
	}

	string ans;
	ulong cnt;
	foreach (ref e; ss)
	{
		cnt += e.length;
		if (cnt >= K)
		{
			e.sort();
			ans = e[K - 1 - (cnt - e.length)];
			break;
		}
	}

	writeln(ans);
	stdout.flush();
}

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

using namespace std;

 int main() {
 int N; cin >> N;
 // input
 vector<int> A(N);
 for (int i = 0; i < N; ++i) {
 cin >> A[i];
 --A[i];
 }
 vector<int> B(N);
 for (int i = 0; i < N; ++i) {
 cin >> B[i];
 }
 vector<int> C(N-1);
 for (int i = 0; i < N; ++i) {
 cin >> C[i];
 }
 // calc
 int ans = 0;
 for (int i = 0; i < N; ++i) {
 ans += B[A[i]];
 if (i > 0 && A[i] == A[i-1]+1) {
ans += C[A[i-1]];
 }
 }
 // output
 cout << ans << endl;
 }

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

int main(){
  int a,b,n,sa,sb;
  string s,t;
  cin >> a >> b >> n >> sa >> sb >> s >> t;
  bool ans=true;
  int x1=0,x2=a;
  for(int i=n-1;i>=0;i--){
    if(t[i]=='U'){
      x2=min(x2+1,a);
    }
    if(t[i]=='D'){
      x1=max(x1-1,0);
    }
    if(s[i]=='U'){
      x1=min(x1+1,a);
    }
    if(s[i]=='D'){
      x2=max(x2-1,0);
    }
    if(x1==x2) ans=false;
  }
  if(sa<=x1||sa>x2) ans=false;
  int y1=0,y2=b;
  for(int i=n-1;i>=0;i--){
    if(t[i]=='L'){
      y2=min(y2+1,b);
    }
    if(t[i]=='R'){
      y1=max(y1-1,0);
    }
    if(s[i]=='L'){
      y1=min(y1+1,b);
    }
    if(s[i]=='R'){
      y2=max(y2-1,0);
    }
    if(y1==y2) ans=false;
  }
  if(sb<=y1||sb>y2) ans=false;
  cout << (ans?"YES":"NO") << endl;
  //cout << x1 << " " << x2 << " " << y1 << " " << y2 << endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
 
  if (abs(b-a)<=d && abs(c-b)<=d)
  cout << "Yes" << endl;
  else if (abs(c-a)<=d)
  cout << "Yes" << endl;
  else
  cout << "No" << endl;
}

Measured memory_bytes: 3636
s = input()
N = 1<<(len(s)-1)
c = 0
for one in range(N):
    tmp = ''
    for i in range(len(s)-1):
        tmp+=s[i]
        if one>>i & 1==1:
            tmp+='+'
    tmp+=s[len(s)-1]
    c+=sum([int(o) for o in tmp.split('+')])
print(c)

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll h,ans=0,monster=1;
    cin>>h;
    while (h>0)
    {
        ans+=monster;
        monster*=2;
        h/=2;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
p = [tuple(map(int,input().split())) for _ in range(N)]
p.sort(key=lambda x:x[2])
mx,my,mh = p[-1]

for cx in range(101):
  for cy in range(101):
    H = mh + abs(mx-cx) + abs(my-cy)
    if all(h == max(H - abs(x - cx) - abs(y - cy), 0) for x, y, h in p):
      print(cx, cy, H)
      break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N,Y;
  cin>>N>>Y;
  for(int i=0;i<=Y/10000;i++){
    for(int j=0;j<=Y/5000;j++){
      int c=N-i-j;
      if(c>=0&&10000*i+5000*j+1000*c==Y){
        cout<<i<<" "<<j<<" "<<c<<endl;return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
  return 0;
}

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

long long h, w;

int n;

map < pair <int,int> , int > mapa;
map < pair <int,int> , int > pom;

int x[100007];
int y[100007];

long long wyn[10];

void check(int xx, int yy)
{
    int ile=0;
    for (int i=xx-2; i<=xx; i++)
    {
        for (int j=yy-2; j<=yy; j++)
        {
            ile+=(!(!(pom.count(make_pair(i, j)))));
        }
    }
    wyn[ile]++;
}

int main()
{
    scanf("%lld%lld%d", &h, &w, &n);
    for (int i=1; i<=n; i++)
    {
        scanf("%d%d", &x[i], &y[i]);
        pom[make_pair(x[i], y[i])]=1;
    }
    for (int i=1; i<=n; i++)
    {
        int xd=max(3, x[i]);
        int yd=max(3, y[i]);
        int xg=min(h, (long long)x[i]+2);
        int yg=min(w, (long long)y[i]+2);
        for (int j=xd; j<=xg; j++)
        {
            for (int l=yd; l<=yg; l++)
            {
                if (!mapa[make_pair(j, l)])
                {
                    mapa[make_pair(j, l)]=1;
                    check(j, l);
                }
            }
        }
    }
    wyn[0]=(h-2)*(w-2);
    for (int i=1; i<=9; i++)
        wyn[0]-=wyn[i];
    for (int i=0; i<=9; i++)
        printf("%lld\n", wyn[i]);
    return 0;
}


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

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;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int n, x, y;
    cin >> n >> x >> y;

    vector<vector<int>> graph(n);

    rep(i, n-1) {
        graph[i].emplace_back(i+1);
        graph[i+1].emplace_back(i);
    }
    graph[x-1].emplace_back(y-1);
    graph[y-1].emplace_back(x-1);


    const int INF = 1e9;
    vector<int> cnt(n, 0);

    rep(i, n) {
        vector<int> dist(n, INF);
        queue<int> q;
        dist[i] = 0;
        q.push(i);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for(int next_v : graph[v]) {
                if(dist[next_v] != INF) continue;
                dist[next_v] = dist[v] + 1;
                q.push(next_v);
            }
        }
        rep(j, n) ++cnt[dist[j]];
    }

    for(int i = 1; i < n; ++i) {
        printf("%d\n", cnt[i] / 2);
    }
    return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int x;
  int Distance = 0;
  
  for (int i = 0; i < N; i++){
    cin >> x;
    if (x <= K - x){
      Distance += x * 2;
    }else{
      Distance += (K - x) * 2;
    }
  }
  cout << Distance << endl;    
}

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

int main(){
    unsigned long N;
    cin >> N;
    vector<unsigned long> C(N), V(N);
    for(auto& i : V)cin >> i;
    for(auto& i : C)cin >> i;
    unsigned long ans{0};
    transform(V.begin(), V.end(), C.begin(), V.begin(), [&ans](auto a, auto b){return ans += max(a, b) - b;});
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#define INF 999999999
#define pause system("pause")
using namespace std;

typedef long long int ll;


int n;



int main() {
	
	string s;
	
	cin >> n >> s;
	
	for (int i = 0; i < s.length(); i++) {
		char c = s[i];
		c += n;
		c %= 91;
		if (c < 65) c += 65;
		cout << c;
	}
	//pause;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    ull n, a, b;
    cin >> n >> a >> b;

    if (a < b)
        swap(a, b);

    // a > b

    if ((a - b) % 2 == 0)
    {
        ull t = (a - b) / 2;
        cout << t << endl;
    }
    else
    {
        ll t = 0;
        if (b - 1 > n - a)
        {
            b += n - a;
            t += n - a;
            a = n;
            if (a % 2 != b % 2)
            {
                t++;
            }
        }
        else
        {
            a -= b - 1;
            t += b - 1;
            b = 1;
            if (a % 2 != b % 2)
            {
                t++;
            }
        }
        t += ((a - b) / 2);
        cout << t << endl;
    }
}


Measured memory_bytes: 256
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.Unboxed          as AU
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n =
  replicateM n (map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine)

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n =
  replicateM n (map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine)

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n (map BS.unpack . BS.words <$> BS.getLine)

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main :: IO ()
main = do
  [a, b, t] <- readInts
  print $ solve a b t
  return ()

solve a b t = b * (t `div` a)

-- solve n w vw = f 0 w
--   where
--     items = VU.fromList vw
--     f i cap
--       | i == n = 0
--       | snd (items VU.! i) > cap = f (i + 1) cap
--       | otherwise =
--         max
--           (memo A.! (i + 1, cap))
--           (memo A.! (i + 1, cap - snd (items VU.! i)) + fst (items VU.! i))
--     memo =
--       A.array
--         ((0, 0), (n, w))
--         [((n', w'), f n' w') | n' <- [0 .. n], w' <- [0 .. w]]


Measured memory_bytes: 380
#include<stdio.h>

int main()

{
    char a;
    scanf("%c",&a);

    switch(a)
    {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u': printf("vowel");
            break;

    default :

        printf("consonant");

    }

    return 0;
}


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

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc159_c();
        }

        static void abc159_c()
        {
            // ABC159 C - Maximum Volume
            int L = int.Parse(Console.ReadLine());
            double ans = Math.Pow(L, 3) / 27;
            Console.WriteLine(ans.ToString("f10"));
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n;
    ll d;
    cin >> n >> d;
    int ans = 0;
    rep(i,0,n){
        ll x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}


void solve()
{   
    int t;cin>>t;
    int a=0,b=0,c=0,d=0;
    while(t--)
    {
        string s;cin>>s;
        if(s=="AC")a++;
        else if(s=="WA")b++;
        else if(s=="TLE")c++;
        else if(s=="RE")d++;
    }
    cout << "AC x "<<a<<"\n";
    cout << "WA x "<<b<<"\n";
    cout << "TLE x "<<c<<"\n";
    cout << "RE x "<<d<<"\n";
}

signed main()
{ 
    boost
    int test=0,t;
    //cin >> t ;
    t=1;
    while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <vector>
#include <queue>
#define PB push_back
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1010,M=1003;
bitset<M> G[N],A[N],B;
int n,m;
int vis[N][2];
int inq[N];
queue<int> que;
void push(int u,int t) {
	if(!vis[u][0]) vis[u][0]=t;
	else if(!vis[u][1]&&vis[u][0]!=t) vis[u][1]=t,B[u]=0;
	else return;
	A[t][u]=0;
	if(!inq[u]) que.push(u),inq[u]=1;
}
int mp[N][N],p1[N][N],p2[N][N];
void sol(int s) {
	B[s]=0;
	for(int i=1;i<=n;++i) if(mp[s][i]) push(i,i);
	while(!que.empty()) {
		int u=que.front(); que.pop(),inq[u]=0;
		while(1) {
			int v=((A[vis[u][0]]|A[vis[u][1]])&G[u]&B)._Find_first();
			if(v==M) break;
			if(vis[u][0]) push(v,vis[u][0]);
          	if(vis[u][1]) push(v,vis[u][1]);
		}
	}
	for(int i=1;i<=n;++i) if(s!=i) {
		p1[s][i]=vis[i][0]||vis[i][1]||mp[s][i];
		p2[s][i]=(vis[i][0]&&vis[i][0]!=i)||(vis[i][1]&&vis[i][1]!=i);
	}
	for(int i=1;i<=n;++i) {
		if(vis[i][0]) A[vis[i][0]][i]=1,vis[i][0]=0;
		if(vis[i][1]) A[vis[i][1]][i]=1,vis[i][1]=0;
		B[i]=1;
	}
}
vector<PII> E;
int main() {
	rd(n),rd(m);
	for(int i=1,x,y;i<=m;++i) rd(x),rd(y),G[x][y]=mp[x][y]=1,E.PB(MP(x,y));
	for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) A[i][j]=1;
	for(int i=1;i<=n;++i) B[i]=1;
	for(int i=1;i<=n;++i) sol(i);
	for(int i=0;i<E.size();++i) { 
		int x=E[i].fir,y=E[i].sec,flg;
		if(p1[y][x]) flg=(p2[x][y]==1);
		else flg=(p2[x][y]==0);
		if(flg) printf("same\n");
		else printf("diff\n");
	}
	return 0;
}
	


Measured memory_bytes: 15088
ans = 0
nums = [str(i) for i in range(10)]
while True:
  try:
    s = input()
    acc = 0
    last_ind = -1
    for i, c in enumerate(s):
      if c in nums:
        if last_ind == i - 1:
          acc *= 10
          acc += int(c)
        else:
          acc = int(c)
        last_ind = i
      else:
        ans += acc
        acc = 0
    else:
      ans += acc
  except EOFError:
    break
print(ans)


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
const int maxn = 1000001;
long long int n, k, ans[maxn],v[maxn];
long long int dp(int);
int main(void)
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	memset(ans, -1, sizeof(ans));
	ans[1] = 0;
	cout << dp(n) << endl;
	/*for (int i = 1; i <= n; i++)
		cout << ans[i] << " ";*/
	return 0;
}
long long int dp(int cur)
{
	long long int& ret = ans[cur];
	if (ret != -1)
		return ret;
	ret = 0xffffffff;
	for (int i = 1; i <= k; i++)
		if (cur - i >= 1)
			ret = min(ret,dp(cur - i) + abs(v[cur] - v[cur - i]));
	return ret;
}

Measured memory_bytes: 13696
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	public static long N;
	public static long K;


	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		N = parseInt(st.nextToken());
		K = parseInt(st.nextToken());
		List<Long> tr = new ArrayList<>();

		for(int i=0;i<N;i++){
			st = new StringTokenizer(br.readLine());
			tr.add((long)parseInt(st.nextToken()));
		}
		Collections.sort(tr);
//		System.out.println(tr);
//		List<Long> newT = tr.stream()
//			.sorted((a, b) -> {
//				return (int)((b-a) / Math.abs(b-a));
//			})
//			.collect(Collectors.toList());

//		System.out.println(newT);
		long max = 100000000000L;
		for(long i=0,b=K-1,len=tr.size()-b;i<len;i++) {
			long m = tr.get((int)(i+b)) -tr.get((int)i);
			if(max > m) {
				max = m;
			}

		}

		System.out.println(max);

	}

}

Measured memory_bytes: 45440
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[100005];
int dp[100005];
int f(int x)
{ 
  if(x>=n)
    return 1e18;
  if(x==n-1)
    return 0;
  if(dp[x]!=-1)
    return dp[x];
  dp[x]=min(f(x+1)+abs(a[x]-a[x+1]),f(x+2)+abs(a[x]-a[x+2]));
  return dp[x];
}
int32_t main()
{  
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  memset(dp,-1,sizeof(dp));
  cout<<f(0);
}

Measured memory_bytes: 3328
//
// Created by tac on 2016/10/27.
//

#include <cstdlib>
#include <iostream>

namespace {

bool is_traiangle(int a, int b, int c) {
    return (a * a == b * b + c * c) ||
           (b * b == a * a + c * c) ||
           (c * c == a * a + b * b);
}

}


int main() {
    int n;
    int a, b, c;
    std::string ans;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> a >> b >> c;
        if (is_traiangle(a, b, c)) {
            ans = "YES";
        } else {
            ans = "NO";
        }
        std::cout << ans << std::endl;
    }
    return EXIT_SUCCESS;
}

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

int main(){
  int H, W, N, sr, sc;
  cin >> H >> W >> N >> sr >> sc;
  string S, T;
  cin >> S >> T;
  int tL=0, tR=0, tU=0, tD=0, aL=0, aR=0, aU=0, aD=0;
  for (int i=0; i<N; i++){
    if (S[i]=='L') tL++;
    else if (S[i]=='R') tR++;
    else if (S[i]=='U') tU++;
    else tD++;
    if (sc+aR-tL<1||tR+sc-aL>W||sr+aD-tU<1||tD+sr-aU>H){
      cout << "NO" << endl;
      return 0;
    }
    if (T[i]=='L') {
      if (tR+sc-aL>1) aL++;
    }
    else if (T[i]=='R') {
      if (sc-tL+aR<W) aR++;
    }
    else if (T[i]=='U') {
      if (tD+sr-aU>1) aU++;
    }
    else {
      if (sr-tU+aD<H) aD++;
    }
  }
  cout << "YES" << endl;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int main() {

	FAST;

	int x;
	cin >> x;
	cout << ((x >= 30) ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            int[] p = new int[N];
            for (int i = 0; i < N; i++) {
                p[i] = sc.nextInt();
            }

            int score;
            for (score = N; score >= 0; score--) {
                int cnt = 0;
                for (int j = 0; j < N; j++) {
                    if ( p[j] >= score ) {
                        cnt++;
                    }
                }
                if ( cnt >= score ) {
                    break;
                }
            }
            System.out.println(score);
        }
    }
}



Measured memory_bytes: 26224
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	stack<int> A;
	char s[15];
	int a, b;
	while (cin >> s)
	{
		if (s[0] == '+')
		{
			b = A.top();
			A.pop();
			a = A.top();
			A.pop();
			A.push(a + b);
		}
		else if (s[0] == '-')
		{
			b = A.top();
			A.pop();
			a = A.top();
			A.pop();
			A.push(a - b);
		}
		else if (s[0] == '*')
		{
			a = A.top();
			A.pop();
			b = A.top();
			A.pop();
			A.push(a * b);
		}
		else
		{
			A.push(atoi(s));
		}
	}

	cout << A.top() << endl;

	return 0;
}


Measured memory_bytes: 3108
n,m = map(int,input().split())
ka = [list(map(int,input().split())) for i in range(n)]
a = [ka[i][1:] for i in range(n)]
b = []

for i in a:
  for j in range(len(i)):
    b.append(i[j])
c = 0
for i in range(m):
  if b.count(i+1) == n:
    c += 1
print(c)

Measured memory_bytes: 3064