akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from itertools import product
from collections import deque

def bfs(maze, s):
  dq = deque()
  count = 0
  dq.append((s[0], s[1], count))
  visited = numpy.zeros(maze.shape, dtype=numpy.int)
  visited[s] = 1
  dxdys = [tuple(map(lambda x:int(x.real), [(0+1j)**(id), (0+1j)**(id+1)])) for id in range(4)]
  while dq:
    x, y, count = dq.popleft()
    for dx, dy in dxdys:
      if x+dx < 0 or y+dy < 0 or maze.shape[0] <= x+dx or maze.shape[1] <= y+dy:
        continue
      if maze[x+dx, y+dy]==1 and visited[x+dx, y+dy]!=1:
        dq.append((x+dx, y+dy, count+1))
        visited[(x+dx, y+dy)] = 1
  return count


def main():
  h, w = map(int, input().strip().split())
  maze = numpy.zeros((h, w), dtype=numpy.int)
  scores = numpy.full((h, w), -1, dtype=numpy.int)
  for ih in range(h):
    maze[ih] = [(0 if c=='#' else 1)for c in input().strip()]
  for sx, sy in product(range(h), range(w)):
    if maze[sx, sy] == 0:
      continue
    scores[sx, sy] = bfs(maze, (sx, sy))
  print(numpy.max([numpy.max(scores), 0]))


if __name__=='__main__':
  main()

Measured memory_bytes: 14256
ans = 0
mod_t = []
for i in range(5):
    t = int(input())
    ans += t
    dif_t = 10 - t % 10
    if dif_t == 10:
      dif_t = 0
    mod_t.append(dif_t)

mod_t.sort()
for i in range(4):
    ans += mod_t[i]
print(ans)


Measured memory_bytes: 2940
def resolve():
  s = input()
  s = s.replace('BC', 'D')
  s = s.replace('B', 'C')

  ans = 0
  count = 0
  for c in s:
    if c == 'C':
      count = 0
      continue
    if c == 'A':
      count += 1
    if c == 'D':
      ans += count

  print(ans)


if __name__ == "__main__":
  resolve()


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+10; 

int main(){
  fast;
  ll x,y;
  cin>>x>>y;
  if(min(x,y)<=max(x,y)-2)
  cout<<"Alice"<<endl;
  else
  cout<<"Brown"<<endl;

  return 0;
}

Measured memory_bytes: 256
<?php
    $n = trim(fgets(STDIN));
    $ret = 0;

    for ($i=1; $i <= $n; $i++) { 
        if (($i % 3) != 0 && ($i % 5) != 0) {
            //echo $i . PHP_EOL;
            $ret = (int)$ret + (int)$i; 
        }
    }

    echo $ret;
    return;
?>

Measured memory_bytes: 16168
#include <iostream>

using namespace std;

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

  int x[102][102] = {0};

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      int dist = 0;
      for (int k = 0; k < d; k++) {
        dist += abs(x[i][k]-x[j][k])*abs(x[i][k]-x[j][k]);
      }
      for (int k = 0; k <= dist; k++) {
        if ( k*k == dist ) {
          ans++;
          break;
        }
        if ( k*k > dist ) {
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll				long long int
#define fast			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
#define vi 			vector<int>
#define vll 			vector<long long int>
#define all(v)			v.begin(),v.end()
const ll MOD = 1e9 + 7;
const ll INF = 10000000000000000;
const ll MAX_N = 1e5 + 7;
using namespace std;
//vector<bool> h(10000001,1);



int main(){
	string s;
	cin >> s;
	int n = (int)s.size();
	n/=2;
	string b="";
	for(int i =0;i<n;i++)
	b+="hi";
	//cout << b << '\n';
	if(b==s)cout << "Yes";
	else cout << "No";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
using ll = long long;
using P = pair<int,int>;

int n,k,m,x,y;
string s,t;
int p[100005];

struct UnionFind {
  vector<int> par;
  UnionFind(int n=0): par(n,-1) {}
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -par[root(x)];}
};

int main() {
  cin >> n >> m;
  rep(i,n) cin >> p[i], p[i]--;
  UnionFind uf(n);
  rep(i,m){
    cin >> x >> y;
    uf.unite(x-1,y-1);
  } 
  int ans=0;
  rep(i,n)if(uf.same(p[i],i)) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define mod 1000000007
#define max(p,q)((p)>(q)?(p):(q))
ll powe(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}


ll n,q;
ll a[212345],b[212345];
ll c[212345];

int main(){
  scanf("%lld",&n);

  for(int i=0;i<n;i++){
    printf("ACL");}
  printf("\n");
  
  
  return 0;
}


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

#define INF 1000000000

struct edge
{
    int to,cup,rev;
};

int H,W;
vector<edge> G[210];
int S = 200,T = 201;
bool used[210];

void add_edge(int from,int to,int cap)
{
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

int DFS(int v,int t,int f)
{
    if(v == t)return f;
    used[v] = 1;
    for(int i = 0; i < G[v].size(); i++)
    {
        edge &e = G[v][i];
        if(!used[e.to] && e.cup > 0)
        {
            int d = DFS(e.to,t,min(f,e.cup));
            if(d > 0)
            {
                e.cup -= d;
                G[e.to][e.rev].cup += d;
                return d;
            }
        }
    }
    return 0;
}

int main()
{
    scanf("%d%d",&H,&W);
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            char c;
            scanf(" %c",&c);
            if(c == '.')continue;
            if(c == 'S')
            {
                add_edge(S,i,INF);
                add_edge(S,100 + j,INF);
            }
            if(c == 'T')
            {
                add_edge(i,T,INF);
                add_edge(100 + j,T,INF);
            }
            add_edge(i,100 + j,1);
            add_edge(100 + j,i,1);
        }
    }
    int ans = 0;
    while(1)
    {
        memset(used,0,sizeof(used));
        int f = DFS(S,T,INF);
        if(f == 0)break;
        ans += f;
    }

    if(ans >= INF)printf("-1\n");
    else printf("%d\n",ans);
    return 0;
}


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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORED(i, s, n) for (int i = (s); i >= (int)(n); i--)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
// gcd : O(logN)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return
#define srting string

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

#define uniq(v) (v).erase(unique(ALL((v))), (v).end());

// area of (0, 0)(a, b)(c, d)
double area(double a, double b, double c, double d){
    return abs(a * d - b * c) / 2.0;
}

const int PREC = 10;
#define coutf(val) cout << fixed << setprecision(PREC) << (val) << endl;

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    make(char, c);

    if (isupper(c)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int a, b;
    cin >> a >> b;
    if( (a == 1 && b == 2) || (a == 2 && b == 1) ){
        cout << 3;
    }
    else if((a == 2 && b == 3) || (a == 3 && b == 2)){
        cout << 1;
    }
    else if((a == 1 && b == 3) || (a == 3 && b == 1)){
        cout << 2;
    }
    return 0;
}

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

int main(){

 int n, value;
 cin>>n>>value;

 if(value > n*4 || value&1 || n*2 > value  ){
   cout<<"No\n";
 }
 else{
   cout<<"Yes\n";
 }

return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sign(int x) { return (x > 0) - (x < 0); }
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T> T sq(T x) { return x * x; }
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int x;
    cin >> x;
    cout << 1 - x << endl;
}

Measured memory_bytes: 3608
# https://atcoder.jp/contests/abc134/tasks/abc134_c

N = int(input())
numlist = []
for _ in range( N ):
    a = int(input())
    numlist.append( a )

numlist2 = sorted(numlist)
first  = numlist2[ -1 ]
second = numlist2[ -2 ]

for i in range( N ):
    n = numlist[ i ]
    if n == first:
        print( second )
    else:
        print( first )


Measured memory_bytes: 14112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int n; cin >> n;
	ll sum = 0;
	rep(i, n + 1) if(i % 5 != 0 && i % 3 != 0) sum += i;
	cout << sum << endl;
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
#define N 1002
int main() {
	char card[N] = "",tmp[N],*p1,*p2="";
	int i,h,m,num,j;
	while (1) {
		tmp[0] = '\0';
		//fgets(tmp, sizeof(tmp), stdin);
		scanf("%s", tmp);
		if (strcmp(tmp,"-")==0 || strcmp(tmp,"-\n")==0) break;
		scanf("%d", &m);

		num = strlen(tmp);
		for (i = 0; i < m; i++) {
			p1 = tmp;
			card[0] = '\0';
			p2 = card;
			scanf("%d", &h);
			strcat(p2, p1+h);
			*(p1+h) = '\0';
			strcat(p2, p1);
			*p1 = '\0';
			strcat(tmp, p2);
		}
		printf("%s\n", p2);
	}
		return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

using mint = modint998244353;

vector<mint> onevec;

struct S{
    ll n;
    mint m;
};
S op(S x, S y){
    return S{
        x.n + y.n,
        x.m * mint(10).pow(y.n) + y.m
    };
}
S e(){ return S{0, 0}; }
struct F{
    bool is_id;
    mint v;
};
S mapping(F f, S x){
    if(f.is_id){
        return x;
    }else{
        return S{
            x.n,
            onevec.at(x.n) * f.v
        };
    }
}
F id(){ return F{true, 1}; }
F composition(F f, F g){
    if(!f.is_id && !g.is_id){
        return f;
    }else if(g.is_id){
        return f;
    }else{
        return g;
    }
}

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

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(n, S{1, 1}));

    onevec.resize(n + 1);
    onevec.at(1) = 1;
    for(ll i = 2; i <= n; ++i){
        onevec.at(i) = 10 * onevec.at(i - 1) + 1;
    }

    REP(i, q){
        ll li, ri, di;
        cin >> li >> ri >> di;
        li--; ri--;
        seg.apply(li, ri + 1, F{false, mint(di)});
        cout << seg.all_prod().m.val() << endl;
    }

    return 0;
}


Measured memory_bytes: 16648
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[Max];
ll n,ans;
void solve(){
	cin>>n;
	VI mo(n+2);
	VI he(n+2);
	rep(i,1,n+2)cin>>mo[i];
	rep(i,1,n+1)cin>>he[i];
	rep(i,1,n+1){
		if(he[i]>=mo[i]){
			he[i]-=mo[i];
			ans+=mo[i];
			if(he[i]>=mo[i+1]){
				ans+=mo[i+1];
				mo[i+1] = 0;
			}else{
				ans+=he[i];
				mo[i+1]-=he[i];
			}
		}else{
			ans+=he[i];
		}
	}
	cout<<ans; 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

int main(){
	int N;
    cin>>N;
    if(N<105)cout<<0;
    if(104<N&&N<135)cout<<1;
    if(134<N&&N<165)cout<<2;
    if(164<N&&N<189)cout<<3;
    if(188<N&&N<195)cout<<4;
    if(194<N)cout<<5;
}


Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)

h,w,n = map(int, input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i],b[i] = map(int, input().split())
    a[i] -= 1; b[i] -= 1
    
## 左上のマスを(0,0)とする
## 正方形の左上のマスを(j,i)とする
sq_i = []
sq_j = []

for x in range(n):
    for k in range(3):
        for l in range(3):
            i = a[x]-k ; j = b[x]-l
            if i<0 or i+3>h or j<0 or j+3>w:
                continue
            d[(j,i)] += 1

ans =[0]*10
for k,v in d.items():
    ans[v] += 1
ans[0] = (h-2)*(w-2)-sum(ans)

for i in range(10):
    print(ans[i])

Measured memory_bytes: 156408
use std::io;

fn main() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n: u32 = n.trim().parse().unwrap();

    let mut ans: u32 = 0;
    for i in 1..n + 1 {
        let s: String = i.to_string();
        if s.len() % 2 == 1 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


D = z()
C = zz()
S = defaultdict(list)
for i in range(D):
    S[i + 1] = zz()
# やらなくていいコンテストはやらないC=0
never_held = []

arr = list(range(26))
resent_contests = []
C, arr = zip(*sorted(zip(C, arr), reverse=False))
i = 0
for _ in range(D):
    if (len(resent_contests) == 26):
        resent_contests = []
    while(arr[i % 26] + 1 in resent_contests):
        i += 1
    resent_contests.append(arr[i % 26]+1)
    print(arr[i % 26]+1)
    i += 1


Measured memory_bytes: 27608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long[] a = new long[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextLong();
		}
		long res = 0;
		int r = 0;
		long sum = 0;
		for(int l=0;l<n;l++) {
			 while(r<n && (sum^a[r])==(sum+a[r])) {
				 sum += a[r++];
			 }
			res += r-l;
			sum -= a[l];
			if(l==r) r++;
		}
		System.out.println(res);
		in.close();
	}

}


Measured memory_bytes: 88052
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
	public static void main (String[] args) throws java.lang.Exception{
		int n=0;
		long sum=1;
		ArrayList<Integer> h = new ArrayList<Integer>();

		Scanner scan = new Scanner(System.in);
		n=scan.nextInt();

		for(int i=0; i<n; i++) h.add(scan.nextInt());

		Collections.sort(h);
		Collections.reverse(h);

		for(int i=0; i<n; i++) sum += (long)Math.max((h.get(i) - i/4), 0);

		System.out.println(sum);
	}
}

Measured memory_bytes: 20872
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))
    
    select = []
    for i in range(1 << n):
        comb = [None] * n
        cnt = 0
        for j in range(n):
            if (i >> j) & 1:
                comb[j] = 1
                cnt += 1
            else:
                comb[j] = 0
        if cnt == k:
            select.append(comb)

    ans = float('inf')
    for s in select:
        tmp_a = list(a)
        tmp_ans = 0
        for i in range(1, n):
            max_height = max(tmp_a[:i])
            if s[i] and max_height >= tmp_a[i]:
                tmp_ans += max_height - tmp_a[i] +1
                tmp_a[i] = max_height + 1
        ans = min(ans, tmp_ans)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68824
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

const int mod = 1000000007;
vector<vector<int>> g;
vector<vector<ll>> dp;

ll rec(int v, int c, int prev){ // c: 0-white, 1-black
    if(dp[v][c] > 0) return dp[v][c];
    
    if(c == 1){
        ll ret = 1;
        for(int nv: g[v]){
            if(nv == prev) continue;
            ret = (ret * rec(nv, 0, v)) % mod;
        }

        return dp[v][c] = ret;
    }

    else{
        ll white = 1;
        ll black = 1;
        for(int nv: g[v]){
            if(nv == prev) continue;
            white = (white * rec(nv, 0, v)) % mod;
            black = (black * rec(nv, 1, v)) % mod;
        }

        return dp[v][c] = (white + black) % mod;
    }
}

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

    int n;
    cin >> n;
    
    g.resize(n);
    for(int i = 0; i < n-1; ++i){
        int a, b;
        cin >> a >> b;
        --a;
        --b;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    dp.resize(n, vector<ll>(2, 0));

    cout << rec(0, 0, -1) << endl; //(rec(0, 0, -1) + rec(0, 1, -1)) % mod << endl;

    return 0;
}

Measured memory_bytes: 22460
#include<iostream>
#include<vector>
#include<algorithm>
#include <complex>
using namespace std;
typedef long long int llint;

int main() {
	int n, m;
	cin >> n >> m;
	int answer = 1;
	for (int i = n;i < m / 2 + 1;i++) {
		if (m%i == 0) {
			answer = m / i;
			break;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int N = 1e5 + 5;
int a[N], l[N], r[N], ans = 0;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		l[i] = __gcd(a[i], l[i-1]);
		r[n-i+1] = __gcd(a[n-i+1], r[n-i+2]);
		// cout << l[i] << " " << r[n-i+1] << "\n";
	}
	for (int i = 1; i <= n; i++) {
		ans = max(__gcd(l[i-1], r[i+1]), ans);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int,string> > vpii;
typedef map<int, int> mii;
const ll N=2*1e5+5;
ll arr[N],A[N]  ;
//bool visited[N]={} , cnt[N]={};
bool f=0;
int main()
{
    int n,ans=0,count(0);
    cin>>n;
    for(int i=105 ; i<=n ; i+=2)
    {
        count=0;
        for(int j=1 ; j<=i ; j+=2)
        {
            if(i%j==0)
            {
                count++;
            }
        }
        if(count==8)
        {
            ans++;
        }
    }
    cout<<ans;
 go;
}


Measured memory_bytes: 256
#include<stdio.h>
long long int gcd(long long int a, long long int b)
{
	long long int r = a % b;
	while (r > 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main()
{
	long long int a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	a--;
	long long int ans = b - a;
	ans -= b / d;
	ans -= b / c;
	ans += a / c;
	ans += a / d;
	long long int g = c * d / gcd(c, d);
	ans += b / g;
	ans -= a / g;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>a(n);
    long long ans = 0, sum = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum += a[i];
        sum %= 1000000007LL;
    }
    
    for(int i=0; i<n-1; i++){
        sum -= a[i];
        if(sum<0) sum += 1000000007LL;
        ans += a[i]*sum;
        ans %= 1000000007LL;
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4824
package main

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

type stack struct {
	data []int
}

func (c *stack) push(v int) {
	c.data = append(c.data, v)
}
func (c *stack) pop(v *int) bool {
	if len(c.data) > 0 {
		*v = c.data[len(c.data)-1]
		c.data = c.data[:len(c.data)-1]
		return true
	}
	return false
}

func main() {
	// var s string
	var stack stack
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	sc.Scan()
	t := strings.Split(sc.Text(), " ")
	for i := 0; i < len(t); i++ {
		var a, b int
		if t[i] == "+" {
			stack.pop(&b)
			stack.pop(&a)
			stack.push(a + b)
		} else if t[i] == "-" {
			stack.pop(&b)
			stack.pop(&a)
			stack.push(a - b)
		} else if t[i] == "*" {
			stack.pop(&b)
			stack.pop(&a)
			stack.push(a * b)
		} else {
			v, _ := strconv.Atoi(t[i])
			stack.push(v)
		}
	}
	var ans int
	stack.pop(&ans)
	fmt.Println(ans)
}



Measured memory_bytes: 1096
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int x,y,n;
	scanf("%d%d%d",&x,&y,&n);
	if (x<y)	swap(x,y);
	if (n%x==0)	printf("%d\n",n/x);
	else printf("%d\n",n/x+1);
	return 0;
}

Measured memory_bytes: 128
def selectionSort(a,n)
  count=0
  n.times{|i|
    minj=i
    (i).upto(n-1){|j|
      minj = j if a[j] < a[minj]
    }
    a[i],a[minj]=a[minj],a[i]
    count+=1 if i!=minj
  }
  puts a.join(" "),count
end

n=gets.to_i;a=gets.split.map(&:to_i)
selectionSort(a,n)



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int k, q; cin >> k >> q;
    
    vi d(k); 
    rep(i, k) {
        cin >> d[i];
    }
    
    while(q--){
        int n, x, m;
        cin >> n >> x >> m;
        vi dm(k);
        ll cnt = 0;
        ll tot = 0;
        rep(i, k){
            dm[i] = d[i] % m;
            if(dm[i] == 0) cnt++;
            tot += dm[i];
        }
        
        // t = a[n-1] を求める
        ll t = tot * ((n-1)/k);
        cnt = cnt * ((n-1)/k);
        
        int r = (n-1) % k;
        rep(i, r){
            t += dm[i];
            if(dm[i] == 0) cnt++;
        }
        // cout << t+x << endl;
        
        ll cnt2 = (t+x)/m - x/m;
        // cout << cnt2 << endl;

        ll res = n - 1 - cnt - cnt2;
        cout << res << endl;
    }
    
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3676
function Main(s){
	s=s.split(/\n/);
	s[0]|=0;
	var a=[],b=[];
	
	for(var i=0;i<s[0];i=(i+1)|0){
		b[s[1][i]]|=0;
		a[s[1][i]]|=0;
		b[s[1][i]]++;
	}
	
	var d=0
	for(var i=0;i<s[0];i=(i+1)|0){
		a[s[1][i]]++;
		b[s[1][i]]--;
		
		var c=0;
		for(var item in a){if(a[item]&&b[item]){c++;}}
		if(d<c){d=c;}
		
	}
	
	console.log(d);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pll pair<ll, ll>
#pragma GCC optimize ("O3")
using namespace std;
ll power (ll a) {
    ll prod=1;
    for (ll i=0;i<a;++i) prod*=10;
    return prod;
}
int main () {
    #ifdef LOCAL
        freopen ("input.txt", "r", stdin);
        freopen ("output.txt", "w", stdout);
        freopen ("error.txt", "w", stderr);
    #else
        ios::sync_with_stdio(false);
        cin.tie (NULL);
    #endif
    ll n; cin>>n;
    ll ans=0, p=1;
    while (power(p-1)<=n) {
        ans+=min(power(p), n+1)-power(p-1);
        p+=2;
    }
    cout<<ans;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
  cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int sumA=0,sumB=0;
  for(int j=0;j<N;j+=2){
    sumA+=A.at(j);
  }
   for(int j=1;j<N;j+=2){
    sumB+=A.at(j);
  }
  cout << sumA-sumB << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string>
using namespace std;
#include<chrono>
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define MIN3(a,b,c)         MIN(a,MIN(b,c))
#define MAX3(a,b,c)         MAX(a,MAX(b,c))
#define MIN4(a,b,c,d)       MIN(a,MIN(b,MIN(c,d)))
#define MAX4(a,b,c,d)       MAX(a,MAX(b,MAX(c,d)))
#define MAX5(a,b,c,d,e)     MAX(MAX3(a,b,c),MAX(d,e))
#define MIN5(a,b,c,d,e)     MIN(MIN3(a,b,c),MIN(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================================================================================

vi g[N];
int vis[N];
int nodes=0;


void iluzn() {
 int l,r,d,ans=0;
 cin>>l>>r>>d;
 int i;
 for(i=l;i<=r;i++)
 {
  if(i%d==0)
    ++ans;
 }
 cout<<ans;
 }

 
 

  
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("out.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) {
      iluzn();
      }
    return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a,int b){
    if(a%b){
        return gcd(b,a%b);
    }
    else{
        return b;
    }
}
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

Measured memory_bytes: 10728
N = int(input())
a = [int(input()) for _ in range(N)]

s = sum(a)
mod = 998244353

dp1 = [0] * (s+1)
dp2 = [0] * (s+1)
dp1[0] = 1
dp2[0] = 1
sum_ = 0


ans = 0
for n in range(N):
    for i in reversed(range(sum_+1)):
        dp1[i] %= mod
        dp2[i] %= mod
        dp1[i+a[n]] += dp1[i]
        dp1[i] <<= 1
        dp2[i+a[n]] += dp2[i]
    #print(dp1,dp2)
    sum_ += a[n]

ans = (3 ** N)%mod
for i in range(s+1):
    if i*2 >= s:
        ans -= dp1[i]*3 + mod*3
        ans %= mod
    if i*2 == s:
        ans += dp2[i]*3
        ans %= mod

print(ans)

Measured memory_bytes: 42460
n=gets.to_i
l=(n-1).times.map{gets.split.map(&:to_i)}
ans=(n-1).times.map{ |i|
  e=l[i][0]+l[i][1]
  (i+1).upto(n-2){ |j|
    cj,sj,fj=l[j]
    x=e%fj>0 ? e+fj-e%fj: e
    e=[x,sj].max
    e+=cj
  }
  e
}
ans << 0
puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int M=3e5+5,mod=1e9+7;
int mmp[8][2]={3,1,5,2,2,2,4,7,3,3,6,1,5,5,3,1},dp[M][8],len,i,j;
char ch[M];
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
int main(){
	scanf("%s",ch);int n = strlen(ch);
	dp[0][0] = 1;
	for(int i=0;ch[i];++i){
		for(int j=0;j<8;++j){
			if(dp[i][j]){
				if(ch[i]!='0') add(dp[i+1][mmp[j][1]],dp[i][j]);
				if(ch[i]!='1') add(dp[i+1][mmp[j][0]],dp[i][j]);
			}
		}
	}
	printf("%d\n",(dp[n][1]+dp[n][2])%mod);
}


Measured memory_bytes: 9856
from collections import deque
N, X, Y = map(int, input().split())
X-=1;Y-=1
d = [[] for _ in range(N)]
for i in range(N):
  if i == 0:
    d[i].append(i+1)
  elif i == N-1:
    d[i].append(i-1)
  else:
    d[i].append(i+1)
    d[i].append(i-1)
  if i == X:
    d[i].append(Y)
  elif i == Y:
    d[i].append(X)
#print(d)
INF = float("inf")
ans = [0 for _ in range(N)]
for i in range(N):
  reach = [INF for _ in range(N)]
  reach[i] = 0
  Q = deque([])
  Q.append(i)
  while Q:
    v = Q.popleft()
    for u in d[v]: #vから行ける地点を調べる。
      if reach[u] != INF:
        continue
      reach[u] = reach[v] + 1
      ans[reach[u]] += 1
      Q.append(u)

for i in range(1,N):
  temp = ans[i]//2
  print(temp)
      

Measured memory_bytes: 53596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

ll gcd(ll n, ll m) {
  if (n > m)
    swap(n, m);
  if (m % n == 0)
    return n;
  else {
    return gcd(n, m % n);
  }
}

int main() {
  ll K;
  cin >> K;

  ll ans = 0;

  FOR(i, 1, K + 1) {
    FOR(j, 1, K + 1) {
      FOR(k, 1, K + 1) { ans += gcd(i, gcd(j, k)); }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
    int num[13] = {0,1,2,1,3,1,3,1,1,3,1,3,1};
    int x,y;
    scanf("%d%d",&x,&y);
    if(num[x] == num[y]) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
        val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
        solve(sc)
    }

    fun solve(sc: java.util.Scanner) {
        val N = sc.nextInt()
        println(if (N >= 3) N / 3 else 0)
    }


Measured memory_bytes: 30996
#include <stdio.h>
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c)!=-1&&a>=1&&a<=100&&b>=1&&b<=100&&c>=1&&c<=100){
		int t;
		if(a<b){t=b;b=a;a=t;}
		if(b<c){t=b;b=c;c=t;}
		if(a<b){t=b;b=a;a=t;}
		printf("%d\n",a-c);
	
	}
} 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
    
    int N;
    vector<int> a(100);
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int sum = accumulate(a.begin(), a.end(), 0);
    vector<int> diff;
    int temp = 0;
    for (int i = 0; i < N; i++) {
        temp += a[i];
        diff.push_back(abs(sum - temp - temp));
    }
    cout << *min_element(diff.begin(), diff.end()) << '\n';

}


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

long long gcd(long long p, long long q) {
	if (p < q) swap(p, q);
	if (p % q == 0) return q;
	else return gcd(p / q, p % q);
}
int keta(long long p, int q) {
	if (p / 10 == 0) return q + 1;
	else return keta(p / 10, q + 1);
}
long long kaijo(int p, int q) {
	if (p == 1) return q;
	else return kaijo(p - 1, p * q);
}

int main() {
	long n, m, ans, GCD;
	cin >> n;
	rep(i, n) {
		if (i == 0) {
			cin >> m;
			ans = m;
		}
		else {
			cin >> m;
			GCD = gcd(m, ans);
			ans *= m / GCD;
		}
	}
	cout << ans << endl;
}

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

int least(int nw,int cost,int mn,vector<vector<int>>&c,vector<bool>psd){
	if(nw==1)return cost;
	else if(cost>=mn)return mn;
	psd.at(nw)=true;
	for(int i=0;i<=9;++i){
		if(psd.at(i))continue;
		mn=min(mn,least(i,cost+c.at(nw).at(i),mn,c,psd));
	}
	return mn;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h,w; cin>>h>>w;
	vector<vector<int>>c(10,vector<int>(10)); for(auto&i:c)for(auto&j:i)cin>>j;
	vector<int>mn(10); for(int i=0;i<10;++i)mn.at(i)=c.at(i).at(1);
	for(int i=0;i<10;++i){
		vector<bool>psd(10,false);
		mn.at(i)=least(i,0,mn.at(i),c,psd);
	}
	int ans=0;
	for(int i=0;i<h*w;++i){
		int a; cin>>a;
		if(a<0)continue;
		ans+=mn.at(a);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A[i];
  sort(A.begin(), A.end());
  vector<bool> fg(A.at(N-1)+10, true);

  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( fg.at(A[i]) ){
      for( int j = 1; j*A[i] <= A.at(N-1); j++ ) fg.at(j*A[i]) = false;
    }else continue;
    if( i < N-1 && A[i] == A[i+1] ) continue;
    ans++;
  }
  cout << ans << endl;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    bool res = true;
    if(t.size() == s.size() + 1){
        for( int i = 0;i<s.size();i++){
            if(s.at(i) != t.at(i)) res = false;
        }
    } else {
        res = false;
    }
    if(res){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t a, b, x;

void solve()
{
    std::cin >> a >> b >> x;

	double_t tan_rad;
	if (2 * x > a * a * b)
	{
		tan_rad = (double_t)(2 * (a * a * b - x)) / (double_t)(a * a * a);
	}
	else
	{
		tan_rad = (double_t)(a * b * b) / (double_t)(2 * x);
	}

	double_t rad = std::atan(tan_rad);
	double_t deg = 180.0 * rad / M_PI;

	std::cout << deg << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 4116
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 1 && s[i] == 'R') {
            cout << "No" << "\n";
            return 0;
        }
        if (i % 2 == 0 && s[i] == 'L') {
            cout << "No" << "\n";
            return 0;
        }
    }

    cout << "Yes" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	deque<int> v;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (i % 2 == 0) {
			v.push_back(a);
		}
		else {
			v.push_front(a);
		}
	}
	if (n % 2 != 0) {
		reverse(v.begin(), v.end());
	}
	for (int i = 0; i < n; ++i) {
		if (i == 0) {
			cout << v[i];
		} else{
			cout << " " << v[i];
		}
	}
	cout << endl;
}


Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
//#include "dkp.h"
#define foreach(it,a)		for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b)			for(int i=(a),_ed=(b);i<_ed;i++)
#define boost				ios_base::sync_with_stdio(0);cin.tie(0);
#define v(T)				vector<T>
#define p(T1, T2)			pair<T1, T2>
#define m(T1, T2)			map<T1, T2>
#define ll					long long int
#define sz(a)				(int) a.size()
#define ms(s, n) 			memset(s, n, sz(s))
#define mp					make_pair
#define pb					push_back
#define ff					first
#define ss					second
#define all(a)				a.begin(), a.end()
#define uni(a)				(a).erase(unique(all(a)), (a).end())
const int inf = 1001001001, mod = (int)1e9+7;
const ll llinf = 1e18;
const double eps = 1e-10, pi = acos(-1.0);
//....................//....................dkp....................//....................//
int ncases = 1;

int main(){
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    int a = Integer.parseInt(data[0]);
    int b = Integer.parseInt(data[1]);
    
    if (a%3 != 0 && b%3 != 0 && (a+b)%3 != 0){
      System.out.println("Impossible");
    } else {
      System.out.println("Possible");
    }
  }
}


Measured memory_bytes: 21460
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

けたごとに見る。
A[i]たちについて、そのけたで1が多ければXのそのけたは0、0が多ければXのそのけたは1

それを集めれば良いが…、K以下という制限がある
その場合は、上のほうのけたを、やむなく1が良かったのに0にする

*/

void main(){
	int n = read.to!int;
	long k = read.to!long;
	long[] as = readln.chomp.split.map!(to!long).array;
	
	long xt; // kを超えているかもしれないが
	int maxi;
	for(int i = 0; (1L<<i) < 2 * k; i ++){
		int cnt;
		foreach(a; as) if((1L<<i) & a) cnt += 1;
		if(cnt * 2 < n) xt += 1L<<i;
		maxi = i;
		debug writeln("i:", i, " cnt:", cnt, " xt:", xt);
	}
	
	long[] xs = [0]; // k以下である候補
	
	foreach_reverse(i; 0 .. maxi + 1){
		if(! ((1L<<i) & xt)) continue;
		if(((1L<<i) ^ xt) <= k) xs ~= (1L<<i) ^ xt;
		else xt ^= (1L<<i);
	}
	debug writeln("xs:", xs);
	
	
	long ans;
	foreach(x; xs){
		long tmpans = 0;
		foreach(a; as) tmpans += x ^ a;
		if(tmpans > ans) ans = tmpans;
		debug writeln("x:", x, " tmpans:", tmpans, " ans:", ans);
	}
	ans.writeln;
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A + B + C >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256