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

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const double EPS=1e-6;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) a.rbegin(),a.rend()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) FLL(a,0)
#define declare(a,it) __typeof(a) it=(a)
#define FOR(it,a) for(declare(a.begin(),it);it!=a.end();++it)
#define FORR(it,a) for(declare(a.rbegin(),it);it!=a.rend();++it)
template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
int s2i(string& a){stringstream ss(a);int r;ss>>r;return r;}
int geti(){int n;scanf("%d", &n);return n;}

char col[10][10];
int h[16],w[16];

vector<PI> ma;
int memo[1<<16];

int rec(int st){
  if(st == (1<<16)-1) return 0;
  if(memo[st] >= 0) return memo[st];
  //cout << st << endl;
  int& ret = memo[st] = 1000000;
  for(int i = 0; i < (int)ma.size(); ++i){
    int nst = (st & ~ma[i].first) | ma[i].second;
    ret = min(ret, rec(nst) + 1);
  }
  return ret;
}

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> h[i] >> w[i];
  }

  for(int i = 0; i < 4; ++i)
    for(int j = 0; j < 4; ++j)
      cin >> col[i][j];

  vector<pair<PI, PI> > box;
  for(int lx = -3; lx < 4; ++lx)
    for(int ty = -3; ty < 4; ++ty)
      for(int i = 0; i < n; ++i){
        if(lx+h[i]>0 && ty+w[i]>0)
          box.push_back({{max(lx,0),max(0,ty)},
                {min(lx+h[i],4),min(ty+w[i],4)}});
      }
  sort(box.begin(), box.end());
  box.erase(unique(box.begin(), box.end()), box.end());
  //cout << "h" << endl;
  
  for(int i = 0; i < (int)box.size(); ++i){
    int lx = box[i].first.first;
    int ly = box[i].first.second;
    int ux = box[i].second.first;
    int uy = box[i].second.second;
    int mask = 0;
    int rr = 0;
    int gg = 0;
    int bb = 0;
    for(int cx = lx; cx < ux; ++cx)
      for(int cy = ly; cy < uy; ++cy){
        mask |= 1 << (cx*4 + cy);
        (col[cx][cy]=='R'?rr:
         col[cx][cy]=='G'?gg:
         bb) |= 1 << (cx*4 + cy);
      }
    ma.push_back({mask,rr});
    ma.push_back({mask,gg});
    ma.push_back({mask,bb});
  }
  //cout << "h" << endl;

  queue<int> q;
  q.push(0);
  for(int cc = 0;!q.empty();++cc){
    queue<int> nq;
    while(!q.empty()){
      int cv = q.front();
      q.pop();
      if(memo[cv]) continue;
      memo[cv] = 1;
      if(cv == (1<<16) - 1){
        cout << cc << endl;
        return 0;
      }
      for(int i = 0; i < (int)ma.size(); ++i){
        int nv = (cv & ~ma[i].first) | ma[i].second;
        if(!memo[nv])
          nq.push(nv);
      }
    }
    q.swap(nq);
  }
  
  memset(memo, -1, sizeof(memo));  
  cout << rec(0) << endl;
  
  return 0;
}

Measured memory_bytes: 9096
#include<cstdio>

int f[50];
long long n;
int res = 0;

int main() {
  for (int i = 1; i < 10; i++) {
    f[i * (i + 1) / 2] = i;
  }
  for (int i = 1; i < 50; i++) {
    if (f[i] < f[i - 1]) {
      f[i] = f[i - 1];
    }
  }
  scanf("%lld", &n);
  for (int i = 2; 1ll * i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      res += f[cnt];
    }
  }
  if (n != 1) {
    res += f[1];
  }
  printf("%d\n", res);
}


Measured memory_bytes: 1736
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]

c = 0
ans = False
for i in d:
    if i[0] == i[1]:

        c += 1
        if c >=3:
            ans = True
            break
    else:
        c = 0
if ans:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 9188
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()
	x, n := io.ScanInt2()
	p := io.ScanInts(n)
	if n == 0 {
		fmt.Println(x)
		return
	}

	sort.Ints(p)

	existNumMap := map[int]bool{}
	for _, v := range p {
		existNumMap[v] = true
	}

	var unExistNums []int
	for i := -1; i <= 101; i++ {
		if !existNumMap[i] {
			unExistNums = append(unExistNums, i)
		}
	}

	curDiff := 102
	var curNum int
	for _, v := range unExistNums {
		diff := AbsDiff(x, v)
		if diff >= curDiff {
			fmt.Println(curNum)
			return
		}
		if diff < curDiff {
			curDiff = diff
			curNum = v
		}
	}
	fmt.Println(curNum)
}

func AbsDiff(n1 int, n2 int) int {
	return int(math.Abs(float64(n1 - n2)))
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2200
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int answer = (x-z) / (y+z);
        System.out.println(answer);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<double,double> P;
typedef pair<double,P> PP;
int main(){
	while(true){
		int N;
		double pw;
		cin>>N;
		if(N==0) break;
		cin>>pw;
		double ans=1e9,ad=0;
		double a=0,c=0;
		vector<PP> vc;
		rep(i,N){
			double vw,pf,vf,th;
			cin>>vw>>pf>>vf>>th;
			if(vw==0) ad+=max(0.0,th/vf*pf);
			else{
				vc.pb(PP(th/vw,P(-vw/vf*pf,th/vf*pf)));
				if(vw>0) a+=-vw/vf*pf,c+=th/vf*pf;
			}
		}
		vc.pb(PP(0,P(0,0)));
		sort(all(vc));
		for(PP pp:vc){
			double w=pp.fs,x=pp.sc.fs,y=pp.sc.sc;
			if(x>0) a+=x,c+=y;
			else a-=x,c-=y;
			if(w>=0) chmin(ans,a*w+c+w*pw);
//			show(w);
//			show(a);
//			show(c);
		}
		printf("%.12f\n",ans+ad);
	}
}

Measured memory_bytes: 7096
import sys


def print_(ans):
    print(ans)
    sys.exit()


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split(' ')))
    if n == 0:
        if a[0] == 1:
            print_(1)
        else:
            print_(-1)
    if a[0] != 0:
        print_(-1)
    max_rest = [0 for _ in range(n + 1)]
    max_rest[0] = 1 - a[0]
    for i in range(1, n + 1):
        max_rest[i] = max_rest[i - 1] * 2 - a[i]
    for i in range(n + 1):
        if max_rest[i] < 0:
            print_(-1)
    rest = [0 for _ in range(n + 1)]
    for i in range(n - 1, -1, -1):
        req_rest = (a[i + 1] + rest[i + 1] + 1) // 2
        if max_rest[i] < req_rest:
            print_(-1)
        rest[i] = min(max_rest[i], a[i + 1] + rest[i + 1])
    ans = sum(a) + sum(rest)
    print_(ans)


Measured memory_bytes: 674104
#include <iostream>

using namespace std;

int main()
{
  int v[1001];
  v[1]=1;

  for(int i=2;i<1000;i++)v[i]=v[i-1]+i;

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

  int ans = v[b-a]-b;
  cout << ans << endl;

  return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    cout << (n + 1) / 2;
    return 0;
}


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

int n;

int scs(int n){
	int Count=0;
	while(n>0){
		n/=10;
		Count++;
	}
	return Count;
}

int main(){
	cin >> n;
	bool check=false;
	for(int i=1; i<=9; i++)
		if (n%i==0 && scs(n/i)==1) check=true;
	
	if (check) cout<<"Yes";
	else cout<<"No";
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

bool solve() {
	int N; cin >> N;
	if (N == 0) return (false);
	vvint cnt(30);
	vector<set<int>> st(N);
	
	for (int i = 0; i < N; i++) st[i].insert(i);

	for (int i = 0; i < N; i++) {
		int F; cin >> F;
		for (int j = 0; j < F; j++) {
			int d; cin >> d; --d;
			cnt[d].push_back(i);
		}
	}
	
	if (st[0].size() == N) { cout << 0 << endl; return (true); }
		
	for (int day = 0; day < 30; day++) {
		for (int i = 0; i < cnt[day].size(); i++) {
			for (int j = 0; j < cnt[day].size(); j++) {
				int a = cnt[day][i], b = cnt[day][j];
				for (auto &v : st[b]) st[a].insert(v);
			}
		}
		for (int i = 0; i < N; i++) {
			if (st[i].size() == N) {
				cout << day+1 << endl;
				return (true);
			}
		}
	}
	cout << -1 << endl;
	return (true);
}

void Main() {
	while (solve());
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}



Measured memory_bytes: 3144
import java.util.*;
class Main{
 public static void main(String arg[])
 {
  Scanner sc=new Scanner(System.in);
   int a=sc.nextInt();
   int b=sc.nextInt();
   int c=sc.nextInt();
   if(b>c && a<c)
   {
     System.out.println("Yes");
   }
   else if(a>c && b<c)
   {
     System.out.println("Yes");
   }
   else
     System.out.println("No");
 
 }
}

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

string my_readln() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto tokens = my_readln.split;
	auto D = tokens[0].to!long;
	auto G = tokens[1].to!long;

	ulong[] p, c;
	foreach (i; 0..D)
	{
		auto tokens2 = my_readln.split;
		p ~= tokens2[0].to!ulong;
		c ~= tokens2[1].to!ulong;
	}

	long f(ulong[] used, long score, long cnt)
	{
		if (score <= 0) return cnt;
		
		long r = long.max;
		foreach (i, e; used)
		{
			if (e == 1) continue;

			auto x = score / ((i + 1) * 100) + (score % ((i + 1) * 100) == 0 ? 0 : 1);
			if (x <= p[i])
			{
				r = min(r, cnt + x);
			}
			else
			{
				auto nUsed = used.dup;
				nUsed[i] = 1;
				r = min(r, f(nUsed, score - ((i + 1) * 100 * p[i] + c[i]), cnt + p[i]));
			}
		}
		
		return r;
	}

	writeln(f(new ulong[](D), G, 0));
	stdout.flush();
}

Measured memory_bytes: 1276
X,K,D = list(map(int,input().split()))

if abs(X) >= K * D:
  print(abs(X) - K*D)
else:
  plus_times = abs(X)//D
  left_times = K - plus_times
  plus_min = abs(X) - (plus_times * D)
  minus_max = plus_min - D
  #print(left_times)
  #print(plus_min,minus_max)

  if left_times % 2 == 0:
    print(abs(plus_min))
  else:
    print(abs(minus_max))

Measured memory_bytes: 61852
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll N; cin >> N;
    ll d[N]; REP(i, N) cin >> d[i];

    ll ans = 0;
    REP(i, N) {
        REP(j, N) {
            if (i<=j) continue;
            ans += d[i] * d[j];
        }
    }

    cout << ans << '\n';


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
void solve()
{
	string s;
	cin>>s;
	map<string,ll> day;
	day["SUN"]=0;
	day["MON"]=1;
	day["TUE"]=2;
	day["WED"]=3;
	day["THU"]=4;
	day["FRI"]=5;
	day["SAT"]=6;
	ll rem=7-day[s];
	cout<<rem<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



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

int n, MAX = 100000, k;
int h[101000], dp[101000];

int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
		dp[i] = 1e9 + 7;
	}
	dp[1] = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			dp[i + j] = min(abs(h[i] - h[i + j]) + dp[i], dp[i + j]);
		}
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1024
main::IO()
main = do
    _ <- getLine
    s <- words <$> getLine
    let x = map read s :: [Int]
    print $ minimum $ fnc x 1
    
fnc :: [Int] -> Int -> [Int]
fnc _ 101 = []
fnc x p = [sum $map ((^2) . (+(-p))) x] ++ fnc x (p+1)

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

	int main(){
      string S;
      cin >>S;
      int A,Z;
      for (int i;i<S.size();i++){
        if (S[i]=='A'){
          A=i;
          break;
        }
      }
      for (int i=S.size()-1;i>=0;i--){
        if (S[i]=='Z'){
          Z=i;
          break;
        }
      }
      cout << Z-A+1;
    }


Measured memory_bytes: 640
// AOJ 2618: Trip to Kyoto
// 2018.1.25 bal4u@uu

#include <stdio.h>

#define MIN(a,b)  ((a)<=(b)?(a):(b))

int x1[10002], y1[10002], x2[10002], y2[10002];
char *msg[2] = { "%d\n", "%d.5\n" };

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(int x1, int y1, int x2, int y2)
{
	int dx, dy;

	x1 += 200000000, x2 += 200000000;
	y1 += 200000000, y2 += 200000000;
	dx = x1-x2; if (dx < 0) dx = -dx;
	dy = y1-y2; if (dy < 0) dy = -dy;
	if (!(x1%20 | x2%20)) {
		if (x1 == x2) return dy;
		else if (y1/20 == y2/20) return dx + MIN(y1%20+y2%20, 40-y1%20-y2%20);
	} else if (!(y1%20 | y2%20)) {
		if (y1 == y2) return dx;
		else if (x1/20 == x2/20) return dy + MIN(x1%20+x2%20, 40-x1%20-x2%20);
	}
	return dx+dy;
}

int main()
{
	int n, x, y, i, j, k, s, t, ans;
	int xmin, xmax, ymin, ymax;
	int x0, y0;

	n = in();
	x = in() << 1, y = in() << 1;
	x1[0] = x, y1[0] = y, xmin = xmax = x2[0] = x+y, ymin = ymax = y2[0] = x-y;
	for (i = 1; i < n; i++) {
		x = in() << 1, y = in() << 1;
		x1[i] = x,   y1[i] = y;
		x2[i] = x+y, y2[i] = x-y;
		if      (x2[i] < xmin) xmin = x2[i];
		else if (x2[i] > xmax) xmax = x2[i];
		if      (y2[i] < ymin) ymin = y2[i];
		else if (y2[i] > ymax) ymax = y2[i];
	}
 
	x = (xmin + xmax) >> 1, y = (ymin + ymax) >> 1;
	x0 = (x + y) >> 1, y0 = (x - y) >> 1;

	ans = 0x7fffffff;
	for (i = x0-20; i <= x0+20; i++)for (j = y0-20; j <= y0+20; j++) {
		if (i%20 && j%20) continue;
		t = 0; for (k = 0; k < n; k++) if (t < (s = calc(i, j, x1[k], y1[k]))) t = s;
		if (ans > t) ans = t;
	}
	printf(msg[ans & 1], ans >> 1);
	return 0;
}


Measured memory_bytes: 2080
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<bool> ac(N, false);
    ll p_i;
    vector<ll> penalty_cnt(N, 0);
    string s_i;
    for (int i = 0; i < M; i++) {
        cin >> p_i >> s_i;
        p_i--;
        if (s_i == "AC") {
            ac[p_i] = true;
        } else {
            if (ac[p_i]) {
                continue; // no penalty
            } else {
                penalty_cnt[p_i]++;
            }
        }
    }
    ll ac_cnt = 0;
    ll p_cnt = 0;
    for (int i = 0; i < N; i++) {
        if (ac[i]) {
            ac_cnt++;
            p_cnt += penalty_cnt[i];
        }
    }
    cout << ac_cnt << " " << p_cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;



ll pow5(ll n){
    return n*n*n*n*n;
}

int main(){
    IOS
    //freopen("output.txt","w",stdout);


    ll x;
    cin>>x;

    unordered_map<ll,ll>mp;
    ll prev;
    for(ll i =0;i<=10000;i++){
        ll cur = pow5(i);
        if(i>0){
            if(cur<prev)break;

        }

        mp[cur]=i;
        mp[-cur]=-i;
        prev = cur;
    }

    for(ll i=0;i<1000;i++){
        ll a = pow5(i);
        a-=x;
        if(mp[a]==0 && a!=0)continue;
        else {
            cout<<i<<" "<<mp[a]<<"\n";
            break;
        }
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    map<ll, ll> M;
    REP(i, N){
        ll a;
        cin >> a;
        M[min(8LL,a/400)]++;
    }

    ll ans = 0;
    for(ll i=0; i<=7; i++){
        ans += min(1LL, M[i]);
    }

    cout << max(ans,1LL) << " " << ans+M[8] << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b;
  cin >> a >> b;
  int ans = a*b - (a+b-1);
  cout << ans << endl;
}






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

int main(){
  string S;
  cin >> S;
  
  
  if(S.at(0) == S.at(1)){
    cout << "Bad" << endl;
  }
  else if(S.at(2) == S.at(1)){
    cout << "Bad" << endl;
  }
  else if(S.at(2) == S.at(3)){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}

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

using namespace std;

#define ll long long

void solve() {
	int a, b;
	cin >> a >> b;
	cout << (a > b ? a-b : 0) << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3612
from copy import copy
d = int(input())
c = [0] + list(map(int, input().split(' ')))

s = [[]] + [[0] + list(map(int, input().split(' '))) for _ in range(d)]

t = 0 # 算出結果

ca = [0] * (1 + 26) # 放置された不満の数々
cat = [] # 不満度の最適な算出のための一時配列
cat2 = []

for i in range(1, d + 1):
    cat = [0]
    for i2 in range(1, 27):
        cat2 = copy(ca)
        cat2[i2] = i
        cat.append(s[i][i2] + sum(c[i3] * (i - ca[i3]) for i3 in range(1, 27)))
    t = cat.index(max(cat))
    ca[t] = i
    print(t)

Measured memory_bytes: 9544
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL inf = 11234567890;
LL N, K;
std::vector<LL>h, memo;

LL dp(LL i)
{
	if (i == N - 1) return 0;
	if (memo[i] != -1) return memo[i];
	LL res = inf;
	for (LL j = i + 1; j <= std::min(i + K, N - 1); ++j) res = std::min(res, dp(j) + std::abs(h[i] - h[j]));
	return memo[i] = res;
}

int main()
{
	in >> N >> K;
	h.resize(N);
	rep(i, N) in >> h[i];

	memo.resize(N, -1);
	out << dp(0) << std::endl;
}


Measured memory_bytes: 6528
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while (true) {
			int H = sc.nextInt(),W= sc.nextInt();
			if (H==0 && W==0) {
				break;
			}
			for(int h=0;h<H;h++){
				for(int w=0;w<W;w++){
					pr("#");
				}
				ln();
			}
			ln();
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
object Main extends App {
  private def func(s:Array[Char]):Long = {
    var count = 0L
    var last = 0
    //do{
      var i=0
      while(i < s.size){
        if(s(i)=='W'){
          last += 1
          count += (i - last + 1)
        }
        i+=1
        //println(count, i, find, s.toSeq)
      } 
    //} while(false/*find*/)
    count
  }
  println(func(io.Source.stdin.getLines.toIndexedSeq.head.toCharArray))
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<int> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;

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


struct Edge {
    int to, cap, rev;
    Edge(int _to, int _cap, int _rev) {
        to = _to; cap = _cap; rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
    G[from].push_back(Edge(to, cap, G[to].size()));
    if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

double d(double x1, double y1, double x2, double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int calcCircleOf2Point(double x1, double y1, double x2, double y2, double x3, double y3, double& cx, double& cy)
{
	double 	ox, oy, a, b, c, d ;
	int		stat ;

	a = x2 - x1 ;
	b = y2 - y1 ;
	c = x3 - x1 ;
	d = y3 - y1 ;

	stat = -1 ;

	if  (a*d-b*c !=0.0) {
		ox = x1 + (d * (a * a + b * b) - b * (c * c + d * d)) / (a * d - b * c) / 2 ;
		if  (b) {
			oy = (a * (x1 + x2 - ox - ox) + b * (y1 + y2)) / b / 2 ;
		} else {
			oy = (c * (x1 + x3 - ox - ox) + d * (y1 + y3)) / d / 2 ;
		}
		cx = ox ;
		cy = oy ;
		stat = 0 ;
	}

	return stat ;
}

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

	ll n;
	cin>>n;

	vector<double> x(n),y(n);
	REP(i,n) cin>>x[i]>>y[i];

	double r=2000.0;

	//2点の線分を直径とする円
	REP(i,n){
		rep(j,i+1,n){
			double xx=(x[i]+x[j])/2.0;
			double yy=(y[i]+y[j])/2.0;
			double rr=0;
			REP(k,n){
				chmax(rr, d(xx,yy,x[k],y[k]));
			}
			chmin(r,rr);
		}
	}

	//3点を演習に含む円
	REP(i,n){
		rep(j,i+1,n){
			rep(k,j+1,n){
				double xx,yy;
				int stat = calcCircleOf2Point(x[i],y[i],x[j],y[j],x[k],y[k],xx,yy);
				if(stat==-1) continue;
				double rr=0.0;
				REP(l,n){
					chmax(rr,d(xx,yy,x[l],y[l]));
				}
				chmin(r,rr);
			}
		}
	}

	cout<<fixed<<setprecision(8)<<r<<en;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
sys.setrecursionlimit(20000000)
def check(p):
    global used
    used[p]=1
    for i in range(n):
        if(p!=i and table[p][i]==1 and used[i]!=1):
            check(i)

n,m=map(int,input().split())
v=[]
table=[[0 for i in range(n)] for i in range(n)]
for i in range(m):
    a,b=(map(int,input().split()))
    table[a-1][b-1]=1
    table[b-1][a-1]=1
    v.append((a-1,b-1))
ans=0
for i in range(m):
    table[v[i][0]][v[i][1]]=0
    table[v[i][1]][v[i][0]]=0
    used=[0 for i in range(n)]
    check(0)
    if(sum(used)!=n):
        ans+=1
    table[v[i][0]][v[i][1]]=1
    table[v[i][1]][v[i][0]]=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	char str[3];
	for(int i=0;i<3;i++)
	{
		cin>>str[i];
	}
	if (str[0]=='R'&&str[1]=='R'&& str[2]=='R')
		cout<<3;
	else if((str[0]=='R'&&str[1]=='R')||(str[1]=='R'&&str[2]=='R'))
		cout<<2;
	else if(str[0]=='R' || str[1]=='R' || str[2]=='R')
		cout<<1;
	else
		cout<<0;
	
}

Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


typedef set <int> SI;

int B[10001];

int main() {
    int n;
    while ( cin >> n && n ) {
        SI A;
        for ( int i = 1; i < n; ++ i ) {
            A.insert( ( i * i ) % n );
        }
        fill( B, B+10001, 0 );
        for ( SI::iterator it_i = A.begin(); it_i != A.end(); ++ it_i ) {
            for ( SI::iterator it_j = it_i; it_j != A.end(); ++ it_j ) {
                if ( *it_i == *it_j ) continue;
                int sub = *it_i - *it_j;
                if ( sub < 0 ) sub += n;
                if ( sub * 2 > ( n - 1 ) ) sub = n - sub;
                B[sub] ++;
            }
        }
        for ( int i = 1; 2 * i <= n - 1; ++ i ) {
            cout << B[i] * 2 << endl;
        }
    }
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '1') cout << "9";
    if (S[i] == '9') cout << "1";
  }
  cout << endl;
}

Measured memory_bytes: 256
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
		
		$n = $s[0];
		$k = $s[1];

		$a = $this->arrayIn();
		
		$ans = 0;
		$buf = $k;
		while(true){
			$ans++;
			
			if($n <= $buf){
				break;
			}else{
				$buf += ($k - 1);
			}
		}
		echo $ans;
	}
}
?>


Measured memory_bytes: 23024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=1e5+5;

ll m=998244353,a[N],c[N];

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

int main()
{ios_base::sync_with_stdio(false);
ll n,mx=0;
cin>>n;
rep(i,1,n)
cin>>a[i];
rep(i,1,n)
{
	c[a[i]]++;
	mx=max(mx,a[i]);
}
if(c[0]!=1||a[1]!=0)
{
	ol(0);
	return 0;
}
ll ans=1;
rep(i,1,mx)
{
	
	ans=(ans*p(c[i-1],c[i]))%m;
}
ol(ans);
return 0;
}



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

int main(){
    int n;
    cin >> n;
    int ans = false;
    for (int i = 0;i*4 <= n;i++){
        for (int j = 0;j*7 <= n;j++){
            if (i*4 + j*7 == n){
                ans = true;
            }
        }
    }

    if (ans){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int temp;
		scanf("%d",&temp);
		n-=temp;
	}
	n=max(n,-1);
	printf("%d",n);
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //ifstream cin("input.in");
   // ofstream cout("output2.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long A,B,C;
    cin>>A>>B>>C;
    A*=100;
    B*=10;
    C+=(A+B);
    if(C%4)
        cout<<"NO";
    else
        cout<<"YES";
}

Measured memory_bytes: 256
mod = 1000000007

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    s = sum(A)
    for i in range(N - 1):
        s -= A[i]
        ans += A[i] * s
    print(ans % mod)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 94360
R, C, K = map(int, input().split())
grid = [[0]*C for _ in range(R)]
for i in range(K):
    r, c, v= map(int, input().split())
    grid[r-1][c-1] = v
dp = [[[0]*(C+1) for _ in range(R+1)] for _ in range(4)]
for i in range(1,R+1):
    for k in range(1,C+1):
        tmp = max(dp[0][i-1][k],dp[1][i-1][k],dp[2][i-1][k],dp[3][i-1][k])
        target = grid[i-1][k-1]
        dp[0][i][k] = max(dp[0][i][k-1],tmp)
        dp[1][i][k] = dp[1][i][k-1]
        dp[2][i][k] = dp[2][i][k-1]
        dp[3][i][k] = dp[3][i][k-1]
        if target != 0:
            dp[1][i][k] = max(dp[0][i][k-1]+target,tmp+target,dp[1][i][k])
            if dp[1][i][k-1] != 0:
                dp[2][i][k] = max(dp[1][i][k-1]+target,dp[2][i][k])
            if dp[2][i][k-1] != 0:
                dp[3][i][k] = max(dp[2][i][k-1]+target,dp[3][i][k])
print(max(dp[0][-1][-1],dp[1][-1][-1],dp[2][-1][-1],dp[3][-1][-1]))

Measured memory_bytes: 426524
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 100000;

int main() {
  int N, K; cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
  }
  int ans = 1;
  int pos = K;
  while (pos < N) {
    pos--;
    pos += K;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i*j == N) {cout << "Yes" << endl; return 0;}
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll  = int64_t;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
int dx[4]    = {1, 0, -1, 0};
int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];
ll h, w;
string s[402];

bool used[402][402];
ll white, black;
void rec(int i, int j) {
    used[i][j] = true;
    char p     = s[i][j];
    if (s[i][j] == '.')
        white++;
    else
        black++;
    for (int k = 0; k < 4; ++k) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        if (ni >= 0 && ni < h && nj >= 0 && nj < w && s[ni][nj] != p &&
            !used[ni][nj])
            rec(ni, nj);
    }
}

signed main() {
    IOS();
    cin >> h >> w;
    Fill(used, false);
    for (int i = 0; i < h; ++i) { cin >> s[i]; }
    ll ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (!used[i][j]) {
                white = black = 0;
                rec(i, j);
                ans += white * black;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13056
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, x = map(int, input().split())

data = getInputListInt()

data.append(x)

data.sort()

tmp = []

for i in reversed(range(1, n+1)):
    tmp.append(data[i]-data[i-1])



gcdans = reduce(fractions.gcd, tmp)

print(gcdans)




















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

const int INIT = 2 * 10000;

int main() {
	ll N;
	cin >> N;
	vector<int> dp(N), h(N);
	rep(i, N) {
		cin >> h[i];
		dp[i] = INIT;
	}
	dp[0] = 0;
	for (int i = 1; i < N; ++i) {
		int a,b;
		a = dp[i - 1] + abs(h[i] - h[i - 1]);
		if (i > 1)
			b = dp[i - 2] + abs(h[i] - h[i - 2]);
		else
			b = INIT;
		dp[i] = min(a, b);
	}
	cout << dp[N - 1] << endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int A[N];
  int B[N];
  int C[N-1];
  int result = 0;
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    result += tmp;
  }
  for(int i=0; i<N-1; i++){
    int tmp;
    cin >> C[i];
  }
  for(int i=0; i<N-1; i++){
  if(A[i]+1 == A[i+1]){
    result += C[A[i]-1];
  	}
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<utility>
#include<algorithm>
#include<queue>
using namespace std;
typedef struct pos{int x,y,cost;}pos;

int M,N,S,T,m[105][105],m2[105][105],p,q,R,t;

int bfs(int (*m)[105],int x,int y)
{
	int i,c=1,mx[2][6]={{-1,0,1,0,-1,-1},{0,1,1,1,0,-1}},my[2][6]={{-1,-1,0,1,1,0},{-1,-1,0,1,1,0}};
	queue<pos>Q;
	m[y][x]=0;
	pos tmp={x,y,0};
	Q.push(tmp);
	while(!Q.empty())
	{
		tmp=Q.front();Q.pop();
		int p=tmp.y%2;
		for(int i=0;i<6;i++)
		{
			if(0<=tmp.y+my[p][i]&&tmp.y+my[p][i]<N&&0<=tmp.x+mx[p][i]&&tmp.x+mx[p][i]<M&&m[tmp.y+my[p][i]][tmp.x+mx[p][i]]>tmp.cost+1)
				{
					m[tmp.y+my[p][i]][tmp.x+mx[p][i]]=tmp.cost+1;
					pos tmp2={tmp.x+mx[p][i],tmp.y+my[p][i],tmp.cost+1};
					c++;
					Q.push(tmp2);
				}
		}
	}
	return c;
}

int main()
{
	for(;~scanf("%d%d%d",&M,&N,&S),M;)
	{
		memset(m,0x7,sizeof(m));
		for(int i=0;i<S;i++)
		{
			scanf("%d%d",&p,&q);
			bfs(m,p-1,q-1);
		}
		R=0;
		scanf("%d",&T);
		for(int i=0;i<T;i++)
		{
			memcpy(m2,m,sizeof(m));
			scanf("%d%d",&p,&q);
			t=bfs(m2,p-1,q-1);
			R=t<R?R:t;
		}
		printf("%d\n",R);
	}
	return 0;
}

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

vector<int> v[200001];




int main() 
{
    int n,m,i,j,a,b,x;
    cin>>n>>m;
    for(i=0;i<m;++i)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int flag=0;
    for(i=0;i<v[1].size();++i)
    {
        x=v[1][i];
        for(j=0;j<v[x].size();++j)
        if(v[x][j]==n)
        {
            flag=1;
        }
    }
    
    if(flag==1)
    cout<<"POSSIBLE"<<endl;
    else
    cout<<"IMPOSSIBLE"<<endl;
    
	return 0;
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, m, l;
vector<int> a, b, x, y, c;

signed main() {
    
    cin >> n >> m >> l;
    a.resize(n);
    b.resize(m);
    x.resize(l);
    y.resize(l);
    c.resize(l);

    int amin = INF, bmin = INF;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        chmin(amin, a[i]);
    }

    for(int i = 0; i < m; i++) {
        cin >> b[i];
        chmin(bmin, b[i]);
    }
    int minv = amin + bmin;
    
    for(int i = 0; i < l; i++) {
        cin >> x[i] >> y[i] >> c[i];
        chmin(minv, a[x[i]-1] + b[y[i]-1] - c[i]);
    }

    cout << minv << endl;


  
    return 0;
}



Measured memory_bytes: 2176
import  itertools
N = int(input())
N_len = len(str(N))

ans = 0
if N < 100:
    print(0)
for i in range(3,N_len+1):
    if i == N_len:
        l = list(itertools.product((3,5,7),repeat=N_len))
        ans += len(l)
        for s in l:
            a = int("".join(list(map(str,s))))
            if "3" not in str(a) or "5" not in str(a) or "7" not in str(a):
                ans -= 1
                continue
            if a > N:
                ans -= 1
        print(ans)

    else:
        ans += (3**i - 2**i*3 + 3)

Measured memory_bytes: 5492
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char S[200010];
int fir[200010],dis[400010],nxt[400010],id;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int F[200010],cF[200010],sz[200010];
void dfs(int x,int fa=-1){
	sz[x]=S[x]-'0';
	for(int i=fir[x];i;i=nxt[i]){
		if(fa==dis[i])continue;
		dfs(dis[i],x);
		if(F[dis[i]]>=F[x])cF[x]=F[x],F[x]=F[dis[i]]+1;
		else cF[x]=std::max(cF[x],F[dis[i]]+1);
		sz[x]+=sz[dis[i]];
	}
}
ll ans;
void DFS(int x,int FF=0,int fa=-1){
	int mx=FF,cm=0;
	for(int i=fir[x];i;i=nxt[i]){
		if(fa==dis[i])continue;
		if(F[dis[i]]+1>mx)cm=mx,mx=F[dis[i]]+1;
		else cm=std::max(cm,F[dis[i]]+1);
	}
	for(int i=fir[x];i;i=nxt[i]){
		if(fa==dis[i])continue;
		int df=FF;
		if(F[x]!=F[dis[i]]+1)df=std::max(df,F[x]);
		else df=std::max(df,cF[x]);
		DFS(dis[i],df+1,x);
	}
	int low=1e9;if(S[x]=='1')low=0;
	for(int i=fir[x];i;i=nxt[i])if(fa!=dis[i]&&sz[dis[i]])low=std::min(low,F[dis[i]]+1);
	if(sz[1]-sz[x])low=std::min(low,FF);
	ans+=std::max(0,std::min(mx,cm+2)-low);
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),u,v;
	for(int i=1;i<n;++i)u=gi(),v=gi(),link(u,v),link(v,u);
	scanf("%s",S+1);
	dfs(1);DFS(1);
	printf("%lld\n",ans+1);
	return 0;
}


Measured memory_bytes: 18560
#include<iostream>
#include <iomanip>
#include<string.h>

using namespace std;

int main(){
	while(1){
		int n,w;
		cin >> n >> w;
		if(n == 0) break;
		
		int v[101];
		int max_num = 0;
		int interval[12];
		memset(interval,0,sizeof(interval));
		for(int i = 0;i < n;i++){
			cin >> v[i];
			if(v[i] > max_num) max_num = v[i];
			interval[v[i]/w]++;
		}
		
		int inter_num = max_num / w + 1;
		int max_index = 0;
		for(int i = 1;i < inter_num;i++){
			if(interval[max_index] < interval[i]) max_index = i;
		}
		
		float ans = 0.0;
		for(int i = 0;i < inter_num;i++){
			ans += ((interval[i] * 1.0) / interval[max_index]) * ((inter_num - 1 - i) * 1.0/(inter_num - 1));
		}
		ans += 0.01;
		cout << fixed << setprecision(6) << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3276