akhauriyash/Code-Regression huggingface dataset:
A1=list(map(int, input().split()))
A2=list(map(int, input().split()))
A3=list(map(int, input().split()))
A=A1+A2+A3
N=int(input())
s=set()
for _ in range(N):
  b=int(input())
  if b in A:
    s|={A.index(b)}
bingo=[{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,5,8},{2,4,6},{3,4,5},{6,7,8}]
print(['No','Yes'][any(s>=b for b in bingo)])

Measured memory_bytes: 9236
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    vector<int> hs(n);
    for(int i = 0; i < n; i++){
        cin >> hs[i];
        // scanf("%d", &hs[i]);
    }
    sort(hs.rbegin(), hs.rend());
    auto solve = [&](int num){
        int cnt = num;
        for(int i = 0; i < n; i++){
            ll hp = hs[i] - b * num;
            if(hp <= 0){ break; }
            cnt -= (hp + a - b - 1) / (a - b);
            if(cnt < 0){
                break;
            }
        }
        return cnt >= 0;
    };
    int l = 0, r = 1e9;
    while(l < r){
        int piv = (l + r) / 2;
        if(solve(piv)){
            r = piv;
        }else{
            l = piv + 1;
        }
        prints(l, r);
    }
    cout << l << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
	
	int i;
	
	char S[100010];
	scanf("%s",S);
	
	int c[26]={0};
	
	for(i=0;i<strlen(S);i++){
		c[S[i]-'a']++;
	}
	
	for(i=0;i<26;i++){
	if(c[i]==0){
	printf("\n%c\n\n",'a'+i);
	return 0;
	}
	}
	
	printf("\nNone\n\n");
	
	return 0;
}

Measured memory_bytes: 256
# エラトステネスの篩

import math

def get_input():
    return int(input())

def eratosthenes(n):
    table = [i for i in range(2, int(math.sqrt(n))+1)]
    prime = []
    while table[0] <= int(math.sqrt(n)):
        prime.append(table[0])
        head = table[0]
        table = [i for i in table if i%head != 0]
        if not table: break
    return prime

if __name__ == '__main__':
    n = get_input()
    
    if n <= 3:
        print("{}: {}".format(n, n))
    else:
        lis = []
        temp = n
        primes = eratosthenes(n) + [n]
        for d in primes:
            if temp <= 0:
                break
            while (temp%d == 0):
                lis.append(str(int(d)))
                temp = temp // d
        
        if temp > 1:
            lis.append(str(temp))

        print("{}: {}".format(n, " ".join(lis)))


Measured memory_bytes: 6904
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String S = "";
        Scanner sc = new Scanner(System.in);
        S = sc.nextLine();
        String[] S1 = S.split(" ");
        System.out.println(S1[S1.length - 1]+" "+S1[0]+ " "+ S1[1]);
    }
}


Measured memory_bytes: 39756
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next(),k="keyence";
    int countl=0,countr=0,j=k.length();
    boolean flag=true;
    for(int i=0;i<s.length();i++) {
    	if(s.substring(i, i+1).equals(k.substring(countl, countl+1))) {
    		countl++;
    		if(countl==7) {
    			System.out.println("YES");
    			System.exit(0);
    		}
    	}else {
    		break;
    	}
    }
    for(int i=s.length();i>0;i--) {
    	if(s.substring(i-1, i).equals(k.substring(j-1, j))) {
    		countr++;
    		j--;
    		if(countr==7) {
    			System.out.println("YES");
    			System.exit(0);
    		}
    	}else {
    		break;
    	}
    }
    //System.out.println("count:"+countl+" countr:"+countr);
    if(countl+countr>=7) {
    	System.out.println("YES");
    }else {
    	System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21972
S = input()
S_inv = S[::-1]
i=0
flg = True
while i<len(S):
    if S_inv[i:i+5]=='dream'[::-1]:
        i = i + 5
    elif S_inv[i:i+7]=='dreamer'[::-1]:
        i = i + 7
    elif S_inv[i:i+5]=='erase'[::-1]:
        i = i + 5
    elif S_inv[i:i + 6] == 'eraser'[::-1]:
        i = i + 6
    else:
        flg = False
        break

if flg ==True:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 73428
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
typedef long double lld;
//#define LOCAL_DEFINE 0
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}


const ll mod = 1e9+7;

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

int X[] = {0,1,0,-1};
int Y[] = {1,0,-1,0};

int main() {
#ifdef LOCAL_DEFINE
    freopen("CCL.in","r",stdin);
    freopen("ans.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    // logic
    int a,b,x;
    cin >> a >> b >> x;
    int req = x-a;
    if(req < 0) printf("NO");
    else {
        if(req <= b) printf("YES");
        else printf("NO");
    }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string str;
  cin >> str;

  ll ans=0;
  ll tmp=0;
  REP(i, str.size()){
    switch(str[i]){
      case 'A':
      case 'C':
      case 'G':
      case 'T':
        tmp++;
        ans = max(ans, tmp);
        break;
      default:
        tmp = 0;
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>

int main()
{
  int n;
  scanf("%d", &n);
  std::pair<int, int> ps[200000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d %d", &ps[i].first, &ps[i].second);
  }
  std::sort(ps, ps + n, [](auto a, auto b) -> bool { return a.second < b.second; });
  long t = 0;
  for (int i = 0; i < n; ++i)
  {
    t += ps[i].first;
    if (t > ps[i].second)
    {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 1664
#
# agc011 a
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 3 5
1
2
3
6
12"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6 3 3
7
6
2
8
10
6"""
        output = """3"""
        self.assertIO(input, output)


def resolve():
    N, C, K = map(int, input().split())
    T = []
    for _ in range(N):
        T.append(int(input()))
    T.sort()

    ans = 0
    u = 0
    s = T[N-1] + K + 1
    for t in reversed(T):
        if t + K >= s and u < C:
            u += 1
        else:
            ans += 1
            s = t
            u = 1

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 20628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
ll dp[55][55][2505];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;cin>>n>>a;
    vector<int> k(n);
    rep(i,n)cin>>k[i];
    rep(i,n+1)rep(j,n+1)rep(l,n*a+1)dp[i][j][l]=0;
    dp[0][0][0]=1;
    rep(i,n)rep(j,n+1)rep(l,n*a+1){
        dp[i+1][j][l]+=dp[i][j][l];
        dp[i+1][j+1][l+k[i]]+=dp[i][j][l];
    }
    ll ans=0;
    for(int j=1;j<=n;j++)ans+=dp[n][j][j*a];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 55424
// C - 2D Plane 2N Points
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N; cin>>N;
	vector<vi> AB(N, vi(2)), CD(N, vi(2));
	rep(i, N) cin>>AB[i][0]>>AB[i][1];
	rep(i, N) cin>>CD[i][0]>>CD[i][1];

	sort(all(CD));
	sort(all(AB), [](vi a, vi b){ return a[1] > b[1]; });

	vector<vi> dim_b(N, vi());
	rep(b, N)
		rep(r, N)
			if(AB[r][0] < CD[b][0] && AB[r][1] < CD[b][1])
				dim_b[b].push_back(r);

	vi vis_r(N, false);
	rep(b, N)
		for(int r:dim_b[b])
			if(!vis_r[r]){ vis_r[r] = true; break; }

	cout<< accumulate(all(vis_r), 0) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=3e3+_;
const LL mod=998244353;
inline LL ad(LL x,LL y){return (x>=mod-y)?x-mod+y:x+y;}
inline LL re(LL x,LL y){return (x<y)?x-y+mod:x-y;}
int n,x;
LL C[maxn][maxn],f[maxn][2*maxn];//只放1、2长度为i和为j的序列方案数 
void yu()
{
	C[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=ad(C[i-1][j-1],C[i-1][j]);
	}
	f[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<x;j++)
			if(f[i][j])
			{
				f[i+1][j+1]=ad(f[i+1][j+1],f[i][j]);
				f[i+1][j+2]=ad(f[i+1][j+2],f[i][j]);
			}
}

int main()
{
	scanf("%d%d",&n,&x); yu();
	LL ans=1;
	for(int L=1;L<=n;L++)
	{
		LL sum=0;
		for(int S=1;S<=2*L;S++)
		{
			if(S<x)sum=ad(sum,f[L][S]);
			else
			{
				if((x%2==0)^(S%2==0))
				{
					if(L*2==S)sum=ad(sum,1);
					else
					{
						int lp=(S-x+2)/2+1,rp=(x+2*L-S)/2;//最左/右的1的位置 
						if(1<=lp&&lp<=L&&1<=rp&&rp<=L&&lp<=rp)
							sum=ad(sum,f[rp-lp+1][S-2*(L-(rp-lp+1))]);
					}
				}
			}
		}
		ans=ad(ans,C[n][L]*sum%mod);
	}
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 217472
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
int length;
int flag;
int l,r;
int i,j;
char str[110];

int main()
{
    flag=1;
    scanf("%s",str);
    length=strlen(str);
    l=(length-1)/2;
    r=(length+3)/2;
    for(i=0,j=l-1;i<l;i++,j--)
        if(str[i]!=str[j])
        {
            flag=0;
            break;
        }
    for(i=r-1,j=length-1;i<length;i++,j--)
        if(str[i]!=str[j])
        {
            flag=0;
            break;
        }
    for(i=0,j=length-1;i<length;i++,j--)
        if(str[i]!=str[j])
        {
            flag=0;
            break;
        }
    if(flag)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int h, w, n;
    cin >> h >> w >> n;

    int mx = max(h, w);

    int ans = (n + (mx - 1)) / mx;

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

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



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

    bool flag1, flag2;
    flag1 = flag2 = false;
    if(s[2] == s[3]) flag1 = true;
    if(s[4] == s[5]) flag2 = true;
    if(flag1 && flag2) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

static const int N = 100;

int main()
{
    int M[N][N];    // 0オリジンの隣接行列
    int n, u, k, v;
    int i, j;

    cin >> n;

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) M[i][j] = 0;
    }

    for (i = 0; i < n; i++)
    {
        cin >> u >> k;
        u--;        // 0オリジンへ変換
        for (j = 0; j < k; j++) {
            cin >> v;
            v--;    // 0オリジンへ変換
            M[u][v] = 1;    // u と v の間に辺を張る
        }
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3136
n = int(input())
s = input()
k = int(input())
li = []

for i in s:
  li.append(i)
check = li[k - 1]
for j in range(n):
  if li[j] != check:
    li[j] = "*"
ans = ""
for l in li:
  ans = ans + l
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

template <typename T>
class SegmentTree {
  const T unit;
  const function<T(const T&, const T&)> op;
  vector<T> container;

 public:
  template <typename Op>
  SegmentTree(int size, const T& identity, const Op& operation)
      : unit(identity), op(operation), container(msb(size * 2 - 1)) {
    fill(container.begin(), container.end(), unit);
  }
  void update(size_t index, T value) {
    int n = container.size() / 2;
    container[index + n] = value;

    int node = (index + n) >> 1;
    while (node > 0) {
      container[node] = op(container[node << 1], container[(node << 1) + 1]);
      node >>= 1;
    }
  }
  T find(size_t s, size_t t) {
    if (s >= t) {
      return unit;
    }
    return find_inner(s, t, 0, container.size() / 2);
  }

 private:
  T find_inner(size_t s, size_t t, size_t lb, size_t ub) {
    if (s == lb && t == ub) {
      int n = container.size() / 2;
      return container[lca(n + s, n + t - 1)];
    }

    T result = unit;
    size_t mid = (lb + ub) / 2;
    if (mid > s) {
      result = op(result, find_inner(s, min(mid, t), lb, mid));
    }
    if (mid < t) {
      result = op(result, find_inner(max(s, mid), t, mid, ub));
    }

    return result;
  }
  int lca(int n0, int n1) {
    int a = n0 ^ n1;
    return n0 / msb(a);
  }
  int msb(int x) {
    x |= x >> 1;
    x |= x >> 2;
    x |= x >> 4;
    x |= x >> 8;
    x |= x >> 16;

    return x + 1;
  }
};

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

  int N, Q;
  cin >> N >> Q;

  vector<int> c(N);
  rep(i, N) {
    cin >> c[i];
    c[i]--;
  }

  using Query = tuple<int, int, int>;
  vector<Query> q;
  rep(i, Q) {
    int l, r;
    cin >> l >> r;
    q.push_back(Query(r, l, i));
  }
  sort(q.begin(), q.end());

  SegmentTree<int> cnt(N + 1, 0,
                       [](const int& lh, const int& rh) { return lh + rh; });
  vector<int> rightmost(N, 0);
  vector<int> result(Q);
  int j = 1;
  rep(i, Q) {
    int l, r, idx;
    tie(r, l, idx) = q[i];
    while (j <= r) {
      int old = rightmost[c[j - 1]];
      rightmost[c[j - 1]] = j;
      cnt.update(old, 0);
      cnt.update(j, 1);
      j++;
    }

    /*cerr << i << ": ";
    rep(k, N) { cerr << rightmost[k] << " "; }
    cerr << "\n";
    cerr << "seg: ";
    irep(i, N) { cerr << cnt.find(i, i + 1) << " "; }
    cerr << "\n";*/

    result[idx] = cnt.find(l, r + 1);
  }

  for (int r : result) {
    cout << r << "\n";
  }
  return 0;
}

Measured memory_bytes: 19572
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*
--------------------------------------------

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

-------------------------------------------- 
*/

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int H,A;
    cin >> H >> A;
    cout << (int)ceil((double)H / A) << endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int total = accumulate(ALL(a), 0);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (4 * m * a[i] >= total) ans++;
    }
    if (ans < m) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int X;
    cin >> X;
    for(int i = ceil(X/105); i <= X/100; i++) {
        for(int m = 100*i; m <= 105*i; m++) {
            if(m == X) {
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
# coding: utf-8
num_N, num_A = map(int, input().split())
l_card = list(map(int, input().split()))

l_card_ave = [i - num_A for i in l_card]

dict_ans = dict()
dict_ans[0] = 1
for card in l_card_ave:
    for key, value in list(dict_ans.items()):
        dict_ans[key + card] = dict_ans.get(key + card, 0) + value

print(dict_ans[0] - 1)

Measured memory_bytes: 3188
a = []
i = 0
j = 0
sum = 0
sumsum = 0

r, c = map(int, input().split())

while i < r:
    a.append(list(map(int, input().split())))
    i += 1

for i in range(r + 1):
    sum = 0

    if i < r:
        for j in range(c + 1):
            if j < c:
                print("%s " % a[i][j], end="")
                sum += a[i][j]
            else:
                print("%s" % sum)
    else:
        for j in range(c + 1):
            sum = 0

            if j < c:
                for i in range(r):
                    sum += a[i][j]
                    sumsum += a[i][j]
            
                print("%s " % sum, end="")
            else:
                print("%s" % sumsum)



Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ieps (int) 1e6
#define eps (int) 1e9
#define pii pair<int,int>
vector<int> adj[ieps];


int32_t main(){
	int n , m;
	cin>>n>>m;
	for(int i = 0;i<m;i++){
		int x , y;
		cin>>x>>y;
		x-- , y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	bool flag = false;
	for(auto v: adj[0]){
		for(auto p : adj[v]){
			if(p == n-1) flag = true;
		}
	}
	if(flag) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 31464
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

vector<ll> a(51), p(51);

ll recursive(ll n, ll x) {
  if (n == 0) return (x > 0) ? 1 : 0;
  if (x <= 1 + a[n-1]) return recursive(n-1, x-1);
  else if (x > 1 + a[n-1]) return p[n-1] + 1 + recursive(n-1, x - a[n-1] - 2);
}

int main() {
  ll n,x;
  cin >> n >> x;

  a[0] = p[0] = 1;
  rep(i,n) {
    a[i+1] = a[i] * 2 + 3;
    p[i+1] = p[i] * 2 + 1;
  }

  printf("%lld\n", recursive(n,x));
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false;
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >>n >>m >>k;
	VI ct(n);
	vector<VI> r(n);
	UF fr(n);
	rep(i, m){
		int a, b; cin >>a >>b;
		fr.unite(a-1, b-1);
		ct[a-1]++; ct[b-1]++;
	}
	rep(i, k){
		int a, b; cin >>a >>b;
		r[a-1].push_back(b-1);
		r[b-1].push_back(a-1);
	}
	rep(i, n){
		int ans = fr.size(i) - ct[i] -1;
		for(auto x: r[i]) ans -= fr.same(i, x);
		cout << ans <<" ";
	}
	cout <<"\n";
	return 0;
}


Measured memory_bytes: 6784
from heapq import nlargest
x,y,z,k=map(int,input().split())
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
D=nlargest(k,(a+b for a in A for b in B ))
E=nlargest(k,(d+c for c in C for d in D ))
for i in E:
    print(i)


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  string s;cin>>s;
  if(s[0]==s[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();
        int N, K;
        {int[] a = r.ii(); N = a[0]; K = a[1];}
        double ans = 0;
        if(K <= N)
            ans += N-K+1;
        for(int i = 1; i <= Math.min(K-1, N); i++){
            int n = 0;
            int score = i;
            while(score < K){
                n++;
                score *= 2;
            }            
            ans += Math.pow(0.5, n);
        }
        ans /= N;
        print(ans);        
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int Int(String s){
            return Integer.parseInt(s);
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <string>

using namespace std;

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

    int head = num / 100;
    int tail = num % 100;

    if (1 <= head && head <= 12) {
        if (1 <= tail && tail <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if (1 <= tail && tail <= 12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

ll POWER (ll x, ll y, ll mod){
    ll ans = 1, c = x;
    while (y){
        if ((y & 1) == 1)
            ans = ans * c % mod;
        c = c * c % mod;
        y /= 2;
    }
    return ans;
}

const ll N = 406, MOD = 1e9 + 7;
const double C = 1;

int n;
ll dp[N][N];
ll s[N];

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> s[i];
        s[i] += s[i - 1];
    }
    for (int l = 1; l < n; l++)
        for (int i = 1; i + l <= n; i++){
            dp[i][i + l] = dp[i][i] + dp[i + 1][i + l];
            for (int k = i + 1; k < i + l; k++)
                dp[i][i + l] = min (dp[i][i + l], dp[i][k] + dp[k + 1][i + l]);
            dp[i][i + l] += s[i + l] - s[i - 1];
        }
    cout<<dp[1][n]<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <ctime>
#include <list>
#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 1 << 18;
int dp[2][N];

int main(){
	int n;
	while (cin >> n, n){
		vector<int> v[500];
		rep(i, n){
			int x, cnt = 0;
			cin >> x;
			while (x % 2 == 0) x /= 2, ++cnt;
			v[x].push_back(cnt);
		}

		int ans = 1;
		rep(i, 500){
			MEMSET(dp, 0);
			int n = v[i].size();
			int Max = 0;
			rep(j, n){
				int cur = j & 1, nxt = j + 1 & 1, x = 1<<v[i][j], mask = x-1;
				dp[nxt][x] = 1;
				rep(k, Max+1){
					if (!dp[cur][k]) continue;
					if (!(k&mask)) dp[nxt][k + x] = max(dp[nxt][k + x], dp[cur][k] + 1);
					dp[nxt][k] = max(dp[nxt][k], dp[cur][k]);
					dp[cur][k] = 0;
				}
				Max += x;
				Max = min(Max, 1 << 17);
			}
			rep(i, 18) ans = max(ans, dp[n & 1][1 << i]);
		}
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int H, W, N;
	cin >> H >> W >> N;
	int SR, SC;
	cin >> SR >> SC;

	string S, T;
	cin >> S >> T;

	int GL = 0;
	int GR = W + 1;
	int GU = 0;
	int GD = H + 1;

	int OK = 1;
	for (int i = N - 1; i >= 0; i--) {
		if (T[i] == 'L') {
			GR++;
			if (GR > W + 1) GR = W + 1;
		}
		if (T[i] == 'R') {
			GL--;
			if (GL < 0) GL = 0;
		}
		if (T[i] == 'U') {
			GD++;
			if (GD > H + 1) GD = H + 1;
		}
		if (T[i] == 'D') {
			GU--;
			if (GU < 0) GU = 0;
		}
		if (GL >= GR - 1) OK = 0;
		if (GU >= GD - 1) OK = 0;
		if (S[i] == 'L') {
			GL++;
		}
		if (S[i] == 'R') {
			GR--;
		}
		if (S[i] == 'U') {
			GU++;
		}
		if (S[i] == 'D') {
			GD--;
		}
		if (GL >= GR - 1) OK = 0;
		if (GU >= GD - 1) OK = 0;
	}

	if (OK && GU < SR && SR < GD && GL < SC && SC < GR) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 920
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MAX_N 200001
using namespace std;
typedef long long int ll;

ll visited[MAX_N];

void init(){
	for(int i = 0; i < MAX_N; i++){
		visited[i] = -1;
	}
}


int main(){
	init();
	int n;
	ll k;
	cin>>n>>k;
	vector<ll> A(n+1);
	for(int i = 1; i <= n; i++){
		cin>>A[i];
	}
	ll count = 0;
	int now = 1;
	int previous = 1;
	while(visited[now] == -1){
		visited[now] = count;
		count++;
		previous = now;
		now = A[now];
	}
	ll offset = visited[now];
	ll loop = visited[previous] - visited[now] + 1;
	now = 1;
	if( k <= offset){
		for(int i = 0; i < k; i++){
			now = A[now];
		}
	}else{
		for(int i = 0; i < offset + ((k-offset) % loop);i++){
			now = A[now];
		}
	}
	cout<<now<<endl;
	//cout<<"offset:"<<offset<<",loop:"<<loop<<endl;
	return 0;
}


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

int main() {
  int N, K, Q; cin >> N >> K >> Q;
  int A[Q];
  for (int i = 0; i < Q; i++) cin >> A[i];
  int point[N];
  for (int i = 0; i < N; i++) point[i] = K - Q;
  for (int i = 0; i < Q; i++) point[A[i] - 1]++;
  for (int i = 0; i < N; i++) {
    if (point[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

int dp0[110][4];
int dp1[110][4]; //確定小於N

int main(){

    string n;
    int k;

    cin >> n >> k;

    int l = n.size();
    dp0[0][0] = 1;

    for(int i=0;i<l;i++){
        for(int j=0;j<=k;j++){

            if(dp0[i][j]){
                for(int h=0;h<=n[i]-'0';h++){
                    if(h+'0' == n[i]){
                        if(n[i]=='0'){
                            dp0[i+1][j] = 1;
                        }
                        else{
                            if(j+1<=k)
                                dp0[i+1][j+1] = 1;
                        }
                    }
                    else{
                        if(h==0){
                            dp1[i+1][j] += 1;
                        }
                        else{
                            if(j+1<=k)
                                dp1[i+1][j+1] += 1;
                        }
                    }
                }
            }

            dp1[i+1][j] += dp1[i][j];
            if(j+1<=k)
                dp1[i+1][j+1] += 9*dp1[i][j];
        }
    }

    /*for(int i=0;i<=l;i++){
        for(int j=0;j<=k;j++){
            cout << dp0[i][j] << " ";
        }
        cout << endl;
    }

    cout << endl;

    for(int i=0;i<=l;i++){
        for(int j=0;j<=k;j++){
            cout << dp1[i][j] << " ";
        }
        cout << endl;
    }*/


    cout << dp0[l][k]+dp1[l][k] << endl;

    return 0;
}


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

const int N = 1e5 + 1;

int n, m;
int dp[N];

vector < int > g[N];

int dfs(int v)
{
	if(g[v].size() == 0)
		return (dp[v] = 0);
	
	if(dp[v] != -1)
		return dp[v];
	
	for(int u : g[v])
		dp[v] = max(dp[v], dfs(u) + 1);
	
	return dp[v];
}

main()
{
	ios::sync_with_stdio(0);
	cin >> n >> m;
	
	while(m--)
	{
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
	}
	
	memset(dp, -1, sizeof(dp));
	
	for(int i = 1; i <= n; i++)
		dp[i] = dfs(i);
	
	int mx = 0;
	for(int i = 1; i <= n; i++)
		mx = max(dp[i], mx);
	
	cout << mx << endl;
}


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

int main(void) {
    int a;

    int tmp;
    rep(i,5){
      cin >> a;
      if(a==0)
        cout << i+1 << endl;
    }


    return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private static double max_n;
	private static double min_n;
	
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		max_n = Double.MIN_NORMAL;
		min_n = Double.MAX_VALUE;
		
		String val;
		while((val =br.readLine()) != null){
			double n = Double.parseDouble(val);
			if(max_n < n){
				max_n = n;
			}
			else if(min_n > n){
				min_n = n;
			}
		}
		
		System.out.println(max_n-min_n);
		

	}
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((a == b + c || b == c + a || c == b + a) ? "Yes" : "No")  << endl;
}


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

int main(void){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> L,R;
    for(int i=0;i<n;i++){
        if(s[i]=='L') L.push_back(i);
        else R.push_back(i); 
    }
    /*
    cout << "L: ";
    for(int x: L){
        cout << x << " ";
    }
    cout << endl;
    cout << "R: ";
    for(int x: R){
        cout << x << " ";
    }
    cout << endl;
    */
   
    vector<int> cycle(n);
    for(int i=0;i<n;i++){
        if(s[i]=='L'){
            int pos = lower_bound(R.begin(),R.end(),i) - R.begin();
            pos--;
            cycle[i] = R[pos];
        }else{
            int pos = upper_bound(L.begin(),L.end(),i) - L.begin();
            cycle[i] = L[pos];
        }
    }
    vector<int> ans(n,0);
    for(int i=0;i<n;i++){
        if(abs(cycle[i]-i)%2==0) ans[cycle[i]]++;
        else ans[cycle[cycle[i]]]++;
    }

    for(int i=0;i<n;i++){
        if(i!=n-1) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1916
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int dfs(int crt, int sum, vector<long long> &v, vector<vector<int>> &G) {
    sum += v[crt];
    v[crt] = sum;
    for (int i = 0; i < G[crt].size(); i++) {
        dfs(G[crt][i], sum, v, G);
    }
    sum -= v[crt];
    return 0;
}

int main(void) {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> G(N);
    vector<long long> v(N);
    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
    }
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        p--;
        v[p] += x;
    }

    dfs(0, 0, v, G);
    for (int i = 0; i < N; i++) {
        cout << v[i] << " ";
    }
    cout << endl;

}

Measured memory_bytes: 24320
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

char grid[52][52];

int h,w;

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    REP(i,1,h+1){
        REP(j,1,w+1){
            cin>>grid[i][j];
        }
    }

    bool f;
    REP(i,1,h+1){
        REP(j,1,w+1){
            if(grid[i][j]=='#'){
                f=false;
                rep(k,4){
                    if(grid[i+dx[k]][j+dy[k]]=='#') f=true;
                }
                if(!f){
                    no;
                    return 0;
                }
            }
        }
    }

    yes;

    return 0;
}


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


int main(){
  long long int n, temp;
  cin >> n;
  vector <long long int> nums (0LL);
  vector<long long int> count(n+1, 0LL);
  for(int i = 0; i < n; i++){
    cin >> temp;
    nums.push_back(temp);
    count.at(temp)++;
  }
  long long int ans = 0LL;
  for(int i = 0; i < n+1; i++){
    temp = count.at(i);
    ans += temp*(temp-1LL)/2LL;
    
  }
  for(int i = 0; i < n+1; i++){
    temp = count.at(i);
    if(temp >= 1LL){
      count.at(i) = ans + (temp-1LL)*(temp-2LL)/2LL - (temp-1LL)*temp/2LL;
    }
  }
  for(int i = 0; i < n; i++){
    cout << count.at(nums.at(i)) << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1};  // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A;
//bitset<32> bset1;
//bool ok = true;
//char ch;
string S, T, U;

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, flag=0, cnt=0;

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

    cin>>x;
    c=x/100;
    if(c*105>=x && c*100<=x)
    {
        cout<<1<<endl;
    }
    else  cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#define ll long long
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll a[200010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	sortup(a,n);
	for(int i=1;i<n;i++)if(a[i-1]==a[i]){
		puts("NO");
		return 0;
	}
	puts("YES");
}

Measured memory_bytes: 3324