akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int r, D, x;

    cin >> r >> D >> x;

    for(int i = 0; i < 10; i++){
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

int main() {
	string s;
	cin >> s;
	int sl = s.length();
	ll cnt = 0;
	string t;
	for (int i = 0; i <sl-1; i++) {
		if (s[i] == 'A') {
			t += '0';
		}
		else if (s[i] == 'B' && s[i + 1] == 'C') {
			t += '1';
			i++;
		}
		else {
			
			int tl = t.length();
			int p = 0;
			for (int j = 0; j < tl; j++) {
				if (t[j] == '1') {
					cnt += j - p;
					p++;
				}
			}

			t = string();

		}

	}

	int tl = t.length();
	int p = 0;
	for (int j = 0; j < tl; j++) {
		if (t[j] == '1') {
			cnt += j - p;
			p++;
		}
	}

	t = string();
	//cout << s << endl;
	cout << cnt << endl;
}

Measured memory_bytes: 3924
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;
        public long[,] X;

        public void Run()
        {
            N = Input.ReadInt();
            X = new long[N, 3];
            for (int i = 0; i < N; i++)
            {
                var line = Input.ReadIntArray();
                X[i, 0] = line[0];
                X[i, 1] = line[1];
                X[i, 2] = line[2];
            }

            long[,] DP = new long[N, 3];
            DP[0, 0] = X[0, 0];
            DP[0, 1] = X[0, 1];
            DP[0, 2] = X[0, 2];

            for (int i = 1; i < N; i++)
            {
                for (int a = 0; a < 3; a++)
                {
                    for (int b = 0; b < 3; b++)
                    {
                        if (a == b) continue;
                        DP[i, a] = Math.Max(DP[i - 1, b] + X[i, a], DP[i, a]);
                    }
                }
            }

            long ret = 0;
            for (int a = 0; a < 3; a++)
            {
                ret = Math.Max(ret, DP[N - 1, a]);
            }
            Console.WriteLine(ret);

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 21812
S = input()
N = len(S)

B = [0] * N
for i in range(N):
  if S[i] == 'R':
    B[i] = i+1;
  else:
    B[i] = i-1;

ans = [1] * N

def move(a, B):
  N = len(a)
  res = [0] * N
  for i in range(N):
    res[B[i]] += a[i]
  return res

step = 10 ** 10
while step > 0:
  if step % 2 == 1:
    ans = move(ans, B)
  BB = B[:]
  for i in range(N):
    BB[i] = B[B[i]]
  B = BB
  step //= 2

print(" ".join(map(str, ans)))


Measured memory_bytes: 14916
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}
 
using i64=int64_t;
 
struct edge{
    int from,to;
    i64 weight;
    edge(int from_,int to_,i64 weight_){
        from=from_;
        to=to_;
        weight=weight_;
    }
};
 
void solve(){
    int N,M;
    cin >> N >> M;
    vector<edge> edges;
    rep(i,0,M){
        int a,b;
        i64 c;
        cin >> a >> b >> c;
        --a;
        --b;
        edges.push_back(edge(a,b,-c));
    }
 
    vector<i64> dist(N,inf64);
    dist[0]=0;
    for(int i=0; i<N-1; ++i){
        for(edge& e:edges){
            int u=e.from,v=e.to;
            if(dist[u]!=inf64 and dist[v]>dist[u]+e.weight) dist[v]=dist[u]+e.weight;
        }
    }
 
    vector<bool> negative(N,false);
    for(int i=0; i<N; ++i){
        for(edge& e:edges){
            int u=e.from,v=e.to;
            if(dist[u]!=inf64 and dist[v]>dist[u]+e.weight){
                dist[v]=dist[u]+e.weight;
                negative[v]=true;
            }
        }
    }
    if(negative[N-1]) cout << "inf" << endl;
    else cout << -dist[N-1] << endl;
}
 
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

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

    int cnt = 0;

    rep(i,n) {
        if( s[i] == 'A' && s[i+1] == 'B' ) {
            if(s[i+2] == 'C') ++cnt;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

int main(){
	int64_t n;
	cin>>n;
	vector<int64_t> k;
	k.reserve(n);
	for(int64_t i1=0;i1<n;i1++){
		int64_t temp;
		cin>>temp;
		k.push_back(temp);
	}
	reverse(k.begin(),k.end());
	int64_t min=2;
	int64_t max=2;
	bool possible=true;
	for(int64_t i1=0;i1<n;i1++){
		int64_t min_index=(min+k.at(i1)-1)/k.at(i1);
		int64_t max_index=max/k.at(i1);
		if(min_index>max_index){
			possible=false;
			break;
		}else{
			min=min_index*k.at(i1);
			max=(max_index+1)*k.at(i1)-1;
		}
	}
	if(possible){
		cout<<min<<" "<<max<<endl;
	}else{
		cout<<-1<<endl;
	}
}


Measured memory_bytes: 1024
#include <stdio.h>
#define det(A) (A.a*A.d-A.b*A.c)
#define fix(A) ((-0.0001<A && A<0)?0:A) /* -0.000ツづー0.000ツづ可修ツ青ウ */

struct matrix{ double a, b, c, d; };
struct vector{ double a, b; };

struct vector multi(struct matrix x, struct vector y){
	struct vector res;
	res.a=x.a*y.a+x.b*y.b,
	res.b=x.c*y.a+x.d*y.b;
	return res;
}

struct matrix inv(struct matrix x){
	struct matrix res;
	res.a=x.d/det(x), res.b=-x.b/det(x),
	res.c=-x.c/det(x), res.d=x.a/det(x);
	return res;
}

int main(void){
	struct matrix m; struct vector v;
	while(~scanf("%lf %lf %lf %lf %lf %lf",&m.a,&m.b,&v.a,&m.c,&m.d,&v.b))
		printf("%.3lf %.3lf\n",fix(multi(inv(m),v).a),fix(multi(inv(m),v).b));
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    int u[100002], v[100002], w[100002];
    vector<P> a[100002];
    for(int i = 0; i < n; i++){
        cin >> u[i] >> v[i] >> w[i];
        u[i]--;
        v[i]--;
        a[u[i]].push_back(P(v[i], w[i]));
        a[v[i]].push_back(P(u[i], w[i]));
    }
    int c[100002];
    fill(c, c + n, -1);
    c[0] = 0;
    queue<int> q;
    q.push(0);
    while(q.size()){
        int now = q.front();
        q.pop();
        for(P next : a[now]){
            if(c[next.first] == -1){
                c[next.first] = (next.second + c[now]) % 2;
                q.push(next.first);
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout << c[i] << endl;
    }
}

Measured memory_bytes: 7936
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  double a,e,f=0;cin>>a;
  vector<ll>b(a);
    double d,c;
  rep(i,a){
    cin>>b[i];
    c+=b[i];
  }
  d=c/a;
  e=round(d);
  rep(i,a){
    f+=(max((ll)(e),b[i])-min((ll)(e),b[i]))*(max((ll)(e),b[i])-min((ll)(e),b[i]));
  }
  cout<<f;
}


Measured memory_bytes: 23680
using System;

namespace ABC057
{
    class C
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long min = long.MaxValue;
            long B = 0;
            for (long i = 1; i <= Math.Sqrt(N); i++)
            {
                if (N % i == 0)
                {
                    B = N / i;

                    min = Math.Min(min, CalculateTheNumberOfRows(B));
                }
            }

            Console.WriteLine(min);
        }

        static long CalculateTheNumberOfRows(long x)
        {
            long count = 0;
            while (0 < x)
            {
                x /= 10;
                count++;

            }
            return count;
        }
    }
}

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

int main(void){
    
    int Aside1, Aside2, Bside1, Bside2;
    int A, B;
    
    cin >> Aside1 >> Aside2 >> Bside1 >> Bside2;
    
    A = Aside1 * Aside2;
    B = Bside1 * Bside2;
    
    if(A >= B) cout << A << endl;
    else cout << B << endl;
    
    return 0;
    
}


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

ma = {}
ma['AC'] = 0
ma['WA'] = 0
ma['TLE'] = 0
ma['RE'] = 0
for i in range(N):
    s = input()
    if s in ma:
        ma[s] += 1


print("AC x " + str(ma['AC']))
print("WA x " + str(ma['WA']))
print("TLE x " + str(ma['TLE']))
print("RE x " + str(ma['RE']))


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	while(1){
		int n,m;
		cin>>n;
		if(n==0) break;
		int res=0;
		bool a=0,b=0,B=1;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			if(s=="lu") a=1;
			if(s=="ru") b=1;
			if(s=="ld") a=0;
			if(s=="rd") b=0;
			if(B==a&&B==b){
				res++;
				B^=1;
			}
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
using namespace std;

int main(){
	ll n;cin>>n;
	string s,s1="",s2="";cin>>s;
	if(n&1){
		cout<<"No\n";
		return 0;
	}
	ll p=n/2;
	f(i,0,n){
		if(i<p)  s1=s1+s[i];
		else s2=s2+s[i];
	}
	if(s1==s2) cout<<"Yes\n";
	else cout<<"No\n";
}

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


int main()
{
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> cnt(10,std::vector<int>(10));

    for(int i = 1; i <= n; i++){
        std::string k = std::to_string(i);
        for(int left = 1 + '0'; left < 10 + '0'; left++){
            for(int right = 1 + '0'; right < 10 + '0'; right++){
                if(*k.begin() == left && k.back() == right)cnt[left - '0'][right - '0']++;
            }
        }
    }
    long long res = 0;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            res += (long long)cnt[i][j] * cnt[j][i];
        }
    }
    std::cout << res << std::endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    K = Scanner.int()
    S = Scanner.string()
    if len(S) <= K:
        print(S)
    else:
        print(S[0:K], '...', sep='')


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10724
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N=3e5;
int tr[4*N];
int Q(int node,int s,int e,int i,int j)
{
    if(i>e || j<s)
    {
        return 0;
    }
    else if(i<=s && e<=j)
    {
        return tr[node];
    }
    int l=node*2;
    int r=l+1;
    int m=(s+e)/2;
    int p=Q(l,s,m,i,j);
    int q=Q(r,m+1,e,i,j);
    return max(p,q);
}
void up(int node,int s,int e,int i,int v)
{
    if(i>e || i<s)
    {
        return;
    }
    else if(s==e && i==s)
    {
        tr[node]=v;
        return;
    }
    int l=node*2;
    int r=l+1;
    int m=(s+e)/2;
    up(l,s,m,i,v);
    up(r,m+1,e,i,v);
    tr[node]=max(tr[l],tr[r]);
}
int main()
{
    ft
    int t,i,j,n,m,l,r,ans=-1;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>l;
        r=Q(1,0,N,max(0,l-m),min(N,l+m));
        up(1,0,N,l,r+1);
        ans=max(ans,r+1);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 7752
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(Math.Ceiling(input[0] / (2 * input[1] + 1.0)));
        }
    }
}

Measured memory_bytes: 13268
//Code By PMD
#include<bits/stdc++.h>
#define faster() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long i64;
int n;
vector < int > a;
void input(){
    cin >> n; a.resize(n);
    for(auto &x : a) cin >> x;
}
void solve(){
    for(auto x : a){
        if ( x % 2 == 0){
            if ( x % 3 !=0 && x%5 != 0){
                cout << "DENIED";
                return;
            }
        }
    }
    cout << "APPROVED";
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    faster();int t=1; 
    //cin>>t; cin.ignore();
    while(t--){ input();solve();}
    cerr << "\nRunning is : " << 1.0*clock()/1000 ;
    return 0;
}
//Code By PMD
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(int, i, a, b)        for (int i=a; i<(b); i++)
#define forev(int, i, b, a)     for (int i = (b)-1; i >= a; i--)
#define uns                     unsigned
#define lli                     long long int
#define ld                      long double
#define all(x)                  x.begin(), x.end()
#define sortall(x)              sort(all(x))
#define enl                     "\n"
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; // const ll INF = 1e18; // const int MX = 100001;
//==================================================================================

void solve() {
    lli n, mxx = 0; cin >> n;
    lli a[n];
    fo(lli, i, 0, n) {
        cin >> a[i];
        mxx = max(mxx, a[i]);
    }
    vector<int> dp(mxx + 1, 1);
    int hash[mxx + 1] = {0};
    for (lli i = 0; i < n; ++i) {
        if (hash[a[i]] == 1) dp[a[i]] = 0;
        hash[a[i]] = 1;
        if (dp[a[i]] == false) continue;
        for (lli j = 2; j < mxx + 1; ++j) {
            if (j * a[i] > mxx) break;
            dp[j * a[i]] = 0;
        }
    }
    lli cnt = 0;
    for (lli i = 0; i < n; ++i) {
        if (dp[a[i]] == 1) cnt++;
    }

    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // int testcase; cin >> testcase; for (int i = 1; i <= testcase; ++i)
    solve();
    return 0;
}

Measured memory_bytes: 12572
#include <stdio.h>
#include <stdlib.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define bit(n,m)(((n)>>(m))&1)

int h,w,a[20];
char S[20][20];

void g(int s,int m){
	if(!s){
		puts("YES");
		exit(0);
	}
	int i=__builtin_ctz(s);
	if(m){
		int b=1;
		rep(k,0,h)b&=S[k][i]==S[a[k]][i];
		if(b)g(s^(1<<i),0);
	}
	rep(j,i+1,w)if(bit(s,j)){
		int b=1;
		rep(k,0,h)b&=S[k][i]==S[a[k]][j];
		if(b)g(s^(1<<i)^(1<<j),m);
	}
}

void f(int s,int m){
	if(!s)g((1<<w)-1,w%2);
	int i=__builtin_ctz(s);
	if(m){
		a[i]=i;
		f(s^(1<<i),0);
	}
	rep(j,i+1,h)if(bit(s,j)){
		a[i]=j;
		a[j]=i;
		f(s^(1<<i)^(1<<j),m);
	}
}

int main(){
	scanf("%d%d",&h,&w);
	rep(i,0,h)scanf(" %s",S[i]);
	f((1<<h)-1,h%2);
	puts("NO");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e3+7;
long double p[N], f[N][N];
int main()
{
	int n;
	long double ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%Lf", &p[i]);
	}
	f[1][1] = p[1];
	f[1][0] = 1-p[1];
	for(int i = 2; i <= n; i++)
	{
		for(int j = 0; j <= i; j++)
		{
			f[i][j] = f[i-1][j]*(1-p[i]);
			if(j-1>=0)
			{
				f[i][j] += f[i-1][j-1]*p[i];
			}
		}
	}
	for(int i = n; i > n-i; i--)
	{
		ans += f[n][i];
	}
    printf("%.12Lf\n", ans);
	return 0;
}

Measured memory_bytes: 139776
#include<stdio.h>

int main(void){
    int a, b;

    scanf("%d %d", &a, &b);
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2140
import collections

N = int(input())
num_list = list(map(int,input().split()))
memo = [0]*(N+1)
memo_flg = [False]*(N+1)
counter = [0] * (N+1)
counter_ans = [0] * (N+1)

for i in num_list:
    counter[i] += 1
for i in range(N+1):
    counter_ans[i] = (counter[i]*(counter[i]-1))//2

all_sum = sum(counter_ans)
def calc(k):
    num = num_list[k]
    
    if(memo_flg[num] is True):
        return memo[num]
    ans = 0
    
    wrong = counter_ans[num]
    c = counter[num]-1
    right = (c*(c-1))//2
    
    ans = all_sum - wrong + right
    memo[num] = ans
    memo_flg[num] = True
    return ans

[print(calc(i)) for i in range(N)]


Measured memory_bytes: 26780
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const double pi=3.14159265358979323846;
int n,m,a[2000]={},b[2000]={},ans=0,par[55]={};
int find(int x) {
  if(par[x]==x) {
    return x;
  }
  return par[x]=find(par[x]);
}
bool same(int x,int y) {
  return find(x)==find(y);
}
void unit(int x,int y) {
  x=find(x);
  y=find(y);
  if(x!=y) {
    par[x]=y;
  }
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
  }
  for(int i=0; i<m; i++) {
    for(int j=0; j<n; j++) {
      par[j]=j;
    }
    for(int j=0; j<m; j++) {
      if(i!=j) {
        unit(a[j],b[j]);
      }
    }
    int f=0;
    for(int i=0; i<n-1; i++) {
      if(!same(i,i+1)) {
        f=1;
      }
    }
    if(f) {
      ans++;
    }
  }
  cout << ans << endl;
}




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

class Cube {
public:
	int f[6];
	Cube(){}

	void roll_y() { roll(0, 2, 5, 3); }//to W
	void roll_x() { roll(0, 1, 5, 4); }//to N
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
	void move(char ch) {
		if (ch == 'E')for (int i = 0; i < 3; i++)roll_y();
		if (ch == 'W')roll_y();
		if (ch == 'N')roll_x();
		if (ch == 'S')for (int i = 0; i < 3; i++)roll_x();
	}
};

int main()
{
	Cube c;
	string com;

	for (int i = 0; i < 6; i++)cin >> c.f[i];

	cin >> com;

	for (int i = 0; i < com.size(); i++)c.move(com[i]);

	cout << c.f[0] << endl;

	return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

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

    ll N, M;
    cin >> N >> M;
    priority_queue<ll, vector<ll>, greater<ll>> que_A;
    REP(i, N) {
        ll A;
        cin >> A;
        que_A.push(A);
    }

    map<ll, ll, greater<ll>> m;
    REP(i, M) {
        ll B, C;
        cin >> B >> C;
        m[C] += B;
    }

    REP(i, N) {
        ll small = que_A.top();
        ll maxv = m.begin()->first;
        if (maxv > small) {
            que_A.pop();
            que_A.push(maxv);
            m[maxv]--;
            debug(m);
            if (m[maxv] == 0) {
                m.erase(maxv);
            }
        }
    }
    ll ans=0;
    REP(i, N){
        debug(que_A.top());
        ans+=que_A.top();
        que_A.pop();
    }
    debug(ans);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7284
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N,Q,s,t;
string S;
vi vec,sum;

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

    vec.resize(N,0), sum.resize(N+1,0);
    for(int i = 1; i < N; i++){
        if(S[i] == 'C' && S[i-1] == 'A') vec[i-1]=1;
    }

    rep(i,N)
        sum[i+1] = sum[i] + vec[i];

    rep(i, Q){
        cin >> s >> t;
        --s, --t;
        cout << sum[t] - sum[s] << endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<pii> x(n);
	rep(i,n) cin >> x.at(i).first >> x.at(i).second;
	sort(x.begin(),x.end());
	int ans = n, cnt = n;
	int j = 0;
	for(int i = 1; i < n; i++){
		if(x.at(i).first - x.at(i).second < x.at(j).first + x.at(j).second){
			cnt--;
			if(x.at(i).first + x.at(i).second < x.at(j).first + x.at(j).second) j = i;
		}
		else{
			j = i;
		}
	}
	ans = cnt;
	cnt = n;
	j = n - 1;
	for(int i = n - 2; i >= 0; i--){
		if(x.at(i).first - x.at(i).second < x.at(j).first + x.at(j).second){
			cnt--;
			if(x.at(i).first + x.at(i).second < x.at(j).first + x.at(j).second) j = i;
		}
		else{
			j = i;
		}
	}
	cout << max(ans, cnt) << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';
 
int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) { int a; scanf("%d", &a); '\n'; p[i] = a - 1;}
	int count1 = 0;
	
	rep(i, n - 1) {
		if (p[i] == i) {
			int tmp = p[i];
			p[i] = p[i + 1];
			p[i + 1] = tmp;
			++count1;
		}
	}
	if (p[n - 1] == n - 1) ++count1;
	cout << count1;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2 * i +1;}

int main() {
  int H, i, A[MAX + 1];

  cin >> H;
  for(i = 1; i < H + 1; i++) cin >> A[i];

  for(i = 1; i < H + 1; i++) {
    cout<<"node "<<i<<": key = " << A[i]<<", ";
    if(parent(i) >= 1) cout<<"parent key = "<<A[parent(i)]<<", ";
    if(left(i) <= H) cout<<"left key = "<<A[left(i)]<<", ";
    if(right(i) <= H) cout<<"right key = "<<A[right(i)] <<", ";
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 3148
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    if A == B and B == C and A == C:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
import math
import itertools

def distance(x0, y0, x1, y1):
    d = math.sqrt((x0 - x1)**2 + (y0 - y1)**2)
    return d

N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
#print("x" + str(x))
#print("y" + str(y))

n = [int(x) for x in range(N)]
itr = list(itertools.permutations(n))
#print("n" + str(itr))

d = 0

for c in itr:
#    print("=================================================")
#    print(c)
    
    for i in range(N - 1):
#        print("------------------------------------")
#        print("i:" + str(i))
#        a = x[c[i]]
#        print("a:" + str(a))
        d += distance(x[c[i]], y[c[i]], x[c[i+1]], y[c[i+1]])
ans = d/len(itr)
print(ans)
    



Measured memory_bytes: 8052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;

int countDivisibles(int A, int B, int M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 







signed main(){
    int t=1;
    // cin>>t;
    while(t--){
        int x;
        cin>>x;
        for(int i=0;i<=1000;i++){
            for(int j=-1000;j<=1000;j++){
                int a = pow(i,5);
                int b = pow(j,5);
                // cout<<a<<" "<<b<<" ## ";
                if(a-b==x){
                    cout<<i<<" "<<j<<endl;
                    return 0;
                }

            }
        }
    }
    return 0;
}


Measured memory_bytes: 4072
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
ll n, sum;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;++i)
        sum += i % 3 && i % 5 ? i : 0;
    cout << sum;
    return 0;
}


Measured memory_bytes: 3632
import java.util.*

private class UnionFind(n: Int) {

    private val par = IntArray(n) { -1 }

    fun find(x: Int): Int {
        if (par[x] < 0) {
            return x
        }
        par[x] = find(par[x])
        return par[x]
    }

    fun unite(x: Int, y: Int) {
        val x1 = find(x)
        val y1 = find(y)
        if (x1 == y1) return

        val (x2, y2) = if (par[x1] > par[y1]) {
            Pair(y1, x1)
        } else {
            Pair(x1, y1)
        }

        par[x2] += par[y2]
        par[y2] = x2
    }

    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    fun size(x: Int): Int {
        return -par[find(x)]
    }

}

fun main(args: Array<String>) {
    val (N, M, K) = readLine()!!.split(' ').map { it.toInt() }
    val uf = UnionFind(N)
    val adj = Array(N) { mutableSetOf<Int>() }
    for (i in 0 until M) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        uf.unite(a - 1, b - 1)
        adj[a - 1].add(b - 1)
        adj[b - 1].add(a - 1)
    }
    val ans = Array(N) { 0 }
    for (i in 0 until N) {
        ans[i] = uf.size(i) - adj[i].count() - 1
    }
    for (i in 0 until K) {
        var (c, d) = readLine()!!.split(' ').map { it.toInt() }
        c--
        d--
        if (uf.same(c, d)) {
            ans[c]--
            ans[d]--
        }
    }
    println(ans.joinToString(" "))
}

Measured memory_bytes: 117148
n, k = map(int, input().split())
h = list(map(int, input().split()))
INF = float('inf')
dp = [INF]*n
dp[0] = 0

for i in range(n):
    for j in range(1, k+1):
        if n <= i+j:
            continue
        dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])

Measured memory_bytes: 55264
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n; // number of entries
  cin >> n;

  vector<int> sort_vec;

  for (int i = 0; i < n; i++) {
    int entry;
    cin >> entry;
    sort_vec.push_back(entry);
  }
  
  //bubble sort
  int n_swaps = 0; //number of swaps
  for (int i = 0; i < n; i++) {
    for (int j = n-1; j > i; j--) {
      if (sort_vec[j] < sort_vec[j-1]) {
	swap(sort_vec[j], sort_vec[j-1]);
	++n_swaps;
      }
    }
  }
  
  //print vector
  for (int i = 0; i < n; i++) {
    cout << sort_vec[i];
    if (i < n - 1) cout << " ";
  }
  cout << endl;

  cout << n_swaps << endl;
}
	

Measured memory_bytes: 1216
#include <cstdio>
#include <iostream>
#include <stack>
#include <string>
#include <queue>
#include <vector>

typedef struct {
  int parent = -1;
  int sibling = -1;
  int degree = 0;
  int depth = 0;
  int height = 0;
  std::string type;
  std::vector<int> children;
} Node;

int main() {
  int n;
  std::cin >> n;
  std::vector<Node> tree(n);
  for (int i = 0; i < n; ++i) {
    int id, left, right;
    std::cin >> id >> left >> right;
    if (left != -1) {
      tree[id].children.push_back(left);
      tree[left].parent = id;
      tree[left].sibling = right;
    }
    if (right != -1) {
      tree[id].children.push_back(right);
      tree[right].parent = id;
      tree[right].sibling = left;
    }
  }
  std::stack<int> s;
  for (int i = 0; i < n; ++i) {
    if (tree[i].parent == -1) {
      std::queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int id = q.front(); q.pop();
        tree[id].depth = (id == i) ? 0 : (tree[tree[id].parent].depth + 1);
        for (int child : tree[id].children)
          q.push(child);
        s.push(id);
      }
      break;
    }
  }
  int id;
  while (!s.empty()) {
    id = s.top(); s.pop();
    if (tree[id].children.size() == 0) {
      tree[id].degree = 0;
      tree[id].height = 0;
      tree[id].type = "leaf";
    }
    else if (tree[id].children.size() == 1) {
      tree[id].degree = 1;
      tree[id].height = tree[tree[id].children[0]].height + 1;
      tree[id].type = "internal node";
    }
    else {
      tree[id].degree = 2;
      tree[id].height = std::max(tree[tree[id].children[0]].height,
                                 tree[tree[id].children[1]].height) + 1;
      tree[id].type = "internal node";
    }
  }
  tree[id].type = "root";
  for (int i = 0; i < n; ++i)
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, tree[i].parent, tree[i].sibling, tree[i].degree, tree[i].depth, tree[i].height, tree[i].type.c_str());
  return 0;
}

Measured memory_bytes: 3256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

# 内部で1-indexedに変えるので入力は0-indexedでよい
# i項目までの和（i含む）
class BitSum:
    def __init__(self, n):
        self.n = n + 3
        self.table = [0] * (self.n + 1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    n,m=MI()
    dlr=[]
    for _ in range(n):
        l,r=MI()
        dlr.append((r-l+1,l,r+1))
    dlr.sort()
    bit=BitSum(m+1)
    i=0
    for k in range(1,m+1):
        while i<n and dlr[i][0]<=k:
            d,l,r=dlr[i]
            bit.add(l,1)
            bit.add(r,-1)
            i+=1
        print(n-i+sum(bit.sum(a) for a in range(k,m+1,k)))

main()

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

typedef long long ll;

int main() {
    ll a,b,c;cin>>a>>b>>c;
    if(4*a*b<(c-a-b)*(c-a-b)&&(c-a-b)>0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long
using namespace std;

ll mod = 1e9 + 7;

vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % mod;
}

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % mod;
    if (pow % 2 == 1) a *= x;
    return a % mod;
}

ll calc_div(ll a, ll b) {
    return a * calc_pow(b, mod - 2) % mod;
}

ll calc_comb(ll n, ll r) {
    if ((n == 0 && r > 0) || n < r)return 0;
    return calc_div(fact[n], fact[r] * fact[n - r] % mod);
}

int main() {
    int n, k;
    cin >> n >> k;

    init_fact(10000);
    for (int i = 1; i <= k; i++) {
        ll place = calc_comb(k - 1, i - 1);
        ll ball = calc_comb(n - k + 1, i);
        cout << place * ball % mod << endl;
    }
    return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
A = [0]*(N+1)
for _ in range(M):
  a, b = map(int, input().split())
  A[a] = (A[a]+1)%2
  A[b] = (A[b]+1)%2
print("YES" if len(list(filter(lambda x:x==1, A))) < 1 else "NO")

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

using namespace std;

using ll = long long;

int main(){

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


Measured memory_bytes: 5108
x, y = map(int, input().split())

a = []

for i in range(x+1):
    kame = 4*i
    turu = 2*(x-i)
    #print(kame, turu)
    a.append(kame+turu)

if y in a:
    print("Yes")
else:
    print("No")


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

int main(void){
    int a[] = {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};
    int k;
    cin >> k;
    cout << a[k-1] << endl;    
    return 0;
}


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

const int MAX = 100000;
int main() {
	int N, a, min = 1, max = 0, num;
	cin >> N >> num;
	for (int i = 1;i < N;i ++) {
		cin >> a;
		if (a == num) min ++;
		else if (a == num + 1) max ++;
		else if (a == num - 1 && max == 0) {
			max = min;
			min = 1;
			num --;
		} else {
			cout << "No";
			return 0;
		}
	}
	if (max) {
		if (max - 1) {
			if (min > num) cout << "No";
			else if (min + max / 2 > num) cout << "Yes";
			else cout << "No";
		} else cout << "No";
	} else if (num == N - 1 || num <= N / 2) cout << "Yes";
	 else cout << "No";
	return 0;
}
// 条件を考えていく。
// 1.猫の宣言できる種類数の差は最大で1 ……(1)
// 2.宣言する数が小さい猫は誰とも色が被ってない
//   →宣言する数が大きい猫は誰かと色が被っている
// 以上より、次の結論が導かれる
// 数字の小さい猫数+数字の大きい猫数/2 >= より多い宣言数 ならばYes
// ※大きい数字を宣言している猫が一匹ならNo
// ※全員が同じ数字を宣言しているならば、宣言がN-1である、或いはN/2以下ならYes
// 
// (1).何匹かいるうち、2匹の猫a,bについてのみ考えてみる
// aとbの色が同じとき…宣言数は同じ
// aの色がbと別の猫と同じ時…
//   bの色が別の猫と同じ時…宣言数は同じ
//   bの色が別の時…宣言数は1違う
// aの色が別の時…
//   bの色が別の猫と同じ時…宣言数は1違う
//   bの色が別の時…宣言数は同じ

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll A, B;
    scanf("%lld %lld", &A, &B);
    if(A%3==0||B%3==0||(A+B)%3==0) printf("Possible\n");
    else printf("Impossible\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
h,n = map(int,input().split())
Mag = []
for i in range(n):
    AB = list(map(int,input().split()))
    Mag.append(AB)
dp = [[float("inf")]*(h+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(h+1):
        dp[i+1][j] = min(dp[i+1][j],dp[i][j])
        dp[i+1][min(j+Mag[i][0],h)] = min(dp[i+1][min(j+Mag[i][0],h)],dp[i+1][j]+Mag[i][1])
        
print(dp[n][h])

Measured memory_bytes: 289928
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool claim[100001]; // true : 両隣同じ

bool kind[100001]; // true : 羊
				   // false : 狼

bool next_animal(bool before, bool animal, bool say) {
	if (animal) {
		if (say) return before;
		else return !before;
	}
	else {
		if (say) return !before;
		else return before;
	}
}

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		char c; cin >> c;
		if (c == 'o') claim[i] = true;
	}

	for (int i = 1; i >=0; i--) {
		for (int j = 1; j >=0; j--) {
			bool flag = true;
			
			kind[0] = i;
			kind[1] = j;
			for (int k = 1; k <= N - 1; k++) kind[k + 1] = next_animal(kind[k - 1], kind[k], claim[k]);

			// チェック
			if (kind[0] != kind[N]) flag = false;
			if (kind[1] != next_animal(kind[N - 1], kind[0], claim[0])) flag = false;

			if (flag) {
				string S;
				for (int i = 0; i < N; i++) {
					if (kind[i]) S.push_back('S');
					else S.push_back('W');
				}
				cout << S << endl;
				return 0;
			}
		}
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <algorithm>

int a[5], b[5], c[5][5];
using namespace std;
int main(){
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			cin>>c[i][j];
	for(int a1 = 0; a1 < 101; a1++)
		for(int a2 = 0; a2 < 101; a2++)
			for(int a3 = 0; a3 < 101; a3++){
        int b1 = c[0][0] - a1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;
 
        a[0] = a1;
        a[1] = a2;
        a[2] = a3;
        b[0] = b1;
        b[1] = b2;
        b[2] = b3;
 
        bool flag = true;
    	for(int i = 0; i < 3; i++)    	
			for(int j = 0; j < 3; j++)
				if (a[i] + b[j] != c[i][j])
					flag = false;
        if (flag) {
            printf("Yes\n");
            return 0;
        }
    }
 
    printf("No\n");
    return 0;
}
	

Measured memory_bytes: 256
'''
def main():
    N, D = map(int, input().split(" "))
    xy = []
    for i in range(N):
        xy.append(list(map(int, input().split(" "))))
    D2 = D **2
    cnt = 0
    for i in range(N):
        if xy[i][0] **2 + xy[i][1] **2 > D2:
            continue
        cnt += 1
    print(cnt)
'''
#if,contiueの使い方による実行時間の比較用
def main():
    N, D = map(int, input().split(" "))
    xy = []
    for i in range(N):
        xy.append(list(map(int, input().split(" "))))
    D2 = D **2
    cnt = 0
    for i in range(N):
        if xy[i][0] **2 + xy[i][1] **2 <= D2:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N,K; cin >> N >> K;
    vector<int> A(N);
    REP(i,N){
        cin >> A[i];
    }

    FORq(i,K,N-1){
        int now = A[i];
        int prev = A[i - K];
        if (now > prev) puts("Yes");
        else puts("No");
    }
}

Measured memory_bytes: 4044