akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, c[10005], M, d[10005], deg[10005], stk[10005], tops = 0, tope = 0;
struct Edge {int np; Edge *nxt;} E[20005], *V[10005];

inline void addedge(const int &u, const int &v){
	E[++tope].np = v, E[tope].nxt = V[u], V[u] = E + tope;
}

int main(){
	getint(N);
	for(register int i = 1; i < N; i++){
		int u, v; getint(u), getint(v);
		addedge(u, v), addedge(v, u), deg[u]++, deg[v]++;
	}
	for(register int i = 1; i <= N; i++) getint(c[i]);
	sort(c + 1, c + N + 1);
	for(register int i = 1; i <= N; i++) if(deg[i] == 1) stk[++tops] = i;
	for(register int i = 1; i <= N; i++){
		const int u = stk[tops--]; M += d[u] = c[i];
		for(register Edge *ne = V[u]; ne; ne = ne->nxt) if(!d[ne->np] && --deg[ne->np] == 1) stk[++tops] = ne->np;
	}
	printf("%d\n", M - c[N]);
	for(register int i = 1; i <= N; i++) printf("%d ", d[i]);
	return 0;
}

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

#define ll long long

int n;

int main(){
	scanf("%d", &n);
	ll t1, a1;
	std::cin >> t1 >> a1;
	n --;
	while(n --){
		ll t2, a2;
		std::cin >> t2 >> a2;
		t1 = (t1 - 1) / t2 + 1;
		a1 = (a1 - 1) / a2 + 1;
		if(t1 < a1){
			t1 = a1;
		}
		t2 *= t1;
		a2 *= t1;
		t1 = t2, a1 = a2;
	}
	std::cout << t1 + a1 << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

class UF
{
private:
    int         num;
    vector<int> par;
    vector<int> siz;
public:
    //vector<int> val;
public:
    UF(int n): num(n) {
        par.resize(n);
        siz.resize(n);
        //val.resize(n);
        int i;
        for(i=0; i<n; i++) {
            par[i]=i; siz[i]=1;
            //val[i]=0;
        }
    }
	
    int find(int x) {
        if(x==par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(siz[x]<siz[y]) {
            par[x]=y;
            siz[y]=siz[x]+siz[y];
            //val[y]=val[x]+val[y];
        }
        else {
            par[y]=x;
            siz[x]=siz[x]+siz[y];
            //val[x]=val[x]+val[y];
        }
    }

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

    int size(int x) {
        return siz[find(x)];
    }

    int ngroup() {
    //int ngroup( int& ans ) {
        int count=0;
        int i;
        for(i=0; i<num; i++) {
            if(par[i]==i) {
                count++;
                //ans += (val[i]? siz[i]: siz[i]-1);
            }
        }
        return count;
    }
};


int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);
    vector<vector<int> > a(m);
    int i,j;
    for(i=0; i<n; i++) {
        int k;
        scanf("%d", &k);
        for(j=0; j<k; j++) {
            int tmp;
            scanf("%d", &tmp); tmp--;
            a[tmp].push_back(i);
        }
    }

    UF uf(n);
    for(i=0; i<m; i++) {
        int siz=(int)a[i].size();
        for(j=1; j<siz; j++) {
            uf.unite(a[i][0],a[i][j]);
        }
    }
    if(uf.ngroup()==1) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 4608
n,q = map(int,input().split())
s = input()

l = [0] * (n)

for i in range(1,n):
    if(s[i-1:i+1] == 'AC'):l[i] = l[i-1] + 1
    else:l[i] = l[i-1]
L = [0] * q
R = [0] * q
for i in range(q):
    a,b = map(int,input().split())
    L[i] = a
    R[i] = b
for i in range(q):
    a = L[i]
    b = R[i]
    x = l[b-1] - l[a-1]
    print(x)

Measured memory_bytes: 14220
// C++ program to find Excel
// column name from a given
// column number
#include <bits/stdc++.h>
#define MAX 50
using namespace std;
#define ll long long
// Function to print Excel column name for a given column number
void printString(ll n)
{
	char str[MAX]; // To store result (Excel column name)
	ll i = 0; // To store current index in str which is result

	while (n > 0) {
		// Find remainder
		ll rem = n % 26;

		// If remainder is 0, then a 'Z' must be there in output
		if (rem == 0) {
			str[i++] = 'z';
			n = (n / 26) - 1;
		}
		else // If remainder is non-zero
		{
			str[i++] = (rem - 1) + 'a';
			n = n / 26;
		}
	}
	str[i] = '\0';

	// Reverse the string and print result
	reverse(str, str + strlen(str));
	cout << str << endl;

	return;
}

// Driver program to test above function
int main()
{
	ll n;
	cin>>n;
	ll a[n+1],i,j,sum=0;
	ll vis[200010]={0};
	for(i=0;i<n;i++)
    {
        cin>>a[i];
        vis[a[i]]++;
        sum+=a[i];
    }
    ll q;
    cin>>q;
    for(i=0;i<q;i++)
    {
        ll b,c;
        cin>>b>>c;
        sum-=vis[b]*b;
        sum+=vis[b]*c;
        vis[c]+=vis[b];
        vis[b]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int a=(N+1)/2;
    cout << fixed << setprecision(6);
    cout << (double)a/N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() { int N, K;
  cin >> N >> K;
  ll ans = 0;
  REP(i, N) { int x;
    cin >> x;
    ans += min(2 * x, 2 * abs(x - K));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: u64,
    }

    let mut sn: u64 = 0;
    let mut ten_x = 1;
    while n >= ten_x {
        sn += (n / ten_x) % 10;
        ten_x *= 10;
    }

    println!("{}", if n % sn == 0 { "Yes" } else { "No" });
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();

		sc.close();

		int tmp = X;
		X = Y;
		Y = tmp;

		tmp = X;
		X = Z;
		Z = tmp;

		out.println(X + " " + Y + " " + Z);

	}

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


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;

int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vi ao(a);
	sort(all(a));
	reverse(all(a));
	for (int i = 0; i < n; i++)
	{
		if (ao[i] == a[0])
			cout << a[1];
		else
			cout << a[0];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
	int rows, columns;
	cin >> rows >> columns;
	int **HW;
	HW = new int * [rows];
	for (int i = 0; i < rows; i++) {
		HW[i] = new int[columns];
	}
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < columns; j++) {
			HW[i][j] = 0;
		}
	}
	//填格子开始

	int Num;
	cin >> Num;
	int *a;
	a = new int[Num];
	for (int i = 0; i < Num; i++) {
		cin >> a[i];
	}
	int var = 0; int x = -1, y = 0;
	for (int i = 0; i < Num; i++) {
		for (int j = 0; j < a[i]; j++) {
			if (var == 0) {
				x++;
				if (x < columns && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x--; j--; var++;
				}
			}else if (var == 1) {
				y++;
				if (y < rows && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y--; j--; var++;
				}
			}else if (var == 2) {
				x--;
				if (x >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x++; j--; var++;
				}
			}else if(var == 3) {
				y--;
				if (y >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y++; j--; var = 0;
				}
			}
		}
	}
	//填格子结束
	for (int i = 0; i < rows; i++) {
		cout << HW[i][0];
		for (int j = 1; j < columns; j++) {
			cout << " " << HW[i][j];
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 384
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string;
    import std.traits : isSomeString;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
    {
        this.file = file;
        this.idx = 0;
        fromString(s);
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.strip.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }

    void fromString(StrType)(StrType s) if (isSomeString!(StrType))
    {
        str ~= s.to!(char[]).strip.split;
    }
}
// }}}

void main()
{
    auto cin = new Scanner;
    auto a = cin.nextArray!int(3);
    writeln(min(abs(a[1] - a[0]) + abs(a[2] - a[1]), abs(a[2] - a[1]) + abs(a[0] - a[2]), abs(a[0] - a[2]) + abs(a[1]  - a[0])));
}


Measured memory_bytes: 256
"use strict";
function main(input) {
  const inputs = input[0].trim().split(" ").map(i => parseInt(i));
  const n = inputs[0];
  const x = inputs[1];
  const y = inputs[2];

  let distances = [];
  for(let i=0;i<n-1;i++){
    distances[i] = 0;
  }

  for(let i=1;i<=n;i++){
    for(let j=i+1;j<=n;j++){
      let distance = Math.min(Math.abs(j-i), Math.abs(x-i)+Math.abs(y-j)+1);
      distances[distance-1]++;
    }
  }
  for(let i=0;i<n-1;i++){
    console.log(distances[i]);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 9644
N, Y = map(int, input().split())

Y //= 1000

for y in range(9):
  Yt = Y - 5*y
  Nt = N - y
  if Nt <= Yt <= 10*Nt:
    x = (Yt - Nt)//9
    z = (10*Nt - Yt)//9
    if x + z == Nt and 10*x + z == Yt:
      print(x, y, z)
      exit()

print(-1, -1, -1)

Measured memory_bytes: 9100
numx,numy,numz,k=list(map(int,input().split()))
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
Z=list(map(int,input().split()))

XY=[ x + y for x in X for y in Y]
XY.sort(reverse=True)
XY=XY[:k]
XYZ=[xy + z for xy in XY for z in Z]
XYZ.sort(reverse=True)

for i in range(k):
  print(XYZ[i])

Measured memory_bytes: 179156
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
  int n;
  vector<long long> hs[MS], pw[MS];
  rolling_hash(){}
  rolling_hash(const string &s) {
    n = s.size();
    for (int i = 0; i < MS; i++) {
      hs[i].assign(n+1,0);
      pw[i].assign(n+1,0);
      hs[i][0] = 0;
      pw[i][0] = 1;
      for (int j = 0; j < n; j++) {
        pw[i][j+1] = pw[i][j]*base%mod[i];
        hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
      }
    }
  }

  long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

  bool match(int l1, int r1, int l2, int r2) {
    bool ret = 1;
    for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
    return ret;
  }

  bool match(int l, int r, long long h[]) {
    bool ret = 1;
    for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
    return ret;
  }
};

int main(){
  COMinit();
  LL n,m,k;
  cin >> n >> m >> k;
  LL res = 0;
  rep(i,1,n){
    LL a = n-i;
    res += i * a * m * m;
    res = res % MOD;
  }
  rep(i,1,m){
    LL a = m - i;
    res += i * a * n * n;
    res = res % MOD;
  }
  res *= COM(n*m-2,k-2);
  res = res % MOD;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 12288
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int a,b,c=0,r=1;
    cin>>a>>b;
    while (r<b){
        r += a-1; c++; 
    }
    cout << c << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3612
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            // a,bは正の整数なので1～Nの組み合わせ
            if (0 == K)
            {
                WriteLine(N * N);
                return;
            }
            // a=\alpha b + K \leq N
            // \alpha=0のとき
            var ans = (N - K) * (N - K + 1) / 2;
            // K+1<=b
            // \alpha(K+1)+K\ leq \alpha b +K\leq N
            // \alpha (K+1) leq N-K
            for (var i = 1; i * (K + 1) <= N - K; ++i)
            {
                // a= \alpha b + K <= N
                for (var b = K + 1; i * b + K <= N; ++b)
                    ans += Min(N, (i + 1) * b - 1) - (i * b + K) + 1;//K以上になるa = \alpha b + K～(\alpha +1)b-1(上限はN)
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#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>;

const int INF = 1001001001;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n);
  rep(sv,n) {
    vector<int> dist(n, INF);
    queue<int> q;
    auto push = [&](int v, int d) {
      if (dist[v] != INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(sv, 0);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      int d = dist[v];
      if (v-1 >= 0) push(v-1, d+1);
      if (v+1 < n) push(v+1, d+1);
      if (v == x) push(y, d+1);
      if (v == y) push(x, d+1);
    }
    rep(i,n) ans[dist[i]]++;
  }
  rep(i,n) ans[i] /= 2;
  for (int i = 1; i <= n-1; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}


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

using namespace std;

char dice[6][4] = {
	{5,1,2,4}, {1,3,1,0}, {0,2,3,2},
	{2,4,5,1}, {4,0,4,3}, {3,5,0,5}
};
int getUpper(int a, int b){
	if(a%3 == 0) return a?6:1;
	if(b%3 == 0) return b?3:4;
	return (b+6-a)%6 < 3 ? 2 : 5;
}

int main(){
	int n;
	while(cin >> n, n){
		string s;
		int a = 0, b = 1, c = 0, r = 1;
		for(int i=0;i<n;i++){
			cin >> s;
			int d = -1;
			if(s[0]=='L') c+=3; 
			if(s[0]=='R') c++;
			if(s[0]=='W') d = 1;
			if(s[0]=='N') d = 0;
			if(s[0]=='E') d = 3;
			if(s[0]=='S') d = 2;
			if(d!=-1){
				a = dice[a][(d+c)%4];
				b = dice[b][(d+c)%4];
			}
			r += getUpper(a, b);
		}
		cout << r << endl;
	}
}

Measured memory_bytes: 0
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int m1,i,m2;
  cin >> m1 >> i >> m2 >> i;
  cout << (m1!=m2) << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

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

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

ll n;
vint a, b;
ll k;
vector<vint> edge;
map<P, int> ma;

void dfs(int num, int par, int pcol){
	int col = 0;
	rep(i, edge[num].size()){
		if(edge[num][i] != par){
			if(col == pcol)col++;
			ma[P(min(num, edge[num][i]),max(num, edge[num][i]))] = col;
			dfs(edge[num][i], num, col);
			col++;
		}
	}
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
	cin>>n;a = vint(n);b = vint(n);
	vint nu(n, 0);
	edge = vector<vint>(n);
	rep(i, n-1){
		ll aa,bb;cin>>aa>>bb;
		a[i] = aa-1;b[i] = bb-1;
		nu[aa-1]++;nu[bb-1]++;
		edge[aa-1].push_back(bb-1);
		edge[bb-1].push_back(aa-1);
	}
	k = 0;
	rep(i, n){
		chmax(k, (ll)nu[i]);
	}

	dfs(0, -1, -1);

	cout << k << endl;
	rep(i, n-1){
		cout << ma[P(a[i], b[i])]+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 18432
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int sum = 0;
        for(int i = 0;i<n;i++){
            sum += sc.nextInt();
        }
        if(sum>=h){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 46728
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int main(){
    int x; cin >> x;
    int dx = sqrt(x);
    int ans=1;
    for(int i=1; i<=dx; i++){
        int res=i;
        for(int j=0; j<10; j++){
            if(res*i<=x){
                res*=i;
            }else{
                break;
            }
        }
        ans = max(ans,res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
n, k = map(int, input().split())
P = list(map(int, input().split()))

maxsum = 0
maxindex = 0
p_sum = 0
for i in range(k):
    p_sum += P[i]
maxsum = p_sum
maxindex = 0
for i in range(1, n - k + 1):
    p_sum = p_sum - P[i - 1] + P[i + k - 1]
    if p_sum > maxsum:
        maxsum = p_sum
        maxindex = i
result = 0
for i in range(maxindex, maxindex + k):
    result += (1 + P[i]) * P[i] / 2 / P[i]
print(result)


Measured memory_bytes: 25316
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

	for(string s; cin >> s && s != "0";) {
		long long ans = 0;
		vector<long long> dp(11, 0);

		for(int i = 0; i < static_cast<int>(s.size()); ++i) {
			if(s[i] != '0') ++dp[0];

			vector<long long> tmp(11, 0);
			for(int j = 0; j < 11; ++j) {
				tmp[(j * 10 + s[i] - '0') % 11] += dp[j];
			}

			ans += tmp[0];
			dp.swap(tmp);
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,total=0;
    cin>>n;
    ll a[n+2];
    a[0]=0;
    a[n+1]=0;
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
    }
    for(int i=2;i<=n;i++)
    {
      total+=(abs(a[i]-a[i-1]));
    }
    vi v;
    total+=(abs(a[1]));
    total+=(abs(a[n]));
    //cerr<<"Total = "<<total<<endl;
    /*for(int i=0;i<=n+1;i++)
    {
      cout<<a[i]<<" ";
    }
    cout<<endl;*/
    for(int i=1;i<=n;i++)
    {
      if(a[i+1]>a[i]&&a[i-1]<a[i])
        { 
          v.pb(total);
          continue;
        }
      else if(a[i+1]<a[i]&&a[i]<a[i-1])
        {  v.pb(total);
          continue;
        }
      else
      {
        ll temp=total-abs(a[i]-a[i-1])+abs(a[i-1]-a[i+1])-abs(a[i]-a[i+1]);
        v.pb(temp);
      }
    }
    for(auto t:v)cout<<t<<endl;

    
}
return 0;
}

Measured memory_bytes: 2932
def inpl(): return list(map(int, input().split()))
N = int(input())
X = inpl()


sX = sorted(X)
a, b = sX[N//2-1], sX[N//2]
for i in X:
    if i==a and i==b:
        print(a)
    elif i<=a:
        print(b)
    else:
        print(a)

Measured memory_bytes: 26016
#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>

using namespace std;
string expand(string str, int low, int high)
{
	int len = str.length();
	while (low >= 0 && high < len && (str[low] == str[high]))
		low--, high++;	
	return str.substr(low + 1, high - low - 1);
}

string LongestPalindromicSubstring(string str, int len)
{
	string max_str = "", curr_str;

	int max_length = 0, curr_length;

	for (int i = 0; i < len; i++)
	{
		
		curr_str = expand(str, i, i);
		curr_length = curr_str.length();

		if (curr_length > max_length)
		{
			max_length = curr_length;
			max_str = curr_str;
		}

		curr_str = expand(str, i, i + 1);
		curr_length = curr_str.length();

		if (curr_length > max_length)
		{
			max_length = curr_length;
			max_str = curr_str;
		}
	}

	return max_str;
}
void change(char *str)
{
    int i=1;
    int j=1;
    int k;
    int d=0;
 while(str[i]!='\0')
 {
     if(str[i-1]==str[i])
     {
         k=i+1;
        while(str[k]!='\0'&&str[k-1]==str[k])
         {
             k++;
         }
         i=k;
      }
    str[j]=str[i];
     j++;
     i++;
}
 str[j]='\0';
 cout<<strlen(str);
}
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    char s[n];
    cin>>s;
    change(s);
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


struct Packet
{
	int t, s, d;
	bool operator<(const Packet& obj) const
	{
		return t < obj.t;
	}
};
int main()
{
	ios::sync_with_stdio(false);

	int n, m;
	while (cin >> n >> m, n)
	{
		bool infe[22222];
		fill(infe, infe + (n + 1), false);
		infe[1] = true;

		Packet p[22222];
		for (int i = 0; i < m; ++i)
			cin >> p[i].t >> p[i].s >> p[i].d;
		sort(p, p + m);
		for (int i = 0; i < m; ++i)
			if (infe[p[i].s])
				infe[p[i].d] = true;
		cout << count(infe, infe + (n + 1), true) << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

void solve(){
   cin>>n;
   n = n % 10;
   if (n == 2 or n == 4 or n == 5 or n == 7 or n == 9){
      cout << "hon";  
   }
   else if (n == 0 or n == 1 or n == 6 or n == 8){
      cout<<"pon";
   }
   else{
      cout<<"bon";
   }
}

int32_t main(){_
   
   int t = 1;
   //cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}

Measured memory_bytes: 3656
package main

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

// Rectangle
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ary := strings.Split(strings.TrimSpace(sc.Text()), " ")
	x, _ := strconv.Atoi(ary[0])
	y, _ := strconv.Atoi(ary[1])

	fmt.Printf("%v %v\n", x*y, (x+y)*2)
}



Measured memory_bytes: 1068
//ツ暗按可コツづ個フツォツーツマツッツトツづ可従ツづづ出ツ療債づーツつケツづヲツ　ツ禿シツ療債づ債づ按つ「
//1x1=1
//1x2=2
//.
//.
//9x8=72
//9x9=81

#include<iostream>
using namespace std;

int main(void)
{
	int l, r;
	for(int i = 0; i < 81; i++)
	{
		l = i/9+1;
		r = i%9+1;
		cout << l << 'x' << r << '=' << l*r << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
 int N,M;cin >> N >> M;
  vector<vector<int>> s(M);
  for(int i = 0;i<M;i++){
    int k;cin >> k;
    for(int j = 0;j<k;j++){
      int a;cin >> a;a--;
      s[i].push_back(a);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; ++i) cin >> p[i];
  
  ll res = 0;
  for(int bit = 0;bit < (1<<N);bit++){
    bool ok = true;
    for(int i = 0;i<M;i++){
      int con = 0;
      for(auto v:s[i]){
        if(bit &(1<<v)) con++;
      }
      if(con%2 != p[i]) ok = false;
       }
          if(ok) res++;
     }
      cout << res << endl;

}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
/*Calculate GCD, LCM =============================*/
long long GCD(long long a, long long b){
    return (b ? GCD(b, a%b) : a);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a,b);
    return (a/g) * (b/g) * g;  // オーバーフローを避ける
}


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    /**
     * n == m なら s == tでなければならない
     * その他では普通に構築
     */

    ll n,m, L; cin >> n >> m;
    string s,t,x; cin >> s >> t;

    if(n==m && s!=t) {
        cout << -1 << '\n';
        return 0;
    }
    if(s[0] != t[0]) {
        cout << -1 << '\n';
        return 0;
    }

    map<int,char> mp, init;
    bool cant = 0;
    L = LCM(n,m);
    rep(i,n) mp[L/n * i] = s[i];
    rep(j,m) {
        if(mp.find(L/m*j) != mp.end()) if(mp[L/m*j] != t[j]) cant = 1;
    }
    if(!cant) {
        cout << L << '\n';
        return 0;
    }
    cout << -1 << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

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

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int time = (H2-H1)*60 + M2 - M1 - K;
  cout << time;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int n;
string a,b;
int main(){
  cin>>n>>a>>b;
  for(int i=0;i<=n;++i){
    if(a.substr(i,n-i)==b.substr(0,n-i)){
      cout << n+i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#define ll long long
using namespace std;
int main()
{
    ll a[100005];
    ll aa,bb,book[100005];
    int flag=0,n,flge=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    for(int i=n-1; i>=0; i--)
    {
        if(a[i]==a[i-1])
        {
            aa=a[i];
            n=i-2;
            flag=1;
            break;
        }
    }
    for(int i=n; i>=0&&flag; i--)
    {
        if(a[i]==a[i-1])
        {
            bb=a[i];
            flge=1;
            break;
        }
    }
    if(flge==1)
    {
        printf("%lld\n",aa*bb);
    }
    else
    {
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

int kai(int n)
{
    int res = 1;
    for (int i = n; i > 0; i--)
        res *= i;
    return res;
}

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

    int N;
    cin >> N;
    vector<pair<double, double> > v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i].first >> v[i].second;
    }

    int k = 1;
    int m = 0;
    for (int i = N; i > 2; i--)
        k *= i;
    vector<double> res(k);
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            res[m++] = (pow(pow((v[i].first-v[j].first),2.0)+pow((v[i].second-v[j].second),2.0), 0.5)); 
            //cout << pow(pow((v[i].first-v[j].first),2.0)+pow((v[i].second-v[j].second),2.0), 0.5) << endl;
        }
    }

    int l = kai(N-2)*(N-1)*2;
    double ans = 0;
    for (int i = 0; i < k; i++) {
        ans += res[i] * l;
    }

    printf("%.10f\n", ans/(k*2));

    return 0;
}

Measured memory_bytes: 640
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class UnionFind {

	int[] par;

	public UnionFind(int size) {
		par = new int[size];
		Arrays.fill(par, -1);
	}

	public int root(int x) {
		if (par[x] < 0) {
			return x;
		}
		int z = root(par[x]);
		par[x] = z;
		return z;
	}

	public boolean same(int a, int b) {
		return root(a) == root(b);
	}

	public void unite(int a, int b) {
		if (!same(a, b)) {
			int ra = root(a);
			int rb = root(b);

			if (par[ra] < par[rb]) {
				par[ra] += par[rb];
				par[rb] = ra;
			} else {
				par[rb] += par[ra];
				par[ra] = rb;
			}
		}
	}

	public int size(int a) {
		return -par[root(a)];
	}

}

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		List<int[]> hen = new ArrayList<>();
		for (int i = 0; i < M; i++) {
			hen.add(new int[] { sc.nextInt() - 1, sc.nextInt() - 1 }); //0オリジンにしとく
		}

		sc.close();

		int ans = 0;
		for (int i = 0; i < M; i++) {
			UnionFind uf = new UnionFind(N);
			for (int j = 0; j < M; j++) {
				//i以外の辺を追加
				if (i == j) {
					continue;
				}
				uf.unite(hen.get(j)[0], hen.get(j)[1]);
			}

			if (uf.size(0) != N) {
				//iは橋
				ans++;
			}
		}

		out.println(ans);

	}

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

}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

bool mem[5001][5001];
const int H = 5000, W = 5000;
vector<pair<int, int>> points;

bool check(int x, int y, int dx, int dy)
{
  return x - dy <= W && x - dy >= 0 && y + dx <= H && y + dx >= 0 && mem[x - dy][y + dx] &&
         x + dx - dy <= W && x + dx - dy >= 0 && y + dy + dx <= H && y + dy + dx >= 0 && mem[x + dx - dy][y + dy + dx];
}

int main()
{
loop:
  fill((bool*)mem, (bool*)mem + 5001 * 5001, false);
  int n, ans = 0;
  cin >> n;
  if(!n)
    return 0;
  for(int i = 0; i < n; i++)
  {
    int x, y;
    cin >> x >> y;
    points.push_back(make_pair(x, y));
    mem[x][y] = true;
  }

  for(auto st : points)
  {
    for(auto ed: points)
    {
      if(st == ed)
        continue;
      auto sx = st.first, sy = st.second,
           ex = ed.first, ey = ed.second;
      auto dx = ex - sx, dy = ey - sy;
      if(check(sx, sy, dx, dy))
        ans = max(ans, dx * dx + dy * dy);
    }
  }
  cout << ans << endl;
  goto loop;
}

Measured memory_bytes: 25748
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a =int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換


    if op=="?": # opが"?"の時は終了
        break
    else: 
        if op=="+":
            print(a+b)
        elif op=="-":
            print(a-b)
        elif op=="*":
            print(a*b)
        elif op=="/":
            print(a//b)


Measured memory_bytes: 5596
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

const int maxn=1e5+5;

int n,rt,tot,deg[maxn];
int A[maxn],now[maxn],pre[maxn*2],son[maxn*2];

int read() {
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return x*f;
}

void add(int a,int b) {
	pre[++tot]=now[a];
	now[a]=tot,son[tot]=b;
}

ll dfs(int fa,int u) {
	if(deg[u]==1)return A[u];
	ll remain=A[u]<<1;
	for(int p=now[u],v=son[p];p;p=pre[p],v=son[p])
		if(v!=fa) {
			ll tmp=dfs(u,v);
			if(tmp>A[u]) {puts("NO");exit(0);}
			remain-=tmp;
		}
	if(remain<0||remain>A[u]) {puts("NO");exit(0);}
	return remain;
}

int main() {
	n=read();
	for(int i=1;i<=n;i++)
		A[i]=read();
	if(n==2) {
		if(A[1]==A[2])puts("YES");
		else puts("NO");return 0;
	}
	for(int i=1;i<n;i++) {
		int x=read(),y=read();
		add(x,y),add(y,x);deg[x]++,deg[y]++;
		if(deg[x]>1)rt=x;if(deg[y]>1)rt=y;
	}
	if(dfs(0,rt))puts("NO");
	else puts("YES");
	return 0;
}


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

int main(void){
    int N, K;
    cin >> N >> K;
    int score;
    double ans = 0.0;

    for(int i = 1; i <= N; i++){
        double tmp = 1.0 / N;
        score = i;
        while(score >= 1 && score <= K - 1){
            tmp *= 0.5;
            score *= 2;
        }
        ans += tmp;
    }
    cout << fixed;
    cout << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n,m;
 
   cin >> n >> m;
  
   
   for(int i=1;i<4;i++){
     
     if(i!=n&&i!=m){
       cout << i <<endl;
     }
     
   }
     
   
   
   
  return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }




// ***************************************


int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vii arr(H, vi(W, 0));

    REP(i, H){
        REP(j, W){
            char x;
            cin >> x;
            if (x == '#') arr[i][j] = 1;
        }
    }

    int ans = 0;
    REP(noH, (1<<H)){
        REP(noW, (1<<W)){
            int cnt = 0;
            REP(i, H){
                if ((1<<i) & noH) continue;
                REP(j, W){
                    if ((1<<j) & noW) continue;
                    if (arr[i][j] == 1) cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

Measured memory_bytes: 4412
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='-')ans--;
		if(s[i]=='+')ans++;
	}
	cout << ans << endl;	
	return 0;
}


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

int main(){
    long x;
    int i=0,j=0;
    cin >> x;
    while(x>=500){
       x=x-500;
       i++;
    }

    while(x>=5){
            x=x-5;
            j++;
    }

    cout << i*1000+j*5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define type 26

int constant(int day)//1~26 順番
{
  return day%type+1;
}
int get_random()//1~26 ランダム
{
  return rand()%type+1;
}
int max(int s[][type+1],int day)//その日の最大の満足度選ぶ
{
  int m,max_score=0,i;
  for(i=1;i<=type;i++)
  {
    if(s[day][i]>max_score){
      max_score=s[day][i];
      m=i;
    }
  }
  return m;
}
void cal(int select,int c[type+1],int last[type+1],int s[][type+1],int day,int sum[])
{
  int i;
  sum[day]=sum[day-1]+s[day][select];
  for(i=1;i<=type;i++){
    sum[day]-=c[i]*(day-last[i]);
  }
}
void change(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D)
//ランダムに変更
{
  int d,t,old,total=0,i,j;
  d=rand()%D+1;
  t=rand()%type+1;
  old=schedul[d];
  schedul[d]=t;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
  //  printf("change\n");
    sum[D]=total;
  }
  else{
    schedul[d]=old;
  }
}
void cross(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D)
//ランダムな２つ交換
{
  int a,b,old_a,old_b,flag=0,i,j,total=0;
  flag=rand()%2;
  a=rand()%D+1;
  if(flag==0){
    b=a+rand()%16+1;
    if(b>D) b=a-(rand()%16+1);
  }
  else{
    b=a-(rand()%16+1);
    if(b<1)   b=a+rand()%16+1;
  }
  old_a=schedul[a];
  old_b=schedul[b];
  schedul[a]=old_b;
  schedul[b]=old_a;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
    sum[D]=total;
  }
  else
  {
    schedul[a]=old_a;
    schedul[b]=old_b;
  }
}
int main(void)
{
  int D,c[type+1],i,j;
  clock_t start,stop;
  start=clock();
  srand((unsigned int)time(NULL));
  scanf("%d",&D);//D=365
  int s[D+1][type+1],last[type+1],sum[D+1],schedul[D+1];
  for(i=0;i<=D;i++) sum[i]=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=type;i++) scanf("%d",&c[i]);
  for(i=1;i<D+1;i++){
    for(j=1;j<=type;j++) scanf("%d",&s[i][j]);
  }
  for(i=1;i<D+1;i++){
    int select;
    select=max(s,i);
    last[select]=i;
    schedul[i]=select;
    cal(select,c,last,s,i,sum);
    //printf("%d\n",sum[i]);
  }
  int count=0;
  stop=start;
  while((double)(stop - start) / CLOCKS_PER_SEC<1.988){
    int flag=rand()%2;
    if(flag==0) cross(c,last,s,sum,schedul,D);
    else change(c,last,s,sum,schedul,D);
    count++;
    stop=clock();
  }
/*
  printf("count:%d\n",count);
  printf("time:%f\n",(double)(stop - start) / CLOCKS_PER_SEC);
  printf("%d\n",sum[D]);
  printf("確認\n");
  int total=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  printf("%d\n",total);
*/
  for(i=1;i<=D;i++) printf("%d\n",schedul[i]);
  return 0;
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n, sm = 0, mx = 0;
  int l[11] = {};
  cin >> n;
  for(int i=0;i<n;i++) cin >> l[i];
  sort(l, l+n, greater<int>());
  mx = l[0];
  for(int i=1;i<n;i++) sm += l[i];
  cout << (mx < sm?"Yes":"No") << endl;
}

Measured memory_bytes: 256