akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    string a,b;
    cin>>a>>b;
    REPARR(i,b){
        cout<<a[i]<<b[i];
    }
    if(sz(a)>sz(b))cout<<a[sz(b)];
    cout<<endl;
    return 0;
}


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

int main(){
	int N;
	int a[10000] = {};
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N);
	cout << a[N - 1] - a[0] << endl;
}

Measured memory_bytes: 256
n, w = map(int, input().split())
goods = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]

for i in range(n):
    weight, value = goods[i]
    for sum_w in range(w + 1):
        if (sum_w - weight) >= 0:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - weight] + value)

        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])

print(dp[n][w])

Measured memory_bytes: 120940
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();
		char[][] a = new char[H][W];
		String inputStr;
		// 初期状態の黒色のマス座標リスト
		ArrayList<Point033> firstBlackPoint = new ArrayList<Point033>();
		for(int i = 0; i < H; i++) {
			inputStr = scan.next();
			a[i] = inputStr.toCharArray();
		}
		scan.close();
		int[][] dist = new int[H][W];
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				dist[i][j] = -1;
				if(a[i][j] == '#') {
					firstBlackPoint.add(new Point033(j, i));
				}
			}
		}
		ArrayDeque<Point033> que = new ArrayDeque<Point033>();
		// スタート地点の登録（複数）
		for(Point033 p : firstBlackPoint) {
			que.add(p);
			dist[p.y][p.x] = 0;
		}
		int nextX, nextY;
		Point033 v;
		int[] dx = {1, -1, 0, 0};
		int[] dy = {0, 0, 1, -1};
		int result = 0;
		while(!que.isEmpty()) {
			v = que.poll();
			for(int i = 0; i < 4; i++) {
				nextX = v.x + dx[i];
				nextY = v.y + dy[i];
				// 領域外である場合、スルー
				if(nextX < 0 || nextY < 0 || nextX >= W || nextY >= H) {
					continue;
				}
				// 黒色である場合、スルー
				if(a[nextY][nextX] =='#') {
					continue;
				}
				// 探索済みである場合、スルー
				if(dist[nextY][nextX] != -1) {
					continue;
				}
				que.add(new Point033(nextX, nextY));
				dist[nextY][nextX] = dist[v.y][v.x] + 1;
				if(dist[nextY][nextX] > result) {
					result = dist[nextY][nextX];
				}
			}
		}
		System.out.println(result);
	}

}
class Point033{
	int x;
	int y;
	Point033(int x, int y) {
		this.x = x;
		this.y = y;
	}
}


Measured memory_bytes: 72956
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

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

using namespace std;

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

const int maxN = 200000;

ll A;
ll B;
int main() {
    cin>>A>>B;
    if ((A+B)%2==0){
       ll ans =(A+B)/2;
       cout<<ans;
    }else{
        cout<<"IMPOSSIBLE";
    }
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  vector<int>t(5),v(5);
  int ans=999999;
  rep(i,5) cin>>t[i];
  rep(i,5){
    if(t[i]%10==0) v[i]=t[i];
    else v[i]=t[i]-t[i]%10+10;
  }
  rep(i,5){
    int sum=0;
    rep(j,5){
      if(i==j) sum+=t[i];
      else sum+=v[j];
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int K;
	cin >> K;
	vector<long long> A( K );
	for( int i = 0; i < K; i++ ) {
		cin >> A[i];
	}

	auto f = [&]( long long n ) -> long long
	{
		long long res = n;
		for( int i = 0; i < K; i++ ) {
			res -= res % A[i];
			if( res < 0 ) return -1;
		}
		return res;
	};

	const long long INF = INT64_MAX / 2;
	long long l = 0;
	long long r = INF;
	while( r - l > 1 ) {
		long long m = (l + r) / 2;
		if( f( m ) <= 2 ) l = m;
		else r = m;
	}
	long long ma = l;
	l = 0;
	r = INF;
	while( r - l > 1 ) {
		long long m = (l + r) / 2;
		if( f( m ) >= 2 ) r = m;
		else l = m;
	}
	long long mi = r;

	if( mi > ma ) cout << -1 << endl;
	else cout << mi << " " << ma << endl;
}


Measured memory_bytes: 4036
#include <iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c)
		cout << "Yes" << "\n";
	else if (a == c && a != b)
		cout << "Yes" << "\n";
	else if (b == c && b != a)
		cout << "Yes" << "\n";
	else if (a == b && b == c)
		cout << "No" << "\n";
	else
		cout << "No" << "\n";
}

Measured memory_bytes: 3604
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.begin(),v.end());
  cout<<v[v.size()/2]-v[v.size()/2-1]<<endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=900010;
int a[maxn],b[maxn],n,m,j;
void read(int &k){
	k=0; int f=1; char c=getchar();
	while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while ('0'<=c&&c<='9')k=k*10+c-'0',c=getchar();
	k*=f;
}
int main(){
	read(n); 
	for (int i=1;i<=n;i++) read(a[i]);
	read(m);
	for (int i=1;i<=m;i++) read(b[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);
	j=0;
	for (int i=1;i<=m;i++){
		j++;
		while (a[j]!=b[i]&&j<=n) j++;
		if (j>n){
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = k;i < n;++i) {
        cout << (a[i-k] < a[i] ? "Yes" : "No") << newl;
    }
}

Measured memory_bytes: 4832
#include <iostream>

using namespace std;

int main() {
    char x, y;  cin >> x >> y;
    if (x - 'A' > y - 'A')
        cout << '>' << endl;
    else if (x - 'A' < y - 'A')
        cout << '<' << endl;
    else
        cout << '=' << endl;
    return 0;    
}

Measured memory_bytes: 760
import heapq
n,m = map(int, input().split())
job_list = []
for i in range(n):
    a,b = map(int, input().split())
    job_list.append((a,b))
job_list.sort(key=lambda x:x[0])
# print(job_list)

hq = []
max_income = 0
j = 0
for i in range(1,m+1):
    while j < n and job_list[j][0] <= i:
        heapq.heappush(hq, (-job_list[j][1],job_list[j][0]))
        j += 1
    if len(hq) < 1:
        continue
    b_i, a_i = heapq.heappop(hq)
    max_income += -b_i

print(max_income)

Measured memory_bytes: 87896
#include <stdio.h>

int main() {
  int length = 0;
  int height = 0;
  int area = 0;
  int cir = 0;

  scanf("%d %d",&length,&height);

  area = length * height;
  cir = length * 2 + height * 2;

  printf("%d %d\n", area, cir);

  return 0;
}

Measured memory_bytes: 596
N, Q = gets.split.map(&:to_i)

tree = Array.new(N+1).map{Array.new}

(N-1).times do
    a, b = gets.split.map(&:to_i)
    tree[a].push(b)
end

val = Array.new(N+1, 0)
Q.times do
    pp, x = gets.split.map(&:to_i)
    val[pp] += x
end

ans = Array.new(N+1, 0)
list = [1]
while !list.empty?
    cur = list.pop
    ans[cur] += val[cur]

    tree[cur].each do |x|
        list.push(x)
        ans[x] += ans[cur]
    end
end

ans.shift
puts ans.join(" ")


Measured memory_bytes: 26724
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
odd = a.count{|num|num%2 == 1}
mult4 = a.count{|num|num%4 == 0}
if (odd <= mult4 && n >= 4) || ((mult4 >= 1 || odd == 0) && n <= 3) || mult4 == n/2
  puts "Yes"
else
  puts "No"
end

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

int main(){
  int m;
  while(cin >> m, m){
    vector<int> X(m), Y(m);
    for(int i = 0; i < m; ++i) cin >> X[i] >> Y[i], X[i] += 2000, Y[i] += 2000;
    int t = 0;
    for(int i = 0; i < m; ++i){
      int i_ = (i+1)%m;
      t += X[i]*Y[i_] - X[i_]*Y[i];
    }
    if(t < 0) reverse(X.begin(), X.end()), reverse(Y.begin(), Y.end());
    vector< vector<int> > C(4001,vector<int>(4001,0));

    for(int j = 0; j < m; ++j){
      if(X[j] == X[(j+1)%m]) continue;
      for(int i = min(X[j],X[(j+1)%m])+1; i <= max(X[j],X[(j+1)%m]); ++i){
        if(X[(j+1)%m] < i and i <= X[j]){
          int dx = X[j] - X[(j+1)%m], dy = Y[j] - Y[(j+1)%m], y_;
          if(dy >= 0){
            y_ = Y[(j+1)%m] + max((dy*(i-X[(j+1)%m])+dx-1)/dx,(dy*(i-1-X[(j+1)%m])+dx-1)/dx) + 1;
            //cerr << 3 << endl;
          }else{
            y_ = Y[(j+1)%m] + max((dy*(i-X[(j+1)%m]))/dx,(dy*(i-1-X[(j+1)%m]))/dx) + 1;
            //cerr << 4 << endl;
          }
          //cerr << i-2000 << " " << y_-2000 << " - " << endl;
          --C[i][y_];
        }else if(X[j] < i and i <= X[(j+1)%m]){
          int dx = X[(j+1)%m] - X[j], dy = Y[(j+1)%m] - Y[j], y_;
          if(dy >= 0){
            y_ = Y[j] + min((dy*(i-X[j])+dx)/dx,(dy*(i-1-X[j])+dx)/dx);
            //cerr << 1 << endl;
          }else{
            y_ = Y[j] + min((dy*(i-X[j])-dx+1)/dx,(dy*(i-1-X[j])-dx+1)/dx) + 1;
            //cerr << 2 << endl;
          }
          //cerr << i-2000 << " " << y_-2000 << " + " << endl;
          ++C[i][y_];
        }
      }
    }
    int ans = 0;
    for(int i = 0; i < 4001; ++i){
      ans += (C[i][0] != 0);
      for(int j = 1; j < 4001; ++j){
        C[i][j] += C[i][j-1];
        ans += (C[i][j] != 0);
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 65332
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
inline LL in()
{
    LL x = 0, flag = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * flag;
}
int n;
int main()
{
    n = in();
    int ans = 0;
    for (int i = 1; i <= n; i ++)
    {
        if (i % 2 == 0) continue;
        int cnt = 0;
        for (int j = 1; j <= i; j ++)
            if (i % j == 0) cnt ++;
        if (cnt == 8) 
        {
            ans ++;
//            cout << i << endl;
        }
    }
    cout << ans;
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  int a=(s[0]-'0')*10+(s[1]-'0');
  int b=(s[2]-'0')*10+(s[3]-'0');
  if((a>12 || a==0) && (b>0 && b<=12)) cout<<"YYMM"<<endl;
  else if((a>0 && a<=12) && (b>12 || b==0)) cout<<"MMYY"<<endl;
  else if((a>0 && a<=12) && (b>0 && b<=12)) cout<<"AMBIGUOUS"<<endl;
  else cout<<"NA"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

template <typename T> ostream& operator<<(ostream& out, vector<T> &v){
  for (int i = 0; i < (int)v.size(); i++) {
    out<<v[i]<<' ';
  }
  return out;
}

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

  float n; cin >> n;
  
  cout << n * 2 * 3.141592653589 << endl;

  // int n, m; cin >> n >> m;
  // vector<int> a(m);
  // int sum = 0;
  // rep(i, m){
  //   cin >> a[i];
  //   sum += a[i];
  // }
  // if(sum == n) cout << 0 << endl;
  // else if (sum < n) cout << n - sum << endl;
  // else cout << -1 << endl;








  return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

vector<bool> visited(51, false);
vector<vector<bool>> g(51, vector<bool>(51, false));
vector<int> a(51), b(51);
int n, m;

void dfs(int v) {
    visited[v] = true;
    rep(to, n) {
        if (g[v][to] == false) continue;
        if (visited[to] == true) continue;
        dfs(to);
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
    }
    int ans = 0;
    rep(i, m) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = false;
        rep(j, n) visited[j] = false;
        dfs(0);
        bool bridge = false;
        rep(j, n) if (!visited[j]) bridge = true;
        if (bridge) ans++;
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> d(n);
  rep(i,n){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  int h=d.size()/2;
  cout<<d[h]-d[h-1]<<endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


struct LCAT {
	int N;
	int it;
	int Root;
	vector<vector<PII>>table;
	vector<int>id;
	vector<vector<pair<int, LL>>>G;
	vector<LL>distarray;
	LCAT(int N) :N(N), it(0), Root(0), table(18, vector<PII>(2 * N)), id(N), G(N), distarray(N) {}
	void add_edge(int a, int b, LL c = 1) {
		G[a].emplace_back(b, c);
		G[b].emplace_back(a, c);
	}
	void build(int root) {
		Root = root;
		dfs(root, -1, 0, 0);
		int m = (N << 1) - 1;
		int h = 31 - __builtin_clz(m);
		for (int i = 0; i < h; i++) {
			for (int j = 0; j + (1 << i) < m; j++) {
				table[i + 1][j] = min(table[i][j], table[i][j + (1 << i)]);
			}
		}
	}
	void dfs(int v, int p, int d, LL distd) {
		id[v] = it;
		distarray[v] = distd;
		table[0][it++] = { d, v };
		for (auto to : G[v]) {
			if (to.first == p)continue;
			dfs(to.first, v, d + 1, distd + to.second);
			table[0][it++] = { d, v };
		}
	}
	int lca(int u, int v) {
		u = id[u], v = id[v];
		if (u > v) swap(u, v);
		int b = 31 - __builtin_clz(v + 1 - u);
		return min(table[b][u], table[b][v + 1 - (1 << b)]).second;
	}
	LL dist(int u, int v) {
		return distarray[u] + distarray[v] - 2 * distarray[lca(u, v)];
	}
};
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL N; cin >> N;
	LCAT tree(N);
	FOR(i, 0, N - 1) {
		LL a, b, c; cin >> a >> b >> c;
		a--, b--;
		tree.add_edge(a, b, c);
	}
	LL Q, K; cin >> Q >> K;
	K--;
	tree.build(K);
	FOR(_, 0, Q) {
		LL a, b; cin >> a >> b;
		a--, b--;
		cout << tree.distarray[a] + tree.distarray[b] << endl;
	}

	return 0;
}


Measured memory_bytes: 41828
#include <iostream>
#include <unordered_set>

using namespace std;

int main(){
  int N, tmp;
  bool f = true;
  cin >> N;
  unordered_set<int> buf;
  for (int i=0; i<N; i++){
    cin >> tmp;
    if (buf.find(tmp) != buf.end()){
      f = false;
    }
    buf.insert(tmp);
  }
  cout << (f ? "YES" : "NO") << endl;
  return 0;
}
  

Measured memory_bytes: 8520
#include<bits/stdc++.h>
     
    #define INF 1000000007
    #define LINF 1000000000000000007
     
    using namespace std;
     
    typedef long long Int;
    typedef pair<Int, Int> P;
     
    Int gcd(Int x, Int y){
    	if(y == 0)
    		return x;
    	return gcd(y, x % y);
    }
     
    Int lcm(Int x, Int y){
    	return x * y / gcd(x, y);
    }
     
    bool sosuu(int x){
    	bool b = 1;
    	if(x == 1) b = 0;
    	for(int i = 2; i * i <= x; i++){
    		if(x % i == 0) {
    			b = 0;
    			break;
    		}
    	}
    	return b;
    }
     
    int n, a[100000];
     
    int main(){
    	cin >> n;
    	for(int i = 0; i < n; i++){
    		cin >> a[i];
    	}
    	
    	sort(a, a+n);
    	int c = a[0];
    	for(int i = 1; i < n-1; i++){
    		if(abs(a[n-1]/2 - a[i]) < abs(a[n-1]/2 - c) || abs(a[n-1]/2+a[n-1]%2 - a[i]) < abs(a[n-1]/2+a[n-1]%2 - c))
    			c = a[i];
    	}
    	
    	cout << a[n-1] << " " << c << endl;
    	
    	return 0;
    }

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int n,l;cin >> n >> l;
      vector<string> v;
      for(int i = 0;i < n;i++){
            string t;cin >> t;
            v.push_back(t);
      }
      sort(v.begin(), v.end());
      for(string t : v){
            cout << t;
      }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
typedef long long ll;
int N,D,point[15][15],sum,temp,Count=0;
double sq;
int main(){
	scanf("%d %d",&N,&D);
	for(int i=1;i<=N;++i){
		for(int j=1;j<=D;++j)
			scanf("%d",&point[i][j]);
	}
	for(int i=1;i<=N;++i){
		for(int j=i+1;j<=N;++j){
			sum=0;
			for(int k=1;k<=D;++k){
				temp=point[i][k]-point[j][k];
				sum+=temp*temp;
			}
			sq=sqrt(sum);
			temp=sq;
			if(sq-temp<1e-10) ++Count;
		}
	}
	printf("%d",Count);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
 
namespace ALDS1_14_D
{
	class SuffixArray
	{
		internal int[] sa, rank, tmp;
		internal string S;
		internal int n, k;
		
		public SuffixArray(string SS)
		{
			S = SS;
			n = S.Length;
			sa = new int[n + 1];
			rank = new int[n + 1];
			tmp = new int[n + 1];
			Construct_SA();
		}
		
		public int Compare_SA(int i, int j)
		{
			if(rank[i] != rank[j]) return rank[i] - rank[j];
			
			int ri = i + k  <= n ? rank[i + k] : -1;
			int rj = j + k <= n ? rank[j + k] : -1;

			return  ri - rj; 
		}
		
		public void Construct_SA()
		{
			for(int i = 0; i < n; i++)
			{
				sa[i] = i;
				rank[i] = S[i];
			}
			sa[n] = n; rank[n] = -1;
			
			for(k = 1; k <= n; k*= 2)
			{
				Array.Sort(sa, Compare_SA);
                
                tmp[sa[0]] = 0;
                for (int i = 1; i <= n; i++)
                {
                    tmp[sa[i]] = tmp[sa[i - 1]] + ((Compare_SA(sa[i - 1], sa[i]) < 0) ? 1 : 0);
                }
                for (int i = 0; i <= n; i++)
                {
                    rank[i] = tmp[i];
                }
 
			}
		}
		
		public string Contains(string pattern)
		{
			int l = 1, r = n + 1;
			int pl = pattern.Length;
			
			while(l < r)
			{
				int m = (l + r) / 2;
				
				string subStr = (sa[m] + pl > n) ? S.Substring(sa[m]) : S.Substring(sa[m], pl);
                    
                int comp = subStr.CompareTo(pattern);
                if (comp == 0) return "1";
                
                if (comp < 0) l = m + 1;
                else r = m;
			}
			return "0";
		}
	}
	
	
    class Program
    {
        static void Main(string[] args)
        {
        	var T = Console.ReadLine();
        	
            SuffixArray SA = new SuffixArray(T);
            StringBuilder sb = new StringBuilder();
 
            var Q = int.Parse(Console.ReadLine());
 
            for (int i = 0; i < Q; i++)
            {
                var P = Console.ReadLine();
 
                sb.AppendLine(SA.Contains(P));
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 33104
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, a, b;std::cin >> n >> a >> b;
  std::cout << min(b, n*a) << '\n';
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  vector<int> N(4);
  REP(i,4) cin >> N[i];
  sort(ALL(N));

  vector<int> ans{1, 4, 7, 9};
  string ret = "YES";
  REP(i,4) if(N[i] != ans[i]) ret = "NO";
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 768
# encoding: utf-8
import math
N = int(input())

for A in list(range(1, int(math.sqrt(N)) + 1))[::-1]:
    if A > math.sqrt(N): continue
    elif N % A == 0: break
    
B = N // A
# print("#", A, B)
for ans in range(1, 11):
    if B // 10 == 0: break
    B = B // 10

print(ans)
    

Measured memory_bytes: 7668
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main(){
    int N; cin >> N;
    string st; cin >> st;

    vector<int> leftR(N);
    vector<int> leftG(N);
    vector<int> leftB(N);

    if(st[0] == 'R'){
        leftR[0]++;
    }else if(st[0] == 'G'){
        leftG[0]++;
    }else{
        leftB[0]++;
    }

    for(int i=1; i<N; ++i){
        leftR[i] = leftR[i-1];
        leftG[i] = leftG[i-1];
        leftB[i] = leftB[i-1];

        if(st[i] == 'R'){
            leftR[i]++;
        }else if( st[i] == 'G' ){
            leftG[i]++;
        }else{
            leftB[i]++;
        } 
    }

    long long cnt = 0;
    for(int j=1; j<=(int)st.size()-1; ++j){
        char mid_char = st[j];

        for(int i=0; i<j; ++i){
            char first_char = st[i];
            int dif = j - i;

            if(first_char == 'R' && mid_char == 'G'){
                int tmp = leftB[N-1] - leftB[j];
                if( tmp > 0 && j+dif < N &&  st[j+dif] == 'B') tmp--;
                cnt += tmp;
            }else if(first_char == 'R' && mid_char == 'B'){
                int tmp = leftG[N-1] - leftG[j];
                if( tmp > 0 && j+dif < N && st[j+dif] == 'G') tmp--;
                cnt += tmp;                
            }else if(first_char == 'B' && mid_char == 'R'){
                int tmp = leftG[N-1] - leftG[j];
                if( tmp > 0 && j+dif < N && st[j+dif] == 'G') tmp--;
                cnt += tmp;                
            }else if(first_char == 'B'&& mid_char == 'G' ){
                int tmp = leftR[N-1] - leftR[j];
                if( tmp > 0 && j+dif < N && st[j+dif] == 'R') tmp--;
                cnt += tmp;
            }else if(first_char == 'G' && mid_char == 'R'){
                int tmp = leftB[N-1] - leftB[j];
                if( tmp > 0 && j+dif < N && st[j+dif] == 'B') tmp--;
                cnt += tmp;
            }else if(first_char == 'G' && mid_char == 'B'){
                int tmp = leftR[N-1] - leftR[j];
                if( tmp > 0 && j+dif < N && st[j+dif] == 'R') tmp--;
                cnt += tmp;
            }

            // if( first_char != mid_char ){
            //     for(int k=j+1; k<(int)st.size(); ++k){
            //         char last_char = st[k];
            //         if( mid_char != last_char && first_char != last_char && j-i != k-j){
            //             cnt++;
            //             //cout << i << j << k << endl;
            //         }
            //     }
            // }
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3660
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

#include <bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

// ------------------------------------------------------------------------------------------------

ll n, a, b;

void func() {
    cin >> n >> a >> b;
    cout << min(n * a, b);
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{

	int n,a[10],b[10],c[10],cnt=0,A,B;
	bool flag1=true,flag2=true;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		c[i]=i+1;
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
    do{
        cnt++;
        flag1=true;
        flag2=true;
        for(int i=0; i<n; i++)
        {
            if(a[i]!=c[i])flag1=false;
            if(b[i]!=c[i])flag2=false;
        }
        if(flag1)A=cnt;
        if(flag2)B=cnt;
    }while(next_permutation(c,c+n));
    cout<<abs(A-B)<<endl;
	return 0;
}

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

int K,N;
vector<int> ans;
int main(){
	cin >> K >> N;
	if(K==1){
		for(int i=0;i<(N+1)/2;i++){
			cout << 1 << (i!=(N+1)/2-1? " ":"\n");
		}
		return 0;
	}
	if(K%2==0){
		for(int i=0;i<N;i++){
			if(i==0) cout << K/2 << " ";
			else cout << K << (i!=N-1? " ":"\n");
		}
		return 0;
	}else{
		for(int i=0;i<N;i++){
			ans.push_back((K+1)/2);
		}
		int cnt = N/2,n = ans.size();
		while(cnt>0){
			if(ans[n-1]==1) ans.pop_back();
			else{
				ans[n-1]--;
				while(ans.size()<N) ans.push_back(K);
			}
			cnt--;
			n = ans.size();
		}
		for(int i=0;i<ans.size();i++){
			cout << ans[i] << (i!=(int) ans.size()-1? " ":"\n");
		}
	}
}

Measured memory_bytes: 3568
n = int(input())
a = [int(i) for i in input().split()]
counter = 0
for i in range(n):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
    if minj != i:
        a[i], a[minj] = a[minj], a[i]
        counter += 1
print(*a)
print(counter)



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

int main() {
  cout << fixed << setprecision(10);
  float r;
  cin >> r;
  float ans = 2 * M_PI * r;
  cout << ans << endl;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int h,w;cin>>h>>w;
  int cnt_w[h][w];
  int cnt_h[h][w];
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      cnt_w[i][j] = -10;
      cnt_h[i][j] = -10;
    }
  }
  std::vector<string> v(h);
  for(int i=0;i<h;++i){
    cin >> v[i];
  }
  for(int i=0;i<h;++i){
    vector<tuple<int,int,int>> vt;
    int cnt =0;
    int start =0;
    int end =0;
    bool found =false;
    for(int j=0;j<w;++j){
      auto sub = v[i].substr(j,1);
      if(sub == "."){
        ++cnt;
        if(found){
          end =j;
        } else {
          start = j;
          end = j;
          found = true;
        }
      } else {
        if(found){
          vt.push_back(make_tuple(start,end,cnt));
          cnt =0;
          found = false;
        }
      }
    }
    if(found)vt.push_back(make_tuple(start,end,cnt));
    for(int k=0;k<vt.size();++k){
      for(int l=get<0>(vt[k]);l<=get<1>(vt[k]);++l) cnt_w[i][l]=get<2>(vt[k]);
    }
  }

  for(int i=0;i<w;++i){
    vector<tuple<int,int,int>> vt;
    int cnt =0;
    int start =0;
    int end =0;
    bool found =false;
    for(int j=0;j<h;++j){
      auto sub = v[j].substr(i,1);
      if(sub == "."){
        ++cnt;
        if(found){
          end =j;
        } else {
          start = j;
          end = j;
          found = true;
        }
      } else {
        if(found){
          vt.push_back(make_tuple(start,end,cnt));
          cnt =0;
          found = false;
        }
      }
    }
    if(found)vt.push_back(make_tuple(start,end,cnt));
    for(int k=0;k<vt.size();++k){
      for(int l=get<0>(vt[k]);l<=get<1>(vt[k]);++l) cnt_h[l][i]=get<2>(vt[k]);
    }
  }
  int max_v = 0;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      max_v = max(max_v, cnt_h[i][j]+cnt_w[i][j]-1);
    }
  }
  cout << max_v << endl;
  return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

int main() {
  std::cout << std::setprecision(9);
  int x, n;
  cin >> x >> n;

  vector<int> p(n);
  for (int i=0; i<n; i++) {
    cin >> p.at(i);
  }

  int abs = 0;
  int ans = x;
  while (true) {
    bool exist = false;
    for (int i=0; i<n; i++) {
      if (p.at(i) == x - abs) {
        exist = true;
        break;
      }
    }
    if (!exist) {
      ans = x - abs;
      break;
    }

    exist = false;
    for (int i=0; i<n; i++) {
      if (p.at(i) == x + abs) {
        exist = true;
        break;
      }
    }
    if (!exist) {
      ans = x + abs;
      break;
    }
    abs++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int> (26));
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < S.size(); j++) {
            A.at(i).at(S.at(j) - 'a')++;;
        }
    }
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < 26; j++) {
            A.at(i + 1).at(j) = min(A.at(i + 1).at(j), A.at(i).at(j));
        }
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < A.at(N - 1).at(i); j++) {
            char B = 'a' + i;
            cout << B;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;
typedef pair < ll, ll > pl;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)3e5 + 5;
const int mod = (int)1e9 + 7;

int n, m;
char a[505][505], ans[2][505][505];

void read() {
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
            ans[0][i][j] = ans[1][i][j] = a[i][j];
        }
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
    read();
    for (int i = 0; i < n; i++) {
        for (int j = 1; j + 1 < m; j++)
            ans[i % 2][i][j] = '#';
    }
    for (int i = 0; i < n; i++)
        ans[0][i][0] = '#', ans[1][i][m - 1] = '#';
    
    for (int it = 0; it < 2; it++) {
        for (int i = 0; i < n; i++, cout << '\n')
            for (int j = 0; j < m; j++)
                cout << ans[it][i][j];
        if (!it)
            cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 1536
k, n = map(int, input().split())

a_list = list(map(int, input().split()))

diff_list = []
for i in range(n-1):
    diff_list.append(a_list[i+1] - a_list[i])

diff_list.append(k - a_list[n-1] + a_list[0])

diff_list.pop(diff_list.index(max(diff_list)))
print(sum(diff_list))



Measured memory_bytes: 26436
def f(a,b,c):
    n=(a+b+c)**2 -a*b -b*c -c*a
    return n

N=int(input())

anslist=[0]*1000005

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            n= f(x,y,z)
            anslist[n-1]+=1

for i in range(N):
    print(anslist[i])

Measured memory_bytes: 16788
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

void lcs( char *X, char *Y, int m, int n ) 
{ 
int L[m+1][n+1]; 
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 
 
int index = L[m][n]; 
char lcs[index+1]; 
lcs[index] = '\0';

int i = m, j = n; 
while (i > 0 && j > 0) 
{  
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1];
		i--; j--; index--;
	} 
 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

cout << lcs; 
} 
int main() 
{ 
  char X[3001]; 
  char Y[3001]; 
  cin >> X;
  cin >> Y;
  int m = strlen(X); 
  int n = strlen(Y);
  lcs(X, Y, m, n); 
  return 0; 
} 


Measured memory_bytes: 35456
#Where's Snuke?
H, W = map(int, input().split())
ab = [chr(ord('A') + i) for i in range(26)]
for i in range(H):
    S = input().split()
    for j in range(W):
        if S[j] == "snuke":
            print(ab[j]+str(i+1)) 
            break

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		String S = in.nextLine();
		//int N = in.nextInt();
		int num = 0;
		for(int i=0; i<4; i++) {
			if(S.substring(i, i+1).equals("+")) {
				num++;
			}else {
				num--;
			}
		}
		System.out.print(num);
		in.close();
		
	}
}

Measured memory_bytes: 25044
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split(' ');
            double W = double.Parse(input[0]);
            double H = double.Parse(input[1]);
            double x = double.Parse(input[2]);
            double y = double.Parse(input[3]);

            double answer = W * H / 2;
            int possible = 0;

            //辺上にあれば1/2で確定
            if (W / 2 == x && H / 2 == y)
                possible = 1;
            else
                possible = 0;

            Console.WriteLine(answer.ToString() + ' ' + possible.ToString());
        }
    }

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

const int64_t INF = 1e+15;

int main() {
    int64_t N,M; // N 宝箱の個数　M 鍵の個数
    cin >> N >> M;
    
    vector<int64_t> a(M),b(M);
    vector<vector<int64_t>> c;
    c.assign(M,vector<int64_t>());
    for ( int64_t i = 0; i < M; ++i){
        cin >> a[i] >> b[i];
        for ( int64_t j = 0; j < b[i]; ++j){
            int64_t C;
            cin >> C;
            --C;
            c[i].push_back(C);
        }
    }
    
    vector<int64_t> f(M); // それぞれの鍵で開く宝箱
    for ( int64_t i = 0; i < M; ++i){
        int64_t F = 0;
        for ( int64_t j = 0; j < b[i]; ++j){
            int64_t C = c[i][j];
            F = F | (1<<C);
        }
        f[i] = F;
    }
    
    // すべての宝箱が開けられるかcheck
    int64_t open = 0;
    bool flg = true;
    for ( int64_t i = 0; i < M; ++i){
        open = open | f[i];
    }
    if ( open != (1<<N)-1 ){
        flg = false;
    }
    
    vector<int64_t> dp(1<<N);
    dp[0] = 0;
    for ( int i = 1; i < (1<<N); ++i){
        dp[i] = INF;
    }
    
    for ( int64_t i = 0; i < M; ++i){
        for ( int64_t k = 0; k < (1<<N); ++k){
            int64_t idx = k | f[i];
            dp[idx] = min(dp[idx],dp[k] + a[i]);
        }
    }
    
    
    
    
    
    
    
    if ( flg ) {
        cout << dp[(1<<N)-1] << endl;
    } else {
        cout << -1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

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


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

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

   vector<pair<int,pair<int,int>>> p(N);
   for (int i = 0; i < N; ++i) {
      LL s, t, x; cin >> s >> t >> x;
      p[i] = make_pair(x, make_pair(s-x, t-x));
   }
   sort(p.begin(), p.end());

   vector<int> D(Q);
   for (int i = 0; i < Q; ++i) {
      cin >> D[i];
   }

   set<int> st(D.begin(), D.end());
   st.insert(-IINF);
   st.insert(IINF);

   map<int,int> ans;
   for (int i = 0; i < N; ++i) {
      int x = p[i].first, s = p[i].second.first, t = p[i].second.second;
      auto l = st.lower_bound(s), r = st.upper_bound(t-1);
      while (l != r) {
         ans[*l] = x;
         l = st.erase(l);
      }
   }

   for (int i = 0; i < Q; ++i) {
      cout << (ans[D[i]] == 0 ? -1 : ans[D[i]]) << endl;
   }


   return 0;
}


Measured memory_bytes: 22656
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=0;
	int r=0;
	for (int i=0;i<s.size();i++){
		if (i%2==0){
			if (s[i]=='0'){
				l++;
			}else{
				r++;
			}
		}else{
			if (s[i]=='0'){
				r++;
			}else{
				l++;
			}
		}
	}
	l=(l<r)?l:r;
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 512
a = []
b = []
ans = 0
def flip(f):
    for i in range(len(a)):
        for j in range(3):
            if f & (1 << j) != 0:
                a[i][j] = - a[i][j]
n,m = map(int,input().split())
for i in range(n):
    a.append(list(map(int,input().split())))
for f in range(8):
    del(b[:])
    flip(f)
    for x in a:
        b.append(sum(x))
    b.sort(reverse = True)
    ans = max([ans,sum(b[:m])])
    flip(f)
print(ans)


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

int main() {
    string s, ans = "";
    cin >> s;
    rep(i,s.size()) ans += 'x';
    cout << ans << endl;
    return 0;
}

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

int main() {
    int x, a;
    cin >> x >> a;

    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e7+10;
const int M=1e7;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    int n;read(n);
    ll ans=0;
    for(re int i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0) continue;
        ans+=i;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3764
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        if (str.Length >= 10)
        {
            WriteLine("NO");
            return;
        }
        for(var i = 0; i < (1 << (str.Length+1)); i++)
        {
            var s = str;
            var ct = 0;
            for(var j = 0; j < str.Length+1; j++)
            {
                if ((1 & i >> j) == 1)
                {
                    if (j == 0)
                        s = "A" + s;
                    else if (j == str.Length)
                        s = s + "A";
                    else
                        s = s.Substring(0, j + ct) + "A" + s.Substring(j + ct);
                    ct++;
                }
            }
            if (s == "AKIHABARA")
            {
                WriteLine("YES");
                return;
            }
        }
        WriteLine("NO");
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){
	int n, i, j, k;
	int b, f, r, v;
	int house[4][3][10] = {};

	cin >> n;

	for (i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		house[b - 1][f - 1][r - 1] = house[b - 1][f - 1][r - 1] + v;
	}

	for (i = 0; i < 4; i++){
		for (j = 0; j < 3; j++){
			for (k = 0; k < 10; k++){
				if (house[i][j][k] < 0){
					cout << 0;
				}
				if (house[i][j][k]>9){
					cout << 9;
				}
				else{
					cout << " " << house[i][j][k];
				}
			}
			cout << endl;
		}
		if (i == 3){
			break;
		}
		cout << "####################" << endl;
	}

	return 0;
}

Measured memory_bytes: 3124
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    maxI = 0
    maxV = sum(P[:K])
    curV = maxV
    for i in range(1, N-K+1):
        curV = curV + P[i+K-1] - P[i-1]
        if curV > maxV:
            maxV = curV
            maxI = i

    res = (sum(P[maxI:maxI+K]) + K) / 2.0
    print(res)

main()

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

int N;

int main()
{
    while (cin >> N)
    {
        if (N == 0)
            return 0;
        vector<int> A(N);
        int ans = (1 << 30);
        for (int i = 0; i < N; i++)
        {
            cin >> A[i];
        }
        sort(A.begin(), A.end());
        for (int i = 0; i + 1 < N; i++)
        {
            ans = min(ans, A[i + 1] - A[i]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3120
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()
A = LIST()

flag = 0
for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            print('DENIED')
            flag += 1
            break

if flag == 0:
    print('APPROVED')


Measured memory_bytes: 5388