akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
a.reverse()
uf = UnionFind(n)
ans = n*(n-1)//2
anslist = []
for i in range(m):
    anslist.append(ans)
    x,y = a[i][0],a[i][1]
    if uf.same(x-1,y-1):
        continue
    ans -= (uf.size(x-1) * uf.size(y-1))
    uf.union(x-1,y-1)
anslist.reverse()
print(*anslist, sep="\n")
    

Measured memory_bytes: 34932
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
class Program
{
    static void Main()
    {
        string s;
        try
        {
            s = Console.ReadLine().Substring(0, 4);
        }
        catch
        {
            Console.WriteLine("No");
            return;
        }
        if (s == "YAKI")
        {
            Console.WriteLine("Yes");
            return;
        }
        Console.WriteLine("No");
    }
}

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

int main(){
  	int n;
  	ll abc[1001001][3];
  	ll dp[1001001][3];
  	cin >> n;
  	rep(i, n)rep(j, 3) cin >> abc[i][j];
  	
  	rep(j, 3) dp[0][j] = abc[0][j];
      
	rep(i, n){
    	rep(j, 3){
        	rep(k, 3){
            	if(j == k) continue;
              	dp[i+1][j] = max(dp[i][k]+abc[i+1][j], dp[i+1][j]) ;
            }
        }
    }
        
    ll res = 0;
    rep(j, 3) res = max(res, dp[n-1][j]);
    cout << res << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
class SegTree {
    int n;// 葉の数
    vector<T> data;// データを格納するvector
    T def; // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;// 点更新で使う処理

    T find(int a, int b) {
        T val_left = def, val_right = def;
        for (a += (n - 1), b += (n - 1); a < b; a >>= 1, b >>= 1)
        {
            if ((a & 1) == 0){
                val_left = operation(val_left, data[a]);
            }
            if ((b & 1) == 0){
                val_right = operation(data[--b],val_right);
            }
        }
        return operation(val_left, val_right);
    }
    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
        function<T(T, T)> _update=[](T a,T b){return b;})
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }
    void set(int i, T x) { data[i + n - 1] = x; }
    void build() {
        for (int k=n-2;k>=0;k--) data[k] = operation(data[2*k+1],data[2*k+2]);
    }
    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        //return _query(a, b, 0, 0, n);
        return find(a,b);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};


int main(){
    ll n,k;cin >> n >>k;
    vl a(n);rep(i,n)cin >> a[i];
    SegTree<ll> st(300010,0,[](ll a,ll b){return max(a,b);});
    rep(i,n){
        ll ret=st.query(max(0LL,a[i]-k),min(300010LL,a[i]+k+1))+1;
        st.change(a[i],ret);
    }
    //rep(i,n)cout << st[i] <<" ";cout << endl;
    cout << st.query(0,300010) <<endl;
}

Measured memory_bytes: 13820
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000000
using namespace std;
int solve(int N){
    int sum = 0;
    int ans = 0;
    for(int i=1;i<=1000;i++){
        for(int j=i;j<=1000;j++){
            sum += j;
            if(sum == N) ans++;
            if(sum >= N){
                sum = 0;
                break;
            }
        }
    }
    return ans-1;
}
int main(){
    int n;
    while(1){
        cin >> n;
        if(n==0) return 0;

        cout << solve(n) << endl;
    }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
long long i;
string s,S;
int main()
{
	std::ios_base::sync_with_stdio(false),cin.tie(0);
	cin>>s,S=s,reverse(s.begin(),s.end());
	for (i=0;i<s.size();i++)
		s[i]==98?s[i]=100:s[i]==100?s[i]=98
			:s[i]==112?s[i]=113:s[i]==113?s[i]=112:0;
	s==S?puts("Yes"):puts("No");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
ll ans[55555];
int main()
{

	int n,x,y; cin>>n>>x>>y;
	x--; y--;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int dist=abs(i-j);
			dist=min(dist,abs(i-x)+1+abs(y-j));         //枚举所有走法
			dist=min(dist,abs(i-y)+1+abs(x-j));
			ans[dist]++;
		}
	}
	for(int i=1;i<=n-1;i++)
	{
		cout<<ans[i]<<'\n';
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long>
#define vii vector<int>
#define vll vector<long long>
using namespace std;

int main()
{
    string a,b;
    cin>>a>>b;
    int ans =0;
    for(int i=0;i<3;i++){
        if(a[i] == b[i])
            ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<62 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

ll fact[303030],invfact[303030];
ll comb(int n,int k){
    if(k<0||k>n)return 0;
    ll ret=invfact[k]*invfact[n-k]%mod;
    return ret*fact[n]%mod;
}
ll powmod(ll n,ll k){
    ll ret=1;
    while(k>0){
        if(k&1)ret=ret*n %mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    fact[0]=1;
    rep(i,300000)fact[i+1]=fact[i]*(i+1)%mod;
    invfact[300000]=powmod(fact[300000],mod-2);
    rep(i,300000)invfact[299999-i]=invfact[300000-i]*(300000-i)%mod;
    ll ans=0;
    rep(i,k+1){
        ll l=(comb(n+2*i,i)-comb(n+2*i,i-1)+mod)%mod;
        ll r=(comb(m+2*(k-i),k-i)-comb(m+2*(k-i),k-i-1)+mod)%mod;
        l=l*r%mod;
        ans+=l*comb(n+m+2*k,n+2*i)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

vector<ll> y(51, 0);
vector<ll> z(51, 0);

ll ans(int n, ll eat, ll pos) {
    if (n == 0) {
        return eat + 1;
    } else if (pos == y[n]) {
        return eat + z[n];
    } else if (pos == 0) {
        return eat;
    } else if (pos < y[n] / 2) {
        return ans(n-1, eat, pos-1);
    } else if (pos == y[n] / 2) {
        return eat + z[n-1] + 1;
    } else {
        return ans(n-1, eat+z[n-1]+1, pos-y[n-1]-2);
    }
}

int main() {
    ll n, x;
    cin >> n >> x;
    y[0] = 1;
    z[0] = 1;
    rep (i, 50) {
        y[i+1] = y[i] * 2 + 3;
        z[i+1] = z[i] * 2 + 1;
    }
    cout << ans(n, 0, x-1);
}

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

public class BinarySearch{
	public static void Main()
	{
		Console.ReadLine();
		var sList = ReadLineAndToIntList();
		Console.ReadLine();
		var tList = ReadLineAndToIntList();
	
		int count = 0;
	
		foreach (var t in tList)
		{
			if(sList.BinarySearch(t) > -1) count++;
		}
		
		Console.WriteLine(count);
	}
	
	//??????????????????????????????
	public static List<int> ReadLineAndToIntList()
	{
		return Console.ReadLine().Split().Select (c => int.Parse(c)).ToList();
	}
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
using namespace std;

int a[20], x[20][20], y[20][20];

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        rep(j, a[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    int ans = 0;
    vector<int> honest(n);
    rep(bit, (1 << n)) {
        bool ok = true;
        rep(i, n) {
            honest[i] = 0;
            if ((bit >> i) & 1) honest[i] = 1;
        }

        rep(i, n) {
            if (!(bit & (1 << i))) continue;
            rep(j, a[i]) if (honest[x[i][j]] != y[i][j]) ok = false;
        }

        if (ok) ans = max(ans, __builtin_popcount(bit));
    }

    cout << ans << endl;

    return 0;
}



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

int main()
{
	string s; cin >> s;
	
	long long sum = 0;

	for (int bit = 0; bit < (1<<s.size() - 1); bit++) {

		long long tmp_sum = 0;
		string tmp; tmp += s[0];
		
		for (int i = 0; i < s.size() - 1; i++) {

			if (bit & (1 << i)) {
				tmp_sum += stoll(tmp);
				tmp = "";
			
			}
			tmp += s[i + 1];			

		}
		tmp_sum += stoll(tmp);
		sum += tmp_sum;

	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
typedef bitset<61> Bitset;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = INT_MAX;
const int MAX = 300000;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M,X;cin>>N>>M>>X;
    vector<int>C(N);
    vector<vector<int>>A(N,vector<int>(M));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M + 1; j++) {
            if(j==0) cin>>C[i];
            else cin>>A[i][j-1];
        }
    }
    int ans = INT_MAX;
    for(int bit = 0; bit < (1 << N); bit++) {
        vector<int> score(M,0);
        int money = 0;
        for(int i = 0; i < N; i++) {
            if(bit & (1 << i)){
                money += C[i];
                for(int j = 0; j < M; j++) {
                    score[j] += A[i][j];
                }
            }
        }
        bool f = 1;
        for(int i = 0; i < M; i++) {
            if(score[i]<X){f = 0;break;}
        }
        if(f) ans = min(ans,money);
    }
    if(ans==INT_MAX) cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 3608
import itertools

k = int(input())
rc_sub = {}
for _ in range(k):
    r, c = [int(i) for i in input().split()]
    rc_sub[r] = c
board = [["."]*8 for _ in range(8)]

for pp in itertools.permutations(range(8), 8):
    rc = {i: p for (i, p) in enumerate(pp)}
    ok = True
    # 初期配置条件を満たさない場合スキップ
    for k, v in rc_sub.items():
        if rc[k] != v:
            ok = False
            break
    if not ok:
        continue

    # 配置条件（斜め）を満たさない場合スキップ
    for (p1, p2) in itertools.combinations(rc.items(), 2):
        if (p2[0] - p1[0]) / (p2[1] - p1[1]) in (1, -1):
            ok = False
            break

    if ok:
        for k, v in rc.items():
            board[k][v] = "Q"
        break

for line in board:
    print(*line, sep="")


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

using namespace std;

const int N = 1e5 + 5;

vector<int> edges[N];
int in_degree[N]; 
int dist[N];
bool visited[N];

void dfs(int a) {
    assert(!visited[a]);
    visited[a] = true;
    for (int b : edges[a]) {
        dist[b] = max(dist[b], dist[a] + 1);
        in_degree[b]--;
        if (in_degree[b] == 0) {
            dfs(b);
        }
    }
}

signed main() {
    int n, m;
    scanf("%d%d", &n, &m);
    while (m--) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        in_degree[b]++;
    }
    for (int i = 1; i <= n; i++) {
        if (!visited[i] && in_degree[i] == 0) {
            dfs(i);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dist[i]);
    }
    printf("%d\n", ans);
    return false;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
int main(){
 	long double tm,sum;
	while(cin>>tm){
		sum = 0;
		for(int i=0;i<5;i++){
			sum+=tm;
			tm*=2.0;
			sum+=tm;
			tm/=3.0;
		}
		printf("%.6Lf\n",sum);
	}
}

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

int main() {
    string S,T;
    cin >> S >> T;
    long long ans=0;
    for (long long i=0; i<S.size(); i++) {
        if (S.at(i)!=T.at(i)) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3912
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine();
        var bits = new[] {
        new[] { "+", "+", "+", "+", "-", "-", "-", "-" },
        new[] { "+", "+", "-", "-", "+", "+", "-", "-" },
        new[] { "+", "-", "+", "-", "+", "-", "+", "-" },
        };

        for(var i = 0; i < (int)Pow(2, 3); i++)
        {
            var r = ToInt32(input.Substring(0,1));
            for(var j = 0; j < 3; j++)
            {
                var num = ToInt32(input.Substring(j+1,1));
                if (bits[j][i] == "+") r += num;
                else r -= num;
            }
            if (r == 7)
            {
                input = input.Insert(1, bits[0][i]);
                input = input.Insert(3, bits[1][i]);
                input = input.Insert(5, bits[2][i]);
                WriteLine(input + "=7");
                break;
            }
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
void findNumberOfDigits(long n, int base)
{
    // Calculating log using base
    // changing property and then
    // taking it floor and then
    // adding 1.
    int dig = (int)(floor( log(n) /
                           log(base)) + 1);

    // printing output
    cout << dig << endl;;
}
int main()
{
    int n, d;
    cin >> n >> d;
    findNumberOfDigits(n, d);
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, M := nextInt(), nextInt()
	for i := 0; i < M; i++ {
		N -= nextInt()
		if N < 0 {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(N)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1848
X = int(input())
dp = [False] * (X+1)
dp[0] = True
def judge(i, j):
    if i >= j:
        return dp[i-j]
    else:
        return False
    
for i in range(1, X+1):
    dp[i] = judge(i, 100) or judge(i, 101) or judge(i, 102) or judge(i, 103) or judge(i, 104) or judge(i, 105)
        
print(int(dp[X]))

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

/*

sort by x[i]

dp[i] consider suffix from i the number of subset

no select i -> dp[i+1]

select i
a continuous part will be activited by i
the first one not be activited is j
dp[i] += dp[j]

*/

typedef pair<int,int> PII;
const int M=2e5+5;
const int INF=0x7fffffff;
const int MO=998244353;

inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}

PII a[M];
stack<PII> st;
int dp[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&a[i].first,&a[i].second);
	}
	sort(a,a+n);
	st.push({INF,n});
	dp[n]=1;
	for(int i=n-1;i>=0;i--)
	{
		// no select i
		dp[i]=dp[i+1];

		// select i
		while(st.top().first<a[i].first+a[i].second)
			st.pop();
		addv(dp[i],dp[st.top().second]);
		st.push({a[i].first,i});
	}
	printf("%d\n",dp[0]);
	return 0;
}

Measured memory_bytes: 3456
N = int(input())
points = []
f = None
for i in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        f = [x, y, h]
    points.append([x, y, h])

def height(cx, cy):
    H = f[2] + abs(f[0] - cx) + abs(f[1] - cy)
    for p in points:
        if p[2] != max(H - abs(p[0] - cx) - abs(p[1] - cy), 0):
            return 0
    return H

for x in range(101):
    for y in range(101):
        h = height(x, y)
        if h > 0:
            print(' '.join([str(x), str(y), str(h)]))

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

int main(){
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if(n*2 >= m){
		ans = m/2;
		cout << ans << endl;
	}else{
		ans += n;
		m -= n*2;
		ans += m/4;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	int[][] graph;
	double[][] dist;
	int n, m, p, a, b;
	int[] tickets;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			n = in.nextInt();
			m = in.nextInt();
			p = in.nextInt();
			a = in.nextInt();
			b = in.nextInt();
			if(n==0) return ;
			graph = new int[m+1][m+1];
			tickets = new int[n];
			dist = new double[m+1][1<<n];
			for(int i=0; i<n; i++)
				tickets[i] = in.nextInt();
			for(int i=0; i<p; i++){
				int x = in.nextInt(), y = in.nextInt(), z = in.nextInt();
				graph[x][y] = graph[y][x] = z;
			}
			double ans = solve();
			if(ans<0) System.out.println("Impossible");
			else System.out.printf("%.7f\n", ans);
		}
	}

	class Pair{
		double x;
		int a, used, visited;
		Pair(double _x, int _a, int _used, int _visited){
			this.x = _x;
			this.a = _a;
			this.used= _used;
			this.visited = _visited;
		}
		Pair(){
			new Pair(0,0,0,0);
		}
	}

	class Comp implements java.util.Comparator<Pair>{
		public int compare(Pair x, Pair y){
			return x.x>y.x?1:x.x<y.x?-1:0;
		}
	}

	double solve(){
		PriorityQueue<Pair> Q = new PriorityQueue<Pair>(11, new Comp());
		Q.add(new Pair(0,a,0,1<<a));
		while(!Q.isEmpty()){
			Pair tp = Q.poll();
			double d = tp.x;
			int cur = tp.a, u = tp.used, v = tp.visited;
			if(dist[cur][u] != 0) continue;
			dist[cur][u] = d;
			for(int i=1; i<=m; i++)if(((v>>i)&1) == 0 && graph[cur][i]!=0){
				for(int j=0; j<n; j++)if(((u>>j)&1) == 0 && dist[i][u|(1<<j)]==0){
					Q.add(new Pair(d+(double)graph[cur][i]/tickets[j], i, u|(1<<j), v|(1<<i)));
				}
			}
		}
		
		double ret = 1e9;
		for(int i=0; i<1<<n; i++)
			if(dist[b][i] > 0 && ret > dist[b][i])
				ret = dist[b][i];
		if(ret == 1e9) return -1;
		return ret;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 36000
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<queue>
#include<set>
#include<map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll encode(ll a,ll b,ll c){
  return a+1001LL*b+1001LL*1001LL*c;
}

ll decode_a(ll num){

  return num%1001LL;

}

ll decode_b(ll num){

  return (num/1001LL)%1001LL;

}

ll decode_c(ll num){

  return (num/(1001LL*1001LL))%1001LL;

}

typedef pair<ll,ll> pi;

int main(void){

  ll x,y,z,k;
  cin>>x>>y>>z>>k;

  vector<ll> a(x);
  vector<ll> b(y);
  vector<ll> c(z);

  rep(i,x) cin>>a[i];
  rep(i,y) cin>>b[i];
  rep(i,z) cin>>c[i];

  sort(all(a),greater<ll>());
  sort(all(b),greater<ll>());
  sort(all(c),greater<ll>());

  set<pi,greater<pi>> sss;
  priority_queue<pi> que;
  
  pair<ll,ll> tmp;

  tmp.second=0;
  tmp.first=a[0]+b[0]+c[0];

  //sss.insert(tmp);
  que.push(tmp);
  map<ll,ll> check;

  rep(i,k){
    //pair<ll,ll> q=*(sss.begin());
    auto q=que.top();
    //sss.erase(q);
    que.pop();

    cout << q.first << endl;
    
    ll _a=decode_a(q.second);
    ll _b=decode_b(q.second);
    ll _c=decode_c(q.second);

    if(_a+1<x && check.count(encode(_a+1,_b,_c))==0){
      //sss.insert( make_pair( a[_a+1]+b[_b]+c[_c],encode(_a+1,_b,_c) ) );
      que.push( make_pair( a[_a+1]+b[_b]+c[_c],encode(_a+1,_b,_c) ) );
      check[encode(_a+1,_b,_c)]=1;
    }
    if(_b+1<y && check.count(encode(_a,_b+1,_c))==0){
      //sss.insert( make_pair( a[_a]+b[_b+1]+c[_c],encode(_a,_b+1,_c) ) );
      que.push( make_pair( a[_a]+b[_b+1]+c[_c],encode(_a,_b+1,_c) ) );
      check[encode(_a,_b+1,_c)]=1;
    } 
    if(_c+1<z && check.count(encode(_a,_b,_c+1))==0){
      //sss.insert( make_pair( a[_a]+b[_b]+c[_c+1],encode(_a,_b,_c+1) ) );
      que.push( make_pair( a[_a]+b[_b]+c[_c+1],encode(_a,_b,_c+1) ) );
      check[encode(_a,_b,_c+1)]=1;

    } 

  }


  return 0;

}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;priority_queue<pair<int,int> >p;int n,q,a,b,d[1<<20];int main(){cin>>n>>q;a=n;while(a--)p.push(make_pair(0,a)),d[a]=0;while(q--){cin>>a>>b;a=n-a,d[a]+=b;p.push(make_pair(d[a],a));while(1){a=p.top().first,b=p.top().second;if(d[b]==a){cout<<n-b<<" "<<a<<endl;break;}p.pop();}}return 0;}

Measured memory_bytes: 23156
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long sum = 1;
		long MAX = 1000000000000000000l;
		long A[] = new long[N];
		for (int i=0;i<N;i++) {
			long temp = sc.nextLong();
			if (temp==0l) {
				System.out.println(0);
				return ;
			}
			A[i] = temp;
		}
		for (int i=0;i<N;i++) {
			long temp = A[i];
			temp *=sum;
			if (temp<sum||temp>MAX) {
				System.out.println(-1);
				return ;
			}
			sum = temp;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 61344
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

/// [..)
struct SegTree(alias _fun, alias def, T)
if (is(typeof(def) : T))
{
    import std.functional : binaryFun;
    alias fun = binaryFun!_fun;

    ///
    this(size_t n, T[] ts) {
        this.n = 1;
        while (this.n < n) this.n *= 2;
        this.tree.length = this.n * 2 - 1;
        foreach (ref e; this.tree) e = def;
        foreach (i, e; ts) this.put(i, e);
    }

    ///
    void put(size_t i, T e) {
        i += this.n - 1;
        this.tree[i] = e;
        while (i > 0) {
            i = (i-1) / 2;
            this.tree[i] = fun(this.tree[i*2+1], this.tree[i*2+2]);
        }
    }

    ///
    T query(size_t a, size_t b) {
        T impl(size_t i, size_t l, size_t r) {
            if (r <= a || b <= l) return def;
            if (a <= l && r <= b) return this.tree[i];
            return fun(
                impl(i*2+1, l, (l+r)/2),
                impl(i*2+2, (l+r)/2, r)
            );
        }
        return impl(0, 0, this.n);
    }

private:
    size_t n;
    T[] tree;
}

///
SegTree!(f, def, T) seg_tree(alias f, alias def, T)(size_t n, T[] arr = [])
{
    return SegTree!(f, def, T)(n, arr);
}

///
SegTree!(f, def, T) seg_tree(alias f, alias def, T)(T[] arr)
{
    return SegTree!(f, def, T)(arr.length, arr);
}

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto ps = readln.split.to!(int[]);

    int last = -1, cnt;
    auto bs = new bool[](N);
    bool has_nc;
    foreach (i, p; ps) {
        if (p > last) {
            ++cnt;
            if (cnt >= K) {
                bs[i-K+1] = true;
                has_nc = true;
            }
        } else {
            cnt = 1;
        }
        last = p;
    }

    auto ps_min = seg_tree!("a < b ? a : b", int.max)(ps.dup);
    auto ps_max = seg_tree!("a > b ? a : b", -1)(ps.dup);

    int r = bs[0] ? 0 : 1;
    foreach (i; 0..N-K) {
        if (
            (ps_min.query(i, i+K) != ps[i] || ps_max.query(i+1, i+K+1) != ps[i+K]) &&
            bs[i+1] == false
        ) ++r;
    }
    writeln(r + (has_nc ? 1 : 0));
}

Measured memory_bytes: 14864
S=input()

x=[-1]*(len(S)+1)
for i in range(len(S)-1):    
    if S[i]==">" and S[i+1]=="<":
        x[i+1]=0

if S[0]=="<":
    x[0]=0

if S[-1]==">":
    x[-1]=0


for i in range(len(S)):
    if S[i]=="<":
        if x[i]>=0:
            x[i+1]=x[i]+1
        
    
for i in reversed(range(len(S))):
    if S[i]==">" and x[i+1]>=0:
        x[i]=max(x[i+1]+1,x[i])

        
print(sum(x))


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

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a <= c && c <= b) 
            Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

int factorial(int n) {
  return n == 0 ? 1 : n * factorial(n - 1);
}

void solve() {
  int n;
  cin >> n;
  cout << factorial(n) << endl;
}

Measured memory_bytes: 3080
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
const int INF = 1e9;
int m[3000];

int main() {
	int x, y, A, B, C;
	cin >> x >> y >> A >> B >> C;
	vector<int>p(A+1), q(B+1),r(C+1);
	rep(i, A)cin >> p[i];
	rep(i, B)cin >> q[i];
	rep(i, C)cin >> r[i];
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());
	int xy = x + y;
	int pc(0), qc(0), rc(0);
	ll ans(0);
	while (xy) {
		if (pc >= x || pc>A-1)p[pc] = -1;
		if (qc >= y || qc>B-1)q[qc] = -1;
		if (rc > C - 1)r[rc] = -1;
		int k = max(p[pc], max(q[qc], r[rc]));
		//cout << k;
		if (k == p[pc])pc++;
		else if (k == q[qc])qc++;
		else rc++;
		ans += ll(k);
		xy--;
	}
	cout << ans;
	return 0;

}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    char s, s2, a, b, c, d;
    
    
        cin >> s >> s2 >> a >> b >> c >> d;
        if( a == b && c == d){
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    string s;
    cin>>s;
    REP(i,s.size()){
        if(s[i]=='1')s[i]='9';
        else s[i]='1';
    }
    cout<<s<<endl;;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n; cin >> n;
    map<ll, int, greater<ll>> mp;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        mp[a]++;
    }


    ll ans = 0;
    for (auto &e: mp) {
        if (!ans) {
            if (e.second >= 4) {
                ans = e.first * e.first;
                break;
            } else if (e.second >= 2) {
                ans = e.first;
            }
        } else {
            if (e.second >= 2) {
                ans *= e.first;
                break;
            }
        }
    }

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

Measured memory_bytes: 6528
#include<cstdio>
#include<algorithm>
long long f(long long n){
    if(n==0)return 0;
    else if(n%2==0)return 2;
    else return 1;
}
long long g(long long a,long long b,long long c){
    long long n[3]={f(a),f(b),f(c)};
    std::sort(n,n+3);
    if(n[2]==2)return std::max(n[0]%2,n[1]%2);
    else return (n[0]+n[1]+n[2])%3;
}
int main(){
    long long i,o,t,j,l,s,z;
    scanf("%lld%lld%lld%lld%lld%lld%lld",&i,&o,&t,&j,&l,&s,&z);
    printf("%lld",i+o+j+l-g(i,j,l));
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

int main(){
  string s,t="keyence";
  cin>>s;
  int cnt=0;
  for(int i=0;i<7;i++){
    if(s[i]!=t[i])break;
    cnt++;
  }
  for(int i=0;i<7;i++){
    if(s[s.size()-1-i]!=t[t.size()-1-i])break;
    cnt++;
  }
  if(cnt>=7)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#ALDS_1_12_C Single Source Shortest Path II
import sys
import heapq

n = int(input())
G = [[] for _ in range(n)]
for i in range(n):
    u, k, *vc = list(map(int, sys.stdin.readline().strip().split()))
    for j in range(k):
        G[u].append([vc[j * 2], vc[j * 2 + 1]])

p = [] * n
c = ['white'] * n
d = [] * n
heapq.heappush(d, (0, 0))  # (distance, node)

mindist = [float('inf')] * n
mindist[0] = 0

while d:
    now = heapq.heappop(d)[1]

    #  色識別はなくても実行可能だが、枝刈りのために実行
    if c[now] == 'black':
        continue
    c[now] = 'black'

    for i in G[now]:
        if mindist[now] + i[1] < mindist[i[0]]:
            mindist[i[0]] = mindist[now] + i[1]
            heapq.heappush(d, [mindist[i[0]], i[0]])

for i in range(n):
    print('{} {}'.format(i, mindist[i]))



Measured memory_bytes: 76484
import java.io.BufferedReader
import java.io.InputStreamReader

fun isPrime(n: Int): Boolean {
    when (n) {
        0 -> return false
        1 -> return false
        else -> {
            for (i in 2..Math.sqrt(n.toDouble()).toInt())
                if (n % i == 0)
                    return false
            return true
        }
    }
}

fun main(args: Array<String>) {
    BufferedReader(InputStreamReader(System.`in`))
            .readText()
            .trim()
            .split(regex = """\s+""".toRegex())
            .map { it.toInt() }
            .drop(n = 1)
            .filter { isPrime(it) }
            .count()
            .let { println(it) }
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

//! n以下でbビット目が1になる数の個数
ll calc(ll n, ll t)
{
    ll x = (n / t) * (t / 2);
    ll y = std::max((n % t) - t / 2 + 1, 0LL);
    //cout<<n<<" "<<x<<" "<<y<<endl;
    return x + y;
}

int main()
{
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    ll t = 1;
    REP(i, 45)
    {
        if (t > B)
            break;
        t *= 2;
        ll n = calc(B, t) - calc(A - 1, t);
        ans |= (n % 2) << i;
    }
    cout << ans << endl;
    return 0;
}

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

void mx(ll& a, ll b) {
	a = max(a, b);
}


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

	int n, W;
	cin >> n >> W;

	vector<ll> dp(W + 1);

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

	cout << *max_element(dp.begin(), dp.end()) << endl;
}




Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.next().split("");
    int cnt = 0;
    for(int i = 0;i<s.length;i++){
      if(s[i].equals("2")){
        cnt++;
      }
    }
    System.out.println(cnt);
  } 
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



const double PI = acos(-1.0);
int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double alpha = (H * 60 + M) / 720 * (PI * 2);
    double beta = M / 60 * (PI * 2);
    double xA = A * cos(alpha), yA = A * sin(alpha);
    double xB = B * cos(beta), yB = B * sin(beta);
    double res = sqrt((xA-xB)*(xA-xB) + (yA-yB)*(yA-yB));
    cout << fixed << setprecision(10) << res << endl;
}

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

int main() {
    int h, w, k;
    char c;
    int board[10][10] = {};

    cin >> h >> w >> k;
    for (int row = 0; row < h; row++) {
        for (int col = 0; col < w; col++) {
            cin >> c;
            if (c == '#') {
                board[row][col] = 1;
            }
        }
    }

    int r_all = 1 << h;
    int c_all = 1 << w;
    int blk, ans = 0;

    for (int r_mask = 0; r_mask < r_all; r_mask++) {
        for (int c_mask = 0; c_mask < c_all; c_mask++) {
            blk = 0;
            for (int row = 0; row < h; row++) {
                if ((r_mask>>row) & 1) {
                    for (int col = 0; col < w; col++) {
                        if ((c_mask>>col) & 1) blk += board[row][col];
                    }
                }
            }
            if (blk == k) ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>
#include <queue>

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

using namespace std;


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

    
    int count=0;
    int count1=0;
    
    for(int i=0;i<N;++i){
        if(s[i]=='R'){
            ++count;
        }
    }
    for(int i=0;i<count;++i){
        if(s[i]=='R'){
            ++count1;
        }
    }
    
    cout<<(count-count1)<<endl;


}


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

struct Time {int h, m;};

int minute(Time t) {return 60 * t.h + t.m;}

bool ok(auto m, auto s, auto e) {
  if(m < minute(s)) return false;
  if(minute(e) < m) return false;
  return true;
}

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

  vector<vector<Time>> t(N, vector<Time>(6));
  for(auto& v: t) for(auto& i: v) cin >> i.h >> i.m;

  set<int> breakfast, lunch, dinner;
  for(auto v: t) {
    breakfast.emplace(minute(v[0]));
    breakfast.emplace(minute(v[1]));
    lunch.emplace(minute(v[2]));
    lunch.emplace(minute(v[3]));
    dinner.emplace(minute(v[4]));
    dinner.emplace(minute(v[5]));
  }

  auto res = 0;
  for(auto a: breakfast) for(auto b: lunch) for(auto c: dinner) {
    auto sum = 0;
    for(auto v: t) {
      if(!ok(a, v[0], v[1])) continue;
      if(!ok(b, v[2], v[3])) continue;
      if(!ok(c, v[4], v[5])) continue;
      ++sum;
    }
    res = max(res, sum);
  }
  cout << res << endl;
}

Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string w;
	cin >> w;
	
	int a[28];
	for (int i = 0; i < 28; i++) {
	    a[i] = 0;
	}
	bool judge = false;
	
	if(w.size() % 2) cout << "No" << endl;
	else {
	    
	    for (int i = 0; i < w.size(); i++) {
	        a[w[i] - 'a']++;
	    }
	    
	    for (int i = 0; i < 28; i++) {
	        if(a[i] % 2) judge = true;
	    }
	    
	    if(judge) std::cout << "No" << std::endl;
	    else std::cout << "Yes" << std::endl;
	}
	
	return 0;
}

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

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

using namespace std;

int main(){
  int N;
  while( cin >> N , N ){
    int cnt = 0, one = 0;
    rep(_,N) {
      int temp;
      cin >> temp;
      if( temp >= 2 ) ++cnt;
      else if( temp == 1 ) ++one;
    }
    if( cnt ) {
      printf("%d\n",cnt+one+1);
    } else {
      puts("NA");
    }
  }
  return 0;
}

Measured memory_bytes: 1148
#include<stdlib.h>
#include<iostream>
using namespace std;

int main(){
  int a, count;
  cin >> a;
  while (a > 0){
    if (a % 10 == 1){
      count++;
    }
    a /= 10;
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
s = [0]*(N+1)
for i in range(M):
  l,r = list(map(int,input().split()))
  s[l] += 1
  if r+1 != N+1:
    s[r+1] -= 1
ruiseki = [0]*(N+1)
cnt = 0
for i in range(1,N+1):
  ruiseki[i] += ruiseki[i-1] + s[i]
  if ruiseki[i] == M:
    cnt +=1
print(cnt)

Measured memory_bytes: 8036
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int num[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int k;
	cin>>k;
	cout<<num[k-1];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#include<cmath>
using namespace std;
int main()
{
	int N,M;
	pair<int,int> PD[10010];
	while(cin>>N>>M && N>0)
	{
		int d,p;
		for (int i = 0 ; i < N ; i++)
		{
			cin >> d >> p;
			PD[i] =  make_pair(p, d);
		}
		sort(PD,PD+N);
		reverse(PD,PD+N);
		int S = 0;
		for(int j = 0; j < N; j++)
		{
			S += PD[j].first * PD[j].second;
		}
		for(int k = 0; k < N; k++ )
		{
			if(M <= 0) break;
			int guarded = min(M, PD[k].second);
			S -=  PD[k].first * guarded;
			M -= guarded;
		}
		cout<<S<<endl;
	}

	return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a;i<(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000;
const char ENDL = '\n';

ll youkurido(ll x, ll y) {
	if (x > y) swap(x, y);
	ll n = y % x;
	if (n == 0)
		return x;
	else
		youkurido(x, n);
}

ll minkoubai(ll x, ll y) {
	ll you = youkurido(x, y);
	ll sub = x / you * y;
	return sub;
}


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

	ll N, Ans;
	cin >> N;
	vector<ll> T(N);
	rep(i, N)
		cin >> T[i];
	
	Ans = T[0];
	rep1(i, N)
		Ans = minkoubai(Ans, T[i]);

	cout << Ans << ENDL;

	return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    H, W, D = map(int, input().split())
    A = []
    for _ in range(H):
        a = list(map(int, input().split()))
        A.append(a)

    place = {}
    for h in range(H):
        for w in range(W):
            place[A[h][w]] = (h, w)

    diff = dict()
    for d in range(1, D + 1):
        cumsum = [0]
        ds = list(range(d, H * W + 1, D))
        N = len(ds)
        for i in range(N - 1):
            x, y = place[ds[i]]
            X, Y = place[ds[i + 1]]
            tmp = cumsum[-1] + abs(x - X) + abs(y - Y)
            cumsum.append(tmp)
        diff[d % D] = cumsum

    Q = int(input())
    ans = []
    for _ in range(Q):
        L, R = map(int, input().split())
        m = L % D
        if m == 0:
            L_idx = L // D - 1
            R_idx = R // D - 1
        else:
            L_idx = L // D
            R_idx = R // D
        a = diff[m][R_idx] - diff[m][L_idx]
        ans.append(a)

    for a in ans:
        print(a)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39944
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000
typedef long long i64;

int n = 7;

char *s[]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
char cur[10];

int input() {
	if (scanf("%s", cur) < 0) return 0;
	return 1;
}

void init() {
}

int solve() {
	for (int i=0; i<n; i++)
		if (strcmp(cur, s[i])==0) {
			for (int j=1; j<=n; j++)
				if (strcmp(s[(i+j) % n], "SUN")==0)
					return j;
		}
	return 1;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<sstream>
using namespace std;
int x;
string s;
int main()
{
	cin>>x;
	cin>>s;
	int sum=0;
	for(int i=1;i<s.size()-1;i++)
	{
		if(s[i]=='B'&&s[i-1]=='A'&&s[i+1]=='C')
			sum++;	
	}
	cout<<sum;
}


Measured memory_bytes: 3588
#include<stdio.h>
#define N 100001

int partition(int *,int,int );

int A[N];
int main(){
  
  int n,i,k;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  k=partition(A,0, n);
  for(i=0;i<k-1;i++)
    printf("%d ",A[i]);
  printf("[%d] ",A[k-1]);
  for(i=k;i<n-1;i++)
    printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  return 0;
}



int partition(int *A,int p, int r)
{
  int x,i,j,tmp;
  x=A[r-1];
  
  for(j=p;j<r;j++){

    if(A[j]<=x){
      tmp=A[i];
  A[i]=A[j];
  A[j]=tmp;

  i++;
  
    }}
  return i;
}




Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
using namespace std;
int dis(int r1, int c1, int r2, int c2){
    return abs(r1 - r2) + abs(c1 - c2);
}
char grid[501][501];
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int h, w;cin >> h >> w;
    int d;cin >> d;
    //FOR(i, h)FOR(j, w)cin >> grid[i][j];
    FOR(i, h){
        FOR(j, w){
            int r = i + j;
            r /= d;
            int c = i - j + 500;
            c /= d;

            //cout << i << " " << j << endl;
//            cout << r << " " << c << endl;
            if((c & 1) && (r & 1)){
                cout << "R"; 
            }else if(c & 1){
                cout << "G"; 
            }else if(r & 1){
                cout << "B"; 
            }else{
                cout << "Y"; 
            }
        }
        cout << endl;
    }
}




Measured memory_bytes: 512