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

int main(){
	
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	A *= 100;
	B *= 100;

	vector<int> mizu;
	for(int water_a=0; water_a<=F; water_a+=A)
		for(int water_b=0; water_b<=F; water_b+=B)
			if(0<water_a+water_b && water_a+water_b<=F) mizu.push_back(water_a+water_b);

	vector<int> satou;
	for(int sugar_c=0; sugar_c<=F; sugar_c+=C)
		for(int sugar_d=0; sugar_d<=F; sugar_d+=D)
			if(sugar_c+sugar_d <= F) satou.push_back(sugar_c+sugar_d);

	int ans_w=0, ans_s=0;
	double nodo=0.0;
	for(int w : mizu)
		for(int s : satou)
			if(w + s <= F && 100*s <= w*E && nodo <= (double)s/(double)w ) {
				nodo = (double)s/(double)w;
				ans_w = w;
				ans_s = s;
			}

	cout << ans_w + ans_s << " " << ans_s << endl;

}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int>v;
for(int i=1;i<=sqrt(n);i++){
    if(n%i==0){
        int a=i;
        int b=n/i;
        if(a>=1 and a<=9){
        if(b>=1 and b<=9){
        cout<<"Yes"<<endl;
        return 0;
        }
    }

}   
}
cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h;
  char c;
  scanf("%d %d %c",&w,&h,&c);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i==0||i==h-1){
	if(j==0||j==w-1) putchar('+');
	else putchar('-');
      } else if(j==0||j==w-1) putchar('|');
      else if(h/2==i&&w/2==j) putchar(c);
      else putchar('.');
    }
    putchar('\n');
  }
  return (0);
}



Measured memory_bytes: 3156
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w, :dp

  def initialize
    @n = gets.to_s.to_i
    @a = gets.to_s.split.map{ |v| v.to_i }
  end

  def solve
    ans = 0
    n.times do |i|
      ans += 1 if i.even? && a[i].odd?
    end
    ans
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14256
#!/usr/bin/env python3
import math

k = int(input())
ans = 0 
for a in range(1,k+1):
    for b in range(1,k+1):
        tmp = math.gcd(a, b)
        for c in range(1,k+1):
            ans += math.gcd(tmp, c)
print(ans)

Measured memory_bytes: 9184
N=int(input())
S=input()

D=[0]*1000

for i in range(1000):
    a=str(i//100)
    b=str((i//10)%10)
    c=str(i%10)
    f=0
    for j in S:
        if(f==2 and c==j):
            D[i]=1
            break
        elif(f==1 and b==j):
            f=2
        elif(f==0 and a==j):
            f=1
print(sum(D))



Measured memory_bytes: 41984
h,w,d = map(int,input().split())
px = [0]*(h*w+1)
py = [0]*(h*w+1)
for i in range(h):
    l = list(map(int,input().split()))
    for j in range(w):
        px[l[j]],py[l[j]] = i,j  

count =[0]*(h*w+1)
for i in range(d+1,h*w+1):
    count[i] = count[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d])

n = int(input())
for i in range(n):
    a,b = map(int,input().split())
    print(count[b]-count[a])

Measured memory_bytes: 9264
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = map(int, sys.stdin.readline().split())

    ret = 0
    cnt = N // (A + B)

    if N % (A + B) == 0:
        print(int(A * cnt))
    elif N < A + B:
        print(min(N, A))
    else:
        ret += A*cnt
        if N - (A+B)*cnt <= A:
            ret += N - (A+B)*cnt
        else:
            ret += A

        print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n,m=map(int,input().split())
A=list(map(int,input().split()))
weight=[0,2,5,5,4,5,6,3,7,6]
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
    for a in A:
        if i+weight[a]<=n:
            dp[i+weight[a]]=max(dp[i+weight[a]],dp[i]*10+a)
print(dp[n])
'''
    dic={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
    a=sorted(list(map(int,input().split())),key=lambda x:(dic[x],-x))
    b=[0]*10
    i=0
    while(n!=0):
        b[a[i]]+=1
        n-=dic[a[i]]
        if n<dic[a[i]] and n!=0:
            while(n<dic[a[i+1]]):
                b[a[i]]-=1
                n+=dic[a[i]]
            i+=1
    print(a)
    print(b)
'''

Measured memory_bytes: 14692
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
  cin>>s;
  int i,j,k,l,m=0;
  for(i=0;i<s.length();i+=2)
    if((s[i]=='L'||s[i+1]=='R'))
       m=1;
       if(m==0)
       cout<<"Yes";
       else
       cout<<"No";
       }
    

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import Data.Ord

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc :: Int -> [(Int, Int)] -> Int -> Int
calc n [] p = p
calc 0 _ p = p
calc n (m : ms) p
  | n >= fst m = calc (n `mod` (fst m)) ms (p + (n `div` (fst m)) * snd m)
  | otherwise = calc n ms p

main = do
  [q, h, s, d] <- getIntList
  n <- getInt
  let ms = [(1, q), (2, h), (4, s), (8, d)]
  let ms' = sortBy (comparing (\x -> (fromIntegral (snd x) / fromIntegral (fst x)))) ms
  print $ calc (4 * n) ms' 0


Measured memory_bytes: 3748
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    string s;
    scan(s);

    auto ok = new string[](0);

    void dfs(int i, string t) {
        if (i == 4) {
            ok ~= t;
            return;
        }

        if (i == 0) {
            dfs(i + 1, t ~ "AKIH");
            dfs(i + 1, t ~ "KIH");
        }
        else if (i == 1) {
            dfs(i + 1, t ~ "AB");
            dfs(i + 1, t ~ "B");
        }
        else if (i == 2) {
            dfs(i + 1, t ~ "AR");
            dfs(i + 1, t ~ "R");
        }
        else {
            dfs(i + 1, t ~ "A");
            dfs(i + 1, t);
        }
    }

    dfs(0, "");

    foreach (t ; ok) {
        if (s == t) {
            writeln("YES");
            return;
        }
    }

    writeln("NO");
}



struct UnionFind {
    private {
        int N;
        int[] p;
        int[] rank;
    }

    this (int n) {
        N = n;
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x) {
        if (p[x] != x) {
            p[x] = find_root(p[x]);
        }

        return p[x];
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        int u = find_root(x), v = find_root(y);

        if (u == v) return;

        if (rank[u] < rank[v]) {
            p[u] = v;
        }
        else {
            p[v] = u;

            if (rank[u] == rank[v]) {
                rank[u]++;
            }
        }
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



struct Queue(T) {
    private {
        int N, head, tail;
        T[] data;
    }

    this(int n) {
        N = n + 1;
        data = new T[](N);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return (tail + 1) % N == head;
    }

    T front() {
        return data[head];
    }

    void push(T x) {
        assert(!full);
        data[tail++] = x;
        tail %= N;
    }

    void pop() {
        assert(!empty);
        head = (head + 1) % N;
    }

    void clear() {
        head = tail = 0;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc140/tasks/abc140_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<int> A(N),B(N),C(N-1);
    for(auto& in:A) cin >> in;
    for(auto& in:B) cin >> in;
    for(auto& in:C) cin >> in;
    
    for(int i = 0; i < N-1;i++){
        if(A[i] +1 == A[i+1]) res += C[A[i]-1];
    }
    res += accumulate(B.begin(),B.end(),0);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int l = fs.nextInt();
		
		double one = ((double) l)/3;
		
		System.out.println(one * one * one);
		
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

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

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

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

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

}


Measured memory_bytes: 21204
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  [n] <- readInt
  let (a, b) = n `divMod` 15 in print $ n * 800 - a * 200


Measured memory_bytes: 380
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    reverse(a.begin(), a.end());
    rep(i,n) {
        cout<<a[i];
        if (i!=n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
n = int(input())
abc=[[0,0,0]]*n
dp = [[0]*n for _ in range(3)]

for i in range(n):
  abc[i] = list(map(int,input().split()))
  
for i in range(3):
  dp[i][0] = abc[0][i]

for i in range(1,n):
  for j in range(3):    
    for k in range(3):
      if j==k:
        pass
      else:
        dp[j][i] = max(dp[j][i], dp[k][i-1]+abc[i][j])
        
print(max([row[-1] for row in dp]))        

Measured memory_bytes: 58968
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
 string a;
  cin>>a;
  for(int i=0; i<a.size(); i++){
   if(a[i]=='?')a[i]='D'; 
  }
cout<<a<<endl;
}
 

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int H, W;
	static char[][] f;
	static int[][][] hole = new int[26][50][51];
	static boolean[][][][] reach;
	static int[][][][] dp;

	public static void main(String[] args) {
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0) break;
			f = new char[H][];
			for (int i = 0; i < H; ++i) {
				f[i] = sc.next().toCharArray();
				for (char j = 'A'; j <= 'Z'; ++j) {
					int pos = 0;
					for (int x = 0; x < W; ++x) {
						if (f[i][x] == j) hole[j - 'A'][i][pos++] = x;
					}
					hole[j - 'A'][i][pos] = 99;
				}
			}
			System.out.println(solve());
		}
	}

	static int solve() {
		reach = new boolean[H][W][H][W];
		dp = new int[H][W][H][W];
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				if (f[y][x] != '#') reach[y][x][y][x] = true;
			}
		}
		for (int h = 0; h < H; ++h) {
			for (int w = 0; w < W; ++w) {
				for (int y1 = 0; y1 < H - h; ++y1) {
					for (int x1 = 0; x1 < W - w; ++x1) {
						update(y1, x1, y1 + h, x1 + w);
					}
				}
			}
		}
		return reach[0][0][H - 1][W - 1] ? dp[0][0][H - 1][W - 1] : -1;
	}

	static void update(int y1, int x1, int y2, int x2) {
		char v1 = f[y1][x1];
		if (v1 == '#') return;
		char v2 = f[y2][x2];
		if (v2 == '#') return;
		if (!(y2 > 0 && reach[y1][x1][y2 - 1][x2] || x2 > 0 && reach[y1][x1][y2][x2 - 1])) return;
		reach[y1][x1][y2][x2] = true;
		if (y1 < y2) {
			dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1 + 1][x1][y2][x2]);
			dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1][x1][y2 - 1][x2]);
		}
		if (x1 < x2) {
			dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1][x1 + 1][y2][x2]);
			dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1][x1][y2][x2 - 1]);
		}
		if ('a' <= v1 && v1 <= 'z' && 'A' <= v2 && v2 <= 'Z') {
			if (v1 - 'a' == v2 - 'A') {
				if (y1 + 1 < y2 && reach[y1 + 1][x1][y2 - 1][x2]) {
					dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1 + 1][x1][y2 - 1][x2] + 1);
				}
				if (y1 < y2 && x1 < x2 && reach[y1 + 1][x1][y2][x2 - 1]) {
					dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1 + 1][x1][y2][x2 - 1] + 1);
				}
				if (y1 < y2 && x1 < x2 && reach[y1][x1 + 1][y2 - 1][x2]) {
					dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1][x1 + 1][y2 - 1][x2] + 1);
				}
				if (x1 + 1 < x2 && reach[y1][x1 + 1][y2][x2 - 1]) {
					dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1][x1 + 1][y2][x2 - 1] + 1);
				}
				if (y1 == y2 && x1 + 1 == x2 || y1 + 1 == y2 && x1 == x2) dp[y1][x1][y2][x2] = 1;
			}
			for (int y = y1; y <= y2; ++y) {
				for (int i = 0; hole[v1 - 'a'][y][i] <= x2; ++i) {
					int x = hole[v1 - 'a'][y][i];
					if (!reach[y1][x1][y][x]) continue;
					dp[y1][x1][y2][x2] = Math.max(dp[y1][x1][y2][x2], dp[y1][x1][y][x] + dp[y][x][y2][x2]);
				}
			}
		}
	}
}

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

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  bool flag = 0;
  rep(i, n) {
    cin >> p.at(i);
    if(p.at(i) == x)
      flag = 1;
  }
  if(flag == 0){
    cout << x << endl;
    return 0;
  }
  
  sort(p.begin(), p.end());
  bool flag2 = 0;
  int a = x;
  int b = x;
  while(flag2 == 0){
    if(find(p.begin(), p.end(), a) != p.end()){
      a--;
    }
    else{
      flag2 = 1;
    }
    if(find(p.begin(), p.end(), b) != p.end()){
      b++;
    }
    else{
      flag2 = 1;
    }
  }
  if(abs(x-a) <= abs(b-x))
    cout << a << endl;
  else 
    cout << b << endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main() {
	long long int N, M, C,cnt=0;
	cin >> N >> M >> C;
	vector<long long int> B(M);
	for (auto& i : B)cin >> i;
	for (long long int i = 0; i < N; i++) {
		vector<long long int>A(M);
		for (auto& j : A)cin >> j;
		long long int checker = C;
		for (long long int j = 0; j <M; j++) checker += A[j] * B[j];
		if(checker>0)cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline())
q = []
bottom = 0
for i in range(n):
    cmd = stdin.readline()[:-1]
    if cmd[0] == 'i':
        q.append(cmd[7:])
    elif cmd[6] == ' ':
        try:
            q.pop(~q[::-1].index(cmd[7:]))
        except:
            pass
    elif cmd[6] == 'F':
        q.pop()
    else:
        bottom += 1

print(' '.join(q[bottom:][::-1]))

Measured memory_bytes: 103484
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
typedef long long LL;
const LL MAX=1e17;
const LL N=2100;
struct qq
{
    LL x,y,z,z1,last;
}e[N*10];LL num,last[N];
void init (LL x,LL y,LL z,LL z1)
{
    num++;
    e[num].x=x;e[num].y=y;e[num].z=z;e[num].z1=z1;
    e[num].last=last[x];
    last[x]=num;
    swap(x,y);z=0;z1=-z1;
    num++;
    e[num].x=x;e[num].y=y;e[num].z=z;e[num].z1=z1;
    e[num].last=last[x];
    last[x]=num;
}
LL from[N];
LL f[N];
bool in[N];
LL st,ed;
bool SPFA ()
{
    for (LL u=1;u<=ed;u++) from[u]=-1,f[u]=-MAX,in[u]=false;
    queue<int> q;q.push(st);
    f[st]=0;in[st]=true;
    while (!q.empty())
    {
        LL x=q.front();q.pop();
        for (LL u=last[x];u!=-1;u=e[u].last)
        {
            LL y=e[u].y;
            if (e[u].z>0&&f[y]<f[x]+e[u].z1)
            {
                f[y]=f[x]+e[u].z1;
                from[y]=u;
                if (in[y]==false)
                {
                    in[y]=true;
                    q.push(y);
                }
            }
        }
        in[x]=false;
    }
    return from[ed]!=-1;
}
LL ans=0;
void lalal ()
{
	//printf("YES!\n");
    LL x=from[ed],t=MAX;
    while (x!=-1)	{t=min(t,e[x].z);x=from[e[x].x];}
    x=from[ed];
    while (x!=-1)	{ans=ans+t*e[x].z1;e[x].z-=t;e[x^1].z+=t;x=from[e[x].x];}
    return ;
}
int main()
{
	num=1;memset(last,-1,sizeof(last));
	LL n; 
	scanf("%lld",&n);st=2*n+10+1;ed=st+1;
	LL cnt=0;
	for (LL u=1;u<=n;u++)
	{
		LL x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		init(st,u,c,0);
		init(u,2*n+1,MAX,x+y);
		init(u,2*n+2,MAX,x-y);
		init(u,2*n+3,MAX,-x+y);
		init(u,2*n+4,MAX,-x-y);
	}
	for (LL u=1;u<=n;u++)
	{
		LL x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		init(u+n,ed,c,0);
		init(2*n+1+4,u+n,MAX,x+y);
		init(2*n+2+4,u+n,MAX,x-y);
		init(2*n+3+4,u+n,MAX,-x+y);
		init(2*n+4+4,u+n,MAX,-x-y);
	}
	init(2*n+1,2*n+4+4,MAX,0);
	init(2*n+2,2*n+3+4,MAX,0);
	init(2*n+3,2*n+2+4,MAX,0);
	init(2*n+4,2*n+1+4,MAX,0);
	while (SPFA()) lalal();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import math
import sys
x = int(input())
flg = 0

if x == 2:
  print(x)
  sys.exit()

for i in range(x,100005):
  flg = 0
  for j in range(2,int(math.sqrt(i))+1):
    if i%j == 0:
      flg = 1
    if flg == 0 and j == int(math.sqrt(i)):
      print(i)
      sys.exit()
    continue
      

Measured memory_bytes: 39664
#include <bits/stdc++.h>
        using namespace std;
         
        int main(){
          //int a,b,c;
          string a;
          cin >> a;
          //cin >> s;
          //if((a+b)%2==1)cout << 1 + (a+b)/2 << endl;
          //else cout << (a+b)/2 << endl;
          sort(a.begin(),a.end());
          if(a=="abc") cout << "Yes" << endl;
          else cout << "No" << endl;
          return 0;
        }

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    string S, T; 
    cin>>S>>T;
    string ans = "No";
    for(char c = 'a'; c <= 'z'; c++){
        string st = S + c;
        if(st == T) ans = "Yes";
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    int n,m,q,i;
    cin>>n>>m>>q;
    int x,y,r[n]={0},c[m]={0},mr=0,mc=0;
    vi v[n];
    fr(i,q)
    {
        cin>>x>>y;
        x--;
        y--;
        r[x]++;
        c[y]++;
        mr=max(mr,r[x]);
        mc=max(mc,c[y]);
        v[x].pb(y);
    }
    int vis[m]={0},co=0,cc;
    fr(i,m)
    {
        if(c[i]==mc)
        {
            co++;
            vis[i]=1;
        }
    }
    int j,ans=mc+mr;
    fr(i,n)
    {
        if(r[i]==mr)
        {
            cc=0;
            fr(j,sz(v[i]))
            {
                if(vis[v[i][j]])
                    cc++;
            }
            if(cc!=co)
            {
                cout<<ans;
                return;
            }
        }
    }
    cout<<ans-1;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 27004
#include <iostream>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)

const int MAX_N = 1000009;
const long long mod = 998244353;
long long val[MAX_N + 9], cnt[MAX_N + 9];
long long N, A[MAX_N + 9], P1[MAX_N + 9], P2[MAX_N + 9];

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 30; i++) {
		if ((b & (1LL << i)) != 0) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

void init() {
	val[1] = 1;
	for (int i = 2; i <= MAX_N; i++) val[i] = Div(1, i, mod);
	for (int i = 1; i <= MAX_N; i++) {
		for (int j = i * 2; j <= MAX_N; j += i) {
			val[j] -= val[i];
			if (val[j] < 0) val[j] += mod;
		}
	}
}

int main() {
	init();
	scanf("%lld", &N);
	for (int i = 0; i < N; i++) { scanf("%lld", &A[i]); cnt[A[i]]++; }
	for (int i = 1; i <= MAX_N; i++) {
		for (int j = i; j <= MAX_N; j += i) {
			P1[i] += 1LL * j * cnt[j];
			P2[i] += 1LL * j * j * cnt[j];
		}
	}
	for (int i = 1; i <= MAX_N; i++) { P1[i] %= mod; P2[i] %= mod; }

	long long ans = 0;
	for (int i = 1; i <= MAX_N; i++) {
		long long V = (P1[i] * P1[i] - P2[i] + mod * mod) % mod;
		if (V % 2 == 1) V += mod; V /= 2;
		ans += (V * val[i]);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35200
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <utility>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int X, A;
	
	cin >> X >> A;
	
	if(X < A)
		cout << 0; 
	else 
		cout << 10;
	
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    loop {
        let n: usize = read();
        let k: usize = read();
        if n == 0 && k == 0 {
            break;
        }
        let a: Vec<i64> = (0..n).map(|_| read()).collect();
        let mut s: Vec<i64> = vec![0; n + 1];

        //累積和 前処理
        for i in 0..n {
            s[i + 1] = s[i] + a[i];
        }

        //答えを求める
        let mut max = std::i64::MIN;
        for i in 0..n + 1 - k {
            max = std::cmp::max(s[i + k] - s[i], max);
        }

        println!("{}", max);
    }
}



Measured memory_bytes: 7092
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		int count = 0;
		
		if(a.substring(0,1).equals("1")) {
			count++;
		}
		
		if(a.substring(1,2).equals("1")) {
			count++;
		}
		
		if(a.substring(2,3).equals("1")) {
			count++;
		}
		
		System.out.println(count);
		
		
		sc.close();
	}
}


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

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return 1;
    }
    return 0;
}

long long dp[100110];
long long h[100110];

long long INF = 1ll<<60;

int main(void){
    int n, k;
    std::cin >> n >> k;

    for(int i = 0; i < n; i++){
        std::cin >> h[i];
    }

    for(int i = 0; i < 100110; i++){
        dp[i] = INF;
    }

    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            chmin(dp[i+j], dp[i] + std::abs(h[i] - h[i+j]));
        }
    }

    std::cout << dp[n-1] << std::endl;
    return 0;

}


Measured memory_bytes: 1792
#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 n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }

    int maxv = h[n-1];
    for (int i = n-2; i >= 0; i--)
    {
        if (h[i]-1 > maxv) {
            cout << "No" << endl;
            return 0;
        }
        maxv = min(maxv, h[i]);
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

char s[200];

int main() {
	cin >> s;
	int N;
	N = strlen(s);
	int maru = 0;
	for(int i=0;i<N;i++){
		maru += (s[i] == 'o');
	}
	maru += 15 - N;
	if(maru >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+7;
int dp[maxn][2],n;
char s[maxn];
void Max(int &x,int y){if (y>x) x=y;}
int main(){
    scanf("%s",s+1); n=strlen(s+1);
    memset(dp,-1,sizeof(dp));
    dp[1][0]=dp[2][1]=1;
    for (int i=1;i<n;i++)
    for (int j=0;j<2;j++) if (dp[i][j]!=-1){
        if (j==0){
            Max(dp[i+2][1],dp[i][j]+1);
            if (s[i]!=s[i+1]) Max(dp[i+1][0],dp[i][j]+1);
        } else {
            Max(dp[i+1][0],dp[i][j]+1);
            if (s[i]!=s[i+2]||s[i-1]!=s[i+1]) Max(dp[i+2][1],dp[i][j]+1);
        }
    }
    cout << max(dp[n][0],dp[n][1]) << endl;
    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  string s[10];
  cin >> s[0] >> s[1];

  if(s[0][0] == s[1][2] and s[0][2] == s[1][0]){
    if(s[0][1] == s[1][1]) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=A[0]
a,b=0,0
g=0
for i in range(1,N):
    if A[i]==t:
        a=t
        g=i
        break
    else:
        t=A[i]
t=A[g+1]
if a!=0:
    for i in range(g+2,N):
        if t==A[i]:
            b=t
            break
        else:
            t=A[i]
print(a*b)

Measured memory_bytes: 62704
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(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;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ld kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n>>k;
    cout<<(ld)n/k;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
C = [int(input()) for _ in range(N)]

mod = 10 ** 9 + 7

D = []
prev = -1
for ci in C:
    if prev != ci:
        D.append(ci)
        prev = ci

M = len(D)

dic = dict()
dp = [1] * M
for i in range(M):
    if D[i] in dic:
        temp = dp[dic[D[i]]]
        dp[i] = (dp[i - 1] + temp) % mod
    else:
        dp[i] = dp[i - 1]
    dic[D[i]] = i

print(dp[-1] % mod)



Measured memory_bytes: 38088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadInts();
            var b = ReadInts();
            if (a.Sum() < b.Sum())
            {
                WriteLine(b.Sum());
            }
            else
            {
                WriteLine(a.Sum());
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/02  Problem: 013_agc_b / Link: https://agc013.contest.atcoder.jp/tasks/agc013_b?lang=en  ----- */
/* ------問題------

N 頂点 M 辺の、連結な単純無向グラフが与えられます。 頂点には 1 から N までの番号がついており、辺には 1 から M までの番号がついています。 辺 i は、頂点 Ai と頂点 Bi を結んでいます。 次の条件を満たすパスを 1 つ見つけて、出力してください。
2 個以上の頂点を通る
同じ頂点を 2 度以上通らない
パスの少なくとも一方の端点と直接辺で結ばれている頂点は、必ずパスに含まれる
ただし、この問題の制約の下で、このようなパスが必ず存在することが証明できます。 また、あり得る答えのうちどれを出力しても構いません。

-----問題ここまで----- */
/* -----解説等-----

昔は次数で場合分けしていたけどその必要はない。
適当に頂点Pを選択し、これからpathをひとつ作成する。
作成後はPでない端の点は条件を満たしている。
一方Pは条件を満たしているかはわからないのでもう一回pathを作れば良い。

次数1だともっと見通しが良い気はする。

----解説ここまで---- */

LL N, M;

LL ans = 0LL;
void dfs(int v, VI& path, VI& visit, VVI& G) {
	visit[v] = 1;
	path.push_back(v);
	FOR(i, 0, SZ(G[v])) {
		int nx = G[v][i];
		if (!visit[nx]) {
			dfs(nx, path, visit, G);
			break;
		}
	}
}

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

	cin >> N >> M;
	VVI G(N);
	FOR(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	VI path;

	VI visit(N,0);
	dfs(0, path, visit, G);
	VI path2;
	dfs(0, path2, visit, G);
	cout << SZ(path) + SZ(path2) -1<< endl;
	reverse(ALL(path2));
	FOR(i, 0, SZ(path2)-1) {
		cout << path2[i] + 1 << " ";
	}
	FOR(i, 0, SZ(path)) {
		cout << path[i] + 1<< " ";
	}
	cout << "\n";

	return 0;
}


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

import itertools
import math

n = int(input())

ab = [list(map(int, input().split())) for i in range(n)]


sum_dis = 0
for i, j in itertools.combinations(range(n), 2):
    x1, y1 = ab[i]
    x2, y2 = ab[j]
    sum_dis += ((x1-x2)**2+(y1-y2)**2)**0.5

sum_dis /= n*(n-1)/2

print(sum_dis*(n-1))


Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int junban[n];
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        junban[a-1] = i;
    }
    for (int i=0; i<n; i++) {
        cout << junban[i]+1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).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; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef pair <ll,int> PLL;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t; cin >> n >> m >> s >> t; s--; t--;
    vector<vector<P> > graph_a(n), graph_b(n);
    rep (i, m) {
        int u, v, a, b; cin >> u >> v >> a >> b; u--; v--;
        graph_a[u].emplace_back(v, a);
        graph_a[v].emplace_back(u, a);
        graph_b[u].emplace_back(v, b);
        graph_b[v].emplace_back(u, b);
    }
    vector<ll> d_a(n), d_b(n);
    vector<bool> used_a(n), used_b(n);
    priority_queue<PLL, vector<PLL>, greater<PLL> > que;
    used_a[s] = true; que.emplace(0, s);
    rep (i, n) d_a[i] = (ll)1e18; d_a[s] = 0;
    while (!que.empty()) {
        PLL p = que.top(); que.pop(); // dist, i
        if (d_a[p.second] < p.first) continue;
        for (auto q : graph_a[p.second]) { // v, dist
            if (chmin(d_a[q.first], d_a[p.second] + q.second)) {
                que.emplace(d_a[q.first], q.first);
            }
        }
    }
    rep (i, n) eprintf("%lld ", d_a[i]); eprintf("\n");
    used_b[t] = true; que.emplace(0, t);
    rep (i, n) d_b[i] = (ll)1e18; d_b[t] = 0;
    while (!que.empty()) {
        PLL p = que.top(); que.pop(); // dist, i
        if (d_b[p.second] < p.first) continue;
        for (auto q : graph_b[p.second]) { // v, dist
            if (chmin(d_b[q.first], d_b[p.second] + q.second)) {
                que.emplace(d_b[q.first], q.first);
            }
        }
    }
    rep (i, n) eprintf("%lld ", d_b[i]); eprintf("\n");
    vector<ll> ans(n);
    rep (i, n) ans[i] = d_a[i] + d_b[i];
    reprev (i, n - 1) chmin(ans[i], ans[i + 1]);
    rep (i, n) cout << (ll)1e15 - ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 16756
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int a, b, cnt = 0;
    cin >> a >> b;

    for(int i = a; i <= b; i++){
        string s = "";
        int c = i;
        while(c != 0){
            s += c%10 + '0';
            c /= 10;
        }
        string t = s;
        reverse(s.begin(), s.end());
        if(s == t) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  cout<<"ABC"<<s<<endl;
}


Measured memory_bytes: 3576
n = gets.to_i
l = gets.split.map(&:to_i).sort
count = 0
#p l 

(0..n-2).each { |a| # short
  (a+1..n).each { |b| # short
    (b+1..n).each { |c| # long
      #      puts "a:#{a} la:#{l[a]} b:#{b} lb:#{l[b]} c:#{c} lc:#{l[c]}"
      next if (l[a].nil? || l[b].nil? || l[c].nil? )
      next if l[a] == l[b] || l[a] == l[c] || l[b]  == l[c] 
      #count+= 1 if ( (l[b] - l[c]).abs < l[a] ) && ( l[a] < l[b] + l[c] )
      count+= 1 if l[c] < l[a] + l[b]
      #      puts "GOT!!!"
    }
  }
}

puts count


Measured memory_bytes: 14420
#include <stdio.h>

void dump(int *A, int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		printf("%d", A[i]);
		if (i < n - 1) printf(" ");
	}
	printf("\n");
}

int main()
{
	int A[100];
	int n, i, j, v;

	scanf("%d", &n);

	for (i = 0; i < n; i++) scanf("%d", &A[i]);
	dump(A, n);

	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;
		dump(A, n);
	}
	
	return 0;

}

Measured memory_bytes: 1808
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

ll i, j, q;
ll n, m, p, k, t, f, s, v, h;
ll a, b, c, d;
ll x, y, z, w, l, r;
ll one = 1, zero = 0, ans = 0, cnt = 0;
ll mod = 1000000007;
ll INF = 9223372036854775807;
ll a1, a2, a3 = 0 , a4, a5, a6, a7, a8;
string st1, st2, st3, st4;
char ch1, ch2, ch3;

int main() {
	IO;
	ifstream fin("Text.txt");
	
	vector<vector<ll> > mp1(100001,vector<ll>(2)), mp2(100001,vector<ll>(2));
	cin >> n;
	f0(i, n) {
		cin >> a;
		if (i & 1) {
			mp1[a][0]++;
			mp1[a][1] = a;
		}
		else {
			mp2[a][0]++;
			mp2[a][1] = a;
		}
	}
	sort(mp1.rbegin(), mp1.rend());

	sort(mp2.rbegin(), mp2.rend());

	if (mp1[0][1] == mp2[0][1]) {
		if (mp1[0][0] + mp2[1][0] > mp1[1][0] + mp2[0][0])
			cout << n - mp1[0][0] - mp2[1][0] << endl;
		else
			cout << n - mp1[1][0] - mp2[0][0] << endl;
	}
	else {
		cout << n - mp1[0][0] - mp2[0][0] << endl;
	}

	return 0;
}

Measured memory_bytes: 11264
// Anve$hi $hukla
#include <bits/stdc++.h>
using namespace std;
struct ${$(){ios_base::sync_with_stdio(false);cin.tie(NULL);}}$;

typedef long long LL;
const long long Mod = 1e9 + 7;

int main() {
    long long x, a, b;
    cin >> x >> a >> b;
    if(a >= b) {
        cout << "delicious" << endl;
        return 0;
    } else  if(b - a <= x) {
        cout << "safe" << endl;
    } else 
    cout << "dangerous" << endl;
    return 0;
}


Measured memory_bytes: 256
//	-*- mode: C++ -*-
//	Print a Frame
//		Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.
//
//		##########
//		#........#
//		#........#
//		#........#
//		#........#
//		##########
//	Input
//		The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.
//
//		The input ends with two 0 (when both H and W are zero).
//
//	Output
//		For each dataset, print the frame made of '#' and '.'.
//
//		Print a blank line after each dataset.
//
//	Constraints
//		3 ≤ H, W ≤ 300
//
//	Sample Input
//		3 4
//		5 6
//		3 3
//		0 0
//	Sample Output
//		####
//		#..#
//		####
//
//		######
//		#....#
//		#....#
//		#....#
//		######
//
//		###
//		#.#
//		###

#include <iostream>
#include <vector>

int	main(int	argc,
		 char*	argv[])
{
	unsigned int	h	{0};
	unsigned int	w	{0};
	std::vector<std::pair<unsigned int, unsigned int> >	v	{};

	for(;;){
		std::cin >> h >> w;

		if((h == 0) && (w == 0)){
			break;
		}

		v.push_back(std::make_pair(h, w));
	}

	for(std::pair<unsigned int, unsigned int> p : v){
		for(unsigned int i = 0; i < p.first; i++){
			for(unsigned int j = 0; j < p.second; j++){
				if((i == 0) || (j == 0) || (i == p.first - 1) || (j == p.second - 1)){
					std::cout << '#';
				}
				else{
					std::cout << '.';
				}
			}
			std::cout << '\n';
		}
		std::cout << '\n';
	}
}



Measured memory_bytes: 3028