akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  int N, Q;
  std::cin >> N >> Q;

  std::vector<std::vector<int>> nodeLink(N);
  for(int i=0; i<N-1; i++)
  {
    int a, b;
    std::cin >> a >> b;
    nodeLink[a-1].push_back(b-1);
    nodeLink[b-1].push_back(a-1);
  }

  std::vector<int> nodeValue(N,0);
  for(int i=0; i<Q; i++)
  {
    int p, x;
    std::cin >> p >> x;
    nodeValue[p-1]+=x;
  }

  std::vector<int> nodeProcessed(N,0);
  std::vector<int> nextChiledren = {0};
  while( ! nextChiledren.empty() )
  {
    int targetNode = nextChiledren.back();
    nextChiledren.pop_back();
    nodeProcessed[targetNode] = 1;

    for(const auto e : nodeLink[targetNode] )
    {
      if( nodeProcessed[e] ) { continue; }
      nextChiledren.push_back(e);
      nodeValue[e] += nodeValue[targetNode];
    }
  }

  for(const auto e : nodeValue )
  {
    std::cout << e << std::endl;
  }
  std::cout << std::endl;
}

Measured memory_bytes: 16372
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

type Triple = (Int, Maybe (Maybe Char, Char))

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  s <- T.getLine :: IO T.Text
  let
    step :: Triple -> Char -> Triple
    step (k, Nothing) c = (k, Just (Nothing, c))
    step (k, Just (Just 'A', 'B')) 'C' = (succ k, Nothing)
    step (k, Just (_, c')) c = (k, Just (Just c', c))
  print . fst . T.foldl step (0, Nothing) $ s

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

string s;
int main(){
	cin >> s;
	int N = s.length();
	string a = s.substr(0,  (N-1)/2);
	string b = s. substr( ((N+3)/2)-1 );
	
	if(s == string(ALLR(s))){
	if(a == string(ALLR(a))){	
	if(b == string(ALLR(b))){
		cout << "Yes" << endl;
		return 0;
	}}}
	cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3056
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;

const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int main() {

    int H, A;

    cin >> H >> A;

    int ret;

    if(H%A == 0){
        if(H < A){
            ret = 1;
        }else{
            ret = H / A;
        }
    }else{
        ret = H / A + 1;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

P = [K] * N
for i in range(N):
    P[i] -= Q

for i in range(Q):
    P[A[i]-1] += 1

for p in P:
    if p > 0:
        print("Yes")
    else:
        print("No")

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

using namespace std;

int dp[123][123];
int arr[123][123];

int n;

int f(int l, int r) {
  if (l < 0 || l > 2 || r < 0 || r > n) {
    return 0;
  }
  if (dp[l][r] != -1) {
    return dp[l][r];
  }
  return dp[l][r] = max(f(l + 1, r), f(l, r + 1)) + arr[l][r];
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", arr[i] + j);
    }
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", f(1, 1));
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

sDash = sorted(s)
tDash = sorted(t, reverse=True)


def checkAlphabetOrder(a, b):
    temp = [a, b]
    compare = sorted(temp)
    return temp[0] == compare[0]


# main
for i in range(min(len(s), len(t))):
    if sDash[i] == tDash[i]: continue
    elif checkAlphabetOrder(sDash[i], tDash[i]):
        print('Yes')
        break
    else:
        print('No')
        break
else:
  if len(s) < len(t):
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3064
import copy
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


K, A, B = na()
if B - A > 1:
    print(1 + (B - A) * ((K - A + 1) // 2) + (A - 1) + ((K - A + 1) % 2))
else:
    print(1 + K)


Measured memory_bytes: 3444
from collections import Counter
N=int(input())
s_li=[]
for i in range(N):
    s=input()
    s_li.append(s)
c=Counter(s_li)
c=c.most_common()
tmp=c[0][1]
res=[]
for j in range(len(c)):
    if tmp>c[j][1]:
        break
    res.append(c[j][0])
res.sort()
for k in range(len(res)):
    print(res[k])

Measured memory_bytes: 45040
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(0,c+b-a)<<endl;
    return 0;
}

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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    ll N, A, B, C, D, E;

    cin >> N >> A >> B >> C >> D >> E;

    ll ans, m, p;
    m=min({A, B, C, D, E});
    
    ans = N / m;
    if(N%m!=0) ans++;

    cout << ans+4 << endl;

    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong gcd(llong a, llong b)
{
        return b != 0 ? gcd(b, a % b) : a;
}


int main()
{
  int n;
  cin>>n;
  vector<llong> a(n,0);
  llong sum=0;

  llong m=INF;
  llong cnt=0;
  REP(i,n)
  {
      cin>>a[i];
      if(a[i]<0) ++cnt;
      sum+=abs(a[i]);
      m=min(m,abs(a[i]));
  }
  if(cnt%2!=0) cout<<sum-2*m<<endl;
  else cout<<sum<<endl;
  
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

int main(){
  string t;
  cin >> t;
  int f = (t[0] - '0') * 10 + (t[1] - '0');
  int s = (t[2] - '0') * 10 + (t[3] - '0');
  int c1 = 0, c2 = 0;
  if(f >= 1 && f <= 12) c1 = 1;
  if(s >= 1 && s <= 12) c2 = 1;
  if(c1 == 1 && c2 == 1)
    cout << "AMBIGUOUS";
  else if(c1 == 0 && c2 == 0)
    cout << "NA";
  else if(c1 == 1)
    cout << "MMYY";
  else
    cout << "YYMM";
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n, k int
	con.Scan(&n, &k)
	l := make([]int, n)
	for i := 0; i < n; i++ {
		con.Scan(&l[i])
	}
	sort.Ints(l)
	m := 0
	for i := n - 1; i >= n-k; i-- {
		m += l[i]
	}
	con.Println(m)
	return nil
}


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

int a[105];

int main()
{
    double n, m, sum=0;

    cin>>n>>m;

    int i, ck=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        sum = sum+a[i];
    }

    sum = sum*double(1/(4*m));

    for(i=0; i<n; i++)
        if(sum<=a[i])
            ck++;

    if(ck>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

min_A = min(A)
prev_answer = None
answer = min_A
while True:
    if answer == prev_answer: break

    next_answer = answer
    for Ai in A:
        remainder = Ai % answer
        if remainder == 0: continue

        next_answer = min(remainder, next_answer)

    prev_answer = answer
    answer = next_answer

print(answer)


Measured memory_bytes: 15020
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    rep(i, 0, N) cin >> w[i] >> v[i];

    ll dp[110][100010] = {};

    rep(i, 0, N) {
        rep(j, 0, W + 1) {
            if (j - w[i] >= 0)
                dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 86272
#include<bits/stdc++.h>
//#define GYD
using namespace std;
const int maxn = 200000 + 10;
int n, m, a[maxn], b[maxn];

int main()
{
    #ifdef GYD
    freopen("..//out.txt", "w", stdout);
    #endif // GYD
    scanf("%d%d", &n, &m);
    int k = 0;
    for(int i = 1; i <= m; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        if(x == 1) a[k++] = y;
        if(y == n) b[x] = 1;
    }
    for(int i = 0; i < k; i++)
    {
        if(b[a[i]] == 1)
        {
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 1408
def solve():
    def max2(x, y): return x if x >= y else y

    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    Ts = input().rstrip()

    Uss = [Ts[i::K] for i in range(K)]

    ans = 0
    for Us in Uss:
#        print('\nUss:', Uss)
        lenU = len(Us)
        dp = [[0]*(3) for _ in range(lenU+1)]
        for i, U in enumerate(Us, start=1):
            # グー
            dp[i][0] = max2(dp[i-1][1], dp[i-1][2])
            if U == 's':
                dp[i][0] += R
            # チョキ
            dp[i][1] = max2(dp[i-1][0], dp[i-1][2])
            if U == 'p':
                dp[i][1] += S
            # パー
            dp[i][2] = max2(dp[i-1][0], dp[i-1][1])
            if U == 'r':
                dp[i][2] += P
#            print(dp[i])

        ans += max(dp[-1])

    print(ans)


solve()


Measured memory_bytes: 22420
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 = sc.nextInt();
			int fdiv = N%500;
			if(A-fdiv>=0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
    }
}


Measured memory_bytes: 22484
#include<iostream>

using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k << endl;
	}
	else if (k <= a + b){
		cout<<a<<endl;	
	}
	else {
		cout << a - (k - a - b) << endl;
	}
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,n) cin>>a[i];
  cout << (n-1-1) / (k-1) + 1 << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Long N = sc.nextLong();
    Long [] X = new Long[6];
    X[0] = N;
    X[1] = 0L;
    X[2] = 0L;
    X[3] = 0L;
    X[4] = 0L;
    X[5] = 0L;
    Long min = Long.MAX_VALUE;
    int c = 0;
    Long [] between = new Long[5];
    for(int i =0;i<5;i++){
      between[i] = sc.nextLong();
      if(between[i]<= min){
          c = i;
          min = between[i];
      }
    }
    Long tmp = 0L; 
    if(N%min!=0){
      tmp = N/min+1;
    }else{
      tmp = N/min;      
    }
    System.out.println(tmp+4);    
    // System.out.println(min);    
  
  }
}




Measured memory_bytes: 35644
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
const int MAX_N = 100000;
struct UnionFind{
    int par[MAX_N];
    void init(int n){
        for(int i = 0;i < n;i++)par[i] = i;
    }
    int root(int x){
        if(par[x] == x)return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y)return;
        par[y] = x;
    }
};
main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,M;
    cin >> N >> M;
    UnionFind uf;
    uf.init(N+1);
    vector<int> A(M+1);
    for(int i = 0;i < N;i++){
        int K;
        cin >> K;
        for(int j = 0;j < K;j++){
            int a;
            cin >> a;
            if(A[a])uf.unite(i+1,A[a]);
            else A[a] = i+1;
        }
    }
    for(int i = 1;i <= N;i++)if(!uf.same(1,i)){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int powi(int x,int y) {int p=1; while(y--)p*=x;return p;}
int main(){
 int D,N,d; cin>>D>>N;
 d=powi(100, D);
 cout<<d*N+(N==100?d:0)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <set>
#include <functional>

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    vector<int> nums;
    for(int i = 100; i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            nums.push_back(i);
        }
    }

    cout << nums[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
r,c=map(int,input().split())
s=[]
for _ in range(r):
    s.append(list(map(int,input().split())))

tmpc=[0 for _ in range(c+1)]
for i in range(r):
    tmpr=0
    for j in range(c):
        tmpr+=s[i][j]
        tmpc[j]+=s[i][j]
    s[i].append(tmpr)
    tmpc[-1]+=tmpr
s.append(tmpc)
for i in range(r+1):
    for j in range(c):
        print(s[i][j],end=" ")
    print(s[i][-1])


Measured memory_bytes: 6228
N, K = list(map(int, input().split(" ")))

nums = {}

for _ in range(N):
    a, b = list(map(int, input().split(" ")))
    
    if a in nums:
        nums[a] += b
    else :
        nums[a] = b
        
acc = 0
for key in sorted(nums.keys()):
    acc += nums[key]
    if acc >= K:
        print(key)
        break

Measured memory_bytes: 10600
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 n;
vector<int> a;
vector<vector<int>> g;

int dfs(int v, int p) {
    int res = 0;
    if(g[v].size() == 1 && g[v][0] == p) return a[v];
    int ma = 0;
    for(int nv: g[v]) {
        if(nv == p) continue;
        int tmp = dfs(nv, v);
        res += tmp;
        chmax(ma, tmp);
    }
    if(g[v].size() == 2 && p != -1) {
        if(res != a[v]) {
            cout << "NO" << endl;
            exit(0);
        }
        return a[v];
    }
    if(ma * 2 > res && p == -1) {
        cout << "NO" << endl;
        exit(0);
    }
    if(2 * a[v] - res < 0) {
        cout << "NO" << endl;
        exit(0);
    }
    if(2 * a[v] - res > res) {
        cout << "NO" << endl;
        exit(0);
    }
    if(a[v] < ma) {
        cout << "NO" << endl;
        exit(0);
    }
    return 2 * a[v] - res;
}

void solve() {
	cin >> n;
    a.resize(n);
    g.assign(n, vector<int>());
    rep(i, n) {
        cin >> a[i];
    }
    if(n == 2) {
        if(a[0] == a[1]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return;
    }
    vector<int> deg(n, 0);
    rep(i, n - 1) {
        int u, v; cin >> u >> v; 
        -- u, -- v;
        deg[u] ++, deg[v] ++;
        g[u].pb(v);
        g[v].pb(u);
    }
    int r = -1;
    rep(i, n) {
        if(deg[i] > 1) r = i;
    }
    int tmp = dfs(r, -1);
    if(tmp == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 17316
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] a = IntStream.range(0,N).map(i -> scan.nextInt()).toArray();
        int index = 0;
        for(int i=0;i<N;++i)if(Math.abs(a[index]) < Math.abs(a[i]))index = i;
        System.out.println(2*N-1);
        for(int i=0;i<N;++i)System.out.println((index+1)+" "+(i+1));
        if(a[index]>0){
            for(int i=2;i<=N;++i)System.out.println((i-1)+" "+i);
        }else{
            for(int i=N-1;i>=1;--i)System.out.println((i+1)+" "+i);
        }
    }
}

Measured memory_bytes: 29780
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans1 = 0;
  int ans2 = 0;

  int ab[S.size()];
  for(int j = 0; j < S.size(); j++) { // 0101...
    if(j % 2 == 0) ab[j] = 0;
    else ab[j] = 1;
  }

  int cd[S.size()];
  for(int j = 0; j < S.size(); j++) { // 1010...
    if(j % 2 == 0) cd[j] = 1;
    else cd[j] = 0;
  }

  for(int i = 0; i < S.size(); i++) { // ab
    if(ab[i] != stoi(S.substr(i, 1))) ans1++;
  }
  for(int i = 0; i < S.size(); i++) {
    if(cd[i] != stoi(S.substr(i, 1))) ans2++;
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}


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

#[fastout]
fn main() {
    input! {n: isize, l: isize};
    let mut v: Vec<i32> = Vec::new();

    for i in l..l + n {
        v.push(i as i32);
    }

    let mut min: i32 = 1_000_000;
    let mut x: i32 = 0;

    for v_i in v.iter() {
        if min > v_i.abs() {
            min = v_i.abs();
            x = *v_i;
        }
    }

    println!("{}", v.iter().sum::<i32>() - x);
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 数値の入力
        int a = sc.nextInt();
        int b = sc.nextInt();

        int roop = 0;
        // 最小から求める
        while (roop < 10000) {
            if (Math.floor((double) roop * 0.08) == a && Math.floor((double) roop * 0.1) == b) {
                System.out.println(roop);
                break;
            }
            roop++;
        }

        if (roop == 10000) {
            System.out.println(-1);
        }

    }
}


Measured memory_bytes: 22852
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;

int main() {
	int a[200];
	int b;
	cin >> b;
	for (int c = 0; c < b*2; c++)scanf("%d", &a[c]);
	sort(a, a + b * 2);
	int s = 0;
	for (int x = 0; x < b * 2; x += 2) {
		s += a[x];
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	int a;
	cin >> a;
	int ans = a * (1 + a + a * a);
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=1e4+5;
const int mod=1e9+7;

int a[N],d,n;
int cache[N][101][2];

void work()
{
     string str;
     cin>>str;
     cin>>d;
     for(int i=0;i<str.size();i++)
          a[i+1]=(str[i]-'0');
     n=str.size();     
}

int dp(int pos,int m,bool ch)
{
     if(pos==n+1)
     {
          if(m==0)
               return 1;
          return 0;     
     }
     int &ans=cache[pos][m][ch];
     if(ans!=-1)    
          return ans;
     ans=0;
     if(ch==0)
     {
          for(int i=0;i<=a[pos];i++)
          {
               ans+=dp(pos+1,(m+i)%d,(i==a[pos]?0:1));
               ans%=mod;
          }
     }
     else
     {
          for(int i=0;i<=9;i++)
          {
                ans+=dp(pos+1,(m+i)%d,1);
                ans%=mod;
          }
     }
     return ans;
}

int32_t main()
{
     IOS;
     memset(cache,-1,sizeof cache);
     work();
     int ans=dp(1,0,0);
     ans--;
     ans+=mod;
     ans%=mod;
     cout<<ans;
}


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

int main() {
  int n;
  cin >> n;
  rep(i, 9) {
  int  j = i + 1;
    if (n % j == 0) {
      int ans = n / j;
      if (1 <= ans && ans <=9) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Set(a,b) memset(a,b,sizeof(a))
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
template <typename T> inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
typedef long long ll;
template<typename T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;return;}
template<typename T>inline void Dec(T&x,int y){x-=y;if(x <  0) x+=mod;return;}
template<typename T>inline int fpow(int x,T k){int ret=1;for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ret=(ll)ret*x%mod;return ret;}
inline int Sum(int x,int y){x+=y;if(x>=mod) return x-mod;return x;}
inline int Dif(int x,int y){x-=y;if(x < 0 ) return x+mod;return x;}
int n,K;
const int MAXN=1e5;
int f[101][MAXN];
int bre[MAXN];int cnt=0;
inline int ID(int i){return ((ll)i*i<=n)? i:(cnt-n/i+1);}
int main()
{
	init(n),init(K);
	for(int l=1,r;l<=n;l=r+1){r=n/(n/l);bre[++cnt]=r;}
	bre[0]=0;
	for(int i=1;i<=cnt;++i) f[1][ID(n/bre[i])]=bre[i]-bre[i-1];
	for(int k=2;k<=K;++k) {
		for(int j=cnt;j;--j) Inc(f[k-1][j],f[k-1][j+1]);
		for(int j=1;j<=cnt;++j) Inc(f[k][ID(n/bre[j])],(ll)f[k-1][j]*(bre[j]-bre[j-1])%mod);
	}
	for(int j=cnt;j;--j) Inc(f[K][j],f[K][j+1]);
	cout<<f[K][1]<<endl;
	return 0;
}


Measured memory_bytes: 38656
//https://cpprefjp.github.io/reference/utility/pair.html ->pair
//https://cpprefjp.github.io/reference/algorithm/sort.html ->sort
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>


int main(){
	int x_buf, y_buf;
	std::vector<std::pair<int, int>> pp;
	
	int n;
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>x_buf>>y_buf;
		pp.push_back({x_buf,y_buf});
	//	std::cout<<pp[i].first<<std::endl;
	//	std::cout<<pp[i].second<<std::endl;
	}

	std::sort(pp.begin(),pp.end());

	for(int i=0;i<n;i++){
		std::cout<<pp[i].first<<" "<<pp[i].second<<std::endl;
	}
	return 0;
}



Measured memory_bytes: 3788
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int a;
  int b;
  cin>>a>>b;
  if((a+b)%2==1){
    cout<<(a+b)/2+1<<endl;
  }else{
    cout<<(a+b)/2<<endl;
  }
    
}


Measured memory_bytes: 3524
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<int> E[110000];

P func(int pos, int pre){
	
	P ret = P(1, 1);
	
	for(int i = 0; i < E[pos].size(); i++){
		if(pre != E[pos][i]){
			P hoge = func(E[pos][i], pos);
			ret.first *= (hoge.first + hoge.second);
			ret.first %= MOD;
			ret.second *= hoge.first;
			ret.second %= MOD;
		}
	}
	return ret;
}

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N - 1; i++){
		int x, y;
		cin >> x >> y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	
	P ans = func(1, 0);
	
	cout << (ans.first + ans.second) % MOD << endl;
	
	return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,m,a[N],c;
vector<int>e[N];
void dfs(int u)
{
	a[u]=1;
	for(auto v:e[u])
		if(!a[v])
			dfs(v);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
	{
		if(!a[i])
		{
			c++;
			dfs(i);
		}
	}
	printf("%d\n",c-1);
	return 0;
}

Measured memory_bytes: 10160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

 int main(){
    ll N; cin >> N;
    map<string,ll> a;
    rep(i, N){
        string s; cin >> s;
        a[s] = 0;
    }
    pt(a.size());
    return 0;
 }

Measured memory_bytes: 19224
#include<iostream>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int a = 0, b = 0, c = 0;

	CI a >> b >> c;
	
	if (a < b && b < c) {
		CO "Yes" E
	}
	else {
		CO "No" E
	}
	
}

Measured memory_bytes: 1156
#include<stdio.h>

int Binary(int a[], int key, int n){
  int left  = 0;
  int right = n;
  int mid;

  while (left < right) {
    mid = (right + left) /2;
    if (key == a[mid])
      return 1;
    if (key > a[mid]) {
      left = mid+1;
    } else if (key < a[mid]) {
      right = mid;
    }
  }
  return 0;
}

int main(){
  int i, q, key, a[1000000], n;
  int sum = 0;

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

  scanf("%d", &q);
  for (i=0; i<q; i++) {
    scanf("%d", &key);
    if (Binary(a, key, n)==1)
      sum++;
  }

  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    int t=0;
    int n=s.size();
    REP(i,n) t+=s[i]-'0';
    cout << (t%9?"No":"Yes") << endl;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s = " "){
  for(int i=0;i<(int)a.size();i++)cout<<(i? s:"")<<a[i];cout<<endl;
}
#define MAX_N N
class BIT{
public:
  typedef long long ll;
  int n;
  ll bit0[MAX_N+1],bit1[MAX_N+1];//1オリジン
  
  BIT(){n = MAX_N;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  BIT(int n){this->n=n;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  
  ll sum(ll *b,int i){
    ll s=0;
    while(i>0){
      s=(s+b[i]);
      i-=i&-i;
    }
    return s;
  }

  void add(ll *b,int i,ll v){
    while(i<=n){
      b[i]=(b[i]+v);
      i+=i&-i;
    }
  }

  //[a,b]にxを加算(1<=a)
  void add (int a,int b,ll x){
    add(bit0,a,-x*(a-1));
    add(bit1,a,x);
    add(bit0,b+1,x*b);
    add(bit1,b+1,-x);
  }

  //[a,b]のsumを得る(1<=a)
  ll sum(int a,int b){
    ll res=0;
    res+=sum(bit0,b)+sum(bit1,b)*b;
    res-=sum(bit0,a-1)+sum(bit1,a-1)*(a-1);
    return res;
  }
};

bool calc(string s, int len){
  int n = s.size();
  BIT bit(n+1);
  char ch = s[0];
  for(int i=0;i<n;i++){
    int a = bit.sum(i+1,i+1);
    
    if((a%2 == 0 && s[i] == ch) || (a%2 == 1 && s[i] != ch)) {
      if(i + len > n) return i>=len;
      bit.add(i+1,i+len,1);
    }

  }
  return 1;
}
signed main(){
  string s;
  cin>>s;
  
  int L = 1, R = s.size()+1;
  while(L+1<R){
    int M = (L+R)/2;
    if(calc(s,M) == 0) R = M;
    else L = M;
  }
  cout<<L<<endl;

  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,p[2][202020],has;
char a[202020];
ll hey(ll aa,ll bb,ll cc)
{
	return (p[cc][bb]-p[cc][aa-1]);
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)p[0][i]=p[0][i-1]+(a[i]=='.');
	for(i=1;i<=n;i++)p[1][i]=p[1][i-1]+(a[i]=='#');
	has=1e18;
	for(i=0;i<=n;i++)
		has=min(has,hey(1,i,1)+hey(i+1,n,0));
	cout<<has<<"\n";
}	

Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL fac[2000005];
LL inv[2000005];

LL pwr(LL x,LL y){
	LL ans = 1,tmp = x;
	while(y){ if(y & 1) ans = (ans * tmp) % N; tmp = (tmp * tmp) % N; y >>= 1; }
	return ans;
}

void init(){
	fac[0] = 1; for(LL i = 1;i <= 2000000;i ++) fac[i] = (fac[i - 1] * i) % N;
	for(LL i = 0;i <= 2000000;i ++) inv[i] = pwr(fac[i],N - 2);
}

LL C(LL x,LL y){
	return ((fac[x] * inv[y]) % N * inv[x - y]) % N;
}

struct node{
	LL x,y;
}s[3005];
bool cmp(node x,node y){ return x.x == y.x ? x.y < y.y : x.x < y.x; }

LL dp[3005] = {0};

int main(){
	LL h,w,n;
	init();
	scanf("%lld %lld %lld",&h,&w,&n);
	for(LL i = 1;i <= n;i ++) scanf("%lld %lld",&s[i].x,&s[i].y);
	sort(s + 1,s + 1 + n,cmp);
	s[0].x = 1; s[0].y = 1;
	++ n; s[n].x = h; s[n].y = w;
	dp[0] = 1;
	for(LL i = 1;i <= n;i ++){
		for(LL j = 0;j < i;j ++){
			if(s[j].y <= s[i].y){
				dp[i] -= dp[j] * C(s[i].y + s[i].x - s[j].y - s[j].x,s[i].x - s[j].x) % N;
				dp[i] = (dp[i] + N) % N;
			}
		}
	}
	printf("%lld\n",(N - dp[n]) % N);
	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

int main() {
  // FILE;
  SPEED;
  
  int n;
  cin>>n;
  int k;
  cin>>k;
  int arr[n];

  fain(arr);

  int dp[n];

  dp[n-1]=0;

  for(int i=n-2;i>=n-k;i--){

    int mini=INT_MAX;

    for(int j=i+1;j<=n-1;j++){

      mini=min(mini,abs(arr[j]-arr[i])+dp[j]);

    }
     dp[i]=mini;

  } 

  for(int i=n-k-1;i>=0;i--){
    int mini=INT_MAX;
    for(int j=1;j<=k;j++){
      mini=min(mini,abs(arr[i]-arr[i+j])+dp[j+i]);
    }
     dp[i]=mini;
  }

  cout<<dp[0]<<endl;

}

Measured memory_bytes: 1024
// Hope is a good thing maybe the best of things and no good thing ever dies

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0)
#define testcase ll T; cin >> T; for (int tc = 1; tc <= T; tc++)
const long long M = 2e5 + 10, M2 = 1e6 + 10, oo = 1e9 + 7;
ll hon[20][20];
bool ison (int N, int pos) {
    return (bool) (N & (1LL << pos));
}
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(hon, -1, sizeof hon);
    ll n, ans = 0;
    cin >> n;
    for (int i = 1, a; i <= n; i++) {
        cin >> a;
        for (int j = 0, x, y; j < a; j++) {
            cin >> x >> y;
            hon[i][x] = y;
        }
    }
    bool ok = true;
    for (int i = 0; i < (1LL << n); i++) {
        ok = true;
        for (int j = 0; j < n; j++) {
            if (ison(i, j)) {
                for (int k = 0; k < n; k++) {
                    if (hon[j + 1][k + 1] != -1 and hon[j + 1][k + 1] != ison(i, k)) {
                        //cout << i << " " << j << " " << k << " " << ison(i, k) << " " << hon[j + 1][k + 1]<< endl;
                        ok = false;
                    }
                }
            }
        }
        if (ok) ans = max(ans, (ll)__builtin_popcountll(i));
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	string number;
	int sum[1000];
	int j = 0;
	while(1){
		sum[j] = 0;
		cin >> number;
		if(number == "0"){
			sum[j] = 0;
			break;
		}
		for (int i =0; i < number.length(); i++){
			sum[j] += number[i] - '0';
		}
		j++;
	}
	j = 0;
	while(1){
		if(sum[j] == 0)
			break;
		cout << sum[j] << endl;
		j++;
	}
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        const int MaxPlug = 20;
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int needItems = 0;
        for (int i = 0; i < MaxPlug; i++)
        {
            if ((needItems * a - (needItems - 1)) < b)
            {
                needItems ++;
            }
            else
            {
                break;
            }
        }
        Console.WriteLine(needItems);
    }
}


Measured memory_bytes: 13140
n = gets.to_i
cities = Array.new
n.times do
  cities << gets.split.map(&:to_i)
end
sum = 0.0
count = 0
cities.combination(2).each do |a, b|
  sum += Math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
  count += 1
end
average = sum / count
puts average * (n - 1)


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

#define ll long long
using namespace std;

const int N = 3005;
int n;
double p[N], dp[N][N];

// dp[N][K] = probability that #heads = K

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= i; j++) {
            dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
        }
    }
    double ans = 0;
    for(int i = (n + 1) / 2; i <= n; i++) {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 69120
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
inline void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
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;}
template<class T> inline void operator>>(istream& is,vector<T>& v) { for(int& i : v){ is>>i; } }
template<class T> inline void operator<<(ostream& os,const vector<T>& v) { for(int i : v){ os<<i<<" "; } os<<endl; }
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    ll sum = 0;
    rep2(i,1,n+1){
        if(i%3 != 0 && i%5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
}


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

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

	vector<int> A(N);
	for (int i = 0; i < N-1; ++i) {
		int temp;
		cin >> temp;
		++A[temp - 1];
	}

	for (auto t : A) {
		cout << t << endl;
	}

	return 0;
}

Measured memory_bytes: 3560
#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;
	cin >> s;
	set<char> values;
	rep(i,s.size()){
		values.insert(s[i]);
	}
	if(values.size() == 26)
		cout << "None" << endl;
	else{
		for(char c = 'a' ; c < 'z' +1; c++){
				if(values.count(c)) continue;
				else{
					cout << c << endl;
					return 0;
				}
			}
		}
	}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    //cout<<h<<endl;
    while(cin>>a>>b){
        if(a==1)a+=13;
        if(b==1)b+=13;
        if(a==b)cout<<"Draw"<<endl;
        else if(a>b)cout<<"Alice"<<endl;
        else cout<<"Bob"<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());

		string[] args;

		args = Console.ReadLine().Split(' ');
		int[] V = new int[N];
		for(int i = 0; i < N; i++)
			V[i] = Int32.Parse(args[i]);

		args = Console.ReadLine().Split(' ');
		int[] C = new int[N];
		for(int i = 0; i < N; i++)
			C[i] = Int32.Parse(args[i]);

		int ans = Int32.MinValue;
		for(int mask = 0; mask < (1 << N); mask++)
		{	
			int X = 0;
			int Y = 0;
			for(int i = 0; i < N; i++)
			{
				if(((mask >> i) & 1) == 0)
					continue;
				X += V[i];
				Y += C[i];
			}
			ans = Math.Max(ans,X-Y);
		}

		Console.WriteLine(ans);
	}
}





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

typedef long long ll;
ll gcd(ll x,ll y) {
	ll p = max(x,y);
	ll q = min(x,y);
	while (p % q != 0) {
		p %= q;
		ll temp = q;
		q = p;
		p = temp; 
	}
	return q;
}
int main() {
	bool ans = true;
	ll n,m;
	cin >> n >> m;
	string s,t;
	cin >> s >> t;
	int gd = gcd(n,m);
	ll xlen = (n/gd) * (m/gd) * gd;
	for (int i = 0;i < (gd);i++) {
		if (s[(n/gd)*i] != t[(m/gd)*i]) {ans = false;}
	}
	xxx:if (!ans) {
		cout << -1 << endl;
	} else {
		cout << xlen << endl;
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
long long f(long long a) {
     long long res[] = {a,1,a+1,0};
     return res[a%4];
}

long long getXor(long long a, long long b) {
     return f(b)^f(max(0LL,a-1));
}
int main()
{
  ll a,b;
  cin>>a>>b;
  ll ans=getXor(a,b);
  cout<<ans<<endl;
}


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

int main(){
    long long a,b,k,c,d;
    cin>>a>>b>>k;
    if(a>k){
        c=a-k;
        d=b;
    }else{
        if(b>k-a){
            c=0;
            d=b+a-k;
        }
        else{
            c=0;
            d=0;
        }
    }

    cout<<c<<' '<<d<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int N=1e5+10;
int p[N];
int ans;
int find(int u){
    return p[u]==u?p[u]:p[u]=find(p[u]);
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;++i)p[i]=i;
    for(int i=1;i<=m;++i){
        int a,b;
        cin>>a>>b;
        a=find(a),b=find(b);
        if(a!=b)p[a]=b;
    }
    for(int i=1;i<=n;++i){
        if(i==p[i])ans++;
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 3972
#include<iostream>
#include<map>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	map<string,bool> dt;
	string s;
	rep(i,n){
		cin>>s;
		dt[s]=true;
	}
	cin>>n;
	bool door=false;
	rep(i,n){
		cin>>s;
		if(dt[s]){
			if(door){
				cout<<"Closed by "<<s<<endl;
			}else{
				cout<<"Opened by "<<s<<endl;
			}
			door=!door;
		}else cout<<"Unknown "<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1240
from collections import deque

h, w = map(int, input().split())
maze = [0] * h
for i in range(h):
    maze[i] = list(input())
# print(maze)
INF = int(1e10 + 7)
d = [[INF] * w for i in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

# que = deque([('x', 'y')])
# print(que)
# print(que[0])

def bfs(x, y):
    d = [[INF] * w for i in range(h)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([(x, y)])
    d[x][y] = 0

    while len(que) != 0:
        val = que.popleft()

        for i in range(4):
            nx = val[0] + dx[i]
            ny = (val[1] + dy[i])
            if (0 <= nx < h and 0 <= ny < w and maze[nx][ny] != '#' and d[nx][ny] == INF):
                que.append((nx, ny))
                d[nx][ny] = d[val[0]][val[1]] + 1
    maxval = 0
    for i in range(h):
        for j in range(w):
            if d[i][j] > maxval and d[i][j] != INF:
                maxval = d[i][j]
    return maxval

maxans = 0
cnt = []
for i in range(h):
    for j in range(w):
        if maze[i][j] != '#':
            if bfs(i, j) > maxans:
                maxans = bfs(i, j)
print(maxans)

Measured memory_bytes: 3316