akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace	std;
#define MAX 100005
#define NIL -1

struct Node{ int depth, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u){
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].depth << ", ";
	cout << "depth = " << D[u] << ", ";

	if ( T[u].depth == NIL) cout << "root, ";
	else if ( T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for ( i = 0,c = T[u].l; c != NIL; i++, c = T[c].r){
		if(i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}


int rec(int u,int depth){
	D[u] = depth;
	if(T[u].r != NIL) rec(T[u].r,depth);
	if(T[u].l != NIL) rec(T[u].l,depth+1);
}

int main(){
	int i,j,d,v,c,l,r;
	cin >> n;
	for(i=0;i<n;i++) T[i].depth = T[i].l = T[i].r = NIL;

	for(i=0;i<n;i++){
		cin >> v >> d;
		for(j=0;j<d;j++){
			cin >> c;
			if(j == 0) T[v].l =c;
			else T[l].r = c;
			l = c;
			T[c].depth = v;
		}
	}

	for(i=0;i<n;i++){
		if(T[i].depth == NIL) r =i;
	}

	rec(r,0);
	
	for(i=0;i<n;i++) print(i);

	return 0;
}



Measured memory_bytes: 7768
// C - *3 or /2
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int ans = 0;
	while(N--){
		int a; cin>>a;
		while(a%2 == 0){
			ans++;
			a/=2;
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] count = new int[N];
    int M = scanner.nextInt();
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      count[a]++;
      count[b]++;
    }
    for (int i = 0; i < N; i++) {
      if (count[i] % 2 != 0) {
        System.out.println("NO");
        return;
      }
    }
    System.out.println("YES");
  }
}


Measured memory_bytes: 67072
#include <stdio.h>

int main (int argc,char **argv)
{
	int x,a,b;
	
	scanf("%d%d%d",&x,&a,&b);

	if (a - b >= 0)
	{
		printf("delicious\n");
	}

	else if ((a - b < 0) && (a - b >= -x))
	{
		printf("safe\n");
	}

	else
	{
		printf("dangerous\n");
	}

	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = -1;
    for (int x = 0; x <= 1000; x++) {
      int va = (int) (x * 0.08);
      int vb = (int) (x * 0.1);
      if (va == a && vb == b) {
        ans = x;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_NM 100000

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, M, S, T;
vector<int> adj_list[MAX_NM + 1];
int d[MAX_NM + 1];
int d1[MAX_NM + 1];
int d2[MAX_NM + 1];

int solve() {
    for(int i = 0; i <= N; ++i)
        d[i] = d1[i] = d2[i] = INF;

    queue<ipair> que;
    que.push(make_pair(S, 0));
    d[S] = 0;

    while(!que.empty()) {
        ipair cur = que.front();    que.pop();

        int cur_d = cur.second;

        for(int i = 0; i < adj_list[cur.first].size(); ++i) {
            int next = adj_list[cur.first][i];
            
            if(next == T && (cur_d + 1) % 3 == 0)
                return (cur_d + 1) / 3;

            if((cur_d + 1) % 3 != 0) {
                if((cur_d + 1) % 3 == 1 && d1[next] <= cur_d + 1) {
                    continue;
                } else if ((cur_d + 1) % 3 == 2 && d2[next] <= cur_d + 1) {
                    continue;
                }

                if((cur_d + 1) % 3 == 1) {
                    d1[next] = cur_d + 1;
                } else if ((cur_d + 1) % 3 == 2 ) {
                    d2[next] = cur_d + 1;
                }
                que.push(make_pair(next, cur_d + 1));

            } else if(d[next] > cur_d + 1) {
                d[next] = cur_d + 1;
                que.push(make_pair(next, cur_d + 1));
                
            }

        }
    }

    if(d[T] == INF)
        return -1;
    else
        return d[T] / 2;
}

int main(int argc, char **argv) {
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        adj_list[u].push_back(v);
    }
    cin >> S >> T;

    int res = solve();
    
    cout << res << endl;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int n, vis[N], tab1[N], tab2[N], bat1[N], bat2[N], pos3[N], i, a, b, ok;
map<int, int> pos, pos2;

void go(int w) {
	vis[w] = 1;
	if (!vis[pos3[w]]) go(pos3[w]);
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) {
	scanf("%d", &tab1[i]);
	pos[tab1[i]] = i;
	tab2[i] = tab1[i];
}
for (i=0;i<n;i++) {
	scanf("%d", &bat1[i]);
	pos2[bat1[i]] = i;
	bat2[i] = bat1[i];
}
sort(tab2, tab2 + n);
sort(bat2, bat2 + n);
for (i=0;i<n;i++) if (tab2[i] > bat2[i]) {
	printf("No\n");
	return 0;
}
ok = 0;
for (i=0;i<n-1;i++) if (tab2[i + 1] <= bat2[i]) ok = 1;
if (ok) {
	printf("Yes\n");
	return 0;
}
for (i=0;i<n;i++) {
	a = pos[tab2[i]];
	b = pos2[bat2[i]];
	pos3[a] = b;
}
go(0);
for (i=0;i<n;i++) if (!vis[i]) {
	printf("Yes\n");
	return 0;
}
printf("No\n");
return 0;
}

Measured memory_bytes: 11904
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> void chmin(T &t, const T &f) { if (t > f) t = f; }
template <class T> void chmax(T &t, const T &f) { if (t < f) t = f; }

// (a | b) & c & d
template <size_t N> bool bitsetOpAny(const bitset<N> &a, const bitset<N> &b, const bitset<N> &c, const bitset<N> &d) {
  constexpr size_t nw = (N + 64 - 1) / 64;
  auto a_ = (const uint64_t *)&a;
  auto b_ = (const uint64_t *)&b;
  auto c_ = (const uint64_t *)&c;
  auto d_ = (const uint64_t *)&d;
  for (size_t i = 0; i < nw; ++i) {
    if ((a_[i] | b_[i]) & c_[i] & d_[i]) {
      return true;
    }
  }
  return false;
}


constexpr int MAX_N = 2005;

int N;
char A[MAX_N][MAX_N];

// bool B[MAX_N][MAX_N];
bitset<MAX_N> B[MAX_N];

// bool dp[MAX_N][MAX_N];
bitset<MAX_N> dp[MAX_N], DP[MAX_N];

int main() {
  for (; ~scanf("%d", &N); ) {
    for (int i = 2; i <= N; ++i) {
      scanf("%s", A[i] + 1);
    }
    for (int i = 0; i <= N + 1; ++i) {
      B[i].reset();
    }
    B[0][N + 1] = true;
    B[N + 1][0] = false;
    for (int i = 1; i <= N; ++i) {
      B[0][i] = false;
      B[i][0] = true;
      B[N + 1][i] = false;
      B[i][N + 1] = true;
    }
    for (int i = 1; i <= N; ++i) for (int j = 1; j < i; ++j) {
      B[i][j] = (A[i][j] == '1');
      B[j][i] = (A[i][j] == '0');
    }
    // memset(dp, 0, sizeof(dp));
    for (int i = 0; i <= N + 1; ++i) {
      dp[i].reset();
      DP[i].reset();
    }
    for (int i = 0; i <= N; ++i) {
      dp[i][i + 1] = true;
      DP[i + 1][i] = true;
    }
    for (int w = 2; w <= N + 1; ++w) {
      for (int i = 0; i <= N + 1 - w; ++i) {
        const int j = i + w;
        // for (int k = i + 1; k < j; ++k) {
          // if ((B[i][k] || B[j][k]) && dp[i][k] && dp[k][j]) {
            // dp[i][j] = true;
            // break;
          // }
        // }
        // dp[i][j] = DP[j][i] = ((B[i] | B[j]) & dp[i] & DP[j]).any();
        dp[i][j] = DP[j][i] = bitsetOpAny(B[i], B[j], dp[i], DP[j]);
      }
    }
// for(int i=0;i<=N+1;++i){for(int j=0;j<=N+1;++j){cout<<dp[i][j];}cout<<endl;}
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
      if (dp[0][i] && dp[i][N + 1]) {
        ++ans;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
using pii = pair<int, int>;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

map<ll, int> prime_factor(ll n) {
    ll a = 2;
    map<ll, int> ans;
    while (n >= a * a) {
        if (n % a == 0) {
            ++ans[a];
            n /= a;
        } else {
            a++;
        }
    }
    if (n > 1) ++ans[n];
    return ans;
}

long mod_pow(long x, long y) {
    if( y == 0 ) return 1;
    else if( y == 1 ) return x % MOD;
    else if( y % 2 == 0 ) return mod_pow(x, y/2) * mod_pow(x, y/2) % MOD;
    else return mod_pow(x, y/2) * mod_pow(x, y/2) % MOD * x % MOD;
}

ll combination(int n, int r){
    if( r == 0 ) return 1;
    ll numerator = 1, denominator = 1;
    inc(i, 1, r+1) {
        numerator *= n - i + 1;
        numerator %= MOD;
        denominator *= i;
        denominator %= MOD;
    }
    return numerator * mod_pow( denominator, MOD-2 ) % MOD;
}

signed main(){
    int N, M;
    cin >> N >> M;
    auto mp = prime_factor(M);
    ll ans = 1;
    for(auto& e : mp) {
        ans = ans * combination(N+e.second-1, e.second) % MOD;
    }
    cout << ans << nl;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  operator ll() const { return v; }
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return (mint)0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

mint mfact(int n) { // n! (mod MOD)
  static vector<mint> fact(1, 1);
  int pn = fact.size();
  if (pn < n + 1) {
    fact.resize(n + 1);
    for (int i = pn; i <= n; i++) fact[i] = fact[i - 1] * (mint)i;
  }
  return fact[n];
}
mint nPk(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k == 0) return 1;
  return mfact(n) * mfact(n - k).inv();
}
mint nCk(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k == 0) return 1;
  return mfact(n) * mfact(k).inv() * mfact(n - k).inv();
}

void solve() {
  int n, k;
  cin >> n >> k;
  k = min(k, n - 1);
  mint ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += nCk(n, i) * nCk(n - i - 1 + i, i);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 4480
# 1行目の入力を数値として扱う
n = int(input())
# 2行目の入力を数値のリストとして扱う
d = list(map(int, input().split()))
     
# 文字列の長さ分の配列を用意
ans = 0
     
# 
for i in range(0, n - 1):
    for j in range(0, n):
        if j <= i:
            continue
#        print(str(i) + "," + str(j))
        ans += d[i] * d[j]

# 答えの出力
print(ans)

Measured memory_bytes: 2940
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <cstdio> // printf
#include <map> // map

#include <set> // set

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);

  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    cin>>q[i];
  }
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a[i]=i+1;
  }
  map<vector<int>, int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
  return 0;
}
    
    
    
  
  
  
  
  
  
  
  
  
  
  


Measured memory_bytes: 5248
N,M,X,Y = list(map(int,input().split()))

data_x = list(map(int,input().split()))
data_y = list(map(int,input().split()))

max_x = max(data_x)
min_y = min(data_y)

if  max_x >= min_y:
	print('War')
elif X >= min_y:
    print('War')
elif Y <= max_x:
    print('War')
else:
    print('No War')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	ll x, y;
	cin >> x >> y;
	int cnt = 1;
	while (2*x <= y)
	{
		cnt++;
		x *= 2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
a=int(input())
time=[0]*a
for i in range(a):
    time[i]=int(input())
print(lcm(time))

Measured memory_bytes: 5100
N  = int(input())
vs = list(map(float, input().split()))

vs_sorted = sorted(vs)

pre_v = 0.0
for i, v in enumerate(vs_sorted):
    if i == 0:
        pre_v = v
        continue
    pre_v = (pre_v + v) / 2

print(pre_v)

Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;


// [a,b)の区間ごとにデータを保持する -1:=そこにデータはない
struct FileSystem{
  list<pair<pair<int, int>, int> >se;
  list<pair<pair<int, int>, int> >::iterator it, insertit;
  FileSystem(){
    se.push_back(make_pair(make_pair(0, 1000000005), -1));
  }
  void write(int id, int size){
    it = se.begin();
    while(it != se.end() && size > 0){
      if(it->second == -1){
	int sectorSize = it->first.second-it->first.first;
	if(sectorSize < size){
	  it->second = id;
	  size -= sectorSize;
	}else{
	  insertit = it; insertit++;
	  if(sectorSize > size) se.insert(insertit,make_pair(make_pair(it->first.first+size, it->first.second), -1));
	  it->second = id;
	  it->first.second = it->first.first + size;
	  size = 0;
	}
      }
      it++;
    }
  }
  void erase(int id){
    it = se.begin();
    while(it != se.end()){
      if(it->second == id) it->second = -1;
      it++;
    }
  }
  int ref(int adress){
    it = se.begin();
    while(it != se.end()){
      if(it->first.first <= adress && adress < it->first.second) return it->second;
      it++;
    }
    return -1;
  }
};

int main(){
  int N;
  while(scanf("%d",&N) && N){
    FileSystem fs;
    rep(i,N){
      char cmd[2];
      scanf("%s", cmd);
      if(cmd[0]=='W'){
	int l,s; scanf("%d%d",&l,&s);
	fs.write(l,s);
      }else if(cmd[0]=='D'){
	int l; scanf("%d",&l);
	fs.erase(l);
      }else if(cmd[0]=='R'){
	int p; scanf("%d", &p);
	printf("%d\n", fs.ref(p));
      }
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1412
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
 
int main()
{
		int n = 0;
		double average;
 
		cin >> n;
	
		vector<int> v(n);
 
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
		}
 
 
		if (n > 2)
		{
			sort(v.begin(), v.end());
 
			average = (v[0] + v[1]) / 2.0;
 
			for (int j = 2; j < n; j++)
			{
				average = (average + v[j]) / 2.0;
			}
		}
		else
		{
			average = (v[0] + v[1]) / 2.0;
		}
		
		cout << average << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int A[100000][2];
int main(){
	IOS;
	int n,k;
	cin >> n>>k;
	for (int i = 0; i < n; i++){
		cin >> A[i][0];
		A[i][1] = -1;
	}
	A[0][1] = 0;
	for (int i = 0; i < n; i++){
		for (int j = i; (j <= i + k) && (j < n); j++){
			int x = abs(A[i][0] - A[j][0]);
			if (A[j][1] == -1) A[j][1] = x + A[i][1];
			else{
				if (A[j][1]> x + A[i][1]) A[j][1] = x + A[i][1];
			}
		}
	}
	cout << A[n - 1][1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
int main() {
  int n;
  cin >> n;
  vector<string> ans;
  if(n == 1) {
    cout << 1 << endl;
    cout << "0" << endl;
  }
  else if(n == 2 || n == 3) {
    cout << 2 << endl;
    cout << "0" << endl;
    cout << "11" << endl;
  }
  else {
    while(n >= 2) {
      string s(n, '1');
      s.front() = '0';
      s.back() = '0';
      ans.emplace_back(s);
      n--;
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) cout << ans[i] << endl;
  }
}



Measured memory_bytes: 3276
import numpy as np

a = [input().split() for l in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
bingo = 0
wa = 0

a = np.array(a)

i = 0
while i < N:
    for j in range(3):
        for h in range(3):
            if int(a[j,h]) == int(b[i]):
                a[j,h] = 0
    i = i + 1

for j in range(3):
    wa = a[j,0] + a[j,1] + a[j,2]
    if int(wa) == 0:
        bingo = 1

for h in range(3):
    wa = a[0,h] + a[1,h] + a[2,h]
    if int(wa) == 0:
        bingo = 1

if int(a[0,0]+a[1,1]+a[2,2]) == 0:
    bingo = 1

if int(a[0,2]+a[1,1]+a[2,0]) == 0:
    bingo = 1
    
if bingo == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 12212
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {
  ll n, k, atmp, btmp, tmp;
  cin >> n >> k;
  map<ll, ll> ab;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> atmp >> btmp;
    if (ab.find(atmp) == ab.end()) ab[atmp] = 0;
    ab[atmp] = ab[atmp] + btmp;
    a[i] = atmp;
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());

  ll cnt = 0;
  for (int i = 0; i < a.size(); i++) {
    cnt += ab[a[i]];
    if (k <= cnt) {
      cout << a[i] << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

vector<int> pm;
vector<int> matsuzaki;
vector<bool> is_pm( 1000001, true );
int main() {
	int n, m;
	
	is_pm[ 0 ] = is_pm[ 1 ] = false;
	for ( int i = 2; i * i <= 1000000; i += 2 ) {
		if ( is_pm[ i ] ) {
			for ( int j = i * i; j <= 1000000; j += i ) {
				is_pm[ j ] = false;
				j += i * ( i % 2 );
			}
		}
		i -= i == 2;
	}
	while ( ~scanf( "%d %d", &n, &m ) && n != -1 && m != -1 ) {
		++n;
		n = max( 2, n );
		if ( 2 != n && n % 2 == 0 ) {
			n++;
		}
		for ( int i = n; i < 1000000; i += 2 ) {
			if ( is_pm[ i ] ) {
				pm.push_back( i );
				for ( int j = 0; j < pm.size(); j++ ) {
					if ( matsuzaki.size() >= m && matsuzaki[ m - 1 ] < pm[ j ] + i ) {
						break;
					}
					matsuzaki.push_back( pm[ j ] + i );
					sort( matsuzaki.begin(), matsuzaki.end() );
				}
				i -= i == 2;
			}
		}
		printf( "%d\n", matsuzaki[ --m ] );
		pm.clear();
		matsuzaki.clear();
	}
	return 0;
}

Measured memory_bytes: 1788
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,m,a[MAXN];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        a[u]^=1;a[v]^=1;
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]&1)
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int,int> vii;
typedef vector<ll,ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
int parent[200000],f[200000];
int findrep(int x){
    if(parent[x]==x) return parent[x];
    else{
        return findrep (parent[x]);
    }
}
void join (int a, int b){
    int repa,repb;
    repa = findrep(a);
    repb = findrep(b);
    if(repa>repb)swap(repa,repb);
    if(repa!=repb)parent[repb]=repa;
}
int n,m,ans;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)parent[i]=i;
    for(int i=1;i<=m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        join (a,b);
    }

    for(int i=1;i<=n;i++){
        int par = findrep(i);
        if(f[par]==0){f[par]++;ans++;}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int h, w, x, y, mul;
double res;

signed main() {
    cin >> w >> h >> x >> y;
    res = 1.*h*w / 2;
    mul = (x*2==w && y*2==h);
    printf("%.14lf %d\n", res, mul);
}


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

const long long zero = 0;

int main(){
    long long a, b, k;
    cin >> a >> b >> k;
    a -= k;
    if(a < 0){
        b += a;
    }

    cout << max(zero, a) << " " << max(zero, b) << endl;
 }

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main() {
  int h, w, m;
  cin >> h >> w >> m;
  set<P> s;
  vector<int> c1(h), c2(w);
  rep(mi, m) {
    int i, j;
    cin >> i >> j;
    --i, --j;
    ++c1[i], ++c2[j];
    s.insert({i, j});
  }

  ll ans = 0;
  int mx1 = 0, mx2 = 0;
  rep(i, h) mx1 = max(mx1, c1[i]);
  rep(i, w) mx2 = max(mx2, c2[i]);

  int cnt1 = 0;
  rep(i, h) cnt1 += (c1[i] == mx1);
  int cnt2 = 0;
  rep(i, w) cnt2 += (c2[i] == mx2);

  ll e = (ll)cnt1 * cnt2;
  for (auto p : s) {
    if (c1[p.first] == mx1 && c2[p.second] == mx2) --e;
  }

  ans = (ll)mx1 + mx2;
  if (e == 0) --ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19632
#include<bits/stdc++.h>
using namespace std;
const bool DEBUG = true;
#define coutd if(DEBUG) cout 
#define ff first
#define ss second
#define debug(x) cout << "> x:" << x << endl;
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(){
	ios::sync_with_stdio(0);
	string a, b;
	cin >> a >> b;
	int ans =0;
	for(int i=0; i<min(len(a), len(b)); ++i){
		if(a[i]==b[i]) ++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
int main(void){
  int n,a,max1=0,max2=0,count=0;
  std::vector<int> position_max1={};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    if(a>max1){
      max2=max1;
      max1=a;
      position_max1={i};
    }
    else if(a==max1){
      position_max1.push_back(i);
    }
    else if(max1>a && a>max2){
      max2=a;
    }
  }
  if(0==max2){
    max2=max1;
  }
  if(position_max1.size()>1){
    for(int i=0;i<n;i++){
      printf("%d\n",max1);
    }
  }
  else{
  	for(int i=0;i<n;i++){
      if(i==position_max1[count]){
        printf("%d\n",max2);
      	count++;
    	}
      else{
        printf("%d\n",max1);
      }
  	}
  }
}

Measured memory_bytes: 2548
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#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 Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

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

const int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),b(n),c(n);
    Rep(i,n) cin >> a[i];
    Rep(i,n) cin >> b[i];
    Rep(i,n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    vector<ll> m(n);
    Rep(i,n){
        auto x = lower_bound(all(a),b[i]);
        m[i] = x-a.begin();
    }
    Rep(i,n-1){
        m[i+1]+=m[i];
    }
    ll ans = 0;
    Rep(i,n){
        auto x = lower_bound(all(b),c[i]);
        if(x-b.begin()==0) continue;
        ans += m[x-b.begin()-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
N,T=map(int,input().split())
A=list(map(int,input().split()))


import heapq
import collections
hq=[]
heapq.heapify(hq)
heapq.heappush(hq,A[0])
tmp=0
table=collections.defaultdict(int)
for i in range(1,N):
  j=heapq.heappop(hq)
  table[A[i]-j]+=1
  tmp=max(tmp,A[i]-j)
  heapq.heappush(hq,j)
  heapq.heappush(hq,A[i])
print(table[tmp])

Measured memory_bytes: 20968
#include <iostream>

using namespace std;

long long int N, M;
long long int a[100001] = {};
long long int b[100001] = {};
long long int c[100001] = {};

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i];
		c[a[i]]++;
		c[b[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		if (c[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[][] = new int[3][3];
    int hit[][] = new int[3][3];
    for(int i = 0;i < 3;i++){
      for(int j = 0;j < 3;j++){
        a[i][j] = sc.nextInt();
      }
    }
    int n = sc.nextInt();
    for(int k = 0;k<n;k++){
      int b = sc.nextInt();
      for(int i = 0;i<3;i++){
        for(int j = 0;j < 3;j++){
          if(b == a[i][j]){
            hit[i][j] = 1;
          }
        }
      }
    }
    //こっからビンゴかたしかめる
    for(int i = 0;i<3;i++){
      if(hit[0][i] == 1 && hit[1][i] == 1 && hit[2][i] == 1){
        System.out.println("Yes");
        return;
      }
      if(hit[i][0] == 1 && hit[i][1] == 1 && hit[i][2] == 1){
        System.out.println("Yes");
        return;
      }
    }
    if(hit[0][0] == 1 && hit[1][1] == 1 && hit[2][2] == 1){
      System.out.println("Yes");
      return;
    }
    if(hit[0][2] == 1 && hit[1][1] == 1 && hit[2][0] == 1){
      System.out.println("Yes");
      return;
    }
    System.out.println("No");

  }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int n;
string s;
int r;


main()
{
    cin>>n>>s;
    for(auto u:s)
    {
        if(u=='R')
            r++;
    }
    n=s.size();
    int ans=0;
    for(int i=0;i<r;i++)
    {
        if(s[i]=='W')
            ans++;
    }
    cout<<ans;
}



Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<ll,int> P;
const ll INF=1000000000000LL;

int n,l;
ll a[100001];
bool used[100001];
priority_queue<P> pq;

void neighborSearch(int left,ll diff){
    if(used[left])
        return;
    if(left==0){
        if(a[left+1]<a[left]){
            pq.push(P(a[left]-diff,left));
            used[left]=true;
        }
    }
    else if(left==n-1){
        if(a[left]>a[left-1]){
            pq.push(P(a[left]-diff,left));
            used[left]=true;
        }
    }
    else{
        if(a[left]>a[left-1]&&a[left]>a[left+1]){
            used[left]=true;
            pq.push(P(a[left]-diff,left));
        }
    }
}

int main(){
    cin>>n>>l;
    fill(used,used+100001,false);
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 0; i < n; i++){
        if(i==0){
            if(a[i+1]<a[i]){
                pq.push(P(a[i],i));
                used[i]=true;
            }
        }
        else if(i==n-1){
            if(a[i]>a[i-1]){
                pq.push(P(a[i],i));
                used[i]=true;
            }
        }
        else{
            if(a[i]>a[i-1]&&a[i]>a[i+1]){
                used[i]=true;
                pq.push(P(a[i],i));
            }
        }
    }
    ll diff=0;
    while(pq.size()){
        // ÅÉàÁÆàå«¢àÌðæèo·
        ll length=0;
        vector<int> nums;
        while(pq.size()){
            if(length==0||length==pq.top().first){
                if(length==0)
                    diff+=l-pq.top().first;
                l=pq.top().first;
                length=l;
                // Ôði[
                nums.push_back(pq.top().second);
                a[pq.top().second]=-INF;
                pq.pop();
            }
            else
                break;
        }
        // æèoµ½àÌÌ¶EÉ évfªðð½·æ¤ÉÈÁ½©²×é
        for(int i = 0; i < nums.size(); i++){
            // ¶EÌvfð`FbN
            int left=nums[i]-1;
            int right=nums[i]+1;
            // ðð½µ½çA élªZ­µ½àÌð}ü
            if(left>=0)
                neighborSearch(left,diff);
            if(right<n)
                neighborSearch(right,diff);
        }
    }
    cout<<diff<<endl;

    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

int main() {
	char str[10];
	int A;
	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;
	scanf("%d", &A);
	
	for(int i=0;i<A;i++) {
		scanf("%s", str);
		if (strcmp(str, "AC") == 0) {
			AC++;
		} else if(strcmp(str, "WA")==0){
			WA++;
		} else if(strcmp(str, "TLE")==0){
			TLE++;
		} else if(strcmp(str, "RE")==0) {
			RE++;
		}
}
		
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE);
	
    return 0;
}

Measured memory_bytes: 1736
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def abc088_d():
    # 入力受け取り、周辺埋めパディング
    H, W = map(int, readline().split())
    grid = [['#'] * (W+2)]
    for ln in read().split():
        grid.append(['#'] + [c for c in ln.decode('UTF-8')] + ['#'])
    else:
        grid.append(['#'] * (W+2))

    # BFSで最短距離を求める
    from collections import deque
    dist = [[-1] * (W+2) for _ in range(H+2)]
    dist[1][1] = 0  # 初期化：パディングあるので(1,1)スタート
    que = deque([(1,1)])
    while que:
        # キューから取り出す
        r, c = que.popleft()
        # 上下左右を処理する
        for i, j in ((r-1, c), (r, c-1), (r, c+1), (r+1, c)):
            if grid[i][j] == '#': continue  # 壁
            if dist[i][j] != -1: continue  # 到達済み
            dist[i][j] = dist[r][c] + 1
            que.append((i,j))

    # 最短経路(距離+1)の個数分は残す、それ以外は黒マスに変えてよい
    if dist[H][W] == -1:
        ans = -1  # ゴールに到達できていない
    else:
        ans = sum([row.count('.') for row in grid])
        ans -= 1 + dist[H][W]
    print(ans)

abc088_d()

Measured memory_bytes: 3316
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
#include<set>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	int N;
	cin >> N;
	int buf;
	set<int> L;
	map<int, int> Lm;
	repeat(i, i < N) {
		scanf("%d", &buf);
		L.insert(buf);
		++Lm[buf];
	}

	if (N < 3) {
		cout << 0;
		return 0;
	}

	long ans = 0;
	set<int>::iterator itr,itr2,itr3;
	/*
	for (itr = L.begin(); itr != L.end(); ++itr) {
		cout << *(itr)<<',';
	}
	cout << '\n';
	*/
	for (itr = L.begin(); next(itr,2) != L.end(); itr++) {
		//LOG(*next(itr, 2));
		for (itr2 = next(itr); next(itr2,1) != L.end(); itr2++) {
			for (itr3 = next(itr2); itr3 != L.end(); itr3++) {
				//LOG(*itr);LOG(*itr2);LOG(*itr3);
				if (*itr3 < *itr + *itr2) {
					ans+=Lm[*itr]*Lm[*itr2]*Lm[*itr3];
				}
			}
		}
	}

	cout << ans;

	L.clear();
	Lm.clear();
	return 0;
}


int compare_int(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n,k;
    cin>>n>>k;
    map<int,int>m;
    while(k--) {
        int d;
        cin>>d;
        for(int i=0;i<d;i++) {
            int x;
            cin>>x;
            m[x] = 1;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++) {
        if(!m[i]) ans++;
    }
    cout<<ans<<"\n";
}

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

int main() {
  int D, N;
  cin >> D >> N;
  
  
  int MIN = 1;
  for (int i = 0; i < D; i++) {
    MIN *= 100;
  }
  
  int NEXT_MIN = MIN * 100;
  
  
  int count = 0;
  int ans = MIN;
  
  while (true) {  
    if (ans % MIN == 0 && ans % NEXT_MIN != 0) count++;
    if (count == N) {
      cout << ans << endl;
      return 0;
    }
    ans += MIN;
  }
}


Measured memory_bytes: 3580
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	char a, b; cin >> a >> b;

	cout << ((a=='H' ^ !(b=='H'))?'H':'D') << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using pint = pair<ll, ll>;

int main(){
    ll a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    for (int i = 0; i<5; i++){
        if(a[i]==0){
          cout << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
fun main(args: Array<String>) {

    val (routesCount, maxTime) = readLine()!!.split(" ").map(String::toInt)

    val list = mutableListOf<List<Int>>()

    for (i in 1..routesCount)
        list.add(readLine()!!.split(" ").map(String::toInt))

    val result = list.filter {
        it[1] <= maxTime
    }.minBy {
        it[0]
    }

    println(if (result == null) "TLE" else result[0])
}

Measured memory_bytes: 38184
arr = []
S = str(input())
T = str(input())
C = ""

for i1 in range(0, len(S)):
  for i2 in range(1, len(S)):
    C=C+S[i2]
  C=C+S[0]
  arr.append(C)
  S=C
  C=""

if T in arr:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int c[1000],s[1000],f[1000];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    for(int i=0; i<n-1; i++)
    {
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=0; i<n-1; i++)
    {
        int sum=s[i];
        for(int j=i+1; j<n; j++)
        {
            sum+=c[j-1];
            if(j==n-1)
                break;
            if(s[j]>sum)
                sum+=s[j]-sum;
            else{
                int cur=s[j];
                while(cur<sum)
                    cur+=f[j];
                sum+=cur-sum;
            }
        }
        cout<<sum<<endl;
    }
    cout<<"0"<<endl;

    return 0;
}


Measured memory_bytes: 3676
import math
N, M = list(map(int, input().split()))
q = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

result_count = 0
for i in range(2**N):
    flag = True
    for idx, j in enumerate(q):  # 電球の数分ループ
        tmp_count = 0
        for k in j[1:]:
            if i >> (k - 1) & 1 == 1:
                tmp_count += 1
        if tmp_count % 2 != p[idx]:
            flag = False
    result_count += 1 if flag else 0

print(result_count)


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

int main(void){
    // Your code here!
    int N;
    cin >> N;
    int d[N];
    for(int i=0; i<N; i++) cin >> d[i];
    
    int ans = 1;
    sort(d, d+N);
    
    for(int i=0; i<N-1; i++){
        if (d[i] < d[i+1]){
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn @Int
  -- 2 <= n <= 2*10^5
  xs <- U.map fromIntegral . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let loop :: Int -> Int64 -> Int64 -> Int64 -> (Int64, Int64, Int64)
      loop !k !a !b !c
        | k > n `quot` 2 = (a, b, c)
        | otherwise =
          -- k <= n `quot` 2
          let a' = a + xs U.! (2*k-2)
              b' = max a' (b + xs U.! (2*k-1))
              c' = if 2*k < n then max b' (c + xs U.! (2*k)) else b'
          in loop (k+1) a' b' c'
      (_,y,z) = loop 1 0 0 0
  print $ if even n then y else z


Measured memory_bytes: 11988
import itertools

def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    a = b = 0
    for i, p in enumerate(itertools.permutations(range(1, N+1))):
        if p == P:
            a = i
        if p == Q:
            b = i
    print(abs(a-b))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38512