akhauriyash/Code-Regression huggingface dataset:
N = int(input())
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c = collections.Counter(prime_factorize(N))
ans = 0
for i in c.values():
    k = i
    j = 1
    while(k>=j):
        k = k-j
        j += 1
        ans += 1
print(ans)


Measured memory_bytes: 9460
#include<stdio.h>

int main()
{

  int N;
  int l;
  int r;
  int i;
  int sum=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d %d",&l,&r);
    sum+=r-l+1;
  }
  printf("%d\n",sum);

  return 0;
}


Measured memory_bytes: 128
input_n = input()
N = str(input_n)

input_a = input()
A = str(input_a)

listN = A.split(' ')

listA = []

for value in range(len(listN)):
    listA.append(int(listN[value]))

result = 0

for value in range(1, len(listA)):
    if listA[value] < listA[value - 1]:
        result += (int(listA[value - 1]) - int(listA[value]))
        listA[value] += (int(listA[value - 1]) - int(listA[value]))

print(str(result))


Measured memory_bytes: 33660
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7;
unordered_map<int, int> a;

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n; cin >> n;
	bool bl = true;
	for(int i = 0; i < n; ++ i){
		int x;
		cin >> x; ++ a[x]; if(a[x] > 1) bl = false;
	}
	bl ? cout << "YES\n" : cout << "NO\n";
	return 0;
}

Measured memory_bytes: 8520
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int y;
	char m[2], d[2], c[2];
	cin >> y >> c[0] >> m[0] >> m[1] >> c[1] >> d[0] >> d[1];
	y++;
	cout << y << "/" << m[0] << m[1] << "/" << d[0] << d[1];
	return 0;
}

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

int main()
{
  int n,w;
  cin>>n;
  cin>>w;
  if(n==0){
  cout<<"0"<<endl;
  return 0;
  }
  vector<unsigned long long> v(w+1),x(w+1);
  vector<unsigned long long> wt(n);
  vector<unsigned long long> val(n);
  for(int i=0;i<n;i++)
  cin>>wt[i]>>val[i];

  //dp[1]=abs(v[1]-v[0]);
  for(int i=1;i<=n;i++)
  {
      for(int j=1;j<=w;j++)
      {
        if(wt[i-1]<=j)
        v[j]=max({v[j],x[j-wt[i-1]]+val[i-1]});
      }
      x=v;
  }
  cout<<v[w]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define WEIGHTSUM weight + i
#define VALUESUM maxValue[i] + value
using namespace std;
ll maxValue[100005];

int main() {
    ll n, w, weight, value;

    cin >> n >> w;
    for (int i = 1; i <= n; i++) {
        cin >> weight >> value;

        for (int i = w - weight; i >= 0; i--)
            maxValue[WEIGHTSUM] = max(maxValue[WEIGHTSUM], VALUESUM);
    }

    cout << maxValue[w];

    return 0;
}


Measured memory_bytes: 4364
import sys
input = sys.stdin.readline

def primeFactor(N):
    i = 2
    ret = {}
    n = N
    mrFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i%2
        if i == 101 and n >= 2**20:
            def findFactorRho(N):
                def gcd(a, b):
                    while b: a, b = b, a % b
                    return a
                def f(x, c):
                    return (x * x + c) % N
                for c in range(1, 99):
                    X, d, j = [2], 1, 0
                    while d == 1:
                        j += 1
                        X.append(f(X[-1], c))
                        X.append(f(X[-1], c))
                        d = gcd(abs(X[2*j]-X[j]), N)
                    if d != N:
                        if isPrimeMR(d):
                            return d
                        elif isPrimeMR(N//d): return N//d
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    mrFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if mrFlg > 0: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def isPrimeMR(n):
    if n == 2:
        return True
    if n == 1 or n & 1 == 0:
        return False
    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    
    L = [2, 7, 61] if n < 1<<32 else [2, 13, 23, 1662803] if n < 1<<40 else [2, 3, 5, 7, 11, 13, 17] if n < 1<<48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
    for a in L:
        t = d
        y = pow(a, t, n)
        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1
        if y != n - 1 and t & 1 == 0:
            return False
    return True

N = int(input())
ans = 0
D = {}
for _ in range(N):
    pf = primeFactor(int(input()))
    a, b = 1, 1
    for p in pf:
        a *= p ** (pf[p] % 3)
        b *= p ** (-pf[p] % 3)
    if a not in D: D[a] = 0
    if a == b:
        if D[a] == 0: ans += 1
    else:
        if b not in D: D[b] = 0
        if D[b] <= D[a]: ans += 1
    D[a] += 1

print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll powLL(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res *= a;
            res %= mod;
        }
        a = a*a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;
    vector<ll> D(101010);
    vector<ll> cnt(101010, 0);
    ll ma = -1;
    REP(i, N){
		cin >> D[i];    	
    	cnt[D[i]]++;
    	ma = max(ma, D[i]);
    }
    ll res = 1;
    if(D[0]!=0){
    	res = 0;
    }else if(cnt[0]!=1){
    	res = 0;
    }else{
    	REP(i, ma){
    		res *= powLL(cnt[i], cnt[i+1]);
    		res %= mod;
    	}
    }
    cout << res << endl;
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n==0) return 0;
    vector<int> ma(n,0),mi(n,0);
    int s,k;
    int c;
    for(int i=0;i<m;i++){
      cin >> s >> k;
      if(k==1){
        cin >> c;
        c--;
        mi[c]+=s;
      }else{
        for(int j=0;j<k;j++){
          cin >> c;
          c--;
          ma[c]+=s;
        }
      }
    }
    int firstma=0,secondma=0,firstmi=100000,secondmi=10000;
    int firstmai=-1,secondmai=-1,firstmii=-1,secondmii=-1;
    for(int i=0;i<n;i++){
      if(ma[i]+mi[i]>=firstma){
        secondma=firstma;
        secondmai=firstmai;
        firstma=ma[i]+mi[i];
        firstmai=i;
      }else if(ma[i]+mi[i]>=secondma){
        secondma=ma[i]+mi[i];
        secondmai=i;
      }
    }
    for(int i=0;i<n;i++){
      if(mi[i]<=firstmi){
        secondmi=firstmi;
        secondmii=firstmii;
        firstmi=mi[i];
        firstmii=i;
      }else if(mi[i]<=secondmi){
        secondmi=mi[i];
        secondmii=i;
      }
    }
    if(firstmai!=firstmii){
      cout << firstma-firstmi+1 << endl;
    }else{
      cout << max(firstma-secondmi,secondma-firstmi)+1 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3172
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, A, B = map(int, input().split())
        ans = 0
        for i in range(1, N + 1):
            s = 0
            for n in str(i):
                s += int(n)
            if A <= s <= B:
                ans += i
        print(ans)


if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 3060
use std::io::{BufRead, Write};
use std::io;
use std::collections::BTreeMap;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let _: usize = s.trim().parse().unwrap();
    s.clear();
    input.read_line(&mut s).unwrap();
    let a: Vec<usize> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut map: BTreeMap<usize, usize> = BTreeMap::new();
    for x in a {
        *map.entry(x).or_insert(0) += 1;
    }
    let mut it = map.iter().rev().flat_map(|(a, b)| if *b >= 4 {
        vec![*a, *a]
    } else if *b >= 2 {
        vec![*a]
    } else {
        vec![]
    });
    writeln!(
        output,
        "{}",
        it.next().unwrap_or(0) * it.next().unwrap_or(0)
    ).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "6
3 1 2 4 2 1\n",
            "2\n",
        );
    }
    #[test]
    fn case2() {
        test(
            "4
1 2 3 4\n",
            "0\n",
        );
    }
    #[test]
    fn case3() {
        test(
            "10
3 3 3 3 4 4 4 5 5 5\n",
            "20\n",
        );
    }
    #[test]
    fn case4() {
        test(
            "4
5 5 5 5\n",
            "25\n",
        );
    }
}


Measured memory_bytes: 8444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll=unsigned long long;
ll a,b,c;
int main(){
	scanf("%lld%lld%lld",&a,&b,&c);
	if(c<a+b) puts("No");
	else if(4*a*b<(c-a-b)*(c-a-b)) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll kai[100010];
ll bit[700010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

ll N;
ll S[1 << 18];
bool judge;
priority_queue<ll> que[18];

void solve() {
	cin >> N;
	rep(i, 1 << N) cin >> S[i];
	sort(S, S + (1 << N));
	reverse(S, S + (1 << N));
	rep(i, N) que[i].push(S[0]);
	rep(i, 1 << N) {
		if (i == 0) continue;
		rep(j, N) {
			if (que[j].size() == 0) continue;
			if (que[j].top() > S[i]) {
				que[j].pop();
				for (int k = j + 1; k < N; k++) {
					que[k].push(S[i]);
				}
				break;
			}
		}
	}
	judge = true;
	rep(i, N) {
		if (que[i].size() > 0) judge = false;
	}
	if (judge) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}
////////////////////////////////////////////////////////////////////////////////////////////jagfhaoi;sd;joi;asdfjzasdi;lfjoi;ernjsdoivcnoizvdfnvdfnon/////////////////////////////////////////////////////////
////////////////////jgoiadhsjgoi;vsjvgfonhjasoivhoivhno

Measured memory_bytes: 6764
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		char b = s.charAt(0);
		
		// 計算
		char result = ' ';
		
		if(b == 'A') result = 'T';
		if(b == 'T') result = 'A';
		if(b == 'C') result = 'G';
		if(b == 'G') result = 'C';
		
		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int n;cin>>n;
  int a[200010];rep(i,n) cin>>a[i];
  int b[200010];
  rep(i,(n+1)/2){
    b[i]=a[n-1-2*i];
  }
  rep(j,n/2){
    int k=(n+1)/2+j;
    b[k]=a[n%2+j*2];
  }
  rep(i,n){
    cout<<b[i]<<" ";
  }
  cout<<"\n";
  

  return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc088.contest.atcoder.jp/tasks/arc088_b>
問題文============================================================
 0 と 1 からなる文字列 S が与えられます。
 以下の操作を好きな回数繰り返すことで S の要素をすべて 0 にできるような、|S| 以下の最大の整数 K を求めてください。
 
 S の長さ K 以上の連続する区間 [l,r] を選ぶ(すなわち、r−l+1≥K が満たされる必要がある)。
 l≤i≤r なるすべての整数 i に対し、Si が 0 なら Si を 1 に、Si が 1 なら Si を 0 に置き換える。

=================================================================

解説=============================================================
 
================================================================
*/
inline int char2num(char c){ return c == '0'?0:1; }
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = (int)S.length();
    for(int i = 0; i < (int)S.length()-1;i++){
        if(S[i] == S[i+1]) continue;
        ans = min(ans,max(i+1,(int)S.length()-(i+1)));
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
x = int(input())
primes = [i for i in range(2, x)]
for i in range(2, int(x ** 0.5 + 0.5)):
    primes = [j for j in primes if j % i != 0 or j == i]
checking = x
while True:
    for p in primes:
        if checking % p == 0:
            break
    else:
        print(checking)
        break
    checking += 1


Measured memory_bytes: 7576
def find_mid(str)
  tmp = 0
  len = str.length
  for i in (0...len)
    tmp += 1 if str[i] == '('
    tmp -= 1 if str[i] == ')'
    return i if str[i] == ',' and tmp == 1
  end
end

class Node
  def initialize
    @left_son = nil
    @right_son = nil
  end

  def extend(str)
    len = str.length
    mid = find_mid(str)
    if mid > 1
      @left_son = Node.new unless @left_son
      @left_son.extend(str[1...mid])
    end
    if mid < len - 2
      @right_son = Node.new unless @right_son
      @right_son.extend(str[mid+1...len-1])
    end
  end

  def shrink(str)
    len = str.length
    mid = find_mid(str)
    if @left_son
      if mid > 1
        @left_son.shrink(str[1...mid])
      else
        @left_son = nil
      end
    end
    if @right_son
      if mid < len - 2
        @right_son.shrink(str[mid+1...len-1])
      else
        @right_son = nil
      end
    end
  end

  def to_s
    str = "("
    str += @left_son.to_s if @left_son
    str += ","
    str += @right_son.to_s if @right_son
    str += ")"
    return str
  end
end

while line = gets
  k, a, b = line.split()
  root = Node.new
  root.extend(a)
  root.extend(b) if k == "u"
  root.shrink(b) if k == "i"
  puts root.to_s
end

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

int main() {
  long long n,k;
  cin>>n>>k;
  vector<long long>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<bool>check(n);
  for(int i=0;i<n;i++) check[i]=false;
  check[0]=true;
  long long all=0;
  long long j=a[0];
  for(int i=0;i<n;i++){
    all++;
    if(check[j-1]) break;
    else{
      check[j-1]=true;
      j=a[j-1];
    }
  }
  long long re=0;
  long long now=j;
  for(int i=0;i<n;i++){
    re++;
    now=a[now-1];
    if(now==j) break;
  }
  long long ans;
  if(k<=all-re){
    ans=1;
    for(int i=0;i<k;i++){
      ans=a[ans-1];
    }
  }
  else{
    long long num=k+re-all;
    num%=re;
    ans=j;
    for(int i=0;i<num;i++){
      ans=a[ans-1];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4844
#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));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll dx[8]={0,0,-1,1,-1,1,-1,1};
ll dy[8]={1,-1,0,0,1,1,-1,-1};
vector<vector<ll> > c(10,vector<ll>(10,0));

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    vector<ll> X(26,INF); //対応
    string s,t; cin>>s>>t;
    rep(i,sz(s)){
        ll tmp1=s[i]-'a';
        ll tmp2=t[i]-'a';
        if(X[tmp1]==INF){
            X[tmp1]=tmp2;
        }
        else if(X[tmp1]!=tmp2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    ll cnt=0;
    set<ll> se;
    rep(i,26){
        if(X[i]!=INF){
            cnt++;
            se.insert(X[i]);
        }
    }
    
    if(sz(se)!=cnt){
        cout<<"No"<<endl;
        return 0;
    }
    
    
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
const int K=3005;
int x[K][K];
int n,k;
int getsize(int x1,int y1,int x2,int y2){
    return x[x2][y2]-x[x2][y1]-x[x1][y2]+x[x1][y1];
}
int main()
{
    cin>>n>>k;
    int a,b;
    char c;
    for(int i=1;i<=n;i++){
        cin>>a>>b>>c;
        a%=2*k,b%=2*k;
        if(c=='W')
            b+=k;
        x[a%(2*k)+1][b%(2*k)+1]++;
    }
    for(int i=1;i<=2*k;i++)
        for(int j=1;j<=2*k;j++)
            x[i][j]=x[i][j]+(x[i-1][j]+x[i][j-1]-x[i-1][j-1]);
    int ans=0,sum;
    for(int i=1;i<=k;i++)
        for(int j=1;j<=k;j++){
            sum=getsize(0,0,i,j);
            sum+=getsize(i,j,k+i,k+j);
            sum+=getsize(k+i,k+j,2*k,2*k);
            sum+=getsize(k+i,0,2*k,j);
            sum+=getsize(0,k+j,i,2*k);
            sum=max(n-sum,sum);
            ans=max(ans,sum);
        }
    cout<<ans;
}

Measured memory_bytes: 24832
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n;
cin>>n;
ll p;
ll cnt=0;
for(int i=0;i<n;i++){
    cin>>p;
    if(p!=i+1){
        cnt++;
    }
}
if(cnt>2){
    cout<<"NO"<<endl;
}else{
    cout<<"YES"<<endl;
}
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int a,b,c,d,e;
    while(scanf("%lld%lld",&a,&b)==2)
    {
        if((a*b)%2==0)
        {
            cout<<"Even"<<endl;
        }
        else
        {
            cout<<"Odd"<<endl;
        }

    }
    return 0;


}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &in, vector<T> &vec) {
    for (auto &e : vec) in >> e;
    return in;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int A, B, M;
    read(A, B, M);

    vector<i64> a(A);
    vector<i64> b(B);
    read(a);
    read(b);

    i64 ans = *min_element(all(a)) + *min_element(all(b));
    rep(i, M) {
        int x, y, c;
        read(x, y, c);
        --x, --y;
        chmin(ans, a[x] + b[y] - c);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1792
s = list(input(),)
x, y = map(int, input().split())
dir, move, fmove, dx, dy = 0, 0, 0, [], [abs(y)]
s.append('E')
first = True
for i in s:
    if i == 'F':
        move += 1
    else:
        if first:
            fmove = move
            first = False
        else:
            if dir % 2 == 0:
                dx.append(move)
            else:
                dy.append(move)
        move = 0
        dir += 1

def to0(d, ini):
    ad = ini
    for i in sorted(d, reverse=True):
        if ad < 0:
            ad += i
        else:
            ad -= i
    return ad
adx, ady = to0(dx, -x + fmove), to0(dy, 0)
if adx == ady == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int main(){
	ll a,b,c,k;cin>>a>>b>>c>>k;
	ll ans=0;
	if(k<=a){
		ans=k;cout<<ans<<endl;return 0;
	}
	else if(k>a&&k<=a+b){
		ans+=a;
		cout<<ans<<endl;return 0;
	}else if(k>(b+a)){
		ans+=a;
		ans-=(k-(a+b));
		cout<<ans<<endl;return 0;
	}
}


Measured memory_bytes: 3636
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

/* RMQ：[0,n-1] について、区間ごとの最大値を管理する構造体
    update(i,x): i 番目の要素を x に更新。O(log(n))
    query(a,b): [a,b) での最大の要素を取得。O(log(n))
*/
template <typename T>
struct RMQ {
    const T INF = -1;
    int n;         // 葉の数
    vector<T> dat; // 完全二分木の配列
    RMQ(int n_) : n(), dat(n_ * 4, INF) { // 葉の数は 2^x の形
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }

    void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    // the maximum element of [a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return INF;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
};

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll n,k;cin>>n>>k;
    vector<ll> a(n);REP(i,n)cin>>a[i];
    RMQ<ll> x(300001);
    REP(i,300001){
        x.update(i,0);
    }
    REP(i,n){
        ll z=x.query(max(0LL,a[i]-k),min(300000LL,a[i]+k)+1);
        //cout<<z<<endl;
        x.update(a[i],z+1);
    }
    cout<<x.query(0,300001LL)<<endl;
}

Measured memory_bytes: 14876
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main() {
    double x,y;
    int n;
    cin>>n;
    vector<pair<double,double>> v;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      v.push_back({x,y});
    }
    double sum=0;
    sort(v.begin(),v.end());
    do{
      for(int i=1;i<v.size();i++){
        sum += sqrt(pow(v[i-1].first-v[i].first,2)+ pow(v[i-1].second-v[i].second,2));
      }

    }while (next_permutation(v.begin(),v.end()));
    for (int i = 1; i <=n; i++)
    {
      sum/=i;
    }
    
    printf("%.8lf\n",sum);
}

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

int main() {
  string n;
  cin>>n;
  for (int i(0);i<3;i++){
    if (n[i]=='1'){
      cout << '9';
    }else{
      cout << '1';
    }
  }
  return 0;
}

Measured memory_bytes: 256
n, m = map(int ,input().split())

adj = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a-=1
    b-=1
    adj[a].append(b)
    adj[b].append(a)

from collections import deque
q = deque()

dist = [-1] * n
ans = [0] * n

q.append(0)
while len(q) != 0:
    now = q.popleft()
    for to in adj[now]:
        if dist[to] != -1:continue
        dist[to] = dist[now] + 1
        q.append(to)
        ans[to] = now 
    
print("Yes")
for i in range(1, n):
    print(ans[i] + 1)



Measured memory_bytes: 34728
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int[][]ds={{0,1},{1,0},{0,-1},{-1,0}};for(int[]n={0,0};(n[0]=s.nextInt())>0;){n[1]=s.nextInt();int[]p={1,1};int d=0,i,x;for(String y;!(y=s.next()).equals("STOP");){if(y.endsWith("D"))for(i=2,x=s.nextInt();i-->0;)p[i]=Math.min(n[i],Math.max(1,p[i]+ds[d][i]*x*(y.charAt(0)==70?1:-1)));if(y.charAt(0)==76)d=(d+3)%4;if(y.charAt(0)==82)d=(d+1)%4;}System.out.println(p[0]+" "+p[1]);}}}

Measured memory_bytes: 12000
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.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(void) {
	ll A;
	double B;
	cin >> A >> B;
	ll b = round(B * 100);
	cout << A * b / 100 << endl;
	return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[200005];
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
	   if(a[i]==a[i+1]){
	   	  cout<<"NO";
	   	  return 0;
	   }
	cout<<"YES";
}

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

int N;
int[10^^5] ts, xs, ys;

void main()
{
    readf("%d", &N);
    foreach (i; 0..N)
        readf(" %d %d %d", &ts[i], &xs[i], &ys[i]);
    
    int x, y, t, d;
    foreach (i; 0..N) {
        d = (xs[i] - x).abs + (ys[i] - y).abs;
        t = i == 0 ? ts[i] : ts[i] - ts[i-1];
        if (d > t || (t-d)%2 == 1) {
            writeln("No");
            return;
        } else {
            x = xs[i];
            y = ys[i];
        }
    }
    writeln("Yes");
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr long INF = 1L << 60;
constexpr int MOD = 998244353;


long A,B;

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

bool prime(long x) {
  for(long i = 2; i*i<=x;++i) {
    if(x%i==0)return false;
  }
  return true;
}

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin>>A>>B;
  long g = gcd(A,B);
  vector<long> xs;
  for(long i=1;i*i<=g;++i){
    if(g%i==0){
      xs.push_back(i);
      if(g/i!=i)xs.push_back(g/i);
    }
  }
  sort(xs.begin(),xs.end());


  long ans = 0;
  for(long x : xs){
    if(prime(x)) ++ans;
  }
  cout<<ans;


  return 0;
}

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

const int UP = 0, RIGHT = 1, DOWN = 2, LEFT = 3;

int m, n;
int i = 1, j = 1;
int dir = UP;

void fwd(int s) {
  if (dir == UP)
    j = min(j + s, n);
  if (dir == DOWN)
    j = max(j - s, 1);
  if (dir == RIGHT)
    i = min(i + s, m);
  if (dir == LEFT)
    i = max(i - s, 1);
}

int main() {
  while (true) {
    cin >> m >> n;
    i = j = 1;
    dir = UP;
    if (m == 0 && n == 0)
      break;
    while (true) {
      string s;
      int t = 0;
      cin >> s;
      if (s == "BACKWARD" || s == "FORWARD")
        cin >> t;
      if (s == "STOP")
        break;
      if (s == "RIGHT")
        dir = (dir + 1) % 4;
      if (s == "LEFT")
        dir = (dir + 3) % 4;
      if (s == "BACKWARD") {
        dir = (dir + 2) % 4;
        fwd(t);
        dir = (dir + 2) % 4;
      }
      if (s == "FORWARD")
        fwd(t);
      // printf("(%d, %d) | Dir: %d | Command: %s %d\n", i, j, dir, s.c_str(),
      // t);
    }
    cout << i << " " << j << endl;
  }
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>

#define loop(i, num)  for (int i = 0; i < num; i++)

using namespace std;

int a, b, c, d;

vector<int> ans(3);

int countNum(int num1, int num2, int op) {
    
    if (op == 0) {
        
        return num1 + num2;
        
    } else {
        
        return num1 - num2;
        
    }
    
}

int count(int op1, int op2, int op3) {
    
    int res = 0;
    
    res = countNum(a, b, op1);
    
//    cout << res << endl;
    
    res = countNum(res, c, op2);
    
//    cout << res << endl;
    
    res = countNum(res, d, op3);
    
//    cout << op1 << ' ' << op2 << ' ' << op3 << ' ' << res << endl;
    
    return res;
    
}

int main() {
    
    a = getchar() - '0';
    
    b = getchar() - '0';
    
    c = getchar() - '0';
    
    d = getchar() - '0';
    
    loop (i, 2) {
        
        loop (j, 2) {
            
            loop (k, 2) {
                
                if (count(i, j, k) == 7) {
                    
                    cout << a << (i ? '-' : '+') << b << (j ? '-' : '+') << c << (k ? '-' : '+') << d << "=7" << endl;
                    
                    return 0;
                    
                }
                
            }
            
        }
        
    }
    
    return 0;
    
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		Map<Integer, Integer>  map = new HashMap<Integer, Integer>();
		for (int i = 0; i < N; i++) {
			int key = reader.nextInt();
			int value = 1;
			if (map.containsKey(key)) {
				value = map.get(key) + 1;
			}
			map.put(key, value);
		}

		for (Entry<Integer, Integer> entry : map.entrySet()) {
			int key = entry.getKey();
			int value = entry.getValue();
			if (value < key) {
				ans += value;
			} else {
				ans += value - key;
			}
		}


		System.out.println(ans);
		reader.close();
	}
}





Measured memory_bytes: 63500
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= n; k++) {
          count++;
        }
      }
    }
    System.out.println(count);
  }
}


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

int main()
{
    int A, B, ans = 0;
    cin >> A >> B;
    for (int i = A; i <= B; i++) if (i / 1000 == (i % 100) % 10 * 10 + (i % 100) / 10) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import math

a,b,h,m = map(int, input().split())

short = (h + m/60) * 30
long = m * 6

big = max(short, long)
small = min(short, long)
  
theta = min(big-small, (360-big) + small)

print((a**2 + b**2 - 2*a*b*math.cos(math.radians(theta)))**0.5)

Measured memory_bytes: 9580
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		
		int N = s.length();
		int[] ii = new int[26];  
		
		for(int i=0; i < N; i++){
			ii[s.charAt(i) - 'a'] += 1;
		}

		for(int i: ii) {
			if(i>1) { System.out.println("no"); return; }
		}
		
		
		System.out.println("yes");
		return;
	}


}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 30;
const ll LINF = 1LL << 60;
const double eps = 1e-9;
const ll MOD = 1000000007LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++) {
        if(s[i] == '1') {
            cout << 9;
        } else {
            cout << 1;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 50000
 
string s;
int size=0;
map<string,int> mp[MAX];
string name[MAX];
int cnt[MAX];
 
int main(){
  string str;
  getline(cin,str);
  stack<P> st;
  st.push(P(-1,0));
   
  while(getline(cin,s)){
    size++;
    string a="",b="";
    int i,len=s.size(),ra=0;
    for(i=0;s[i]==' ';i++)ra++;
    for(;s[i]!=':';i++)a.push_back(s[i]);
    if(i+1<len&&s[i+1]==' '){
      for(i=i+2;i<len;i++)b.push_back(s[i]);
    }
    //cout<<ra<<' '<<a<<' '<<b<<endl;
 
    P p;
    while(1){
      p=st.top();
      if(p.first >= ra){
        st.pop();
      }else{
        break;
      }
    }
 
    mp[p.second][a]=size;
    // cout<<p.second<<' '<<a<<' '<<size<<endl;
 
    if(b=="")name[size]="object";
    else name[size]=b;
 
    cnt[p.second]++;
    st.push(P(ra,size));
  }
   
 
  for(int i=0;i<(int)str.size();i++){
    if(str[i]=='.')str[i]=' ';
  }
 
  stringstream ss(str);
  string tmp;
  int p=0;
  vector<string> vec;
  while(ss>>tmp)vec.push_back(tmp);
   
  for(int i=0;i<(int)vec.size();i++){
    if(mp[p][vec[i]]==0){
      cout<<"no such property"<<endl;
      return 0;
    }
    p=mp[p][vec[i]];
  }
  if(cnt[p]==0)cout<<"string \""<<name[p]<<"\""<<endl;
  else cout<<name[p]<<endl;
 
  return 0;
}

Measured memory_bytes: 4076
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int two = 0, four = 0;
    REP(i, N) {
        if (a[i] % 2 == 0)
            two++;
        if (a[i] % 4 == 0)
            four++;
    }

    if (two + four >= N || four >= N / 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
# 2019-11-19 10:28:31(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import numpy as np 


def main():
    n, m, l = map(int, sys.stdin.readline().split())
    ABCQST = np.array(sys.stdin.read().split(), np.int64)
    ABC = ABCQST[:m * 3]
    A, B, C = ABC[::3], ABC[1::3], ABC[2::3]
    ST = ABCQST[m * 3 + 1:]
    S, T = ST[::2], ST[1::2]

    dist = csr_matrix((C, (A, B)), (n+1, n+1))
    min_dist = floyd_warshall(dist, directed=False)

    filling_times = np.full((n+1, n+1), np.inf)
    np.diagonal(filling_times, 0)
    filling_times[min_dist <= l] = 1

    min_filling_times = floyd_warshall(filling_times, directed=False)

    min_filling_times[min_filling_times == np.inf] = 0
    # 最後に-1する
    min_filling_times = min_filling_times.astype(int)

    res = min_filling_times[S, T] - 1
    print('\n'.join(res.astype(str)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 44104
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long;
#define REP(i,s,N) for(ll i=s;i<N;++i)

int main () {
	int N;
	cin >> N;
	if (N % 2 == 0) {
		cout << N << endl;
	} else {
		cout << 2*N << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
int main(){
	LL n;
	cin >> n;
	LL a[n];
	LL b[n];
	for(LL i = 0; i < n; i++) cin >> a[i] >> b[i];
	LL z = 0;
	for(LL i = n-1; i >= 0; i--){
		a[i] += z;
		z += (b[i]-(a[i] % b[i]))%b[i];
	}
	cout << z << endl;
}


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

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

	int n;
	cin >> n;
	int h[n], dp[n];
	for(int i=0; i<n; ++i) {
		cin >> h[i];
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2; i<n; ++i)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout << dp[n-1];
}


Measured memory_bytes: 4388
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int n;
cin>>n;
set<string> s;
for(int i=0;i<n;i++){
    string t={};
    cin>>t;
    s.insert(t);
}
int m;
cin>>m;
int open=1;
for(int i=0;i<m;i++){
    string t={};
    cin>>t;
    if(s.find(t)!=s.end()){
        if(open)cout<<"Opened by "<<t<<endl;
        else cout<<"Closed by "<<t<<endl;
        open^=1;
    }
    else cout<<"Unknown "<<t<<endl;
}
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int a[400000];
int main()
{
    cin >> n >> s;
    a[0] = 0;
    for(int i = 1; i < n; i++)
    {
        if(s[i] == 'E')
        {
            a[0] = a[0] + 1;
        }
    }
    
    int m = a[0];
    
    for(int i = 1; i < n; i++)
    {
        if(s[i-1] == 'E' && s[i] == 'E')
        {
            a[i] = a[i-1] - 1;
        }
        else if(s[i-1] == 'W' && s[i] == 'W')
        {
            a[i] = a[i-1] + 1;
        }
        else
        {
            a[i] = a[i-1];
        }
        
        m = min(m, a[i]);
    }
    
    cout << m << endl;
}



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

int main(){
	long A,B,K;
	std::cin>>A>>B>>K;
	for(int i{0}; i < K; i++){
		if(i % 2 == 0){
			if(A % 2 == 1){
				A -= 1;
			}
			A/=2;
			B += A;
		}else{
			
			if(B % 2 == 1){
				B -= 1;
			}
			B/=2;
			A += B;	
		}
	}
	std::cout<<A<<" "<<B;
	return 0;
	

}

Measured memory_bytes: 256