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

int main() {
    int N;
    std::cin >> N;

    if (N % 2 == 0) {
        printf("%.10lf\n", 0.5);
    } else {
        printf("%.10lf\n", (double)(N/2 + 1) / (double)(N));
    }

    return 0;
}


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

const int N = 1e5 + 10;
vector<int> adj[N];
bool mark[N];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, u, v;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        adj[--u].push_back(--v);
        adj[v].push_back(u);
    }
    deque<int> ans;
    ans.push_back(0);
    mark[0] = true;
    bool flag = true;
    while (flag) {
        flag = false;
        u = ans.back();
        for (auto v: adj[u])
            if (!mark[v]) {
                mark[v] = true;
                flag = true;
                ans.push_back(v);
                break;
            }
    }
    flag = true;
    while (flag) {
        flag = false;
        u = ans[0];
        for (auto v: adj[u])
            if (!mark[v]) {
                mark[v] = true;
                flag = true;
                ans.push_front(v);
                break;
            }
    }
    cout << ans.size() << "\n";
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i] + 1 << " ";
    cout << "\n";
}

Measured memory_bytes: 6784
from collections import deque

def main():
    n,m = map(int,input().split())
    dq = [deque() for _ in range(n)]
    for _ in range(m):
        q = list(map(int,input().split()))
        if q[0] == 0:dq[q[1]].append(q[2])
        elif q[0] == 1:print (' '.join(map(str,dq[q[1]])))
        else :dq[q[1]].clear()



if __name__ == '__main__':
    main()




Measured memory_bytes: 61780
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, ans = 0;
    cin >> n;
    vector<int> v;
    for(int i = 1; i <= 100; i++){
        v.push_back(i * (i + 1) / 2);
    }
    for(ll i = 2; i * i <= n; i++){
        int cnt = 0;
        while(n % i == 0){
            cnt++;
            n/=i;
        }
        if(cnt) ans += upper_bound(v.begin(), v.end(), cnt) - v.begin();
    }
    if(n != 1) ans++;
    cout << ans;
    return 0;

}


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

typedef struct{
	int num;
	int p; //point
	int r; //rank
}team;

int main(){
	int n;
	team t[100];
	scanf(" %d", &n);
	
	for(int i=0; i<n; ++i){
		t[i].p=0;
		t[i].num=i;
	}
	
	for(int i=0; i<n*(n-1)/2; ++i){
		int a, b, c, d;
		scanf(" %d %d %d %d", &a, &b, &c, &d);
		if(c<d) t[b-1].p += 3;	
		else if(c>d) t[a-1].p += 3;	
		else{
			t[a-1].p += 1;
			t[b-1].p += 1;
		}
	}	
	
	for(int i=0; i<n; ++i){
		for(int j=i; j<n; ++j){
			if(t[i].p < t[j].p) swap(t[i], t[j]);		
		}
	}
	
	t[0].r=1;
	
	int now=1;
	int count=1;
	for(int i=0; i<n-1; ++i){
		if(t[i+1].p == t[i].p) count++;
		else{
			now+=count;
			count=1;
		}
		t[i+1].r=now;
	}
	
	for(int i=0; i<n; ++i){
		for(int j=i; j<n; ++j){
			if(t[i].num > t[j].num) swap(t[i], t[j]);		
		}
	}
	
	for(int i=0; i<n; ++i) printf("%d\n", t[i].r);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;
int R;
int main(){
    cin >> R;
    if(R < 1200) cout << "ABC" << endl;
    else if(R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <bitset>
#include <set>
#include <map>
using namespace std;
#define inf 2000000000
#define mod 1000000007
int main() {
    cin.sync_with_stdio(false);
	cin.tie(NULL);
	int r;
	cin >> r;
	cout << r*r;
}

Measured memory_bytes: 256
from sys import stdin
input = [int(x) for x in stdin.readline().rstrip().split()]
H=input[0]
W=input[1]
start=[0,0]
goal=[H-1,W-1]
road=[]
wall_len=0
for h in range(H):
    road.append(list(stdin.readline().rstrip().split()[0]))
    wall_len+=len([x for x in road[h] if x == "#"])

def bfs(H,W,start,goal,road):
    road_dist=[[float("inf") for w in range(W)] for h in range(H)]
    queue_list=[start]
    already_list=[]
    road_dist[start[0]][start[1]]=0
    move_list=[[0,1],[0,-1],[1,0],[-1,0]]
    while len(queue_list)>0:
        now_position=queue_list.pop(0)
        already_list.append(now_position)
        now_dist=road_dist[now_position[0]][now_position[1]]
        if now_position == goal:
            break
        next_list=[]
        for dy, dx in move_list:
            next_y=now_position[0]+dy
            next_x=now_position[1]+dx
            if (0<=next_x<W) & (0<=next_y<H):
                if (road[next_y][next_x]!="#") & (road_dist[next_y][next_x]==float("inf")):
                    next_list.append([next_y,next_x])
        for p in next_list:
            if p in queue_list:
                continue
            if p in already_list:
                continue
            queue_list.append(p)
            road_dist[p[0]][p[1]]=now_dist+1

    return road_dist

rd=bfs(H,W,start,goal,road)
if rd[goal[0]][goal[1]] == float("inf"):
    output=-1
else:
    output=H*W-(rd[goal[0]][goal[1]]+1+wall_len)

print(output)

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILE_WR freopen("../input.txt", "r", stdin);\
	freopen("../output.txt", "w", stdout);
#define deb(x)	cout << #x << " " << x << endl;
#define ll long long int

int main() {

	
	IOS

	string s;
	cin >> s;

	cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    // 行き先, 距離
    vector<vector<pair<int, ll>>> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a;
        --b;
        graph[a].push_back(make_pair(b, c));
        graph[b].push_back(make_pair(a, c));
    }
    int q, k;
    cin >> q >> k;
    --k;
    // 始点k
    vector<ll> dist(n, infl);
    dist[k] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
    que.push(make_pair(0, k));

    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first)
            continue;

        for (const auto &edge : graph[v]) {
            if (dist[edge.first] > dist[v] + edge.second) {
                dist[edge.first] = dist[v] + edge.second;
                que.push(make_pair(dist[edge.first], edge.first));
            }
        }
    }
    vector<ll> ans;
    for (int i = 0; i < q; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        ans.push_back(dist[x] + dist[y]);
    }

    for (ll k : ans) {
        cout << k << endl;
    }
    return 0;
}

Measured memory_bytes: 12528
#include <bits/stdc++.h>
using namespace std;
string s;
int x,y=1000000;
int main()
{
    cin>>s;
    for (int i=0;i<s.size();i++)
    {
        if (i<=s.size()-3)
        {
            x=abs(((int (s[i+2])-48)+((int (s[i+1])-48)*10)+((int (s[i])-48)*100))-753);
            y=min(y,x);
        }
    }
    cout<<y;
    return 0;
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> xs(n);
	for (auto &&x : xs)
	{
		cin >> x;
	}

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

	int64_t p = accumulate(xs.begin(), xs.end(), int64_t(0)) / n;

	int64_t ans = 0;

	for (auto &&x : xs)
	{
		ans += (x - p) * (x - p);
	}

	{
		p--;

		int64_t tmp = 0;

		for (auto &&x : xs)
		{
			tmp += (x - p) * (x - p);
		}

		ans = min(ans, tmp);

		p++;
		p++;

		tmp = 0;

		for (auto &&x : xs)
		{
			tmp += (x - p) * (x - p);
		}

		ans = min(ans, tmp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
def run():
    H,W,K = map(int, sysread().split())
    S = []
    for i in range(H):
        S.append(list(accumulate(list(map(int, list(input()))))))
    for h in range(1, H):
        for w in range(W):
            S[h][w] += S[h-1][w]

    ret = float('inf')

    for idxes_ in product((0,1), repeat=H-1):
        l = 0
        r = 1
        idxes = [0]
        for i, val in enumerate(idxes_, 1):
            if val == 1:
                idxes.append(i)
        idxes.append(H)
        min_cut = len(idxes) - 2
        while r <= W:
            for i in range(len(idxes)-1):
                if idxes[i] == 0 and l == 0:
                    cri = S[idxes[i+1]-1][r-1]
                elif l == 0:
                    cri = S[idxes[i+1]-1][r-1] - S[idxes[i]-1][r-1]
                elif idxes[i] == 0:
                    cri = S[idxes[i+1]-1][r-1] - S[idxes[i+1]-1][l-1]
                else:
                    cri = S[idxes[i+1]-1][r-1] - S[idxes[i]-1][r-1] - S[idxes[i+1]-1][l-1] + S[idxes[i]-1][l-1]

                if cri > K:
                    r -= 1
                    if l == r:
                        min_cut = float('inf')
                        r = W+1
                        break
                    l = r
                    min_cut += 1
                    break
            r += 1
        ret = min(ret, min_cut)

    print(ret)




if __name__ == "__main__":
    run()


Measured memory_bytes: 43356
#include<stdio.h>
#include<math.h>
#define N 10000
int main(){
  int ary[N];
  int i,j,n,flag=0,scount=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ary[i]);
  }
  for(i=0;i<n;i++){
    flag=0;
    for(j=2;j<=sqrt(ary[i]);j++){
      if(ary[i]%j==0){
	flag=1;
      }
    }
    if(flag==0)scount++;
  }
  printf("%d\n",scount);
  return 0;
}



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

int main()
{
  int num, dist;
  cin >> num >> dist;
  int ans = 0;
  for (int i = 0; i < num; i++)
  {
    int64_t x, y;
    cin >> x >> y;
    if (x * x + y * y <= (int64_t)dist * dist)
    {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main(){
	
	unsigned long long N=0;
	unsigned long long A=0;
	unsigned long long B=0;
	unsigned long long ans=0;
  	unsigned long long tmp=0;
	cin >> N;
	cin >> A;
	cin >> B;

  if(A==0){
    ans=0;
  }else{
	ans=N/(A+B)*A;
	if(N%(A+B)>=A){
	ans=ans+A;
}else{
	ans=ans + N%(A+B);
}
  }
		cout << ans <<endl;
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;
using P = pair<int,int>;
int dist(P x, P y) {
    return abs(x.first-y.first) + abs(x.second-y.second);
}
int main() {
    int n, m; cin >> n >> m;
    vector<P> person(n), checkPoint(m);
    rep(i, n) cin >> person[i].first >> person[i].second;
    rep(i, m) cin >> checkPoint[i].first >> checkPoint[i].second;
    rep(i, n) {
        int ans = 0;
        int mi = 1001001001;
        rep(j, m) {
            if(mi > dist(person[i], checkPoint[j])) {
                ans = j;
                mi = dist(person[i], checkPoint[j]);
            }
        }
        cout << ans+1 << endl;
    }
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    ll sum = 0;
    ll ans = 0;
    vector<pair<ll, ll> > s;
    for(int i=0;i<n;i++){
        ll a, b; cin >> a >> b;
        s.push_back(make_pair(a, b));
    }
    sort(s.begin(), s.end());
    for(int i=0;i<n;i++){
        if(s[i].second < m - sum){
            ans += s[i].first * s[i].second;
            sum += s[i].second;
        }else{
            ans += (m - sum) * s[i].first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
package main

import (
	"bufio"
	"fmt"
	"os"
)

type cell struct {
	tate int
	yoko int
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func rs() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	ar := make([]string, h)
	for i := range ar {
		ar[i] = rs()
	}
	br := make([][]cell, h)
	for i := range br {
		br[i] = make([]cell, w)
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if ar[i][j] == '#' {
				continue
			}
			if br[i][j].yoko == 0 {
				yoko := 1
				for k := j + 1; k < w; k++ {
					if ar[i][k] == '#' {
						break
					}
					yoko++
				}
				for k := j; k < w; k++ {
					if ar[i][k] == '#' {
						break
					}
					br[i][k].yoko = yoko
				}
			}
			if br[i][j].tate == 0 {
				tate := 1
				for k := i + 1; k < h; k++ {
					if ar[k][j] == '#' {
						break
					}
					tate++
				}
				for k := i; k < h; k++ {
					if ar[k][j] == '#' {
						break
					}
					br[k][j].tate = tate
				}
			}
		}
	}
	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if ar[i][j] == '#' {
				continue
			}
			if ans < br[i][j].yoko+br[i][j].tate {
				ans = br[i][j].yoko + br[i][j].tate
			}
		}
	}
	if ans == 0 {
		fmt.Println(ans)
		return
	}
	fmt.Println(ans - 1)
}


Measured memory_bytes: 71168
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cum_a = []
total = 0
for i in range(n):
  total += a[i]
  if total > k:
    break
  cum_a.append(total)
  
cum_b = []
total = 0
for j in range(m):
  total += b[j]
  if total > k:
    break
  cum_b.append(total)
lim_a = len(cum_a)
lim_b = len(cum_b)
idx = 0
ans = lim_a
for l in range(1, lim_a + 1):
  while idx < lim_b:
    if k >= cum_a[-l] + cum_b[idx]:
      ans = max(ans, lim_a - l + idx + 2)
    else:
      break
    idx += 1
ans = max(ans, lim_b)
print(ans)


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

using namespace std;

#define maxn 200005
#define ll long long int
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<<endl
#define IN freopen("input.txt","r",stdin)

const int N = (int)1e5+5;
int deg[N];
vector< pair< int , int >  > g[N];
int ans[N];
int mx = -1;
int n;
set< int > S;

void dfs(int src, int par , int prev){
    int sz = g[src].size();
    map < int , bool > M;
    M[prev] = 1;
    int pos = 1;
    for(auto to : g[src]){
        int v = to.first;
        int idx = to.second;
        if(v==par){ continue ;}
        int lol = -1;
        for(int i = pos; i <= mx; i++){
            if(M.find(i)==M.end()){
                M[ i ] = 1;
                lol = i; break;
            }
        }
        ans[ idx ] = lol;
        pos = lol;
        dfs(v,src,lol);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    cin >> n;
    for(int i = 1; i < n; i++){
        int u , v;
        cin >> u >> v;
        g[u].push_back({v,i});
        g[v].push_back({u,i});
        deg[u]++;
        deg[v]++;
        mx = max(mx,deg[u]);
        mx = max(mx,deg[v]);
    }
    for(int i = 1; i <= mx; i++){
        S.insert(i);
    }
    dfs(1,-1,0);
    cout<< mx << endl;
    for(int i = 1 ; i < n; i++){
        cout<< ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 20480
s=input()
x,y=map(int, input().split())
X,Y=[],[]
t,c=0,0
for i in range(len(s)):
  if s[i]=='F':
    c+=1
  else:
    if t%2==0:
      X.append(c)
    else:
      Y.append(c)
    c=0
    t+=1
if t%2==0:
  X.append(c)
else:
  Y.append(c)
if len(X)>0:
  D=[X[0]]
  E=[]
  for i in range(1,len(X)):
    for j in D:
      E.append(j+X[i])
      E.append(j-X[i])
    D,E=list(set(E)),[]
if x not in D:
  print('No')
  exit()
  
if len(X)>0:
  D=[0]
  E=[]
  for i in range(len(Y)):
    for j in D:
      E.append(j+Y[i])
      E.append(j-Y[i])
    D,E=list(set(E)),[]
if y not in D:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 84196
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int n;
  cin >> n;
  if (n <= 999) cout << "ABC";
  else cout << "ABD";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int
main ()
{
  int n, m;
  cin >> n >> m;
  if (n == 1)
    {
      n = 14;
    }
  if (m == 1)
    {
      m = 14;
    }
  if (n == m)
    {
      cout << "Draw";
    }
  else if (n < m)
    {
      cout << "Bob";
    }
  else
    {
      cout << "Alice";
    }
  return 0;
}

Measured memory_bytes: 3640
IDENTIFICATION  DIVISION.
PROGRAM-ID.     MAIN.
ENVIRONMENT     DIVISION.
DATA            DIVISION.
WORKING-STORAGE  SECTION.
01 STR        PIC 99.
01 ANS		  PIC 99.
      
PROCEDURE DIVISION.

ACCEPT STR.
COMPUTE ANS = 48 - STR.
DISPLAY ANS.
STOP RUN.

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

int main(){
    int n;
    ll k;
    ll a[100005];
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    int zero[70];
    int one[70];
    int keta=0;//0,1は0桁
    ll dketame[70]={0};
    while(k>0){
        dketame[keta]=k%2;
        k/=2;
        if(k>0) keta++;
    }
    for(int i=0;i<51;i++){
        for(int j=0;j<n;j++){
            
            if(a[j]%2==0) zero[i]++;
            else one[i]++;
            a[j]/=2;
        }
    }
    ll res=0;
    for(int d=40;d>=-1;d--){
        if(d!=-1 && dketame[d]==0) continue;
        
        ll tmp=0;
        
        for(int i=0;i<40;i++){
            ll mask=1LL<<i;
            if(i<d){
                tmp+=max(zero[i],one[i])*pow(2,i);
            }
            else if(i==d){
                tmp+=one[i]*mask;
            }
            else{
                if(dketame[i]==1) tmp+=zero[i]*mask;
                else tmp+=one[i]*mask;
            }
        }
        res=max(res,tmp);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
import Data.List

main = interact $ unlines . map drawing_lots_2 . read' . lines
 where
  read' ["0"] = []
  read' (n:m:s:d:xs) = (read n, read m, read s, read d, map obstruct (take (read d) xs)) : read' (drop (read d) xs)
  obstruct line = "0" ++ line ++ "0"

drawing_lots_2 (n,m,s,d,amida)
 | reachable m s amida = "0"
 | null right_draws = "1"
 | otherwise = let (l,c) = head right_draws in show l ++ " " ++ show c
 where
  right_draws = [(l,c)| l<-[1..d], c<-[1..(n-1)], reachable m s (draw (l,c) amida),
                        amida!!(l-1)!!(c-1)=='0', amida!!(l-1)!!c=='0', amida!!(l-1)!!(c+1)=='0']
  draw (l,c) amida = take (l-1) amida ++ [update (amida!!(l-1))] ++ drop l amida
   where update line = take c line ++ "1" ++ drop (c+1) line

reachable top bot amida = pursue amida top == bot
 where
  pursue [] col = col
  pursue (l:ls) col
   | l !! col     == '1' = pursue ls (col+1)
   | l !! (col-1) == '1' = pursue ls (col-1)
   | otherwise = pursue ls col

Measured memory_bytes: 4140
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
typedef unsigned long long ull;
using namespace std;
typedef pair<ll, ll>P;

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
struct people { ll v, k, year; };
bool comp(const etree& e1, const etree& e2) {
	return e1.cost < e2.cost;
}
bool comp2(const people& e1, const people& e2) {
	return e1.year < e2.year;
}
#define ALL(x) (x).begin(),(x).end()

int main() {
	ll n, a[200010], itr[200010], ans = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		itr[a[i] - 1] = i;
	}
	set<ll>se;
	se.insert(-1);
	se.insert(n);
	for (int i = 0;i < n;i++) {
		auto it = se.lower_bound(itr[i]);
		ll r = (*it) - itr[i];
		it--;
		ll l = itr[i] - (*it);
		ans += a[itr[i]] * l*r;
		se.insert(itr[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

ll peta[2003];

int main () {
	ll x;
	cin>>x;
	for(ll i=-1000ll;i<=1000ll;i++){
		peta[i+1000]=i*i*i*i*i;
	}
	for(ll i=1ll;i<=2000ll;i++){
		for(ll j=0ll;j<i;j++){
			if(peta[i]-peta[j]==x){
				cout<<i-1000<<" "<<j-1000;
				return 0;
			}
		}
	}
	



return 0;
}



Measured memory_bytes: 3636
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [float('inf')]*len(a)
dp[0] = 0
for i in range(len(a)):
    for j in range(i+1, min(i+k+1, len(a))):
        dp[j] = min(dp[j], dp[i] + abs(a[j] - a[i]))
print(dp[-1])

Measured memory_bytes: 55008
from numba import njit,prange


@njit(parallel=True)
def solve(n,x,y):
    ans = [0] * (n - 1)
    for i in prange(n):
        for j in prange(n):
            c = min(abs(i - j), abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1)
            if c:
                ans[c-1] += 1
    return ans


n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = solve(n,x,y)
for ai in ans:
    print(ai//2)


Measured memory_bytes: 112176
a,b,c = map(int,input().split())

if a%2 == 1 or b%2 == 1 or c%2 == 1:
    print(0)
    exit()

if a == b == c:
    print(-1)
    exit()

count = 0

while True:
    count += 1
    a,b,c = b//2+c//2,a//2+c//2,a//2+b//2
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
        break

print(count)

Measured memory_bytes: 3064
# A
S = input()
cnt = 0
B_cnt = 0
ans = 0
for s in reversed(S):
    # print(s)
    if s == "B":
        ans += (cnt - B_cnt)
        B_cnt += 1
    cnt += 1
    # print("B_cnt: " + str(B_cnt))
    # print("Cnt:" + str(cnt))
print(ans)


Measured memory_bytes: 9252
using System;
using System.Linq;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

                if (inputs.All(x => x == 0))
                {
                    goto Finish;
                }

                var height = inputs[0];
                var width = inputs[1];

                for (int i = 0; i < height; i++)
                {
                    if (i == 0 || i + 1 == height)
                    {
                        for (int j = 0; j < width; j++)
                        {
                            Console.Write("#");
                        }
                    }
                    else
                    {
                        Console.Write($"#{new string('.',width-2)}#");
                    }

                    Console.WriteLine();
                }

                Console.WriteLine();
            }

            Finish:
            return;
        }
    }
}



Measured memory_bytes: 16248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int x;
  cin>>x;
  x/=100;
  x-=4;
  x/=2;
  cout<<8-x<<endl;
}
  

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N, K; cin>>N>>K;
    vec_int A(N+1);
    for(int i=0;i<N;i++){
        cin>>A.at(i+1);
    }


    for(int i=K+1;i<=N;i++){
        //つまるところ、i-Kとi学期のどっちの点数が高かったかを比べればよい
        if(A.at(i)>A.at(i-K)){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }

    }

    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define mci       	  map<char,int>  	
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define pii           pair<int ,int >
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN   		  1000000
#define f(n) for(int i=0;i<n;i++)
using namespace std;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int a,b,c;
  cin>>a>>b>>c;
  int d=c-(a-b);
  if(d<=0)
    cout<<"0";
  else
    cout<<d;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2005;
ll n,x;
ll a[maxn],dp[maxn][maxn];
int main(){
	scanf("%lld%lld",&n,&x);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		dp[i][0] = a[i];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<n;j++){
			ll t = i-j;
			if(t<=0)
				t = t+n;
			dp[i][j] = min(dp[i][j-1],a[t]);
		}
	ll ans = 1e18;
	for(int i=0;i<n;i++){
		ll sum = 0;
		for(int j=1;j<=n;j++)
			sum += dp[j][i];
		ans = min(ans,x*i+sum);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31616
import math
A,B=map(int,input().split())

am=math.ceil(A/0.08)
bm=math.ceil(B/0.1)
aM=math.ceil((A+1)/0.08)-1
bM=math.ceil((B+1)/0.1)-1
if max(am,bm)>min(aM,bM):
    print(-1)
else:
    print(max(am,bm))

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

#define N 10000

int isPrime(int x){
  int i;

  if(x==2) {return 1;}

  if(x<2 || x%2==0){ return 0;}

  i=3;

  while(i<=sqrt(x)){

    if(x%i==0) return 0;

    i=i+2;
  
  }
    return 1;
}

int main(){

  int i,n,a[N],count=0,s;

  scanf("%d",&n);

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

    scanf("%d",&a[i]);
  
    s=isPrime(a[i]);

    if(s==1) count++;

    }

  printf("%d\n",count);

  return 0;
}

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

class Program
{
	static void Main(string[] args)
	{			
		//文字列を読み込む
		int[] line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
		int N = line[0];
		int K = line[1];
		int[] Pk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
		
		//最大値をとインデックスを格納する変数
		double sum = 0;
		double max = -1;
		
		for(int i=0; i<N; i++){
				sum += Pk[i];
				if(i >= K){
						sum -= Pk[i-K];
				}
				if(sum > max){
						max = sum;
				}
		}
		
		/*
		サイコロの目nに対する期待値は(n+1)/2（= n/2 + 1/2）である。
		よって、期待値の合計は、max/2 + K/2（＝(max-K)/2 + K）になっている。
		可能な限り除算の回数を減らす。
		*/
		double answer = K + (max - K)/2;
		
		//出力
		Console.WriteLine(answer);

	}
}

Measured memory_bytes: 33116
var
  s:ansistring;
  i,l,sc,sf:longint; 
begin
  read(s);
  l:=length(s);
  sc:=maxlongint;
  for i:=1 to l do
    if s[i]='F'then sf:=i;
  for i:=l downto 1 do
    if s[i]='C'then sc:=i;
  if sc<sf then writeln('Yes')
           else writeln('No');
end.

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (r, g, b) = scan!(i64, i64, i64);
    if (r * 100 + g * 10 + b) % 4 == 0 {
        println!("YES")
    } else {
        println!("NO")
    }
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	A, B := sc.nextInt(), sc.nextInt()
	sum := A + B
	if (sum)%2 == 0 {
		fmt.Println(sum / 2)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    for(int i = 1; i <= k; i++){
        if(i % 2)
            b += a / 2, a /= 2;
        else
            a += b / 2, b /= 2;

    }

    cout << a << ' ' << b << '\n';
    return 0;
}


Measured memory_bytes: 256
from sys import exit

n, m = map(int, input().split())
s = [0]*m
c = [0]*m
for i in range(m):
  s[i], c[i] = map(int, input().split())
  
for i in range(1000):
  if len(str(i)) != n:
    continue
  f = True
  for j in range(m):
    if int(str(i)[s[j]-1]) != c[j]:
      f = False
  if f:
    print(i)
    exit(0)
  
print(-1)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {
	int X, Y;
	int kame, turu;
	bool flag = false;

	cin >> X >> Y;

	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			turu = i;
			kame = j;
			if (i * 2 + j * 4 == Y && i + j == X) {
				flag = true;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
/*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
stack push pop top
queue push pop front
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  vector<int> a(5);
  REP(i,5) cin >> a[i];
  sort(ALL(a),greater<int>());
  REP(i,5) printf("%d%s",a[i],(i==4)?"\n":" ");
  return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int a,b;
int main()
{
    int c,d,e,f,g,h,i,n,z,sum=0;
    scanf("%d%d%d",&z,&a,&b);
    for(n=1;n<=z;n++)
    {


    if(n<10)
    {

            g=n;
    }
    else if(n>=100&&n<1000)
    {
        c=n%10;d=n/10;e=d%10;f=d/10;
        g=c+e+f;


    }
    else if(n>=10&&n<100)
    {
        c=n%10; d=n/10;
        g=c+d;

    }
    else if(n>=1000&&n<10000)
    {
        c=n%10; d=n/10; e=d%10; f=d/10; h=f%10; i=f/10;
        g=c+e+h+i;

    }
    else if(n==10000)
    {
        g=1;
    }
    if(g>=a&&g<=b) sum=sum+n;


    }
    printf("%d",sum);

}

Measured memory_bytes: 128
def geti; gets.to_i end
def getis; gets.split.map &:to_i end
def getin n;  n.times.map{geti}  end
def getisn n; n.times.map{getis} end
YES = "YES"; NO = "NO"; Yes = "Yes"; No = "No";

n,a,b=getis
puts (1..n).select{|s| c=s.to_s.chars.map(&:to_i).reduce(:+); a<=c&&c<=b }.reduce(:+)

__END__
a,b,c,d=getis
puts %w(Balanced Left Right)[a+b<=>c+d]

puts (gets.sub(?\s,'').to_i**0.5)%1==0? "Yes" : "No"

a,b=getis
puts a*b%2==0? "Even" : "Odd"


Measured memory_bytes: 1916
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let hs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let ans = ref max_int
let _ = Array.sort (-) hs; for i = 0 to n - k do ans := min !ans @@ hs.(k + i - 1) - hs.(i) done; Printf.printf "%d\n" !ans

Measured memory_bytes: 5248
#include<stdio.h>
#include<string.h>

int max(int a,int b){
  if(a > b)return a;
  else return b;
}

int lcs(char s1[],char s2[],int m,int n){
  int c[1001][1001];
  int i,j;
  int maxl = 0;

  for(i=1;i<=m;i++){
    c[i][0] = 0;
  }
  for(j=1;j<=n;j++){
    c[0][j] = 0;
  }

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(s1[i-1] == s2[j-1]){
        c[i][j] = c[i-1][j-1] + 1;
      }else{
        c[i][j] = max(c[i-1][j],c[i][j-1]);
      }
      maxl = max(maxl,c[i][j]);
    }
  }

  return maxl;
}


int main(){
  int n;
  int i;
  char s1[1001],s2[1001];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",lcs(s1,s2,strlen(s1),strlen(s2)));
  }
  return 0;
}



Measured memory_bytes: 5700
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
struct fix_point: private T {
  explicit constexpr fix_point(T &&func): T(std::forward<T>(func)) { }
  template <class... Args>
  constexpr decltype(auto) operator () (Args &&... args) const {
    return T::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class T>
constexpr decltype(auto) make_fix_point(T &&func) {
  return fix_point<T>{std::forward<T>(func)};
}

int main() {
  int N;
  std::cin >> N;
  std::vector<std::vector<int>> graph(N);
  for (int i: range(0, N - 1)) {
    int x, y;
    std::cin >> x >> y;
    --x; --y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  bool answer = true;
  if (make_fix_point([&](auto &&dfs, int u, int p) -> bool {
    int count = 0;
    for (int v: graph[u]) {
      if (v != p) {
        if (dfs(v, u)) {
          ++count;
        }
      }
    }
    if (count >= 2) {
      answer = false;
    }
    return count == 0;
  })(0, -1)) {
    answer = false;
  }
  std::cout << (answer ? "Second" : "First") << '\n';
  return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>
int main(){
  int S, h, m, s;
  scanf("%d", &S);
  h = S / 3600;
  m = (S % 3600) / 60;
  s = S % 60;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll choose(ll a) {
	return a * (a - 1) / 2;
}

void solve() {
	int n;
	cin >> n;
	vector<string> v(n);
	rep(i,n) cin >> v[i];
	vector<vector<int>> u(n, vector<int>(26));
	rep(i,n) {
		string s = v[i];
		rep(j,10) {
			u[i][(s[j] - 'a')]++;
		}
	}
	ll ans = 0;
	map<vector<int>, int> mp;
	for (int i = 0; i < n; i++) {
		mp[u[i]]++;
	}
	for (auto p: mp) {
		if (p.second <= 1) continue;
		ans += choose(p.second);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 38264
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(x+r>0){
		if(y+r>0){
			if(W>=x+r){
				if(H>=y+r){
					printf("Yes\n");
				}
				else{
					printf("No\n");
				}
			}
			else{
				printf("No\n");
			}
		}
		else{
			printf("No\n");
			}
	}
	else{
		printf("No\n");
	}
			

	
	return 0;
}

Measured memory_bytes: 584
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.math.BigInteger;
    
public class Main{

static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;

public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
HashMap<String,String> map=new HashMap<String,String>();
while(true){
int n=ir.nextInt();
if(n==0) break;
StringBuilder sb=new StringBuilder();
while(n-->0) map.put(ir.next(),ir.next());
int m=ir.nextInt();
while(m-->0){
String str=ir.next();
sb.append((map.containsKey(str))?map.get(str):str);
}
out.println(sb.toString());
map.clear();
}
out.flush();
}

static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;

public InputReader(InputStream in) {this.in=in;}
  
public int readByte() {
if(lenbuf==-1) throw new InputMismatchException();
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}
catch (IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0)
return -1;
}
return buffer[curbuf++];
}

public boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;}

public String next() {
int b=skip();
StringBuilder sb=new StringBuilder();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
 
public int nextInt() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public long nextLong() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public int[] toIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
}
}

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

using namespace std;

#define il inline
#define re register int
#define Rep(i, s, e) for (re i = s; i <= e; ++i)
#define Dep(i, s, e) for (re i - s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout);

il int read() {
	int x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}

int n, k, p[200010], nMin, tp;
double ans;
int main() {
	n = read(), k = read();
	Rep(i, 1, k) {
		p[i] = read(), tp += p[i];
	}
	nMin = tp, ans = 0.5 * (nMin + k);
	Rep(i, k + 1, n) {
		p[i] = read(), tp = tp - p[i - k] + p[i];
		if (tp > nMin) nMin = tp, ans = 0.5 * (1.0 * tp + k);
	}
	return printf("%lf", ans) & 0;
}

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

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, X;
    cin >> N >> X;
    map<pair<int, int>, vector<long long>> mem;
    long long prime = 1000000007;
    auto mod = [&](long long x) {
        return (x % prime + prime) % prime;
    };
    function<vector<long long> (int, int)> calc = [&](int n, int k) {
        if (k > n || k < 0) {
            return vector<long long>{};
        }
        if (mem.find(make_pair(n, k)) != mem.end()) {
            return mem.find(make_pair(n, k))->second;
        }
        if (n == 1) {
            return k == 0 ? vector<long long>{1LL} : vector<long long>{0LL, 0LL, 1LL};
        }
        // cases:
        // (1) n goes to n+1. n+1 goes to n. (k*k possibilities. recurse on k-1 and add 2*k)
        // (2) n goes to n+1. n+1 does not go to n. (k possibilities. recurse on k and add 2*k)
        // (3) n goes to itself. (1 possibility. recurse on k and add 2*k)
        // (4) n goes to < n. n+1 goes to n. (k possibilities. recurse on k and add 2*k)
        // (5) n goes to < n. n+1 does no go to n. (1 possibility. recurse on k+1 and add 2*k)
        // note that case (1), (2) and (4) are not possible if k = 0.
        vector<pair<vector<long long>, int>> cs = {make_pair(calc(n-1, k-1), k*k), make_pair(calc(n-1, k), 2*k+1), make_pair(calc(n-1, k+1), 1)};
        // In these three cases we use the recursive result and add (1) 1 + 1*(k-1), (2) 0 + k, (3) k. They are all k.
        int max_length = 0;
        for (auto& c : cs) {
            max_length = max(max_length, (int) c.first.size());
        }
        vector<long long> result(max_length+2*k, 0LL);
        for (auto& c : cs) {
            for (int i = 0; i < c.first.size(); ++i) {
                result[i+2*k] = mod(result[i+2*k] + c.first[i] * c.second);
            }
        }
        return mem[make_pair(n, k)] = result;
    };
    auto res = calc(N, 0);
    if (res.size() > X) {
        cout << res[X] << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3840