akhauriyash/Code-Regression huggingface dataset:
# ABC068C - Cat Snuke and a Voyage (ARC079C)
def main():
    N, M, *AB = map(int, open(0).read().split())
    from_1, to_N = set(), set()
    for a, b in zip(*[iter(AB)] * 2):
        if a == 1:
            from_1.add(b)
        if b == N:
            to_N.add(a)
    flg = from_1 & to_N  # intermediate point of both 1, N exists?
    print("POSSIBLE" if flg else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Measured memory_bytes: 46660
package main

import (
  "bufio"
  "container/heap"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  const INF int64 = 10000000000
  input := Input{bufio.NewReaderSize(os.Stdin,1000000)}
  q,_,_ := input.NextInts(true)
  var l,r PriorityQueue
  heap.Init(&l);heap.Push(&l,&Item{priority:INF})
  heap.Init(&r);heap.Push(&r,&Item{priority:INF})
  var x,y,m int64
  for k:=0;k<q;k++ {
    n,a,b := input.NextInts(false)
    if n == 2 {
      fmt.Println(m,x+y)
    } else {
      y += b
      lb := heap.Pop(&l).(*Item)
      ub := heap.Pop(&r).(*Item)
      if a < -lb.priority {
        x += -lb.priority-a
        heap.Push(&l,&Item{priority:-a})
        heap.Push(&l,&Item{priority:-a})
        heap.Push(&r,&Item{priority:-lb.priority})
        heap.Push(&r,&Item{priority:ub.priority})
      } else if ub.priority < a {
        x += a-ub.priority
        heap.Push(&l,&Item{priority:lb.priority})
        heap.Push(&l,&Item{priority:-ub.priority})
        heap.Push(&r,&Item{priority:a})
        heap.Push(&r,&Item{priority:a})
      } else {
        heap.Push(&l,&Item{priority:lb.priority})
        heap.Push(&l,&Item{priority:-a})
        heap.Push(&r,&Item{priority:ub.priority})
        heap.Push(&r,&Item{priority:a})
      }
      t := heap.Pop(&l).(*Item)
      m = -t.priority
      heap.Push(&l,&Item{priority:-m})
    }
  }
}

type Item struct {
  priority int64
  index int
}
type PriorityQueue []*Item
func(pq PriorityQueue) Len() int {
  return len(pq)
}
func(pq PriorityQueue) Swap(i,j int) {
  pq[i],pq[j] = pq[j],pq[i]
  pq[i].index = i
  pq[j].index = j
}
func(pq PriorityQueue) Less(i,j int) bool {
  return pq[i].priority < pq[j].priority
}
func(pq *PriorityQueue) Push(x interface{}) {
  var n int = len(*pq)
  var item *Item = x.(*Item)
  item.index = n
  *pq = append(*pq,item)
}
func(pq *PriorityQueue) Pop() interface{} {
  var old PriorityQueue = *pq
  var n int = len(old)
  var item *Item = old[n-1]
  item.index = -1
  *pq = old[0:n-1]
  return item
}

type Input struct {
  reader *bufio.Reader
}
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts(single bool) (int,int64,int64) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  if single || len(s) == 1 { return x,0,0 }
  y,_ := strconv.ParseInt(s[1],10,64)
  z,_ := strconv.ParseInt(s[2],10,64)
  return x,y,z
}

Measured memory_bytes: 21504
#include<stdio.h>
#include<ctype.h>
int main()
{
	char a[101], b[101], c[101];
	scanf("%s%s%s", a, b, c);
	a[0] = toupper(a[0]);
	b[0] = toupper(b[0]);
	c[0] = toupper(c[0]);
	printf("%c%c%c\n", a[0], b[0], c[0]);
}

Measured memory_bytes: 128
import sys
def ds6(here, field, turn):
	if turn == -1 or here in field and (field[here] == -1 or field[here] >= turn) : 
		return

	field[here] = turn
	ds6((here[0], here[1]+1), field, turn - 1)
	ds6((here[0], here[1]-1), field, turn - 1)

	ds6((here[0]+1, here[1]), field, turn - 1)
	ds6((here[0]-1, here[1]), field, turn - 1)
	
	ds6((here[0]+1, here[1]+1), field, turn - 1)
	ds6((here[0]-1, here[1]-1), field, turn - 1)

sys.setrecursionlimit(10000)
while 1:
	t, n = map(int,raw_input().split(" "))
	if (t,n) == (0,0):
		break
	field = dict()
	for i in range(n):
		block = map(int,raw_input().split(" "))
		field[(block[0],block[1])] = - 1
	start = map(int,raw_input().split())
	ds6((start[0],start[1]), field, t)
	print len(field) - n

Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,K;
    int num=1;
    cin >> N >> K ;

    for(int i=0; i<N; i++){
        if(num*2 < num+K){
            num=num*2;
        }else{
            num+=K;
        }
    }
    cout<< num << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  static long long F[100001];
  while (N--) {
    int a, b;
    cin >> a >> b;
    for (auto i = M; i >= a; --i)
      F[i] = max(F[i], F[i - a] + b);
  }
  cout << F[M] << endl;
  return 0;
}


Measured memory_bytes: 1024
def tami(x, vis, cnt):
  global ans
  if cnt == N:
    ans += 1
    #print(vis)
    return
  for i in root[x]:
    if i not in vis:
      tami(i, vis+[i], cnt+1)

N,M = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(M)]

root = [[] for _ in range(N+2)]
for a,b in ab:
  root[a].append(b)
  root[b].append(a)

visited = []
ans = 0
tami(1, visited+[1], 1)
print(ans)

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

int main(){
  int N; cin >> N;
  long count = 0;
  vector<long> A(N + 1); vector<long> B(N);
  for(int i; i < N + 1; i++)
    cin >> A.at(i);
   for(int i; i < N; i++)
    cin >> B.at(i);
  
  for(int i; i < N; i++){
    
    if(A.at(i) < B.at(i)){
      
      if(A.at(i) + A.at(i + 1) < B.at(i))
      count += A.at(i) + A.at(i + 1);
      else
      count += B.at(i);
      
      A.at(i + 1) -= min(A.at(i + 1), B.at(i) - A.at(i));
    }
    else
      count += B.at(i);
  }
  cout << count << endl;
}
    


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

int main() {
 
  int H, W;
  cin >> H >> W;
  
  vector<char> a(W + 2, '#');
  for (int i = 0; i < W + 2; i++) {
    cout << a.at(i);
  }
  cout << endl;

  for (int j = 0; j < H; j++) {
  	vector<char> b(W + 2, '#');
    cout << '#';
  	for (int i = 1; i < W + 1; i++) {
      cin >> b.at(i);
      cout << b.at(i);
  	}
    cout << '#';
    cout << endl;
  }
  
  for (int i = 0; i < W + 2; i++) {
    cout << a.at(i);
  }
  cout << endl;
  
}


Measured memory_bytes: 256
public class Main {


  private static void solve() {
    int t = ni();
    int x = ni();
    
    System.out.println((double)t / x);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22868
import sys
readline = sys.stdin.readline

H,W,N = map(int,readline().split())
from collections import defaultdict

# 9x9のマスの左上のマスの座標をキーにして、各正方形の黒マス数をdictionaryで管理
# 10 ** 5 * 9程度

dic = defaultdict(int)

for i in range(N):
  a,b = map(int,readline().split())
  a,b = a - 1,b - 1
  for A in range(max(0,a - 2), min(a + 1,H - 2)):
    for B in range(max(0,b - 2), min(b + 1,W - 2)):
      dic[(A,B)] += 1

ans = [0] * 10
for v in dic.values():
  ans[v] += 1

ans[0] = (H - 2) * (W - 2) - sum(ans[1:])

for a in ans:
  print(a)


Measured memory_bytes: 145440
#include<bits/stdc++.h>
#include<stdio.h> //per fare input output con scanf and printf
#include<stdlib.h> //per fare qsort e bsearch
#include<string.h> // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali
#include<math.h>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<map>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector <ll> 
#define pi pair <int, int>
#define binary(v, el) binary_search((v).begin(), (v).end(), (el))
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(n, t) get<(n)>((t)) // get element of a tuple
#define F first
#define S second
#define input(type, n) type n; cin >> n
#define FORN(n) for (ll i=0;i<(n); i++)
#define print(x) cout << x << endl
#include <iomanip>      // std::setprecision
#define M 1000*1000*1000+7
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int main(){
  IOS
  int a,b; cin>>a>>b;
  cout << max(a+b, max(a*b, a-b));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  string s;
  cin>>s;
  if(s=="SSS") cout<<0<<endl;
  else if(s=="RRS" or s=="SRR") cout<<2<<endl;
  else if(s=="RRR") cout<<3<<endl;
  else cout<<1<<endl;
  return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 105

int n;
string s[MAXX];
int p[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    map<string  , int> m;
    vector<pair<int , int> > v[MAXX];
    set<string> str;
    set<string>::iterator it;
    for(int i = 1; i <= n; i++){
        cin >> s[i] >> p[i];
        if(!m[s[i]])    m[s[i]] = i;
        v[m[s[i]]].push_back({p[i] , i});
        str.insert(s[i]);
    }
    for(it = str.begin(); it != str.end(); it++){
        string k = (*it);
        sort(v[m[k]].begin() , v[m[k]].end());
        reverse(v[m[k]].begin() , v[m[k]].end());
        for(int i = 0; i < v[m[k]].size(); i++){
            cout << v[m[k]][i].second << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
if a > b:
  print(0)
elif a == b:
  print(1)
else:
  if n > 1:
    max_ = a*1 + (n-1)*b
    min_ = a*(n-1) + 1*b
    print(max_ - min_ + 1)
  else:
    print(0)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

const int N = 2e5 + 5;
const int B = 18;
const int INF = 1e9;

int a[N], pos[N], n;
bool vis[N];

struct Seg {
  int l, r, x;
  inline bool operator < (const Seg &o) const {
    return x > o.x;
  }
};
priority_queue <Seg> Q;

struct RMQ {
  int tab[B][N];
  RMQ() {
    memset(tab, 0, sizeof tab);
  }
  inline void Init() {
    for (int i = 1, d = 1; i < B; i ++, d <<= 1)
      for (int j = 1; j <= n - d; j ++)
	tab[i][j] = min(tab[i - 1][j], tab[i - 1][j + d]);
  }
  inline int Query(int l, int r) {
    int len = r - l + 1, d = 0, e = 1;
    for (; (e << 1) <= len; e <<= 1, d ++);
    return min(tab[d][l], tab[d][r - e + 1]);
  }
} qry[2];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
    qry[i & 1].tab[0][i] = a[i];
    qry[!(i & 1)].tab[0][i] = INF;
  }
  qry[0].Init();
  qry[1].Init();
  Q.push((Seg){1, n, qry[1].Query(1, n)});
  Seg c;
  int x, y, px, py;
  while (!Q.empty()) {
    c = Q.top(); Q.pop();
    x = c.x;
    px = pos[x];
    y = qry[!(c.l & 1)].Query(px + 1, c.r);
    py = pos[y];
    printf("%d %d ", x, y);
    if (c.l < px - 1) Q.push((Seg){c.l, px - 1, qry[c.l & 1].Query(c.l, px - 1)});
    if (px + 1 < py) Q.push((Seg){px + 1, py - 1, qry[(px + 1) & 1].Query(px + 1, py - 1)});
    if (py + 1 < c.r) Q.push((Seg){py + 1, c.r, qry[(py + 1) & 1].Query(py + 1, c.r)});
  }
  return 0;
}


Measured memory_bytes: 31992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e6 + 5;

int n, ans;
int prime[N];

void sieve() {
    memset(prime, false, sizeof(prime));
    prime[0] = prime[1] = false;
    for(int i = 2; i * i <= N - 5; i++) {
        if(prime[i]) {
            for(int j = i * i; j <= N - 5; j += i) {
                prime[j] = false;
            }
        }
    }
}

int countFactor(int x) {
    int ret = 0;
    for(int i = 1; i * i <= x; i++) {
        if(x % i == 0) {
            ret++;
            if(x / i != i) ret++;
        }
    }
    return ret;
}

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    sieve();
    for(int tc = 1; tc <= T; tc++) {
        cin >> n;
        for(int i = 1; i < n; i++) {
            if(!prime[n - i]) {
                ans += countFactor(n - i);
            }
        }
        cout << ans << "\n";
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

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

int main() {
	long long int dp[87];
	dp[0]=2;
	dp[1]=1;
	for(int i=2;i<87;i++)
	  {
	     dp[i]=dp[i-1]+dp[i-2];	
	  }
	int n;
	cin>>n;
	cout<<dp[n]<<'\n';
	return 0;
}

Measured memory_bytes: 256
import copy
import sys
sys.setrecursionlimit(10**6)

H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

dx=[1,0,-1,0]
dy=[0,1,0,-1]

walker=[]
for row in range(H):
    walker.append([None]*W)
waiting=[]
def func(xy, walker):
    x, y = xy
    for i in range(4):
        if 0 <= x+dx[i] < W and 0 <= y+dy[i] <H:
            if walker[y+dy[i]][x+dx[i]] == None and S[y+dy[i]][x+dx[i]] == '.':
                walker[y+dy[i]][x+dx[i]] = walker[y][x]+1
                waiting.append((x+dx[i], y+dy[i]))
    if waiting:
        func(waiting.pop(0) ,walker)
    else:
        return None


candicate = []
for sx in range(W):
    for sy in range(H):
        if S[sy][sx] == '.':
            temp_walker=copy.deepcopy(walker)
            temp_walker[sy][sx]=0
            func((sx,sy), temp_walker)
            far=0

            for gx in range(W):
                for gy in range(H):
                    if S[gy][gx]=='.':
                        if far < temp_walker[gy][gx]:
                            far = temp_walker[gy][gx]

            #print(sx, sy, temp_walker, far)
            candicate.append(far)
print(max(candicate))




Measured memory_bytes: 83420
#include <stdio.h>
#include <stdlib.h>
 
#define JUDGE 1000000007
#define BLANK 1
 
int N, M;
 
typedef struct 
{
    int type;
    int road;
} Stair;
 
void visit(Stair*);
 
int main()
{
    int i;
    char buf[256];
    fgets(buf, 256, stdin);
    sscanf(buf, "%d %d", &N, &M);
 
    Stair* p = (Stair*)malloc(sizeof(Stair) * N);
 
    for (i = 0; i < N; i++)
    {
        p[i].type = 0;
        p[i].road = 0;
    }
 
    int a = 0;
    for (i = 0; i < M; i++)
    {
        scanf("%d", &a);
        p[a-1].type = BLANK;
    }
    
    if (p[0].type != BLANK || p[1].type != BLANK)
    {
        p[0].road = 1;
        p[1].road = 1;
        visit(p);
    }
    printf("%d\n", p[N-1].road % JUDGE);
 
    return 0;
}
 
void visit(Stair* p)
{
    int i;
    for (i = 0; i < N-2; i++)
    {
        if (p[i].type == BLANK) continue;
        if (p[i+1].type != BLANK)
        {
            p[i+1].road += p[i].road % JUDGE;
        }
        
        if (p[i+2].type != BLANK)
        {
            p[i+2].road += p[i].road % JUDGE;
        }
    }
 
    if (p[N-1].type != BLANK && p[N-2].type != BLANK)
    {
        p[N-1].road += p[N-2].road % JUDGE;
    }
 
    return;
}

Measured memory_bytes: 896
// C - Many Medians
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vi X(N), Y(N);
	rpz(i, N) cin>>X[i];
	sort(all(Y = X));
	int y1 = Y[N/2], y2 = Y[N/2-1];
	rpz(i, N) cout<< (X[i]<y1? y1: y2) <<endl;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000000 + 7)

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

u64 My_Combination(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

int main() {
  cout << setprecision(18);
  u32 N;
  cin >> N;
  vector<vector<u32>> Tree(N);
  map<pair<u32, u32>, u32> res;
  vector<pair<u32, u32>> route(N - 1);
  for (u32 i = 0; i < N - 1; ++i) {
    u32 a, b;
    cin >> a >> b;
    Tree[a - 1].push_back(b - 1);
    Tree[b - 1].push_back(a - 1);
    res[make_pair(a - 1, b - 1)] = 0;
    route[i] = make_pair(a - 1, b - 1);
  }
  u32 max_node = 0;
  u32 max_size = 0;
  for (u32 i = 0; i < N; ++i) {
    if (max_size < Tree[i].size()) {
      max_size = Tree[i].size();
      max_node = i;
    }
  }
  vector<bool> achieve(N, false);
  queue<u32> Next;
  Next.push(max_node);
  achieve[max_node] = true;
  while (!Next.empty()) {
    u32 next_node = Next.front();
    Next.pop();
    set<u32> Col;
    u32 c = 1;
    for (auto itr = Tree[next_node].begin(); itr != Tree[next_node].end();
         ++itr) {
      u32 a = *itr, b = next_node;
      if (a > b) swap(a, b);
      if (res[make_pair(a, b)] != 0) Col.insert(res[make_pair(a, b)]);
    }
    for (auto itr = Tree[next_node].begin(); itr != Tree[next_node].end();
         ++itr) {
      if (achieve[*itr]) continue;
      u32 a = *itr, b = next_node;
      if (a > b) swap(a, b);
      if (res[make_pair(a, b)] == 0) {
        while (Col.find(c) != Col.end()) {
          ++c;
        }
        res[make_pair(a, b)] = c;
        Col.insert(c);
      }
      achieve[*itr] = true;
      Next.push(*itr);
    }
  }
  cout << max_size << endl;
  for (auto itr = route.begin(); itr != route.end(); ++itr) {
    cout << res[*itr] << endl;
  }

  return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    if(s.size() % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    REP(i, s.size()){
        if (((s[i] == 'h') && (i%2 == 0)) or ((s[i] == 'i') && (i%2 == 1))){
            continue;
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector<int> from(N, 0);
    for(int i = 0; i < M; i++){
        int a, b;
        std::cin >> a >> b;
        a--; b--; // to 0 origin
        from[a]++; from[b]++;
    }

    for(int i = 0; i < N; i++){
        std::cout << from[i] << std::endl;
    }
    return 0;
}


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

using namespace std;

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

    int s, w;
    cin >> s >> w;
    if (w >= s)
    {
        cout << "unsafe";
    }
    else
    {
        cout << "safe";
    }
    
    
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<stack>
using namespace std;
int main(){
    string str;
    while(getline(cin,str)){
        stringstream ss(str);
        vector<int>V;
        while(ss){
            int a;
            ss>>a;
            V.push_back(a);
        }
        if(V[0]==0)break;
        V.pop_back();
        stack<pair<int,int> >S;
        S.push(pair<int,int>(0,0));
        int Max=0;
        while(!S.empty()){
            int pnt=S.top().first,cnt=S.top().second;
            S.pop();
            if(pnt>21)continue;
            if(cnt==V.size()){
                Max=max(Max,pnt);
                continue;
            }
            int to=V[cnt];
            if(to>10)to=10;
            S.push(pair<int,int>(pnt+to,cnt+1));
            if(to==1)S.push(pair<int,int>(pnt+11,cnt+1));
        }
        cout<<Max<<endl;
    }
    return 0;
}

Measured memory_bytes: 1244
//write：Sakura
//id：
//problem：
//note：

#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;

int a,b;
int ans1=0,ans2=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d %d",&a,&b);
	ans1=a+b;
	ans2=a*b;
	if(ans1==15){
		puts("+");
		exit(0);
	}
	if(ans2==15){
		puts("*");
		exit(0);
	}
	else{
		puts("x");
		exit(0);
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define f first
#define s second
#define inf 1000000007
#define mugen 1<<30

ll N;
vector<vector<ll>>A(310,vector<ll>(310,0));
vector<vector<bool>>Ab(310,vector<bool>(310));


int main() {
    cin >> N;
    ll ans = 0;
    rep(i,N){
        rep(j,N) {
            cin >> A[i][j];
        }
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                if (i == j || j == k || k == i) continue;
                if (A[i][j] > A[i][k] + A[k][j]){
                    cout << -1 << endl;
                    return 0;
                }
                else if(A[i][j] == A[i][k] + A[k][j]){
                    Ab[i][j] = true;
                }
            }
        }
    }
    rep(i,N-1){
        repi(j,i+1,N){
            if (!Ab[i][j]) ans += A[i][j];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
bool cmp(int val1, int val2){
	return val1>val2;
}
int S(int n){
	int sum=0;
	while(n){
		sum+=n%10;
		n/=10;
	}
	return sum;
}
int main(){
	int n;
	cin>>n;
	printf("%s\n", n%S(n)==0 ? "Yes" :"No");
	return 0;
}

Measured memory_bytes: 256
import java.util.*
import java.util.ArrayDeque

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val p = sc.asSequence().take(n).map { it.toInt() }.toList()

    var min = p[0]
    var r = 0
    p.forEach {
        if (it <= min) {
            r++
            min = it
        }
    }
    print(r)
}


Measured memory_bytes: 58952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
  int h;
  while(cin>>h){
    if(h==0)return 0;
    int m[h][5];
    int dm[h][5];
    rep(i,h){
      rep(j,5){
        cin>>m[i][j];
      }
    }
    int res = 0;
    mm(dm,0);
    bool OK = true;
    while(OK){ //dmが全部0になるまで
      rep(i,h){
        int c[5];
        mm(c,0);
        rep(j,5){
          if(m[i][j]==0)continue;
          queue<int> que;
          que.push(j);
          int cnt = 0;
          int dx[2] = {1,-1};
          int v[5]= {0,0,0,0,0};
          while(que.size()){
            int p = que.front(); que.pop();
            v[p] = 1;
            for(int k=0;k<2;k++){
              int nx = p + dx[k];

              if(nx<0||nx>4){
                continue;
              }
              if(m[i][nx] != m[i][j] || v[nx]!=0){
                continue;
              }
              //cout<<"aA"<<endl;
              que.push(nx);
            }
            cnt++;
          }
          //cout<<cnt<<endl;
          if(cnt > 2){
            dm[i][j] = 1;
          }
        }
      }

      
      rep(i,h){
        rep(j,5){
          //cout<<dm[i][j]<<" ";
        }
        //cout<<endl;
      }

      int cnt = 0;
      //ここから消滅処理
      rep(i,h){
        rep(j,5){
          if(dm[i][j]==1){
            dm[i][j]=0;
            res += m[i][j];
            m[i][j] = 0;
          }else{
            cnt++;
          }
        }
      }
      if(cnt == h*5){
        OK = false;
      }

      //ここから落下処理
      for(int i = 1; i<h; i++){
        for(int j = 0; j < 5; j++){
          int k = i;
          while(m[k][j]==0){
            m[k][j] = m[k-1][j];
            m[k-1][j] = 0;
            k--;
            if(k<1)break;
          }
        }
      }

      //cout<<"res:"<<res<<endl;
      
      rep(i,h){
        rep(j,5){
          //cout<<m[i][j]<<" ";
        }
        //cout<<endl;
      }
      //cout<<endl;

    }

      cout<<res<<endl;
    }
  }



Measured memory_bytes: 3084
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  com <- BS.unpack <$> BS.getLine :: IO String
  putStr $ trim com ""

trim :: String -> String -> String
trim [] y = reverse y
trim (x:xs) y 
  | x == '0' = trim xs (x:y)
  | x == '1' = trim xs (x:y)
  | x == 'B' && y == mempty = trim xs y
  | x == 'B' = trim xs (tail y)


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	bool ans = false;
	FOR(cake,0,26)FOR(donut,0,20){
		if(4 * cake + 7 * donut == n){
			ans = true;
			break;
		}
	}
	Yes(ans);
	return 0;
}


Measured memory_bytes: 256
#define task "test"
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

typedef long long LL;
const int maxN = 300005;
const LL oo = 1e18;
int n, a[maxN];
LL f[maxN], g[maxN];

void pre(){
	priority_queue<int> heap;
	LL sum;

	while (!heap.empty()) heap.pop();

	sum = 0;
	for (int i = 1; i <= n; ++i){
		sum += a[i];
		heap.push(-a[i]);
	}

	f[n] = sum;
	for (int i = n+1; i <= 2*n; ++i){
		sum += a[i];
		heap.push(-a[i]);
		sum += heap.top();
		heap.pop();
		f[i] = sum;
	}

	while (!heap.empty()) heap.pop();

	sum = 0;
	for (int i = 3*n; i >= 2*n+1; --i){
		sum += a[i];
		heap.push(a[i]);
	}

	g[2*n+1] = sum;
	for (int i = 2*n; i >= 1; --i){
		sum += a[i];
		heap.push(a[i]);
		sum -= heap.top();
		heap.pop();
		g[i] = sum;
	}
}

int main(){
	//freopen(task".inp", "r", stdin);
	//freopen(task".out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= 3*n; ++i) scanf("%d", &a[i]);

	pre();

	LL ans = -oo;
	for (int i = n; i <= 2*n; ++i) ans = max(ans, f[i] - g[i+1]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5496
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
   
using namespace std;
typedef long long int ll;
  
int main()
{
	set<int> st;
  for(int i=0; i<3; i++){
    int a;
    scanf("%d", &a);
    st.insert(a);
  }
  
    printf("%d\n", st.size());
  
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main() {
    int r, g, b;
    scanf("%d %d %d", &r, &g, &b);

    int n;
    n = 100*r + 10 * g + b;
    if(n % 4 == 0){
        printf("YES\n");
    } else {
        printf("NO\n");
    }


    return 0;
}

Measured memory_bytes: 128
radixConvert b n
  | n < b = [n]
  | otherwise = (mod n b) : (radixConvert b (div n b))

main = do
  n <- readLn :: IO Int
  print $ minimum [sum (radixConvert 6 i) + sum (radixConvert 9 (n-i))| i<-[0..n]]
  


Measured memory_bytes: 892
N = input()
T = map(int, raw_input().split())
A = map(int, raw_input().split())
MOD = 10**9+7

prev = -1
TP = [None for _ in xrange(N)]
for i, t in enumerate(T):
    if t > prev:
        TP[i] = (t, t)
    else:
        TP[i] = (1, t)
    prev = t

prev = -1
AP = [None for _ in xrange(N)]
for i in xrange(N-1, -1, -1):
    a = A[i]
    if a > prev:
        AP[i] = (a, a)
    else:
        AP[i] = (1, a)
    prev = a

ans = 1
for i in xrange(N):
    lt, rt = TP[i]
    la, ra = AP[i]

    if rt < la or ra < lt:
        print 0
        exit()

    s = sorted([lt, rt, la, ra])
    ans = ans * (s[2]-s[1]+1) % MOD
print ans


Measured memory_bytes: 39544
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    vector<P> pos;
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == 'B')
                pos.emplace_back(i, j);
        }
    }
    int ret = 0;
    int sz = pos.size();
    for (int i = 0; i < sz; i++)
    {
        for (int j = i + 1; j < sz; j++)
        {
            ret = max(ret, abs(pos[i].first - pos[j].first) + abs(pos[i].second - pos[j].second));
        }
    }
    cout << ret << endl;
}



Measured memory_bytes: 3220
#include<stdio.h>
#include<string.h>
#define inf 1072114514

int dx4[4]={1,-1,0,0};
int dy4[4]={0,0,1,-1};

#define size 16777216

int deque[size],fpt=size/2,bpt=(size/2)+1;

void push(int v,int isbk){
  if(isbk){deque[bpt]=v;bpt++;}
  else{deque[fpt]=v;fpt--;}
}

int pop(int isbk){
  int r;
  if(isbk){bpt--;r=deque[bpt];deque[bpt]=inf;}
  else{fpt++;r=deque[fpt];deque[fpt]=-inf;}
  return r;
}

int main(){
  int h,w;
  int sh,sw;
  int th,tw;
  char s[1024][1024];
  int dl[1024][1024];
  scanf("%d%d%d%d%d%d",&h,&w,&sh,&sw,&th,&tw);
  for(int i=0;i<=w+1;i++){s[0][i]='.';s[h+1][i]='.';}
  for(int i=1;i<=h;i++){
    s[i][0]='.';
    scanf("%s",&s[i][1]);
    s[i][w+1]='.';
    for(int j=1;j<=w;j++){dl[i][j]=inf;}
  }
  push(1024*sh+sw,0);
  dl[sh][sw]=0;
  while(fpt+1!=bpt){
    int v,ci,cj,ni,nj;
    v=pop(0);
    ci=(v/1024);cj=(v%1024);
    //printf("%d %d : %d\n",ci,cj,dl[ci][cj]);
    if(ci==th&&cj==tw){printf("%d\n",dl[th][tw]);return 0;}
    for(int k=0;k<4;k++){
      ni=ci+dx4[k];nj=cj+dy4[k];
      if(s[ni][nj]=='#'){continue;}
      if(dl[ci][cj]<dl[ni][nj]){
        dl[ni][nj]=dl[ci][cj];
        push(1024*ni+nj,0);
      }
    }
    for(int i=-2;i<=2;i++){
      for(int j=-2;j<=2;j++){
        ni=ci+i;nj=cj+j;
        if(s[ni][nj]=='#'){continue;}
        if(dl[ci][cj]+1<dl[ni][nj]){
          dl[ni][nj]=dl[ci][cj]+1;
          push(1024*ni+nj,1);
        }
      }
    }
  }
  puts("-1");
  return 0;
}

Measured memory_bytes: 8268
n=list(input())
for i in range(1<<3):
    cnt=int(n[0])
    l=[n[0]]
    for j in range(3):
        if (i>>j)%2==1:
            cnt+=int(n[j+1])
            l+="+"+n[j+1]
        else:
            cnt-=int(n[j+1])
            l+="-"+n[j+1]
    if cnt==7:
        print("".join(l)+"=7")
        break

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

int a[5];
int ttl = 0;
int main() {
  for (int i = 0; i < 5; i++) cin >> a[i], ttl += (a[i] + 9) / 10 * 10;
  int mn = 11;
  for (int i = 0; i < 5; i++) mn = min(mn, a[i] % 10 + (a[i] % 10 == 0 ? 10 : 0));
  ttl -= (10 - mn);
  cout << ttl << endl;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    int count = 0;
    for(int i = 0;i < s.size();i++){
        if(s.at(i) != t.at(i))count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3916
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  string S; cin>>S;
  ll N=S.size();
  vector<ll> list(3,0);//a,b,cの順
  rep(i,N)
  {
    int hoge=S.at(i)-'a';
    list.at(hoge)++;
  }
  sort(list.begin(),list.end());
  if(list.at(0)==0&&list.at(1)==0)
  {
    if(list.at(2)==1)
    {
      cout<<"YES"<<endl; 
      return 0;
    }
    cout<<"NO"<<endl;
    return 0;
  }  
  if(list.at(0)==0)
  {
    if(list.at(1)==1&&list.at(2)==1) {cout<<"YES"<<endl; return 0;}
    cout<<"NO"<<endl;
    return 0;
  }
  if(list.at(0)==list.at(1)&&list.at(0)==list.at(2)) {cout<<"YES"<<endl; return 0;}
  if(list.at(0)==list.at(1)&&list.at(0)+1==list.at(2)) {cout<<"YES"<<endl; return 0;}
  if(list.at(0)+1==list.at(1)&&list.at(0)+1==list.at(2)) {cout<<"YES"<<endl; return 0;}
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 3808
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a;
	while(cin>>a,a){
		vector<int>in(5);
		in[0]=a;
		rep(i,4)cin>>in[i+1];
		bool h[3]={0};
		rep(i,5)in[i]--;
		rep(i,5)h[in[i]]=true;
		int sum=h[0]+h[1]+h[2];
		if(sum==3||sum==1){
			rep(i,5)cout<<3<<endl;
			continue;
		}
		if(!h[0]){
			rep(i,5)if(in[i]==1)cout<<1<<endl;
			else cout<<2<<endl;
		}else if(!h[1]){
			rep(i,5)if(in[i]==2)cout<<1<<endl;
			else cout<<2<<endl;
		}else if(!h[2]){
			rep(i,5)if(in[i]==0)cout<<1<<endl;
			else cout<<2<<endl;
		}
	}
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//~ const int mod = (int)1e9 + 7;
const int mod = 998244353;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}


pair<string,pair<int,int> > v[110];

void sort_v(int n){
	rep(i,1,n){
		int key = i;
		rep(j,i+1,n){
			if(v[key].f.compare(v[j].f) == 0){
				int x = v[key].s.f;
				int y = v[j].s.f;
				if(x<y)
					key = j;
			}
		}
		swap(v[i],v[key]);
	}
}

int main(void) 
{	
	int n; cin>> n;
	string s = ""; int p = 0;
	rep(i,1,n){
		cin>> s >> p;
		v[i] = mp(s,mp(p,i));
	}
	sort(v+1,v+1+n);

	
	sort_v(n);

	rep(i,1,n)
		cout<<v[i].s.s<<" "<<endl; 
	return 0;
} 



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

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

using namespace std;
using namespace __gnu_pbds;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
#define oset tree<pi, null_type,greater<pi>, rb_tree_tag,tree_order_statistics_node_update>


int main()
{
    map<char, char> mp;
    mp['C'] = 'G';
    mp['G'] = 'C';
    mp['A'] = 'T';
    mp['T'] = 'A';
    char c;
    cin >> c;
    cout << mp[c] << '\n';

    return 0;
}


Measured memory_bytes: 3532
import math
def mark(s, x):
    for i in xrange(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in xrange(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in xrange(0,n) if s[i] and i > 1]

n = int(input())

arr = sieve(n+1)
f = math.factorial(n)

primes = [0 for i in range(n+1)]


for i in arr:
	while f%i == 0:
		f/= i
		primes[i] += 1

ans = 1
for i in primes:
	if i!= 0:
		ans *= i+1

print ans%(10**9+7)

Measured memory_bytes: 2696
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}

template <class T>
T lcm(T a, T b) {
  T h = gcd(a, b);
  return (h != 0) ? (a * (b / h)) : 0;
}

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

  ll ans = lcm(A, B);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
A,B,C,D,E,F = map(int, input().split())
ans = {"w":A*100, "s":0}
def density(water, sugar):
    return 100*sugar/(water+sugar)

G = gcd(C,D)
for a in range(31):
    for b in range(31):
        water = (a*A+b*B)*100
        if water>F:
            continue
        max_sugar = min((a*A+b*B)*E, F-water)
        sugar = int(G*(max_sugar//G))
        if sugar<min(C,D): continue
        if water+sugar==0: 
            continue
        if density(water, sugar)>density(ans["w"], ans["s"]):
            ans["w"] = water
            ans["s"] = sugar
            #print(water, sugar)
print(ans["w"]+ans["s"], ans["s"])

Measured memory_bytes: 5044
from functools import reduce

def fact(n):
    if n == 0:
        return 1
    return reduce(lambda a,b:a*b, range(1, n + 1))

def C(n, r):
    return fact(n) // fact(n - r) // fact(r)

N, A, B = map(int, input().split(" "))
v = sorted(map(int, input().split(" ")), reverse=True)
S = sum(v[:A])
print(S / A)

used = v[:A].count(v[A-1])
all = v.count(v[A-1])

if v[0] == v[A - 1]:
    ub = min(B, all)
    print(sum(C(all, i) for i in range(A, ub + 1)))
else:
    print(C(all, used))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  	int a,b;
  	long aa = 0,bb = 0;
  	scanf("%d %d",&a,&b);
  	for(int i = 0;i < b;i++) aa += a*pow(10,i);	
  	for(int i = 0;i < a;i++) bb += b*pow(10,i);
  	if(to_string(aa) <= to_string(bb)) printf("%ld\n",aa);
  	else printf("%ld\n",bb);
  
    return 0;   
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int k;
    cin >> k;
    int A, B;
    cin >> A>>B;
    int ff = 0;
    for(int i=A;i<=B; i++){
        if(i%k==0){
            ff = 1;
            cout<<"OK"<<endl;
            break;}
    }
    if(ff==0)
        cout<<"NG"<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
int c,n;
string s[1111];
int calc(int i,int j){
  int tmp=0;
  tmp+=s[i][j]=='1';
  tmp+=s[n-1-i][j]=='1';
  tmp+=s[i][n-1-j]=='1';
  tmp+=s[n-1-i][n-1-j]=='1';
  return tmp;
}
signed main(){
  cin>>c>>n;
  for(int i=0;i<n;i++) cin>>s[i];
  int cnt=0;
  for(int i=0;i<n/2;i++){
    for(int j=0;j<n/2;j++){
      if(calc(i,j)==0||calc(i,j)==4) cnt++;
    }
  }
  c--;
  int ans=cnt==n*n/4;
  while(c--){
    int d;
    cin>>d;
    for(int k=0;k<d;k++){
      int i,j;
      cin>>i>>j;
      i--;j--;
      if(calc(i,j)==0||calc(i,j)==4) cnt--;
      if(s[i][j]=='1') s[i][j]='0';
      else s[i][j]='1';
      if(calc(i,j)==0||calc(i,j)==4) cnt++;
    }
    ans+=cnt==n*n/4;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4108
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()

arr.sort(reverse=True)
#print(arr)
#print(arr[n//3],arr[(2*n)//3])
ans=0
for i in range(1,n+1):
    ans+=arr[2*i -1]
print(ans)

Measured memory_bytes: 122252
#include<bits/stdc++.h>
using namespace std;
int main(){
    int hp,N;
    cin >> hp >> N;
    int dmg[N];
    int sumd = 0;
    for(int i = 0;i<N;i++){
        cin >> dmg[i];
        sumd += dmg[i];
    }
    if(hp <= sumd){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<stdio.h>

using namespace std;
int main()
{
    char str[1000];
    cin >> str;
    int n=strlen(str);
    for(int i=0;i<n;i++){
        int num=(int)str[i];
        num-=3;
        if(num<65){
            num=90-64+num;
        }
        unsigned char moji=(char)num;
        printf("%c", moji);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
long long int x[100002];
using namespace std;
int main()
{
	long long int n,a,b,p=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	  {
	  	cin>>x[i];
	  	
	  }
	sort(x+1,x+1+n);  
	for(int i=1;i<n;i++)
	  {
	  	if((x[i+1]-x[i])*a>=b)
	  	  p+=b;
	  	else
		  p=p+(x[i+1]-x[i])*a;  
 	  }  
 	cout<<p;  
	return 0;
}

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

int N;
int Y;
int main(){
    cin >> N >> Y;
    Y /= 1000;

    for(int i = 0;i <= N;i++){
        for(int j = 0;j <= N;j++){
            if(i + j > N) break;
            int k = N - i - j;
            if(Y == i * 10 + j * 5 + k){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int n ;
  cin >> n ;
  vector<int> wei(n) ;
  vector<double> plu(n+1) ;
  double sum = 0 ;
  double num1, num2 ;
  plu.at(0) = 0 ;
  
  REP(i, n){
    cin >> wei.at(i) ;
  }
  REP(i, n){
    sum += wei.at(i) ;
  }
  REP(i,n){
    plu.at(i+1) = plu.at(i) + wei.at(i) ;
   // cout << plu.at(i) <<endl ; 
    if(plu.at(i)>=sum/2){
      num1 = plu.at(i-1) ;
      num2 = plu.at(i) ;
      break ;
    }
  }
 // cout << num1 << " "<<num2 <<endl ;
  if(abs(num1-sum/2)>=abs(num2-sum/2)){
    cout <<abs(sum-2*num2)<<endl ;
  }
  else{
    cout <<abs(sum-2*num1)<<endl ;
  }
  
  return 0 ;
}




Measured memory_bytes: 256