akhauriyash/Code-Regression huggingface dataset:
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

//ei1333さんのGitHubから https://ei1333.github.io/luzhiled/

//グラフ用テンプレ
//edge := 重み付き辺
//Edges := 重み付き辺集合
//WeightedGraph := 重み付きグラフ
//UnWeightedGraph := 重みなしグラフ
//Matrix := 距離行列
template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int to, T cost) : src(-1), to(to), cost(cost) {}
	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
	
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
//テンプレここまで

//Dijkstra : E log(V)
template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
	const auto MINF = numeric_limits< T >::max();
	vector< T > dist(g.size(), MINF);

	using Pi = pair< T, int >;
	priority_queue< Pi, vector< Pi >, greater< Pi > > que;
	dist[s] = 0;
	que.emplace(dist[s], s);
	while(!que.empty()) {
		T cost;
		int idx;
		tie(cost, idx) = que.top();
		que.pop();
		if(dist[idx] < cost) continue;
		for(auto &e : g[idx]) {
			auto next_cost = cost + e.cost;
			if(dist[e.to] <= next_cost) continue;
			dist[e.to] = next_cost;
			que.emplace(dist[e.to], e.to);
		}
	}
	return dist;
}
//

int main() {
		ll tmp;
	int n, m, s, t; cin >> n >> m >> s >> t;
	int u, v;
	ll a, b;
	WeightedGraph<ll> yg(n+1), sg(n+1);
	REP(i, m){
		cin >> u >> v >> a >> b;
		yg[u].emplace_back(v, a);
		yg[v].emplace_back(u, a);
		sg[u].emplace_back(v, b);
		sg[v].emplace_back(u, b);
	}
	vector<ll> yc = dijkstra(yg, s);
	vector<ll> sc = dijkstra(sg, t);
	
	vector<ll> ans(n+2);
	REP(i, n+2) ans[i] = 0;
	ll def = 1000000000000000;
	for(int i = n; i >= 1; i--){
		ans[i] = max(ans[i+1], def - yc[i] - sc[i]);
	}
	REP1(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 20988
#include<bits/stdc++.h>
using namespace std;
const int N = 1005;
int qs[12][N];
int dp[N];
char s[N];
int n,m,k;
int get(int i,int j,int k,int l)
{
    return qs[k][l]-qs[i-1][l]-qs[k][j-1]+qs[i-1][j-1];
}
int check(int bit,int st,int en)
{
    int last = 1;
    for(int j=1;j<=n;j++)
    {
        if((1<<(j-1))&bit)
        {
            if(get(last,st,j,en)>k) return 0;
            last = j+1;
        }
    }
//    if(bit==2&&st==1&&en==4)    printf("[[%d %d %d %d %d]]\n",get(st,last,n,en),st,last,n,en);
    if(get(last,st,n,en)>k)  return 0;
    return 1;
}
int main()
{
    scanf("%d %d %d",&n,&m,&k);
    int lim = 1<<(n-1),ans = 1e9;
    for(int i=1;i<=n;i++)
    {
        scanf(" %s",s+1);
        for(int j=1;j<=m;j++)
        {
            qs[i][j] = qs[i-1][j]+qs[i][j-1]-qs[i-1][j-1]+(s[j]=='1');
        }
    }
    for(int i=0;i<lim;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int l = 0,r = j-1;
            dp[j] = 1e9;
            while(l<r)
            {
                int mid = (l+r) >> 1;
                if(check(i,mid+1,j))    r=mid;
                else                    l=mid+1;
            }
            if(check(i,l+1,j))  dp[j] = min(dp[j],dp[l]+(l!=0));
//            if(i==2)    printf("[%d %d %d %d]\n",j,dp[j],l,check(2,1,4));
        }
        ans = min(ans,dp[m]+__builtin_popcount(i));
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int max_num = max(a, b);
    bool flga = false;
    bool flgb = false;
    bool flgc = false;
    max_num = max(max_num, c);
    if ( max_num == a ) {
        flga = true;
    }
    else if ( max_num == b ) {
        flgb = true;
    }
    else {
        flgc = true;
    }
    rep(i, k) max_num *= 2;
    if ( flga )      cout << max_num + b + c << endl;
    else if ( flgb ) cout << max_num + a + c << endl;
    else if ( flgc ) cout << max_num + a + b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define OP_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i = a; i < b; i++)
#define foi(i,a,b) for(int i = a; i>=b; i--)
#define fi first
#define si second
#define pb push_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const ll INF = 1e18L + 5;
const int MAXN = 1e5+10;

vi inp[MAXN];
int dp[MAXN];

int solve(int u){
  if(dp[u] != -1){
    return dp[u];
  }
  int ret = 0;
  fo(v, 0 , inp[u].size()){
    ret = max(ret, 1+solve(inp[u][v]));
  }
  return dp[u]=ret;
}

int main(){
  OP_IO;
  int N,M;
  cin>>N>>M;
  fo(i,0,M){
    int x,y;
    cin>>x>>y;
    --x;--y;
    inp[x].pb(y);
  }
  fo(i,0,MAXN){
    dp[i] = -1;
  }
  int ret = 0;
  fo(i,0,N){
    ret = max(ret, solve(i));
  }
  cout<<ret<<endl;
  
  return 0;
}


Measured memory_bytes: 8192
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.C
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			int[] a = cin.ArrayInt(n);
			int[] count = new int[a.Max() + 5];

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

			Console.WriteLine(count.Max());

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 17376
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 123;
int dp[3][MAXN], candy[3][MAXN];
int main() {
    int n; cin >> n;
    for (int i = 1; i <= 2; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> candy[i][j];
        }
    }
    for (int i = 1; i <= 2; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = dp[i-1][j] + candy[i][j];
            dp[i][j] = max(dp[i][j], candy[i][j]+dp[i][j-1]);
        }
    }
    cout << dp[2][n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<set>

const int maxn=1e5+5;

using namespace std;

int a,b;

int x,y,flag,ans;

int main()
{
    scanf("%d%d",&a,&b);
    for(int i=1;i<=maxn;i++)
    {
        x=floor(i*0.08);
        y=floor(i*0.1);
        if(x==a&&y==b)
        {
            flag=1;
            ans=i;
            break;
        }
    }
    if(flag)
        printf("%d\n",ans);
    else
        printf("-1\n");
}

Measured memory_bytes: 128
for _ in range(int(input())):
  a,b=map(int,input().split())
  if abs(a-b)<=1:print(min(a,b)*2-2)
  else:
    c=int((a*b)**0.5)
    if c**2==a*b:c-=1
    if c*(c+1)>=a*b:print(2*c-2)
    else:print(2*c-1)

Measured memory_bytes: 9248
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<stack>
#include<set>
#include<sstream>
#include<fstream>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

static int a[100001] = {};

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> Mod(M, 0);
	vector<unordered_map<int, int>> memo(M);

	for(int i = 0; i < N; ++i){
		int x;
		cin >> x;
		++a[x];
		++Mod[x%M];
		auto itr = memo[x%M].find(x);
		if(itr == end(memo[x%M])){
			memo[x%M].insert(make_pair(x, 1));
		} else{
			++itr->second;
		}
	}

	vector<vector<int>> nums(M);
	for(int i = 0; i < M; ++i){
		nums[i].reserve(memo[i].size());
		for(const auto& val : memo[i]){
			nums[i].push_back(val.second);
		}
		sort(begin(nums[i]), end(nums[i]), [](auto x, auto y){return x > y; });
	}

	long long ans = 0;
	int L = (M % 2 ? M / 2 + 1 : M / 2);
	for(int i = 1; i < L; ++i){
		if(Mod[i] < Mod[M - i]){
			ans += Mod[i];
			int rest = Mod[M - i] - Mod[i];
			for(const auto& val : nums[M - i]){
				if(rest >= val){
					ans += val / 2;
					rest -= ((int)(val / 2)) * 2;
				} else{
					ans += rest / 2;
					break;
				}
				if(val == 1 || rest == 1)break;
			}
		} else{
			ans += Mod[M - i];
			int rest = Mod[i] - Mod[M - i];
			for(const auto& val : nums[i]){
				if(rest >= val){
					ans += val / 2;
					rest -= ((int)(val / 2)) * 2;
				} else{
					ans += rest / 2;
					break;
				}
				if(val == 1 || rest == 1)break;
			}
		}
	}

	ans += Mod[0] / 2;
	if(M % 2 == 0)ans += Mod[M / 2] / 2;

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 18176
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = LIST()
a.sort()
b = sorted(list(set(a)))
idx = 0
cnt = [0 for _ in range(len(b))]
for i in range(n):
    if a[i] != b[idx]:
        idx += 1
    cnt[idx] += 1
ans = 0
for i in range(len(b)):
    tmp = cnt[i] - b[i]
    if tmp < 0:
        tmp = cnt[i]
    ans += tmp
print(ans)

Measured memory_bytes: 85100
#!/usr/bin/env python3
#AGC17 B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,a,b,c,d = LI()

f = defaultdict(list)
lst = []
s,t = 0,n-1
for _ in range(n):
    lst.append((a+s*c-t*d,a+s*d-t*c))
    s += 1
    t -= 1
for i,j in lst:
    if i <= b <= j:
        print('YES')
        quit()
print('NO')


Measured memory_bytes: 67796
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int N, M;
struct edge {
	int from, to;
	ll cost; 
};
vector<edge> es;
vector<ll> d;
int V, E;

bool find_negative_loop(int s) {
	d[s] = 0;
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < E; j++) {
			edge e = es[j];
			
			if (d[e.from] == inf) continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if (i == V - 1) return true;
			}
		}
	}
	return true;
}

vector<bool> negative;

void negative_check() {
	negative = vector<bool>(V, false);

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < E; j++) {
			edge e = es[j];

			if (d[e.from] == inf) continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				negative[e.to] = true;
			}
		}
	}
}

int main()
{
	cin >> N >> M;
	V = N;
	E = M;
	d = vector<ll>(V, inf);
	es = vector<edge>(E);
	for (int i = 0; i < M; i++) {
		edge e;
		cin >> e.from >> e.to >> e.cost;
		e.from--;
		e.to--;
		e.cost *= -1;
		es[i] = e;
	}
	find_negative_loop(0);
	ll ans = -d[N - 1];
	negative_check();
	if (negative[N - 1]) {
		cout << "inf" << endl;
	}
	else {
		cout << -d[N - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


void solv() {

	ll n;
	cin >> n;
	ll a[5];
	for (size_t i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	ll t[7];
	fill(t, t + 7, 0);
	t[1] = n;
	ll c = 0;
	while (t[6] == 0)
	{
		for (int i = 5; i > 0; i--)
		{
			ll p = i - 1;
			ll v = a[p];
			t[i + 1] += min(v, t[i]);
			t[i] = max(0LL, t[i] - v);
		}
		c++;
	}
	ll rest = (n - t[6]);
	c += (rest / t[6]) + (rest % t[6] == 0 ? 0 : 1);
	cout << c << endl;
}


int main() {
	//COMinit();
	solv();

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int curMin = 1e8;
  int ans = 0;
  rep(i,n){
    curMin = min(curMin, p[i]);
    if (curMin == p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner( System.in);
		int N,M;
		int a,b;
		List<Integer> alist=new ArrayList<Integer>() ;
		List<Integer> blist=new ArrayList<Integer>() ;
		N=stdin.nextInt();
		M=stdin.nextInt();
		for(int i=1;i<=M;i++){
			a=stdin.nextInt();
			b=stdin.nextInt();
			if(a==1)alist.add(b);
			if(b==N)blist.add(a);
		}
		Collections.sort(alist);
		Collections.sort(blist);
		Stack<Integer> astack=new Stack<Integer>();
		Stack<Integer> bstack=new Stack<Integer>();
		for(int i=0;i<alist.size();i++){
			astack.push(alist.get(i));
		}
		for(int i=0;i<blist.size();i++){
			bstack.push(blist.get(i));
		}
		
		if(astack.empty()||bstack.empty()){
			System.out.print("IMPOSSIBLE");
			System.exit(0);
		}
		a=astack.pop();
		b=bstack.pop();
		do{
			if(a<b){
				if(bstack.empty())break;
				b=bstack.pop();
			}
			if(a>b){
				if(astack.empty())break;
				a=astack.pop();
			}
			if(a==b){
				System.out.print("POSSIBLE");
				System.exit(0);
			}
		}while(true);
				
		System.out.print("IMPOSSIBLE");
	}
}




Measured memory_bytes: 95928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.TreeSet;
import java.util.StringTokenizer;

/**
 * Created by Aksenov239 on 24.09.2016.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public class Pair implements Comparable<Pair> {
        int x, id;
        public Pair(int x, int id) {
            this.x = x;
            this.id = id;
        }
        public int compareTo(Pair p) {
            return p.id == id ? x - p.x : id - p.id;
        }

        public String toString() {
            return x + " " + id;
        }
    }

    public void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();
        int q = nextInt();
        int[] a = new int[q];
        for (int i = 0; i < q; i++) {
            a[q - i - 1] = nextInt();
        }
        ArrayList<Integer> b = new ArrayList<Integer>();
        HashMap<Integer, Integer> pos = new HashMap<Integer, Integer>();
        for (int i = 0; i < q; i++) {
            if (!pos.containsKey(a[i])) {
                b.add(a[i]);
                pos.put(a[i], b.size() - 1);
            }
        }
        TreeSet<Pair> seq = new TreeSet<Pair>();
        for (int i = 0; i < m; i++) {
            seq.add(new Pair(i + 1, b.size()));
        }
        for (int i = b.size() - 1; i >= 0; i--) {
            seq.remove(new Pair(b.get(i), b.size()));
            seq.add(new Pair(b.get(i), i));
        }
        int[] s = new int[m];
        int it = 0;
        for (Pair x : seq) {
            s[it++] = x.x;
        }
        it--;
        while (it > 0 && s[it] >= s[it - 1]) {
            it--;
        }
        int[] order = new int[it];
        pos.clear();
        for (int i = 0; i < it; i++) {
            order[i] = b.get(i);
            pos.put(order[i], i);
        }
        int[] waiting = new int[it];
        for (int i = 0; i < q; i++) {
            if (!pos.containsKey(a[i]))
                continue;
            int c = pos.get(a[i]);
            if (c != 0 && waiting[c] == waiting[c - 1]) {
                continue;
            }
            waiting[c]++;
        }
        for (int i = 0; i < it; i++) {
            if (waiting[i] < n) {
                out.println("No");
                return;
            }
        }
        out.println("Yes");
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 48616
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[100002][11];
std::vector<int> edge[1000000];
void f(int v,int d,int c){
  if(dp[v][d]||d<0)return;
  dp[v][d]=c;
  for(int p:edge[v])f(p,d-1,c);
  f(v,d-1,c);
}
//main
signed main(){
  int N,M;cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b;cin>>a>>b;
    a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  memset(dp,0,sizeof(dp));
  int Q;cin>>Q;
  std::vector<int> v(Q),d(Q),c(Q);
  for(int i=0;i<Q;i++)cin>>v[i]>>d[i]>>c[i];
  for(int i=Q-1;i>=0;i--)f(v[i]-1,d[i],c[i]);
  for(int i=0;i<N;i++)cout<<dp[i][0]<<endl;
}


Measured memory_bytes: 38900
#include <iostream>
#include <map>
#include <set>
 
using namespace std;

string::iterator it;
map<char, set<int>> elements;

class Parse
{
  public:     
    set<int> term()
    {
        set<int> a;
        if(*it == '('){
            ++it;
            a = expr();
            ++it;
        }else if(*it == 'c'){
            ++it;
            a = term();
            a = complement(a);
        }else{
            a = elements[*it];
            ++it;
        }
        return a;
    }
     
    set<int> expr()
    {
        set<int> a = term(), b;
        while(*it == 'd' ||
              *it == 'i' ||
              *it == 's' ||
              *it == 'u')
        {
            char ch = *it; ++it;
            b = term();
            switch(ch)
            {
                case 'd':
                    a = difference(a, b);
                    break;
                case 'i':
                    a = intersection(a, b);
                    break;
                case 's':
                    a = sym_difference(a, b);
                    break;
                case 'u':
                    a = union_(a, b);
                    break;
            }
        }
        return a;
    }
 
    set<int> complement(const set<int> a)
    {
        return difference(elements['U'], a);
    }
     
    set<int> difference(const set<int> a, const set<int> b)
    {
        set<int> res;
        for(auto x : elements['U']){
            if(a.count(x) > 0 and b.count(x) == 0){
                res.insert(x);
            }
        }
        return res;
    }
 
    set<int> intersection(const set<int> a, const set<int> b)
    {
        set<int> res;
        for(auto x : elements['U']){
            if(a.count(x) > 0 and b.count(x) > 0){
                res.insert(x);
            }
        }            
        return res;
    }
 
    set<int> sym_difference(const set<int> a, const set<int> b)
    {
        return (union_(difference(a, b), difference(b, a)));
    }
 
    set<int> union_(const set<int> a, const set<int> b)
    {
        set<int> res;
        for(auto x : elements['U']){
            if(a.count(x) > 0 or b.count(x) > 0){
                res.insert(x);
            }
        }            
        return res;
    }
};
 
int main()
{
    char ch;
    int N, x;
    while(cin >> ch >> N)
    {
        elements.clear();
        set<int> U = {};
        do{
            if(ch == 'R') break;
            set<int> st;
            for(int i = 0 ; i < N ; i++){
                cin >> x;
                st.insert(x);
                U.insert(x);
            }                    
            elements[ch] = st;
        }while(cin >> ch >> N);
 
        elements['U'] = U;
         
        string str;
        cin >> str;
         
        Parse parse;
        it = str.begin();
        set<int> res = parse.expr();
         
        if(res.size() == 0){
            cout << "NULL" << endl;
        }else{
            bool sp = 0;
            for(auto r : res){
                if(sp) cout << " ";
                sp = 1;
                cout << r;
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
typedef long long ll;
 
using namespace std;

void pv(vector<int>& v) {
    cout << "{ ";
    for (auto el: v) {
        cout << el << ", ";
    }
    cout << " }" << endl;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int i = 1;
    int n;
    while (cin >> n) {
        if (n == 0) {
            cout << i << endl;
            return 0;
        }
        i++;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3652
def main():
    n = int(input())
    count = 0
    for i in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
            if count == 3:
                return "Yes"
        else:
            count = 0
    return "No"


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 62516
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#define N 100020
#define MOD 1000000007
using namespace std;

vector<int> a[N], b;

int main(void)
{
    int n, x;
    int i, j, o, s;

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
    {
        scanf("%d", &x);
        a[++ x].push_back(i);
    }
    for(i = 1; i <= n; i ++)
        sort(a[i].begin(), a[i].end());
    a[0] = vector<int>(3, -1);

    if(a[1].empty())
    {
        printf("0\n");

        return 0;
    }

    for(i = o = 1; i <= n; i ++)
    {
        if(a[i].size() > a[i - 1].size())
        {
            printf("0\n");

            return 0;
        }

        b = a[i];
        for(j = 0; b.size() < a[i - 1].size(); j ++)
            b.push_back(n + j);
        sort(b.begin(), b.end());

        s = 0;
        do
        {
            for(j = 0; j < (signed)b.size(); j ++)
                if(a[i - 1][j] > b[j])
                    break;
            s += j == b.size();
        }
        while(next_permutation(b.begin(), b.end()));
        // printf("at %d : %d\n", i, s);
        o = (long long)o * (s / (a[i - 1].size() - a[i].size() == 2 ? 2 : a[i - 1].size() - a[i].size() == 3 ? 6 : 1)) % MOD;
    }
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 5760
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=0;i<(a);++i)
#define clr(a,v) memset((a),(v),sizeof(a))

const int MAX_N = 100, INF = std::numeric_limits<int>::max()>>2;

int n;
int r[MAX_N], c[MAX_N];
int dp[MAX_N][MAX_N];

int rec( int b, int e )
{
    if( b == e )
        return dp[b][e] = 0;

    if( ~dp[b][e] )
        return dp[b][e];

    int ret = INF;

    rep( i, e-b )
        ret = std::min( ret, rec( b, b+i )+rec( b+i+1, e )+r[b]*c[b+i]*c[e] );

    return dp[b][e] = ret;
}

int main()
{
    scanf( "%d", &n );
    rep( i, n )
        scanf( "%d%d", r+i, c+i );

    clr( dp, -1 );

    printf( "%d\n", rec( 0, n-1 ) );

    return 0;
}

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

using namespace std;


int main()
{
	int n, K;
	
	cin >> n >> K;
	
	int Ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		if (x >= K) Ans++;
	}
	
	printf("%d\n", Ans);
	
	return 0;
}

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

using ll = long long;

int main(int argc, char **argv)
{
	string str; cin >> str;

	ll ref = 1ll << 60;
	for (int start = 0; start <= 1; ++start)
	{
		ll val{start};
		ll c{0} ;
		for (ll i = 0; i < (int)str.size(); ++i)
		{
			if (val != (str[i] - '0')) ++c;
			val = 1 - val;
		}
		ref = min(ref, c);
	}
	std::cout << ref << std::endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int linearSearch(vector<int> v, int key) {
	int n = v.size();
	int i = 0;
	v.push_back(key);
	while (v.at(i) != key) i++;
	return i != n;
}

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

	int q;
	cin >> q;
	vector<int> T(q);
	for (int i = 0; i < q; i++) cin >> T.at(i);

	int sum = 0;
	for (int i = 0; i < q; i++) {
		if (linearSearch(S, T.at(i))) sum++;
	}

	cout << sum << endl;
}



Measured memory_bytes: 3256
#input
N, X, Y = map(int, input().split())

#output
dp = [0] * N
for i in range(N-1):
    for j in range(i+1, N):
        temp = min(j-i, abs(X-1-i)+abs(Y-1-j)+1, abs(Y-1-i)+abs(X-1-j)+1)
        dp[temp] += 1

for k in range(1, N):
    print(dp[k])

Measured memory_bytes: 3444
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 1e18;
const int mod = 1e9 + 7;
const int N = 105;

int i, n;

void solve()
{
    cin >> n;
    cout << 1 - n;
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
n=int(input())
a=[]
a.append(list(map(int,input().split())))
for i in range(1,n):
  tmp=list(map(int,input().split()))
  a.append([tmp[0]+max(a[i-1][1],a[i-1][2]),tmp[1]+max(a[i-1][0],a[i-1][2]),tmp[2]+max(a[i-1][0],a[i-1][1])])
print(max(a[-1]))

Measured memory_bytes: 23204
#include <stdio.h>

int main(void){

  int n,b,f,r,v,i;
  int p[4][3][10] = {};

  scanf ("%d",&n);

  for (i = 0; i < n; i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    p[b - 1][f - 1][r - 1] += v;
  }
  for (b = 0; b < 4; b++){
    if (b != 0){printf("####################\n");}
    for (f = 0; f < 3; f++){
      for (r = 0; r < 10; r++){
        printf(" %d",p[b][f][r]);
      }
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 2712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for (int i = 0; i < n; i++) {
			String string = sc.next();
			if (string.equals("AC")) {
				ac++;
			} else if (string.equals("WA")) {
				wa++;
			} else if (string.equals("TLE")) {
				tle++;
			} else {
				re++;
			}
		}
		System.out.println("AC " + "x " + ac);
		System.out.println("WA " + "x " + wa);
		System.out.println("TLE " + "x " + tle);
		System.out.println("RE " + "x " + re);
		sc.close();
	}
}

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

    
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    int i,j;
    for(i=1;i<=h;i++)
    for(j=1;j<=w;j++)
    cin>>a[i][j];
    ll int dp[h+1][w+1];
    for(i=0;i<=h;i++)
    dp[i][0]=0;
    for(j=0;j<=w;j++)
    dp[0][j]=0;
    for(i=1;i<=h;i++)
    {
    if(a[i][1]=='.')
    dp[i][1]=1;
    else
    break;
    }
    for(;i<=h;i++)
    dp[i][1]=0;
    
    for(j=1;j<=w;j++)
    {
        if(a[1][j]=='.')
        dp[1][j]=1;
        else
        break;
        
    }
    
    for(;j<=w;j++)
    {
        
    dp[1][j]=0;
    }
    
    
  
    for(i=2;i<=h;i++)
    for(j=2;j<=w;j++)
    {
        if(a[i][j]=='.')
        {
        dp[i][j]=dp[i-1][j]+dp[i][j-1];
        dp[i][j]=dp[i][j]%N;
        }
        else
        dp[i][j]=0;
        
    }
    cout<<dp[h][w]<<endl;
    
    return 0;
    
}

Measured memory_bytes: 9088
import java.io.*;
import java.util.*;
import java.math.BigDecimal; 
 
public class Main {
 
	void submit() {
	    long a = nextLong();
	    long b = nextLong();
	    long c = nextLong();
	    
	    if(c -a -b > 0 && 4*a*b < (c - a - b)*(c - a - b)){
	        out.println("Yes");	        
	    }else{
	        out.println("No");	        
	    }
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23124
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

t2 = a[0]
x = a[0]//2
ans = 1
for i in range(1,n):
  t = abs(x - a[i])
  if t < t2:
    t2 = t
    ans = i
print(a[0],a[ans])

Measured memory_bytes: 20016
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    string s;
    cin >> s;
    int n = s.size();


    vector<char> v;
    rep(i, n){
        if (s[i] != 'x') v.push_back(s[i]);
    }




    int m = v.size();
    if (m == 0){
        cout << 0 << endl;
        return 0;
    }
    
    
    
    bool flag = true;
    rep(i, (m + 1) / 2){
        if (v[i] != v[m-i-1]) flag = false; 
    }

    if (!flag){
        cout << -1 << endl;
        return 0;
    }

    // rep(i, v.size()) cout << v[i] << " ";
    // cout << endl;

    vector<char> l, r;
    int i = 0, c = 0;
    while (i < n){
        l.push_back(s[i]);
        if (s[i] == v[c]) c++;
        if (c == (m + 1) / 2) break;
        i++;
    }
    int j = n-1;
    c = 0;
    while (j >= 0){
        r.push_back(s[j]);
        if (s[j] == v[c]) c++;
        if (c == (m + 1) / 2) break;
        j--;
    }

    // rep(i, l.size()) cout << l[i] << " ";
    // cout << endl;
    // rep(i, r.size()) cout << r[i] << " ";
    // cout << endl;

    i = 0, j = 0;
    ll ans = 0;
    while (i < l.size() && j < r.size()){
        if (l[i] == 'x' && r[j] != 'x'){
            ans++;
            i++;
        }
        else if (l[i] != 'x' && r[j] == 'x'){
            ans++;
            j++;
        }
        else {
            i++;
            j++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string s;
bool f=false;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
    	if(s[i]=='C')f=true;
    	else if(s[i]=='F' && f==true){
    		cout<<"Yes\n";
    		return 0;
    	}
    }
    cout<<"No\n";
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9+1)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/
int main(){
    ll w,h,x,y;cin>>w>>h>>x>>y;
    double s=w*h/2.0;
    bool ans=false;
    if(x==w/2.0&&y==h/2.0)ans=true;
    printf("%.10f %d",s,ans);
}


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

public class AtCoder
{
  public static void Main()
  {
    var s = Console.ReadLine().Trim().ToCharArray();

    var n = Math.Pow(2, s.Length - 1);
    long ans = 0;

    for (var i = 1; i <= n; i++)
    {
      var val = "0";
      for (var j = 0; j < s.Count(); j++)
      {
        val += s[j].ToString();
                
        if (((i >> j) & 1) > 0)
        {
          ans += long.Parse(val);
          val = "0";        
        }
      }
      ans += long.Parse(val);
    }

    Console.WriteLine(ans);
  }
}

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

const double EPS = 1e-12;

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b)))
		return 0;
	return a + b;
}

struct P {
	double x, y;
	P() {};
	P(double x, double y) : x(x), y(y) {
	}

	P operator + (P p) {
		return P(add(x, p.x), add(y, p.y));
	}

	P operator - (P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}

	P operator * (double d) {
		return P(x * d, y * d);
	}

	P operator / (double d) {
		return P(x / d, y / d);
	}

	// 内積
	double dot(P p) {
		return add(x * p.x, y * p.y);
	}

	// 外積
	double det(P p) {
		return add(x * p.y, -y * p.x);
	}
};

// 線分上に点があるか
bool on_seg(P p1, P p2, P q) {
	return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}

// 直線と直線の交点
P intersection(P p1, P p2, P q1, P q2) {
	return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}

// 2直線の直行判定
bool line_orth(P a1, P a2, P b1, P b2) {
	return fabs((a1 - a2).dot(b1 - b2)) < EPS;
}

// 2直線の平行判定
bool line_paral(P a1, P a2, P b1, P b2) {
	return fabs((a1 - a2).det(b1 - b2)) < EPS;
}

int main(void) {
	int N;
	P p[4];
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> p[j].x >> p[j].y;
		}
		cout << (line_paral(p[0], p[1], p[2], p[3]) ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  i64 H;
  cin >> H;
  
  i64 ans = 0;
  i64 i = 1;
  while(H > 1) {
    ans += i;
    i = i << 1;
    H /= 2;
  }
  if(H==1) {ans += i;}
  cout << ans << endl;
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		sort(a,a+i);
		for(int j=0;j<n;j++){
			cout<<a[j];
			if(j!=n-1) cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define ALL(v) v.begin(), v.end()

// every calculation can be written
// ((a ? b) ? c) ? d  or  (a ? b) ? (c ? d)

int calc(int a, int b, char ope) {
    if (ope == '+') return a + b;
    if (ope == '-') return a - b;
    if (ope == '*') return a * b;
    return -1;
}

bool isten(string s) {
    int ans;
    if (s[1] == '(') {
        int a, b, c, d;
        a = s[2] - '0';
        b = s[6] - '0';
        c = s[11] - '0';
        d = s[16] - '0';
        ans = calc(calc(calc(a,b,s[4]), c, s[9]), d, s[14]);
    }else {
        int a, b, c, d;
        a = s[1] - '0';
        b = s[5] - '0';
        c = s[11] - '0';
        d = s[15] - '0';
        ans = calc(calc(a, b, s[3]), calc(c, d, s[13]), s[8]);
    }
    return ans == 10;
}

// every calculation can be written
// ((a ? b) ? c) ? d  or  (a ? b) ? (c ? d)


vector<char> operands = {'+', '-', '*'};
random_device rd;

char getRandomOperand() {
    return operands[rd() % 3];
}

void solve41(int a, int b, int c, int d) {
    vector<int> nums;
    nums.push_back(a), nums.push_back(b), nums.push_back(c), nums.push_back(d);
    sort(ALL(nums));
    do {
        REP(i,30) {
            string eq1, eq2;
            eq1 = "((" + to_string(nums[0]) + " " + getRandomOperand() + " " +
            to_string(nums[1]) + ") " + getRandomOperand() + " " + to_string(nums[2]) +
            ") " + getRandomOperand() + " " + to_string(nums[3]);
            eq2 = "(" + to_string(nums[0]) + " " + getRandomOperand() + " " +
            to_string(nums[1]) + ") " + getRandomOperand() + " (" + to_string(nums[2]) +
            " " + getRandomOperand() + " " + to_string(nums[3]) + ")";
            if (isten(eq1)) {
                cout << eq1 << endl;
                return;
            }else if (isten(eq2)) {
                cout << eq2 << endl;
                return;
            }
        }
    }while (next_permutation(nums.begin(), nums.end()));
    cout << 0 << endl;
}

int main() {
    int a, b, c, d;
    while(cin >> a >> b >> c >> d, a + b + c + d) {
        solve41(a,b,c,d);
    }
    return 0;
}

Measured memory_bytes: 3212
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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



int N, M, Q;
int a[50], b[50], c[50], d[50];

int rec(vi v)
{
    if (v.size() == N)
    {
        int res = 0;

        rep(i, Q)
        {
            if (v[b[i]] - v[a[i]] == c[i]) res += d[i];
        }

        return res;
    }

    int start = 1;
    if (v.size() > 0) start = v.back();

    int res = 0;

    reple(i, start, M)
    {
        v.push_back(i);
        chmax(res, rec(v));
        v.pop_back();
    }

    return res;
}


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

    cin >> N >> M >> Q;

    rep(i, Q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    cout << rec({}) << endl;

    return 0;
}

Measured memory_bytes: 3672
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def calc(F):    
    res = 0
    for f in F:
        S = format(f, "024b")[22::-1]
        count = 12
        tmp = 1
        for s in S:
            if s == "1":
                count = min(count, tmp)
                tmp = 1
            else:
                tmp += 1
        count = min(count, tmp)
        res = max(res, count)
    
    return res


def g(D, F):
    if len(D) == 0:
        return calc(F)

    d = D[0]
    s = set()
    for f in F:
        if (f >> d) & 1 == 0:
            s.add(f + 2 ** d)
        
        d = 24 - d
        if (f >> d) & 1 == 0:
            s.add(f + 2 ** d)
    
    return g(D[1:], s)
    

def main():
    N = int(input())

    D = read_list()
    if D.count(0) > 0:
        print(0)
        return
    F = {1,}    
    print(g(D, F)) 
    

if __name__ == "__main__":
    main()


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

int main() {
  int N, A;
  string op;
  cin >> N >> A;

  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  /*else if (op == "-") {
    cout << A - B << endl;
  }
  else if (op == "*") {
    cout << A * B << endl;
  }
  else if (op == "?" || op == "=" || op == "!" || op == "=" || B == 0 ) {
    cout << "error" << endl;
  }*/
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
mod=10**9+7
if n==3:
    print(61)
    exit()
zt=['A','G','C','T']
for i in range(3):
    tmp=[]
    for j in zt:
        for k in list('AGCT'):
            tmp.append(j+k)
    zt=tmp
ng=set([])
for i in list('AGCT'):
    ng.add('AGC'+i)
    ng.add('AG'+i+'C')
    ng.add('A'+i+'GC')
    ng.add(i+'AGC')
    ng.add('ACG'+i)
    ng.add('GAC'+i)
    ng.add(i+'ACG')
    ng.add(i+'GAC')
z=[]
for j in zt:
    if not j in ng:
        z.append(j)
zn=len(z)
dp=[[0 for j in range(zn)] for i in range(n-3)]
for i in range(zn):
   # if not z[i] in ng:
    dp[0][i]=1
for i in range(n-4):
    for j in range(zn):
        for k in range(zn):
            #if not z[k] in ng:
            if z[j][1:]==z[k][:3]:
                dp[i+1][k]+=dp[i][j]
                dp[i+1][k]%=mod
print(sum(dp[-1])%mod)


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    int a, b;
    cin>>a>>b;
    if(b%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    if(b>=(2*a) && b<=(4*a)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3632