akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

typedef vector<string> card_list;

bool comp(string a, string b) {
    int x = static_cast<int>(a[1]) - 48;
    int y = static_cast<int>(b[1]) - 48;
    return x < y;
}

int bubbleSort(card_list& A) {
    int N = A.size();
    int c = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = N-1; j > i; --j) {
            if (comp(A[j], A[j-1])) {
                swap(A[j], A[j-1]);
                c++;
            }
        }
    }
    return c;
}

int selectionSort(card_list& A) {
    int N = A.size();
    int c = 0;
    for (int i = 0; i < N; ++i) {
        int min = i;
        for (int j = i; j < N; ++j) {
            if (comp(A[j], A[min])) {
                min = j;
            }
        }
        if (i != min) {
            swap(A[i], A[min]);
            c++;
        }
    }
    return c;
}

void print_card_list(card_list& cards) {
    card_list::iterator it = cards.begin();
    for (; it != cards.end()-1; ++it) {
        cout << *it << " ";
    }
    cout << *it << endl;
}

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

    int a[n];
    card_list A;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        A.push_back(s);
    }
    card_list B = A;

    bubbleSort(A);
    print_card_list(A);
    cout << "Stable" << endl;

    selectionSort(B);
    print_card_list(B);
    if (equal(A.begin(), A.end(), B.begin())) {
        cout << "Stable";
    } else {
        cout << "Not stable";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int D, G;
	cin >> D >> G;
	vi P(D), C(D);
	REP(i, D)cin >> P[i] >> C[i];
	rev(P), rev(C);
	int ans = INF;
	REP(bit, (1 << D)) {
		vi V;
		int sum = 0;
		int cnt = 0;
		REP(i, D) {
			if (((bit >> i) & 1) != 0) {
				cnt += P[i];
				sum += C[i] + 100 * P[i] * (D - i);
			}
			else {
				V.push_back(i);
			}
		}
		while (sum < G) {
			int ind = V[0];
			V.erase(V.begin());
			if (sum + P[ind] * (D - ind) * 100 <= G) {
				sum += P[ind] * (D - ind) * 100 + C[ind];
				cnt += C[ind];
			}
			else {
				int dif = (G - sum + (D - ind) * 100 - 1) / ((D - ind) * 100);
				sum += dif * (D - ind) * 100;
				cnt += dif;
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
main :: IO ()
main = do
  l1 <- getLine
  let n = read l1 :: Int
  putStrLn $ case n `mod` 10 of
    x | x `elem` [2, 4, 5, 7, 9] -> "hon"
      | x `elem` [0, 1, 6, 8] -> "pon"
      | otherwise -> "bon"


Measured memory_bytes: 3776
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==n){
        printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
}
        

Measured memory_bytes: 1708
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


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


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


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


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


def main():
    N, R = read_values()
    print(R if N >= 10 else R + 100 * (10 - N))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>

#define STR_SIZE 51U
#define OFFSET 32U

int main(void) {
    int k, n;
    int r;
    int i;
    char s[STR_SIZE], s_out[STR_SIZE];
    char c_tmp;

    r = scanf("%d %d", &n, &k);
    r = scanf("%s", s);

    for(i = 0; i <= STR_SIZE; i++ )
    {
        if (i == k - 1)
        {
            if (s[i] >= 'A' && s[i] <= 'C')
            {
                c_tmp = s[i] + OFFSET;
            }
            else
            {
                c_tmp = s[i];
            }
            s_out[i] = c_tmp;
        }
        else
        {
           s_out[i] = s[i];
        }
    }

    printf("%s\n", s_out);

	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = [input() for _ in range(N)]
#%%
mydic = {}
for s in S:
    mydic[s] = 0

for s in S:
    mydic[s] += 1

MIN = -1
for s in S:
    MIN = max(MIN, mydic[s])

ans = []
for s in S:
    if mydic[s] == MIN:
        ans.append(s)

ans.sort()
print(ans[0])
for i in range(1,len(ans)):
    if ans[i] == ans[i-1]:
        continue
    else:
        print(ans[i])
    

Measured memory_bytes: 35212
N, A, B = map(int, input().split())
s = input()

x = A + B
cnt = 1
rank = 1
for i in range(N):
    y = s[i : i+1]
    if cnt <= x:
        if y == "a":
            print("Yes")
            cnt += 1
        elif y == "b" and rank <= B:
            print("Yes")
            cnt += 1
            rank += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n, k;
    cin >> n >> k;
    int h[n];
    int ans = 0;
    rep(i, n) {
        cin >> h[i];
        if(h[i] >= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3980
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1] << endl;
	return 0;
}

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

class Program {
    static void Main(string[] args) {

        string[] NKQ = Console.ReadLine().Split(' ');

        int N = int.Parse(NKQ[0]);
        long K = int.Parse(NKQ[1]);
        int Q = int.Parse(NKQ[2]);

        long[] point = Enumerable.Repeat(K-Q, N).ToArray();

        for(int i = 0; i < Q; i++) {
            int A=int.Parse(Console.ReadLine());
            point[A-1]++;
        }

        for(int a = 0; a < N; a++) {
            if (point[a] <= 0) {
                Console.WriteLine("No");
            } else {
                Console.WriteLine("Yes");
            }
        }

    }
}

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

int main() {
  int N, K;
  cin >> N >> K;
  if (N % 2) {
    if (K <= N / 2 + 1) cout << "YES" << endl;
    else cout << "NO" << endl;
  } else {
    if (K <= N / 2) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
e = [0 for _ in range(N + 1)]

for i in range(2, N + 1):
    for j in range(2, i + 1):
        while i % j == 0:
            i //= j
            e[j] += 1

c = tuple(filter(lambda x: x > 0, e))  # 素因数の指数

dp = [[0 for _ in range(75 + 1)] for _ in range(len(c) + 1)]  # dp[素因数のidx][約数の個数] = 条件を満たす個数
dp[0][1] = 1

i = 1
for cc in c:
    for j in range(1, 75 + 1):
        k = 0  # 指数のうち使う個数
        while j * (k + 1) <= 75 and k <= cc:
            dp[i][j * (k + 1)] += dp[i - 1][j]
            k += 1
    i += 1

# print(c)
print(dp[len(c)][75])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
signed main(void){
    int n, p; cin>>n>>p;
    auto fac = prime_factorize(p);
    int ans = 1;
    int x = fac.size();
    for(auto p:fac){
        rep(j, p.second/n) ans *= p.first;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main() {
    init();
int n;
cin>>n;
string s;
string arr [n];
for(int i=0;i<n;i++){
cin>>s;
arr[i]=s;}
for(int i=1;i<n;i++){
if(arr[i-1][arr[i-1].size()-1]!=arr[i][0]){
    cout<<"No";
    return 0;
}}

for(int i=0;i<n;i++){
    for(int o=i+1;o<n;o++){
            
         if(arr[i]==arr[o]){
            cout<<"No";
            return 0;
        }

    }

}
cout<<"Yes";
}





Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
	    int aDigit = int.Parse(Console.ReadLine());
	    string[] bString = Console.ReadLine().Split();
	    
	    int result = int.Parse(bString[0]);
	    for (int i = 1; i < bString.Length; i++)
	    {
	        result += Math.Min(int.Parse(bString[i - 1]), int.Parse(bString[i]));
	    }
	    result += int.Parse(bString[bString.Length - 1]);
	    
	    Console.WriteLine(result);
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18 + 1
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int dp[100005][2];
vi Tree[100005];

int compute(int n, bool c, int p){
    if(dp[n][c] != -1)  return dp[n][c];

    int ans = 0, w1 = 1;
    for(int child : Tree[n]){
        if(child != p)
            w1 = (w1 * compute(child, 0, n))%mod;
    }
    ans += w1;
    if(!c){
        int w2 = 1;
        for(int child : Tree[n]){
            if(child != p)
                w2 = (w2 * compute(child, 1, n))%mod;
        }
        ans = (ans + w2)%mod;
    }

    return dp[n][c] = ans;
}

void solve(){
    int n, x, y;  cin>>n;
    forI(i, 1, n-1){
        cin>>x>>y;
        Tree[x].pb(y);
        Tree[y].pb(x);
    }
    memset(dp, -1, sizeof dp);
    cout<<compute(1, 0, -1)<<endl;
}   

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 17516
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  for (int n = 1; n <= N; n++) {
    int ans = 0;
    int n2 = (int)sqrt(N);
    for (int x = 1; x <= n2; x++) {
      if (x >= n) break;
      for (int y = 1; y <= n2; y++) {
        if (y >= n) break;
        const int c = n - x * x - y * y - x * y;
        int lb = 0;
        int ub = n2;
        while (ub - lb > 1) {
          int mid = (lb + ub) / 2;
          int tmp = mid * mid + (y + x) * mid;
          if (tmp == c) {
            ans++;
            break;
          } else if (tmp > c) {
            ub = mid;
          } else {
            lb = mid;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

#define NIL -1
#define A 101
#define N 2000

void MSTPrim();

static const int MAX=500;
static const int INFTY=(1<<21);

int key[A], M[A][A], p[A], n, sum;

main(){
  int i, j, e;
  scanf("%d", &n);
  for (i=0; i<n; i++ ){
    for (j=0; j<n; j++ ){
      scanf("%d", &e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }
  sum=0;
  MSTPrim();
  printf("%d\n", sum);
  return 0;
}

void MSTPrim(){
  int i, v, u;

  for(u=0;u<n;u++){
    key[u]=INFTY;
    p[u]=NIL;
  }

  key[0]=0;

  while(1){
    int minv=INFTY;
    u=NIL;

    for(i=0;i<n;i++){
      if(key[i] < minv && p[i]==NIL ){
	u=i;
	minv=key[i];
      }
    }
    if(u==NIL) break;
    p[u]=1;
    sum+=key[u];
    for(v=0;v<n;v++){
      if(M[u][v]<key[v]){
	key[v]=M[u][v];
      }
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/format.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

struct city_t {
  int idx;
  int year;
};

std::vector<std::string> solve(int n, int m,
                               std::vector<std::vector<city_t>> ps) {
  std::vector<std::string> rets(m, "");
  for (int i = 0; i < n; i++) {
    std::sort(ps[i].begin(), ps[i].end(), [](const auto& lhs, const auto& rhs) {
      return lhs.year < rhs.year;
    });
    int const nn = ps[i].size();
    for (int j = 0; j < nn; ++j) {
      const auto& city = ps[i][j];
      rets[city.idx] = (boost::format("%06d%06d") % (i + 1) % (j + 1)).str();
    }
  }
  return rets;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  int m;
  std::cin >> m;
  std::vector<std::vector<city_t>> ps(n, std::vector<city_t>());
  for (int i = 0; i < m; i++) {
    int p;
    std::cin >> p;
    p--;
    int year;
    std::cin >> year;
    city_t city{i, year};
    ps[p].push_back(city);
  }
  for (const auto& res : solve(n, m, std::move(ps))) {
    std::cout << res << std::endl;
  }
  return 0;
}


Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node
{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key)
{
  Node *cur = nil->next;
  while ( cur != nil && cur->key != key )
  {
    cur = cur->next;
  }
  return cur;
}

void init()
{
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList()
{
  Node *cur = nil->next;
  int isf = 0;
  while (1)
  {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t)
{
  if ( t == nil ) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}


void deleteFirst()
{
  deleteNode(nil->next);
}

void deletelast()
{
  deleteNode(nil->prev);
}

void deleteKey(int key)
{
  deleteNode(listSearch(key));
}

void insert(int key)
{
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main()
{
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;

  scanf("%d", &n);
  init();

  for ( i=0; i < n; i++ )
  {
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd')
    {
      if ( strlen(com) > 6 )
      {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deletelast();
      }
      else
      {
        deleteKey(key); nd++;
      }
      size--;
    }
  }
  printList();

  return 0;
}



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

int main(){
    int N;
    cin >> N;
    int a[N];
    for (int i=0; i<N; ++i) cin >> a[i];
    int cnt=0;
    for (int i=0; i<=N/2; ++i){
        if (a[2*i]%2 == 1) ++cnt;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3576
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int INF = 1<<25;
		while (true) {
			r = scanner.nextInt();
			if (r == 0)
				break;
			map = new int[2][250001];
			for (int[] m : map)
				Arrays.fill(m, INF);
			map[0][0] = map[1][0] = 0;

			for (int i = 0; i < 2; i++) {
				w = scanner.nextInt();
				h = scanner.nextInt();
				sx = scanner.nextInt() - 1;
				sy = scanner.nextInt() - 1;
				int[][] m = new int[h][w];
				for (int j = 0; j < h; j++)
					for (int k = 0; k < w; k++)
						m[j][k] = scanner.nextInt();
				slove(m, i);
			}
			int res = INF;
			for (int i = 0; i <= r; i++)
				res = Math.min(res, map[0][i] + map[1][r - i]);
			System.out.println(res);
		}
	}

	private void slove(int[][] m, int i) {
		boolean[][] b = new boolean[h][w];
		b[sy][sx] = true;
		PriorityQueue<Point> pq = new PriorityQueue<Point>();
		pq.offer(new Point(m[sy][sx], sy, sx));
		int l = -1;
		int id = 1;
		while (!pq.isEmpty()) {
			Point p = pq.poll();
			l = Math.max(l, p.k);
			map[i][id++] = l;
			for (int[] mo : move) {
				int ny = p.y + mo[0];
				int nx = p.x + mo[1];
				if (!isOK(ny, nx))
					continue;
				if (b[ny][nx])
					continue;
				b[ny][nx] = true;
				pq.offer(new Point(m[ny][nx], ny, nx));
			}
		}

	}

	private boolean isOK(int ny, int nx) {
		if (0 <= ny && ny < h && 0 <= nx && nx < w)
			return true;
		return false;
	}

	int r, w, h, sx, sy;
	int[][] map;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point implements Comparable<Point> {
		int k, y, x;

		@Override
		public String toString() {
			return "Point [k=" + k + ", y=" + y + ", x=" + x + "]";
		}

		public Point(int k, int y, int x) {
			super();
			this.k = k;
			this.y = y;
			this.x = x;
		}

		@Override
		public int compareTo(Point o) {
			return k - o.k;
		}

	}
}

Measured memory_bytes: 171228
a = []
while True:
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        break
    a.append([x, y])

for i in range(len(a)):
    if a[i][0] > a[i][1]:
        print("{0} {1}".format(a[i][1], a[i][0]))
    else:
        print("{0} {1}".format(a[i][0], a[i][1]))



Measured memory_bytes: 6016
import java.io.IOException;
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

// ALDS1_7_D
public class Main {
	Node root = null;
	int key = 0;
	void preParse(Node node) {
		if (node == null) return;
		System.out.print(" " + node.number);
		preParse(node.left);
		preParse(node.right);
	}
	
	void inParse(Node node) {
		if (node == null) return;
		inParse(node.left);
		System.out.print(" " + node.number);
		inParse(node.right);
	}
	
	void postParse(Node node, StringBuilder build) {
		if (node == null) return;
		postParse(node.left, build);
		postParse(node.right, build);
		build.append(" " + node.number);
	}
	
	void reTree(Node parent, int[] pre, int[] in, int pinindex, int left, int right) {
		// System.out.println("key:"+key + ", left:" + left + ", right:" + right);
		if (key > pre.length-1) return;
		if (left > right) return;
		int inkey = -1;
		for (int i = left; i <= right; i++) {
			if (pre[key] == in[i]) {
				inkey = i;
			}
		}
		if (inkey == -1) {
			return;
		}
		Node node = new Node(pre[key]);
		if (parent == null) {
			root = node;
		} else if (pinindex > inkey) {
			parent.left = node;
		} else {
			parent.right = node;
		}
		key++;
		reTree(node, pre, in, inkey, left, inkey-1);
		reTree(node, pre, in,  inkey, inkey+1, right);
	}
	
	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] pre = new int[n];
		int[] in = new int[n];
		// preorder
		for (int i = 0; i < n; i++) {
			pre[i] = sc.nextInt();
			
		}
		// inorder
		for (int i = 0; i < n; i++) {
			in[i] = sc.nextInt();
		}
		reTree(null, pre, in, -1, 0, pre.length-1);
		StringBuilder build = new StringBuilder();
		postParse(root, build);
		build.deleteCharAt(0);
		System.out.println(build);
		sc.close();
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}

class Node {
	int number;
	Node parent = null;
	Node left = null;
	Node right = null;
	Node(int number) {
		this.number = number;
	}
}


Measured memory_bytes: 26292
def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A,B = map(int, input().split())
gcd = gcd(A,B)
divs = make_divisors(gcd)
# ps = getprime(gcd)
if len(divs)==1:
    print(1)
else:
    print(len(factorization(gcd))+1)

Measured memory_bytes: 3276
H, W = map(int, input().split())
a = [[x for x in input()] for _ in range(H)]

ans = []
ans.append(['#'*(W+2)])
for row in a:
    row.insert(0, '#')
    row.append('#')
    ans.append(row)
ans.append(['#'*(W+2)])
for i in range(H+2):
    print(*ans[i], sep='')

Measured memory_bytes: 4468
N,K=map(int,input().split())
p=list(map(int,input().split()))

l = []
tmp = 0
#O(N)
for i in range(K):
    a= (p[i]+1)/2
    tmp+=a
    l.append(a)
ans = tmp
for i in range(K,N):
    a = (p[i]+1)/2
    l.append(a)
    b = l[i-K]
    tmp += a
    tmp -= b
    ans=max(ans,tmp)

print(ans)

Measured memory_bytes: 25060
#include <stdio.h>
#include <math.h>
int main()
{
    int x, point = 0;
    scanf("%d", &x);

    while(x > 499) {
        x -= 500;
        point += 1000;
    }
    while(x > 4) {
        x -= 5;
        point += 5;
    }

    printf("%d\n", point);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a + b == c || a + c == b || c + b == a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int dp[22][1<<22];
int g[25][25];
const int MOD =1e9+7;
int n;
int fun(int id,int mask){
    if(id<0){
        return mask ==0;
    }
    if(dp[id][mask]!=-1)    return dp[id][mask];
    dp[id][mask] = 0;
    for(int i=0;i<n;i++){
        if((mask & (1<<i)) && g[id][i])
            dp[id][mask] = (dp[id][mask] + fun(id-1,mask^(1<<i)))%MOD;

    }
    return dp[id][mask];
}

int main(){
    cin>>n;


    for(int i=0;i<n;++i)
		for(int mask=0;mask < (1<<n); ++mask)
			dp[i][mask] = -1;

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>g[i][j];
    cout<<fun(n-1,(1<<n)-1);
    return 0;
}


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

const int INF = 2000000000;

int main()
{
    int V, E;
    cin >> V >> E;
    Matrix dist;
    dist = Matrix(V, vector<int>(V, INF));
    rep(i, V) dist[i][i] = 0;
    rep(i,E){
        int from, to, cost;
        cin >> from >> to >> cost;
        dist[from][to] = cost;
    }
    rep(k,V){
        rep(i,V){
            if(dist[i][k]!=INF){
                rep(j,V){
                    if(dist[k][j]!=INF){
                        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                        if(i==j && dist[i][j]<0){
							printf("NEGATIVE CYCLE\n");
                            return 0;
                        }
                    }
                }
            }
        }
    }
    rep(i,V){
        rep(j,V){
            if(dist[i][j]==INF){
                cout << "INF";
            }else{
                cout << dist[i][j];
            }
            if(j!=V-1)
                cout << " ";
        }
        cout << endl;
    }
}


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

string subst(string S,int i, int j){
	string s;
	for(int k = i ; k <= j ; k++){
		s += S[k];
	}
	return s;
}

int main() {
	string S;cin >> S;
	vector<string> ans;
	for(int i = 0 ; i < S.size() ; i++){
		for(int j = 0 ; j < min(5,(int)S.size()) ; j++){
			if(i + j >= S.size()) break;
			ans.push_back(subst(S,i,i+j));
		}
	}
	sort(ans.begin(),ans.end());
	string akari = "zzzzz";
	int K; cin >> K;
	for(int i = 0 ; i < K ; i++){
		if(akari != ans[i]){
			if(K == i + 1){
				cout << ans[i] << endl;
				return 0;
			}
		}
		if(akari == ans[i]){
			K++;
		}
		akari = ans[i];
	}
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


int main()
{
    string s;
    cin >> s;
    int N;
    N = (int)(s.length());
    if (stoi(s.substr(N-1)) == 3) {
        cout << "bon" << endl;
    }
    else if (stoi(s.substr(N-1)) == 0 || stoi(s.substr(N-1)) == 1 || stoi(s.substr(N-1)) == 6 || stoi(s.substr(N-1)) == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3600
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] A;
        A = new int[H][W];
        for(int i=0; i<H; i++){
            char[] JOI = sc.next().toCharArray();
            int time = -1;
            for(int j=0; j<W; j++){
                if(JOI[j] == 'c') time = 0;
                A[i][j] = time;
                if(time>-1) time++;
            }
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                System.out.print(A[i][j]);
                if(j<W-1) System.out.print(" ");
                else System.out.println();
            }
        }
    }
 
}

Measured memory_bytes: 33972
n,a,b = gets.chomp.split(' ').map(&:to_i)
arr = (1..n).to_a

i = 0
while i < arr.size
  ar = arr[i].to_s.split('').map(&:to_i).inject(:+)
  if ar > b || ar < a
    arr[i] = 0
  end
  # p ar
  i += 1
end
p arr.inject(:+)

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
typedef long long ll;

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; }

int main()
{
  int N, M;
  cin >> N >> M;
  
  vector<pair<int, int>> sc(M);
  for(int i=0; i<M; i++)
    cin >> sc[i].first >> sc[i].second;

  int init=0;
  int endon=10;
  if(N==2)
    {
      init=10;
      endon=100;
    }
  if(N==3)
    {
      init=100;
      endon=1000;
    }

  ll ans=10000;
  
  for(int i=init; i<endon; i++)
    {
      for(int j=0;j<M;j++)
	{
	  ll waru=1;
	  if(sc[j].first==1)
	    waru = 1;
	  if(sc[j].first==2)
	    waru=10;
	  if(sc[j].first==3)
	    waru=100;
	  ll waruwaru = init / waru;
	  if(waruwaru==0)
	    waruwaru=1;
	  if((i/waruwaru)%10!=sc[j].second)
	    {
	      break;
	    }
	  if(j==M-1)
	    {
	      if(i<ans)
		ans=i;
	    }
	}
    }
    

  if(ans!=10000)
    cout << ans << endl;
  else if (M==0)
    cout <<  init << endl;
  else
    cout << -1 << endl;

  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<int> dp(1 << N, pow(10, 9));

    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        ll x = 0;
        for(int j = 0; j < b; j++) {
            ll c;
            cin >> c;
            x += 1LL << (c - 1LL);
        }
        for(ll bit = 1LL; bit < (1LL << N); bit++) {
            if((bit & x) == bit) {
                dp[bit] = min(dp[bit], a);
            }
        }
    }

    for(ll bit = 1LL; bit < (1LL << N); bit++) {
        for(int i = 1LL; i < bit; i++) {
            if((bit & i) == i) {
                dp[bit] = min(dp[bit], dp[bit - i] + dp[i]);
            }
        }
    }

    if(dp[(1 << N) - 1LL] == pow(10, 9)) {
        cout << -1 << endl;
    } else {
        cout << dp[(1 << N) - 1LL] << endl;
    }
}

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)

	c := map[rune]rune{
		'0': '1',
		'1': '0',
	}
	p1, p2 := '0', '1'
	a1, a2 := 0, 0
	for _, s := range S {
		if p1 == s {
			a1++
			p1 = c[s]
		} else {
			p1 = s
		}
		if p2 == s {
			a2++
			p2 = c[s]
		} else {
			p2 = s
		}
	}

	if a1 > a2 {
		a1 = a2
	}

	fmt.Println(a1)
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define kakkei vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{return f<p.f;};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{
		return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);
	};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
ten shaei(ten p,chokusen l){
	v2 a=l.p2-l.p1;
	return l.p1+a*a.naiseki(p-l.p1)/a.abs2();
}
ten hansha(ten p,chokusen l){
	return shaei(p,l)*2-p;
}
void solve(){
	chokusen l;
	cin>>l.p1.x>>l.p1.y>>l.p2.x>>l.p2.y;
	ll q;cin>>q;
	cout<<sep(10);
	rep(i,0,q){
		ten p;cin>>p.x>>p.y;
		ten k=hansha(p,l);
		cout<<k.x<<' '<<k.y<<kai;
	}
}


Measured memory_bytes: 3312
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			List<Integer> p = new ArrayList<>(), q = new ArrayList<>();
			IntStream.range(0, n).forEach(i -> p.add(scanner.nextInt() - 1));
			IntStream.range(0, n).forEach(i -> q.add(scanner.nextInt() - 1));
			System.out.println(Math.abs(calcOrder(p) - calcOrder(q)));
		}
	}

	private static int calcOrder(List<Integer> p) {
		if (p.size() == 1) {
			return 0;
		}
		return p.get(0) * frac(p.size() - 1) + calcOrder(subList(p));
	}

	private static List<Integer> subList(List<Integer> list) {
		int first = list.get(0);
		list.remove(0);
		for (int i = 0; i < list.size(); i++) {
			Integer number = list.get(i);
			list.set(i, (number > first) ? number - 1 : number);
		}
		return list;
	}

	private static int frac(int n) {
		if (n <= 0) {
			return 1;
		}
		int result = 1;
		for (int i = 2; i <= n; i++) {
			result *= i;
		}
		return result;
	}
}


Measured memory_bytes: 28884
from sys import stdin


def main() -> None:
    n = int(next_str())
    print(int(n ** 0.5) ** 2)

def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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


public class A
{
	public static void Main()
	{
		string[] args = new string[3];
		for(int i = 0; i < 3; i++)
			args[i] = Console.ReadLine();		
		Console.WriteLine("{0}{1}{2}", args[0][0], args[1][1], args[2][2]);
	}
}





Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,Q; cin>>N>>Q;
    string S; cin>>S;
    vec C(N+1,0);
    FOR(i,1,N){
        C[i+1]=C[i];
        if(S[i-1]=='A'&&S[i]=='C') C[i+1]++;
    }
    vec l(Q),r(Q);
    REP(i,Q) {
        cin>>l[i]>>r[i];
        l[i]--; r[i]--;
        Out(C[r[i]+1]-C[l[i]+1]);
    }
}

Measured memory_bytes: 5812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,w;
    cin >> n >> w;
    vector<ll> z(n);
    vector<ll> x(n);
    vector<vector<ll>> dp(n + 1, vector<ll>(103000,123456789012345));
    for (int i = 0; i < n; i++) {
        cin >> z[i] >> x[i];
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 101500; j++) {
            dp[i + 1][j] = dp[i][j];
        }
        for (int j = 0; j < 101500; j++) {
            dp[i + 1][x[i] + j] = min(dp[i + 1][x[i]+j], dp[i][j] + z[i]);
        }
    }
    ll ans = 0;
    for (int j = 0; j < 102000; j++) {
        if (dp[n][j] <= w)ans = j;
    }
    cout << ans << endl;
}

Measured memory_bytes: 85632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll k;cin>>k;
    ll n = (1ll<<k);
    multiset<ll> st;
    for(ll i=0;i<n;i++){
        ll x;cin>>x;
        st.insert(x*-1);
    }
    vector<ll> a;
    a.push_back(*st.begin());
    st.erase(st.begin());
    for(ll i=0;i<k;i++){
        vector<ll> tmp;
        for(auto &ele:a){
            if(st.upper_bound(ele)==st.end())return cout<<"No" , 0;
            tmp.push_back(*(st.upper_bound(ele)));
            st.erase(st.upper_bound(ele));
        }
        for(auto &ele:tmp)a.push_back(ele);
        sort(a.begin(),a.end());
    }
    cout<<"Yes";
}

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

if a <= 0 <= b:
    print('Zero')
elif a > 0 and b > 0:
    print('Positive')
elif a < 0 and b < 0:
    if (abs(a-b)+1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')


Measured memory_bytes: 2940
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,T,A,H;
	while(cin>>N>>T>>A) {
		ll ans = -1;
		double best = 1e30;
		REP(i, N) {
			cin>>H;
			double v = abs(A-(T-H*0.006));
			if(v<best) {
				best = v;
				ans = i+1;
			}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


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

int main() {
    size_t N;
    cin >> N;

    vector<long> a(3 * N);
    for(auto& i : a)cin >> i;

    vector<long> ans(N + 1);
    {
        priority_queue<long, vector<long>, greater<>> pq(a.begin(), a.begin() + N);
        long s = accumulate(a.begin(), a.begin() + N, 0L);
        ans[0] = s;
        for (size_t i = 0; i < N; ++i){
            pq.push(a[i + N]);
            ans[i + 1] += (s += a[i + N]) -= pq.top();
            pq.pop();
        }
    }
    reverse(a.begin(), a.end());
    reverse(ans.begin(), ans.end());
    {
        priority_queue<long, vector<long>, less<>> pq(a.begin(), a.begin() + N);
        long s = accumulate(a.begin(), a.begin() + N, 0L);
        ans[0] -= s;
        for (size_t i = 0; i < N; ++i){
            pq.push(a[i + N]);
            ans[i + 1] -= (s += a[i + N]) -= pq.top();
            pq.pop();
        }
    }
    cout << *max_element(ans.begin(), ans.end()) << endl;
    return 0;
}

Measured memory_bytes: 4992
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


K = int(sys.stdin.buffer.readline())
S = sys.stdin.buffer.readline().decode().rstrip()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')


Measured memory_bytes: 27224
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,a,b,x=0,c[10];
	string s;
	cin>>s;
	a=s.size();
	for(i=0;i<a;i++)
	{
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
		{
			x++;
		}
		else
		{
			x=0;
		}
		c[i]=x;
	}
	sort(c,c+a);
	cout<<c[a-1]<<endl;
}

Measured memory_bytes: 3592
import math as mt
import sys
import bisect
input=sys.stdin.readline
t=1
#t=int(input())
mod=10**9+7
for _ in range(t):
    
    n=int(input())
    #n,k,w=map(int,input().split())
    #u1,d1=map(int,input().split())
    #u2,d2=map(int,input().split())
    #l=list(map(int,input().split()))
    print(n^1)

Measured memory_bytes: 62008