akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
char c[10000];
int main() {
  char a[81], b[81];
  int i, j, k, n, s;
  char m;
  scanf("%d", &n);
  for (s = 0; s < n; s ++) {
    for (i = 0; i < 81; i ++) {
      a[i] = 0; b[i] = 0;
    }
    scanf(" %s", c);
    for (i = 0; i < 82 && c[i] != 0; i ++);
    for (j = 0; j < i; j ++) a[j] = c[i - j - 1];
    k = i;
    scanf(" %s", c);
    for (i = 0; i < 82 && c[i] != 0; i ++);
    if(i == 81 || k == 81){
      printf("overflow\n");
      continue;
    }
    for (j = 0; j < i; j ++) b[j] = c[i - j - 1]; 
    if (k > i) {
      for (j = i; j < k; j ++) b[j] = '0';
    } else if (i > k) {
      for (j = k; j < i; j ++) a[j] = '0';
    }
    for (i = 0; i < 100; i ++) c[i] = 0;
    for (i = 0; a[i] || b[i]; i ++) {
      if (i == 80) {
	printf("overflow");
	i++;
	break;
      }
      m = a[i] - '0' + b[i] - '0';
      if (m > 9) {
	if (a[i + 1]) {
	  a[i + 1] += 1;
	} else {
	  a[i + 1] = '1'; b[i + 1] = '0';
	}
	m -= 10;
      }
      m += '0'; c[i] = m;
    }
    i --;
    for (; i < 80 && i > -1; i --) printf("%c", c[i]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;

using int64 = long long;
using i64 = int64;

template<typename T>
using p_que = priority_queue<T>;
template<typename T>
using rp_que = priority_queue<T, vector<T>, greater<T>>;

constexpr int INF = (1 << 30) - 1;
constexpr int64 INF64 = (1ll << 60) - 1;

#define rep(i, N) for(int i=0;i<(int)(N);++i)
#define rep1(i, N) for(int i=1;i<=(int)(N);++i);
#define fs first
#define sc second
#define e_b emplace_back
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& m) {
	os << "{" << endl;
	for (auto& e : m) os << "(" << e.first << ", " << e.second << ")" << endl;
	return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
	os << "{" << endl;
	for (auto& e : s) os << ", " << e << endl;
	return os << "}";
}

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

int64 gcd(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	int64 r;
	while ((r = y % x) != 0) {
		y = x;
		x = r;
	}
	return x;
}
int64 lcm(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	return x / gcd(x, y) * y;
}

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

void Main();
signed main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	Main();
}

/*----------------------------Insert from here!----------------------------*/

map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};

/*----------------------------Insert above here----------------------------*/

//const int MOD = 998244353;
//const int MOD = 1e9 + 7;

void Main() {
	int A, B; cin >> A >> B;

	int ans = B / A;
	if (B % A != 0) ans++;

	cout << ans << endl;
}


Measured memory_bytes: 3152
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(){
        
        string[] inputND = Console.ReadLine().Split(' ');
        int n = int.Parse(inputND[0].ToString());
        int d = int.Parse(inputND[1].ToString());
        
        int[,] x = new int[n,d];
        int ans = 0;
        
        for(int i=0; i<n; i++){
            string[] inX = Console.ReadLine().Split(' ');
            for(int j=0; j<d; j++) x[i,j] = int.Parse(inX[j]);
        }
        
        for(int k=0; k<n; k++){
            for(int l=k+1; l<n; l++){
                
                double dist=0;
                for(int m=0; m<d; m++) dist += Math.Pow(x[k,m] - x[l,m],2);
                dist = Math.Sqrt(dist);
                if(dist-Math.Floor(dist)==0) ans++;
                
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
S = input()
N = len(S)
haba1 = int((N-1)/2)
haba2 = int((N+3)/2)
con1 = ""
con2 = ""
for i in range(0,haba1):
    con1 += S[i]
for i in range(haba2-1,N):
    con2 += S[i]
if S[::-1] != S :
    print("No")
elif con1[::-1] != con1 :
    print("No")
elif con2[::-1] != con2 :
    print("No")
else :
    print("Yes")


Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final char[] chs = sc.next().toCharArray();
			
			int mod = 0;
			for(int i = 0; i < chs.length; i++) {
				mod += chs[i] - '0';
				mod %= 9;
			}
			
			System.out.println(mod == 0 ? "Yes" : "No");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 36596
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define mod(x) ((x % MOD) + MOD) % MOD
#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int,int> P;

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


signed main()
{
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  int ans = INF;
  for (int i = 0; i + K - 1 < N; i++) {
    int j = i + K - 1;
    ans = min(ans, abs(x[i]) + abs(x[i]-x[j]));
    ans = min(ans, abs(x[j]) + abs(x[i]-x[j]));
  }

  cout << ans << endl;

  return 0;
}


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

int n;
int a[200005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,[](const int &a,const int &b){
        return a>b;
    });
    int tot=n-1;
    long long ans=0;
    for(int i=0;i<n;i++){
        if(tot){
            ans+=a[i];
            tot--;
        }
        if(tot&&i){
            ans+=a[i];
            tot--;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4392
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
    $str = trim(fgets(STDIN));
    for($j = 0; $j < strlen($str); $j++){
        @$map[$i][$str[$j]]++;
    }
}
ksort($map[0]);
foreach($map[0] as $k => $v){
    foreach($map as $m){
        $v = min($v, @$m[$k]);
    }
    echo str_repeat($k, $v);
}


Measured memory_bytes: 4856
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      static long MOD = 1000000007L;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N+1; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //solve
         long[] fac = new long[N+5];
         long[] invfac = new long[N+5];
         fac[0] = 1L;   invfac[0] = 1L;
         for(int i=1; i <= N+4; i++)
         {
            fac[i] = (fac[i-1]*i)%MOD;
            invfac[i] = power(fac[i], MOD-2, MOD);
         }
         int tag = -1;
         HashSet<Integer> set = new HashSet<Integer>();
         for(int x: arr)
            if(!set.add(x))
               tag = x;
         int left = 0;
         int right = 0;
         for(int i=0; i <= N; i++)
         {
            if(arr[i] == tag)
               break;
            left++;
         }
         for(int i=N; i >= 0; i--)
         {
            if(arr[i] == tag)
               break;
            right++;
         }
         int ends = left+right;
         StringBuilder sb = new StringBuilder(N+"\n");
         for(int k=2; k <= N+1; k++)
         {
            long total = (fac[N+1]*invfac[N+1-k])%MOD;
            total = (total*invfac[k])%MOD;
            if(ends-k+1 >= 0)
            {
               long extra = (fac[ends]*invfac[k-1])%MOD;
               extra = (extra*invfac[ends-k+1])%MOD;
               total -= extra;
            }
            if(total < 0)  total += MOD;
            sb.append(total+"\n");
         }
         System.out.print(sb);
      }
      public static long power(long x, long y, long p) 
      { 
          long res = 1L;      
          x = x % p;  
          while (y > 0) 
          { 
              if((y & 1)==1) 
                  res = (res * x) % p; 
              y = y >> 1;  
              x = (x * x) % p;  
          } 
          return res; 
      } 
   }

Measured memory_bytes: 47488
N = int(input())
a = list(map(int, input().split()))

a.sort()

l = 0
r = 1
ans = 0

if N == 1:
    print(1)
    exit()

while r < N:
    if a[r] - a[l] <= 2 or r == l:
        ans = max(ans, r - l + 1)
        r += 1
    else:
        l += 1

print(ans)


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

#define MOD 1000000007
typedef unsigned long long ull;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), penalty(n);
  int ac_count = 0, penalty_count = 0;
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;

    // AC済なら無視
    if (ac[p] != 0) {
      continue;
    }
    // 未AC
    if (s == "WA") {
      penalty[p]++;
    } else {
      ac[p]++;
      ac_count++;
      penalty_count += penalty[p];
    }
  }

  cout << ac_count << " " << penalty_count;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <map>
#include <deque>
using namespace std;

long long d[100000];
long long h[100000];
long long s[100000];
int main(){
	long long N,H,mx;
	cin >> N >> H;
	mx = H;
	for(int i = 0 ; i < N-1 ; i++){
		cin >> d[i] >> h[i];
		s[i+1] = s[i] + d[i];
	}
	
	int ans = 0;
	deque<int> Q;
	for(int i = 0 ; i < N-1 ; i++){

		//if( i > 10 ) return 0;
		//cout << "s" << i << " " << H << " " << ans << endl;
		while( Q.size() && h[Q.back()] <= h[i]) Q.pop_back();
		Q.push_back(i);
		while( Q.size() && s[i] - s[Q.front()] > mx) Q.pop_front();
		//for(int j = 0 ; j < Q.size() ; j++) cout << h[Q[j]] << " (" << Q[j] << "," << mx - (s[i]-s[Q[j]]) << ") ";cout << endl;
		if( H <= d[i] ){
			for(int j = 0 ; j < Q.size() ; j++){
				long long heal_max = max(0ll, mx - (s[i] - s[Q[j]]) - H );
				
				//cout << i << " " << Q[j] << " " << s[i] << " " << s[Q[j]] << " " << H << " " << heal_max << endl;
				long long need = d[i] - H + 1;
				long long use = min(need,heal_max) / h[Q[j]];
				//cout << Q[j] << " : " << need << " <========== " << " " << heal_max << endl;
				//if( use == 0 ) continue;
				H += use * h[Q[j]];
				//H = min(H,mx - (s[i] - s[Q[j]]));
				ans += use;
				if( H > d[i] ) break;
				
				if( j+1 >= Q.size() || mx - (s[i] - s[Q[j]]) - H >= h[Q[j+1]] ){
					//cout << H << " " << heal_max << endl;
					ans++;
					H = min( H + h[Q[j]], mx - (s[i] - s[Q[j]]) );
				}
				if( H > d[i] ) break;
			}
		}
		H -= d[i];
		if( H <= 0 ){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int A[110000];
signed main() {
    cin >> N;
    rep(i, N) { cin >> A[i]; }
    int ans = 0;
    rep(i, N - 1) {
        ans += A[i] / 2;
        A[i] %= 2;
        int c = min(A[i], A[i + 1]);
        ans += c;
        A[i + 1] -= c;
    }
    ans += A[N - 1] / 2;
    cout << ans << endl;
}

Measured memory_bytes: 1024
C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))

if (C1[0]-C1[1]==C2[0]-C2[1] and C2[0]-C2[1] ==C3[0]-C3[1]) and (C1[0]-C1[2]==C2[0]-C2[2] and C2[0]-C2[2]==C3[0]-C3[2]):
    print('Yes')
else:
    print('No')


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

class Pos{
public:
  int x, y, z;
  Pos(int a, int b, int c): x(a), y(b), z(c){}
};

bool operator<(const Pos& l, const Pos& r){return l.x < r.x;}

int main(){
  int X, Y, Z, K; cin >> X >> Y >> Z >> K;
  vector<long long> A(X), B(Y), C(Z);

  for(int i=0; i<A.size(); ++i) cin >> A[i];
  for(int i=0; i<B.size(); ++i) cin >> B[i];
  for(int i=0; i<C.size(); ++i) cin >> C[i];

  sort(A.begin(), A.end(), greater<long long>());
  sort(B.begin(), B.end(), greater<long long>());
  sort(C.begin(), C.end(), greater<long long>());

  A.push_back(numeric_limits<long long>::min());
  B.push_back(numeric_limits<long long>::min());
  C.push_back(numeric_limits<long long>::min());

  priority_queue<pair<long long, Pos>> q;
  q.push(make_pair(A[0]+B[0]+C[0], Pos(0, 0, 0)));

	set<int> s;
	s.insert(0);

  vector<long long> ans;
  while(ans.size() < K){
    ans.push_back(q.top().first);
    auto pos = q.top().second;
    q.pop();

		for (int i = 0; i < 3; i++)
		{
			int a = pos.x;
			int b = pos.y;
			int c = pos.z;
			if (i == 0) a++;
			if (i == 1) b++;
			if (i == 2) c++;
			//hashを作る
			int hash = (a << 20) + (b << 10) + c;
			if (s.find(hash) == s.end()) {
				s.insert(hash);
				q.push(make_pair(A[a] + B[b] + C[c], Pos(a, b, c)));
			}
		}
  }

  for(auto answer : ans){
    cout << answer << endl;
  }

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  vector<bool> chk(26, false);
  vector<vector<int>> index(26, vector<int>());
  rep(i, s.size()){
    int now = s.at(i) - 'a';
    chk.at(now) = true;
    index.at(now).push_back(i);
  }
  rep(i, t.size()){
    int now = t.at(i) - 'a';
    if(chk.at(now) != true){
      cout << -1 << endl;
      return 0;
    }
  }

  int ni = s.size();
  ll ans = 0;
  rep(i, t.size()){
    int now = t.at(i) - 'a';
    auto itr = upper_bound(index.at(now).begin(), index.at(now).end(), ni);
    if(itr == index.at(now).end()){
      ans += index.at(now).front() + (s.size()-ni);
      ni = index.at(now).front();
    }else{
      ans += *itr - ni;
      ni = *itr;
    }
  }
  ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	long long int n, min;
	scanf("%ld", &n);
	
	long long int i;
	for(i=sqrt(n); i>=1; i--){
		if(n%i==0){
		min=i+n/i; break;
		}
	}
	
	printf("%lld", min-2);
	
return 0;
}

Measured memory_bytes: 128
s = input()
if len(s) % 2 != 0:
    print("No")
    exit()
else:
    S = [s[i] + s[i+1] for i in range(0, len(s), 2)]
    sS = list(set(S))
    if len(sS) == 1 and sS[0] == "hi":
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
import sys
def side(p1,p2):
  global D
  y1,x1=p1
  y2,x2=p2
  dy=y2-y1
  dx=x2-x1
  for p3 in D[::-1]:
    if p1==p3 or p2==p3:continue
    if (p3[1]-x1)*dy-dx*(p3[0]-y1)<0:return 0
  else:return 1

while 1:
  n=input()
  if n==0:break
  D=sorted([list(input()) for i in range(n)])
  p=p1=D[0]
  D1=D[:]
  while True:
    for p2 in D1:
      if p1!=p2 and side(p1,p2):break
    p1=p2
    D1.remove(p2)
    if p2==p:break
  print len(D1)

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

int main() {
	string s;
	cin >> s;

	int n= s.length() - 1;

	if(s[n] != 's') {
		cout << s << 's';
	} else {
		cout << s << "es";
	}

	return 0;
}

Measured memory_bytes: 3628
# include <iostream>
# include <algorithm>
using namespace std;
int main()
{
	int n,k,s;
	s=0;
	cin>>n>>k;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0; i<k; i++)
	{
		s=s+a[i];
	}
	cout<<s;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
int ans;
int main(){
	int a,b;
	cin>>a>>b;
	ans+=a;
	ans+=b/2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll a,b,c,d ; cin >>a>>b>>c>>d;
  ll c_divide=b/c-(a-1)/c;
  ll d_divide=b/d-(a-1)/d;
  ll cd_divide=b/(c*d/(__gcd(c,d)))-(a-1)/(c*d/(__gcd(c,d)));
  cout<<b-a+1-c_divide-d_divide+cd_divide<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)%mod*(x)%mod);
        x = (x*x)%mod;
        n = n/2;
    }
    return res%mod;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n%1000==0){cout<<0;}
    else cout<<1000-n%1000;
	return 0;
}


Measured memory_bytes: 3652
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 505;
int H , W , h , w;
int a[N][N];

int main(){
    scanf("%d%d%d%d",&H,&W,&h,&w);
    if(H % h == 0 && W % w == 0) puts("No");
    else {
        puts("Yes");
        int remain = H * W - (H / h) * h * (W / w) * w;
        int pos = (H / h) * (W / w) / remain + 1;
        int neg = -(h * w - 1) * pos - 1;
        rep(i,0,H) rep(j,0,W) printf("%d%c",i%h==h-1&&j%w==w-1?neg:pos," \n"[j+1==W]);
    }
    return 0;
}


Measured memory_bytes: 1280
s = str(input())

def calc(s):
    if len(s) == 0: return [0]
    if len(s) == 1: return [int(s)]
    tmp = []
    for i in range(len(s)):
        left = s[:i+1]
        right = s[i+1:]
        x = int(left)
        for j in calc(right):
            tmp.append(x + j)
    return tmp

print(sum(calc(s)))

Measured memory_bytes: 3064
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
}
int q[N];
char s[N];
map<int,int>mp,vis;
int main(){
	char c;
	cin>>c;
	if(c>='A'&&c<='Z'){
		cout<<"A";
	}
	else cout<<"a";
}
/*

 */

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

struct Vertex {int c=0, d=-1;};
using Graph = vector<vector<int>>;

struct Query {int v, d, c;};

using Node = pair<int, int>; // id, d

int main() {
  int N, M;
  cin >> N >> M;

  Graph G(N);
  for(auto i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  int Q;
  cin >> Q;
  vector<Query> query(Q);
  for(auto& i: query) cin >> i.v >> i.d >> i.c, --i.v;

  vector<Vertex> V(N);
  reverse(begin(query), end(query));
  for(auto q: query) {
    queue<Node> que;
    vector<bool> used(N);
    used[q.v] = true;
    if(V[q.v].c == 0) V[q.v].c = q.c;
    if(V[q.v].d < q.d) que.push({q.v, V[q.v].d=q.d});

    while(!que.empty()) {
      int v, d;
      tie(v, d) = que.front();
      que.pop();
      if(d == 0) break;

      for(auto i: G[v]) if(!used[i]) {
        used[i] = true;
        auto& to = V[i];
        if(to.d >= d-1) continue;

        if(to.c == 0) to.c = q.c;
        que.push({i, to.d=d-1});
      }
    }
  }

  for(auto v: V) cout << v.c << endl;
}


Measured memory_bytes: 8952
n = int(input())
h = [int(i) for i in input().split()]
# dpの最小値を変更する関数
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
    
# 無限大の値
f_inf = float('inf')
# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)
# 初期条件
dp[0] = 0
# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i-1]))
    # 一番目の足場では一つ前しか存在しない
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i -2]))
print(dp[n-1])

Measured memory_bytes: 14056
#include<stdio.h>

int main(void)
{
  int N, K;
  scanf("%d %d", &N, &K);

  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d", &A[i]);
  }

  for(int i=K-1;i<N-1;i++){
    if(A[i+1] > A[i-K+1]) printf("Yes\n");
    else printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 2396
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
    ll r,d,x;
    cin >> r >> d >> x;
    for(ll i=0;i<10;i++){
        x*=r;
        x-=d;
        cout << x << endl; 
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
		using namespace std;
		#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
		#define ll long long
		#define ld long double
		#define fi first
		#define se second
		#define mp make_pair
		#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower)
		#define upper(a) transform(a.begin(),a.end(),a.begin(),::toupper)
		//#define min(a) *min_element(a.begin(),a.end())
		//#define max(a) *max_element(a.begin(),a.end())
		#define pdd pair<long double,long double>
		#define prnt(a) for(auto x:a) cout<<x<<" ";
		#define pb push_back
		#define all(x) x.begin(),x.end()
		#define endl '\n'
		#define PI 3.1415926535897932385
		#define INF 1000000000000000
		#define MOD 1000000007
		#define ve  vector<ll>;
		

		int main()
		{  ll n;
			cin>>n;
			vector<ll> a(n);
			for(ll i=0;i<n;i++)
			{
				cin>>a[i];
			}
			sort(all(a));
			ll min=INT_MAX;
			for(ll i=*min_element(all(a));i<=*max_element(all(a));i++)
			{
				ll temp=0;
			for(ll j=0;j<n;j++)
			{
                temp+=(i-a[j])*(i-a[j]);
			}
			if(temp<min)
			{
				min=temp;
			}

			}
			cout<<min<<endl;
			return 0;
		

	}


Measured memory_bytes: 3588
a,b,k = map(int,input().split())
class stack:
    def __init__(self):
       self.items = []
        
    def is_empty(self):
       return self.items == []
        
    def push(self, item):
       self.items.append(item)
        
    def pop(self):
       return self.items.pop()
        
    def peek(self):
       return self.items[len(self.items)-1]
        
    def size(self):
       return len(self.items)

ansstack = stack()
for i in range(1, max(a, b) + 1):
    if a % i == 0 and b % i == 0:
        ansstack.push(i)
ans = 0
for i in range(k):
    ans = ansstack.pop()
print(ans)

Measured memory_bytes: 3064
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    ll N, P;
    cin >> N >> P;

    ll answer = 1;

    // 素因数分解 (factoring)
    FOR(i, 2, sqrt(P)+1){

        int count = 0;
        while(P % i == 0){
            // cout << i << "で割れました" << endl;
            count++;
            P /= i;
        }
        int n = floor(count / N);
        if(n>0){
            answer *= pow(i, n);
        }
    }

    // 割っていった残りも素因数である
    int n = floor(1/N);
    if(n>0){
        answer *= pow(P, n);
    }
    
    p(answer);
    return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/agc003/tasks/agc003_a
//A - Wanna go back home
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    string S; cin>>S; 
    bool has_n=false,has_w=false,has_s=false,has_e=false;
    for(const auto& c:S){
        if(c=='N'){
            has_n=true;
        }else if(c=='W'){
            has_w=true;
        }else if(c=='S'){
            has_s=true;
        }else if(c=='E'){
            has_e=true;
        }else{
            assert(0);
        }
    }   
    bool ans=(has_n==has_s&&has_w==has_e);
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String strn = input.readLine( );
		int n = Integer.parseInt(strn);

		String str = input.readLine( );
		String[] s = str.split("");

		int answer = 0;
		int sum = 0;

		for(int i=0; i<n; i++){
			if(s[i].equals("I")){
				sum = sum+1;
				if(answer<sum){
					answer = sum;
				}
			}else {
				sum = sum-1;
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 8404
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int M1 = sc.nextInt();
		int temp = sc.nextInt();
		int M2 = sc.nextInt();
		int D3 = sc.nextInt();
		
		int result = M1 == M2 ? 0 : 1;
		
		System.out.println(result);
		
	}
	
	
	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

void
swap(int* v, int i, int j) {
  int t = v[i];
  v[i] = v[j];
  v[j] = t;
}

int main() {

  int w, n; cin >> w >> n;
  int xs[w];
  rep (i, w) xs[i] = (i+1);
  rep (i, n) {
    char comma;
    int a, b; cin >> a >> comma >> b;
    --a; --b;
    swap(xs, a , b);
  }
  rep (i, w) cout << xs[i] << endl;

  return 0;
}

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

int main(){
    int n,d,x;
    cin >> n >> d >> x;

    vector<int> a(n);

    rep(i,n){
    cin >> a[i];        
    }

    int ans =0;


    
    rep(i,n){
    int date=1;
    int j=1;
    while(date<=d){
        
        date=a[i]*j+1;
       // cout << date << endl;
        j++;
        ans++;

      }   
    }

    cout << ans+x << endl;
    return 0;

}

Measured memory_bytes: 3564
Ns,Ms,=input().split()
N=int(Ns)
M=int(Ms)
H=list(map(int,input().split()))
A=[]
B=[]
ans_arr=[]
for i in range(N):
    ans_arr.append(0)

for i in range(M):
    Ax,Bx=map(int,input().split())
    if  H[Ax-1]==H[Bx-1]:
        ans_arr[Ax-1]=-1
        ans_arr[Bx-1]=-1
    elif H[Ax-1]<H[Bx-1]:
        ans_arr[Ax-1]=-1
    else:
        ans_arr[Bx-1]=-1

ans=0
for i in ans_arr:
    if i!=-1:
        ans+=1

print(ans)

Measured memory_bytes: 20140
n = int(input())

def baseNeg2(N: int) -> str:
        negTwoL = [0]*32
        index = len(negTwoL)-1
        if N >=0:
            while index > -1:
                if N >= 2**index:
                    if index % 2 == 0:
                        negTwoL[index] += 1
                    else:
                        negTwoL[index] += 1
                        negTwoL[index+1] += 1
                    N -= 2**index
                index -= 1
        else:
            N=-N
            while index > -1:
                if N >= 2**index:
                    if index % 2 == 1:
                        negTwoL[index] += 1
                    else:
                        negTwoL[index] += 1
                        negTwoL[index+1] += 1
                    N -= 2**index
                index -= 1

        if N >= 0:
            flag = 1
            while flag:
                flag = 0
                index2 = 0
                while index2 < len(negTwoL)-2:
                    if negTwoL[index2] > 1:
                        flag = 1
                        if negTwoL[index2] % 2 == 0:
                            if negTwoL[index2+1] == 1:
                                negTwoL[index2+1] = 0
                            else:
                                negTwoL[index2+1] += 1
                                negTwoL[index2+2] += 1
                            negTwoL[index2] = 0
                        else:
                            if negTwoL[index2+1] == 1:
                                negTwoL[index2+1] = 0
                            else:
                                negTwoL[index2+1] += 1
                                negTwoL[index2+2] += 1
                            negTwoL[index2] = 1
                    index2 += 1
        else:
            flag = 1
            while flag:
                flag = 0
                index2 = 2
                while index2 < len(negTwoL):
                    if negTwoL[index2] > 1:
                        flag = 1
                        if negTwoL[index2] % 2 == 1:
                            if negTwoL[index2+1] == 1:
                                negTwoL[index2+1] = 0
                            else:
                                negTwoL[index2-1] += 1
                                negTwoL[index2-2] += 1
                            negTwoL[index2] = 0
                        else:
                            if negTwoL[index2+1] == 1:
                                negTwoL[index2+1] = 0
                            else:
                                negTwoL[index2+1] += 1
                                negTwoL[index2+2] += 1
                            negTwoL[index2] = 1
                    index2 += 1
        negTwoL.reverse()
        while True:
            if len(negTwoL) == 1:
                break
            else:
                if negTwoL[0] == 0:
                    del negTwoL[0]
                else:
                    break
        return "".join(list(map(str, negTwoL)))


print(baseNeg2(n))


Measured memory_bytes: 3192
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int a[216000];
Int n;
Int b[216000];
Int check(Int val){
  int mid = n -1;
  for(int i = 0;i < 2*n-1;i++)b[i] = a[i] > val;
  for(int k = 0;k < n-1;k++){
    if(b[mid + k] == b[mid+k+1])return b[mid+k];
    if(b[mid-k] == b[mid-k-1])return b[mid-k];
  }
  return (b[mid] + n + 1) % 2;
}

int main(){
  cin >> n;
  for(int i = 0;i < 2*n-1;i++)cin >> a[i];
  int bottom = 1, top = 2*n-1;
  while(top - bottom > 1){
    int mid = (top + bottom) / 2;
    if(check(mid) == 1)bottom = mid;
    else top = mid;
  }
  cout << top << endl;  
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<deque>
#include<tuple>
using namespace std;

int main(){
  vector <vector<int> > path_field;
  int n;

  cin >> n; n++;
  path_field.resize(n);
  for(int i=1;i<n;i++){
    path_field[i].resize(n);
    for(int j=1;j<n;j++){
      path_field[i][j]=0;
    }
  }
  for(int i=1;i<n;i++){
    int _m,m;

    cin >> _m >> m;
    for(int j=0;j<m;j++){
      int to;
      
      cin >> to;
      path_field[i][to]=1;
    }
  }

  vector <tuple<int,int> > ans;
  deque <int> stk;
  int sarched_point,sum=0;

  ans.resize(n);
  for(int i=1;i<n;i++){
    ans[i]=make_tuple(0,0);
  }
  for(int i_=1;i_<n;i_++){
    if(get<0>(ans[i_])==0){
      stk.push_back(i_);
      if(sum!=0) sum++;
    }
  
    while(!stk.empty()){
      sarched_point = stk.back();
      sum++;

      if(get<0>(ans[sarched_point])==0){
        get<0>(ans[sarched_point])=sum;
      }
      for(int i=1;i<n;i++){
        if((path_field[sarched_point][i]==1)&&(get<0>(ans[i])==0)){
          stk.push_back(i);
       	  break;
        }else if(i==(n-1)){
          get<1>(ans[sarched_point])=sum+1;
          stk.pop_back();
        }
      }
    }
  }

  for(int i=1;i<n;i++){
    cout << i << " " << get<0>(ans[i]) << " " << get<1>(ans[i]) << endl;
  }
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
int zero() { return 0; }
void swap(vel &que, vel &pos, int i, int j) {
	int x = que[i];
	int y = que[j];
	pos[x] = j; pos[y] = i;
	que[i] = y; que[j] = x;
}
void down(vel &que, vel &pos, vel &va, int n) {
	int i = 1;
	while (i * 2 <= n) {
		if (i * 2 == n) {
			swap(que, pos, i, 2 * i);
			i = 2 * i;
		}
		else {
			if (va[que[2 * i]] < va[que[2 * i + 1]]) {
				swap(que, pos, i, 2 * i);
				i = 2 * i;
			}
			else {
				swap(que, pos, i, 2 * i + 1);
				i = 2 * i + 1;
			}
		}
	}
}
void up(vel &que, vel &pos, vel &va, int i) {
	while (i > 1) {
		int j = i / 2;
		if (va[que[i]] < va[que[j]]) {
			swap(que, pos, j, i);
			i = j;
		}
		else i = 0;
	}
}
signed main() {
	int n, m, x;
	cin >> n >> m >> x;
	vel fr(m);
	vel to(m);
	vel cos(m);
	vel ko(n);
	vel te(n);
	for (int i = 0; i < n; i++) { cin >> te[i]; }
	for (int i = 0; i < m; i++) {
		cin >> fr[i] >> to[i] >> cos[i];
		fr[i]--; to[i]--;
		ko[fr[i]]++; ko[to[i]]++;
	}
	vvel way(n); vel cou(n, 0);
	for (int i = 0; i < n; i++) { way[i] = vel(ko[i]); }
	vvel wac = way;
	for (int i = 0; i < m; i++) {
		way[fr[i]][cou[fr[i]]] = to[i];
		way[to[i]][cou[to[i]]] = fr[i];
		wac[fr[i]][cou[fr[i]]] = cos[i];
		wac[to[i]][cou[to[i]]] = cos[i];
		cou[fr[i]]++; cou[to[i]]++;
	}
	int var = n * (x + 1) * 3;//n,3,x+1
	int ma = var * 200 + 1;
	int fl = 0;
	vel que(var + 1);
	vel pos(var);
	for (int i = 0; i < var; i++) {
		que[i + 1] = i; pos[i] = i + 1;
	}
	vel va(var, ma);
	vel dij(var, ma);
	dij[0] = 0; int ans;
	while (fl == 0) {
		int fr1 = que[1];
		va[fr1] = ma;
		int po1 = fr1 / (3 * x + 3);
		int tm1 = fr1 % (3 * x + 3);
		int te1 = tm1 / (x + 1);
		int mi1 = tm1 % (x + 1);
		if (po1 == n - 1) fl = 1; ans = dij[fr1];
		down(que, pos, va, var);
		for (int nu = 0; nu < ko[po1]; nu++) {
			int po2 = way[po1][nu];
			int ok = 0;
			int nmi = min(mi1 + wac[po1][nu], x);
			if (te[po2] == 1) {
				int to1 = po2 * (3 * x + 3) + te1 * (x + 1) + nmi;
				if (dij[to1] > dij[fr1] + wac[po1][nu]) {
					dij[to1] = dij[fr1] + wac[po1][nu];
					va[to1] = dij[to1];
					up(que, pos, va, pos[to1]);
				}
			}
			else if (nmi >= x or te[po2] == te1) {
				int to1 = po2 * (3 * x + 3) + te[po2] * (x + 1);
				if (dij[to1] > dij[fr1] + wac[po1][nu]) {
					dij[to1] = dij[fr1] + wac[po1][nu];
					va[to1] = dij[to1];
					up(que, pos, va, pos[to1]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, C;
    cin >> A >> B >> C;
    if(A <= C && C <= B) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXIST2(s,e) (find(ALL(s),(e))!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int dx[2][6]={{-1,0,1,0,-1,-1},{0,1,1,1,0,-1}},dy[2][6]={{-1,-1,0,1,1,0},{-1,-1,0,1,1,0}};

	int w,h;

int dfs(vvi &m,int y,int x,vvi &used){
	used[y][x]=1;
	int ret=0;
	REP(i,6){
		int yy=y+dy[y%2][i];
		int xx=x+dx[y%2][i];
		if(yy>=0&&xx>=0&&yy<h+6&&xx<w+6){
			if(m[yy][xx]){
				ret++;
			}else if(!used[yy][xx]){
				ret+=dfs(m,yy,xx,used);
			}
		}
	}
	return ret;
}

int main(){
	cin>>w>>h;
	vvi m(h+6,vi(w+6));
	REP(i,h){
		REP(j,w){
			cin>>m[i+3][j+3];
		}
	}
	int ans=0;
	vvi used(h+6,vi(w+6));

	ans+=dfs(m,0,0,used);
	cout<<ans<<endl;
}

Measured memory_bytes: 1872
import sys
sys.setrecursionlimit(10**7)
mo=10**9+7
n=int(input())
a=[0]*9
for s in map(int,input().split()):
    for i in range(8):
        if int(s)>=i*400 and (i+1)*400>int(s):
            a[i]=1
    if int(s)>=3200:
        #print(int(s),'rain')
        a[8]+=1
    
#print(a)
ans=sum(a[0:8])
#ans=[ans,min(8,a[8]+ans)]
ans=[max(1,ans),a[8]+ans]
print(*ans)


Measured memory_bytes: 3064
import java.util.*;

public class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		int n=s.nextInt();
		int[] branches=new int[n];
		int[] parent=new int[n];
		int[][] childlen=new int[n][];

		for(int i=1;i<n;++i)
			++branches[parent[i]=s.nextInt()-1];

		for(int i=0;i<n;++i)
			childlen[i]=new int[branches[i]];

		loop:
		for(int i=0;i<n;++i){
			int I=i;
			while(true){
				if(branches[I]>0)
					break;
				int r=0;
				{
					int[] c=childlen[I];
					Arrays.sort(c);
					for(int j=0,e=c.length;j<e;++j)
						r=Math.max(r,c[j]+e-j);
				}
				if(I==0){
					System.out.println(r);
					break loop;
				}
				I=parent[I];
				childlen[I][--branches[I]]=r;
			}
		}
	}
}


Measured memory_bytes: 64924
#include<iostream>
#include<string>
#include<set>

using namespace std;

typedef long long ll;

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

	set<string> S;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << "\n";
	return 0;
}

Measured memory_bytes: 19256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
int a,b,c,m;
cin >> a >> b >> c;
if(a > b){ m = a; a = b; b = m;}
if(b > c){ m = b; b = c; c = m;}
if(a > b){ m = a; a = b; b = m;}
cout << a << " " << b << " " << c << endl;
return 0;

} 



Measured memory_bytes: 3100