akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int n,a[200000],r,t[200000],i;
long long k,q;
int main(){
    scanf("%d%lld",&n,&k);
    for(i=0;i<n;i++){scanf("%d",&a[i]);t[i]=-1;}
    r=1;
    i=0;
    while(t[r-1]==-1){
        t[r-1]=i++;
        r=a[r-1];
    }
    if(k<i)q=k;
    else q=(k-t[r-1])%(i-t[r-1])+t[r-1];
    for(i=0;i<n;i++)if(t[i]==q)break;
    printf("%d",i+1);
    return 0;
}

Measured memory_bytes: 3272
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
cmd = [[-1,0],[1,0],[0,1],[0,-1]]
h,w = map(int,input().split())
Map = [["#"]*(w+2)]
for _ in range(h):
    s = ["#"]+list(input())[:-1]+["#"]
    Map.append(s)
Map.append(["#"]*(w+2))
MAX = 0
for sx in range(1,w+1):
    for sy in range(1,h+1):
        p = 0
        if Map[sy][sx] == "#":
            continue
        q = deque([[sx,sy]])
        visidat = [[0]*(w+2) for _ in range(h+2)]
        while len(q) != 0:
            x,y = q.popleft()
            for cx,cy in cmd:
                newx = x + cx
                newy = y + cy
                if Map[newy][newx] == "#" or(newx ==sx and newy == sy):
                    continue
                else: 
                    if visidat[newy][newx] == 0:
                        visidat[newy][newx] += visidat[y][x] + 1
                        if p < visidat[newy][newx]:
                            p = visidat[newy][newx]
                        q.append([newx,newy])
        MAX = max(MAX,p)
print(MAX)

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

string S, T;

bool match(int k){

	REP(i,T.length()){
		if(S[i+k] == T[i] or S[i+k] == '?') continue;
		else return false;
	}

	return true;

}


int main(void){


	cin >> S >> T;

	int N = S.length() - T.length();
	int idx = -1;
	REP(i,N+1){
		if(match(i) == true) idx = i;
	}

	if(idx == -1){
		cout << "UNRESTORABLE" << endl;
	}else{
		REP(i,S.length()){
			if(i < idx){
				if(S[i] == '?') cout << 'a';
				else cout << S[i];
			}else if(i < idx + T.length()) cout << T[i-idx];
			else{
				if(S[i] == '?') cout << 'a';
				else cout << S[i];
			}
		}
		cout << endl;
	}






	return 0;

}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;

// ABC132-C

int main() {

    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N){
        cin >> d[i];
    }
    sort(d.begin(),d.end());

    int a = d[N/2-1];
    int b = d[N/2];

    cout << b-a << endl;

    return 0;
}


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

typedef long long ll;

const int MAX_N = 1010;
char grid[MAX_N][MAX_N];
bool visited[MAX_N][MAX_N];
int goals[11][2];
int h, w, n;

typedef pair<int,int> P;

int dir[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
int bfs(int sx, int sy, int ex, int ey) {
    queue<P> que;
    visited[sx][sy] = true;
    que.push(P(sx, sy));
    int step = 0;
    while(!que.empty()) {
        for(int size = que.size(); size ; size--) {
            P cur = que.front(); que.pop();
            int x = cur.first, y = cur.second;
            if(x == ex && y == ey) return step;
            for(int i = 0; i < 4; i++) {
                int nx = x + dir[i][0], ny = y + dir[i][1];
                if(nx >= 0 && nx < h && ny >= 0 && ny < w && grid[nx][ny] != 'X' && !visited[nx][ny]) {
                    visited[nx][ny] = true;
                    que.push(P(nx, ny));
                }
            }
        }
        step++;
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w >> n;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> grid[i][j];
            if(grid[i][j] == 'S') {
                goals[0][0] = i;
                goals[0][1] = j;
            }
            if(grid[i][j] >= '1' && grid[i][j] <= '9') {
               goals[grid[i][j] - '0'][0] = i;
               goals[grid[i][j] - '0'][1] = j;
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        memset(visited, false, sizeof(visited));
        ans += bfs(goals[i-1][0], goals[i-1][1], goals[i][0], goals[i][1]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5156
using System;
using System.Collections.Generic;
using System.Text;

namespace codeTester.todayProblem
{
    class ABC062C
    {
        static List<long> hw = new List<long>();
        static long answer = 0;

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            hw = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            long h = hw[0];
            long w = hw[1];
            long hMod3 = h % 3;
            long wMod3 = w % 3;
            if (hMod3 == 0 || wMod3 == 0)
            {
                answer = 0;
                return;
            }
            answer = Math.Min(compromise(h, w), compromise(w, h));
        }

        /*
         * サイズ差が戻り値
         */
        static long compromise(long longer, long shorter)
        {
            long firstCutoutLength = longer % 3 == 2 ? (longer / 3 + 1) : (longer / 3);
            long firstPieceSize = firstCutoutLength * shorter;
            long remainLength = longer - firstCutoutLength;
            
            // 残りは正確に半分にできるならそれがベスト
            if (shorter % 2 == 0 || remainLength % 2 == 0)
            {
                return Math.Abs(firstPieceSize - (remainLength * shorter) / 2);
            }
            LogRectangle(1, firstCutoutLength, shorter);
            return compromise2(firstPieceSize, Math.Max(shorter, remainLength), Math.Min(shorter, remainLength));
        }

        static long compromise2(long firstPieceSize, long longer, long shorter)
        {
            long halfLonger = longer / 2;
            long secondPieceSize = halfLonger * shorter;
            long thirdPieceSize = (halfLonger + 1) * shorter;

            long diff12 = Math.Abs(firstPieceSize - secondPieceSize);
            long diff13 = Math.Abs(firstPieceSize - thirdPieceSize);
            long diff23 = Math.Abs(secondPieceSize - thirdPieceSize);

            return Math.Max(diff12, Math.Max(diff13, diff23));
        }


        static void Output()
        {
            Console.WriteLine(answer.ToString());
        }

        static void DebugPrint(string msg)
        {
            // 提出時に消す
            // Console.WriteLine(msg);
        }

        static void LogRectangle(int id, long longer, long shorter)
        {
            DebugPrint(id.ToString() + " : " + longer.ToString()
                + " * " + shorter.ToString() + " = " + (longer * shorter).ToString());
        }
    }
}


Measured memory_bytes: 13268
import numpy as np
import scipy as sp

def main():
    # parse
    X, A, B = parse(get_stdin())
    # compute
    result = compute(X, A, B)
    # show result
    print(result)

def compute(X, A, B):
    if 0 >= B-A:
        return "delicious"
    elif X >= B-A:
        return "safe"
    else:
        return "dangerous"

def get_stdin():
    return input()

def split_stdin(stdin_val, delimiter = ' '):
    return [x for x in stdin_val.split(delimiter) if x != '']

def parse(stdin_vars):
    vars = split_stdin(stdin_vars)
    return int(vars[0]), int(vars[1]), int(vars[2])

if __name__ == "__main__":
    main()

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int max, min;
  max = min = a;
  if(b > a) max = b;
  else min = b;
  if(c > max) max = c;
  if(c < min) min = c;
  cout << max - min << endl;
  return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
for i in range(N):
    A = list(map(int, input().split()))
    sum = 0
    for a, b in zip(A, B):
        sum += a*b
    sum += C
    if sum > 0:
        cnt += 1
print(cnt)

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

int main(){
	string s1,s2;
	cin>>s1;
	cin>>s2;
	int n = s1.size();
	int count = 0;
	for(int i=0;i<n;i++){
		if(s1[i] != s2[i]){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3912
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] v = new double[n];
		for(int i = 0; i < n; i++){
			v[i] = sc.nextDouble();
		}
		Arrays.sort(v);
		double ans = (v[0]+v[1])/2;
		for(int i = 2; i < n; i++){
			ans = (ans+v[i])/2;
		}
		System.out.print(ans);
	}
}


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

class LCA{
public:
  typedef pair<int,int> P;
  int LOG_V;                          //log V (自分で決めて)
  int V;                              //頂点数
  vector<vector<P> > G;               //グラフの隣接リストの表現
  int root;                           //根のノード番号
  vector<vector<int> > parent;        //親を2^k回辿って到達する頂点(根を通りすぎる場合は-1とする)
  vector<int> depth;                  //根からの深さ
  vector<int> D;                      //根からの距離
  int ok;

  LCA():V(-1){}
  LCA(int V,int root = 0):V(V),G(V),root(root),depth(V), D(V, 0),ok(0){
    LOG_V = 1;
    int tmp = V;
    while(tmp) LOG_V++, tmp /= 2;
    parent.resize(LOG_V, vector<int>(V));
  }

  void add_edge(int a, int b,int c = 1){
    assert(a >= 0 && b >= 0);
    assert(a < V && b < V);
    G[a].push_back(P(b,c));
    G[b].push_back(P(a,c));
  }

  void dfs(int v,int p,int d,int c){
    assert(v < V);
    parent[0][v] = p;
    depth[v] = d;
    D[v] = c;
    for(auto to:G[v])
      if(to.first != p) dfs(to.first, v, d+1, c + to.second);
  }

  //vからn個上の祖先
  int getAnc(int v,int n){
    for(int k=0; k<LOG_V ;k++) if((v != -1) && (n>>k&1)) v=parent[k][v];
    return v;
  }

  //初期化
  void build(){
    ok = 1;
    //parent[0]とdepthを初期化する。
    dfs(root, -1, 0, 0);
    //parentを初期化する
    for(int k=0; k+1<LOG_V ;k++)
      for(int v=0; v<V ;v++)
        if(parent[k][v] < 0)parent[k+1][v] = -1;
        else parent[k+1][v] = parent[k][parent[k][v]];
  }

  //uとvのLCAを求める
  int get(int u,int v){
    assert(ok);
    assert(u >= 0 && v >= 0);
    assert(u < V && v < V);
    if(depth[u]>depth[v]) swap(u,v);
    v = getAnc(v, depth[v] - depth[u]);

    if(u==v) return u;
    //二分探索でLCAを求める
    for(int k=LOG_V-1; k>=0 ;k--)
      if(parent[k][u] != parent[k][v]){
        u = parent[k][u];
        v = parent[k][v];
      }
    return parent[0][u];
  }

  int getDis(int u,int v){
    assert(u >= 0 && v >= 0);
    assert(u < V && v < V);
    return D[u] + D[v] - 2 * D[get(u, v)];
  }

  //rootを根としたときの頂点uの親: O(logV)
  int getParent(int u, int root = -1){
    if(root == -1) root = this->root;
    assert(0 <= u && u < V);
    assert(0 <= root && root < V);
    int num = depth[root] - depth[u];
    if(num > 0){
      int v = getAnc(root, num - 1);
      int p = parent[0][v];
      if(p == u) return v;
    }
    return parent[0][u];
  }
};

int main(){
  int n;
  cin>>n;
  LCA lca(n);

  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int c;
      cin>>c;
      lca.add_edge(i,c);
    }
  }

  lca.build();

  int q;
  cin>>q;
  while(q--){
    int u,v;
    cin>>u>>v;
    cout<<lca.get(u,v)<<endl;
  }
  return 0;
}



Measured memory_bytes: 19492
n = int(input())
h = list(map(int, input().split()))

f = [0 for i in range(n)]
for i in range(n - 2, -1, -1) :
    f[i] = 10 ** 10
    for j in range(1, 3) : 
        if (i + j < n) :
            f[i] = min(f[i], f[i + j] + abs(h[i] - h[i + j]))

print(f[0])


Measured memory_bytes: 13924
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
int INF = 1e9;

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  vector<vector<int>> dist(H+2,vector<int>(W+2,INF));
  vector<vector<char>> vec(H+2,vector<char>(W+2,'@'));
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      cin >> vec[i][j];
    }
  }
  
  vector<int> dx = {0,1,0,-1};
  vector<int> dy = {1,0,-1,0};
  P start = {x1,y1};
  queue<P> Q;
  Q.push(start);
  dist[x1][y1] = 0;
  while(Q.size()){
    P p = Q.front();
    Q.pop();
    int nx = p.first;
    int ny = p.second;
    for(int i=0; i<4; i++){
      for(int j=1; j<=K; j++){
        if(vec[nx + dx[i]*j][ny + dy[i]*j] == '@'){
          break;
        }
        else if(dist[nx + dx[i]*j][ny + dy[i]*j] <= dist[nx][ny]){
          break;
        }
        else if(dist[nx + dx[i]*j][ny + dy[i]*j] > dist[nx][ny] + 1){
          dist[nx + dx[i]*j][ny + dy[i]*j] = dist[nx][ny] + 1;
          P q = {nx + dx[i]*j, ny + dy[i]*j};
          Q.push(q);
        }
      }
    }
  }
  if(dist[x2][y2] == INF){
    dist[x2][y2] = -1;
  }
  cout << dist[x2][y2] << endl;
}
  

Measured memory_bytes: 18840
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













const int MA = 1000001;
int N, A[201010];
int cnt[1010101];
bool ok[1010101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	rep(i, 0, N) cnt[A[i]]++;
	rep(x, 1, MA) ok[x] = true;
	rep(x, 1, MA) if(0 < cnt[x]) {
		if (1 < cnt[x]) ok[x] = false;
		for (int x2 = x * 2; x2 < MA; x2 += x) ok[x2] = false;
	}

	int ans = 0;
	rep(i, 0, N) if (ok[A[i]]) ans++;
	cout << ans << endl;
}







Measured memory_bytes: 9264
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int getnum(int numbers[100]){
 
	char *tempo;
	char input[100];
 
	int i;
 
	fgets(input, sizeof(input), stdin);
	numbers[0] = atoi(strtok(input, " "));
	for (i = 1; i <= 100; i++){
		if ((tempo = strtok(NULL, " ")) != NULL){
			numbers[i] = atoi(tempo);
		}else{
			break;
		}
	}
	return (i - 1);
}
 
void BubSort(int numbers[100], int element){
 
	int tempo;
	int i;
	for (;element >= 1; element--){
		for (i = 1; i <= element; i++){
			if (numbers[i - 1] > numbers[i]){
				tempo = numbers[i - 1];
				numbers[i - 1] = numbers[i];
				numbers[i] = tempo;
			}
		}
	}
}
 
int main(void){
 
	int numbers[100];
	int element;
	int i;
 
	element = getnum(numbers);
	BubSort(numbers, element);
 
	for (i = 0; i <= (element - 1); i++){
		printf("%d ", numbers[i]);
	}
	printf("%d\n", numbers[element]);
 
	return 0;
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%i",&n);
	int a[n+1],b[n+1],c=0,d=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%i%i",&a[i],&b[i]);
		if(a[i]==b[i])
		{
			c++;
			if(c==3)
			{
				d=1;
			}
		}
		else
		{
			c=0;
		}
	}
	if(d==0)
	{
		printf("No");
	}
	else 	printf("Yes");
	return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m,vector<int>());
    vector<int> p(m);

    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            int S;
            cin >> S;
            s[i].push_back(S);
        }
    }
    rep(i,m) cin >> p[i];

    int ans=0;
    int bit=0;
    for(; bit<(1<<n); bit++){
        int cnt=0;
        rep(i,m){
            int cnton =0;
            rep(j,k[i]){
                int shift = s[i][j] -1;
                if(bit & (1<<shift)) cnton++;
            }
            if(cnton % 2 == p[i]) cnt++;
        }
        if(cnt==m) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s;
    cin >> s;

    char now = s[0];
    int ans = 0;
    rep (i, s.size())
    {
        if (now != s[i])
        {
            now = s[i];
            ++ans;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 512
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      long[] array = new long[n];
      for(int k = 0; k < n; k++){
         array[k] = Long.parseLong(st.nextToken());
      }
      
      if(n%2 == 0){
         long[][] dp = new long[n][2];
         
         for(int k = 0; k < n; k++) Arrays.fill(dp[k],Long.MIN_VALUE);
         dp[0][0] = array[0];
         dp[1][1] = array[1];
         
         for(int k = 0; k < n; k++){
            for(int j = 0; j < 2; j++){
               if(dp[k][j] == Long.MIN_VALUE) continue;
               
               //no skip
               if(k+2 < n){
                  dp[k+2][j] = Math.max(dp[k+2][j],dp[k][j] + array[k+2]);
               }
               //1 skip
               if(k+3 < n && j < 1){
                  dp[k+3][j+1] = Math.max(dp[k+3][j+1],dp[k][j] + array[k+3]);
               }
            }
         }
         
         long answer = Math.max(dp[n-2][0],dp[n-1][1]);
         
         out.println(answer);
      
      
      } else {
         
         long[][] dp = new long[n][3];
         
         for(int k = 0; k < n; k++) Arrays.fill(dp[k],Long.MIN_VALUE);
         dp[0][0] = array[0];
         dp[1][1] = array[1];
         dp[2][2] = array[2];
         
         for(int k = 0; k < n; k++){
            for(int j = 0; j < 3; j++){
               if(dp[k][j] == Long.MIN_VALUE) continue;
               
               //no skip
               if(k+2 < n){
                  dp[k+2][j] = Math.max(dp[k+2][j],dp[k][j] + array[k+2]);
               }
               //1 skip
               if(k+3 < n && j < 2){
                  dp[k+3][j+1] = Math.max(dp[k+3][j+1],dp[k][j] + array[k+3]);
               }
               //2 skip
               if(k+4 < n && j < 1){
                  dp[k+4][j+2] = Math.max(dp[k+4][j+2],dp[k][j] + array[k+4]);
               }
            }
         }
         
         long answer = Math.max(dp[n-3][0],dp[n-2][1]);
         answer = Math.max(answer,dp[n-1][2]);
         
         out.println(answer);
      
      }
      
      
      

      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 65568
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	int N;  //候補の数
	int T, A; //平均気温、平均気温の基準
	cin >> N;
	cin >> T >> A;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	vector<double> x(N);
	vector<double> a(N);
	for (int i = 0; i < N; i++) {
		x[i] = (double)T - (double)H[i] * 0.006;
	}
	double min = abs((double)A - x[0]);
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (min > abs((double)A - x[i])) {
			min = abs((double)A - x[i]);
			ans = i + 1;
		}
	}
	cout << ans << endl;
	getchar();
	getchar();

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string t, h;
    int m, ta=0, ha=0;
    
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> t >> h;
        if(t > h) ta += 3; 
        else if(h > t) ha += 3;
        else {ta += 1; ha += 1;}
    }
    cout << ta << " " << ha << endl;
    
    return 0;
    
}



Measured memory_bytes: 3124
num_=input()
op_=len(num_)-1
for i in range(2**op_):
  op=["-"]*op_
  for j in range(op_):
    if ((i>>j)&1):
      op[op_-1-j]="+"
  formula=""
  op.append("")
  for p_num,p_op in zip(num_,op):
    formula+=p_num+p_op
  if eval(formula)==7:
    print(formula+"=7")
    break


Measured memory_bytes: 9008
N,C,K=gets.chomp.split.map(&:to_i)
t = []
N.times { t << gets.to_i }
t.sort!

i=0
ans = 0
while(i<N)
    m = t[i] + K
    j = 0
    while(i+j < N && m >= t[i+j] && j < C)
        j += 1
    end
    i = i + j
    ans += 1
end

puts ans

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-7
using namespace std;

#define MAX 100005
#define NIL -1
struct Node { int l, r, p; };
Node T[MAX];
int n, u, r, l;
void Pre(int u) {
	if (u == -1) return;
	printf(" %d", u);
	Pre(T[u].l);
	Pre(T[u].r);
}
void In(int u) {
	if (u == -1) return;
	In(T[u].l);
	printf(" %d", u);
	In(T[u].r);
}
void Post(int u) {
	if (u == -1) return;
	Post(T[u].l);
	Post(T[u].r);
	printf(" %d", u);
}
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) T[i].p = T[i].l = T[i].r = -1;
	for (int i = 0; i < n; ++i) {
		cin >> u >> l >> r;
		T[u].l = l, T[u].r = r;
		T[l].p = u, T[r].p = u;
	}
	int root;
	for (int i = 0; i < n; ++i) if (T[i].p == -1) root = i;
	cout << "Preorder" << endl;
	Pre(root);
	cout << endl;
	cout << "Inorder" << endl;
	In(root);
	cout << endl;
	cout << "Postorder" << endl;
	Post(root);
	cout << endl;
}


Measured memory_bytes: 3212
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int n,tot,a[300];
ll d[300][90001];
ll go(int N,int sum)
{
	if(N==n)
	{
		if(sum*2>=tot)return 3;
		else return 0;
	}
	ll &ret=d[N][sum];
	if(~ret)return ret;
	ret=0;
	ret=(ret+go(N+1,sum+a[N]))%MOD;
	ret=(ret+2*go(N+1,sum))%MOD;
	return ret;
}
ll go2(int N,int sum)
{
	if(N==n)
	{
		if(sum*2==tot)return 3;
		else return 0;
	}
	ll &ret=d[N][sum];
	if(~ret)return ret;
	ret=0;
	ret=(ret+go2(N+1,sum+a[N]))%MOD;
	ret=(ret+go2(N+1,sum))%MOD;
	return ret;
}
int main(){
	MEM_1(d);
	scanf("%d",&n);
	fup(i,0,n-1,1)scanf("%d",a+i);
	tot=accumulate(a,a+n,0);
	ll ans=1;
	fup(i,1,n,1)ans=(ans*3)%MOD;
	ans-=go(0,0);
	MEM_1(d);
	ans=(ans+go2(0,0))%MOD;
	if(ans<0)ans+=MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 211200
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    string s[n] = {};
    int d[n][m];
    memset(d,-1,sizeof(d));
    queue<pair<int,int>>q;
    f(n) {
        cin >> s[i];
        fr(j,0,m) {
            if (s[i][j]=='#') {
                q.push({i,j});
                d[i][j] = 0;
            }
        }
    }
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    while (!q.empty()) {
        auto now = q.front();
        q.pop();
        f(4) {
            int nx = now.F + dx[i];
            int ny = now.S + dy[i];
            if (nx >= n || nx < 0 || ny >= m || ny < 0)continue;
            if (~d[nx][ny])continue;
            q.push({nx,ny});
            d[nx][ny] = d[now.F][now.S] + 1;
        }
    }
    int mx = 0;
    f(n){
        fr(j,0,m){
            mx = max(mx,d[i][j]);
        }
    }
    cout << mx << '\n';
}


Measured memory_bytes: 13456
#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>;

void Main()
{
    string s;
    cin >> s;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
        cout << 3 << endl;
    } else if (s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R') {
        cout << 2 << endl;
    } else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////
 
 
int main(){
    
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll ans=0;
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            ans+=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


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

using namespace std;

int main()
{
	int n;
  	cin>>n;
  	if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9)
    {
      	cout<<"hon";
      	return 0;
    }
  	if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8)
    {
      	cout<<"pon";
      	return 0;
    }
  	cout<<"bon";
    return 0;
}   
  
      

Measured memory_bytes: 3620
def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b%a, a)
def lcm(a, b):
    return a*b//gcd(a, b)
while 1:
    try:
        a,b = map(int, input().split(" "))
        print(gcd(a, b),lcm(a, b))
    except:
        break


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

int main() {
    ll n;
    cin >> n;

    ll ans = 0;

    ll a;
    for (int i=0; i<n; i++) {
        cin >> a;
        if (i%2 == 0) {
            if (a%2 == 1) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 1e5 + 5, M = 1e9 + 7;
ll ans;
ll sum(ll n)
{
    return ((n * (n + 1)) >> 1) % M;
}
ll zabat(ll a)
{
    return ((a % M) + M) % M;
}
ll sub(ll a, ll b)
{
    a = zabat(a);
    b = zabat(b);
    return zabat(a - b);
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, k, big, small;
    cin >> n >> k;
    for(ll i = k;i <= n + 1;++i)
    {
        big = sum(n) - sum(n - i);
        small = sum(i - 1);
        ans += sub(big, small);
        ++ans;
        ans %= M;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <map>
using namespace std;

typedef long long ll;
ll n, m, a, k, ans;
map<ll, ll> mp={{0,1}};
int main() {
	scanf("%lld%lld", &n, &m);
	while(n--) {
		scanf("%lld", &a);
		k = (k+a) % m;
		ans += mp[k]++;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4224
//
// Created by TakahiroYamaji on 2020/08/02.
//
#include<iostream>
#include<cmath>
typedef long long ll;
int N;
ll K;
ll A[2000000];
using namespace std;
bool C(double d){
    ll res = 0;
    for (int i=0;i<N;i++){
        ll item = A[i] / d;
        res += item;
        double rest = A[i] - d * item;
        //std::cout << rest << endl;
        if (rest != 0){
            res++;
        }
    }
    //std::cout << res << endl;
    return res <= N+K;
}

int main(){
    cin >> N >> K;
    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    double start = 0;
    double end = 1e10;
    for (int i=0;i<100;i++){
        //std::cout << start << " " << end << endl;
        double mid = (start + end) / 2;
        if (C(mid)) end = mid;
        else start = mid;
    }
    ll ans = ceil(start);
    cout << ans << endl;
}



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

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

    ll mi = min({A, B, C, D, E});
    cout << (N + mi - 1) / mi + 4 << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long int N, blue, red;
    long long int amari, num_b, num_full_set, nokori;
    
    scanf("%lld %lld %lld", &N, &blue, &red);
    
    if(blue+red<=0){
        printf("%d", 0);
        return 0;
    }
    
    amari = N%(blue+red);
    num_full_set = N/(blue+red);
    nokori = N-(num_full_set*(blue+red));
   
    if(amari==0){
        num_b = num_full_set*blue;
    }else{
        if (nokori>=blue) {
            num_b = (num_full_set+1)*blue;
        }else{
            num_b = num_full_set*blue + amari;
        }
    }
     
    printf("%lld", num_b);
        
    return 0;
}


Measured memory_bytes: 128
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let sss = Array.init h @@ fun _ -> Array.init w @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let _ =
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do if sss.(i).(j) = "snuke" then Printf.printf "%c%d\n" (Char.chr @@ Char.code 'A' + j) @@ i + 1 done done

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int h[100001];
int dp[100002];
int main(){
    int n,k;
    cin>>n>>k;
    rep(i,n) cin>>h[i];
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    rep(i,n)FOR(j,1,k+1){
        if(i+j<=n)dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 2e5 + 50, oo = 5e18 + 500;
const int mod = 998244353;
//const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-6, PI = 2 * acos(0.0);
int n, m, k;
int cnt = 0;
int lg = 18;
vi g[N];
vi rg[N];
vi visit(N, 0);

int gcd(int a, int b)
{
	while (b)
	{
		a %= b;
		swap(a, b);
	}

	return a;
}


signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n >> m;

	vi x(n);
	int B = 50 * 50;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
		x[i] -= m;
		//x[i] += 50;
	}

	vvi dp(n, vi(B + 1, 0));
	sort(rall(x));

	if (x[0] < 0)
	{
		return cout << 0, 0;
	}

	dp[0][x[0]] = 1;
	for (int i = 1; i < n; i++)
	{
		if(x[i] >= 0)
			dp[i][x[i]] = 1;
		for (int j = 0; j <= B; j++)
		{
			if (dp[i - 1][j])
			{
				dp[i][j] += dp[i - 1][j];

				if (j + x[i] <= B && j + x[i] >= 0)
					dp[i][j + x[i]] += dp[i - 1][j];
			}
		}
	}

	cout << dp[n - 1][0];
}



Measured memory_bytes: 14952
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,M;
int dp[305][305][305];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);read(M);
    dp[0][1][1] = 1;
    for(int i = 0 ; i < M ; ++i) {
	for(int j = 1 ; j <= i + 1 ; ++j) {
	    for(int k = 1 ; k <= i + 1 ; ++k) {
		if(!dp[i][j][k]) continue;
		update(dp[i + 1][j][k + 1],mul(dp[i][j][k],N - k));
		update(dp[i + 1][k][k],mul(dp[i][j][k],j));
		update(dp[i + 1][j][k],mul(dp[i][j][k],k - j));
	    }
	}
    }
    out(dp[M][N][N]);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 108800
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e7+7;
int isPrime[N+1];

void sieve()
{
    
    rep(i,1,N)
    isPrime[i]=i;
    
    isPrime[1]=1;
   
    for(int i=2;i*i<=N;i++)
    {
        if(isPrime[i]==i)
        for(int j=i*i;j<=N;j+=i)
       { 
           if(isPrime[j]==j)
           isPrime[j]=i;
       }
    }
    
}

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


int main()
{
     
    
            int n;
            scf(n);
            
            ll ans=0;
            
            sieve();
            
            for(int i=1;i<=n;i++)
            {
                int x=i;
                
                map<int,int>m;
                
                while(x!=1)
                {
                    m[isPrime[x]]++;
                    
                    x/=(isPrime[x]);
                }
                
                ll y=1;
                
                for(auto it:m)
                y*=(it.S+1);
                
                ans+=(y*i*1LL);
                    
            }
            
            lprin(ans);
            
        
}

Measured memory_bytes: 42848
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int n;
G g;

void bfs(int start, vector<int> &dist) {
  queue<int> q;
  q.push(start);

  while(!q.empty()) {
    int v = q.front(); q.pop();
    int nd = dist[v]+1;
    for (int nv: g[v]) {
      if (dist[nv] <= nd) continue;
      q.push(nv);
      dist[nv] = nd;
    }
  }
  return;
}

int main() {
  IOS;
  cin >> n;
  g.resize(n);

  REP(i,n-1) {
    int a,b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> distA(n,INF), distB(n,INF);
  distA[0] = 0; distB[n-1] = 0;
  bfs(0,distA);
  bfs(n-1,distB);

  int cnt = 0;
  REP(i,n) {
    if (distA[i] <= distB[i]) cnt++;
    else cnt--;
    // cout << distA[i] << " " << distB[i] << endl;
    // 1-4-2-3
  }

  COUT(cnt > 0 ? "Fennec" : "Snuke");
  return 0;
}

Measured memory_bytes: 9536
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

vector<vector<int> > edges;
vector<int> check;

bool solve(int curr, int color, vector<int>& x)
{
    check[curr] = color;
    ++ x[color];

    for(unsigned i=0; i<edges[curr].size(); ++i){
        int next = edges[curr][i];
        if(check[next] == -1){
            if(!solve(next, color^1, x))
                return false;
        }else{
            if(check[next] == color)
                return false;
        }
    }

    return true;
}

int main()
{
    int v, e;
    cin >> v >> e;

    edges.assign(v, vector<int>());
    for(int i=0; i<e; ++i){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    check.assign(v, -1);
    bitset<50001> bs;
    bs[0] = true;

    for(int i=0; i<v; ++i){
        if(check[i] != -1)
            continue;

        vector<int> x(2, 0);
        if(!solve(i, 0, x)){
            cout << -1 << endl;
            return 0;
        }

        bs = (bs << x[0]) | (bs << x[1]);
    }

    int a = v / 2;
    while(!bs[a])
        -- a;

    long long ret = (long long)a * (v - a);
    ret -= e;
    cout << ret << endl;

    return 0;
}

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

ans=False
for i in range(0,k+1):
    for j in range(0,k+1):
        if(i+j>k):
            continue
        if(a*2**i<b*2**j and b*2**j < c*2**(k-i-j)):
            #print(i,j,k-i-j)
            ans=True

if(ans):
    print("Yes")
else:
    print("No")

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

bool  abc[8][8];

int dfs(int a,int b,bool c[8]){
  
  bool abcd=true;
  
  for(int i=0;i<b;i++){
    if(c[i]==false)
      abcd=false;
  }
  if(abcd){
    return 1;
  }
  int d=0;
  for(int i=0;i<b;i++){
    if(abc[a][i]==false)continue;
    if(c[i])continue;
    
    c[i]=true;
    
    d+=dfs(i,b,c);
    
    c[i]=false;
  }
  return d;
}
int main(){
  int e,f;
  cin >> e >> f;
  int g[f],h[f];
  for(int i=0;i<f;i++){
    cin >> g[i] >> h[i];
    abc[g[i]-1][h[i]-1] = abc[h[i]-1][g[i]-1] = true;
  }
  
  bool c[8];
  
  for(int i=0;i<e;i++){
    c[i]=false;
  }
  
  c[0]=true;
  cout << dfs(0,e,c)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int count = 0;
    for(int i = a;i<=b;i++){
      String s = String.valueOf(i);
      if(s.substring(0,1).equals(s.substring(4,5)) && s.substring(1,2).equals(s.substring(3,4))){
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 36692
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<long double, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
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);}

template<typename T>
T pow_mod(T a, long long b) {
  if (a == 0) {
    return 0;
  }
 
  T x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (x * a);
    }
    a = (a * a);
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;
 
struct Circle{
  long double x,y,r;
};
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  Circle s,t;

  std::cin>>s.x>>s.y>>t.x>>t.y;

  s.r=0;t.r=0;

  ll n;
  std::cin>>n;

  std::vector<Circle> circles(n+2);

  circles[0]=s;
  circles[n+1]=t;

  rep(i,0,n){
    long double x,y,r;
    std::cin>>x>>y>>r;
    circles[i+1]={x,y,r};
  }

  std::vector<long double> d(n+2,-1);
  d[0]=0;

  std::priority_queue<P,std::vector<P>,std::greater<P>> que;

  que.push({0,0});

  while(!que.empty()){
    P p=que.top();
    que.pop();

    ll v=p.second;

    if(d[v]<p.first)continue;

    rep(i,0,n+2){
      if(i!=v){
        long double cost=sqrtl(pow_mod(circles[i].x-circles[v].x,2)+pow_mod(circles[i].y-circles[v].y,2))-circles[i].r-circles[v].r;
        chmax(cost,0);
        if(d[i]==-1||d[i]>d[v]+cost){
          d[i]=d[v]+cost;
          que.push({d[i],i});
        }
      }
    }
  }

  std::cout<<std::setprecision(10)<<std::fixed<<d[n+1]<<"\n";

  return 0;
}





Measured memory_bytes: 10480
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
int f;
int main(){
	ios::sync_with_stdio(0);
	cin>>f;
	f^=1;
	cout<<f;
	re 0;
}


Measured memory_bytes: 3636