akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    vi x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    bool par = (x[0] ^ y[0])&1;
    for (int i = 1; i < N; i++) {
        if (((x[i] ^ y[i])&1) != par) {
            cout << -1 << endl;
            return 0;
        }
    }

    vi arms;
    for (int p2 = 30; p2 >= 0; p2--) {
        arms.push_back(1 << p2);
    }
    if (!par) {
        arms.push_back(1);
    }

    cout << arms.size() << "\n";
    for (int v : arms)
        cout << v << " ";
    cout << "\n";

    string dirs = "LRDU";
    vi dx = { -1, 1, 0, 0 };
    vi dy = { 0, 0, -1, 1 };

    for (int i = 0; i < N; i++) {
        ll cx = 0, cy = 0;

        for (int v : arms) {
            int bst = -1;
            ll bdist = LLONG_MAX;

            for (int d = 0; d < 4; d++) {
                ll dist = abs(cx + dx[d] * v - x[i]) + abs(cy + dy[d] * v - y[i]);
                if (dist < bdist) {
                    bdist = dist;
                    bst = d;
                }
            }

            cout << dirs[bst];
            cx += dx[bst] * v;
            cy += dy[bst] * v;
        }
        cout << "\n";

        assert(cx == x[i]);
        assert(cy == y[i]);
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  vector<int >p;
  p.push_back(a+b);
  p.push_back(a+c);
  p.push_back(c+b);
  sort(p.begin(),p.end());
       cout<<p[0];
       return 0;
       }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	char x;
	cin>>a>>x>>b;
	if(x=='+')
	{
		c=a+b;
		printf("%d",c);
	}
	if(x=='-')
	{
		c=a-b;
		printf("%d",c);
	}
    return 0;
}

Measured memory_bytes: 256
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n=getint()
a=getints()
b=list(sorted(a))

cnt = 0
for i in range(n):
    if a[i] != b[i]:
        cnt += 1


print("YES" if cnt <= 2 else "NO")


Measured memory_bytes: 3060
word = input()
words = {}
while True:
    input_line = input()
    if input_line == "END_OF_TEXT":
        break
    for w in input_line.split():
        tmp = words.setdefault(w.lower(), 0)
        words[w.lower()] = tmp + 1
if word in words.keys():
    print(words[word])
else:
    print("0")


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


using namespace std;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

class UnionFindTree{
private:
  // indexの数の親ノード(ある集合の親を見つけたいときはここを直接参照せず、findを使う)
  vector<int> par;
  // indexを根とする木のランク
  vector<int> rank;
  // 集合のサイズ
  vector<int> cnts;
  // 木の最大値
  int treeSize;
public:
  UnionFindTree(int initTreeSize = 1000){
    // 引数で与えられた値を最大格納数とするUnionFindTreeの作成
    treeSize = initTreeSize;
    init(initTreeSize);
  }
  void init(int sz){
    par.clear(),rank.clear(),cnts.clear();
    treeSize=sz;
    for(int i = 0; i < sz; i++){
      par.push_back(i);
      rank.push_back(0);
      cnts.push_back(1);
    }
  }
  // 与えられた数が格納されている木のルートを探索
  int find(int x){  
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
  }
  // 和集合をとる。ただしここでは各集合の親の付け替えは起こらない
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      par[x] = y;
      cnts[y]+=cnts[x];
    }
    else{
      par[y] = x;
      cnts[x]+=cnts[y];
      if(rank[y] == rank[x])rank[x]++;
    }
  }
  // xの属する集合のサイズ
  int getCnt(int x){
    return cnts[find(x)];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
    
};


int N;

const string v = "Vacant";
const string m = "Male";
const string f = "Female";

string strs[100010];

int main(){

    cin >> N;

    int from = 0;
    int to   = N - 1;

    cout << 0 << endl;
    cout<<flush;
    cin >> strs[0];
    if(strs[0] == v) return 0;
    strs[N] = strs[0];
    to = N;

    int cnt = 20 - 1;
    
    while(to - from >= 2){
        int c = (to + from) / 2;
        cout << c << endl;
        cout<<flush;
        cin >> strs[c];
        if(strs[c] == v) return 0;
        
        cnt--;
        assert(cnt > 0);

        if(((c-from) % 2) ^ (strs[from] == strs[c])){
            from = c;
        }
        else{
            to = c;
        }
    }

    // assert(0);

    return 0;
}


Measured memory_bytes: 1620
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.09.07 16:27:38
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 1000000010;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

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

vector<P> vec;
int n, a[100010], dp[100010];

int main() {
    scanf("%d", &n);
    rrep(i, n) scanf("%d", &a[i]);

    rep(i, n) {
        dp[i] = INF;
    }
    rep(i, n) {
        auto ite = upper_bound(dp, dp + n, a[i]);
        *ite = a[i];
        // printf("ite: %d\n", ite - dp);
    }

    int ret = lower_bound(dp, dp + n, INF) - dp;
    printf("%d\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

ll modPow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n-1, p)) % p;
  ll t = modPow(a, n/2, p);
  return (t * t) % p;
}

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

  ll n, k;
  cin >> n >> k;
  vector<ll> rec(k);
  for (int i = k; i > 0; i--) {
    ll cnt = modPow(k / i, n, MOD);
    //cout << cnt << endl;
    for (int j = i*2; j <= k; j+=i) {
      cnt -= rec[j-1];
    }
    cnt = (cnt + 10000LL*MOD) % MOD;
    rec[i-1] = cnt;
  }
  ll ans = 0;
  for (int i = 0; i < k; i++) {
    //cout << rec[i] << " ";
    ans += (i+1) * rec[i];
    ans %= MOD;
  }
  cout << ans << endl;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

ll gcd(ll a, ll b);

ll sum(int n);

void go(){
   int n;cin>>n;
   vector<int> nums(n);
   for(int i=0;i<n;i++){
      cin>>nums[i];
   }
   
   int l=0,r=n-1;
   int cnt=0;
   for(int i=0;i<n-1;i++){
      if(nums[i]!=i+1){
         cnt++;
      }
   }
   string ans=cnt<=2?"YES":"NO";
   cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

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

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
N,K = map(int,input().split())
LR = []
mod = 998244353
for i in range(K):
    L,R = map(int,input().split())
    LR.append((L,R))
dp = [0]*(3*N)
for L,R in LR:
    dp[L] += 1
    dp[L] %= mod
    dp[R+1] -= 1
    dp[R+1] %= mod
for i in range(1,N-1):
    for L,R in LR:
        dp[i+L] += dp[i]
        dp[i+L] %= mod
        dp[i+R+1] -= dp[i]
        dp[i+R+1] %= mod
    dp[i+1] += dp[i]
    dp[i+1] %= mod
print(dp[N-1])

Measured memory_bytes: 72716
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> v(m);
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int s;
            cin>>s;
            v[i].push_back(s);
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;i++) cin>>p[i];
    //bit全探索
    int ans=0,cnt=0,on=0;
    for(int bit=0;bit<(1<<n);bit++){
        cnt=0;
        for(int i=0;i<m;i++){
            on=0;
            for(int j=0;j<v[i].size();j++){
                if(bit & (1<<(v[i][j]-1))) on++;
            }
            if(on%2==p[i]) cnt++;
        }
        if(cnt==m) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  long ans = 0;
  for(int i=1; i<=N; i++){
    if(!(i%3 == 0 || i%5 == 0)){
      ans+=i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string k;
ll d,mod=1e9+7,dp[10005][105][2][2];
ll gao(int x,int y,int z,int t){
    if(x==k.size())return (y==0 and z==1);
    ll &ans=dp[x][y][z][t],b=t?k[x]-'0':9;
    if(ans!=-1)return ans;
    ans=0;
    for(int i=0;i<=b;i++)
        ans+=gao(x+1,(y+i)%d,z or i!=0,(t and i==b)?1:0)%mod;
    return ans%=mod;
}
int main(){
	cin >> k >> d;
	memset(dp,-1,sizeof(dp));
	cout << gao(0,0,0,1);
    return 0;
}

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

int main() {

	char a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a == b && b==c) {
		cout << "Yes" << endl;
	}
	else if (b == c && c == d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  int a[7] = {1,3,5,7,8,10,12};
  int b[4] = {4,6,9,11};
  int c[1] = {2};
  int x, y;
  cin >> x >> y;
  
  int ga=100, gb=101, gc=102;
  
	for(int  i=0; i<7; i++){
		if(x == a[i]) x=ga;
		if(y == a[i]) y=ga;
    }
  
  for(int  i=0; i<4; i++){
		if(x == b[i]) x=gb;
		if(y == b[i]) y=gb;
    }
  if(x == 2) x=gc;
  if(y == 2) y=gc;
  
  if(x == y) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

f n = mod (div n 10) 111 == 0 || mod (mod n 1000) 111 == 0

main = cond "Yes" "No" . f <$> getInt >>= putStrLn

Measured memory_bytes: 508
#include <stdio.h>
#include <math.h>

int n;
int cnt[10][10];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x = i;
        while (x >= 10) x /= 10;
        cnt[x][i % 10]++;
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        int x = i;
        while (x >= 10) x /= 10;
        ans += 1ll * cnt[i % 10][x];
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> d(N, 0);

	for (int i = 0; i < d.size(); i++) {
		cin >> d[i];
	}

	unsigned long long ans = 0;
	for (int i = 0; i < (d.size() - 1); i++) {
		for (int j = (i + 1); j < d.size(); j++) {
			ans += d[i] * d[j];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
a1 = list(map(str,input().split()))
a2 = list(map(str,input().split()))
a3 = list(map(str,input().split()))
M=int(input())
N = "N"
if M <= 2:
    print('No')
    sys.exit()

Num=[] #appendのために宣言が必要
while True:
    try:
        Num.append(input())

    except:
        break;

A1= ["N" if Num.count(i)!=0 else i for i in a1]
A2= ["N" if Num.count(i)!=0 else i for i in a2]
A3= ["N" if Num.count(i)!=0 else i for i in a3]

if A1[0] == N and A1[1] == N and A1[2] == N :
    print("Yes")
elif A2[0] == N and A2[1] == N and A2[2] == N :
    print("Yes")
elif A3[0] == N and A3[1] == N and A3[2] == N :
    print("Yes")
elif A1[0] == N and A2[0] == N and A3[0] == N :
    print("Yes")
elif A1[1] == N and A2[1] == N and A3[2] == N :
    print("Yes")
elif A1[2] == N and A2[2] == N and A3[2] == N :
    print("Yes")
elif A1[0] == N and A2[1] == N and A3[2] == N :
    print("Yes")
elif A1[2] == N and A2[1] == N and A3[0] == N :
    print("Yes")
else:
    print("No")




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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  int A,B;
  cin >> A >> B;

  cout << A*B << endl;
  return 0;
}

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

using ll = long long;

class Kruskal {
    class Edge {
        public:
        int u, v, w;
        Edge(int source, int target, int cost) {
            u = source;
            v = target;
            w = cost;
        }
        bool operator<(const Edge &e) const { return w < e.w; }
    };

    class UnionFind {
        public:
        vector<int> rank, parent, size;

        UnionFind();
        UnionFind(int n) {
            rank.resize(n, 0);
            parent.resize(n, 0);
            size.resize(n, 0);
            for (int i = 0; i < n; ++i) {
                parent[i] = i;
                rank[i] = 0;
                size[i] = 1;
            }
        }

        int getSize(int x) { return size[root(x)]; }

        bool same(int x, int y) { return root(x) == root(y); }

        void unite(int x, int y) {
            int a = root(x), b = root(y);
            if (rank[a] < rank[b]) swap(a, b);
            parent[b] = a;
            if (rank[a] == rank[b]) ++rank[a];
            size[a] += size[b];
        }

        int root(int x) {
            if (parent[x] != x) {
                parent[x] = root(parent[x]);
            }
            return parent[x];
        }
    };

    private:
    int size;
    vector<Edge> edges;

    public:
    int total_cost;
    vector<Edge> mst;

    Kruskal(int n) {
        total_cost = 0;
        size = n;
    }

    void add_edge(int u, int v, int w) {
        Edge e(u, v, w);
        edges.push_back(e);
    }

    void set_mst() {
        UnionFind uf(size);

        sort(edges.begin(), edges.end());
        for (Edge e : edges) {
            if (!uf.same(e.u, e.v)) {
                total_cost += e.w;
                mst.push_back(e);
                uf.unite(e.u, e.v);
            }
        }
    }
};

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

    int V, E;
    cin >> V >> E;

    Kruskal krskl(V);

    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        krskl.add_edge(s, t, w);
        krskl.add_edge(t, s, w);
    }

    krskl.set_mst();
    cout << krskl.total_cost << endl;
    
    return 0;
}


Measured memory_bytes: 5896
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
map<ll,int> ct;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    ll ans=0,x,m,s[n+1];
    cin>>m;
    s[0]=0;
    ct[0]=1;
    for (int i=1;i<=n;i++) {
        cin>>x;
        s[i] = (s[i-1]+x)%m;
        ans += ct[s[i]];
        ct[s[i]]++;
    }
    cout<<ans;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

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

using namespace std;

const int inf=1<<28;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

string board[55];
string tmp[10][55];
bool sw[1024][55][55];

int dist[55][55][2][1024];

int main(void){
	int w,h;
	cin >> w >> h;
	rep(i,h) cin >> board[i];

	int s;
	cin >> s;
	rep(idx,s)rep(i,h) cin >> tmp[idx][i];


	rep(mask,1<<s){
		rep(i,h)rep(j,w) sw[mask][i][j]=false;
		rep(idx,s) if(mask&bit(idx)) rep(i,h)rep(j,w) if(tmp[idx][i][j]=='*') sw[mask][i][j]^=true;
	}

	rep(i,h)rep(j,w)rep(d,2)rep(mask,1<<s) dist[i][j][d][mask]=inf;
	
	using state=tuple<int,int,int,int>;
	int si=-1,sj=-1;
	rep(i,h)rep(j,w) if(board[i][j]=='%') si=i,sj=j;

	dist[si][sj][0][0]=0;
	queue<state> q;
	q.push(state(si,sj,0,0));

	while(!q.empty()){
		int ci,cj,cd,cmask;
		tie(ci,cj,cd,cmask)=q.front();q.pop();
		//cout << ci << " " << cj << " " << cd << " " << cmask << endl;
		rep(d,4){
			const int ni=ci+dy[d],nj=cj+dx[d],nd=cd,nmask=cmask;
			if(board[ni][nj]=='#') continue;
			
			int tar=-1;
			if(board[ni][nj]=='_'||islower(board[ni][nj])||board[ni][nj]=='%'||board[ni][nj]=='&') tar=1;
			if(board[ni][nj]=='^'||isupper(board[ni][nj])) tar=2;
			if(tar!=-1) tar^=(3*sw[nmask][ni][nj]);
			if(board[ni][nj]=='|') tar=3;
			
			if((tar&bit(nd))==0) continue;
			if(chmin(dist[ni][nj][nd][nmask],dist[ci][cj][cd][cmask]+1))
				q.push(state(ni,nj,nd,nmask));
		}

		if(board[ci][cj]=='|'){
			const int ni=ci,nj=cj,nd=cd^1,nmask=cmask;
			if(chmin(dist[ni][nj][nd][nmask],dist[ci][cj][cd][cmask]+1))
				q.push(state(ni,nj,nd,nmask));
		}

		if(isalpha(board[ci][cj])){
			int idx=tolower(board[ci][cj])-'a';
			const int ni=ci,nj=cj;
			const int nmask=cmask^bit(idx);
			const int nd=cd^(sw[cmask][ni][nj]^sw[nmask][ni][nj]);
			if(chmin(dist[ni][nj][nd][nmask],dist[ci][cj][cd][cmask]+1))
				q.push(state(ni,nj,nd,nmask));
		}
	}

	int gi=-1,gj=-1;
	rep(i,h)rep(j,w) if(board[i][j]=='&') gi=i,gj=j;
	int ans=inf;
	rep(d,2)rep(mask,1<<s) chmin(ans,dist[gi][gj][d][mask]);
	if(ans==inf) ans=-1;
	cout << ans << endl;

	return 0;
}

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

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

    if (x == 1 || x == 2 * N - 1)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    int t = 1;
    for (int i = 0; i < N - 2; i++)
    {
        if (t == x - 1 || t == x || t == x + 1)
            t = x + 2;
        cout << t << endl;
        t++;
    }
    cout << x - 1 << endl;
    cout << x << endl;
    cout << x + 1 << endl;
    for (int i = 0; i < N - 2; i++)
    {
        if (t == x - 1 || t == x || t == x + 1)
            t = x + 2;
        cout << t << endl;
        t++;
    }
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<cstdlib>

using namespace std;

int main(void){
    int a[6];
    int change = 0;

    for(int i=0;i<6;i++){
        cin >> a[i];
        }

    for(int i=0;i<5;i++){
       if(a[5] < abs(a[0] - a[i])){
        change = 1;
        cout << ":(" << endl;
        break;
        }
        }

    if(change == 0){
        cout << "Yay!" << endl;
        }
return 0;

        }


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

void rotate( int* a )
{
    int x = a[7];
    for( int i = 6; i >= 0; i-- )
        a[i+1] = a[i];
    a[0] = x;
}

int getPoint( int* a )
{
    int x = 10000000;
    int sum = 0;
    for( int i = 0; i < 8; i++ )
    {
        sum += a[i] * x;
        x /= 10;
    }
    return sum;
}

int getPossibleNumber( int a, int b )
{
    if( a - b < 0 )
        return a;
    else
        return b;
}

int main()
{
    int p[8];

    while( cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7] )
    {
        int c[8] = { 4, 1, 4, 1, 2, 1, 2, 1 };
        int sum[8] = {}, max = 0, min2 = 1000000000;
        int res[8];
        for( int i = 0; i < 8; i++ )
        {
            for( int j = 0; j < 8; j++ )
                sum[i] += getPossibleNumber( p[j], c[j] );
            if( sum[i] > max )
            {
                for( int j = 0; j < 8; j++ )
                    res[j] = c[j];
                max = sum[i];
                min2 = getPoint(c);
            }
            else if( sum[i] == max && getPoint(c) < min2 )
            {
                for( int j = 0; j < 8; j++ )
                    res[j] = c[j];
                min2 = getPoint(c);
            }
            rotate(c);
        }
        for( int i = 0; i < 7; i++ )
            cout << res[i] << " ";
        cout << res[7] << endl;
    }
    return 0;
}


Measured memory_bytes: 3008
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ans = "Yes";
        String[] w = new String[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.next();
            for (int j = 0; j < i; j++) {
                if (w[j].equals(w[i])) ans = "No";
            }
        }
        for (int i = 1; i < n; i++) {
            if (w[i-1].charAt(w[i-1].length()-1) != w[i].charAt(0)) ans = "No";
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
int N,A,B,C;
 
int main(){
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for(int i=0;i<N;i++)cin >> l[i];
  int ans=200000000;
  sort(l.begin(),l.end());
  do{
    for(int i=0;i<N-2;i++){
      int q=0; int t=0;
      for(int j=0;j<=i;j++){q+=l[j]; if(j!=0)t+=10;}
      for(int j=i+1;j<N-1;j++){
        int w=0; int y=t;
        for(int k=i+1;k<=j;k++){w+=l[k]; if(k!=i+1)y+=10;}
        for(int k=j+1;k<N;k++){
          int e=0; int u=y;
          for(int m=j+1;m<=k;m++){e+=l[m]; if(m!=j+1)u+=10;}
          int s=abs(q-A)+abs(w-B)+abs(e-C)+u;
          ans=min(ans,s);
        }
      }
    }
  }while(next_permutation(l.begin(),l.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>

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

bool isKaibun(int n) {
  string s = to_string(n);
  string t = s;
  reverse(s.begin(), s.end());
  return (s == t);
}

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

  int a, b;
  cin >> a >> b;

  int res = 0;
  for (int i = a; i <= b; ++i) {
    if (isKaibun(i)) ++res;
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3744
#include <stdio.h>

int main(void){
	int yoyu = 1;
	int last, n, in;
	scanf("%d", &n);
	scanf("%d", &last);
	for(int i = 0; i < n - 1; i++){
		scanf("%d", &in);
		if(last < in){
			yoyu = 1;
			last = in;
		}else if(last - 1 == in && yoyu){
			yoyu = 0;
			last = in;
		}else if(last - 1 == in){
			printf("No\n");
			return 0;
		}else if(last - 1 > in){
			printf("No\n");
			return 0;
		}else
			last = in;
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 18;
const int P = 998244353;
const int inv2 = (P + 1) / 2;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
void FWT(int *a, int N) {
	for (int len = 2; len <= N; len <<= 1)
	for (int i = 0; i < N; i += len)
	for (int j = i, k = i + len / 2; k < i + len; j++, k++) {
		int tmp = (a[j] + a[k]) % P, tnp = (a[j] - a[k] + P) % P;
		a[j] = tmp, a[k] = tnp;
	}
}
void UFWT(int *a, int N) {
	for (int len = 2; len <= N; len <<= 1)
	for (int i = 0; i < N; i += len)
	for (int j = i, k = i + len / 2; k < i + len; j++, k++) {
		int tmp = (a[j] + a[k]) % P, tnp = (a[j] - a[k] + P) % P;
		a[j] = 1ll * tmp * inv2 % P, a[k] = 1ll * tnp * inv2 % P;
	}
}
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int n, goal, p[MAXN], q[MAXN], res[MAXN];
int main() {
	read(n), goal = 1 << n;
	int sum = 0;
	for (int i = 0; i < goal; i++)
		read(p[i]), sum += p[i];
	sum = power(sum, P - 2);
	for (int i = 0; i < goal; i++) {
		p[i] = 1ll * p[i] * sum % P;
		q[i] = P - 1;
	}
	p[0] -= 1;
	q[0] = goal - 1;
	FWT(p, goal);
	FWT(q, goal);
	for (int i = 1; i < goal; i++)
		res[i] = 1ll * q[i] * power(p[i], P - 2) % P;
	UFWT(res, goal);
	for (int i = 0; i < goal; i++)
		writeln((res[i] - res[0] + P) % P);
	return 0;
}

Measured memory_bytes: 5888
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
    int x=0,f=1;char ch=gc();
    for (;ch<'0'||ch>'9';ch=gc())   if (ch=='-')    f=-1;
    for (;ch>='0'&&ch<='9';ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}
inline int read(){
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar())  if (ch=='-')    f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar())    x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}
inline void print(int x){
    if (x<0)    putchar('-'),x=-x;
    if (x>9)    print(x/10);
    putchar(x%10+'0');
}
const int N=2e5;
int pre[(N<<1)+10],now[N+10],child[(N<<1)+10],val[(N<<1)+10];
int size[N+10],Msize[N+10];
int n,tot,rize,root;
ll Ans;
void join(int x,int y,int z){pre[++tot]=now[x],now[x]=tot,child[tot]=y,val[tot]=z;}
void insert(int x,int y,int z){join(x,y,z),join(y,x,z);}
void dfs(int x,int fa,int v){
    int Max=0; size[x]=1;
    for (int p=now[x],son=child[p];p;p=pre[p],son=child[p]){
        if (son==fa)    continue;
        dfs(son,x,val[p]),size[x]+=size[son];
        Max=max(Max,size[son]);
    }
    Ans+=1ll*min(size[x],n-size[x])*v*2;
    Max=max(Max,n-size[x]);
    Msize[x]=Max;
    if (Max<rize){
        rize=Max;
        root=x;
    }
}
int main(){
    n=read(),rize=inf;
    for (int i=1;i<n;i++){
        int x=read(),y=read(),z=read();
        insert(x,y,z);
    }
    dfs(1,0,0);
    int tmp=inf;
    for (int p=now[root],son=child[p];p;p=pre[p],son=child[p]){
        tmp=min(tmp,val[p]);
        if (Msize[root]==Msize[son]){
            Ans-=val[p];
            printf("%lld\n",Ans);
            return 0;
        }
    }
    printf("%lld\n",Ans-tmp);
    return 0;
}


Measured memory_bytes: 12416
S = list(input())

s = 0
cl = 0
cc = S[0]
ccc = 0

def kaidan(k):
    return k * (k + 1) / 2

for i in range(len(S)):
    if S[i] == cc:
        ccc += 1
    else:
        if cc == '<':
            s += kaidan(ccc) + cl * ccc
            cl = ccc
        else:
            s += kaidan(ccc) - min(cl, ccc)
            cl = 0
        cc = S[i]
        ccc = 1

if cc == '<':
    s += kaidan(ccc) + cl * ccc
else:
    s += kaidan(ccc) - cl

print(int(s))


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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	cin >> n;
	int p = 0;
	for(int i=0; i< n; i++){
		string s; int m;
		cin >> s >> m;
		if(s == "(") p += m;
		else p -= m;
		if(p < 0){cout << "NO" << endl; return 0;}
	}
	if(p == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define int long long
using namespace std;

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

  set<int> st;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    st.insert(a);
  }

  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 7720
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q, r;
    cin >> p >> q >> r;
    int ans = p + q + r - max({p,q,r});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var A = int.Parse(ReadLine());
        if (N % 500 <= A) WriteLine("Yes");
        else WriteLine("No");
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)

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

	char S[11],T[11];
	cin >> S >> T;
	char* p = S;
	char* q = T;
	while (*p != '\0') {
		if (*p != *q) {
			cout << "No" << endl;
			return(0);
		}
		p++;
		q++;
	}
	if (*q == '\0') {
		cout << "No" << endl;
		return(0);
	}
	q++;
	if (*q != '\0') {
		cout << "No" << endl;
		return(0);
	}

	cout << "Yes" << endl;
	return(0);
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define mx 100005
#define ll long long
long long a[mx],dp[mx+100];
int n,k;
void memo(int i,int n,int k)
{
    if(i==n) return;
    for(int m=1;m<=k;m++)
    {
        dp[i+m] =min(dp[i+m],dp[i]+abs(a[i+m]-a[i]));
    }
    memo(i+1,n,k);
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
   for(int i=0;i<mx+k;i++)
      dp[i] = INT_MAX;
    dp[0] = 0;
    memo(0,n,k);
    cout<<dp[n-1]<<endl;
    return 0;

}


Measured memory_bytes: 1792
def main():
    n = int(input())
    a = list(map(int, input().split()))

    ans = []
    for i in range(n):
        ans.append(0)
    for x in a:
        ans[x-1] += 1

    for x in ans:
        print(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32192
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
	int key;
	Node *prev;
	Node *next;
};

struct Node *nil;
void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil-> prev = nil; 
}

void insert (int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node* listSearch(int key){
	struct Node *cur;
	cur = nil->next;
	while (cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t){
	if (t == nil){
		return;
	}
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

void printList(){
	Node *list = nil->next;
	int printSpace = 0;
	while(true){
		if(list == nil){
			break;
		}
		if(printSpace != 0){
			printf(" ");
		}
		printSpace++;
		printf("%d", list->key);
		list = list->next;
	}
	printf("\n");
}

int main(){
	int key, num, i;
	char command[15];
	scanf("%d", &num);
	init();
	for(i=0;i<num;i++){
		scanf("%s%d", command, &key);
		if(strcmp(command, "insert") == 0){
			insert(key);
		}else if(strcmp(command, "delete") == 0){
			deleteKey(key);
		}else if(strcmp(command, "deleteFirst") == 0){
			deleteFirst();
		}else if(strcmp(command, "deleteLast") == 0){
			deleteLast();
		}
	}
	printList();
	
	return 0;
}



Measured memory_bytes: 33832
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(kbrni,n)cout<<" "<<a[kbrni];cout<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define svecp(v) cout<<#v<<":";each(kbrni,v)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;
typedef pair<int,ll> pil;

const int MAX_N = 100005;

class segtree {
private:
    int n,sz;
    vector<int> cnt;
    vector<ll> sum;
public:
    segtree(){
        sz = 100001;
        n = 1;
        while(n < sz){
            n *= 2;
        }
        cnt.resize(2*n-1,0);
        sum.resize(2*n-1,0);
    }
    void add(int k)
    {
    	k += n-1;
        cnt[k]++;
        sum[k]+=k-n+1;
    	while(k>0){
    		k = (k-1)/2;
            cnt[k] = cnt[2*k+1]+cnt[2*k+2];
    		sum[k] = sum[2*k+1]+sum[2*k+2];
    	}
    }
    int query(int c,int d,ll e,int k=0,int l=0,int r=-1)
    {
        if(r < 0) r = n;
    	if(r - l == 1){
            if(k-n+1 == c){
                if((ll)c*d >= e){
                    return d+cnt[k];
                }else{
                    return d;
                }
            }else{
                return d+(int)min((ll)cnt[k],((ll)c*d-e)/(k-n+1-c));
            }
    	}else{
            // show((l+r)/2);
    		int x = d+cnt[2*k+1];
            ll y = e+sum[2*k+1];
            // cout << x << " " << y << "\n";
            if(y <= (ll)x*c){
                return query(c,x,y,2*k+2,(l+r)/2,r);
            }else{
                return query(c,d,e,2*k+1,l,(l+r)/2);
            }
    	}
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> vec(n);
    rep(i,n){
        cin >> vec[i].se >> vec[i].fi;
    }
    sort(all(vec),greater<P>());
    segtree sg;
    int mx = 0;
    rep(i,n){
        sg.add(vec[i].se);
        // cout << sg.query(vec[i].fi,0,0LL) << "\n";
        cmx(mx,sg.query(vec[i].fi,0,0LL));
    }
    cout << mx << "\n";
    return 0;
}



Measured memory_bytes: 8396
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n, i, *a, count, ans = 0;
    cin >> n;
    a = new ll[n];
    for (i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    map<ll, ll> mp;
    for (i = 1, count = 1; i < n; i++)
    {
        if (a[i] == a[i - 1])
            count++;
        else
        {
            mp.insert(make_pair(a[i - 1], count));
            count = 1;
        }
    }
    mp.insert(make_pair(a[n - 1], count));
    // for (auto it = mp.begin(); it != mp.end(); it++)
    //     cout << it->first << " " << it->second << endl;
    for (auto it1 = mp.begin(); it1 != mp.end(); it1++)
        for (auto it2 = next(it1, 1); it2 != mp.end(); it2++)
            for (auto it3 = next(it2, 1); it3 != mp.end(); it3++)
            {
                if (it3->first >= it1->first + it2->first)
                    break;
                ans += it1->second * it2->second * it3->second;
            }
    cout << ans << endl;
}

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

using namespace std;

vector<int> V;

void solve(){
  sort(V.begin(),V.end());

  int pos = 0;
  while(pos < V.size()){
    int start = pos;
    while(V[pos]+1 == V[pos+1] && pos < V.size()-1) pos++;
    if(start != 0) cout << " ";
    if(pos-start == 0) cout << V[pos++];
    else cout << V[start] << "-" << V[pos++];
  }
  cout << endl;
}

int main(){
  int n;
  while(cin >> n && n){
    V.clear();
    while(n--){
      int in;
      cin >> in;
      V.push_back(in);
    }
    solve();
  }
  return 0;
}

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

int main(){
        string str;
        cin>>str;
        int sum=0;
        for(int i=0;i<str.size();i++){
            sum+=str[i]-'0';
        }
        printf("%s",sum%9?"No":"Yes");
    return 0;
}


Measured memory_bytes: 3848
a,b=input().split()
a=int(a)
b=int(b)
c=[input().split() for i in range(a)]
d=0
for i in range(a):
  if abs((int(c[i][0]))**2+(int(c[i][1])**2))<=b**2:
    d=d+1
print(d)


Measured memory_bytes: 67604
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  
  vector<int> H(N);
  
  for(int i = 0;i < N;++i){
    cin >> H[i];
  }
  
  int num = 0;
  
  if(N == 1){
    cout << "Yes" << endl;
  }
  else{
    for(int i = 0;i < N - 1;++i){
      if(H[i] >= H[i + 1] + 2){
        cout << "No" << endl;
        return 0;
      }
      if(H[i] == H[i + 1] + 1){
        num++;
      }
      
      if(H[i] < H[i + 1]){
        num = 0;
      }
      
      if(num == 2){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  
}



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

int main()
{
    int n;
    cin>>n;
    int a[n];
    int ans =0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if( (i+1)%2==1 && a[i]%2==1   )
            ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;

// strictly-increasing LIS in nlogn
/*
   in case of longest nondecreasing sequences
   change lower_bound to upper_bound
*/
vector<int> a;
int lis(){
   vector<int> v;
   for (int i = 0; i < n; i++) {
       auto it = upper_bound(v.begin(), v.end(), a[i]);
       if (it != v.end()) *it = a[i];
       else v.push_back(a[i]);
   }
   return (int)v.size();
}

int32_t main(){_

   cin>>n;

   a.resize(n);
   
   for(auto &i: a)
      cin >> i;
   
   reverse(a.begin(), a.end());

   cout<<lis();
   

   return 0;
}

Measured memory_bytes: 2168
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'


void solve()
{
 int n,W;
 cin>>n>>W;
  long long int w[n],v[n],dp[n+1][W+1];
  memset(dp, 0, sizeof dp); 
 for (int i = 0; i < n; ++i)
 {
   cin>>w[i]>>v[i];
 }

  for(int i=1;i<=n;i++)
  { 
    for(int j=1;j<=W;j++) 
      { 
        dp[i][j]=dp[i-1][j];
        if(w[i-1]<=j)
        { //if(i==3 && j==3)
            //cout<<dp[i][j]<<dp[i-1][j-w[i-1]]+v[i-1]<<"ssd";
          dp[i][j]=max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
       // cout<<dp[i][j]<<" ";
      }
      //cout<<endl;
 }

  cout<<dp[n][W];

}

int main() 
{ IOS
    
    solve();
  

  return  0;

}

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

typedef long long lint;

int main()
{
	string str;
	lint k;
	lint ans=0;
	lint cnt=0;
	
	cin >> str >> k;
	
	
	for(lint i=0;i<str.size();i++)
	{
		ans=str[i]-'0';
		
		if(ans!=1)break;
		else cnt++;
	}
	
	if(k<=cnt)cout << 1 << endl;
	else cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
n=int(input())
count=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for a in range(n):
    i,j,k,x=map(int,input().split())
    count[i-1][j-1][k-1] += x
for i in range(4):
    for j in range(3):
        for k in count[i][j][:]:
            print(" ",end="")
            print(k,end="")
        print()
    if i<3:
        print("####################")


Measured memory_bytes: 5628
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    var divNum = 1.0
    
    for (i in 1..N) {
        divNum *= i
    }

    val pos = Array<Pair<Double, Double>>(N) { Pair(0.0, 0.0) }
    
    for (i in 0 until N) {
        val (x, y) = readInputLine().split(" ").map { it.toDouble() }
        pos[i] = Pair(x, y)
    }
    
    val arr = IntArray(N) { it }

    var ans = 0.0

    do {
        var tmp = 0.0
        for (i in 1 until N) {
            tmp += Math.sqrt((pos[arr[i]].first - pos[arr[i - 1]].first) * (pos[arr[i]].first - pos[arr[i - 1]].first)
                             + (pos[arr[i]].second - pos[arr[i - 1]].second) * (pos[arr[i]].second - pos[arr[i - 1]].second))
        }
        tmp /= divNum
        ans += tmp
    } while (nextPermutation(arr))

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun nextPermutation(arr: IntArray): Boolean {
    var i = arr.size - 1
    while (i > 0 && arr[i - 1] >= arr[i]) {
        i--
    }

    if (i <= 0) {
        return false
    }
    
    var j = arr.size - 1
    while (arr[j] <= arr[i - 1]) {
        j--
    }

    var temp = arr[i - 1];
    arr[i - 1] = arr[j];
    arr[j] = temp;
    
    j = arr.size - 1;
    while (i < j) {
        temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
        i++;
        j--;
    }
    
    return true;
}


Measured memory_bytes: 38688
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[1010][20010] = {};

typedef struct {
    ll w;
    ll s;
    ll v;
} P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll w[1010], s[1010], v[1010];
    rep(i,0,N) cin >> w[i] >> s[i] >> v[i];
    vector<P> vp;
    rep(i,0,N) vp.push_back({w[i], s[i], v[i]});
    sort(vp.begin(), vp.end(), [](P p1, P p2){
        return min(p1.s, p2.s - p1.w) > min(p2.s, p1.s - p2.w);
    });
    rep(i,0,N){
        w[i] = vp[i].w;
        s[i] = vp[i].s;
        v[i] = vp[i].v;
    }
    rep(i,0,N){
        rep(j,0,20001){
            if(j <= s[i]){
                dp[i+1][j + w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    ll ans = 0;
    rep(i,0,20001) ans = max(ans, dp[N][i]);
    print(ans);

    

}

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

int main()
{
    int aa, a, b, c, i = 0, m;
    vector<int> box(110); //1<=A<=100より、余りは99通り
    cin >> aa >> b >> c;

    while (true)
    {
        i++;
        a = aa * i;
        m = a % b;
        if (m == c)
        {
            cout << "YES" << endl;
            return 0;
        }
        if (count(box.begin(), box.end(), m))
        {
            cout << "NO" << endl;
            return 0;
        }
        box.push_back(m);
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}


signed main()
{
    hello();
    
    int n;
    cin >> n;
    vector <int> seq(n);
    for (int i = 0; i < n; ++i)
        cin >> seq[i];
    int x = 0;
    for (int i = 0; i < n; ++i)
        x ^= seq[i];
    for (int i = 0; i < n; ++i)
        cout << (x ^ seq[i]) << " ";
    cout << endl;
}

Measured memory_bytes: 4780