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

using ll = long long int;

const int MAX_N = (int)(1e5 + 5);

int h, w;

ll ans = (ll)(1e10 + 5);

int main(void){
  scanf("%d %d", &h, &w);

  for (int i = 1; i <= h; ++i) {
    ll fst = (ll)(w) * (ll)(i);
    int nearmid = w / 2;
    for (int j = nearmid - 10; j < nearmid + 10; ++j) {
      ll snd = (ll)(h - i) * (ll)(j);
      ll trd = (ll)(h - i) * (ll)(w - j);

      ll tmp = max(fst, max(snd, trd)) - min(fst, min(snd, trd));
      ans = min(ans, tmp);
    }
  }

  for (int i = 1; i <= h; ++i) {
    ll fst = (ll)(w) * (ll)(i);
    int nearmid = (h - i) / 2;
    for (int j = nearmid - 10; j < nearmid + 10; ++j) {
      ll snd = (ll)(j) * (ll)(w);
      ll trd = (ll)(h - i - j) * (ll)(w);
      ll tmp = max(fst, max(snd, trd)) - min(fst, min(snd, trd));
      ans = min(ans, tmp);
    }
  }

  swap(h, w);

  for (int i = 1; i <= h; ++i) {
    ll fst = (ll)(w) * (ll)(i);
    int nearmid = w / 2;
    for (int j = nearmid - 10; j < nearmid + 10; ++j) {
      ll snd = (ll)(h - i) * (ll)(j);
      ll trd = (ll)(h - i) * (ll)(w - j);

      ll tmp = max(fst, max(snd, trd)) - min(fst, min(snd, trd));
      ans = min(ans, tmp);
    }
  }

  for (int i = 1; i <= h; ++i) {
    ll fst = (ll)(w) * (ll)(i);
    int nearmid = (h - i) / 2;
    for (int j = nearmid - 10; j < nearmid + 10; ++j) {
      ll snd = (ll)(j) * (ll)(w);
      ll trd = (ll)(h - i - j) * (ll)(w);
      ll tmp = max(fst, max(snd, trd)) - min(fst, min(snd, trd));
      ans = min(ans, tmp);
    }
  }

  printf("%lld\n", ans);

  return 0;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  
  bool balanced = false;
  int a, b;
  int N = s.size();
  for(int i = 0; i < N-1; i++){
    if(s[i] == s[i+1]){
      balanced = true;
      a = i, b = i+1;
    }
  }
  for(int i = 0; i < N-2; i++){
    if(s[i] == s[i+2] && s[i] != s[i+1]){
      balanced = true;
      a = i, b = i+2;
    }
  }
  a++, b++;
  if(!balanced) a = -1, b = -1;
  cout << a << " " << b;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int k;
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	cin >> k;

	rep(i, 100) {
		if (a[0] < a[1]) {
			k -= i;
			break;
		}
		a[1] *= 2;
	}
	if (k < 0) {
		cout << "No" << endl;
		return 0;
	}
	rep(i, 100) {
		if (a[1] < a[2]) {
			k -= i;
			break;
		}
		a[2] *= 2;
	}
	if (k < 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3604
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	X = int(input())
	var = 100
	for i in range(4000):
		var = int(var * 1.01 // 1)
		if var >= X:
			print(i + 1)
			return

	


if __name__ == '__main__':
	main()

Measured memory_bytes: 68624
#include<stdio.h>
int main(void)
{
	int i,n;
	int a[9];
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<9;i++){
			scanf("%d",&a[i]);
			n-=a[i];
		}
		printf("%d\n",n);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

int a[100010];

int cnt[100010];

int main(int argc, char const *argv[])
{
	int n;cin>>n;

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

	cnt[0]=3;

	ll ans = 1;

	rep(i,n) {
		ans*=(cnt[a[i]]-cnt[a[i]+1]);
		ans%=MOD;
		cnt[a[i]+1]++;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1024
/* https://atcoder.jp/contests/abc097/tasks/arc097_a */

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>

std::string solve(const std::string s, const int K)
{
  int s_len = s.length();
  std::set<std::string> sub_s;

  for (int i = 1; i <= K; ++i) {
    for (int j = 0; j+i-1 <= s_len; ++j) {
      std::string sub = s.substr(j, i);
      sub_s.insert(sub);
    }
  }

  std::vector<std::string> sub_s_vec(sub_s.begin(), sub_s.end());

  return sub_s_vec.at(K);
}

int main(int argc, char *argv[])
{
  // Input
  std::string s;
  int K;

  std::cin >> s >> K;

  // Output
  std::cout << solve(s, K) << std::endl;

  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

std::vector<intmax_t> divisor(intmax_t n) {
  std::vector<intmax_t> res;
  for (intmax_t i = 1; i*i <= n; ++i) {
    if (n % i != 0) continue;
    res.push_back(i);
    if (n / i != i)
      res.push_back(n/i);
  }
  std::sort(res.begin(), res.end());
  return res;
}

int main() {
  intmax_t N;
  scanf("%jd", &N);

  intmax_t res = 0;
  for (auto m: divisor(N)) {
    if (m == 1) continue;
    // fprintf(stderr, "m: %jd, N / m: %jd, N %% m: %jd\n", m, N/m, N%m);
    if (N / (m-1) == N % (m-1)) res += m - 1;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main()
{
    ifstream fIn("input.txt");
    if (fIn.is_open())
        cin.rdbuf(fIn.rdbuf());

    int a, b;
    cin >> a >> b;

    if(a < 1 || a > 9 || b < 1 || b > 9){
        cout << "-1" << endl;
    }else{
        cout << a * b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int gcd(int a,int b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}

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

    int k;
    cin>>k;

    ll sum = 0;

    for(int i=1;i<=k;i++){
    	for(int j=1;j<=k;j++){
    		for(int c=1;c<=k;c++){
    			sum += gcd(gcd(i,j),c);
    		}
    	}
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>

using namespace std;

#define ll long long
#define d double
#define ld long double
#define pii pair<int,int>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }


int main(int,char**) {
    ios_base::sync_with_stdio(false);
    ll N, M; cin >> N >> M;

    ll ans = min(N, M/2);
    M -= ans * 2;
    ans += M / 4;
    cout << ans << endl;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int power(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


int n, k;

int read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return 0;
  }
  return 1;
}

const int maxn = (int) 2e3 + 10;
int dp[maxn][maxn];

int cs[maxn * maxn];

void solve() {
  if (k == 1) {
    printf("1\n");
    return;
  }

  for (int i = 0; i < k - 2; ++i) {
    cs[i] = 0;
  }
  cs[k - 2] = 1;
  for (int i = k - 1; i <= n * k; ++i) {
    cs[i] = mult(mult(cs[i - 1], i), power(i - k + 2, mod - 2));
  }

  for (int left = 0; left <= n; ++left) {
    for (int t = 0; t + left <= n; ++t) {
      int &cur = dp[left][t];
      cur = 0;
      if (!left && !t) {
        cur = 1;
        continue;
      }

      if (t) {
        add(cur, mult(dp[left][t - 1], cs[(left + t) * k - t - 1]));
      }

      if (left) {
        add(cur, dp[left - 1][t + 1]);
      }
      //eprintf("dp[left=%d][t=%d] = %d\n", left, t, cur);
    }
  }
  int res = dp[n][0];
  for (int i = 1; i <= n; ++i) {
    res = mult(res, i);
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

int main()
{
    int n; cin >> n;
    vector<long long> A(n);
    vector<long long> B(n);
    vector<long long> C(n);
    
    rep(i, 0, n) cin >> A[i];
    rep(i, 0, n) cin >> B[i];
    rep(i, 0, n) cin >> C[i];
    
    sort(A.begin(), A.end());
    // sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    long long  ans = 0;
    
    for(int b = 0; b < n; b++){
        long long  ab = lower_bound(A.begin(), A.end(), B[b]) - A.begin();
        long long  bc = C.end() - upper_bound(C.begin(), C.end(), B[b]) ;
        ans += (ab * bc);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		char [] list = {'y','u','i','o','p','h','n','j','k','l','m'};
		while(true){
			String str = sc.next();
			if(str.equals("#")) break;
			char first = str.charAt(0);
			boolean temp = isC(first, list);
			//System.out.println(temp);
			int count = 0;
			for(int i= 1; i < str.length(); i++){
				boolean now = isC(str.charAt(i), list);
				//System.out.println(now + " " + temp);
				if(now == temp){
					
				}
				else{
					temp = now;
					count++;
				}
			}
			System.out.println(count);
		}
	}
	
	private boolean isC(char c, char [] list){
		for(int i=0; i < list.length;i++){
			if(c == list[i]){
				return true;
			}
		}
		return false;
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
// header {{{
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
using namespace std;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}

template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
// }}}

// init {{{
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {


	i64 ans = 0;
	string ANS;
	string S, T;

	cin >> S >> T;

	int A, B;

	cin >> A >> B;

	string U;

	cin >> U;

	if (S==U) 
	{
		A--;
	}
	else
	{
		B--;
	}

	cout << A << " " << B << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
    if(u == NIL || u->key == k)
        return u;
    if(u->key > k )
        return treeSearch(u->left,k);
    else
        return treeSearch(u->right,k);
}




void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    
    if(y == NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
    
    
    
}

void inorder(Node u){
    if(u->left != NIL)inorder(u->left);
    printf(" %d",u->key);
    if(u->right != NIL)inorder(u->right);
}
void preorder(Node u){
    printf(" %d",u->key);
    if(u->left != NIL)preorder(u->left);
    if(u->right != NIL)preorder(u->right);
}


int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'f' ){
            scanf("%d", &x);
            Node t = treeSearch(root, x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");
        } else if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S,s1,s2;
  cin >> N;
  cin >> S;
  s1 = S.substr(0,N/2);
  s2 = S.substr(N/2,N);
  if(s1 == s2 && N % 2 == 0){
  cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

using ll = long long int;

vector<int> arr[200010];

int main(void) {

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;

		arr[a].push_back(b);
		arr[b].push_back(a);
	}

	for (int i = 1; i <= n; i++) {
		bool f1 = false, f2 = false;
		for (int j = 0; j < arr[i].size(); j++) {
			if (arr[i][j] == 1)f1 = true;
			if (arr[i][j] == n)f2 = true;
		}

		if (f1 && f2) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
		else {
		}
	}

	cout << "IMPOSSIBLE" << endl;

}


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

using namespace std;

int main() {
	
	long long m, n;
	cin >> m >> n;

	long long res = 1;

	if (n <= 1000) {
		for (long long i = 0; i < n; i++) {
			res = res * m;
			res = res % 1000000007;
		}
		cout << res << endl;
		return 0;
	}
	else {
		long long res0 = 1;
		long long res1 = 1;

		for (long long i = 0; i < 1000; i++) {
			res0 = res0 * m;
			res0 = res0 % 1000000007;
		}
		for (long long i = 0; i < n/1000; i++) {
			res1 = res1 * res0;
			res1 = res1 % 1000000007;
		}

		for (long long i = 0; i < n%1000; i++) {
			res1 = res1 * m;
			res1= res1 % 1000000007;
		}
		cout << res1 << endl;
		return 0;
	}
}


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

using namespace std;

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

    int yy = num/100;
    int mm = num%100;

    if(yy>=1&&yy<=12){
        if(1<=mm&&mm<=12)
            cout<<"AMBIGUOUS"<<endl;
        else
            cout<<"MMYY"<<endl;
    }else{
        if(1<=mm&&mm<=12)cout<<"YYMM"<<endl;
        else    cout<<"NA"<<endl;
    }

}


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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
}

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif





void solve()
{
    int m,d;
    cin>>m>>d;

    int ans=0;

    for(int i=10; i<=d; i++)
    {

        int t1=i%10;
        int t2=i/10;
        int t=t1*t2;
        if(t<=m && t1>=2 &&t2>=2)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }


    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
lis = []
for i in range(h):
    lis.append(input())

row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if lis[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        s = ''
        for j in range(w):
            if col[j]:
                s += lis[i][j]
        print(s)


Measured memory_bytes: 3064
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double r = input.nextDouble();
        double area = Math.PI*Math.pow(r,2);
        double circ = Math.PI*2*r;
        System.out.printf("%f %f\n",area,circ);
    }
}


Measured memory_bytes: 28404
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	string str;
	int count1 = 0;
	int count2 = 0;
	int N;
	cin >> N;
	cin >> str;
	for (int i = 0; i < N; i++)
	{
		if (str[i] == '(')
		{
			count1++;
		}
		else
		{
			if (count1 > 0)
			{
				count1--;
			}
			else
			{
				count2++;
			}
		}
	}
	for (int i = 0; i < count2; i++)
	{
		str = '(' + str;
	}
	for (int i = 0; i < count1; i++)
	{
		str = str + ')';
	}
	cout << str << endl;
	return 0;
}

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

int v[55],c,ans;

int main(void){
    int n;cin>>n;
    for(int i=0;i<n;i++)cin>>v[i];
    for(int i=0;i<n;i++){
        cin>>c;
        if(v[i]-c>0)ans+=v[i]-c;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int N;
	cin >> N;
	vector<int> W(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> W[i];
	}
	int min_value = INT_MAX;
	for (int i = 0; i < N; ++i)
	{
		int S1 = 0, S2 = 0;
		for (int j = 0; j <= i; ++j)
		{
			S1 += W[j];
		}
		for (int j = i + 1; j < N; ++j)
		{
			S2 += W[j];
		}
		min_value = min(min_value, abs(S1 - S2));
	}
	cout << min_value << endl;
	return 0;
}


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

int GCD(int a, int b) {
    if(a < b) {
        swap(a, b);
    }
    if(a % b == 0) {
        return b;
    } else {
        return GCD(b, a % b);
    }
}
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int max_h = pow(10, 9);
    int min_h = max_h;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        min_h = min(min_h, A.at(i));
    }

    int min_last_h = max_h;
    for(int i = 0; i < N; i++) {
        min_last_h = min(GCD(A.at(i), min_h), min_last_h);
    }
    cout << min_last_h << endl;
    return 0;
}

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

int main() {

	int N;
	cin >> N;
	vector<int> V, P, Q;
	for (int i = 1; i <= N; i++) {
		V.push_back(i);
	}
	int dig;
	for (int i = 0; i < N; i++) {
		cin >> dig;
		P.push_back(dig);
	}
	for (int i = 0; i < N; i++) {
		cin >> dig;
		Q.push_back(dig);
	}
	int a = 0, b = 0;
	for (int i = 1; ; i++) {
		if (V == P)
			a = i;
		if (V == Q)
			b = i;
		if (a * b != 0)
			break;
		next_permutation(V.begin(), V.end());
	}
	cout << abs(a - b) << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(N):
  x,y=map(int,input().split())
  A.append((x,y,i))
A=sorted(A)
B=sorted(A,reverse=False, key=lambda x: x[1]) 
#print(A,B)
E=[]
for i in range(N-1):
  E.append(((A[i+1][0]-A[i][0]),A[i][2],A[i+1][2]))
  E.append(((B[i+1][1]-B[i][1]),B[i][2],B[i+1][2]))
edge=E

def kruskal():
    cost=0
    edge.sort()
    for c,u,v in edge:
        if same(u,v):
            continue
        union(u,v)
        cost+=c
    return cost

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def union(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True

def same(x, y):
    return find(x) == find(y)
par=[-1]*N
print(kruskal())

Measured memory_bytes: 48780
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long x,y,z;
   cin>>x;
   if(x%1000==0)
   {
       y=x%1000;

   }
   else
   {
    z=x%1000;
    y=1000-z;
   }

  cout<<y<<"\n";
}


Measured memory_bytes: 3620
#include <iostream>

#define N (20)
int main(void) {  
  while(true) {
    int n;
    std::cin >> n;
    if(n == 0) break;
    int x[N], y[N];
    for(int i=0; i<n; i++)
      std::cin >> x[i] >> y[i];
    for(int i=n; i<N; i++)
      x[i] = y[i] = -1;
    
    int m;
    std::cin >> m;
    int rx=10, ry=10;
    
    for(int i=0; i<m; i++) {
      char d;
      int s;
      std::cin >> d >> s;
      int dx=0, dy=0;
      if(d == 'N')
        dy=1;
      else if(d == 'E')
        dx=1;
      else if(d == 'S')
        dy=-1;
      else if(d == 'W')
        dx=-1;
        
      for(int j=0; j<s; j++) {
        rx += dx;
        ry += dy;
        for(int k=0; k<n; k++)
          if(rx == x[k] && ry == y[k])
            x[k] = y[k] = -1;
      }
    }
    bool f=true;
    for(int i=0; i<n; i++) {
      if(x[i] != -1) {
        std::cout << "No" << std::endl;
        f = false;
        break;
      }
    }
    if(f)
      std::cout << "Yes" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		long K = GetLong();
		var sb = new StringBuilder();
		long snuke = 0;
		for(int i = 0; i < K; i++)
		{
			snuke = f(snuke + 1);
			sb.AppendFormat($"{snuke}\n");
		}
		Console.Write(sb);
	}

	private static long f(long x)
	{
		long ans = x;
		double min = ((double)x) / ((double)S(x));
		long div = 1;
		for(int i = 0; i < 16; i++)
		{
			long upper = (x / (div * 10)) * (div * 10);
			long num = (x / div) % 10;
			for(long j = num + 1; j <= 9; j++)
			{
				long y = upper + (num * div) + div - 1;
				double tmp = ((double)y) / ((double)S(y));
				if(tmp < min)
				{
					min = tmp;
					ans = y;
				}
			}
			div *= 10;
		}
		return ans;
	}

	private static long S(long x)
	{
		long ans = 0;
		while(x > 0)
		{
			ans += x % 10;
			x /= 10;
		}
		return ans;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 9172
#include <stdio.h>


int main(void) {
	long unsigned int a;
	unsigned int b;

	scanf("%lu", &a);

	char temp[5];
	scanf("%s", temp);
	b = (temp[0] - '0') * 100 + (temp[2] - '0') * 10 + (temp[3] - '0');

	printf("%lu\n", a * b / 100);

	return 0;
}


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

int main(){
  long double n,k,ans=0,i,j;cin>>n>>k;
  for(i=1;i<=n;i++){
    j=0;
    while(i<k/pow(2,j)) j++;
    ans+=1/pow(2,j);
  }
  cout<<fixed<<setprecision(9)<<ans/n;
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1)
    {
    }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> langs(n);
    UnionFind uf(m);
    for(ll i = 0;i < n;i++)
    {
        int k;
        cin >> k;
        langs[i].resize(k);
        for(int j = 0;j < k;j++)
        {
            cin >> langs[i][j];
            langs[i][j]--;
        }
        auto f = langs[i][0];
        for(int j = 1;j < k;j++)
        {
            uf.unionSet(f, langs[i][j]);
        }
    }
    auto r = uf.root(langs[0][0]);
    for(int i = 0;i < n;i++)
    {
        //cout << uf.root(langs[i][0]) << endl;
        if(r != uf.root(langs[i][0]))
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

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

    int count;
    for(int i = 1; i < N + 1; i++){
        count = 0;
        for(int x = 1; x * x * 6 <= i; x++){
            for(int y = x; y * y * 3 <= i; y++){
                for(int z = y; z * z <= i; z++){
                    if(x * x + y * y + z * z + x * y + y * z + z * x == i){
                        if((x == y) && (y == z)){
                            count++;
                        }else if((x == y) || (y == z) || (z == x)){
                            count += 3;
                        }else{
                            count += 6;
                        }
                    }
                }
            }
        }
        cout << count << endl;    
    }
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int out = n;
  for(int i = 0; i < n-1; i++){
    if(s.at(i) == s.at(i+1)){
       out--;
    }
  }

  cout << out;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b; cin >> a >> b;
  cout << (a * b % 2 ? "Odd" : "Even") << endl;
}


Measured memory_bytes: 256
/*
 © 2020-01-31 19:54:48 crystaalroo all Rights Reserved
*/
#include <bits/stdc++.h>
#define fore(i, a, b) for(int i = (a); i <(b); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
#define sz(x) (int) (x).size()
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long lli;
typedef pair<double,double > ii;
#define ENDL '\n'
#define deb(x) cout << #x": " << (x) << endl;
const lli INF=1e14+10;
const lli mod = 1e9+7;
const int N = 1E6;
lli dp[N];
lli co[N];
int n,k;
lli rec(int v){
  if(dp[v]!=INF)return dp[v];
  lli res = INF;
  fore(i,v+1,v+k+1){if(i>=n)break;res = min(res,rec(i)+abs(co[i]-co[v]));}
  return dp[v]=res;
}
int main(){

  cin>>n>>k;
  fore(i,0,n)dp[i]=INF;
  dp[n-1]=0;
  fore(i,0,n){
    cin>>co[i];
  }
  rec(0);
  cout<<dp[0]<<ENDL;

//  cout<<dp[n-1]<<ENDL;
}


Measured memory_bytes: 9856
#include<stdio.h>

int main(void){
int H,W,i,I,j,k;
for(i=0;i<10000;i++){		//何回行うか 
	scanf("%d %d",&H,&W);
	if(H!=0){				//四角形として成立しているか 
	for(I=0;I<H;I++){		//建ての回数 
	if(I%2==0){
		for(j=0;j<W;j++){	//横の回数 
			if(j%2==0){
				printf("#");
			}else{
				printf(".");
			}
			
		}
			  }else{
			  for(j=0;j<W;j++){
			if(j%2==0){
				printf(".");
			}else{
				printf("#");
			}
		
		}
			  }
		printf("\n");
			  
			  }
			 }else{
				break;
			}
		printf("\n");	
			}
	return 0;
}



Measured memory_bytes: 2608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(all(a));
	a.erase(unique(all(a)), a.end());
	if(a.size() == n) {
		cout << "YES" << '\n';
	} else {
		cout << "NO" << '\n';
	}
	return 0;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d %d", $H, $W);
$m = [];
for ($i = 0; $i < $H; $i++) {
    $m[$i] = str_split(trim(fgets(STDIN)));
}
$init = $m[0][0] === '.' ? 0 : 1;
$mem[0] = [$init];
printf("%d", ceil(solve($H - 1, $W - 1) / 2));

function solve($y, $x) {
    // echo "y:{$y} x:{$x}\n";
    global $m, $mem;
    if (isset($mem[$y][$x])) {
        return $mem[$y][$x];
    }
    if ($x > 0 && $y > 0) {
        $l = ($m[$y - 1][$x] !== $m[$y][$x]) * 1 + solve($y - 1, $x);
        $u = ($m[$y][$x - 1] !== $m[$y][$x]) * 1 + solve($y, $x - 1);
        $mem[$y][$x] = min($u, $l);
        return min($u, $l);
    } else if ($y > 0) {
        $l = ($m[$y - 1][$x] !== $m[$y][$x]) * 1 + solve($y - 1, $x);
        $mem[$y][$x] = $l;
        return $l;
    } else if ($x > 0) {
        $u = ($m[$y][$x - 1] !== $m[$y][$x]) * 1 + solve($y, $x - 1);
        $mem[$y][$x] = $u;
        return $u;
    } else if ($x === 0 && $y === 0) {
        return 0;
    } else {
        exit('ERR');
    }
}


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

const int maxn = 100010;
int dp[maxn], n, a[maxn];

int main() {
	//freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]); 
	dp[0] = 0, dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; i++)
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), 
					dp[i-2] + abs(a[i] - a[i-2]));
	printf("%d\n", dp[n-1]);
	return 0;
}


Measured memory_bytes: 1024
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
ab = [tuple(li()) for _ in range(n)]

ab.sort(key=lambda x: x[1])
cur = 0
ok = True

for ai, bi in ab:
    cur += ai
    if cur > bi:
        ok = False
        break

print("Yes" if ok else "No")


Measured memory_bytes: 31936
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define puts(s) cout<<s<<endl
#define inf (1000000007)
#define nil -1

int main() {
	int x;
	cin >> x;
	int t= 0;
	int now = 0;
	while (now<x) {
		now += t+1;
		t++;
	}
	puts(t);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	cin>>n;
	while(n--) 
	{
		bool one=false,two=false,three=false;
		int out=0,ans=0;
		while(1) 
		{
			string in; cin>>in;
			if(in=="OUT")
			{
				out++;
				if(out==3) break;
			}
			else if(in=="HOMERUN")
			{
				int cnt=1;
				cnt+=one?1:0;
				cnt+=two?1:0;
				cnt+=three?1:0;
				one=two=three=false;
				ans+=cnt;
			}
			else
			{
				if(three) ans+=1;
				three=two; two=one; one=true;
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
const int MAX_V = 100;
int a[MAX_V+1];
map<pair<int,int>, int> memo;

int dp(int s,int t){
  int &res=memo[make_pair(s,t)];
  if(res!=0) return res;
  if(t-s<2) return 0;
  int min=0x7fffffff;
  for(int i=s+1;i<=t-1;i++){
    int sum=dp(s,i)+dp(i,t)+a[s]*a[i]*a[t];
    if(sum<min){
      min=sum;
    }
  }
  res=min;
  return res;
}

int main(){
  int n; scanf("%d",&n);
  for(int i=0;i<n;i++){
    int fst,snd;
    scanf("%d %d",&fst,&snd);
    a[i]=fst; a[i+1]=snd;
  }
  int sum=dp(0,n);
  printf("%d\n",sum);
}

Measured memory_bytes: 1488
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef array<int,3> A;

vector<A> nodes;
void push(string& s){
	int i=0;
	int c=0;
	while(i<s.size()){
		int v=s[i]-'0';
		if(nodes[c][v]==0){
			nodes[c][v]=nodes.size();
			nodes.push_back(A{{}});
		}
		c=nodes[c][v];
		i++;
	}
	nodes[c][2]=1;
}
LL g(LL h){
	LL u=1;
	while((h&u)==0){
		u<<=1;
	}
	return u;
}
LL f(int i,LL h){
	if(nodes[i][2]==1){
		return 0;
	}
	LL ret=0;
	for(int j=0;j<2;j++){
		if(nodes[i][j]){
			ret^=f(nodes[i][j],h-1);
		}
		else{
			ret^=g(h-1);
		}
	}
	return ret;
}
int main() {
	LL N,L;
	cin >> N >> L;
	nodes.push_back(A{{}});
	for(int i=0;i<N;i++){
		string s;
		cin >> s;
		push(s);
	}
	if (f(0,L+1)){
		cout << "Alice" << endl;
	}
	else{
		cout << "Bob" << endl;
	}

	return 0;
}



Measured memory_bytes: 6452
#!/usr/bin/env python3

import sys

P_NUM = 1000000007


def solv(n, m, a):
    no_hole = [1] * (n+1)
    for i in range(2, n+1):
        no_hole[i] = no_hole[i-1] + no_hole[i-2]

    ans = 1
    start = 0
    for broken in a:
        dist = broken-1-start
        if dist < 0:
            return 0
        ans *= no_hole[dist] % P_NUM
        start = broken+1

    dist = n-start
    if dist < 0:
        return 0
    ans *= no_hole[dist] % P_NUM

    return ans % P_NUM


if __name__ == '__main__':

    n, m = map(int, input().split())
    a = map(int, sys.stdin)

    ans = solv(n, m, a)

    print(ans)


Measured memory_bytes: 460020
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) throws Exception {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

            String[] in = br.readLine().split(" ");

            br.close();

            BigDecimal x = new BigDecimal(in[0]);
            BigDecimal y = new BigDecimal(in[1]);

            System.out.println(x.multiply(y).toBigInteger());

        }
    }
}

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

P f(int x){
    int a = x % 10;
    int b = 0;
    while(x){
        b = x;
        x /= 10;
    }
    return P(a,b);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    char s;
    cin >> s;
    cout << (char)(s+1) << endl;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1111;
#define INF 0x3f3f3f
int n;
struct qnode				//dis
{
	int v, c;
	qnode(int _v=0,int _c=0):v(_v),c(_c){}
	bool operator < (const qnode &r)const
	{
		return c > r.c;
	}
};
struct Edge
{
	int v,cost;
	Edge(int _v=0,int _cost =0):v(_v),cost(_cost){}
};
vector<Edge> E[maxn];
bool vis[maxn];
int dis[maxn];
void Dijkstra(int n, int s)
{
	memset(vis, false, sizeof(vis));
	fill(dis, dis + n, INF);
	priority_queue<qnode> que;			//存dis
	dis[s] = 0;
	que.push(qnode(s, 0));
	qnode temp;
	while (que.size())
	{
		temp = que.top();
		que.pop();
		int u = temp.v;
		if (vis[u])
			continue;
		vis[u] = true;
		for (int i = 0;i < E[u].size();i++)
		{
			int v = E[u][i].v;
			int cost = E[u][i].cost;
			if (!vis[v] && cost + dis[u] < dis[v])
			{
				dis[v] = dis[u] + cost;
				que.push(qnode(v, dis[v]));
			}
		}
	}
}
void addedge(int u, int v, int w)
{
	E[u].push_back(Edge(v, w));
}
int main()
{
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		int a, b, w,k;
		cin >> a >> k;
		for (int j = 0;j < k;j++)
		{
			cin >> b >> w;
			addedge(a, b, w);
		}
	}
	Dijkstra(n,0);
	for (int i = 0;i < n;i++)
	{
		cout<<i<<" "<< dis[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vi> a(h,vi(w));
  rep(i,h)rep(j,w) cin >> a[i][j];
  vector<vi> ans;
  rep(i,h) {
    if(i%2==0) rep(j,w) {
      if(j!=w-1) {
        if(a[i][j]%2==1) {
          a[i][j]--;
          a[i][j+1]++;
          ans.push_back({i+1,j+1,i+1,j+2});
        }
      }
      else if(j==w-1 && i!=h-1) {
        if(a[i][j]%2==1) {
          a[i][j]--;
          a[i+1][j]++;
          ans.push_back({i+1,j+1,i+2,j+1});
        }
      }
    }
    else per(j,w) {
      if(j!=0) {
        if(a[i][j]%2==1) {
          a[i][j]--;
          a[i][j-1]++;
          ans.push_back({i+1,j+1,i+1,j});
        }
      }
      else if(j==0 && i!=h-1) {
        if(a[i][j]%2==1) {
          a[i][j]--;
          a[i+1][j]++;
          ans.push_back({i+1,j+1,i+2,j+1});
        }
      }
    }
  }
  int n = ans.size();
  cout << n << endl;
  rep(i,n) cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
  return 0;
}

Measured memory_bytes: 10928
N = int(input())

for h in range(1, 3501):
    for n in range(h, 3501):
        q = 4 * h * n - N * h - N * n
        if q <= 0:
            continue
        p = N * h * n
        if p % q == 0:
            w = int(p / q)
            print(str(h) + ' ' + str(n) + ' ' + str(w))
            exit()

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 200010
ll d[N];
int main(){
	ll n, m;
	cin>>n>>m;
	vector<int> a(n);
	rep(i, n) cin>>a[i];
	ll res = 0;
	rep(i, n-1){
		int x = a[i], y = a[i+1];
		if(y<x) y += m;
		res += y-x;
		if(y-x<=1) continue;
		d[x+2] += 1;
		d[y+1] += -(y-x);
		d[y+2] += y-x-1;
	}
	rep(i, 2*m) d[i+1] += d[i];
	rep(i, 2*m) d[i+1] += d[i];
	ll mx = 0;
	rep(i, m) mx = max(mx, d[i+1]+d[i+1+m]);
	cout<<res-mx<<endl;
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

#define TOP_NUM 13
#define NOTOP_NUM 13

int main(){
	IO_STREAM;
	int D;	cin>>D;
	vi c(26);
	vector<pair<int,int>>cs(26);
	rep(i,0,26){
		cin>>c[i];
		cs[i].first=c[i];
		cs[i].second=i;
	}
	int s[D][26];
	rep(i,0,D){
		rep(j,0,26){
			cin>>s[i][j];
		}
	}

	sort(all(cs));
	reverse(all(cs));
	vi top(D,1);
	rep(i,0,TOP_NUM){
		top[i]=cs[i].second+1;
	}
	vi notop(D,1);
	rep(i,0,NOTOP_NUM){
		notop[i]=cs[i+TOP_NUM].second+1;
	}

	int cnt=1;
	int nt_idx=0;
	while(1){
		rep(i,0,TOP_NUM){
			cout<<top[i]<<endl;
			cnt++;
			if(cnt>D) return 0;
		}
		rep(i,0,5){
			cout<<notop[nt_idx]<<endl;
			nt_idx++;
			if(nt_idx>=NOTOP_NUM) nt_idx=0;
			cnt++;
			if(cnt>D) return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <functional>
#include <queue>

#define INF 1000000000

using namespace std;
class Edge {
public:
    Edge(){};
    Edge(int s, int t, int w) : s {s}, t {t}, w {w} {};
    int s;
    int t;
    int w;
};

class Graph {
public:
    Graph(int v, vector<Edge> es) : n {v}, vs {vector<vector<Edge>>(v)} {
        for(auto e : es){
            vs[e.s].push_back(e);
            vs[e.t].push_back(e);
        }
    };
    vector<int> dijkstra(int st){
        auto ds = vector<int>(n, INF);
        auto que = priority_queue<Edge, vector<Edge>, function<bool(Edge, Edge)>>([](Edge a, Edge b){
                                                                                    return a.w > b.w;
                                                                                  }, vector<Edge>());
        que.push(Edge(st, st, 0));
        while(que.size()){
            Edge e = que.top();
            que.pop();
            if(ds[e.t] == INF){
                ds[e.t] = e.w;
                for(auto ne : vs[e.t]){
                    que.push(Edge(ne.s, ne.t, ne.w + ds[e.t]));
                }
            }
        }
        return ds;
    };
private:
    int n;
    vector<vector<Edge>> vs;
};
int main(){
    ios_base::sync_with_stdio(false);
    int v, e, r;
    cin >> v >> e >> r;
    auto es = vector<Edge>();
    int s, t, w;
    for(int i = 0; i < e; ++i){
        cin >> s >> t >> w;
        es.push_back(Edge(s, t, w));
    }
    auto gs = Graph(v, es);
    auto ds = gs.dijkstra(r);
    for(auto d : ds){
        if(d == INF){
            printf("INF\n");
        } else {
            printf("%d\n", d);
        }
    }
}

Measured memory_bytes: 40236
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define INF 0x7FFFFFFF
#define ALL(v) v.begin(), v.end()  //sort(ALL(v)) 昇順ソート sort(ALL(v),greater<int>())
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
  
  	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> f[i];
	sort(ALL(a), greater<ll>());
	sort(ALL(f));
 
	ll l=0, r=a[0]*f[n-1];
	while(l!=r){
		ll m=(l+r)/2, s=0;
		for(int i=0; i<n; i++){
			if(a[i]*f[i]>m) s+=a[i]-m/f[i];
		}
		if(s<=k) r=m;
		else l=m+1;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 3456
N=int(input())

A=0

for i in range(N):
    for k in range(N):
        if 4*i+7*k==N:
            print("Yes")
            break
        else:
            pass
    if 4*i+7*k==N:
        break
    else:
        pass
    
else:
    print("No")


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

using namespace std;
#define ll long long
int main(void){
	int N,K;
	cin >> N >> K;
	vector<ll> h(N);
	for(int i=0;i<N;i++)cin >> h[i];
	sort(h.begin(),h.end());
	ll ans = 1e18;
	for(int i=0;i<N-K+1;i++){
		ans = min(ans,h[i+K-1]-h[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024