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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100000;

// ──────────────────────────────────────────────────────────────────

int dp[1010][1010];

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

	rep(i, n) {
		string s, t;
		cin >> s >> t;

		memset(dp, 0, sizeof(dp));
		rep(i, s.size()) {
			rep(j, t.size()) {
				if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
				dp[i + 1][j + 1] = max({ dp[i + 1][j + 1], dp[i + 1][j], dp[i][j + 1] });
			}
		}
		cout << dp[s.size()][t.size()] << endl;
	}
}


Measured memory_bytes: 7200
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    for(int i=0; i<3; i++){
      a[i] = Integer.parseInt(sc.next());
    }

    Arrays.sort(a);

    System.out.println(a[0]+a[1]);
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i=0; i*4<=n; i++){
		for(int j=0; i*4+j*7<=n; j++){
			if(i*4+j*7 == n){
				cout << "Yes" << '\n';
				return 0;
			}
		}
	}
	cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    l=list(map(int,input().split()))
    for i in range(3):
        if sum(l)-l[i]==l[i]:
            print('Yes')
            exit()
    print('No')
    

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

typedef set<int> si;
typedef set<ii> sii;
typedef set<ld> sd;
typedef set<ll> sl;

typedef map<int, int> mii;
typedef priority_queue<int> pqi;
typedef queue<int> qi;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second

mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

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

    int n, ans = 0;
    cin >> n;
    int a = 0, b = 0, ba = 0;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s[0] == 'B' and s.back() == 'A') ba++;
        else if (s[0] == 'B') b++;
        else if (s.back() == 'A') a++;
        for (int i = 1; i < (int) s.length(); i++) {
            if (s[i] == 'B' and s[i - 1] == 'A') ans++;
        }
    }

    if (a == 0 and ba == 0) {
        cout << ans << endl;
        return 0;
    }

    string s = (a == 0 ? "BA" : "A");
    int ct = 0;
    if (a == 0) ba--;
    else a--;
    while (a or ba or b) {
        if (s.back() == 'A') {
            if (ba) ba--, ct++, s = "BA";
            else if (b) b--, ct++, s = "B";
            else if (a) a--, s = "A";
        }
        else {
            if (ba) ba--, s = "BA";
            else if (a) a--, s = "A";
            else if (b) b--, s = "B";
        }
    }

    cout << ans + ct << endl;
}

/*
USE LONG LONG!!!!

:pray: :fishy15:
:pray: :summitosity:
:pray: :prodakcin:

          .=     ,        =.
  _  _   /'/    )\,/,/(_   \ \
   `//-.|  (  ,\\)\//\)\/_  ) |
   //___\   `\\\/\\/\/\\///'  /
,-"~`-._ `"--'_   `"""`  _ \`'"~-,_
\       `-.  '_`.      .'_` \ ,-"~`/
 `.__.-'`/   (-\        /-) |-.__,'
   ||   |     \O)  /^\ (O/  | .        <-  BESSIE THE COW
   `\\  |         /   `\    /
     \\  \       /      `\ /
      `\\ `-.  /' .---.--.\
        `\\/`~(, '()      ('
         /(O) \\   _,.-.,_)    
        //  \\ `\'`      /
       / |  ||   `""""~"`
     /'  |__||
           `o
*/

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

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

int main() {
    int x, n;
    int p[105];
    int e[105];
    cin >> x >> n;

    for (int i = 0; i <= 101; i++) {
        e[i] = 0;
    }

    rep(i, n) {
        cin >> p[i];
        e[p[i]] = 1;
    }

    int min = 1000;
    int ans = x;
    for (int i = 0; i <= 101; i++) {
        if (e[i] == 0 && min > abs(x - i)) {
            min = abs(x - i);
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define END(x) cout << x << endl; exit(0);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int calc(ll n) {
    ll c = 0;
    for (k = 1; k <= n; k++) {
        if (n % k == 0) c++;
    }
    return c;
}

int main() {
    cin >> a >> b;
    REP(i, 0, 4) {
        if (a * b * i % 2 == 1) {
            END("Yes")
        }
    }
    MSG("No")
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  string a,q1="Sunny",q2="Cloudy",q3="Rainy";
  cin >> a;
  if(a==q1) cout << q2 << endl;
  if(a==q2) cout << q3 << endl;
  if(a==q3) cout << q1 << endl;
}

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

const double EPS = 1e-8;

vector<double> gauss_jordan(const vector< vector<double> >& A, const vector<double>& b){
    int n = A.size();
    vector< vector<double> > B(n, vector<double>(n + 1));
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < n ; ++j){
            B[i][j] = A[i][j];
        }
    }
    for(int i = 0 ; i < n ; ++i){
        B[i][n] = b[i];
    }

    for(int i = 0 ; i < n ; ++i){
        int pivot = i;
        for(int j = i ; j < n ; ++j){
            if(abs(B[j][i]) > abs(B[pivot][i])){
                pivot = j;
            }
        }
        swap(B[i], B[pivot]);

        if(abs(B[i][i]) < EPS){
            return vector<double>();
        }

        for(int j = i + 1 ; j <= n ; ++j){
            B[i][j] /= B[i][i];
        }

        for(int j = 0 ; j < n ; ++j){
            if(i != j){
                for(int k = i + 1 ; k <= n ; ++k){
                    B[j][k] -= B[j][i] * B[i][k];
                }
            }
        }
    }

    vector<double> x(n);
    for(int i = 0 ; i < n ; ++i){
        x[i] = B[i][n];
    }

    return x;
}

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

    while(n--){
        vector< vector<double> > A(2, vector<double>(2));
        vector<double> b(2);
        vector<double> x(3), y(3);
        for(int i = 0 ; i < 3 ; ++i){
            cin >> x[i] >> y[i];
        }
        A[0][0] = 2.0 * (x[0] - x[1]);
        A[0][1] = 2.0 * (y[0] - y[1]);
        b[0] = x[0] * x[0] + y[0] * y[0] - x[1] * x[1] - y[1] * y[1];
        A[1][0] = 2.0 * (x[1] - x[2]);
        A[1][1] = 2.0 * (y[1] - y[2]);
        b[1] = x[1] * x[1] + y[1] * y[1] - x[2] * x[2] - y[2] * y[2];
        vector<double> p = gauss_jordan(A, b);
        double r = sqrt((x[0] - p[0]) * (x[0] - p[0]) + (y[0] - p[1]) * (y[0] - p[1]));
        cout << fixed << setprecision(3) << p[0] << ' ' << p[1] << ' ' << r << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<62)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c;
    string ans;
    cin>>a>>b>>c;
    if(a==b&&b==c) ans="No";
    else if(a!=b&&b!=c&&c!=a) ans="No";
    else ans="Yes";
    
    
    puta(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    while (X <= Y)
    {
        ans++;
        X *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
defmodule Main do
  require Integer

  def main do
    n = IO.gets("") |> String.trim() |> String.to_integer()

    div_game(n) |> IO.puts()
  end

  @doc """
  div_game

  ## Examples

      iex> DivGame.div_game(24)
      3
      iex> DivGame.div_game(64)
      3
      iex> DivGame.div_game(1)
      0
      iex> DivGame.div_game(1000000007)
      1
      iex> DivGame.div_game(997764507000)
      7

  """
  def div_game(n) do
    M.factorization(n)
    |> Enum.map(fn [_, p] -> p end)
    |> Enum.map(&divide/1)
    |> Enum.sum()

  end

  defp divide(n) do
    Stream.iterate(1, & &1 + 1)
    |> Enum.reduce_while({n, 0}, fn i, {acc_n, acc_cnt} ->
      rem = acc_n - i
      if rem < 0, do: {:halt, {rem, acc_cnt}}, else: {:cont, {rem, acc_cnt + 1}}
    end)
    |> elem(1)
  end
end

# https://qiita.com/sym_num/items/c7ad291644a55d6c0419
defmodule M do
  def normal(n) do
    W.factor([],n,2,trunc(:math.sqrt(n)))
    |> compress
  end

  def factorization(n) when n < 10000 do
    W.factor([],n,2,trunc(:math.sqrt(n)))
    |> compress
  end
  def factorization(n) do
    limit = trunc(:math.sqrt(n))
    factors1(10,n,2,div(limit,10)+1,limit)
    factors2(10,[])
    |> Enum.sort |> sieve |> adjust(n)|> compress |> Enum.reverse
  end

  def compress(ls) do
    Enum.chunk_by(ls,fn(n) -> n end)
    |> Enum.map(fn(x) -> [hd(x),length(x)] end)
    |> Enum.reverse
  end

  def factors1(1,n,start,_,limit) do
    pid = spawn(W,:part,[])
    send pid, {self(),{n,start,limit}}
  end
  def factors1(c,n,start,add,limit) do
    stop = start + add
    pid = spawn(W,:part,[])
    send pid, {self(),{n,start,stop}}
    factors1(c-1,n,stop+1,add,limit)
  end

  def factors2(0,ls) do ls end
  def factors2(n,ls) do
    receive do
      {:answer, msg } ->
        factors2(n-1,msg++ls)
    end
  end

  def sieve([]) do [] end
  def sieve([l|ls]) do
    [l] ++ sieve(sieve1(ls,l,[]))
  end

  def sieve1([],_,res) do Enum.reverse(res) end
  def sieve1([l|ls],x,res) do
    if rem(l,x) == 0 && x != l do
      sieve1(ls,x,res)
    else
      sieve1(ls,x,[l]++res)
    end
  end

  def adjust(l,x) do
    if Enum.member?(l,x) do
      [x]
    else
      l
    end
  end

end

defmodule W do
  def part do
    receive do
      {sender,{n,start,stop}} -> send sender,{:answer, W.factor([],n,start,stop) }
    end
  end

  def factor(p,n,x,limit) do
    cond do
      n == 1 -> p
      x > limit -> [n|p]
      rem(n,x) == 0 -> factor([x|p],div(n,x),x,limit)
      x == 2 -> factor(p,n,3,limit)
      rem(x,2) == 0 -> factor(p,n,x+1,limit)
      true -> factor(p,n,x+2,limit)
    end
  end

end

Measured memory_bytes: 30884
n,y=map(int,input().split())
a=False
for i in range(n+1):
    for j in range(n-i+1):
        total=10000*i+5000*j+1000*(n-j-i)
        if total==y:
            a=True
            b=i
            c=j
            d=n-j-i
            break
if a:
    print(b,c,d)
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
using int64 = long long;
const double INF = 1e18;
 
int N, K;
vector< int > g[100000];
int subtree_size[100000];
int dp[100000];
 
int dfs(int idx, int par)
{
  subtree_size[idx] = 1;
  int add = 0, ret = 0;
  vector< int > vs;
  for(auto &to : g[idx]) {
    if(to == par) continue;
    ret = max(ret, dfs(to, idx));
    subtree_size[idx] += subtree_size[to];
    add += subtree_size[to] >= K;
    vs.emplace_back(dp[to]);
  }
  if(vs.empty()) return (0);
  sort(vs.rbegin(), vs.rend());
  dp[idx] = max(add, vs[0] + add - 1);
 
  if(N - subtree_size[idx] >= K) ++add;
  ret = max(ret, vs[0] + add - 1);
  if(g[idx].size() > add) ret = max(ret, add);
  if(vs.size() >= 2) ret = max(ret, vs[0] + vs[1] + add - 2);
  return (ret);
}
 
int main()
{
  cin >> N >> K;
  for(int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  cout << dfs(0, -1) << endl;
}

Measured memory_bytes: 18516
function F1(m,b,c){
   var sum=0;
   for(var i=0;i<Y;i++){
      sum+=Math.floor(m*b);
      m-=c;
   }
   return m+sum;
}
function F2(m,b,c){
   for(var i=0;i<Y;i++){
      m+=Math.floor(m*b)-c;
   }
   return m;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var M=Arr.shift()-0;
for(var i=0;i<M;i++){
   var money=Arr.shift()-0;
   var Y=Arr.shift()-0;
   var N=Arr.shift()-0;
   var arr=[];
   for(var j=0;j<N;j++){
      var D=(Arr.shift()).split(" ").map(Number);
      if(D[0]==0)arr.push(F1(money,D[1],D[2]));
      if(D[0]==1)arr.push(F2(money,D[1],D[2]));
   }
   console.log(Math.max.apply(null,arr));
}

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

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

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	
	string S, T;
	int sum = 0;
	
	cin >> S >> T;
	
	for(int i = 0;i < S.length();i++){
		if( S[i] != T[i] ){
			sum++;
		}
	}
	
	cout << sum;
	
	return 0;
	
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
void sc(int& x){x=0;char c=getchar();while(c>'9' || c<'0')c=getchar();
for(;c>='0' && c<='9';c=getchar())x=x*10+c-'0';
}
typedef long long ll;
typedef double db;
const int N=2017;
const int M=N*N;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};
char s[N][N];
int n,m,vis[N][N],fa[M];
int id(int x,int y){
	return (x-1)*m + y;
}
bool pan(int x,int y){
	if(x<1 || x>n || y<1 || y>m || vis[x][y] || s[x][y]!='1')return false;
	return true;
}
void dfs(int x,int y){
	vis[x][y]=1;
	rep(k,0,3){
		int nx=x+dx[k],ny=y+dy[k];
		if(pan(nx,ny)){
			fa[id(nx,ny)] = id(x,y);
			dfs(nx,ny);
		}
	}
}
vector<int> d[4][N];
int sum[N][N],SUM;

int Q(int a,int b,int c,int d){a--,b--;
	return sum[c][d] - sum[c][b] - sum[a][d] + sum[a][b];
}
int query(int op,int pos,int L,int R){
	if(!d[op][pos].size())return 0;
	
	int l=lower_bound(d[op][pos].begin(),d[op][pos].end(),L)-d[op][pos].begin();
	int r=upper_bound(d[op][pos].begin(),d[op][pos].end(),R)-d[op][pos].begin()-1;
	
	return r-l+1;
}
int q;
int main(){
	sc(n),sc(m),sc(q);
	rep(i,1,n){
		scanf("%s",s[i]+1);
	}
	rep(i,1,n)rep(j,1,m)if(!vis[i][j] && s[i][j]=='1'){
		SUM++;
		sum[i][j]++;
		dfs(i,j);
	}
	rep(i,1,n)rep(j,1,m)sum[i][j] += sum[i][j-1] + sum[i-1][j] - sum[i-1][j-1]; 
	
	memset(vis,0,sizeof(vis));
	rep(i,1,n)rep(j,1,m)if(s[i][j]=='1'){
		rep(k,0,3){
			int nx=i+dx[k],ny=j+dy[k];
			if(pan(nx,ny)){
				if(fa[id(i,j)] == id(nx,ny)){
					
					if(k<2)d[k][j].push_back(i);
					else d[k][i].push_back(j);
				}
			}
		}
	}
	int x1,y1,x2,y2,ans;
	rep(i,1,q){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		ans=Q(x1,y1,x2,y2);
		
		ans+=query(3,x1,y1,y2);
		ans+=query(2,x2,y1,y2);
		ans+=query(1,y1,x1,x2);
		ans+=query(0,y2,x1,x2);
		
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 71296
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

bool line(double x1, double y1, double x2, double y2, double xp, double yp){
    return (yp-y1)*(x2-x1) - (y2-y1)*(xp-x1) > 0;
}

int main(){
    vector<double> p(6);
    double xp, yp;
    while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> xp >> yp){
        bool yes = true;
        for(int i = 0; i < 3; i++){
            yes &= !(line(p[0],p[1],p[2],p[3],p[4],p[5]) ^ line(p[0],p[1],p[2],p[3],xp,yp));
            rotate(p.begin(), p.begin()+2, p.end());
        }
        cout << (yes ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 1216
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int arr[]=new int[n];
        HashMap<Integer,Integer> hashMap=new HashMap<>();
        HashMap<Integer,Long> ans=new HashMap<>();
        List<Integer> list=new ArrayList<>();
        HashSet<Integer> hashSet=new HashSet<>();
        for(int j=0;j<n;j++){
            arr[j]=scanner.nextInt();
            if(hashMap.get(arr[j])==null){
                hashMap.put(arr[j],1);
            }
            else{
                hashMap.put(arr[j],hashMap.get(arr[j])+1);
                if(!hashSet.contains(arr[j])) {
                    list.add(arr[j]);
                    hashSet.add(arr[j]);
                }
            }
        }
        long tot=0;
        for(int i=0;i<list.size();i++){

                //tot+=(long)((long)(hashMap.get(list.get(i))-1)*(long)(hashMap.get(list.get(i))-2))/(long)2;
                tot+=(long)((long)(hashMap.get(list.get(i))-1)*(long)(hashMap.get(list.get(i))))/(long)2;


        }
        for(int j=0;j<n;j++)
        {
            if(ans.get(arr[j])==null){
                long tott=0;
                if(hashMap.get(arr[j])==1){
                    tott=tot;
                }
                else {
                    tott = (long)tot - (long)((hashMap.get(arr[j]) - 1) * (hashMap.get(arr[j])))/2 +
                            (long)((hashMap.get(arr[j]) - 1) * (hashMap.get(arr[j])-2))/2 ;
                }
                ans.put(arr[j],tott);
                System.out.println(tott);
            }
            else{
                System.out.println(ans.get(arr[j]));
            }
        }

    }
}


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

using namespace std;

int main()
{
int n;
cin>>n;
int arr[10001]={0};
for(int i=1; i<=n; i++) {
    for(int j=1; j<=n; j++) {
        for(int k = 1; k<=n; k++) {
            int x =(i*i) + (j*j) + (k*k) + (i*j) + (j*k) + (k*i);
        if(x > n) break;

        else arr[x]++;

        }
    }
}
for(int i=1; i<=n; i++) {
    cout<<arr[i]<<endl;
}
return 0;
}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int k;
	while (cin >> k, k) {
		int sum(0);
		rep(i, 0, k*(k-1)/2) {
			int a; cin >> a;
			sum += a;
		}
		cout << sum / (k - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,sys.stdin.readline().split())

fib={0:0,1:1,2:1}
for i in range(3,100003):
    fib[i]=fib[i-1]+fib[i-2]
  #  fib.append(fib[i-1]+fib[i-2])

n,m=intinput()
mod=10**9+7
a=[int(sys.stdin.readline()) for _ in range(m)]
if m!=0:
    l=[a[0]]
    for i in range(len(a)-1):
        l.append(a[i+1]-a[i]-1)
    l.append(n-a[-1])
    k=1
    for i in l:
        k=fib[i]*k%mod
    print(k%mod)
else:
    print(fib[n+1]%mod)

Measured memory_bytes: 473344
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

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

	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n - 1);
	rep(i, n - 1) cin >> a[i];
	rep(i, n) a[i]--;

	vector<int> b(n);
	rep(i, n - 1) {
		b[a[i]]++;
	}
	rep(i, n) cout << b[i] << endl;

	return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair


int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    string s;
    cin >> s;
    int n = (int)s.length();
    int ans = n;
    for (char c : s) {
        int res = 0;
        int l = 0;
        while(l < n) {
            if (s[l] == c) {
                l++;
                continue;
            }
            int r = l;
            while(r < n && s[r] != c) r++;
            res = max(res, r - l);
            l = r;
        }
        ans = min(ans, res);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n+1];
        for(int i=1; i<=n; i++) {
            p[i] = sc.nextInt();
        }
        int count = 0;
        for(int i=1; i<=n; i++) {
            if(p[i] != i) {
                for(int j=i+1; j<=n; j++) {
                    if(p[j] == i) {
                        p[j] = p[i];
                        p[i] = i;
                        count++;
                        if(count >= 2) {
                            System.out.println("NO");
                            return;
                        }
                    }
                }
            }
        }
        System.out.println("YES");
    }
}

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

const int MAXN = 1e5 + 21;

int n;
long long a[MAXN][3], dp[MAXN][3];

int main() {
  	ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    dp[1][0] = a[1][0];
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];

    for (int i = 2; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + a[i][2];
    }
    long long mx;
    mx = max(dp[n][0], max(dp[n][1], dp[n][2]));

    cout << mx << '\n';
    return 0;
}   


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;
const int maxN = 2e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
const int inf = 1e9+10;
#define X first;
#define Y second;

ll c[maxN];

int main() {
	int n;
	scanf("%d",&n);
	int f = 0;
	for(int x =1;x<=9;x++)
	{
		if(n%x == 0)
		{
			if(n/x <= 9)
			{
				f = 1;
				puts("Yes");
				break;
			}
		}
	}
	if(!f)
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    char[] ns = scanner.next().toCharArray();
    int N = ns.length;
    for (int i = 0; i < N; i++) ns[i] = (char) (ns[i] - '0');
    int K = scanner.nextInt();

    long[][] dp1 = new long[N + 1][K + 1];
    long[][] dp2 = new long[N + 1][K + 1];
    dp2[0][0] = 1;
    for (int i = 1; i <= N; i++) {
      dp1[i][0] = 1;
      for (int j = 1; j <= K; j++) {
        dp1[i][j] = dp1[i - 1][j] + 9 * dp1[i - 1][j - 1];
        if (ns[i - 1] != 0) dp1[i][j] += dp2[i - 1][j] + (ns[i - 1] - 1) * dp2[i - 1][j - 1];
        dp2[i][j] = ns[i - 1] == 0 ? dp2[i - 1][j] : dp2[i - 1][j - 1];
      }
    }
    System.out.println(dp1[N][K] + dp2[N][K]);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int a,b;
	while(!cin.eof()){
		if(cin.eof()) goto endrt;
		int zz[101]={0};
		int ing=-999, oug;
		while(cin >> a >>b){
			if(a==0 && b==0) break;
			if(cin.eof()) goto endrt;
			zz[a]++;
			zz[b]++;
			oug=b; if(ing<0) ing=a;
		}
		bool ans=true;
		if(!(zz[ing] % 2 && zz[oug] % 2 )) ans=false;
		rep(i,101) if(i != ing && i != oug && zz[i] % 2 ) ans=false;
//		rep(i,101) if(zz[i] > 0){printf("%d:%d, ",i,zz[i]); } printf("\n"); 
		if(ing>0) cout << (ans? "OK": "NG") << endl;
	
	}
	endrt:
	return 0;
	
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<pair<int, int>> p(N);
  int cnt;
  
  for(int i = 0; i < N; ++i){
    cin >> p.at(i).first;
    p.at(i).second = i;
  }
  
  sort(p.begin(), p.end());
  
  for(int i = 0; i < N; ++i){
    if(p.at(i).second != i) cnt++;
  }
  
  if(cnt == 0 || cnt == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
  ll A,B,Q;
  cin>>A>>B>>Q;
  vector<ll> shr(A);
  vector<ll> tem(B);
  vector<ll> que(Q);
  for(ll i = 0LL; i < A; i++) cin>>shr[i];
  for(ll i = 0LL; i < B; i++) cin>>tem[i];
  for(ll i = 0LL; i < Q; i++) cin>>que[i];
  vector<ll> nt(A);
  vector<ll> ns(B);
  ll k = 0LL;
  for(ll i = 0LL; i < A; i++) {
    auto a = lower_bound(tem.begin(),tem.end(),shr[i]);
    if(a==tem.end())nt[i]=abs(shr[i]-tem[B-1LL]);
    else if(a==tem.begin())nt[i]=abs(shr[i]-tem[0]);
    else nt[i]=min(abs(shr[i]-*a),abs(shr[i]-*(a-1)));
  }
  for(ll i = 0LL; i < B; i++) {
    auto a = lower_bound(shr.begin(),shr.end(),tem[i]);
    if(a==shr.end())ns[i]=abs(tem[i]-shr[A-1LL]);
    else if(a==shr.begin())ns[i]=abs(tem[i]-shr[0]);
    else ns[i]=min(abs(tem[i]-*a),abs(tem[i]-*(a-1)));
  }
  for(auto x:que){
    ll pasa=0LL,pasb=0LL;
    auto a = lower_bound(tem.begin(),tem.end(),x);
    if(a==tem.end()){
      pasa+=abs(x-tem[B-1LL]);
      pasa+=ns[B-1LL];
    }
    else if(a==tem.begin()){
      pasa+=abs(x-tem[0]);
      pasa+=ns[0];
    }
    else {
      pasa+=min(abs(x-*a)+ns[a-tem.begin()],abs(x-*(a-1))+ns[a-1-tem.begin()]);
    }
    auto b = lower_bound(shr.begin(),shr.end(),x);
    if(b==shr.end()){
      pasb+=abs(x-shr[A-1LL]);
      pasb+=nt[A-1LL];
    }
    else if(b==shr.begin()){
      pasb+=abs(x-shr[0LL]);
      pasb+=nt[0];
    }
    else {
      pasb+=min(abs(x-*b)+nt[b-shr.begin()],abs(x-*(b-1))+nt[b-1-shr.begin()]);
    }
    cout<<min(pasa,pasb)<<endl;
  }
}

Measured memory_bytes: 5248
n = int(input())
numbers = [ int(i) for i in input().split()]
if 0 in numbers:
    print(0)
else:
    result = 1

    max = 10**18
    for i in range(n):
        result *= numbers[i]    
        if result > max:
            break


    if result > max:
        print(-1)
    else:
        print(result)


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

int solve(long long x){
  long long z = 2*x+1;
  for(long long y=3ll;y*y<=z;y+=2){
    if(z%y==0)return 0;
  }
  return 1;
}

int main(void){
  int n;
  scanf("%d",&n);
  int ans = 0;
  while(n--){
    long long x;
    scanf("%lld",&x);
    ans += solve(x);
  }
  printf("%d\n",ans);
}



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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const ll maxWH = 100000;
const ll mod = 1e9+7;
vector<ll> fact;
ll add(ll a, ll b) {
    return (a + b) % mod;
}
ll mul(ll a, ll b) {
    return a * b % mod;
}
ll power(ll x, ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i <<= 1) {
        if (i & n) res = mul(res, x);
        x = mul(x, x);
    }
    return res;
}
ll inv(ll n) {
    return power(n, mod-2);
}
ll divi(ll a, ll b) {
    return mul(a, inv(b));
}
ll init() {
    fact.assign(maxWH*2+1, 1);
    FOR(i, 1, fact.size()) {
        fact[i] = mul(fact[i-1], i);
    }
}
ll comb(ll n, ll r) {
    // cout << n << " " << r << " " << n-r << endl;
    return divi(fact[n], mul(fact[r], fact[n-r]));
}
ll go(ll x1, ll y1, ll x2, ll y2) {
    ll w = x2-x1+1, h = y2-y1+1;
    return comb(w-1+h-1, w-1);
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    init();
    ll H, W, A, B; cin >> H >> W >> A >> B;
    ll ans = 0;
    REP(i, min(H-A, W-B)) {
        ll x = B+1+i, y = H-A-i;
        ans = add(ans, mul(go(1, 1, x, y), go(x, y, W, H)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
main(){double a,l,x,s,t;
for(;~scanf("%lf%lf%lf",&a,&l,&x);)
s=(l+l+a)/2,t=(l+x+l)/2,printf("%lf\n",sqrt((s-l)*(s-l)*(s-a)*s)+2*sqrt((t-(l+x)/2)*(t-(l+x)/2)*(t-l)*t));exit(0);}

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

int main() {
	string s;
	cin >> s;
	vector<int> d(s.size());
	for (int i = 0; i < s.size(); ++i) {
		d[i] = (int)(s[i] - '0');
	}

	int res = 1e8;
	for (int i = 0; i <= s.size() - 3; ++i) {
		int n = d[i] * 100 + d[i + 1] * 10 + d[i + 2];

		res = min(res, abs(753 - n));
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, a, b) for(int i=(a); i<(int)(b); i++)

typedef long long ll;

using namespace std;

int dx[] ={-1, 0, 0, 1};
int dy[] ={0, -1, 1, 0};

int main(void){
	string s; cin >> s;

	ll dp[15] ={0};
	dp[0] = 1;
	ll mul = 1;
	int len = s.length();

	rep(i, len){
		ll nextDP[15]={0};
		char ch = s[len-i-1];
		if(ch == '?'){
			rep(k, 10){
				rep(j, 13){
					nextDP[(k * mul + j) % 13] += dp[j];
					nextDP[(k * mul + j) % 13] %= MOD;
				}
			}
		} else{
			int k = ch - '0';
			rep(j, 13){
				nextDP[(k * mul + j) % 13] += dp[j];
				nextDP[(k * mul + j) % 13] %= MOD;
			}
		}
		mul *= 10;
		mul %= 13;
		copy(nextDP, nextDP+13, dp);
	}

	cout << dp[5] << endl;
	return 0;
}

Measured memory_bytes: 512
def factorial2(n)
  arr = [*1..n]
    return 1 if n== 0
  loop do
    return arr[0] if arr.length == 1
    arr = arr.each_slice(2).map { |a, b| b ? a * b : a }
  end
end
 
n, k =gets.strip.split.map(&:to_i)
c=a=factorial2(k-1)
k.times do |i|
  i += 1
  combi=1
    i.times{|f|combi=combi*((n-k+1)-f)/(f+1) }
  a=factorial2(k-i)
  b=factorial2(i-1)
  puts combi*c/(a*b)%1000000007
end

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

const int inf=0x3f;
int h[100005],dp[100005];

signed main()
{
	int n;
	while(cin>>n){
		for(int i=1;i<=n;i++)cin>>h[i];
		memset(dp,inf,sizeof dp);
		
		dp[1]=0,dp[2]=abs(h[2]-h[1]);
		for(int i=3;i<=n;i++){
			dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		}
		cout<<dp[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4400
#include<bits/stdc++.h>
#define For(i, j, k) for(register int i = j; i <= k; ++i)
#define Forr(i, j, k) for(register int i = j; i >= k; --i)
using namespace std;

namespace pb_ds {

    namespace io {
        const int MaxBuff = 1 << 16;
        const int Output = 1 << 22;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
        char Out[Output], *iter = Out;
        inline void flush() {
            fwrite(Out, 1, iter - Out, stdout);
            iter = Out;
        }
    }

    template<class Type> inline Type read() {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }

    template<class Type> inline void write(register Type x, register char ch = '\n') {
        using namespace io;
        if(!x) *iter++ = '0';
        else {
            if(x < 0) *iter++ = '-', x = -x;
            static int s[100]; register int t = 0;
            while(x) s[++t] = x % 10, x /= 10;
            while(t) *iter++ = '0' + s[t--];
        }
        *iter++ = ch;
    }
}

using namespace pb_ds;

long long f[1000005], sum[1000005], a[1000005];
int n, m, cnt;

int main() {
	a[++ cnt] = n = read<int>(), m = read<int>();
	For(i, 1, m) {
		long long x = read<long long>();
		while (*(a + cnt) >= x) -- cnt;
		*(a + (++ cnt)) = x;
	}

	*(sum + cnt) = 1;
	Forr(i, cnt, 2) {
		*(sum + i - 1) += (*(sum + i) * (*(a + i) / *(a + i - 1)));
		long long res = *(a + i) % *(a + i - 1);

		for (;;) {
			if (res == 0) break;
			int x = upper_bound(a + 1, a + 1 + cnt, res) - a - 1;
			if (x == 0) { *(f + res) += *(sum + i); break; }
			*(sum + x) += (res / *(a + x)) * (*(sum + i)), res %= *(a + x);
		}
	}
	*(f + *(a + 1)) = *(sum + 1);
	register int i;
	for (i = n - 1; i >= 8; i -= 8) {
		*(f + i) += *(f + i + 1);
		*(f + i - 1) += *(f + i);
		*(f + i - 2) += *(f + i - 1);
		*(f + i - 3) += *(f + i - 2);
		*(f + i - 4) += *(f + i - 3);
		*(f + i - 5) += *(f + i - 4);
		*(f + i - 6) += *(f + i - 5);
		*(f + i - 7) += *(f + i - 6);
	}
	for (; i >= 1; --i) *(f + i) += *(f + i + 1);
	
	for (i = 1; i <= n - 8; i += 8) {
		write(*(f + i), '\n');
		write(*(f + i + 1), '\n');
		write(*(f + i + 2), '\n');
		write(*(f + i + 3), '\n');
		write(*(f + i + 4), '\n');
		write(*(f + i + 5), '\n');
		write(*(f + i + 6), '\n');
		write(*(f + i + 7), '\n');
	}

	for (; i <= n; ++ i) write(*(f + i), '\n');

	io::flush();
	return 0;
}


Measured memory_bytes: 14848
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = 1,b = n - a;
        int min = Integer.MAX_VALUE;
        while (a <= b){
            char[] acr = String.valueOf(a).toCharArray();
            char[] bcr = String.valueOf(b).toCharArray();
            int t = 0;
            for (char ac:acr){
                t += Integer.valueOf(String.valueOf(ac));
            }
            for (char bc:bcr){
                t += Integer.valueOf(String.valueOf(bc));
            }
            min = min > t ? t : min;
            ++a;
            --b;
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 40772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//１は複数存在しない！

int main()
{
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a));

    int ans = 0;
    int right = 0;
    while(1)
    {
        if (ans == 0) right += k;
        else right += k - 1;
        ans++;

        if (right >= n) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<vector>
using namespace std;
string S, T;
int L, R, N, M;
vector<int>vec[500000];
vector<int>vec2[500000];
int main() {
	cin >> N >> M;
	cin >> S;
	for (int i = 0; i < M; i++) {
		cin >> T;
		if (T == "L++") { L++; }
		if (T == "L--") { L--; }
		if (T == "R++") { R++; }
		if (T == "R--") { R--; }
		for (int j = 0; j < vec2[R - L].size(); j++) {
			for (int k = 0; k <= R - L; k++) {
				if (S[vec2[R - L][j] + k] != S[L + k]) {
					goto F;
				}
				if (R - L >= 10000) { k += 30; }
			}
			goto E;
		F:;
		}
		vec[L].push_back(R);
		vec2[R - L].push_back(L);
	E:;
	}
	int sum = 0;
	for (int i = 0; i < 500000; i++) { sum += vec[i].size(); }
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 35472
#include<cstdio>
using namespace std;
long long n,f[200];  
int main()
{
  scanf("%lld",&n);f[0]=2;
  for(int i=1;i<=n;i++)  f[i]=f[i-1]*2+2;
  printf("%lld\n",f[n]);
  return 0;
}

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

#define forn(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) begin(x),end(x)
#define ll long long
#define vi vector<int>

using namespace std;


int main(){
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        string s,t;
        cin>>s>>t;
        cout<<t+s;
        return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = []
for _ in range(H): C.append([c for c in input()])
ans = 0
for i in range(1<<H):
    for j in range(1<<W):
        cnt = 0
        for m in range(H):
            for n in range(W):
                if i>>m&1: continue
                if j>>n&1: continue
                if C[m][n] == '#': cnt += 1
        if cnt == K: ans += 1
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n,x;
    cin >> n >> x;
    int mn = 1e9;
    rep(i,n){
        int y;
        cin >> y;
        x-=y;
        mn = min(mn,y);
    }
    cout << n+x/mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
   int n,t;
   cin>>n>>t;
   int a[n],b[n];
   int cost=1001;
   rep(i,n){
     cin>>a[i]>>b[i];
     if(b[i]<=t){
       cost=min(cost,a[i]);
     }
   }
  if(cost!=1001){
    cout<<cost<<endl;
  }else{
    cout<<"TLE"<<endl;
  }
}


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

public class Main
{
  
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String sl[];

    sl = r.readLine().split(" ");
    int n = Integer.parseInt(sl[0]);
    int d = Integer.parseInt(sl[1]);
    
    int v[][] = new int[n][d];
    
    for(int i = 0; i < n; i++)
    {
      sl = r.readLine().split(" ");
      for(int j = 0; j < d; j++)
      {
        v[i][j] = Integer.parseInt(sl[j]);
      }
    }
    int a = 0;
    for(int i = 0; i < n; i++)
    {
      for(int j = i + 1; j < n; j++)
      {
        int s = 0;
        for(int k = 0; k < d; k++)
        {
          s += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
        }
        int k = 0;
        for(k = 0; k * k < s; k++);
        if(k * k == s)
        {
          a++;
        }
      }
    }

    System.out.println(a);
    
  }

}

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

int main(){
    string s; cin >> s;
    for(int i = s.size()-1; i >= 0; i--){
        if(i >= 5 && s[i] == 'r' && s[i-1] == 'e' && s[i-2] == 's' && s[i-3] == 'a' && s[i-4] == 'r' && s[i-5] == 'e'){
            i -= 5;
        }else if(i >= 4 && s[i] == 'e' && s[i-1] == 's' && s[i-2] == 'a' && s[i-3] == 'r' && s[i-4] == 'e'){
            i -= 4;
        }else if(i >= 6 && s[i] == 'r' && s[i-1] == 'e' && s[i-2] == 'm' && s[i-3] == 'a' && s[i-4] == 'e' && s[i-5] == 'r' && s[i-6] == 'd'){
            i -= 6;
        }else if(i >= 4 && s[i] == 'm' && s[i-1] == 'a' && s[i-2] == 'e' && s[i-3] == 'r' && s[i-4] == 'd'){
            i -= 4;
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <fstream> 
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <math.h>
#include <cmath>
using namespace std;
int main(){	
   int a,b,c;
   cin >> a >> b >> c;
   cout << (a+b)*c/2; 	
}

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

using namespace std;

int main() {
	int n;

	while(true) {
		cin >> n;

		if(!n) {
			break;
		}

		vector< vector< int > > score(n, vector< int >(5, 0));
		vector< int > point(n, 0);

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

		for(int i = 0; i < n; i++) {
			int tmp = 0;
			for(int j = 0; j < 5; j++) {
				tmp += score[i][j];
			}
			point[i] = tmp;
		}

		int p_max = 0, p_min = INT_MAX / 4;

		for(int i = 0; i < n; i++) {
			p_max = max(p_max, point[i]);
			p_min = min(p_min, point[i]);
		}

		cout << p_max << " " << p_min << endl;
	}
}

Measured memory_bytes: 1224