akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // abs()
#include <string.h>         // memset()
#include <stdbool.h>

#define MAX_N 16
#define MAX_S (1 << MAX_N)

const double INF = 1e10;

int n;
int s[MAX_N], l[MAX_N], v[MAX_N];
double dp[MAX_N][MAX_S];
int w[MAX_N][MAX_S];
short prev[MAX_N][MAX_S][2];
int ord[MAX_N];

int
main(int argc, char **argv)
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d%d", &s[i], &l[i], &v[i]);

	memset(prev, -1, sizeof(prev));
	int S = 1;
	for (int i = 0; i < n; i++, S <<= 1)
		w[i][S] = v[i];

	int e = 1 << n;
	for (int k = 0; k < e; ++k)
	{
		S = 1;
		for (int i = 0; i < n; ++i, S <<= 1)
		{
			if (k & S)
				continue;

			int t = k | S;
			for (int j = 0; j < n; ++j)
			{
				if (i == j || w[j][k] == 0)
					continue;

				int d = abs(l[i] - l[j]);
				double x = dp[j][k] + (d * (7 + 2 * w[j][k])) / 200.0;
				if (dp[i][t] == 0 || x < dp[i][t])
				{
					dp[i][t] = x, w[i][t] = w[j][k] + v[i];
					prev[i][t][0] = j;
					prev[i][t][1] = k;
				}
			}
		}
	}

	double min = INF;
	int u = 0;
	for (int i = 0; i < n; ++i)
	{
		double y = dp[i][e - 1];
		if (y == 0)
			continue;

		if (y < min)
			min = y, u = i;
	}

	ord[0] = u;
	int v = e - 1;
	for (int k = 1; k < n; ++k)
	{
		ord[k] = prev[u][v][0];
		v = prev[u][v][1];
		u = ord[k];
	}

	for (int i = n - 1; i >= 0; --i)
		printf("%d%c", s[ord[i]], (i != 0) ? ' ' : '\n');

	return 0;
}

Measured memory_bytes: 10908
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll A, B, X; cin >> A >> B >> X;
  auto a = A / X;
  auto b = B / X;
  auto c = b - a;
  if (A % X == 0) {
    ++c;
  }
  cout << c << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

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

  int count=0;
  int p[n+1];

  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int i=1;i<n-1;i++){
    if(p[i-1]<p[i] && p[i]<p[i+1]){
      count++;
    }
    else if(p[i-1]>p[i] && p[i]>p[i+1]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input().strip()

wl = []
wc = 0
prevs = None
for i, _s in enumerate(s):
  if prevs is None:
    wl.append(i)
    prevs = _s
    if _s == '0':
      wc += 1
  elif prevs != _s:
    wl.append(i)
    prevs = _s
    if _s == '0':
      wc += 1
wl.append(n)

if k >= wc:
  print(n)
elif s[0] == '0':
  if s[-1] == '0':
    maxl = max(wl[2*k] - wl[0], wl[-1] - wl[-2*k-1])
    for l, r in zip(wl[1::2], wl[2*k+2:-1:2]):
      if r - l > maxl:
        maxl = r - l
  else:
    maxl = wl[2*k] - wl[0]
    for l, r in zip(wl[1::2], wl[2*k+2::2]):
      if r - l > maxl:
        maxl = r - l
  print(maxl)
else:
  if s[-1] == '0':
    maxl = wl[-1] - wl[-2*k-1]
    for l, r in zip(wl[::2], wl[2*k+1:-1:2]):
      if r - l > maxl:
        maxl = r - l
  else:
    maxl = 0
    for l, r in zip(wl[::2], wl[2*k+1::2]):
      if r - l > maxl:
        maxl = r - l
  print(maxl)


Measured memory_bytes: 7924
#include <iostream>

using namespace std;

int main() {
	int count = 0;
	int N;
	int A[200];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	bool breakflag = false;
	while (!breakflag) {
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 == 0) {
				A[i] = A[i] / 2;
			}
			else {
				breakflag = true;
			}
		}
		if (!breakflag) count++;
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>

int main(){
    int x;
    std::cin >> x;
    int max = 1;
    if(x == 1){
        std::cout << 1 << std::endl;
        return 0;
    }
    for(int b = 2; b < sqrt(x); b++){
        int p = 1;
        while(1){
            if(std::pow(b, p) > x){
                break;
            }
            if(max < std::pow(b, p)){
                max = std::pow(b, p);
            }
            p++;
        }
    }
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
mod=pow(10,9)+7
#ans=[int(input()) for _ in range(n+1)]
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1]
for i in range( 2, n + 2 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
# 二つあるやつの左の方の左にl個、右のやつの右のほうにr個数字がある
f=[-1]*(n+1)
l,r=0,0
for i in range(n+1):
  ai=a[i]
  if f[ai]==-1:
    f[ai]=i
  else:
    l=f[ai]
    r=n-i
    break
for k in range(1,n+2):
  a=cmb(n+1,k,mod)
  if l+r>=k-1:
	  a-=cmb(l+r,k-1,mod)
  #print(a==ans[k-1],a,ans[k-1])
  print(a%mod)

Measured memory_bytes: 24676
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val dp = Array.fill(n+1)(Int.MaxValue)
  dp(0) = 0

  def loop(i:Int, num:Int, cnt:Int):Unit = {
    val d = math.pow(num,cnt).toInt
    if(d <= i) {
      dp(i) = math.min(dp(i), dp(i-d)+1)
      loop(i, num, cnt+1)
    }
  }

  for(i <- 1 to n) {
    loop(i, 6, 0)
    loop(i, 9, 1)
  }

  println(dp(n))
}

Measured memory_bytes: 27596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}


int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int h, n, a[1000], b[1000];
int dp[1010][20010];
int ans = INF;

signed main() {
	cin >> h >> n;
	for (int i = 0; i < 1010; i++) {
		for (int j = 0; j < 20010; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		for (int j = 0; j < h + 10000; j++) {
			if (j >= a[i] && j < h + a[i]) dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i]);
			else dp[i + 1][j] = dp[i][j];
		}
		cout << endl;
	}
	for (int i = h; i < h + 10000; i++) {
		ans = min(ans, dp[n][i]);
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    int mid1 = sum/n;
    int mid2 = sum/n+1;
  
    int ans1=0,ans2=0;
    for(int i=0;i<n;i++){
        ans1 += (mid1-a[i])*(mid1-a[i]);
        ans2 += (mid2-a[i])*(mid2-a[i]);
    }
    if(ans1>=ans2){
      cout << ans2 << endl;
    }
    else {
      cout << ans1 << endl;
    }

}

Measured memory_bytes: 256
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1362",problemID = "B",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    q = n % 10
    if q in [2,4,5,7,9]:
        print("hon")
    elif q in [0,1,6,8]:
        print("pon")
    else:
        print("bon")
                
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

def power_two(n):
    if n == 1:
        return(True)
    sttr = str(n)
    len_str = len(sttr)
    sttr = list(sttr)
    num = 0
    if (len_str == 1 and sttr[len_str - 1] == '1'): 
        return(False)
    while (len_str != 1 or sttr[len_str - 1] != '1'):
        if ((ord(sttr[len_str - 1]) - ord('0')) % 2 == 1):
            return(False)
        j = 0; 
        for i in range(len_str):  
            num = num * 10 + (ord(sttr[i]) - ord('0')); 
            if (num < 2): 
                if (i != 0):  
                    sttr[j] = '0'
                    j += 1
                continue
  
            sttr[j] = chr((num // 2) + ord('0'))
            j += 1; 
            num = (num) - (num // 2) * 2
        len_str = j
    return(True)

def log_two(n): 
    return(math.log(n) / math.log(2))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

Measured memory_bytes: 63084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, M;
ll Hs[100100];

void solve() {
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        cin >> Hs[i];
    }
    vector<int> jj[N];
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        jj[a-1].push_back(b-1);
        jj[b-1].push_back(a-1);
    }

    ll x = 0;
    for (int i = 0; i < N; ++i) {
        vector<int> js = jj[i];
        if (js.size() == 0) x++;
        else {
            ll hx = Hs[i];
            bool ok = true;
            for (int po : js) {
                ll hp = Hs[po];
                if (hx <= hp) {
                    ok = false;
                    break;
                }
            }
            if (ok) x++;
        }
    }
    cout << x << endl;
}

int main() {
    solve();
    return 0;
}


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

int main(void)
{
    int n, m, c=0, yes=0;
    cin >> n >> m;
    int a[n];
    for(int i=0; i<n; ++i)
    {
        cin >> a[i];
        c += a[i];
    }
    double x = 1.0/(4*m);
    for(int i=0; i<n; ++i)
    {
        if(a[i] >= c*x) ++yes;
    }
    if(yes >= m) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include <set>
#include <numeric>
#include <iostream>
#include <iterator>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int main(){
  int n;
  while(cin >> n, n){
    set<int> s[2];

    REP(i,n){ int tmp; cin >> tmp; s[0].insert(tmp); }
    REP(i,n + n) if(!s[0].count(i + 1))
      s[1].insert(i + 1);
    
    int turn = 0;
    int card = 0;
    
    while(s[0].size() && s[1].size()){
      set<int>::iterator it = lower_bound(s[turn].begin(), s[turn].end(), card + 1);
      
      if(it == s[turn].end()){
	card = 0;
      }else{
	card = *it;
	s[turn].erase(it);
      }
      
      turn = turn ^ 1;
    }
    
    cout << s[1].size() << endl;
    cout << s[0].size() << endl;
  }

  return 0;
}

Measured memory_bytes: 0
h,w = map(int, input().split())
aij = [list(input()) for i in range(h)]
aij1 = []
for r in aij:
    if r.count(".")==w:
        continue
    aij1.append(r)

h_r = len(aij1)
aij1_t = [[""]*h_r for i in range(w)]
for i in range(h_r):
    for j in range(w):
          aij1_t[j][i] = aij1[i][j]
          
ans_t = []
for c in aij1_t:
    if c.count(".") == h_r:
        continue
    ans_t.append(c)
    
w_r = len(ans_t)
ans = [[""]*w_r for i in range(h_r)]
for i in range(h_r):
    for j in range(w_r):
        ans[i][j] = ans_t[j][i]

for r in ans:
    print("".join(r))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int s = a.back();
  int wa=0;
  rep(i,n-1){
    wa+=a[i];
  }
  cout << (wa>s?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 2000001
#define M 10001
int n,A[N],B[N],C[M];
void countingSort(void);
int main(){
  int i;
  int count=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  countingSort();
  for(i=1;i<=n;i++){
    if( (i-1)!=0 ){
      printf(" ");
    }
    printf("%d",B[i]);
    count++;
  }
  printf("\n");
  return 0;
}
void countingSort(void){
  int i;
  for(i=0;i<M;i++){
    C[i] = 0;
  }
  for(i=1;i<=n;i++){
    C[A[i]]++;
  }
  for(i=1;i<M;i++){
    C[i] += C[i-1];
  }
  for(i=1;i<=n;i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
  return;
}

Measured memory_bytes: 16268
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

char mp[111][111];

int main()
{
	
	REP(i,111)REP(j,111)mp[i][j] = '#';
	int h,w;cin >> h>>w;
	REP(i,h)REP(j,w)cin >> mp[i+1][j+1];
	
	REP(i,h+2)
	{
		REP(j,w+2)
		{
			cout << mp[i][j];
		}
		cout << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void fun(char *);
void fun(char *s)
{
    int i;
    int a[26]={0};
    for(i=0;s[i]!='\0';i++)
    {
        a[s[i]-'a']++;
    }
    for(i=0;i<26;i++)
    {
        if(a[i]==2)
        {
            printf("no\n");
            return;
        }
    }
    printf("yes\n");
}
int main()
{
    char a[27];
    scanf("%s",a);
    fun(a);
    return 0;
}

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

lis=[a,b,c]
lis.sort()

a=lis[0]
b=lis[1]
c=lis[2]
if a==b and b!=c:
    print("Yes")
elif b==c and a!=b:
    print("Yes")
else:
    print("No")

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vp;

#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



int main()
{
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    ll n, k; cin>>n>>k;
    if(n >= k)
    {
        n = n-1LL*k*(1+1LL*(n-k)/k);
    }
    cout<<min(n, k-n);
    
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
loop vars,1LL in mult, out of bounds, int v ll, endl, finish taking inputs, large doubles, larger INF
*/





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

template<typename T>
struct BellmanFord{
    const T inf=numeric_limits<T>::max();
    struct edge{
        int u,v; T w;
        edge(int u,int v,T w):u(u),v(v),w(w){}
    };
    int n;
    vector<vector<int>> G;
    vector<int> check,reach;
    vector<edge> es;
    BellmanFord(int n):n(n),G(n),check(n),reach(n,1){}
    void add_edge(int u,int v,T w){
        es.emplace_back(u,v,w);
        G[u].emplace_back(v);
    }
    vector<T> build(int s,int &neg_loop){
        vector<T> d(n,inf);
        d[s]=0;
        for (int i=0;i<n;++i){
            bool update=false;
            for (auto e:es){
                if (!reach[e.u]||!reach[e.v]||d[e.u]==inf) continue;
                if (d[e.u]+e.w<d[e.v]){
                    d[e.v]=d[e.u]+e.w;
                    update=true;
                }
            }
            if (!update) break;
            if (i==n-1){neg_loop=1; return d;}
        }
        neg_loop=0; return d;
    }
    void dfs(int v){
        if (check[v]) return;
        check[v]=1;
        for (int u:G[v]) dfs(u);
    }
    T shortest_path(int s,int t,int &neg_loop){
        for (int i=0;i<n;++i){
            fill(check.begin(),check.end(),0);
            dfs(i);
            reach[i]=check[t];
        }
        return build(s,neg_loop)[t];
    }
};

// https://atcoder.jp/contests/abc061/tasks/abc061_d

void ABC061_D(){
    int N,M; cin >> N >> M;

    BellmanFord<long long> BF(N);
    for (int i=0;i<M;++i){
        int a,b,c; cin >> a >> b >> c;
        BF.add_edge(--a,--b,-c);
    }

    int neg;
    long long ans=BF.shortest_path(0,N-1,neg);
    if (neg) cout << "inf" << '\n';
    else cout << -ans << '\n';
}

void ABC137_E(){

}

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

Measured memory_bytes: 3616
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,K;
    R(N,K);
    VI h(N);
    REP(i,N)R(h[i]);
    sort(ALL(h));
    if(K>=N)W(0);
    else{
        LL an=0;
        REP(i,N-K)an+=h[i];
        W(an);
    }
    return 0;
}


Measured memory_bytes: 1024
n, m = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i).sort.reverse
sum = nums.inject(:+)
selected = []
nums.each do |num|
  rate = num.to_f / sum
  if rate >= (1.0 / (4 * m))
    selected << num
  end
end
if selected.size >= m
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n,a;
	cin>>n>>a;
	cout<<n*n-a<<endl;
	return 0;
}

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

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

  if( s == "zyxwvutsrqponmlkjihgfedcba" ){
    cout<<-1<<endl;
    return 0;
  }
  
  if( s.size() < 26 ){
    
    int cnt[300] = {};

    for(int i=0;i<s.size();i++) cnt[s[i]] = 1;
    
    for(int i='a';i<='z';i++){
      
      if( cnt[i] == 0 ){
	cout<<s+(char)i<<endl;
	return 0;
      }
      
    }
    
  }
  else{
    
    for(int i=(int)s.size()-2;i>=0;i--){
      
      if( s[i] < s[i+1] ){
	
	string ans = s.substr(0, i);
	
	int add = 'z';
	
	for(int j=i+1;j<s.size();j++){
	  if( s[i] < s[j] ) add = min( add, (int)s[j] );
	}
	
	cout<<ans+(char)add<<endl;
	
	return 0;
      }
      
    }
    
  }
  
  return 0;
}


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

using namespace std;

#define N 600000

int n,a[N],f[N];
char s[N];

void upd(int &x,int y){
	x=max(x,y);
}

int main(){
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n;++i) a[i]=s[i]-'0';
	for (int i=1;i<=n;++i){
		upd(f[i],f[i-1]);
		if (i>1&&a[i]&&!a[i-1]){
			int j=i-2;
			for (;a[j];--j);
			upd(f[i],f[j]+(i-j-2));
			upd(f[i],f[j+1]+(i-j-3));
		}
		if (i<n&&a[i]&&!a[i+1]){
			int j=i+2;
			for (;a[j];++j);
			upd(f[j-1],f[i-1]+(j-i-2));
			upd(f[j-2],f[i-1]+(j-i-3));
		}
	}
	printf("%d\n",f[n]);
	
	return 0;
}
			

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int max = 0;
            for (int i = 0; i < n; i++)
            {
                max = Math.Max(max, a[i]);
            }
            int[] ls = new int[max + 1];
            for (int i = 0; i < n; i++)
            {
                ls[a[i]]++;
            }
            if(max % 2 ==0)
            {
                for (int i = 0; i < max/2; i++)
                {
                    if(ls[i]>0)
                    {
                        Console.WriteLine("Impossible");
                        return;
                    }
                }
                if (ls[max / 2] != 1)
                {
                    Console.WriteLine("Impossible");
                    return;
                }
                for (int i = max/2 + 1; i <= max; i++)
                {
                    if(ls[i]<2)
                    {
                        Console.WriteLine("Impossible");
                        return;
                    }
                }
            }
            else
            {
                for (int i = 0; i < (max + 1)/ 2; i++)
                {
                    if (ls[i] > 0)
                    {
                        Console.WriteLine("Impossible");
                        return;
                    }
                }
                if (ls[(max + 1) / 2] != 2)
                {
                    Console.WriteLine("Impossible");
                    return;
                }
                for (int i = (max + 1) / 2 + 1; i <= max; i++)
                {
                    if (ls[i] < 2)
                    {
                        Console.WriteLine("Impossible");
                        return;
                    }
                }
            }
            Console.WriteLine("Possible");
        }
    }
}


Measured memory_bytes: 2776
//abc136

#include "iostream"
#include <string>
#include <deque>
#include <algorithm>
//#include <map>
using namespace std;

//map<string, int> Map;

//long long CalValue(int val)
//{
//	long long ret = 1;
//
//	ret = val ;
//	ret *= (val - 1) / 2;
//
//	return ret;
//}
long long CalValue(int val)
{
	long long ret = 1;
	if (val < 2)
		return 0;
	for (int i = val; i > val - 2; i--)
	{
		ret *= i;
	}

	return ret / 2;
}

int main(void)
{
	int N;
	int i;
	string s;
	int pos1;
	int count = 0;
	long long maxCount = 0;

	cin >> N;

	string *psArray = new string[N];

	for (i = 0; i < N; i++)
	{
		cin >> s;
		sort(s.begin(), s.end());
		psArray[i] = s;
	}

	sort(psArray, psArray + N);

	pos1 = 0;
	count = 1;
	for (i = 1; i < N; i++)
	{
		if (psArray[i] == psArray[pos1])
		{
			count++;
			if (i == (N - 1))
			{
				maxCount += CalValue(count);
			}
		}
		else
		{
			pos1 = i;
			maxCount += CalValue(count);
			count = 1;
		}
	}

	//for (i = 0; i < N; i++)
	//{
	//	cout << psArray[i]<<endl;
	//}

	cout << maxCount;
	delete[]psArray;
	return 0;
}


//
//int main(void)
//{
//	int N;
//	int i;
//	deque <string> dequeS;
//	string s;
//	int pos1;
//	int count = 0;
//	long long maxCount = 0;
//
//	cin >> N;
//	
//	string *psArray = new string[N];
//
//	for (i = 0; i < N; i++)
//	{
//		cin >> s;
//		sort(s.begin(), s.end());
//		psArray[i] = s;
//	}
//
//	sort(psArray, psArray + N);
//
//	pos1 = 0;
//	count = 1;
//	for (i = 1; i < N; i++)
//	{
//		if (psArray[i] == psArray[pos1])
//		{
//			count++;
//			if (i == (N - 1))
//			{
//				maxCount += CalValue(count);
//			}
//		}
//		else
//		{
//			pos1 = i;
//			maxCount += CalValue(count);
//			count = 1;
//		}
//	}
//
//	//for (i = 0; i < N; i++)
//	//{
//	//	cout << psArray[i]<<endl;
//	//}
//
//	cout << maxCount;
//	delete[]psArray;
//	return 0;
//}






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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define rrep(i, n) for(long long i = (long long)(n - 1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	vector<int> A(n, 0);
	rep(i, k)
	{
		int d;
		cin >> d;

		rep(j, d)
		{
			int a;
			cin >> a;
			a--;
			A[a] = 1;
		}
	}

	int ans = 0;
	rep(i, n)
	{
		if (A[i] == 0)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    n: i64,
  }
  let mut t: i64 = n;
  let mut x: i64 = 2;
  let mut ans = 0;
  while x * x <= n {
    let mut a = 0;
    while t % x == 0 {
      t = t / x;
      a = a + 1;
    }
    for i in 1..50 {
      if a >= i {
        a = a - i;
        ans = ans + 1;
      }
      else {
        break;
      }
    }
    x = x + 1;
  }
  if t != 1 {
    ans = ans + 1;
  }
  if n == 1 {
    ans = 0;
  }
  
  println!("{}",ans);
}

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

int main() {
  long long r, d;
  vector<long long> x(11);
  cin >> r >> d >> x.at(0);
  
  for(int i = 1; i < 11; i++){
    x.at(i) = x.at(i - 1) * r - d;
    cout << x.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005;
struct node{
	ll num,no;
};
node p[N];
bool cmp(node node1,node node2) {
	return node1.num<node2.num;
}
ll f[N][N];
ll n;
ll calc(ll x,ll y) {
	if (f[x][y]>-1) return f[x][y];
	if (x>y) return f[x][y]=0;
	ll now=y-x+1;
	f[x][y]=max(p[now].num*abs(p[now].no-x)+calc(x+1,y),p[now].num*abs(p[now].no-y)+calc(x,y-1));
	return f[x][y];
}
int main() {
	ll i,j,ans;
	scanf("%lld",&n);
	for (i=1;i<=n;i++) {
		scanf("%lld",&p[i].num);
		p[i].no=i;
	}
	sort(p+1,p+n+1,cmp);
	for (i=1;i<=n;i++) for (j=1;j<=n;j++) f[i][j]=-1;
	ans=calc(1,n);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 35296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,M;
    cin >> A >> B >> M;
    vec<int> X(A),Y(B);
    for(int i=0;i<A;i++) cin >> X[i];
    for(int j=0;j<B;j++) cin >> Y[j];
    int ans = *min_element(X.begin(),X.end())+*min_element(Y.begin(),Y.end());
    for(int i=0;i<M;i++){
        int x,y,c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans,X[x]+Y[y]-c);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;

        final int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            min = Math.min(min, a);
            max = Math.max(max, a);
        }

        System.out.println(max - min);
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
int main()
{   
    int N;
    cin>>N;
    string ans="No";
    REP2(i,1,10){
        if(N%i==0){
			if(N/i<10) ans="Yes";
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

ttl = abs(a[0])+abs(a[n-1])

for i in range(n-1):
    ttl += abs(a[i+1] - a[i])
    
for i in range(n):
    if i == 0:
        tmp = ttl
        tmp -= abs(a[0])
        tmp -= abs(a[1]-a[0])
        tmp += abs(a[1])
        print(tmp)
    elif i == n-1:
        tmp = ttl
        tmp -= abs(a[n-1])
        tmp -= abs(a[n-1]-a[n-2])
        tmp += abs(a[n-2])
        print(tmp)
    else:
        tmp = ttl
        tmp -= abs(a[i]-a[i-1])
        tmp -= abs(a[i+1]-a[i])
        tmp += abs(a[i+1] - a[i-1])
        print(tmp)

Measured memory_bytes: 13800
#include <iostream>
#include <algorithm>
using namespace std;


int main ()
{

string s;
cin >> s;

sort(s.begin(), s.end());

if(s[0]==s[1]  && s[1]!=s[2] && s[2]==s[3])
{
	 cout << "Yes" << endl;
}
else
{
	cout << "No" << endl;
}

	return 0;
}











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

vector<int> a(22), b(22), c(22), v;


int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
    int n; cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 1; i <= n; ++i) cin >> b[i];
    for(int i = 1; i <= n - 1; ++i) cin >> c[i];
    v.assign(n + 1, 0);
    
    
    
    for(int i = 1; i <= n; ++i){
		v[a[i]] += b[a[i]];
	}
	for(int i = 1; i <= n - 1; ++i){
		if(a[i+1] == (a[i] + 1)) v[a[i+1]] += c[a[i]];
	}
	
	int sum = 0;
	for(auto i : v) sum += i;
	
	cout << sum;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
  
using namespace std;

double r;
int n;

int main(){
	
	while(cin>>r>>n,r){

		double left,right,h;
		map<int,double> HL,HR;
		for(int i=0;i<n;i++){
			cin>>left>>right>>h;
			for(int x=left;x<=right;x++){
				if(x!=right) HL[x]=max(HL[x],h);
				if(x!=left)  HR[x]=max(HR[x],h);
			}	
		}
		
		double res=1e10;
		//[i,i+1]??????????????????
		for(int i=-r;i<=r-1;i++){
			double t1=r-sqrt(r*r-i*i)+HL[i];
			double t2=r-sqrt(r*r-(i+1)*(i+1))+HR[i+1];
			res=min(res,min(t1,t2));
		}
		printf("%.8f\n",res);
		
	}
	
	return 0;
}

Measured memory_bytes: 3152
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/

int main()
{
	int h, m, s;
	while (cin >> h >> m >> s&&h != -1)
	{
		int t = 120*60-h*3600-m*60-s;
		printf("%02d:%02d:%02d\n", t / 3600, (t / 60) % 60, t % 60);
		t *= 3;
		printf("%02d:%02d:%02d\n", t / 3600, (t / 60) % 60, t % 60);
	}
	

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
            using namespace std;
             
            int main() {
              int N, A, B , sum, K, i;              
              cin >> N >> K;
              sum = 1;
              for (i = 0; i < N; i++){   
                if(sum * 2 < sum + K) {
                  sum = sum * 2;
                } else {
                  sum = sum + K;
                }
              }
               cout << sum << endl;
            }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	vector<string>w(n);
	rep(i, n)cin >> w[i];
	rep(i, n - 1) {
		if (w[i][w[i].size() - 1] != w[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	sort(w.begin(), w.end());
	rep(i, n - 1) {
		if (w[i] == w[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
// Copyright 2017 wu_qing
#include <cstdio>
const int N = 800;
int h, w;
char a[N], x[N][N], y[N][N];
int main() {
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            x[i][j] = y[i][j] = '.';
    for (int i = 1; i <= h; i++) {
        x[i][1] = y[i][w] = '#';
        x[i][w + 1] = y[i][w + 1] = '\0';
    }
    for (int i = 1; i <= h; i += 2)
        for (int j = 1; j < w; j++)
            x[i][j] = '#';
    for (int i = 2; i <= h; i += 2)
        for (int j = 2; j <= w; j++)
            y[i][j] = '#';
    for (int i = 1; i <= h; i++) {
        scanf("%s", a + 1);
        for (int j = 1; j <= w; j++)
            if (a[j] == '#')
                x[i][j] = y[i][j] = '#';
    }
    for (int i = 1; i <= h; i++)
        printf("%s\n", x[i] + 1);
    printf("\n");
    for (int i = 1; i <= h; i++)
        printf("%s\n", y[i] + 1);
}


Measured memory_bytes: 1408
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <math.h> 

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (i = 0; i < n; i++)
#define FOR(i, a, b) for (i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

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

int main()
{

    std::cin.tie(0);

    double a,b,h,m;
    cin >> a >> b >> h >> m;

    double res;

    double tmp;
    // double rad_tmp = 1/12*m/60*360;

    tmp = abs((h/12*360 + 360/12*m/60) - m/60*360); //deg
    double ttmp = cos(pi * tmp / 180); //rad

    res = (a*a + b*b) - 2 * a * b * ttmp;

    cout << fixed << setprecision(15) << sqrt(res) << endl;


}



Measured memory_bytes: 4092
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

const LL mod = 998244353;

int a[200005];
 int n;

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  scanf("%d", &n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", s ^ a[i]);
  }
  printf("\n");
 

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 4536
import sys

def solve(a, b):
    x = max(a, b)
    y = min(a, b)
    if x > y + 1:
        return 2 * x - 1
    else:
        return x + y

if __name__ == '__main__':

    a, b = sys.stdin.readline().strip().split(" ")
    ans = solve(int(a), int(b))
    print ans

Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int i,i2,m,qx,qy,X,Y,a[17][17],dp[17][17];
	cin>>X>>Y;
	while(X!=0||Y!=0){
		for(i=1;i<=Y;i++){
			for(i2=1;i2<=X;i2++){
				a[i2][i]=0;
				dp[i2][i]=0;
			}
		}
		dp[1][1]=1;
		cin>>m;
		for(i=1;i<=m;i++){
			cin>>qx>>qy;
			a[qx][qy]=1;
		}
		for(i=1;i<=Y;i++){
			for(i2=1;i2<=X;i2++){
				if(a[i2][i]==0){
					if(i2+1<=X&&a[i2+1][i]==0){
						dp[i2+1][i]+=dp[i2][i];
					}
					if(i+1<=Y&&a[i2][i+1]==0){
						dp[i2][i+1]+=dp[i2][i];
					}
				}
			}
		}
		/*for(i=1;i<=Y;i++){
			for(i2=1;i2<=X;i2++){
				cout<<dp[i2][i]<<' ';
			}
			cout<<endl;
		}*/
		cout<<dp[X][Y]<<endl;
		cin>>X>>Y;
	}
}

Measured memory_bytes: 2908
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    // 二次元累積和を利用：全体計算量 O(N^2 + Q)
    int N = Cin(), M = Cin(), Q = Cin();
    // 二次元累積和　O(N^2)
    vector<vector<int>> p(N + 1, vector<int>(N + 1, 0));
    for (int i = 1; i <= M; ++i)
    {
        int L = Cin(), R = Cin();
        ++p[L][R];
    }
    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= N; ++j)
        {
            p[i][j] += p[i][j - 1];
        }
    }
    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= N; ++j)
        {
            p[i][j] += p[i - 1][j];
        }
    }
    // クエリ O(Q)
    for (int i = 0; i < Q; ++i)
    {
        int L = Cin(), R = Cin();
        cout << p[R][R] - p[L - 1][R] - p[R][L - 1] + p[L - 1][L - 1] << endl;
    }
}


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

int main(int argc, const char * argv[]) {
    char S[4];
    cin >> S[0] >> S[1] >> S[2] >> S[3];
    
    int id = -1;
    for (int i = 1; i < 4; i++) {
        if (S[0] == S[i]){
            id = i;
            break;
        }
    }
    
    if (id == -1) {
        cout << "No" << endl;
        return 0;
    }
    
    int a[2];
    int j = 0;
    for (int i = 1; i < 4; i++) {
        if (id != i) {
            a[j] = i;
            j++;
        }
    }
    
    if ((S[a[0]] != S[a[1]]) ||
        (S[a[0]] == S[0])) {
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
def gcd2(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd2(b, a % b)


def gcd3(a, b, c):
    return gcd2(gcd2(a, b), c)


k = int(input())
sum = 0


for i in range(1, k + 1):
    sum += gcd3(i, i, i)

for i in range(1, k + 1):
    for j in range(1, k + 1):
        if i == j:
            continue
        else:
            sum += gcd3(i, i, j) * 3

for i in range(1, k + 1):
    for j in range(i + 1, k + 1):
        for l in range(j + 1, k + 1):
            sum += gcd3(i, j, l) * 6

print(sum)


Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int a, b, c, k;
	int num;
	cin >> a >> b >> c >> k;
	if(k <= a)
		num = k;
	else if(k <= a + b)
		num = a;
	else
		num = a - (k - a - b);

	cout << num;
		

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int h, w, d;
    cin >> h >> w >> d;
    char field[505][505];
    char buf[2][2];
    buf[0][0] = 'R';
    buf[0][1] = 'Y';
    buf[1][0] = 'G';
    buf[1][1] = 'B';
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            int MI = i + j;
            int MJ = i - j;
            MI = (MI + d) / d;
            MJ = (MJ + d * w) / d;
            field[i][j] = buf[MI % 2][MJ % 2];
            cout << field[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	k := nextInt()

	p := make([]float64, n)
	for i := 0; i < n; i++ {
		p[i] = ex(nextInt())
	}

	s := make([]float64, n + 1)
	s[0] = 0
	for i := 1; i <= n; i++ {
		s[i] = s[i - 1] + p[i - 1]
	}

	max := float64(0)
	t := make([]float64, n - k + 1)
	for i := 0; i < n - k + 1; i++ {
		t[i] = s[i + k] - s[i]
		if max < t[i] {
			max = t[i]
		}
	}

	fmt.Printf("%.12f", max)
}

func ex(x int) float64 {
	total := float64(0)
	for i := 1; i <= x; i++ {
		total += float64(i) / float64(x)
	}
	return total
}



Measured memory_bytes: 6144