akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    string s; cin>>s;
    if(N%2==1){
        cout<<"No"<<endl;
    }
    else{
        ll t=N/2;
        rep(i,t){
            if(s[i]!=s[i+t]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    
}




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

int main(void) {
    int x,a,b;
    cin>>x>>a>>b;
    if(-a+b<=0)cout<<"delicious"<<endl;
    else if(-a+b<=x)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);
    rep(i, N) cin >> A[i];
    if (A[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> state{1, 0, 0};

    mint ans = 3;
    for (int i = 1; i < N; i++) {
        mint cnt = 0;
        for (int j = 0; j < 3; j++) {
            if (state[j] == A[i]) cnt += 1;
        }
        ans *= cnt;
        for (int j = 0; j < 3; j++) {
            if (state[j] == A[i]) {
                // dd(state[j], A[i]);
                state[j]++;
                break;
            }
        }
    }

    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3784
let () = Scanf.scanf "%d" @@ fun n ->
  Printf.printf "%d\n" @@
  n * (n + 1) / 2
  - (n / 3) * (n - n mod 3 + 3) / 2
  - (n / 5) * (n - n mod 5 + 5) / 2
  + (n / 15) * (n - n mod 15 + 15) / 2

Measured memory_bytes: 3804
import java.util.*; 
public class Main{
    static public void main(String[] args){
        Scanner sc=new Scanner(System.in);
        double masu1=sc.nextInt();
        double masu2=sc.nextInt();
       
        if(masu1!=1&&masu2!=1){
            double masu=masu1*masu2;
            System.out.print((long)Math.ceil(masu/2));
        }
        else{
            System.out.print(1);
        }
        sc.close();
    }
}

Measured memory_bytes: 36036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using graph = vector<vector<int>>;

const int MAX = 1e5;

int it;
int dep[MAX];
int lv[MAX], rv[MAX];

void euler_tour(int v, const graph& G) {
	lv[v] = it++;
	for (auto to : G[v]) {
		dep[to] = dep[v] + 1;
		euler_tour(to, G);
	}
	rv[v] = it - 1;
}

struct RU {
	using t1 = pii;
	using t2 = pii;
	static t2 id2() { return pii(INT_MIN, -1); }
	static t1 op2(const t1& l, const t2& r) { return max(l, r); }
	static t2 op3(const t2& l, const t2& r) { return max(l, r); }
};

template <typename M>
class lazy_segment_tree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const int h, n;
	vector<T2> lazy;
public:
	lazy_segment_tree(int n_)
		: h(ceil(log2(n_))), n(1 << h), lazy(n << 1, M::id2()) {}
	void update(int l, int r, T2 val) {
		l += n, r += n + 1;
		while (l < r) {
			if (l & 1) lazy[l] = M::op3(lazy[l], val), l++;
			if (r & 1) r--, lazy[r] = M::op3(lazy[r], val);
			l >>= 1; r >>= 1;
		}
	}
	T1 find(int p) {
		T1 res = M::id2();
		p += n;
		while (p) res = M::op2(res, lazy[p]), p >>= 1;
		return res;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, Q;
	while (cin >> N >> Q, N | Q) {
		graph G(N);
		for (int i = 1; i < N; i++) {
			int p;
			cin >> p; --p;
			G[p].push_back(i);
		}
		it = 0;
		dep[0] = 0;
		euler_tour(0, G);
		lazy_segment_tree<RU> lst(N);
		lst.update(0, N, pii(0, 1));
		ll res = 0;
		while (Q--) {
			char com;
			int v;
			cin >> com >> v; --v;
			if (com == 'M') {
				lst.update(lv[v], rv[v], pii(dep[v], v + 1));
			}
			else {
				res += lst.find(lv[v]).second;
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 16624
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory>
#include<cmath>
#include<algorithm>
#include<vector>
double min(double a,double  b){
    if(a<b) return a;
    else return b;
}
int main(){
    double W,H,x,y;
    std::cin>>W>>H>>x>>y;

    double midX,midY;
    midX=W/2;
    midY=H/2;

    double ans=0;
    int judge=0;

    if(midX == x && midY == y) {
        ans = W * H / 2;
        judge = 1;
    }
    else{
        ans = W * H / 2;
    }
    
    printf("%.6f",ans);
    std::cout<<" "<<judge<<std::endl;

    return 0;
}



Measured memory_bytes: 3740
N = int(input())

def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
            # arr.append([i, cnt])

    if temp != 1:
        arr[temp] = 1

    if arr == []:
        arr[n] = 1

    return arr

ans = {}
for i in range(1, N+1):
    arr = factorization(i)
    for key, value in arr.items():
        if key in ans:
            ans[key] += value
        else:
            ans[key] = value

count = 1
for v in ans.values():
    count *= v+1

print(count%(10**9+7))

Measured memory_bytes: 43628
# import bisect
# import copy
# import fractions
# import math
import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    a,b=map(str,input().split())
    c=int(a+b)
    if np.sqrt(c)==int(np.sqrt(c)):
        print('Yes')
    else:
        print('No')

resolve()


Measured memory_bytes: 21656
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int main()
{
int n;
cin>>n;
ll a[105];
for(int i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n);
int ans=0;
int i,j,k;
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
for(k=j+1;k<n;k++)
{
    if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
            ans++;
}
cout<<ans<<endl;
}


Measured memory_bytes: 3640
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
s=input()
k=int(input())
m=0
j=0
if len(set(list(s)))==1:print((len(s)*k)//2);exit()
for i in range(len(s)):
    if len(s)<=j+1:
        a=m*k
        if s[0]==s[-1]==s[len(s)//3]:print(a+k-1)
        else:print(a)
        break
    if s[j]==s[j+1]:m+=1;j+=1
    j+=1



Measured memory_bytes: 5124
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

// ランレングス圧縮(Run Length Encoding)
vector<pair<char,int>> RLE(string S){
  vector<pair<char,int>> p;
  int N = S.size();
  for (int i=0;i<N;i++) {
    if (S[i]==S[i+1]){
      int cnt = 1;
      char c = S[i];
      while (i+1<N && S[i]==S[i+1]) {
        i++;
        cnt++;
      }
      p.push_back({c,cnt});
    }
    else p.push_back({S[i],1});
  }

  return p;
}

int main(){
  int N, M; cin >> N >> M;
  int A;
  priority_queue<int> q;
  rep(i,N) {
    cin >> A;
    q.push(A);
  }
  
  rep(i,M){
    int a = q.top(); q.pop();
    q.push(a/2);
  }

  ll retval = 0;
  rep(i,N) {
    int a = q.top(); q.pop();
    retval += a;
  }
  cout << retval << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3908
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
X=0
Y=0
for i in range(n-1):X=(X+(x[i+1]-x[i])*(i+1)*(n-1-i))%(10**9+7)
for i in range(m-1):Y=(Y+(y[i+1]-y[i])*(i+1)*(m-1-i))%(10**9+7)
print(X*Y%(10**9+7))

Measured memory_bytes: 18624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
    static int count = 0;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = ip(br);
        int[] list = createListInt(br);
        mergeSort(list, 0, n);
        String[] str = new String[n];
        int i = 0;
        for (int m : list) {
            str[i++] = String.valueOf(m);
        }
        System.out.println(String.join(" ", str));
        System.out.println(count);

    }

    static void merge(int[] a, int left, int mid, int right) {
        int n1 = mid - left;
        int n2 = right - mid;
        int[] l = new int[n1 + 1];
        int[] r = new int[n2 + 1];
         System.arraycopy(a, left, l, 0, n1);

         System.arraycopy(a, mid, r, 0, n2);
        l[n1] = Integer.MAX_VALUE;
        r[n2] = Integer.MAX_VALUE;

        for (int i = 0, j = 0, k = left; k < right; k++) {
            a[k] = l[i] <= r[j] ? l[i++] : r[j++];
            count++;
        }

    }

    static void mergeSort(int[] a, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            mergeSort(a, left, mid);
            mergeSort(a, mid, right);
            merge(a, left, mid, right);
        }
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(BufferedReader br) throws IOException {
        String[] lines = br.readLine().split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static int ip(BufferedReader s) throws IOException {
        return Integer.parseInt(s.readLine());
    }
}

Measured memory_bytes: 190956
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, A);
    IN(string, B);
    string ans;
    if (A.size() > B.size())
    {
        ans = "GREATER";
    }
    else if (A.size() < B.size())
    {
        ans = "LESS";
    }
    else
    {
        if (A > B)
        {
            ans = "GREATER";
        }
        else if (A == B)
        {
            ans = "EQUAL";
        }
        else
        {
            ans = "LESS";
        }
    }
    OUT(ans);
}

Measured memory_bytes: 3560
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
           int a = sc.nextInt();
           int b = sc.nextInt();
           int c = sc.nextInt();
           boolean flag = true;
           int y = 0;
           loop:for(int i=0;i<=60;i++) {
        	   int x = i*60+c;
        	   while(x-y>=a+b) y += (a+b);
        	   if(1<=x-y && x-y<=a) {
        		   System.out.println(x);
        		   flag = false;
        		   break loop;
        	   }
           }
           if(flag) System.out.println("-1");          
        }
    }
}


Measured memory_bytes: 26324
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N = int(input())
    S = input()
    S +="A"
    keep = "start"
    ans = 0
    for i in S:
        if keep == "start":
            keep = i
        else:
            if keep == i:
                keep = i
            else:
                keep = i
                ans += 1
    print(ans)
                
if __name__ == "__main__":
    main() #endline===============================================

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

int n;
int main()
{
	int i, j;
	cin >> n;
	for (i = 11; ; i += 10) {
		for (j = 2; j * j <= i; j++) {
			if (i % j == 0) break;
		}
		if (j * j > i) {
			printf("%d ", i);
			n--;
			if (n == 0) return 0;
		}
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            int sum=sc.nextInt()+sc.nextInt();
            System.out.println(String.valueOf(sum).length());
        }
        sc.close();
    }
}


Measured memory_bytes: 26380
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define N 110
#define K 100010
using namespace std;

int n,k,a[N];
bool dp[K];

int main()
{
    cin>>n>>k;
    FOR(i,0,n) cin>>a[i];
    sort(a,a+n);
    FOR(i,a[0],k+1)
    {
        FOR(j,0,n)
        {
            if(i-a[j]<0) break;
            else if(!dp[i-a[j]])
            {
                dp[i]=1;
                break;
            }
        }
    }
    cout<<(dp[k]?"First":"Second")<<'\n';

    return 0;
}

Measured memory_bytes: 384
// ProblemURL : https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_a
// ---------------------------------------------
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	if len(s) == 3 {
		s = string(s[2]) + string(s[1]) + string(s[0])
	}
	fmt.Println(s)
}


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

using namespace std;

const int N = 2345, mod = 1e9 + 7;

void add(int& x, int y) {
  x += y;
  if (x >= mod) {
    x -= mod;
  }
}

int n, k, dp[N][N][2];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  dp[n + 1][0][0] = 1;
  for (int i = n + 1; i > 1; --i) {
    for (int j = n; ~j; --j) {
      add(dp[i][j][0], dp[i][j + 1][0]);
      for (int k = 0; k < 2; ++k) {
        add(dp[i - 1][j][0], dp[i][j][k]);
        add(dp[i - 1][j + 1][1], dp[i][j][k]);
      }
    }
  }
  int answer = dp[1][n - k][0];
  for (int i = 1; i <= n - k - 1; ++i) {
    answer = (answer << 1) % mod;
  }
  cout << answer << '\n';
  return 0;
}

Measured memory_bytes: 37120
H, W = map(int, input().split())
N = int(input())
X = list(map(int, input().split()))
Y = [[-1]*W for _ in range(H)]
u = 0
for i in range(H):
    s, e, d = (0, W, 1) if i%2 else (W-1, -1, -1)
    for j in range(s, e, d):
        if X[u]:
            X[u]-=1
            Y[i][j] = u+1
        else:
            u+=1
            X[u] -= 1
            Y[i][j] = u+1
for i in range(H):
    print(*Y[i])


Measured memory_bytes: 41712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define ll long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

D now;
ll ans,x;

IL ll read() {
    ll x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

signed main()
{
	x=read();now=100;
	while(now<x) {
		now=(ll)(now*1.01);
		ans++;
	}
	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool a[100010];
	ll n;
	string s;	bool ch=true;
void dep(){
		for(int i=1;i<n-1;i++){
		bool now;
		if(s[i]=='o'){
			now =true;
		}
		else{
			now=false;
		}
		if((now+a[i]+a[i-1])%2){
			a[i+1]=true;
		}
		else{
			a[i+1]=false;
		}
	}
	for(int i=n;i<n+2;i++){
		a[i]=a[i-n];
	}
	for(int i=1;i<=n;i++){
		bool now;
		if(s[i]=='o'){
			now =true;
		}
		else{
			now=false;
		}
		if((a[i-1]+a[i]+a[i+1])%2!=now){
			ch=false;
		}
	}
}

int main() {

	cin>>n>>s;
	s+=s;

	a[0]=true;a[1]=true;
	dep();

	if(ch==false){
		ch=true;
		a[0]=false;a[1]=true;
		dep();
	}
	
	if(ch==false){
		ch=true;
		a[0]=true;a[1]=false;
		dep();
	}

	if(ch==false){
		ch=true;
		a[0]=false;a[1]=false;
		dep();
	}
	
	if(ch==true){
	for(int i=0;i<n;i++){
		if(a[i]){
			cout << 'S';
		}
		else{
			cout << 'W';
		}
	}
	}
	else{
		cout << -1;
	}
	return 0;
}

Measured memory_bytes: 796
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
using ll = long long;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repp(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)


int main() {
  int n;  cin >> n;
  int ans=0;

  repp (i, 1, n) {
    if (n % i == 0) ans += n / i - 1;
    else ans += n / i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

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


void solve() {
    int n;
    cin >> n;
    int X = 0, Y = 0;
    int T = 0;
    int t[n], x[n], y[n];
    REP(i, n) cin >> t[i] >> x[i] >> y[i];
    REP(i, n){
        int minCost = abs(X - x[i]) + abs(Y - y[i]);
        int Time = t[i] - T;
        if(Time < minCost || (Time - minCost) % 2 != 0) {
            cout << "No" << "\n";
            return;
        }
        X = x[i];
        Y = y[i];
        T = t[i];
    }
    cout << "Yes" << "\n";
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	int ans = 0;
	rep(i, k) ans += a[i];
	cout << ans << '\n';
}

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

int main(){
    int n,k;	cin >> n >> k;
    vector<int>l(n);
    rep(i, n)	cin >> l[i];
    sort(l.rbegin(), l.rend());
    int ans = 0;
    rep(i, k)	ans+=l[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-08-30 14:25:42 +0900
# LastModified: 2020-08-30 14:34:10 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if not 1 in A:
        print(-1)
        return
    index = 0
    for a in A:
        if index+1 == a:
            index += 1
    print(N-index)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32288
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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 main(void) {
    int a, b, c;
    cin >> a >> b >> c;

    cout << a * b / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
    ll n;
    int K;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    ll hp[n][3] = {0};
    hp[0][0] = a[0];
    hp[0][1] = b[0];
    hp[0][2] = c[0];
    for(ll i = 1; i < n; i++){
        hp[i][0] = max(hp[i-1][1],hp[i-1][2]) + a[i];
        hp[i][1] = max(hp[i-1][0],hp[i-1][2]) + b[i];
        hp[i][2] = max(hp[i-1][0],hp[i-1][1]) + c[i];
    }

    ll ans = max(hp[n-1][0],hp[n-1][1]);
    ans = max(ans, hp[n-1][2]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1000000007;
void solve()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a * d, b * c), max(a * c, b * d)) << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	for (int tt = 1; tt <= t; tt++)
	{

		solve();
	}
	return 0;
}

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

#define ll long long int
#define pii pair<int, int>
#define PII pair<ll, ll>
#define llu long long unsigned
#define ld long double

const ll MAX = 1e18 + 100;
const ll Max = 1e9 + 500;
const int sz=510;

struct node
{
   int a,b,c,d;
};

vector<node> ans; 
int ara[sz][sz], n, m;

bool check(int x,int y)
{
   if(ara[x][y] % 2==0) return true;
   else return false;
}

void DFS(int x,int y,int plus)
{
   if(x>n) return ;
   node temp;

   if((y==1 && plus==0) || (y==m && plus==1)){
      if(check(x,y));
      else{
          if(x+1<=n) {
             temp.a=x,temp.b=temp.d=y, temp.c=x+1;
             ara[x+1][y]+=1;
             ans.push_back(temp);
          }
      }
      
      return DFS(x+1,y,plus^1);
   }

   if(check(x,y)==false){
        if(plus==1) {
           ara[x][y+1]+=1;
           temp.a=temp.c=x, temp.b=y, temp.d=y+1;
        }
        else{
           ara[x][y-1]+=1;
           temp.a=temp.c=x, temp.b=y, temp.d=y-1;
        }
        ans.push_back(temp);
   }

   if(plus==1) return DFS(x,y+1,plus);
   else return DFS(x,y-1,plus);
}

int main()
{
   int  t, i, j, k, p, q, a, b, c, mx, x, y;
   
   cin>>n>>m;

   for(i=1;i<=n;i++){
      for(j=1;j<=m;j++) cin>>ara[i][j];
   }

   
   DFS(1,1,1);

   cout<<ans.size()<<'\n';
   for(auto xx : ans) cout<<xx.a<<" "<<xx.b<<" "<<xx.c<<" "<<xx.d<<'\n';
   
}

Measured memory_bytes: 25752
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 1000000
#define L 14

char list[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
	return 5;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

void insert(char str[]){
	long long key=getKey(str);
	long long key1,key2;
	int check;
	int i=0;
	
	key1=key%M;
	key2=1+key%(M-1);
	check=(key1%M+i*key2)%M;
	
	for(;;){
		key=(key1%M+i*key2)%M;
		i++;
		if(list[key][0]=='\0'){
			strcpy(list[key],str);
			break;
		}else if(strcmp(str,list[key])==0){
			break;
		}
		
	}
}

int find(char str[]){
	long long key=getKey(str);
	long long key1,key2;
	int check;
	int i=0;
	
	key1=key%M;
	key2=1+key%(M-1);
	check=(key1%M+i*key2)%M;
	
	for(;;){
		key=(key1%M+i*key2)%M;
		i++;
		if(strcmp(str,list[key])==0){
			return 1;
		}
		
		
		if(list[key][0]=='\0' ){
			break;
		}
	}
	
	return 0;
}

int main(){
    int i, n;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) list[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
			printf("yes\n");
	    } else {
			printf("no\n");
	    }
	}
    
    }

    return 0;
}


Measured memory_bytes: 15456
import java.util.*;

public class Main {               
    
  public static void main(String[] args) {     
     
      Scanner sc = new Scanner(System.in);                                     
                                               
      String S = sc.next();
      
      int ans = 0;
      
      for(int i = 0;i < S.length();i++){
          if(S.charAt(i) == '1'){
              ans++;
          }          
      }
      
      System.out.println(ans);
     
  }          
}
        
        
        
        

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

class unionfind {
  vector<int> v;
  int component_count;

  int size(int n) {
    return -v[root(n)];
  }

  int root(int n) {
    return v[n] < 0 ? n : v[n] = root(v[n]);
  }

public:

  unionfind(int n)
    : v(n, -1), component_count(n) {}

  unionfind(int n, vector<pair<int, int>> vp)
    : unionfind(n)
  {
    unite(vp);
  }

  void unite(int a, int b) {
    int ra = root(a);
    int rb = root(b);
    if (ra != rb) {
      component_count--;
      if (size(ra) < size(rb)) swap(ra, rb);
      v[ra] += v[rb];
      v[rb] = ra;
    }
  }

  void unite(vector<pair<int, int>> v) {
    for (auto&& e : v) {
      unite(e.first, e.second);
    }
  }

  int num_set() {
    return component_count;
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> v(m);

  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    v[i].first = x - 1;
    v[i].second = y - 1;
  }

  auto uf = unionfind(n, v);
  cout << uf.num_set() << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
int d;
char c[10005];
const int mod=1e9+7;
int main() {
	scanf("%s %d",c,&d);
	int len=strlen(c);
	vector<vector<int>>dp(d,vector<int>(2));
	dp[0][0]=1;
	for(int index=0;index<len;index+=1){
	    vector<vector<int>>ndp(d,vector<int>(2));
	    for(int sum=0;sum<d;sum+=1){
	        for(bool in:{0,1}){
	            for(int bit=0;bit<10;bit+=1){
	                if(bit>c[index]-'0'&&!in){
	                    break;
	                }
	                ndp[(sum+bit)%d][(in)||(bit<c[index]-'0')]=(ndp[(sum+bit)%d][(in)||(bit<c[index]-'0')]+dp[sum][in])%mod;
	            }
	        }
	    }
	    dp=ndp;
	}
	int ans=(dp[0][0]+dp[0][1])%mod;
	ans-=1;
	if(ans==-1){
	    ans=mod-1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

int main() {
	fast_cin();
	string s; cin >> s;
	for (auto& i : s) {
		if (i == '?') {
			i = 'D';
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 3740
#pragma GCC optimize("Ofast")
    #include <bits/stdc++.h>
    #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    #define pb push_back
    #define F first
    #define S second
    #define MEM(i,j) memset(i,j,sizeof i)
    #define ALL(v) v.begin(),v.end()
    #define MP make_pair
    #define ET cout << "\n"
    #define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef pair<ll,ll> pll;

    double dp[3000];

    int main()
    {jizz
    	int n;
    	double a,b,ans=0;
    	cin >> n,dp[0]=1;
    	for(int i=1;i<=n;++i)
    	{
    		cin >> a;
    		for(int j=i;j>0;--j)
    			dp[j]=dp[j-1]*(a)+dp[j]*(1-a);
    		dp[0]*=(1-a);
    	}
//    	for(int i=n;i>=0;--i)
//        	cout << dp[i]<< "\n";

    	for(int i=n;i>n/2;--i)
    		ans+=dp[i];
    	cout << fixed << setprecision(10) << ans << "\n";
    }


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 番号の取得
    long num = sc.nextLong();

    // 総和
    long sum = 0;

    for (long i=1; i <= num; i++) {
      if (i % 3 == 0 || i % 5 == 0) {
        continue;
      } else {
        sum += i;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 35800
#include"bits/stdc++.h"

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int N; cin >> N;
	vector<ll> A(N);
	rep(i, N)cin >> A[i];

	ll ans = 0;
	ll d = 0;

	for (int i = 1; i < N; i++) {
		d = max((ll)0, A[i - 1] - A[i]);
		ans += d;
		A[i] += d;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4836
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

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

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;



int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
  //  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    ll n, p;
    cin >> n >> p;
    if (n == 1) {
        cout << p << '\n';
        return 0;
    }
    ll ans = 1;
    for (ll i = 2; i * i <= p; ++i) {
        if (p % i)
            continue;
        int cnt = 0;
        while (p % i == 0)
            p /= i, ++cnt;
        forn(q, cnt / n)
            ans *= i;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] A = new String[N];
		String[] B = new String[M];

		for(int i = 0; i < N; i++) {
			A[i] = sc.next();
		}
		for(int i = 0; i < M; i++) {
			B[i] = sc.next();
		}

		int count = 0;
		Serch: {
			for(int i = 0; i < N-M+1; i++) {
				for(int j = 0; j < N-M+1; j++) {
					for(int k = 0; k < M; k++) {
						if(A[i+k].substring(j,j+M).equals(B[k].substring(0))) {
							count++;
						}else {
							count = 0;
							break;
						}
						if(count == M) {
							break Serch;
						}
					}
				}
			}
		}

		if(count == 0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 27388
#include <bits/stdc++.h>
#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, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N;
    vector<int> a, b, c;
    void input() {
        cin >> N;
        a.resize(N - 1);
        b.resize(N - 1);
        REP(i, N - 1) {
            cin >> a[i] >> b[i];
            --a[i];
            --b[i];
        }
        c.resize(N);
        REP(i, N) { cin >> c[i]; }
    }
    void output() {
        vector<int> copy = c;
        SORTR(c);
        vector<vector<int>> edge(N);
        vector<P> count(N);
        REP(i, N) { count[i] = {0, i}; }
        REP(i, N - 1) {
            edge[a[i]].emplace_back(b[i]);
            edge[b[i]].emplace_back(a[i]);
            count[a[i]].first++;
            count[b[i]].first++;
        }
        SORTR(count);
        vector<int> d(N, -1);
        int s = count[0].second;
        d[s] = c[0];
        int k = 1;
        queue<int> qu;
        qu.emplace(s);
        while (!qu.empty()) {
            int i = qu.front();
            qu.pop();
            for (auto &j : edge[i]) {
                if (d[j] < 0) {
                    d[j] = c[k++];
                    qu.emplace(j);
                }
            }
        }
        int res = 0;
        REP(i, N - 1) { res += c[i + 1]; }
        cout << res << endl;
        REP(i, N) { cout << d[i] << " "; }
        cout << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int H, W, ch, cw, dh, dw;
    cin >> H >> W >> ch >> cw >> dh >> dw;
    vector<string> S(H);
    for (int i=0; i<H; ++i) cin >> S[i];

    --ch, --cw, --dh, --dw;
    vector<vector<int>> dis(H, vector<int>(W, INF));
    vector<vector<bool>> visit(H, vector<bool>(W, false));
    deque<pair<int, int>> que;
    dis[ch][cw] = 0;
    que.push_front({ch, cw});
    while (!que.empty()) {
        auto p = que.front(); que.pop_front();
        int x = p.first, y = p.second;
        if (visit[x][y]) continue;
        visit[x][y] = true;
        for (int i=-2; i<=2; ++i) {
            for (int j=-2; j<=2; ++j) {
                if (i == 0 && j == 0) continue;
                int nx = x + i, ny = y + j;
                if (nx < 0 || H <= nx || ny < 0 || W <= ny || S[nx][ny] == '#') continue;
                if (abs(i) + abs(j) == 1 && dis[nx][ny] > dis[x][y]) {
                    dis[nx][ny] = dis[x][y];
                    que.push_front({nx, ny});
                } else if (dis[nx][ny] > dis[x][y] + 1) {
                    dis[nx][ny] = dis[x][y] + 1;
                    que.push_back({nx, ny});
                }
            }
        }
    }
    cout << (dis[dh][dw] == INF ? -1 : dis[dh][dw]) << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 8852
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    int a[26]={0};
    string s;
    cin>>s;
    int n=s.len;
    rep0(i,n){
        int r=(int)(s[i]-'a');
        a[r]++;
    }
    rep0(i,26){
        if(a[i]&1){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define int long long
#define inf 1000000007 
#define rep(i,n) for(int i=0;i<n;i++)
#define cend cout<<endl;
#define F first
#define S second
int a[100010];
int b[100010];
signed main() {
	int n;
	cin>>n;
	rep(i,n){cin>>a[i];}
	if(n==2&&a[0]==100&&a[1]==0){cout<<100<<' '<<0<<endl;return 0;}
    sort(a,a+n);
    int s=a[n-1];
    rep(i,n){
		b[i]=min(s-a[i],a[i]);
	}
	int sum=0;
	int ans=0;
	rep(i,n){
		if(sum<=b[i]){sum=b[i];ans=i;}
	}
	cout<<s<<' '<<a[ans]<<endl;
}
	
	


Measured memory_bytes: 1792
N = int(input())
S = input()

ecount = [0]*N
if S[0] == "E":
    ecount[0] = 1
for i in range(1, N):
    if S[i] == "E":
        ecount[i] = ecount[i-1] + 1
    else:
        ecount[i] = ecount[i-1]
ans = float("INF")
for i in range(N):
    west = 0
    if i > 1:
        west = i+1 - ecount[i]
    east = 0
    if i < N-1:
        east = ecount[N-1] - ecount[i]
    ans = min(ans, west+east)
print(ans)


Measured memory_bytes: 15260
n=int(input())
if 1<=n<=9:
    print(n)
elif 10<=n<=99:
    print(9)
elif 100<=n<=999:
    print(n-99+9)
elif 1000<=n<=9999:
    print(909)
elif 10000<=n<=99999:
    print(n-9999+909)
else:
    print(90909)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
K, L = min(a), max(a)
s = a.count(K)

if L-K>1:
    print("No")
    quit()
if L==K:
    print("Yes" if K==n-1 or K<=n//2 else "No")
else:
    t = n-s
    print("Yes" if L-s>0 and L-s<=t//2 else "No")

Measured memory_bytes: 13964
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

counter = 0
sum = 0
(a + 1).times do |a_i|
  sum_a = 500 * a_i
  sum = sum_a
  if sum == x
    counter += 1
    next
  elsif sum > x
    next
  end
  (b + 1).times do |b_i|
    sum_b = 100 * b_i
    sum = sum_a + sum_b
    if sum == x
      counter += 1
      next
    elsif sum > x
      next
    end
    (c + 1).times do |c_i|
      sum_c = 50 * c_i
      sum = sum_a + sum_b + sum_c
      if sum == x
        counter += 1
        next
      elsif sum > x
        next
      end
    end
  end
end
puts counter


Measured memory_bytes: 1788
n = int(input())
lst_a = list(map(int, input().split()))

def gcd(a, b):
    if b==0:
        return a
    else:
        return gcd(b, a%b)

ans = lst_a[0]
for a in lst_a:
    # 配列の最初からひとつずつ最大公約数を取っていけばよい。
    ans = gcd(ans, a)

print(ans)

Measured memory_bytes: 14224
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 16;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int in[200050];
int u[200050];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= 2*N-1; i++) scanf("%d", &in[i]);

	int st = 1, en = 2 * N - 1, mi, rv = 0;
	while (st <= en) {
		mi = (st + en) / 2;
		for (i = 1; i <= 2 * N - 1; i++) {
			if (in[i] >= mi) u[i] = 1;
			else u[i] = 0;
		}

		int ans = -1;
		for (i = 1; i <= N - 1; i++) {
			int t1 = N - i, t2 = N + i;
			if (u[t1] == u[t1 + 1] || u[t2] == u[t2 - 1]) {
				ans = u[t1 + 1];
				break;
			}
		}
		if (ans == -1) ans = u[1];
		if (ans == 1) {
			rv = mi;
			st = mi + 1;
		}
		else en = mi - 1;
	}
	return !printf("%d\n", rv);
}

Measured memory_bytes: 1792