akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int H, W; 
  std::cin >> H >> W;

  std::vector<std::vector<int>> A(H, std::vector<int>(W));
  rep(i,H) rep(j,W) std::cin >> A[i][j];

  std::vector<std::vector<int>> B(H, std::vector<int>(W));
  rep(i,H) rep(j,W) std::cin >> B[i][j];

  constexpr int KMAX = 15000;
  bool dp[H][W][KMAX] = { {false} };
  dp[0][0][std::abs(A[0][0]-B[0][0])] = true;

  rep(i, H) rep(j, W) rep(k, KMAX) {
    if ( i + 1 < H && dp[i][j][k] == true ) {
      dp[i+1][j][std::abs(k+std::abs(A[i+1][j]-B[i+1][j]))] = true;
      dp[i+1][j][std::abs(k-std::abs(A[i+1][j]-B[i+1][j]))] = true;
    }
    if ( j + 1 < W && dp[i][j][k] == true ) {
      dp[i][j+1][std::abs(k+std::abs(A[i][j+1]-B[i][j+1]))] = true;
      dp[i][j+1][std::abs(k-std::abs(A[i][j+1]-B[i][j+1]))] = true;
    }
  }
  
  rep(k, KMAX) {
    if ( dp[H-1][W-1][k] ) {
      std::cout << k << std::endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 93952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    ll f[100][14];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<10;j++){
            cin >> f[i][j];
        }
    }
    ll p[100][15];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<11;j++){
            cin >> p[i][j];
        }
    }
    ll ans=-1e10;
    for(ll tmp=1;tmp<(1<<10);tmp++){
        ll x=0;
        for(ll i=0;i<n;i++){
            ll y=0;
            for(ll j=0;j<10;j++){
                if((tmp>>j&1)&&f[i][j]==1)y++;
            }
            x+=p[i][y];
        }
        ans=max(ans,x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
open Printf
open Scanf

let id x = x

type state = {h : int; sp : int; bd : int array}

let () =
  let n = 4 in
  let isp = ref 0 in
  let bd = Array.init (n * n) (fun i -> let v = scanf "%d " id in if v = 0 then isp := i; v) in
  let dist bd = Array.fold_left (fun (i, d) x ->
                                 if x = 0 then (i+1, d)
                                 else
                                   let r, c = (i / n, i mod n) in
                                   let y = x - 1 in
                                   let r', c' = (y / n, y mod n) in
                                   (i + 1, d + abs (r - r') + abs (c - c'))
                                ) (0, 0) bd |> snd in
  let rec dfs st d pd limit =
    if st.h = 0 then Some d
    else if d + st.h > limit then None
    else List.fold_left (fun v (dx, dy) ->
                         match v with
                           Some _ -> v
                         | None -> 
                            let x, y = (st.sp / n, st.sp mod n) in
                            let nx, ny = (dx + x, dy + y) in
                            let npd = 2 * dx + dy in
                            if 0 <= nx && nx < n && 0 <= ny && ny < n && npd + pd <> 0 then
                              let nsp = n * nx + ny in
                              let nbd = Array.copy st.bd in
                              begin
                                nbd.(st.sp) <- st.bd.(nsp);
                                nbd.(nsp) <- 0;
                                let nst = {h = dist nbd; sp = nsp; bd = nbd} in
                                dfs nst (d+1) npd limit
                              end
                            else None
                        ) None [(1,0);(0,1);(-1,0);(0,-1)]
  in
  let rec loop st limit =
    if limit = 100 then failwith "15 puzzle"
    else
      match dfs st 0 0 limit with
        None -> loop st (limit + 1)
      | Some x -> x
  in
  let ih = dist bd in loop {h = ih; sp = !isp; bd = bd} ih |> printf "%d\n"

Measured memory_bytes: 4544
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define pub push_back
#define pii pair<int, int>
#define vi vector<int> 
#define fst first
#define snd second
using namespace std;
string s, ns;
int lft = 0, rg = 0;
vector<pii> v;
bool cp(const pii &l, const pii &r)
{
	return make_pair(l.snd, l.fst) > make_pair(r.snd, r.fst);
}
int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		for (int j = 0; j < s.size(); j++)
		{
			if (s[j] == '(') {ns.pub('(');}
			else
			{
				if (ns.size() && ns.back() == '(') {ns.pop_back();}
				else {ns.pub(')');}
			}
		}
		if (ns.size())
		{
			int j = 0;
			for (j = 0; j < ns.size() && ns[j] == ')'; j++) {}
			if (j == 0) {lft += ns.size();}
			else {v.pub({j, ns.size() - j});}
		}
		ns.clear();
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++)
	{
		if (v[i].snd - v[i].fst >= 0)
		{
			if (v[i].fst <= lft) {lft += v[i].snd - v[i].fst;}
			else {cout << "No\n"; return 0;}
		}
	}
	sort(v.begin(), v.end(), cp);
	for (int k = 0; k < v.size(); k++)
	{
		if (v[k].snd - v[k].fst < 0)
		{
			if (v[k].fst <= lft) {lft += v[k].snd - v[k].fst;}
			else {cout << "No\n"; return 0;}
		}
	}
	if (lft == 0) {cout << "Yes\n";}
	else {cout << "No\n";}
	return 0;
}

Measured memory_bytes: 7372
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

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


int main(){
  ll N;cin>>N;
  vector<ll> t(N);
  rep(i,N) cin>>t[i];
  ll ans = 1;
  rep(i,N){
    ans = ans / gcd(ans,t[i]);
    ans *= t[i];
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


vector<ll> z_algorithm(vector<char> &S){
  vector<ll> A(S.size());
  A[0] = S.size();

  ll x = 1, y = 0;
  while (x < S.size()) {
    while (x+y < S.size() && S[y] == S[x+y]){
      y++;
    }
    A[x] = y;
    if (y == 0) {
      x++;
      continue;
    }
    int k = 1;
    while (x+k < S.size() && k+A[k] < y){
      A[x+k] = A[k];
      k++;
    }
    x += k;
    y -= k;
  }
  return A;
}

void solve(long long N, std::string S){
  ll rst = 0;
  for(ll i=0; i<S.size(); i++){
    // 部分文字列を作る。
    vector<char> subs(S.begin()+i, S.end());
    //for(ll j=i; j<S.size(); j++){
      //subs[j-i] = S[j];
    //}

    // z-algorithm で、一致する長さを求める。
    vector<ll> Z = z_algorithm(subs);

    // 重なっていてはいけないので、重なっていない最大長にする。
    for(ll k=0; k<subs.size(); k++){
      if(Z[k] > k) Z[k] = k;
    }

    // 最長を計算
    for(ll k=0; k<subs.size(); k++){
      if(Z[k] > rst) rst = Z[k];
    }
  }
  cout << rst << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}

  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int a, p;
	cin >> a >> p;
	int apple = 3 * a + p;
	cout << apple / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

//入力
int n, w;
ll W[110];
ll v[110];
ll dp[110][100100];

int main()
{
    cin >> n >> w;
    for (int i = 0; i < n; i++)
    {
        cin >> W[i] >> v[i];
    }
    for (int i = 0; i <= w; i++)
    {
        dp[0][i] = 0;
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            if (j >= W[i])
            {
                dp[i + 1][j] = max(dp[i][j - W[i]] + v[i], dp[i][j]);
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    printf("%lld\n", dp[n][w]);
}

Measured memory_bytes: 80128
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n,m;std::cin >> n >> m;
  std::map<int, std::vector<std::string>> mp;
  REP(i,m) {
    int temp_p;
    std::string temp_s;
    std::cin >> temp_p >> temp_s;
    mp[temp_p].PB(temp_s);
  }
  int ans = 0;
  int ac_counter = 0;
  for (auto& x:mp){
    int temp=0;
    bool flag=false;
    for (auto & element : x.S) {
      if (element == "WA") temp++;
      else if (element == "AC") {
        ac_counter++;
        flag=true;
        break;
      }
    }
    if (flag) {
      ans+=temp;
    }
  }
  std::cout << ac_counter <<' ' << ans << '\n';

  return 0;
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var X = int.Parse(input[0]);
            var N = int.Parse(input[1]);
            if (N == 0)
            {
                Console.WriteLine(X);
                return;
            }

            var p = new int[N];
            var inputp = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                p[i] = int.Parse(inputp[i]);
            }

            var dis = int.MaxValue;
            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                var tempDis = Math.Abs(p[i] - X);
                if (dis > tempDis)
                {
                    dis = tempDis;
                    ans = p[i];
                }
            }

            var searchNum = ans;
            var positiveMinNum = 0;
            var positiveDis = 0;
            var negativeMinNum = 0;
            var negativeDis = 0;
            //数直線上のx軸で考えた場合正の方向に走査
            while (true)
            {
                searchNum++;
                if (!p.Contains(searchNum))
                {
                    positiveMinNum = searchNum;
                    positiveDis = Math.Abs(positiveMinNum - X);
                    break;
                }
            }
            searchNum = ans;
            while (true)
            {
                searchNum--;
                if (!p.Contains(searchNum))
                {
                    negativeMinNum = searchNum;
                    negativeDis = Math.Abs(negativeMinNum - X);
                    break;
                }
            }

            if (positiveDis >= negativeDis)
            {
                Console.WriteLine(negativeMinNum);
            }
            else
            {
                Console.WriteLine(positiveMinNum);
            }
        }
    }
}


Measured memory_bytes: 18840
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int n;
    cin>>n;
    vll a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    ll x=a[0];
    for(int i=1;i<n;i++) x^=a[i];
    for(int i=0;i<n;i++)
    {
        ll p=x^a[i];
        cout<<p<<" ";
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 4764
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a[5];
  while (scanf("%d%d%d%d%d", a, a+1, a+2, a+3, a+4) == 5) {
    bool b[3] = {0};
    for (int i = 0; i < 5; i++)
      b[a[i]-1] = true;
    if (b[0] && b[1] && b[2] ||
        b[0] && !b[1] && !b[2] ||
        !b[0] && b[1] && !b[2] ||
        !b[0] && !b[1] && b[2])
      for (int i = 0; i < 5; i++)
        cout << 3 << endl;
    else {
      int w;
      if (b[0] && b[1])
        w = 1;
      else if (b[1] && b[2])
        w = 2;
      else
        w = 3;
      for (int i = 0; i < 5; i++)
        cout << (a[i] == w ? 1 : 2) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
// 卍 嘘解上等 卍
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
int main() {
    lint n; cin >> n;
    vector<lint> a(n);
    rep(i,n) cin >> a[i];
    bool ans = false;
    sort(a.begin(),a.end(), greater<lint>());
    multiset<lint> setA;
    for(int i=1; i<n; i++) setA.insert(a[i]);
    vector<lint> r(n+1);
    r[0] = a[0];
    r[n] = a[0];
    for(int i=1; i<n; i++) {
        setA.erase(setA.find(a[i]));
        lint want = r[0] ^ a[i];
        auto it = setA.find(want);
        if (it != setA.end()) {
            setA.erase(it);
            r[1] = want;
            r[2] = a[i];
            ans = true;
            break;
        }
        setA.insert(a[i]);
    }
    if (ans) {
        for(int i=3; i<n; i++) {
            lint want = r[i-2] ^ r[i-1];
            auto it = setA.find(want);
            if (it != setA.end()) {
                setA.erase(it);
                r[i] = want;
            } else {
                ans = false;
                break;
            }
        }
    }
    auto o = ans ? "Yes" : "No";
    cout << o << endl;
}

Measured memory_bytes: 9512
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;
	vector<int> a( n );
	for( auto& v: a ) { cin >> v; }

	int q;
	cin >> q;
	while( q-- > 0 ) {
		int k;
		cin >> k;
		cout << lower_bound( a.begin(), a.end(), k ) - a.begin() << '\n';
	}

	return 0;
}



Measured memory_bytes: 3352
from operator import mul
 
n = int(input())
cof = [1 << x for x in range(10)]

fs = [sum(map(mul, map(int, input().split()), cof)) for _ in range(n)]
ps = [list(map(int, input().split())) for _ in range(n)]
ans = float('-inf')
for g in range(1, 1024):
    sum=0
    for f, p in zip(fs, ps):
        sum+=p[bin(f & g).count('1')]
  
    #tmp=sum(p[bin(f & g).count('1')] for f, p in zip(fs, ps))
    #ans = max(ans, tmp)
    ans = max(ans, sum)

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<vector>
#define maxn 1000005
#define mid ((nl+nr)>>1)
using namespace std;
typedef long long ll;
int n,m;
int a[maxn];
int cnt[maxn];
vector<int>edge[maxn];
int main()
{
	for(int i=2;i<=1e6;i++)
		for(int j=i+i;j<=1e6;j+=i)
			edge[j].emplace_back(i);
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	
	int flag=1;
	
	for(int i=2;i<=1e6;i++)
	if(cnt[i])
	{
		if(cnt[i]>1)
		{
			flag=0;
			break;
		}
		int len=edge[i].size();
		for(int j=0;j<len;j++)
		{
			int nex=edge[i][j];
			cnt[nex]++;
		}
	}
	
	for(int i=2;i<=1e6;i++)
	{
		if(cnt[i]>1)
		{
			flag=0;
			break;
		}
	}
	
	if(flag)
		printf("pairwise coprime\n");
	else 
	{
		int g=a[1];
		for(int i=2;i<=n;i++)
		g=__gcd(g,a[i]);
		if(g==1)
			printf("setwise coprime\n");
		else
			printf("not coprime\n");
	}
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	for(int i = 1;i<500;i++){
		if((a*i)%b==c){
			cout << "YES"<<endl;
			return 0;
		}
	}
	
	cout << "NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        d: [i64; n],
    }

    let mut ans = 0;

    for i in 0..n {
        for j in i + 1..n {
            ans += d[i] * d[j];
        }
    }

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


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			var hw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int h = hw[0];
			int w = hw[1];
			string[] a = new string[h];
			for (int i = 0; i < h; i++) {
				a[i] = Console.ReadLine();
			}

			int pos = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < pos - 1; j++) {
					if (a[i][j] == '#') {
						Console.WriteLine("Impossible");
						return;
					}
				}

				for (int j = pos; j < w; j++) {
					if (a[i][j] == '.') {
						break;
					} else {
						++pos;
					}
				}

				for (int j = pos + 2; j < w; j++) {
					if (a[i][j] == '#') {
						Console.WriteLine("Impossible");
						return;
					}
				}
			}

			Console.WriteLine("Possible");
		}
	}
}

Measured memory_bytes: 28272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isMult=0;
int a[10000000]={};
void solve()
{
	ll n;
	cin>>n;
	
	for(ll i=1; i<=n; ++i)
	{
		ll j=i;
		while(j<=n)
		{
			a[j]++;
			j+=i;
		}
	}
	ll res=0;
	for(ll i=1; i<=n; ++i)
	{
		res+=i*a[i];
	}
	cout << res << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	if(isMult) cin>>t;
	while(t--) solve();
	return 0;
}

Measured memory_bytes: 42668
def main():
  n = int(input())
  hs = tuple(map(int, input().split()))

  a, b = 0, abs(hs[1] - hs[0])

  for i in range(2, n):
    c = hs[i]
    t1 = c - hs[i-2]
    t2 = c - hs[i-1]
    d1 = a + (t1 if t1 > 0 else -t1)
    d2 = b + (t2 if t2 > 0 else -t2)
    a, b = b, d1 if d1 <= d2 else d2

  print(b)

if __name__ == "__main__":
  main()

Measured memory_bytes: 14108
object Main {
    def main(args: Array[String]): Unit = {
//        val strAry = io.StdIn.readLine().split(' ')
//        println(strAry.sorted.mkString(" "))
//        val x = io.StdIn.readInt()
//        println(x * x * x)
        val in = readLine.split(" ").map(_.toInt)
        val a = in(0)
        val b = in(1)
        println(a * b + " " + 2 * (a + b))
    }
}



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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

/*
a3+b1 a3+b2 a3+b3
a2+b1 a2+b2 a2+b3
a1+b1 a1+b2 a1+b3
*/

int c[3][3];
int sum = 0;
int main(){
  REP(i,3)REP(j,3){
    scanf("%d",&c[i][j]);
    sum += c[i][j];
  }
  if(sum%3 != 0){
    cout << "No" <<endl;
    return 0;
  }
  sum/=3;
  REP(i,3){
    int tmp1 = c[0][i];
    int tmp2 = c[i][0];
    REP(j,3){
      if(i==j) continue;
      tmp1 += c[1][j];
      tmp2 += c[j][1];
      REP(k,3){
        if(i==k||j==k) continue;
        tmp1 += c[2][k];
        tmp2 += c[k][2];
        if(sum!= tmp1 || sum!= tmp2){
          cout <<"No"<<endl;
          return 0;
        }
        tmp1 -= c[2][k];
        tmp2 -= c[k][2];
      }
      tmp1 -= c[1][j];
      tmp2 -= c[j][1];
    }
  }
  cout << "Yes" <<endl;
}


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

typedef long long ll;

int MOD=1000000007;


int main(){
    int N;
    cin >> N;
    int A[N],mx=0,mx2=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] > mx){
            mx2 = mx;
            mx = A[i];
        }else if(A[i]==mx){
            mx2 = A[i]; 
        }else if(A[i] > mx2){
            mx2 = A[i];
        }
    }

    for(int i=0;i<N;i++){
        if(A[i] == mx){
            cout << mx2 << endl;
        }else{
            cout << mx << endl;
        }
    }
}



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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;

constexpr int MAX_N = 5050;
ll ch[MAX_N][2], dp[MAX_N][MAX_N][2];

class ProblemE {
public:
    ProblemE(int _n) : n(_n), m(n - 1), root(0), tree(n), comb(n + 1), sz(n, 1) {
        comb[2] = 1;
        for (int i = 4; i <= n; i += 2)
            comb[i] = ((i - 1) * comb[i - 2]) % MOD;
    }
    inline void add_edge(int v[2]) {
        tree[v[0] - 1].push_back(v[1] - 1);
        tree[v[1] - 1].push_back(v[0] - 1);
    }

    ll Solve() {
        Dfs(root, -1);

        ll res = 0;
        for (int i = 0; i <= n; ++i) {
            res = (res + (dp[root][i][0] * comb[i]) % MOD) % MOD;
            res = (res - (dp[root][i][1] * comb[i]) % MOD + MOD) % MOD;
        }

        return (res % MOD + MOD) % MOD;
    }

private:
    const int n, m, root;
    vector<vector<int>> tree;
    vector<ll> comb;
    vector<int> sz;

    void Dfs(const int cur, const int p) {
        dp[cur][1][0] = 1;

        for (const int dst : tree[cur]) {
            if (dst == p) continue;
            Dfs(dst, cur);
            for (int i = 0; i <= sz[cur] + sz[dst]; ++i)
                ch[i][0] = ch[i][1] = 0LL;

            for (int x = 1; x <= sz[cur]; ++x) {
                for (int y = 1; y <= sz[dst]; ++y) {
                    // combine cur with dst
                    (ch[x + y][0] += dp[cur][x][0] * dp[dst][y][0]) %= MOD;
                    (ch[x + y][0] += dp[cur][x][1] * dp[dst][y][1]) %= MOD;
                    (ch[x + y][1] += dp[cur][x][0] * dp[dst][y][1]) %= MOD;
                    (ch[x + y][1] += dp[cur][x][1] * dp[dst][y][0]) %= MOD;

                    // separate dst
                    (ch[x][1] += dp[cur][x][0] * dp[dst][y][0] % MOD * comb[y]) %= MOD;
                    (ch[x][1] += dp[cur][x][1] * dp[dst][y][1] % MOD * comb[y]) %= MOD;
                    (ch[x][0] += dp[cur][x][0] * dp[dst][y][1] % MOD * comb[y]) %= MOD;
                    (ch[x][0] += dp[cur][x][1] * dp[dst][y][0] % MOD * comb[y]) %= MOD;

                }
            }

            for (int i = 0; i <= sz[cur] + sz[dst]; ++i) {
                dp[cur][i][0] = ch[i][0];
                dp[cur][i][1] = ch[i][1];
            }
//            swap(dp[cur], ch);
            sz[cur] += sz[dst];
        }
    }
};

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

    int n, v[2];
    cin >> n;
    ProblemE p(n);
    for (int i = 0; i < n - 1; ++i) {
        cin >> v[0] >> v[1];
        p.add_edge(v);
    }
    cout << p.Solve() << endl;

    return 0;
}


Measured memory_bytes: 395136
#include "iostream"
#include "cmath"
using namespace std;
int main()
{
	int n, h[20],ans=0,hmax=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> h[n];
		if (h[n] >= hmax)
		{
			hmax = h[n];
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int v[n], c[n];
    for (int i = 0; i < n; i++)
        scanf("%d",&v[i]);
    for (int i = 0; i < n; i++)
        scanf("%d",&c[i]);
    int ans = 0;
    for (int i = 0; i < n; i++)
        if (v[i] > c[i])
            ans += v[i] - c[i];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, M;
    cin >> N >> M;
    set<int> s;
    for (int i = 1; i * i <= M; i++) {
        if (M % i == 0) {
            s.insert(i);
            s.insert(M / i);
        }
    }
    auto k = s.upper_bound(M / N);
    k--;
    cout << *(k) << endl;
}

Measured memory_bytes: 256
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
    }

    if c - (a - b) > 0 {
        println!("{}", c - (a - b));
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
from collections import deque
from itertools import product
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read():
    N = int(input().strip())
    A = map(int, input().strip().split())
    return N, A


def dfs(I, J, K, N, dp):
    for k in range(0, K+1):
        for j in range(0, J+K+1):
            for i in range(0, N+1):
                x = 0.0
                if not(i + j + k > N or i == 0 and j == 0 and k == 0):
                    x += dp[i-1][j] * (i / N) if i > 0 else 0.0
                    x += dp[i+1][j-1] * (j / N) if j > 0 else 0.0
                    x += dp[i][j+1] * (k / N) if k > 0 else 0.0
                    x += 1.0
                    x *= N / (i + j + k)
                dp[i][j] = x
    return dp[I][J]


def solve(N, A):
    dp = [[0.0 for j in range(N + 2)] for i in range(N + 2)]
    C = [0 for i in range(4)]
    for a in A:
        C[a] += 1
    return dfs(C[1], C[2], C[3], N, dp)


if __name__ == "__main__":
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 42348
using System;

namespace ABC111_B_AtCoder_Beginner_Contest_111
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string N = Console.ReadLine();
			int[] nArrs = new int[3];

			for (int i = 0; i < 3; i++) {
				nArrs[i] = int.Parse(N.Substring(i, 1));
			}

			if (nArrs[0] == nArrs[1] && nArrs[1] == nArrs[2])
			{
				foreach (int nArr in nArrs)
				{
					Console.Write(nArr);
				}
			}else if (nArrs[0] < nArrs[1] || (nArrs[0] == nArrs[1] && nArrs[1] < nArrs[2]))
			{
				nArrs[0]++;
				for (int i = 0; i < 3; i++)
				{
					Console.Write(nArrs[0]);
				}
			}
			else
			{
				for (int i = 0; i < 3; i++) {
					Console.Write(nArrs[0]);
				}
			}
		}
	}
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100100;

int A[MAX];

LL RES[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	set<PII> s;
	A[0] = 0;
	s.insert(MP(0, 0));
	n++;
	FOR (i, 1, n)
	{
		scanf("%d", &A[i]);
		s.insert(MP(-A[i], i));
	}

	PII a = *s.begin();

	int ind = a.second-1;
	map<int, int> m;

	FOR (i, ind+1, n)
	{
		s.erase(MP(-A[i], i));
		m[-A[i]]++;
	}

	int pind = ind + 1;

	while(SZ(s))
	{
		PII a = *s.begin();
		int pos = a.second;
		int val = -a.first;
		while(ind >= pos)
		{
			s.erase(MP(-A[ind], ind));
			m[-A[ind]]++;
			ind--;
		}

		LL res = 0;

		while(SZ(m) && -m.begin()->first > val)
		{
			PII a = *m.begin();
			m.erase(m.begin());


			res += (-a.first - val)*(LL)a.second;
			m[-val] += a.second;
		}

		RES[pind] += res;
		pind = ind + 1;
	}

	FOR (i, 1, n)
	{
		printf("%lld\n", RES[i]);
	}

}


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

const long MOD=1000000007;
const long INF=100000000000000000;
int main(){
    long N,K;
    cin>>N>>K;
    vector<long> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    
    vector<long> next(N);//次にその値がくる点なければ-1;
    vector<long> front(200010,-1);//計算のため。A.at(i)のそこまでの先頭
    for(int i=N-1;i>=0;i--){
        next.at(i)=front.at(A.at(i));
        front.at(A.at(i))=i;
    }
    
    vector<long> pass(N+1);//数列Aをiばんめから始めた時に先頭になる点の添字。次ならNとなる。
    pass.at(N)=N;
    for(int i=N-1;i>=0;i--){
        if(next.at(i)==-1) pass.at(i)=i;
        else pass.at(i)=pass.at(next.at(i)+1);
    }
    
    long syuki=1,prei=pass.at(0);
    while(prei!=N){
        syuki++;
        prei=pass.at(front.at(A.at(prei))+1);
    }
    
    //cout<<syuki<<endl;
    
    
    K%=syuki;
    long pos=0;
    //cout<<K<<endl;
    while(K-1>0){//最後は出力と同時にシミュレートする
        K--;
        pos=front.at(A.at(pass.at(pos)))+1;
    }
    //cout<<pos<<endl;
    long para=pos;
    while(para<N){
        if(next.at(para)==-1){
            cout<<A.at(para)<<" ";
            para++;
        }else{
            para=next.at(para)+1;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 7808
#include<iostream>
using namespace std;
int main(){
    char ch;
    while(1){
        scanf("%c",&ch);
        if(ch=='\n')break;
        else if('a'<=ch&&ch<='z')ch-=32;
        else if('A'<=ch&&ch<='Z')ch+=32;
        cout<<ch;
    }cout<<endl;
    return 0;
}


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

int main() {
    int m, f, b;
    cin >> m >> f >> b;
    if (m + f < b) {
        cout << "NA" << endl;
        return 0;
    }
    if (m >= b) {
        cout << 0 << endl;
    } else {
        cout << b - m << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define Accepted return 0;
int main()
{
    int a,b,c,d,i,j;
    bool flag;
    cin>>a>>b>>c;flag=false;
    for(i=0;i<=a;i++)
        for(j=0;j<=b;j++)
        {
            d=i*b+j*a-2*i*j;
            if (d==c) flag=true;
        }
    if (flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    Accepted
}

Measured memory_bytes: 256
def sky(x):
    return x[1]


while True:
    n = int(input())
    if n == 0:
        break
    
    arr = [[] for i in range(n)]
    sumh = 0
    for i in range(n):
        arr[i] = list(map(int, input().split()))
    arr.sort(key=sky)
    res = True
    for e in arr:
        sumh += e[0]
        if sumh > e[1]:
            res = False
            break
    if res:
        print("Yes")
    else:
        print("No")



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

#[fastout]
fn main() {
    input! {n: usize, k:usize, h: [u128; n]};
    let mut h: Vec<u128> = h;

    h.sort();

    for _ in 0..k {
        h.pop();
    }

    let sum_h = h.iter().sum::<u128>();

    println!("{}", sum_h)
}


Measured memory_bytes: 8304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}



int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n; scanf("%d",&n);
	ll ans = 1;
	REPP(i,2,n+1){
		int f = 1;
		REPP(j,2,i) if(i%j==0) f=0;
		if(f){
			ll a = i,b=0;
			while(a<=n){
				b+=n/a;a*=i;
			}
			ans = ans*(b+1)%mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}




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

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int X;
	cin >> X;
	for(int i = 1; i <= 360; i++) if((i*X)%360 == 0) {
		cout << i << "\n";
		return 0;
	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    
    if(10%p==0){
        ll ans = 0;
        rep(i,n){
            if( (s[i]-'0') % p == 0 ){
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> d(n+1);
    map<int,ll> mp;
    int ten = 1;
    ll ans = 0;
    for(int i=n-1;i>=0;i--){
        int a = (s[i] - '0') * ten % p;
        d[i] = (d[i+1]+a)%p;
        ten *= 10; ten %= p;
        mp[d[i]]++;
        if(d[i]==0)ans++;
    }
    for(auto x:mp)ans += x.second * (x.second-1) / 2LL;
    cout << ans << endl;
}


Measured memory_bytes: 1812
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){

  int n;
  cin >> n;
  vector<int> a, b, c;
  for (int i = 0; i < n; i++){
    int p;
    scanf("%d", &p);
    a.push_back(p);
  }
  for (int i = 0; i < n; i++){
    int p;
    scanf("%d", &p);
    b.push_back(p);
  }
  for (int i = 0; i < n; i++){
    int p;
    scanf("%d", &p);
    c.push_back(p);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long  ans = 0;
  for (int i = 0; i < b.size(); i++){
    long u = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    long v = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    ans += u * (n - v);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n,m;
		cin>>n>>m;
		cout<<(n*(n-1)+m*(m-1))/2;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
using Graph = vector<vector<ll>>;
int main()
{
  ll N, X, Y; cin >> N >> X >> Y;
  vector<ll> K(N, 0);
  Graph G(N + 1);
  for (ll i = 1; i < N; i++) {
  	G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[X].push_back(Y);
  G[Y].push_back(X);
  
  for (ll i = 1; i <= N; i++) {
//  	cout << i << ": ";
    for (ll j = 0; j < G[i].size(); j++) {
//    	cout << G[i][j] << " ";
    }
//    cout << endl;
  }
//  cout << endl;
  
  vector<ll> dist(N + 1, -1);
  queue<ll> que;
  
  for (int i = 1; i < N; i++) {
  	dist[i] = 0;
  	que.push(i);
    while (!que.empty()) {
  		ll v = que.front();
    	que.pop();
    
    	for (ll nv : G[v]) {
    		if (dist[nv] != -1)
    	      continue;
    	  dist[nv] = dist[v] + 1;
    	  que.push(nv);
    	}
  	}
    for (ll v = 1; v <= N; v++){
//    	cout << v << ": " << dist[v] << endl;
    }
    for (ll v = i; v <= N; v++) {
    	K[dist[v]]++;
    }
//    cout << endl;
    dist = vector<ll>(N + 1, -1);
  }
  for (ll i = 1; i < N; i++) {
  	cout << K[i] << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
using std::swap;

std::vector <int> len;

int main() {
	int N, X,k;
	cin >> N >> X;
	len.resize(N);
	k = 0;
	for (int i = 0; i < N; ++i)cin >> len[i];
	for (int i = 0; i < N; ++i) {
		k += len[i];
		if (k > X) {
			cout << i+1 << "\n";
			break;
		}
      else if (k <= X && i == N - 1) {
			cout << N+1 << "\n";
			break;
		}
	}
	return 0;
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    int arr[3] = {a, b, c};
    sort(arr, arr + 3);
    if (arr[2] == arr[0] + arr[1]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
###B - Foods Loved by Everyone
N, M = map(int, input().split())
kaito = []
for i in range(N):
    kaito.append([int(i) for i in input().split()])

cnt = 0
for i in range(1, M+1):
    jlist = []
    for j in range(N):
        if i in kaito[j][1:]:
            jlist.append(True)
        else:
            jlist.append(False)
    if all(jlist):
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll cnt = 0;

    for (ll i = 0; i < n; i++)
    {
        if (a[i] <= 0)
        {
            cnt++;
        }
    }

    if (cnt % 2)
    {
        ll ans = 0;
        ll mn = INF;
        for (ll i = 0; i < n; i++)
        {
            ans += llabs(a[i]);
            mn = min(mn, llabs(a[i]));
        }
        cout << ans - mn * 2 << endl;
    }
    else
    {
        ll ans = 0;
        for (ll i = 0; i < n; i++)
        {
            ans += llabs(a[i]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    int dp[n+1];
    rep(i,n+1) dp[i]=1001001;
    dp[0]=0;
    rep(i,n+1){
        int k=1;
        if(i+1<=n) chmin(dp[i+1],dp[i]+1);
        k=6;
        while(i+k<=n){
            chmin(dp[i+k],dp[i]+1);
            k*=6;
        }
        k=9;
        while(i+k<=n){
            chmin(dp[i+k],dp[i]+1);
            k*=9;
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    int p = 1;
    while(true){
        p *= k;
        if(p > n)break;
        ans++;
    }
    cout << ans << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  int n;
  cin >> n;
  
  vector<int> v(n);
  REP(i,n)
    cin >> v[i];
  
  int count = 0;
  REP(i,n-2){
	if(v[i] < v[i+1] && v[i+1] < v[i+2])
	  count++;
	
	if(v[i] > v[i+1] && v[i+1] > v[i+2])
	  count++;
  }
  
  cout << count << endl;
  
  //cout << CX << " " << CY << " " << H << "\n";
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<pair<int,int>,ll> dp;
ll numlun(int length, int start){
	if (length==1){
		return 1;
	}
	auto f = dp.find({length,start});
	if (f!=dp.end()){
		return f->second;
	}
	ll total = 0;
	total+=numlun(length-1,start);
	if (start!=9){
		total+=numlun(length-1,start+1);
	}
	if (start!=0){
		total+=numlun(length-1,start-1);
	}
	return dp[{length,start}]=total;
}

ll numoflength(int length){
	ll ans = 0;
	for (int i = 1; i<=9; i++){
		ans+=numlun(length,i);
	}
	return ans;
}

void findnum(int start, int length, int k){
	cout<<start;
	if (length==1){
		cout<<endl;
		return;
	}
	ll tmpcnt;
	if (start!=0){
		tmpcnt = numlun(length-1,start-1);
		if (tmpcnt<k){
			k-=tmpcnt;
		} else {
			findnum(start-1,length-1,k);
			return;
		}
	}
	tmpcnt = numlun(length-1,start);
	if (tmpcnt<k){
		k-=tmpcnt;
	} else {
		findnum(start,length-1,k);
		return;
	}
	tmpcnt = numlun(length-1,start+1);
	if (tmpcnt<k){
		k-=tmpcnt;
	} else {
		findnum(start+1,length-1,k);
		return;
	}
	assert(1==0);
}

int main(){
	int k;
	cin>>k;
	int length = 0;
	ll val = 0;
	do {
		length++;
		k-=val;
		val = numoflength(length);
	} while (val<k);
	for (int i = 1; i<=9; i++){
		ll num = numlun(length,i);
		if (num<k){
			k-=num;
		} else {
			findnum(i,length,k);
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n, m, a;
    
    while (scanf("%d %d %d", &n, &m, &a) && a){
        vector<pair<int, pair<int, int>>> A;
        
        for (int i = 0; i < m; i++){
            int h, p, q;
            scanf("%d %d %d", &h, &p, &q);
            A.push_back(make_pair(h, make_pair(p, q)));
        }
        
        sort(A.rbegin(), A.rend());
        
        for (int i = 0; i < m; i++){
            if (A[i].second.first == a || A[i].second.second == a)
                a ^= ((A[i].second.first) ^ (A[i].second.second));
        }
        
        printf("%d\n", a);
    }
    
    return (0);
}

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

using namespace std;


int main() {

    int x;
    string res1, res2;
    res1 = "YES";
    res2 = "NO";
    cin >> x;

    if(x == 7 || x == 5 || x == 3) {
        cout << res1 << endl;
    } else {
        cout << res2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256