akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX
#define MAX 10000
#define NIL -1

using namespace std;
using LL=long long;

struct Node { int p,l,r;};
Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL) return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if(u==NIL) return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

void postParse(int u){
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main(){
    int i,v,l,r,root;
    scanf("%d",&n);
    for(i=0;i<n;i++) T[i].p=NIL;
    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL) T[l].p=v;
        if(r!=NIL) T[r].p=v;
    }
    for(i=0;i<n;i++) if(T[i].p==NIL) root=i;
    printf("Preorder\n");
    preParse(root);
    printf("\nInorder\n");
    inParse(root);
    printf("\nPostorder\n");
    postParse(root);
    printf("\n");
    return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    string s;
    cin>>s;
    ll res=0;
    int acnt=0;
    for(int i=0;i+1<s.size();i++){
        if(s[i]=='A') acnt++;
        else if(s[i]=='B' && s[i+1]=='C'){
            res+=acnt;
            i++;
        }
        else{
            acnt=0;
        }
    }
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main(){
    double ln;
    double rn;
    int l1=0,r1=0,l2=0,r2=0,l3=0,r3=0,l4=0,r4=0;
    while(cin >> ln >> rn){
    	
    	
    	
        if(ln >= 1.1) l1++;
        else if(ln >= 0.6) l2++;
        else if(ln >= 0.2) l3++;
        else l4++;
        
        
        
        if(rn >= 1.1) r1++;
        else if(rn >= 0.6) r2++;
        else if(rn >= 0.2) r3++;
        else r4++;
    }
    cout<<l1<< " " <<r1<<endl;cout<<l2<< " " <<r2<<endl; cout<<l3<< " " <<r3<<endl;cout<<l4<< " " <<r4<<endl;
    return 0;
}

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


void solve(long long N, long long K){
  vector<long long> pow_list(log2(K) + 2);
  double ans = 0.0;
  for(unsigned long long i = 1; i < pow_list.size(); ++i){
    pow_list.at(i) = pow(2, i);
  }

  for(long long i = 1; i <= N; ++i){
    if(i >= K){
      ans += 1.0 / N;
      continue;
    }
    long long min_multiplier = (K + (i - 1)) / i;
    auto itr = lower_bound(pow_list.begin() + 1, pow_list.end(), min_multiplier);
    ans += 1.0 / *itr / N;
  }

  cout << fixed << setprecision(12) << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
string t;
int f;
int tt;
int tna;
int ff;
int k;
int ind;
int ans;
int x[100005];
int main()
{
	cin>>s;
	rep(i,s.size())
	{
		if(s[i]!='x')t+=s[i];
	}
	tt=t.size();
	rep(i,tt)
	{
		if(t[i]!=t[tt-1-i])f=1;
	}
	if(f==1)
	{
		cout<<-1<<endl;
		return 0;
	}
	tna=tt/2;
	rep(i,s.size())
	{
		if(s[i]!='x')ind++;
		if(s[i]=='x')x[ind]++;
	}
	rep(i,(int)(ind+1)/2)
	{
		ans+=(int)abs(x[i]-x[ind-i]);
	}
	cout<<ans<<endl;
	/*rep(i,s.size())
	{
		if(s[i]!='x')ff++;
		if(ff==tna-1)
		{
			k=1;
		}
		if(k==1&&s[i]=='x')
		{
			cout<<s.size()-tt-1<<endl;
			return 0;
		}
		if(ff==tna)k=0;
	}*/
	//cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 768
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

b_num = [0 for _ in range(n)]
for b_i in range(n):
    c_i = bisect.bisect_right(c, b[b_i])
    b_num[b_i] = n - c_i

for i in range(1, len(b_num)):
    b_num[len(b_num) - 1 - i] += b_num[len(b_num) - i]

ans = 0
for a_i in range(len(a)):
    b_i = bisect.bisect_right(b, a[a_i])
    if b_i >= n:
        continue
    ans += b_num[b_i]
print(ans)

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll N;
    cin >> N;
    set<ll> A;
    while(N--){
        ll a; cin >> a;
        A.insert(a);
    }

    ll M;
    cin >> M;
    set<ll> B;
    while(M--){
        ll b; cin >> b;
        B.insert(b);
    }

    vector<ll> C;
    set_intersection(ALL(A), ALL(B), back_inserter(C));

    for(ll c : C){
        p(c);
    }

    return 0;
}


Measured memory_bytes: 22264
n = int(input())
s = str(input())

lst_s = s.split()
lst = [int(str) for str in lst_s]
i = 0
flg = 0

if lst[0] > 1:
  lst[0] -= 1

while i <= n-2 and n > 1:
  if lst[i] < lst[i+1]:
    lst[i+1] -= 1
  elif lst[i] > lst[i+1]:
    flg = 1  
  i += 1

if flg == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 63984
import java.util.*;

public class Main {
    static int[] vx = {1,0,-1,0};
    static int[] vy = {0,1,0,-1};
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int x = sc.nextInt();
        int y = sc.nextInt();

        ArrayList<Integer> vx = new ArrayList<>();
        ArrayList<Integer> vy = new ArrayList<>();
        int xpp = 0;
        boolean f = true;
        boolean nx = true;
        int tmp = 0;
        for(int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'F') {
                if(f) {
                    xpp++;
                } else {
                    tmp++;
                }
            } else {
                if(f) {
                    f = false;
                } else {
                    if(nx) {
                        vx.add(tmp);
                    } else {
                        vy.add(tmp);
                    }
                }
                tmp = 0;
                nx = !nx;
            }
        }
        if(nx) {
            vx.add(tmp);
        } else {
            vy.add(tmp);
        }
        boolean[][] dpx = new boolean[vx.size() + 1][20000];
        boolean[][] dpy = new boolean[vy.size() + 1][20000];
        dpx[0][10000 + xpp] = true;
        dpy[0][10000] = true;
        for(int i = 0; i < vx.size(); i++) {
            int t = vx.get(i);
            for(int j = 0; j < 20000; j++) {
                if(j + t < 20000) {
                    dpx[i + 1][j + t] |= dpx[i][j];
                }
                if(j - t >= 0) {
                    dpx[i + 1][j - t] |= dpx[i][j];
                }
            }
        }
        for(int i = 0; i < vy.size(); i++) {
            int t = vy.get(i);
            for(int j = 0; j < 20000; j++) {
                if(j + t < 20000) {
                    dpy[i + 1][j + t] |= dpy[i][j];
                }
                if(j - t >= 0) {
                    dpy[i + 1][j - t] |= dpy[i][j];
                }
            }
        }

        boolean ans = dpy[dpy.length - 1][y + 10000] && dpx[dpx.length-1][x + 10000];


        if(ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 233028
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vvi edges(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int q;
    cin >> q;
    vi v(q), d(q), c(q);
    for (int i = 0; i < q; ++i) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    vvi colors(n, vi(11, 0));
    for (int i = 0; i < q; ++i) {
        colors[v[i]][d[i]] = i + 1;
    }
    for (int i = 10; i >= 1; --i) {
        for (int j = 0; j < n; ++j) {
            chmax(colors[j][i - 1], colors[j][i]);
            for (auto &ne : edges[j]) {
                chmax(colors[ne][i - 1], colors[j][i]);
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (colors[i][0] == 0)
            cout << 0 << "\n";
        else
            cout << c[colors[i][0] - 1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 16248
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>

const int drct[2][3][2] = {{{0, 1}, {-1, 0}, {1, 0}}, {{0, -1}, {1, 0}, {-1, 0}}};

int sd_x, sd_y, bottom;

struct State {
	int x, y, bot, up, step;
	
	State() {}
	State(int x, int y, int bot, int up, int step): 
		x(x), y(y), bot(bot), up(up), step(step) {}
};

int NEXT(int x, int t) {
	switch (t) {
		case 0:
			if (x < 5 || (x >= 10 && x < 15)) return x + 5;
			return x - 5;
		case 1:
			if (x < 5) return (x + 4) % 5;
			if (x < 10) return (x + 5 - 10 + 1) % 5 + 10;
			if (x < 15) return (x - 5 - 5 + 4) % 5 + 5;
			return (x - 15 + 1) % 5 + 15;
		case 2:
			if (x < 5) return (x + 1) % 5;
			if (x < 10) return x + 5;
			if (x < 15) return x - 5;
			return (x - 15 + 4) % 5 + 15;
	}
	
	return -1;
}

std::pair<int, int> NEXT(int x, int up, int t) {
	int a = NEXT(x, (up + t) % 3), b;
	switch ((up + t) % 3) {
		case 0:
			b = 0; break;
		case 1:
			if (x < 5 || x >= 15) b = 1;
			else b = 0;
			break;
		case 2:
			if (x < 5 || x >= 15) b = 2;
			else b = 0;
			break;
	}
	return std::make_pair(a, (b + up) % 3);
}

int dist[205][205][20][3];

void BFS() {
	static std::queue<State> que;
	static State now;
	
	que.push(State(0, 0, 0, 0, 0));
	dist[0 + 100][0 + 100][0][0] = 0;
	while (!que.empty()) {
		now = que.front(); que.pop();
		if (now.step >= 100) break;
		for (int t = 0; t < 3; ++t) {
			int xx = now.x + drct[(now.x + now.y) & 1][t][0], 
				yy = now.y + drct[(now.x + now.y) & 1][t][1];
			int fir = NEXT(now.bot, now.up, t).first, 
				sec = NEXT(now.bot, now.up, t).second;
			if (~dist[xx + 100][yy + 100][fir][sec]) continue;
			dist[xx + 100][yy + 100][fir][sec] = now.step + 1;
			que.push(State(xx, yy, fir, sec, now.step + 1));
		}
	}
}

int main() {
	memset(dist, -1, sizeof dist);
	BFS();
	
	while (~scanf("%d%d%d", &sd_x, &sd_y, &bottom) && (sd_x || sd_y || bottom)) {
		int ans = 0x3f3f3f3f;
		for (int t = 0; t < 3; ++t) if (~dist[sd_x + 100][sd_y + 100][bottom][t])
			ans = std::min(ans, dist[sd_x + 100][sd_y + 100][bottom][t]);
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 12640
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=1e5+10;
int n,cnt;
int A[N],B[N],t1[N],t2[N],F[N];
map<int,int> S;
int Find(int a) {
  return F[a]==a?a:F[a]=Find(F[a]);
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n);
  for(int i=1;i<=n;++i) read(A[i]),A[n+1]^=A[i],t1[i]=A[i]; t1[n+1]=A[n+1];
  for(int i=1;i<=n;++i) read(B[i]),B[n+1]^=B[i],t2[i]=B[i]; t2[n+1]=B[n+1];
  sort(t1+1,t1+n+2); sort(t2+1,t2+n+2);
  for(int i=1;i<=n+1;++i) {
    if(t1[i]!=t2[i]) {
      return puts("-1"),0;
    }
  }
  for(int i=1;i<=n;++i) F[i]=i;
  int res=0;
  for(int i=1;i<=n;++i) {
    if(A[i]==B[i]) continue;
    ++res;
    int u=S.count(A[i])?S[A[i]]:S[A[i]]=++cnt,v=S.count(B[i])?S[B[i]]:S[B[i]]=++cnt;  
    int x=Find(u),y=Find(v);
    if(x!=y) {
      F[y]=x;
    }
  }
  if(!res) return puts("0"),0;
  for(int i=1;i<=cnt;++i) if(Find(i)==i) ++res;
  --res;
  bool OK=true;
  for(int i=1;i<=n;++i) {
    if(A[n+1]==B[i]) {
      OK=false;
      break;
    }
  }
  res+=OK;
  printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 6912
H,W = map(int,input().split())
board = [["." for x in range(W)]]
for i in range(H):
	board.append("." + input() + ".")
board.append(["." for x in range(W)])

for i in range(1,H):
	for j in range(1,W):
		if board[i][j] == "#":
			if board[i-1][j] == "." and board[i+1][j] == "." and board[i][j-1] == "." and board[i][j+1] == ".":
				print("No")
				break
	else:
		continue
	break
else:
	print("Yes")


Measured memory_bytes: 3064
# 単調増加したらそこの山の高さは決まる。それ以外ならある高さ以内で自由に取れる。t,aで矛盾したら0
# 一人ずつ考えた
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 1
MOD = 10**9 + 7
a_fixed = [-1] * n
t_fixed = [-1] * n

t_fixed[0] = t[0]
for i in range(1, n):
    if t[i] > t[i - 1]:
        t_fixed[i] = t[i]

a_fixed[-1] = a[-1]
for i in range(n - 2, -1, -1):
    if a[i] > a[i + 1]:
        a_fixed[i] = a[i]


for i in range(n):
    if t_fixed[i] != -1 and a_fixed[i] != -1:
        if t_fixed[i] != a_fixed[i]:
            print(0)
            exit()
    elif t_fixed[i] != -1:
        if t_fixed[i] > a[i]:
            print(0)
            exit()
    elif a_fixed[i] != -1:
        if a_fixed[i] > t[i]:
            print(0)
            exit()
    else:
        ans *= min(a[i], t[i])
        ans %= MOD
# print(fixed)
print(ans)

# if t[-1] != a[0]:
#     print(0)
#     exit()
# # # 最初の山チェック
# # if t[0] > a[0]:
# #     print(0)
# #     exit()
# # 最後の山の照合
# if fixed[-1] != -1:
#     if fixed[-1] != a[-1]:
#         print(0)
#         exit()
# fixed[-1] = a[-1]

# for i in range(n - 2, -1, -1):
#     if a[i] > a[i + 1]:  # この状況下でしか照合されないので最初の山の照合を取り逃している！
#         if fixed[i] == -1:
#             fixed[i] = a[i]
#         else:
#             if fixed[i] != a[i]:
#                 print(0)
#                 exit()
# for i in range(n):
#     if fixed[i] != -1:
#         continue
#     else:
#         ans *= min(a[i], t[i])
#         ans %= MOD
# # print(fixed)
# print(ans)


Measured memory_bytes: 24092
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=55;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll dp[N][N*N];
int main()
{
    std::ios::sync_with_stdio(false);
    int n,a;
    ll x;
    cin>>n>>a;
    dp[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        cin>>x;
        for(int j=i-1; j>=0; j--)
        {
            for(int w=0;w<N*N;w++)
            {
                dp[j+1][w+x]+=dp[j][w];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=dp[i][i*a];
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

struct edge{
    int a, b;
    ll c;
} edges[100005];
ll dist[5005];

const ll INF = 100000000000000LL;

bool visited[5005];

void dfs(int v){
    if(visited[v]) return;
    visited[v] = 1;
    for(auto c : edges){
        if(c.b == v) dfs(c.a);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n, m;
    cin >> n >> m;
    ll p;
    cin >> p;
    for(int i=1; i<=m; i++){
        cin >> edges[i].a >> edges[i].b >> edges[i].c;
        edges[i].c = -edges[i].c + p;
    }
    for(int i=2; i<=n; i++) dist[i] = INF;
    dfs(n);
    for(int j=1; j<=n; j++){
        for(int i=1; i<=m; i++){
            if(dist[edges[i].a] < INF) dist[edges[i].b] = min(dist[edges[i].b], dist[edges[i].a] + edges[i].c);
        }
    }
    ll g = dist[n];
    if(g == INF){
        cout << -1;
        return 0;
    }
    for(int j=1; j<=n; j++){
        for(int i=1; i<=m; i++){
            if(dist[edges[i].a] < INF && dist[edges[i].b] > dist[edges[i].a] + edges[i].c){
                if(visited[edges[i].b]){
                    cout << -1;
                    return 0;
                }
            }
        }
    }
    cout << max(-g, 0LL);
    return 0;
}


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

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

    string s, t;
    cin >> s >> t;

    map<char, vector<int>> m;
    for (int j = 0; j < s.length(); j++) {
        map<char, vector<int>>::iterator it = m.find(s[j]);
        if (it == m.end())
            m[s[j]] = vector<int>(1, j);
        else
            it->second.push_back(j);
    }

    long long i = 0;
    int prev = -1;
    for (int j = 0; i != -1 && j < t.length(); j++) {
        map<char, vector<int>>::iterator mit = m.find(t[j]);
        if (mit == m.end())
            i = -1;
        else {
            vector<int>::iterator vit = upper_bound(mit->second.begin(), mit->second.end(), prev);
            if (vit == mit->second.end()) {
                i += s.length();
                prev = mit->second[0];
            } else
                prev = mit->second[vit - mit->second.begin()];
        }
    }
    if (i != -1)
        i += prev + 1;

    cout << i << '\n';

    return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
#include<stdlib.h>
#define MAX 8
int first[MAX];
int rowStat[MAX];//the column value of queen in this row
int colStat[MAX];//can be put: 0
int dPosStat[2*MAX-1];
int dNegStat[2*MAX-1];
void init(void);
void putQueen(int);
int setQueen(int,int,int);
void removeQueen(void);
void printBoard(void);
int main(void)
{
  int i;//counter
  int firstNum;
  int row,col;
  init();
  scanf("%d",&firstNum);
  for(i=0;i<firstNum;i++)
    {
      scanf("%d%d",&row,&col);
      rowStat[row]=col;
      colStat[col]=dPosStat[row+col]=dNegStat[col-row+MAX-1]=1;
      first[row]=1;
    }
  putQueen(0);
  return 0;
}
void init(void)
{
  int i,j;//counter
  for(i=0;i<MAX;i++)
    {
      first[i]=0;
      rowStat[i]=-1;
      colStat[i]=0;
    }
  for(i=0;i<2*MAX+1;i++) dPosStat[i]=dNegStat[i]=0;
}
void putQueen(int i)
{
  int j;//counter
  //printf("putQueen(%d)\n",i);
  if(i==MAX)
    {
      printBoard();
      return;
    }
  if(first[i]==0)
    {
      for(j=0;j<MAX;j++)
        {
          if(colStat[j]==0&&dPosStat[i+j]==0&&dNegStat[j-i+MAX-1]==0)
            {
              rowStat[i]=j;
              colStat[j]=dPosStat[i+j]=dNegStat[j-i+MAX-1]=1;
              //printf("put(%d,%d)\n",i,j);
              putQueen(i+1);
              //printf("remove(%d,%d)\n",i,j);
              colStat[j]=dPosStat[i+j]=dNegStat[j-i+MAX-1]=0;
            }
        }
    }
  else putQueen(i+1);
}
void printBoard(void)
{
  int i,j;//counter
  for(i=0;i<MAX;i++)
    {
      for(j=0;j<MAX;j++)
        {
          if(rowStat[i]==j) printf("Q");
          else printf(".");
        }
      printf("\n");
    }
}


Measured memory_bytes: 2104
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <stdlib.h>
#include <vector>

using namespace std;

int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector <int> xi;
    vector <int> yi;
    int temp;
    int maxx = -100;
    int miny = 100;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        xi.push_back(temp);
        maxx = max(temp, maxx);
    }

    for (int i = 0; i < m; i++) {
        cin >> temp;
        yi.push_back(temp);
        miny = min(temp, miny);
    }
    
    int z = min(miny, y);
    
    if (z > max(x, maxx))
        cout << "No ";
    cout << "War";
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define rad(A) (A/180.0*M_PI)

int main(void){
	double x=0, y=0; int r, angle=90, t;
	
	while(scanf("%d,%d",&r,&t), r){
		x-=r*cos(rad(angle)), y+=r*sin(rad(angle));
		angle+=t;
	}
	
	printf("%d\n%d\n",(int)x,(int)y);
	
	return 0;
}

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

void solve() {
    int n;
    cin >> n;
    unordered_map<int, int> mp;
    while(n--) {
        int x;
        cin >> x;
        mp[x]++;
    }
    int ans = 0;
    for (auto x : mp) {
        if(x.second % 2) {
            ans++;
        }
    }
    cout << ans;
}


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


Measured memory_bytes: 7180
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll N, A, B;
  cin >> N >> A >> B;

  if(A%2==B%2){
    cout << (B-A)/2 << endl;
  }else{
    ll ret = N;
    {
      ll tmp = A;
      ll BB = B-A;
      if(BB <= 1){
        ret = min(ret, A);
      }else{
        ret = min(ret, A + (BB-1)/2);
      }
    }
    {
      ll tmp = N-B+1;
      ll AA = A+(N-B+1);
      if(AA >= N){
        ret = min(ret, N-B+1);
      }else{
        ret = min(ret, N-B+1 + (N-AA)/2);
      }
    }
    cout << ret << endl;
  }
  
  return 0;
}



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



//WBWBWB -> WBWBWWW -> WBWBBBB -> WBWWWWWW -> WBBBBBBB -> BBBB///
int main(){
  string s;
  cin >> s;

  int n = sz(s);

  int ans = 0;
  rep(i,n-1){
    if(s[i] != s[i+1]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3728
q, h, s, d = map(int, input().split())
n = int(input())

pricesfor2 = [q * 8, h * 4, s * 2, d]
pricesfor2 = sorted(pricesfor2)

nep = n % 2 == 1

n //= 2

res = n * pricesfor2[0]

if(nep):
    res += min(q * 4, min(h * 2, s))

print(res)


Measured memory_bytes: 3060
/**
** 
** Last Updated: 2019/06/07 22:03:49 JST
** (c) was
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
  //input
  int a,b;cin >> a >> b;
  //compute
  if(a<=5) cout << 0 << endl;
  else if(5<a && a<13) cout << b/2 << endl;
  else cout << b << endl;
  //output

  return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll k,a,b,c=1,kk;
    cin>>k>>a>>b;
    kk=k;
    if(c<a)
    {
      k-=(a-c);
      c=a;
     
    }
    //cerr<<k<<endl;
    
      if(a<b-1&&k>1)
      {   
          ll temp=k/2;
          //cerr<<"Temp = "<<temp<<endl;
          c=c-((1ll*temp)*a);
          //cerr<<"CC = "<<c<<endl;
          c=c+(1ll*temp*b);
          //cerr<<"C "<<c<<endl;
          //c=c-((1ll*temp)*a);
         // cerr<<c<<endl;
          k=k-(temp*2);
          if(k>0)
          {
            c+=k;
          }

      }
      cout<<max(kk+1,c)<<endl;
      
    }

return 0;
}

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

using namespace std;

int main(){
  int h, w;
  cin >> h >> w;

  vector<string> C;
  for(int i = 0; i < h; i++) {
    string tmp;
    cin >> tmp;
    C.push_back(tmp);
  }
  for(int i= 0; i < h; i++) {
    cout << C[i] << endl;
    cout << C[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
N = int(input())
As = [int(input())-1 for i in range(N)]
seen = [-1] * N
# print(As)
from collections import deque
q = deque()
q.append(0)
seen[0] = 1
cnt = 1
while len(q) > 0:
    a = q.popleft()
    n = As[a]
    # print("pop",n)
    if n == 1:
       print(seen[a])
       exit()
    if seen[n] > -1: continue
    seen[n] = seen[a] + 1
    q.append(n)
print(-1)


Measured memory_bytes: 11176
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  vector<vector<char> > s(h+2, vector<char>(w+2, '.'));
  FOR (i, 1, h+1) {
    FOR (j, 1, w+1) {
      scanf(" %c", &s[i][j]);
    }
  }
  FOR (i, 1, h+1) {
    FOR (j, 1, w+1) {
      if (s[i][j] == '.') {
        continue;
      }
      if (s[i+1][j] == '.' && s[i][j+1] == '.' && s[i-1][j] == '.' && s[i][j-1] == '.') {
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int query(int n) {
    string s;
    cout << n << endl;
    cin >> s;
    if (s[0] == 'V') exit(0);
    return (s[0] == 'M' ? 0 : 1);
}

int N;

int main() {
    cin >> N;
    int b = 0, s = query(b);

    int l = 1, r = N; 
    while (l < r) {
        int m = (l + r) / 2;
        int q = query(m);
        if ((b + s) % 2 != (m + q) % 2) {
            r = m;
        } else {
            b = m;
            s = q;
            l = m+1;
        }
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> ch(h, 0), cw(w, 0);
    map<P, int> mp;
    for (int i = 0; i < m; i++) {
        int hi, wi;
        cin >> hi >> wi;
        hi--; wi--;
        ch[hi]++;
        cw[wi]++;
        mp[make_pair(hi, wi)]++;
    }
    
    int mh = *max_element(ch.begin(), ch.end());
    int mw = *max_element(cw.begin(), cw.end());
    vector<int> h2, w2;
    for (int i = 0; i < h; i++) {
        if (ch[i] == mh)
            h2.push_back(i);
    }
    for (int i = 0; i < w; i++) {
        if (cw[i] == mw)
            w2.push_back(i);
    }
    for (int u : h2) {
        for (int v : w2) {
            if (mp.count(make_pair(u, v)) == 0) {
                cout << mh + mw << endl;
                return 0;
            }
        }
    }

    cout << mh + mw - 1 << endl;    
    return 0;
}


Measured memory_bytes: 28548
n, q=map(int, input().split())
s=input()
l_list=[]
r_list=[]

t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)

for i in range(q):
    l, r=map(int, input().split())
    print(t[r-1]-t[l-1])


Measured memory_bytes: 50776
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
	int a,b,c,n;
	scanf("%d",&n);
	while(n>0){
		scanf("%d %d %d",&a,&b,&c);
		if(a>=b && a>=c){
			if(a*a==b*b+c*c)printf("YES\n");
			else printf("NO\n");
		}
		else if(b>=a &&b>=c){
			if(b*b==a*a+c*c)printf("YES\n");
			else printf("NO\n");
		}
		else if(c>=a && c>=a){
			if(c*c==b*b+a*a)printf("YES\n");
			else printf("NO\n");
		}
		n--;
	}



	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

#define max(x, y) ((x) > (y)) ? (x) : (y)
#define min(x, y) ((x) < (y)) ? (x) : (y)

signed main(void){
    int h, w;
    cin >> h >> w;
    vector<string> as = vector<string>(h);
    rep (i, h) {
        cin >> as[i];
    }

    vector<vint> cnts = vector<vint>(h);
    rep(i, h) cnts[i] = vint(w, INF);
    rep(tt, 2) {
        rep (i, h) {
            int cnt = INF;
            rep (j, w) {
                if (as[i][j] == '.') {
                    if (cnt < cnts[i][j]) {
                        ++cnt;
                        cnts[i][j] = cnt;
                    } else {
                        cnt = cnts[i][j];
                    }
                } else {
                    cnts[i][j] = 0;
                    cnt = 0;
                }
            }
            cnt = INF;
            for (int j = w - 1; j >= 0; --j) {
                if (as[i][j] == '.') {
                    if (cnt < cnts[i][j]) {
                        ++cnt;
                        cnts[i][j] = cnt;
                    } else {
                        cnt = cnts[i][j];
                    }
                } else {
                    cnts[i][j] = 0;
                    cnt = 0;
                }
            }
        }

        rep (j, w) {
            int cnt = INF;
            rep (i, h) {
                if (as[i][j] == '.') {
                    if (cnt < cnts[i][j]) {
                        ++cnt;
                        cnts[i][j] = cnt;
                    } else {
                        cnt = cnts[i][j];
                    }
                } else {
                    cnts[i][j] = 0;
                    cnt = 0;
                }
            }
            cnt = INF;
            for (int i = h - 1; i >= 0; --i) {
                if (as[i][j] == '.') {
                    if (cnt < cnts[i][j]) {
                        ++cnt;
                        cnts[i][j] = cnt;
                    } else {
                        cnt = cnts[i][j];
                    }
                } else {
                    cnts[i][j] = 0;
                    cnt = 0;
                }
            }
        }
    }
//  rep(i, h) rep(j, w) DBG(cnts[i][j]);

    int ans = 0;
    rep(i, h) rep(j, w) ans = max(cnts[i][j], ans);
    cout << ans << endl;
    return 0;
}


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

/*int compare(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}*/


int main(){
	
	int N,M,a[60],b[60],i,load[60],j;
	scanf("%d",&N);
	scanf("%d",&M);
	
	for(i=0;i<M;i++){
		scanf("%d",&a[i]);
		scanf("%d",&b[i]);
	}
	
	for(i=1;i<N+1;i++){
		load[i]=0;
	}
	
	
	/*qsort(a,M,sizeof(int),compare);
	qsort(b,M,sizeof(int),compare);
	*/
	for(j=0;j<M;j++){
		
		load[a[j]]++;
		load[b[j]]++;
		/*for(j=0;j<M;j++){
		if(a[j]==i){
			load[i]++;
		}else if(b[j]==i){
			load[i]++;
		}
		
		}*/
		
	}
	
	for(i=1;i<N+1;i++){
	printf("%d\n",load[i]);
	}
	
	
	return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

d=sum(b)
for i in range(n-1):
    if a[i]+1==a[i+1]:
        d+=c[a[i]-1]
print(d)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
using namespace std;

#define int long long

signed main() {
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
 
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int MAX_NUM = 100000000;
 
int main() {
    int H, N;
    cin >> H >> N;
 
    int A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
 
    int dp[H+1];
    rep(i,H+1) dp[i] = MAX_NUM;
 
    rep(i,H+1)rep(j,N) {
        if (A[j] >= i) dp[i] = min(dp[i], B[j]);
        else dp[i] = min(dp[i], dp[i - A[j]] + B[j]);
    }
 
    cout << dp[H] << endl;
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	int a,b,c,d;

	cin>>a>>b>>c>>d;

	if(abs(c-a)<=d){
        cout<<"Yes"<<endl;
	}
	else if(abs(b-a)<=d && abs(c-b)<=d){
            cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;


}


Measured memory_bytes: 3624
#include<stdio.h>
int solve(int,int);
int m[20];
int n;
int main(){
  int i,k,b,h[200];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&m[i]);
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&h[i]);
  }
  for(i=0;i<k;i++){
  b=solve(0,h[i]);
  if(b==1) printf("yes\n");
  else if(b==0) printf("no\n");
  }
  return 0;
}


int solve(int j,int o)
{
  int res;
  if( o == 0) return 1;
  if (j >= n){
    return 0;
  }
  res = solve(j + 1, o) || solve(j + 1, o - m[j]);
  return res;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(3e5 + 5);
const double EPS = 1e-4;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, s, d;
    cin >> n;
    REP(i,n){
        cin >> s >> d;
        int cnt = 0;
        if(s<0 && d<0){
            s = abs(s);
            d = abs(d);
            swap(s,d);
        }
        else if(s<=0 && d>=0){ // 必ず0を経由する
            s = abs(s);
            while(s>0){
                cnt += s&1;
                s >>= 1;
            }
        }
        while(s<d){
            ll b = d & -d;  // 乗車できる最大の等級は最下位bit
            while(s>d-b){
                b >>= 1;
            }
            d -= b;
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

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

int main() {
	int n; scanf("%d", &n); std::vector<int> x(n), y(n);
	for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);

	auto dist = [&](double x, double y) { return x * x + y * y; };

	double gx = 0, gy = 0;
	for(auto v: x) gx += v; gx /= (double)n;
	for(auto v: y) gy += v; gy /= (double)n;

	double d = 0, P = 0.1;
	for(int loop = 0; loop < 30000; loop++) {
		int f = 0;
		d = dist(gx - x[0], gy - y[0]);
		for(int i = 1; i < n; i++) {
			double tmp = dist(gx - x[i], gy - y[i]);
			if(d > tmp) continue;
			d = tmp;
			f = i;
		}

		gx += (x[f] - gx) * P;
		gy += (y[f] - gy) * P;
		P *= 0.999;
	}

	printf("%.12f\n", sqrt(d));
	return 0;
}


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

using namespace std;

#define fir first
#define sec second
#define ins insert
#define pb push_back
#define po pop_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265

typedef long long ll;

const ll max_n = 1e6 + 10 , max_h = 200 , Mod = 1e9 + 7 , inf = 1e18;
ll table[max_h][max_h];
ll h , w , n , tmp = 1 , tp = 1 , num;

void read_input(){
        cin >> h >> w >> n;
}

void solve(){                   
        for(int i = 1 ; i <= n ; i++){
                cin >> num;
                while(num--){
                        table[tmp][tp] = i;

                        if(tp == w && tmp % 2 == 1)
                                tmp++;

                        else if(tp == 1 && tmp % 2 == 0)
                                tmp++;
                        
                        else if(tmp % 2)
                                tp++;
                        
                        else
                                tp--;
                }
        }
}

void output(){
        for(int i = 1 ; i <= h ; i++){
                for(int j = 1 ; j <= w ; j++)
                        cout << table[i][j] << " ";
                cout << '\n';
        }
}

int main(){
        IOS;
        read_input();
        solve();
        output();
        return 0;
}

Measured memory_bytes: 512
object Main extends App {
  import scala.util.control.Breaks._
  val nums = io.StdIn.readLine().toCharArray.map(_-48)
  breakable {
    for (bit <- 0 until 1 << 3) {
      var acc = nums(0)
      val builder = StringBuilder.newBuilder
      builder.append(nums(0))
      for (i <- 0 to 2; n = nums(i+1)) {
        if ((bit >> i & 1) == 0) {builder.append('+'); acc = acc + n}
        else {builder.append('-'); acc = acc - n}
        builder.append(n)
      }
      if (acc == 7) {println(builder.toString() + "=7"); break}
    }
  }
}

Measured memory_bytes: 25496
#include<iostream>
#include<string>
using namespace std;
int main(){
char s[3];
 cin>>s;
  if((s[0]=='R' && s[1]=='R' && s[2]=='S') || ( s[0]=='S' && s[1]=='R' && s[2]=='R')){
    cout<<"2"<<endl;
  }
  else if(s[0]=='R' && s[1]=='R' && s[2]=='R'){
    cout<<"3"<<endl;
  }
   else if(s[0]=='S' && s[1]=='S' && s[2]=='S'){
    cout<<"0"<<endl;
  }
  else {
    cout<<"1"<<endl;}
  return 0;

}

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

int main()
{
    long long N,K;
    cin >> N >> K;
    vector<long long> H(N);
    rep(i, N) cin >> H[i];
    sort(H.begin(), H.end());
    long long total = 0;
    rep(i,N-K) total += H[i];
    cout << total << endl;  

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
const int N=100005;
ll dp[4][3002][3002]={};
ll val[3002][3002]={};
void solve()
{
    ll n,k=0,m=INT64_MIN,i=0,j,x,y;
    ll ans=0;
    cin>>n>>m>>k;
    while(k--)
    {    cin>>x>>y;
        cin>>val[x][y];
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            k=val[i][j];
            if(k)
            {
                dp[0][i][j]=max({dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j],dp[0][i][j-1]});
                dp[1][i][j]=max({dp[1][i][j-1],dp[1][i-1][j]+k,dp[2][i-1][j]+k,dp[3][i-1][j]+k,dp[0][i-1][j]+k,dp[0][i][j-1]+k});
                dp[2][i][j]=max(dp[2][i][j-1],dp[1][i][j-1]+k);
                dp[3][i][j]=max(dp[3][i][j-1],dp[2][i][j-1]+k);
            }
            else 
            {
                dp[0][i][j]=max({dp[0][i][j-1],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j],dp[0][i-1][j]});
                dp[1][i][j]=dp[1][i][j-1];
                dp[2][i][j]=dp[2][i][j-1];
                dp[3][i][j]=dp[3][i][j-1];
            }
        }
    }
    cout<<max({dp[0][n][m],dp[1][n][m],dp[2][n][m],dp[3][n][m]});
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

Measured memory_bytes: 355296
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int oo=100000000;
int n,m,x;
int c[15];
int a[15][15];
int tmp[15];
int ans;
inline void read(int &x)
{
	int f=1;char c;
	for(x=0,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48); x*=f;
}
inline int mx(int _x,int _y)
{
	return _x>_y?_x:_y;
}
inline int mn(int _x,int _y)
{
	return _x<_y?_x:_y;
}
inline bool check()
{
	for(int i=1;i<=m;i++)
	{
		if(tmp[i]<x) return false;
	}
	return true;
}
inline void dfs(int dep,int cost)
{
//	printf("%d %d %d\n",dep,cost,ans);
	if(dep>n)
	{
		if(check()) 
		{	
	//		for(int i=1;i<=m;i++) printf("%d ",tmp[i]);
	//		puts("");
			ans=mn(ans,cost);
	//		printf("%d\n",ans);
		}
		return ;
	}
	dfs(dep+1,cost);
	for(int i=1;i<=m;i++) tmp[i]+=a[dep][i];
	dfs(dep+1,cost+c[dep]);
	for(int i=1;i<=m;i++) tmp[i]-=a[dep][i];
}
int main()
{
	ans=oo;
	read(n);read(m);read(x);
	for(int i=1;i<=n;i++)
	{
		read(c[i]);
		for(int j=1;j<=m;j++)
			read(a[i][j]);
	} 
	dfs(1,0);
	if(ans==oo) puts("-1");
	else printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t = h2 * 60 + m2 - h1 * 60 - m1;
    cout << t - k << newl;
}

Measured memory_bytes: 3648