akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from random import randint
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
import sys
import os
import re
sys.setrecursionlimit(9999)
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353
N = 5001
 
'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''

def main():
	n = int(input())
	ans = inf
	for i in range(1, int(n**.5)+1):
		if n%i == 0:
			curr = i + (n//i) - 2
			ans = min(ans, curr)
	print(ans)


BUFSIZE = 8192
class FastI(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = StringIO()
		self.newlines = 0
 
	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()
 
	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count("\n") + (not b)
			ptr = self._buffer.tell()
			self._buffer.seek(0, 2), self._buffer.write(
				b), self._buffer.seek(ptr)
		self.newlines -= 1
		return self._buffer.readline()
class FastO(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = __pypy__.builders.StringBuilder()
		self.write = lambda s: self._buffer.append(s)
 
	def flush(self):
		os.write(self._fd, self._buffer.build())
		self._buffer = __pypy__.builders.StringBuilder()
def print(*args, **kwargs):
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
	def bootstrap(cont):
		call, arg = cont.switch()
		while True:
			call, arg = cont.switch(to=continulet(
				lambda _, f, args: f(*args), call, arg))
	cont = continulet(bootstrap)
	cont.switch()
	main()

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

using namespace std;

long long a[2 * 100 * 1000];
int main() {
	int n;
	cin >> n;
	long long ans = 0;
	long long _max;
	cin >> _max;
	for(int i = 1; i < n; i++) {
		cin >> a[i];
		ans += max(0ll, _max - a[i]);
		_max = max(_max, a[i]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 5232
#coding: utf-8
H, W = map(int, input().split())
table = []
for _ in range(H):
    table.append(list(input().split()))
alp = [chr(i) for i in range(65, 65+26)]
for i in range(H):
    for j in range(W):
        if table[i][j] == "snuke":
            print(alp[j] + str(i+1))
            break

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int h = scanner.nextInt();
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int r = scanner.nextInt();

		if(x-r >= 0 && y-r >= 0 && x+r <= w && y+r <= h){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}

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

#define all(A) begin(A), end(A)
#define sz(A) int(A.size())

using namespace std;

typedef long long ll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector <int> v(n), c(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  int ans = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    int x = 0, y = 0;
    for (int bit = 0; bit < n; bit++) if ((mask >> bit) & 1) x += v[bit], y += c[bit];
    ans = max(ans, x - y);
  }
  cout << ans << endl;
  return (0);
}


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

using namespace std;

int main(){
	int a, b, c;
	bool d[1000] = {};
	cin >> a >> b >> c;
	d[a] = true;
	d[b] = true;
	d[c] = true;

	int cnt = 0;

	for (int i = 0; i < 1000; i++){
		if (d[i] == true){
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn acc(b: &Vec<bool>) -> Vec<u32> {
    let mut v = vec![0; b.len() + 1];
    for i in 0..b.len() {
        v[i + 1] = v[i] + b[i] as u32;
    }
    v
}

fn main() {
    input! { n, k, a: [usize; n] };
    let a = a.into_iter().filter(|&aa| aa < k).collect::<Vec<_>>();
    let n = a.len();
    let mut ans = n;
    let mut dp1 = vec![vec![false; k]; n + 1];
    let mut dp2 = vec![vec![false; k]; n + 1];
    dp1[0][0] = true;
    for i in 0..n {
        for j in 0..k {
            dp1[i + 1][j] = dp1[i][j] | if j >= a[i] { dp1[i][j - a[i]] } else { false };
        }
    }
    dp2[n][0] = true;
    for i in (0..n).rev() {
        for j in 0..k {
            dp2[i][j] = dp2[i + 1][j]
                | if j >= a[i] {
                    dp2[i + 1][j - a[i]]
                } else {
                    false
                };
        }
    }
    for i in 0..n {
        let rv = acc(&dp2[i + 1]);
        for j in 0..k {
            if dp1[i][j] {
                let x = if k >= a[i] + j { k - a[i] - j } else { 0 };
                if rv[k - j] != rv[x] {
                    ans -= 1;
                    break;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 55548
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	const int X = 10000;
	
	int N,M,C,ans=0;
	int B[X];
	int A[100][100];
	
	
	cin>>N>>M>>C;
	
	for(int i=1;i<=M;i++)
		cin>>B[i];
	
	for(int i=1;i<=N;i++)
	for(int j=1;j<=M;j++)
	cin>>A[i][j];
	
	for(int i=1;i<=N;i++)
	{
		int t=0;
		for(int j=1;j<=M;j++)
			t+=A[i][j]*B[j];
		t+=C;
		if(t>0)
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using i64 = int64_t;

int main(){
    int n, m;
    cin >> n >> m;
    deque<bool> accepted(n+1);
    vector<int> penalties(n+1);
    for(int i=0;i<m;++i){
        int p;
        string s;
        cin >> p >> s;
        if(s == "WA"){
            if(accepted[p])continue;
            penalties[p]++;
        }else{
            accepted[p] = true;
        }
    }

    int ac = 0, penalty = 0;
    for(int i=1;i<=n;++i){
        if(accepted[i]){
            ac++;
            penalty += penalties[i];
        }
    }

    cout << ac << " " << penalty << endl;

    return 0;
}

Measured memory_bytes: 768
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define  MN                           INT_MIN
#define  MX                           INT_MAX

const int nmax = 100001; 

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int dp[110000][3];
int32_t main()
{
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	for(int i =  0;i<n;i++)
		cin >> a[i] >> b[i] >> c[i];
	for(int i= 0 ;i<n;i++)
	{
		for(int j = 0;j<3;j++)
		{
			if(i==0)
			{
				if(j==0)dp[i][j] = a[i];
				if(j==1)dp[i][j] = b[i];
				if(j==2)dp[i][j] = c[i];
			}else{
				for(int k = 0;k<3;k++)
				{
					if(k==j)continue;
					if(j==0)dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i]);
					if(j==1)dp[i][j] = max(dp[i][j], dp[i-1][k] + b[i]);
					if(j==2)dp[i][j] = max(dp[i][j],dp[i-1][k] + c[i]);
				}
			}
		}
	}
	int ans = 0;
	ans = max(ans,dp[n-1][0]);
	ans = max(ans,dp[n-1][1]);
	ans = max(ans,dp[n-1][2]);
	cout << ans << endl;
}
	

Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef complex<double> pnt;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> pp;
typedef double ld;
typedef long double lld;
#define INF 0x3f3f3f3f // for int
#define LL_INF 0x3f3f3f3f3f3f3f3f // for ll
#define gl(x) getline(cin, (x))
#define sz(x) (int)(x.size())
#define af(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof(x))
#define mpp make_pair
#define pb push_back
#define AUT auto
//coordinate compression:sort(val.begin(), val.end());
//		val.resize(unique(val.begin(), val.end()) - val.begin());
#define nl '\n'
typedef unsigned long long ull;
const int MOD = 1e9 + 7;
const lld pi = 3.14159265358979323846;

//remember to remove ios stuff if i use scanf

//printf("%05lld\n", x); --> print last 5 digits including 0's
//printf("%02d:%02d", h, m); --> time
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll pwmd(ll b, ll exp) {
    ll ret = 1;
    while (exp > 0) {
        if (exp % 2 == 1) ret = (ret * b) % MOD;
        exp /= 2;
        b = (b * b) % MOD;
    }
    return ret;
}
//void RotateArr(int X) {
//    for (int n=0; n<X; n++) {
//        for (int i=0; i<N/2; i++) {
//            for (int j=0; j<N; j++) {
//                swap(a[i][j], a[N-i-1][j]);
//            }
//        }
//        for (int i=0; i<N; i++) {
//            for (int j=i+1; j<N; j++) {
//                swap(a[i][j], a[j][i]);
//            }
//        }
//    }
//}

/*
 * string input;
 *
 * stringstream ss(input);
 *- if the input contains '\n', separate lines with: string line; while (getline(ss, line))
 * - clear() to clear the stream
 * - >> : read smth from stringstream object ie. while (s >> word)
 */

struct pair_hash { //megabrain --> for unordered_set<pair<ll, ll>>
    //initialize the set with unordered_set<pair<ll, ll>, pair_hash>st
    inline std::size_t operator()(const std::pair<ll,ll> & v) const {
        return v.first*31+v.second;
    }
};
/* for dijkstra:
 * bool operator < (const E &other) const {
        return this->w > other.w;
    }
 */

int n, a;

void solve(int tc) {

    cin >> n; ll ans = 0, mx = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a; mx = max(1LL * mx,  1LL * a);
        ans += (1LL * mx - 1LL * a);
    }
    cout << ans << nl;

}

//you should really read the stuff at the bottom

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int tc = 1; //cin >> tc;
    for (int t = 0; t < tc; t++) solve(t);

    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?
*/

Measured memory_bytes: 3648
/// @file
/// @version Accepted.
#include <bits/stdc++.h>
using namespace std;

int N;
vector<int64_t> V;  ///< Distance of a vertex i.
vector<vector<pair<int, int>>> E;  ///< Adjacency list with distance.

void dfs(int v, int64_t d) {  // vertex, distance
  V[v] = d;
  for (const auto& x : E[v]) {
    int v_next = x.first;
    int d_next = x.second;
    if (V[v_next] != -1) continue;  // already visited.
    dfs(v_next, d + d_next);
  }
}

int main() {
  cin >> N;
  V.push_back(-1);  // dummy for one-based.
  E.push_back(vector<pair<int, int>>());  // dummy for one-based.
  for (int i = 1; i <= N; ++i) {
    V.push_back(-1);
    E.push_back(vector<pair<int, int>>());
  }
  for (int i = 1; i <= N - 1; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    // Connects vertice a and b with distance c.
    E[a].push_back({b, c});
    E[b].push_back({a, c});
  }
  int Q, K;
  cin >> Q >> K;
  dfs(K, 0);
  for (int i = 1; i <= Q; ++i) {
    int x, y;
    cin >> x >> y;
    cout << V[x] + V[y] << endl;
  }
}


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

int main() {
    int n;
    cin >> n;
    int a,mx=0,cnt = 0;
    for(int i = 0;i < n;++i){
        scanf("%d",&a);
        if(a >= mx) cnt++;
        mx = max(a,mx);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    K = k * 2
    """
    K * Kに点を全て移したので、この中で黒模様の左下の頂点を全探索。
    二次元累積和で各場合についてO(1)で計算可能。

    まず前準備として白マスはxかyに関してkずらすことで黒マスにできる。こうすれば記述量はもっと減らせた。
    """
    hope = [[0] * (K + 1) for _ in range(K + 1)]
    for _ in range(n):
        x, y, c = input().split()
        x, y = int(x), int(y)
        if c == 'B':
            """あとで累積和を0-indexedで取る都合上、頂点座標は1-indexedにしておく。"""
            hope[1 + y % K][1 + x % K] += 1
        if c == 'W':
            hope[1 + (y + k) % K][1 + x % K] += 1

    """
    二次元累積和の書き方に悩んでたのは失態。
    やってみて気づいたが、やはり累積和は0-indexedにしないと後々の取り扱いが非常に面倒。
    """
    sumB = [[0] * (K + 1) for _ in range(K + 1)]
    for y in range(1, K + 1):
        for x in range(1, K + 1):
            sumB[y][x] = sumB[y-1][x] + sumB[y][x-1] + hope[y][x] - sumB[y-1][x-1]

    def calc_sum(x0, y0, x1, y1):
        # (x0, y0)が左下、(x1, y1)が右上となる矩形領域の値を返す
        return sumB[y1][x1] - sumB[y0-1][x1] - sumB[y1][x0-1] + sumB[y0-1][x0-1]

    """
    あとは黒四角の左下頂点(x, y)に関して全探索。
    """
    ans = 0
    for y in range(1, K+1):
        for x in range(1, k+1):
            if y <= k:
                val = (calc_sum(1, 1, x-1, y-1) + calc_sum(x, y, x+k-1, y+k-1)
                        + calc_sum(x+k, y+k, K, K) + calc_sum(x+k, 1, K, y-1)
                        + calc_sum(1, y+k, x-1, K))
                ans = max(ans, val)
            else:
                val = (calc_sum(x, 1, x+k-1, y-k-1) + calc_sum(1, y-k, x-1, y-1)
                        + calc_sum(x+k, y-k, K, y-1) + calc_sum(x, y, x+k-1, K))
                ans = max(ans, val)
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 138232
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    vvi a(n,vi(m));
    cin >> a;
    rep(i,n) rep(j,m) a[i][j]--;
    int ans = inf;
    vb v(m,true);
    rep(_,m) {
        vi cnt(m);
        rep(i,n) {
            rep(j,m) if(v[a[i][j]]) {
                cnt[a[i][j]]++;
                break;
            }
        }
        auto it = max_element(all(cnt));
        chmin(ans,*it);
        v[it-cnt.begin()] = false;
    }
    cout << ans << endl;
}


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


int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; ++i){
    if(i/10000 == i%10 && (i%10000)/1000 == (i%100)/10) ans++;
  }
  cout<< ans << endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <cmath>
# include <tuple>
# include <vector>
# include <queue>
# include <string>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s=="Sunny") {
        cout << "Cloudy" << endl;
    } else if (s=="Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;
ll n,len;
string s,s1;
ll pre[200005],suf[200005];
int main()
{	
	cin>>n;
	cin>>s;
	s1=s;
	ll i;
	
	len=s.length();
	if(s[0]=='#')
		pre[0]=1;
	for(i=1;i<len;i++)
		if(s[i]=='#')
			pre[i]=pre[i-1]+1;
		else
			pre[i]=pre[i-1];
	if(s[len-1]=='.')
		suf[len-1]=1;
	for(i=len-2;i>=0;i--)
		if(s[i]=='.')
			suf[i]=suf[i+1]+1;
		else
			suf[i]=suf[i+1];
		ll mini=1e18;
		for(i=0;i<len;i++)
			mini=min(mini,pre[i]+suf[i+1]);
		mini=min(mini,suf[0]);
		cout<<mini;
		
	return 0;
}

Measured memory_bytes: 3844
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int d[N];


int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &d[i]);
    }
    sort(d + 1 , d + n + 1);
    printf("%d\n" , d[n / 2 + 1] - d[n / 2]);
}

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

int n;
string s;
const int INF = 1e9;

int main() {
    cin >> n >> s;
    int cntEL, cntER, cntWL, cntWR;
    cntEL = cntER = cntWL = cntWR = 0;

    for (auto &i : s){
        cntER += i == 'E';
        cntWR += i == 'W';
    }

    int ans = INF;
    for (auto &i : s){
        (i == 'E' ? cntER : cntWR) -= 1;
        ans = min(ans, cntWL + cntER);
        (i == 'E' ? cntEL : cntWL) += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 


int main(){
  int N, M; cin >> N >> M;
  vector<int> retval(N,-1);
  int s, c;
  bool flag = true;
  rep(i,M){
    cin >> s >> c;
    s--;
    if ((N!=1&&s==0&&c==0)|| (retval[s]!=-1&&retval[s]!=c)) flag = false;
    else retval[s] = c;
  }

  if (!flag) cout << -1 << endl;
  else {
    rep(i,N){
      if (retval[i]==-1){
        if (N>=2&&i==0) cout << 1;
        else cout << 0;
      }
      else cout << retval[i];
    }
    cout << endl;

  }

  return 0;
}


Measured memory_bytes: 256
s = input()
t = input()


ans = 1000

for i in range(len(s)-len(t)+1):
    #print(s[i:i+len(t)])
    cnt = 0
    for j in range(len(t)):
        
        if t[j] != s[i:i+len(t)][j]:
            cnt +=1
        #print(cnt,t[j],s[i:i+len(t)][j])
    #print(cnt)
    ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 9116
c=[list(map(int,input().split())) for i in range(3)]
a=[]
b=[]
for i in range(3):
    a.append(c[i][0]-c[i][1])
    b.append(c[i][0]-c[i][2])
if len(set(a))==1 and len(set(b))==1:print("Yes")
else:print("No")

Measured memory_bytes: 3064
import math
n = int(input())
a = list(map(int,input().split()))

h = sum(a)/2#4.5
ans1 = 0
ans2 = 0
ls = [a[0]]

for i in range(1,n):
    ls.append(ls[i-1]+a[i])
        
        
for i in range(len(ls)):
    if ls[i] > h:
        ans1 = abs(ls[i]-sum(a[i+1:]))
        ans2 = abs(ls[i-1]-sum(a[i:]))
        print(min(ans1,ans2))
        break
        
    


Measured memory_bytes: 27300
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 200001;
const ll M = 1;

void update(ll BIT[], ll n, ll x, ll i)
{
    for(; i <= n; i += (i) & (-i)) BIT[i] += x;
}

ll query(ll BIT[], ll l)
{
    ll sum1 = 0;
    for(; l; l = l & (l - 1)) sum1 += BIT[l];
    return sum1;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, x = 0, y = 0, ans = 0, d, A, l, r, mid;
        cin >> n >> d >> A;
        pll a[n];
        for(int i = 0; i < n; i++) cin >> a[i].ff >> a[i].ss;
        sort(a, a + n);
        ll BIT[n + 2] = {};
        y = 2 * d;
        ll sol = 0;
        for(int i = 0; i < n; i++)
        {
            a[i].ss -= query(BIT, i + 1);
            if(a[i].ss <= 0) continue;
            x = (a[i].ss + A - 1)/ A;
            sol += x;
            x = x * A;
            l = i, r = n - 1;
            ans = i;
            while(l <= r)
            {
                mid = (l + r) >> 1;
                if(a[mid].ff - a[i].ff <= y)
                {
                    ans = max(mid, ans);
                    l = mid + 1;
                }
                else r = mid - 1;
            }
            update(BIT, n, x, i + 1);
            update(BIT, n, -x, ans + 2);
        }
        cout << sol << "\n";
    }
    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  
  string moji[101];
  
  for (int i = 0; i < h; i++) {
    cin >> moji[i];
  }
  
  bool hy[101] = {0};
  bool hx[101] = {0};
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (moji[i][j] == '#') {
        hy[i] = true;
        hx[j] = true;
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    if (hy[i]) {
      for (int j = 0; j < w; j++) {
        if (hx[j]) {
          cout << moji[i][j];
        }
      }
      cout << endl;
    }
  }
}

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

int n;
long long int dis[20][20];
long long int dp[1 << 16];
long long int inf = 100000 * 16 + 1;

int main() {

    while(true) {

        cin >> n;

        if(n == 0){
            break;
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n + 1; j++) {
                cin >> dis[i][j];
            }
        }

        for (int i = 0; i < (1 << n); i++) {
            dp[i] = inf;
        }

        dp[0] = 0;

        for (int i = 0; i < (1 << n); i++) {
            for (int j = 0; j < n; j++) {
                if (dp[i] == inf) continue;

                //次の状態について探索
                for (int k = 0; k < n; k++) {
                    if ((i >> k) % 2 == 1) {
                        continue;
                    }
                    int next_i = i | (1 << k);
                    long long int min_dis = dis[k][0];

                    for (int r = 0; r < n; r++) {
                        if (i & (1 << r)) {
                            min_dis = min(min_dis, dis[k][r + 1]);
                        }
                    }

                    long long int next_d = dp[i] + min_dis;
                    dp[next_i] = min(dp[next_i], next_d);
                }
            }
        }

        int all = 0;

        for (int i = 0; i < n; i++) {
            int add = 1 << i;
            all += add;
        }

        cout << dp[all] << endl;

    }

    return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int n, m;
	cin >> n >> m;
    int ans = n*(n-1)/2 + m*(m-1)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math
a, b, x = list(map(int, input().split()))
if x > a**2 * b / 2:
    c = math.atan(2 * (b - x/a**2) / a)
else:
    c = math.atan(a*b**2 / (2 * x))
pi = math.pi
print(c * 180 / pi)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  while(1){
    string s; cin>>s;
    if(s=="0") break;
    int c=0;
    rep(i,0,s.size()){
      c+=s[i]-48;
    }
    co(c);
  }
      
  return 0;
}


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

int main() {
    int k, s, ans = 0;
    cin >> k >> s;

    for(int x=0; x<=k; x++){
        for(int y=0; y<=k; y++){
            int z = s - x - y;
            if(z >= 0 && z <= k){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
                
        while(true){
            int H=sc.nextInt();
            int W=sc.nextInt();
            if(H==0&&W==0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 62816
N,M=map(int,input().split())
num={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
A=list(map(int,input().split()))
A.sort(reverse = True)
dp = [0]+[-1]*(N+1)
for i in range(N):
    for j in A:
        if i+num[j]<=N:
            dp[i+num[j]] = max(dp[i+num[j]],dp[i]+1)
ans = []
m=N
while m>0:
    for i in A:
        if m-num[i]>=0 and dp[m-num[i]]==dp[m]-1:
          m-=num[i]
          ans.append(str(i))
          break
print("".join(ans))

Measured memory_bytes: 3696
n,m= map(int, input().split())
ans=[]
if n%2==1:
    for i in range(m):
        ans.append(i+1)
        ans.append(n-1-i)

else:
    if m<=n//4:
        for i in range(m):
            ans.append(n//2+1+i)
            ans.append(n//2-i)

    else:
        for i in range(m-n//4):
            ans.append(2+i)
            ans.append(n-i)
        for i in range(n//4):
            ans.append(n//2+1+i)
            ans.append(n//2-i)


print(*ans)

Measured memory_bytes: 81860
import sys

MOD = 10**9 + 7

N = int(input())
Cs = [int(sys.stdin.readline())-1 for _ in range(N)]

numCs = [0] * (2 * 10**5)
anss = [0] * N
numCs[Cs[0]] = 1
anss[0] = 1
for i, C in enumerate(Cs[1:], 1):
    if C == Cs[i-1]:
        anss[i] = anss[i-1]
    else:
        numCs[C] += anss[i-1]
        anss[i] = numCs[C] % MOD

print(anss[-1])


Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int a, b, c, ans;
  cin >> a>>b>>c;

  if (c-(a-b) < 0) {
    ans = 0;
  } else {
    ans = c-(a-b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from math import sqrt,pi,acos
n = int(input())
p1 = [[int(i) for i in input().split()] for i in range(n)]
p,q,ans = sorted(p1),[],[]
x1,x2,y1,y2,z1,z2 = p[0][0],p[0][1]+1,p[0][0],p[0][1],10**6+1,0
def cos(a,b,c,d,e,f):
	a,b,e,f = a-c,b-d,e-c,f-d
	return (a*e+b*f)/(sqrt(a**2+b**2)*sqrt(e**2+f**2))
while p[0]!=[z1,z2]:
	q.append([y1,y2])
	num = 2
	for i,j in p:
		if y1!=i or y2!=j:
			m = cos(x1,x2,y1,y2,i,j)
			if num>m: num,z1,z2 = m,i,j
	ans.append((pi-acos(max(-1,num)))/(2*pi))
	x1,x2,y1,y2 = y1,y2,z1,z2
ans = [(pi-acos(cos(x1,x2,y1,y2,q[1][0],q[1][1])))/(2*pi)]+ans[1:]
for i in p1:
	if i in q: print(ans[q.index(i)])
	else: print(0)

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

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

    return gcd(b, a % b);
}

int main(){
    int K ;
    cin >> K;
    int ans = 0;
    rep(i,K+1){
        rep(j,K+1){
            rep(k,K+1){
                ans += gcd(gcd(i,j),k);
            }
        }
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  pair<int, int> cor[N];
  int tmp_x, tmp_y;
  rep(i,N){
    cin >> tmp_x >> tmp_y;
    cor[i] = make_pair(tmp_x, tmp_y);
  }
  sort(cor, cor+N);
  map<pair<int, int>, int > m_pq;
  map<pair<int, int>, int >::iterator ite;
  rep(i,N){
    for(int j=i+1; j < N; j++){
      if(m_pq[make_pair(cor[i].first-cor[j].first,cor[i].second-cor[j].second )]==0){
	m_pq[make_pair(cor[i].first-cor[j].first,cor[i].second-cor[j].second )] = 1;
      }
      else{
	m_pq[make_pair(cor[i].first-cor[j].first,cor[i].second-cor[j].second )]++;
      }
    }
  }
  int tmp_max=0;
  for(ite =m_pq.begin(); ite!=m_pq.end();ite++){
    tmp_max = max(ite->second, tmp_max);
  }
  cout << N-tmp_max << endl;

  return 0;
    

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define M 1000000007
#define ll long long
#define LIM 100000
using namespace std;
ll v[LIM];
int main() {
  ll h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    string a;
    cin >> a;
    cout << a << endl;
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    int a[(n+1)*(m+1)];
    int b=0;
    for(int p=0;p<n+1;p++)
    {
        for(int q=0;q<m+1;q++)
        {
                a[b]=m*p+n*q-2*q*p;
            b++;
        }
    }
    int c=0;
    int ans=0;
    while(ans!=1 && b!=c)
    {
        if(a[c]==k)
            ans =1;
        c++;
    }
    if(ans==1)
      printf("Yes");
    else
      printf("No");
}

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

using namespace std;

int main() {
    int N, K;
    double ans = 0;

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        double cur_prob = 1.0/N;
        if (i < K) {
            int pow = 1;
            int score = i;
            while (score < K) {
                pow *= 2;
                score *= 2;
            }
            cur_prob *= 1.0/pow;
        }
        ans += cur_prob;
    }

    //    cout << ans << endl;                                       
    printf("%.12f\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) > abs(x - b)) cout << "B" << endl;
    else cout << "A" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int A[1000];
  int N;
  int v,i,j,k;
  
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);

  for(k=0;k<N;k++){
    if(k==N-1)printf("%d\n",A[k]);
    else printf("%d ",A[k]);
  }
  
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while (j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;

    
    for(k=0;k<N;k++){
      if(k==N-1)printf("%d\n",A[k]);
      else printf("%d ",A[k]);
    }

  }
  
  return 0;
}


Measured memory_bytes: 2084
// Around Square

#include <iostream>

using namespace std;

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

	long long res;

	for (int i = 1; ; ++i){
		long long square = i * i;
		if (square > N){
			res = (i-1) * (i-1);
			break;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,p,d[110],s,i;
  while(scanf("%d %d %d",&n,&m,&p),n){
    for(i=s=0;i<n;s+=d[i])scanf("%d",&d[++i]);
    printf("%d\n",d[m]?s*(100-p)/d[m]:0);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
bitset<5000> dp1[5001], dp2[5001];
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  dp1[0][0] = dp2[n][0] = 1;
  for (int i = 0; i < n; i++) {
    dp1[i + 1] = dp1[i] | dp1[i] << a[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    dp2[i] = dp2[i + 1] | dp2[i + 1] << a[i];
  }
  auto needed = [&](int i) {
    if (a[i] >= k) return true;
    int x = 0, y = k - 1;
    while (true) {
      while (x < k and not dp1[i][x]) x++;
      if (x == k) break;
      while (x + y >= k - a[i]) {
        if (y >= 0 and dp2[i + 1][y]) return true;
        y--;
      }
      x++;
    }
    return false;
  };
  int l = -1, r = n;
  while (true) {
    int m = (l + r) / 2;
    if (needed(m)) r = m;
    else l = m;
    if (r - l == 1) break;
  }
  cout << r << '\n';
  return 0;
}


Measured memory_bytes: 6400
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
res = INF
for i in range(1,10**6+10):
    if n%i == 0:
        tmp = i + n//i - 2
        res = min(res, tmp)
print(res)

Measured memory_bytes: 66152
/*
	The Island Was Silent before.
	.....
	And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);

int main() {
	#ifndef ONLINE_JUDGE
	//ioso ffe
	#endif
	int t; cin >> t;
	int a[100010];
	for(int cas=1;cas<=t;cas++) {
		//cout << " : " << cas << ": ";
		cin >> a[cas];

	}
	ll cnt=0;
	for(int i=1;i<=t;i++) {
		if(a[a[i]]==i) {cnt++; a[a[i]]=0; a[i]=0;}
	}
	cout << cnt << endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct UnionFind {
  vector<int> data;
  UnionFind(int n):data(n, -1){}
  int find(int x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
  bool same(int x, int y) { return find(x) == find(y); }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y]; data[y] = x;
  }
};

struct Point {
  double x, y;
  Point(){}
  Point(double x, double y):x(x), y(y){}
  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
};

double norm(Point p) {
  return p.x*p.x+p.y*p.y;
}
double abs(Point p) {
  return sqrt(norm(p));
}
double dist(Point a, Point b) {
  return abs(a-b);
}

struct edge {
  int u, v;
  double w;
  edge(){}
  edge(int u, int v, double w):u(u), v(v), w(w){}
  bool operator < (const edge& e) const {
    return w > e.w;
  }
};

int N, M;
vector<Point> P;
vector<edge> E;

double kruskal() {
  UnionFind uf(N);
  sort(all(E));
  double res = 0;
  for(edge &e : E) {
    if(!uf.same(e.u, e.v)) {
      uf.unite(e.u, e.v);
      res += e.w;
    }
  }
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  rep(i, N) {
    Point p;
    cin >> p.x >> p.y;
    P.push_back(p);
  }
  double sum = 0;
  rep(i, M) {
    int p, q;
    cin >> p >> q;
    --p, --q;
    double cost = dist(P[p], P[q]);
    E.push_back(edge(p, q, cost));
    sum += cost;
  }
  cout << sum - kruskal() << endl;

  return 0;
}

Measured memory_bytes: 4036
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
	int tan[1100],i,j,n,t,c;
	
	while(scanf("%d",&n)){
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d",&tan[i]);
		}
		scanf("%d",&t);
		
		i=0;
		j=n-1;
		c=0;
		while(i<=j){
			++c;
			if(tan[(i+j)/2]<t){
				i=(i+j)/2+1;
			}else if(tan[(i+j)/2]==t){
				break;
			}else{
				j=(i+j)/2-1;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>

int main(){
    int N;
    std::cin >> N;
    
    long long sum = 0;
    for(int i=1; i<=N; i++){
        for(int j=i; j<=N; j++){
            for(int k=j; k<=N; k++){
                int min = std::min({i, j, k});
                int tmp = 1;
                int i_tmp = i, j_tmp = j, k_tmp = k;
                for(int divid=2; divid<=min; divid++){
                    while(i_tmp%divid == 0 && j_tmp%divid == 0 && k_tmp%divid == 0){
                        i_tmp /= divid;
                        j_tmp /= divid;
                        k_tmp /= divid;
                        tmp *= divid;
                    }
                }
                if(i == j && j == k){
                    sum += tmp;
                }else if(i == j || j == k || k == i){
                    sum += tmp * 3;
                }else{
                    sum += tmp * 6;
                }
            }
        }
    }
    
    
    std::cout << sum << std::endl;
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
using namespace std;

int main() {
  long long n, p;
  long long i = 0;
  long long ans;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
  } else if (p == 1) {
    cout << "1" << endl;
  } else if (n > 64) {
    cout << "1" << endl;
  } else {
    ans = 1;
    i = 2;
      
    while (pow(i, n) <= p) {
      if (p % (long long)pow(i, n) == 0){
        ans = i;
      }
      i++;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

void solve()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5])
        cout << "Yes\n";
    else
        cout << "No\n";

}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

struct UnionFind{
	int *par;
	ll *size;
	UnionFind(int n){
		par=(int *)malloc(sizeof(int)*n);
		size=(ll *)malloc(sizeof(ll)*n);
		rep(i,n)par[i]=i;
		rep(i,n)size[i]=1;
	}
	int root(int x){
		if(par[x]==x)return x;
		return par[x]=root(par[x]);
	}


	void unite(int x, int y){
		int rx=root(x);
		int ry=root(y);
		if(rx==ry)return;
		par[ry]=rx;
		size[rx]+=size[ry];
	}

	bool same(int x, int y){
		int rx=root(x);
		int ry=root(y);
		return rx==ry;
	}

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

ll s[100005],t[100005];

int calc_right(int l, int r, ll val){
	while(l+1<r){
		if(s[(l+r)/2]<val)l=(l+r)/2;
		else r=(l+r)/2;
	}
	return r;
}

int calc_right1(int l, int r, ll val){
	while(l+1<r){
		if(t[(l+r)/2]<val)l=(l+r)/2;
		else r=(l+r)/2;
	}
	return r;
}
int main(void){
	int a,b,q;
	cin>>a>>b>>q;


	rep(i,a)cin>>s[i];
	rep(i,b)cin>>t[i];
	sort(s,s+a);
	sort(t,t+b);

	rep(i,q){
		ll val;
		cin>>val;
		int x,y;
		x=calc_right(0,a-1,val);
		y=calc_right1(0,b-1,val);
		ll lx=s[x-1],rx=s[x];
		ll ly=t[y-1],ry=t[y];
		//cout<<x<<","<<y<<endl;
		ll min=1000000000000;
		if(x-1==-1)lx=-min;
		if(x==a)rx=min;
		if(y-1==-1)ly=-min;
		if(y==b)ry=min;
		//cout<<"val = "<<val<<endl;
		//cout<<"s:"<<lx<<","<<rx<<endl;
		//cout<<"t:"<<ly<<","<<ry<<endl;

		
		if(min>abs(lx-val)+abs(lx-ly))min=abs(lx-val)+abs(lx-ly);
		if(min>abs(lx-val)+abs(lx-ry))min=abs(lx-val)+abs(lx-ry);
		if(min>abs(rx-val)+abs(rx-ly))min=abs(rx-val)+abs(rx-ly);
		if(min>abs(rx-val)+abs(rx-ry))min=abs(rx-val)+abs(rx-ry);
		if(min>abs(ly-val)+abs(lx-ly))min=abs(ly-val)+abs(lx-ly);
		if(min>abs(ly-val)+abs(rx-ly))min=abs(ly-val)+abs(rx-ly);
		if(min>abs(ry-val)+abs(lx-ry))min=abs(ry-val)+abs(lx-ry);
		if(min>abs(ry-val)+abs(rx-ry))min=abs(ry-val)+abs(rx-ry);
		cout<<min<<endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const ll mod = 1e9 + 7;
ll n, m, dp[1000 + 9][1000 + 9];
char arr[1000][1000];

ll ans(ll i, ll j) {
    ll &ret=dp[i][j];
    if(~ret)return ret;
    if (i == n || j == m||arr[i][j]=='#')return 0;
    if (i == n - 1 && j == m - 1)return 1;
    ll path1 = ans(i + 1, j) % mod;
    ll path2 = ans(i, j + 1) % mod;
    return ret=(path1+path2)%mod;
}

int main() {
    fast();
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> arr[i][j];
        }
    }
    clr(dp,-1);
    cout << ans(0, 0);
}

Measured memory_bytes: 9216
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256